Package org.eclipse.jface.text.source
Class OverviewRuler
java.lang.Object
org.eclipse.jface.text.source.OverviewRuler
- All Implemented Interfaces:
IOverviewRuler
,IOverviewRulerExtension
,IVerticalRuler
,IVerticalRulerInfo
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
ConstructorDescriptionOverviewRuler
(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 TypeMethodDescriptionvoid
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.createControl
(Composite parent, ITextViewer textViewer) Creates the ruler's SWT control.int
Returns the height of the visual presentation of an annotation in this overview ruler.Returns the ruler's SWT control.Returns this rulers header control.int
Returns the line number of the last mouse button activity.getModel()
Returns the current annotation model of this ruler ornull
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.
-
Constructor Details
-
Method Details
-
getControl
Description copied from interface:IVerticalRulerInfo
Returns the ruler's SWT control.- Specified by:
getControl
in interfaceIVerticalRulerInfo
- 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 interfaceIVerticalRulerInfo
- Returns:
- the width of this ruler's control
-
setModel
Description copied from interface:IVerticalRuler
Associates an annotation model with this ruler. A valuenull
is acceptable and clears the ruler.- Specified by:
setModel
in interfaceIVerticalRuler
- Parameters:
model
- the new annotation model, may benull
-
createControl
Description copied from interface:IVerticalRuler
Creates the ruler's SWT control.- Specified by:
createControl
in interfaceIVerticalRuler
- Parameters:
parent
- the parent control of the ruler's controltextViewer
- 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 interfaceIVerticalRuler
-
addAnnotationType
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 interfaceIOverviewRuler
- Parameters:
annotationType
- the annotation type
-
removeAnnotationType
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 interfaceIOverviewRuler
- Parameters:
annotationType
- the annotation type
-
setAnnotationTypeLayer
Description copied from interface:IOverviewRuler
Sets the drawing layer for the given annotation type in this overview ruler.- Specified by:
setAnnotationTypeLayer
in interfaceIOverviewRuler
- Parameters:
annotationType
- the annotation typelayer
- the drawing layer
-
setAnnotationTypeColor
Description copied from interface:IOverviewRuler
Sets the color for the given annotation type in this overview ruler.- Specified by:
setAnnotationTypeColor
in interfaceIOverviewRuler
- Parameters:
annotationType
- the annotation typecolor
- 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 interfaceIVerticalRulerInfo
- 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 interfaceIVerticalRulerInfo
- 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
Description copied from interface:IVerticalRuler
Returns the current annotation model of this ruler ornull
if the ruler has no model.- Specified by:
getModel
in interfaceIVerticalRuler
- 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 interfaceIOverviewRuler
- 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 interfaceIOverviewRuler
- Parameters:
y
- the y-coordinate- Returns:
true
if there is an annotation,false
otherwise
-
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 interfaceIOverviewRuler
- Returns:
- the header control of this overview ruler.
-
addHeaderAnnotationType
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 interfaceIOverviewRuler
- Parameters:
annotationType
- the annotation type to be tracked
-
removeHeaderAnnotationType
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 interfaceIOverviewRuler
- 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 interfaceIOverviewRulerExtension
- Parameters:
useSaturatedColor
-true
if saturated colors should be used,false
otherwise- Since:
- 3.8
-