# Class OverviewRuler

java.lang.Object
org.eclipse.jface.text.source.OverviewRuler

All Implemented Interfaces:
  `IOverviewRuler, IOverviewRulerExtension, IVerticalRuler, IVerticalRulerInfo`

public class OverviewRuler extends Object implements IOverviewRulerExtension, IOverviewRuler
Ruler presented next to a source viewer showing all annotations of the viewer's annotation model in a compact format. The ruler has the same height as the source viewer.

This overview ruler uses non-saturated colors unless `setUseSaturatedColors(boolean)` gets called.

Clients usually instantiate and configure objects of this class.

Since:
  2.1

## Constructor Summary

Constructors
Constructor
Description
`OverviewRuler(IAnnotationAccess annotationAccess, int width, ISharedTextColors sharedColors)`
Constructs a overview ruler of the given width using the given annotation access and the given color manager.
`OverviewRuler(IAnnotationAccess annotationAccess, int width, ISharedTextColors sharedColors, boolean discolorTemporaryAnnotation)`
Constructs a overview ruler of the given width using the given annotation access and the given color manager.

## Method Summary

Modifier and Type
Method
Description
`void`
`addAnnotationType(Object annotationType)`
Adds the given annotation type to this overview ruler.
`void`
`addHeaderAnnotationType(Object annotationType)`
Adds the given annotation type to the header of this ruler.
`Control`
`createControl(Composite parent, ITextViewer textViewer)`
Creates the ruler's SWT control.
`int`
`getAnnotationHeight()`
Returns the height of the visual presentation of an annotation in this overview ruler.
`Control`
`getControl()`
Returns the ruler's SWT control.
`Control`
`getHeaderControl()`
Returns this rulers header control.
`int`
`getLineOfLastMouseButtonActivity()`
Returns the line number of the last mouse button activity.
`IAnnotationModel`
`getModel()`
Returns the current annotation model of this ruler or `null` if the ruler has no model.
`int`
`getWidth()`
Returns the width of this ruler's control.
`boolean`
`hasAnnotation(int y)`
Returns whether there is an annotation an the given vertical coordinate.
`void`
`removeAnnotationType(Object annotationType)`
Removes the given annotation type from this overview ruler.
`void`
`removeHeaderAnnotationType(Object annotationType)`
Removes the given annotation type from the header of this ruler.
`void`
`setAnnotationTypeColor(Object annotationType, Color color)`
Sets the color for the given annotation type in this overview ruler.
`void`
`setAnnotationTypeLayer(Object annotationType, int layer)`
Sets the drawing layer for the given annotation type in this overview ruler.
`void`
`setModel(IAnnotationModel model)`
Associates an annotation model with this ruler.
`void`
`setUseSaturatedColors(boolean useSaturatedColor)`
Sets whether to use saturated colors in the overview ruler.
`int`
`toDocumentLineNumber(int y_coordinate)`
Translates a y-coordinate of the ruler's SWT control into the according line number of the document of the connected text viewer.
`void`
`update()`
Forces the vertical ruler to synchronize itself with its annotation model and its viewer's view port.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### OverviewRuler

public OverviewRuler(IAnnotationAccess annotationAccess, int width, ISharedTextColors sharedColors)
Constructs a overview ruler of the given width using the given annotation access and the given color manager.

Note: As of 3.4, temporary annotations are no longer discolored. Use `OverviewRuler(IAnnotationAccess, int, ISharedTextColors, boolean)` if you want to keep the old behavior.

Parameters:
  `annotationAccess` - the annotation access
  `width` - the width of the vertical ruler
  `sharedColors` - the color manager

### OverviewRuler

public OverviewRuler(IAnnotationAccess annotationAccess, int width, ISharedTextColors sharedColors, boolean discolorTemporaryAnnotation)
Constructs a overview ruler of the given width using the given annotation access and the given color manager.

Parameters:
  `annotationAccess` - the annotation access
  `width` - the width of the vertical ruler
  `sharedColors` - the color manager
  `discolorTemporaryAnnotation` - `true` if temporary annotations should be discolored
Since:
  3.4

## Method Details

### getControl

public Control getControl()
Description copied from interface: `IVerticalRulerInfo`
Returns the ruler's SWT control.

Specified by:
  `getControl` in interface `IVerticalRulerInfo`
Returns:
  the ruler's SWT control

### getWidth

public int getWidth()
Description copied from interface: `IVerticalRulerInfo`
Returns the width of this ruler's control.

Specified by:
  `getWidth` in interface `IVerticalRulerInfo`
Returns:
  the width of this ruler's control

### setModel

public void setModel(IAnnotationModel model)
Description copied from interface: `IVerticalRuler`
Associates an annotation model with this ruler. A value `null` is acceptable and clears the ruler.

Specified by:
  `setModel` in interface `IVerticalRuler`
Parameters:
  `model` - the new annotation model, may be `null`

### createControl

public Control createControl(Composite parent, ITextViewer textViewer)
Description copied from interface: `IVerticalRuler`
Creates the ruler's SWT control.

Specified by:
  `createControl` in interface `IVerticalRuler`
Parameters:
  `parent` - the parent control of the ruler's control
  `textViewer` - the text viewer to which this ruler belongs
Returns:
  the ruler's SWT control

### update

public void update()
Description copied from interface: `IVerticalRuler`
Forces the vertical ruler to synchronize itself with its annotation model and its viewer's view port.

Specified by:
  `update` in interface `IVerticalRuler`

### addAnnotationType

public void addAnnotationType(Object annotationType)
Description copied from interface: `IOverviewRuler`
Adds the given annotation type to this overview ruler. Starting with this call, annotations of the given type are shown in the overview ruler.

Specified by:
  `addAnnotationType` in interface `IOverviewRuler`
Parameters:
  `annotationType` - the annotation type

### removeAnnotationType

public void removeAnnotationType(Object annotationType)
Description copied from interface: `IOverviewRuler`
Removes the given annotation type from this overview ruler. Annotations of the given type are no longer shown in the overview ruler.

Specified by:
  `removeAnnotationType` in interface `IOverviewRuler`
Parameters:
  `annotationType` - the annotation type

### setAnnotationTypeLayer

public void setAnnotationTypeLayer(Object annotationType, int layer)
Description copied from interface: `IOverviewRuler`
Sets the drawing layer for the given annotation type in this overview ruler.

Specified by:
  `setAnnotationTypeLayer` in interface `IOverviewRuler`
Parameters:
  `annotationType` - the annotation type
  `layer` - the drawing layer

### setAnnotationTypeColor

public void setAnnotationTypeColor(Object annotationType, Color color)
Description copied from interface: `IOverviewRuler`
Sets the color for the given annotation type in this overview ruler.

Specified by:
  `setAnnotationTypeColor` in interface `IOverviewRuler`
Parameters:
  `annotationType` - the annotation type
  `color` - the color

### getLineOfLastMouseButtonActivity

public int getLineOfLastMouseButtonActivity()
Description copied from interface: `IVerticalRulerInfo`
Returns the line number of the last mouse button activity. Based on the input document of the connected text viewer.

Specified by:
  `getLineOfLastMouseButtonActivity` in interface `IVerticalRulerInfo`
Returns:
  the line number of the last mouse button activity or `-1` if the last mouse activity does not correspond to a valid document line

### toDocumentLineNumber

public int toDocumentLineNumber(int y_coordinate)
Description copied from interface: `IVerticalRulerInfo`
Translates a y-coordinate of the ruler's SWT control into the according line number of the document of the connected text viewer.

Specified by:
  `toDocumentLineNumber` in interface `IVerticalRulerInfo`
Parameters:
  `y_coordinate` - a y-coordinate of the ruler's SWT control
Returns:
  the line number of that coordinate or `-1` if that coordinate does not correspond to a valid document line

### getModel

public IAnnotationModel getModel()
Description copied from interface: `IVerticalRuler`
Returns the current annotation model of this ruler or `null` if the ruler has no model.

Specified by:
  `getModel` in interface `IVerticalRuler`
Returns:
  this ruler's annotation model or `null` if there is no model

### getAnnotationHeight

public int getAnnotationHeight()
Description copied from interface: `IOverviewRuler`
Returns the height of the visual presentation of an annotation in this overview ruler. Assumes that all annotations are represented using the same height.

Specified by:
  `getAnnotationHeight` in interface `IOverviewRuler`
Returns:
  the visual height of an annotation

### hasAnnotation

public boolean hasAnnotation(int y)
Description copied from interface: `IOverviewRuler`
Returns whether there is an annotation an the given vertical coordinate. This method takes the compression factor of the overview ruler into account.

Specified by:
  `hasAnnotation` in interface `IOverviewRuler`
Parameters:
  `y` - the y-coordinate
Returns:
  `true` if there is an annotation, `false` otherwise

### getHeaderControl

public Control getHeaderControl()
Description copied from interface: `IOverviewRuler`
Returns this rulers header control. This is the little area between the top of the text widget and the top of this overview ruler.

Specified by:
  `getHeaderControl` in interface `IOverviewRuler`
Returns:
  the header control of this overview ruler.

### addHeaderAnnotationType

public void addHeaderAnnotationType(Object annotationType)
Description copied from interface: `IOverviewRuler`
Adds the given annotation type to the header of this ruler. Starting with this call, the presence of annotations is tracked and the header is drawn in the configured color.

Specified by:
  `addHeaderAnnotationType` in interface `IOverviewRuler`
Parameters:
  `annotationType` - the annotation type to be tracked

### removeHeaderAnnotationType

public void removeHeaderAnnotationType(Object annotationType)
Description copied from interface: `IOverviewRuler`
Removes the given annotation type from the header of this ruler. The presence of annotations of the given type is no longer tracked and the header is drawn in the default color, depending on the other configured configured annotation types.

Specified by:
  `removeHeaderAnnotationType` in interface `IOverviewRuler`
Parameters:
  `annotationType` - the annotation type to be removed

### setUseSaturatedColors

public void setUseSaturatedColors(boolean useSaturatedColor)
Sets whether to use saturated colors in the overview ruler.

The initial value is defined by the ruler implementation.

Specified by:
  `setUseSaturatedColors` in interface `IOverviewRulerExtension`
Parameters:
  `useSaturatedColor` - `true` if saturated colors should be used, `false` otherwise
Since:
  3.8