Package org.eclipse.jface.text.source
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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAnnotationType(Object annotationType)Adds the given annotation type to this overview ruler.voidaddHeaderAnnotationType(Object annotationType)Adds the given annotation type to the header of this ruler.ControlcreateControl(Composite parent, ITextViewer textViewer)Creates the ruler's SWT control.intgetAnnotationHeight()Returns the height of the visual presentation of an annotation in this overview ruler.ControlgetControl()Returns the ruler's SWT control.ControlgetHeaderControl()Returns this rulers header control.intgetLineOfLastMouseButtonActivity()Returns the line number of the last mouse button activity.IAnnotationModelgetModel()Returns the current annotation model of this ruler ornullif the ruler has no model.intgetWidth()Returns the width of this ruler's control.booleanhasAnnotation(int y)Returns whether there is an annotation an the given vertical coordinate.voidremoveAnnotationType(Object annotationType)Removes the given annotation type from this overview ruler.voidremoveHeaderAnnotationType(Object annotationType)Removes the given annotation type from the header of this ruler.voidsetAnnotationTypeColor(Object annotationType, Color color)Sets the color for the given annotation type in this overview ruler.voidsetAnnotationTypeLayer(Object annotationType, int layer)Sets the drawing layer for the given annotation type in this overview ruler.voidsetModel(IAnnotationModel model)Associates an annotation model with this ruler.voidsetUseSaturatedColors(boolean useSaturatedColor)Sets whether to use saturated colors in the overview ruler.inttoDocumentLineNumber(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.voidupdate()Forces the vertical ruler to synchronize itself with its annotation model and its viewer's view port.
-
-
-
Constructor Detail
-
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 accesswidth- the width of the vertical rulersharedColors- 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 accesswidth- the width of the vertical rulersharedColors- the color managerdiscolorTemporaryAnnotation-trueif temporary annotations should be discolored- Since:
- 3.4
-
-
Method Detail
-
getControl
public Control getControl()
Description copied from interface:IVerticalRulerInfoReturns the ruler's SWT control.- Specified by:
getControlin interfaceIVerticalRulerInfo- Returns:
- the ruler's SWT control
-
getWidth
public int getWidth()
Description copied from interface:IVerticalRulerInfoReturns the width of this ruler's control.- Specified by:
getWidthin interfaceIVerticalRulerInfo- Returns:
- the width of this ruler's control
-
setModel
public void setModel(IAnnotationModel model)
Description copied from interface:IVerticalRulerAssociates an annotation model with this ruler. A valuenullis acceptable and clears the ruler.- Specified by:
setModelin interfaceIVerticalRuler- Parameters:
model- the new annotation model, may benull
-
createControl
public Control createControl(Composite parent, ITextViewer textViewer)
Description copied from interface:IVerticalRulerCreates the ruler's SWT control.- Specified by:
createControlin 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:IVerticalRulerForces the vertical ruler to synchronize itself with its annotation model and its viewer's view port.- Specified by:
updatein interfaceIVerticalRuler
-
addAnnotationType
public void addAnnotationType(Object annotationType)
Description copied from interface:IOverviewRulerAdds 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:
addAnnotationTypein interfaceIOverviewRuler- Parameters:
annotationType- the annotation type
-
removeAnnotationType
public void removeAnnotationType(Object annotationType)
Description copied from interface:IOverviewRulerRemoves the given annotation type from this overview ruler. Annotations of the given type are no longer shown in the overview ruler.- Specified by:
removeAnnotationTypein interfaceIOverviewRuler- Parameters:
annotationType- the annotation type
-
setAnnotationTypeLayer
public void setAnnotationTypeLayer(Object annotationType, int layer)
Description copied from interface:IOverviewRulerSets the drawing layer for the given annotation type in this overview ruler.- Specified by:
setAnnotationTypeLayerin interfaceIOverviewRuler- Parameters:
annotationType- the annotation typelayer- the drawing layer
-
setAnnotationTypeColor
public void setAnnotationTypeColor(Object annotationType, Color color)
Description copied from interface:IOverviewRulerSets the color for the given annotation type in this overview ruler.- Specified by:
setAnnotationTypeColorin interfaceIOverviewRuler- Parameters:
annotationType- the annotation typecolor- the color
-
getLineOfLastMouseButtonActivity
public int getLineOfLastMouseButtonActivity()
Description copied from interface:IVerticalRulerInfoReturns the line number of the last mouse button activity. Based on the input document of the connected text viewer.- Specified by:
getLineOfLastMouseButtonActivityin interfaceIVerticalRulerInfo- Returns:
- the line number of the last mouse button activity or
-1if the last mouse activity does not correspond to a valid document line
-
toDocumentLineNumber
public int toDocumentLineNumber(int y_coordinate)
Description copied from interface:IVerticalRulerInfoTranslates a y-coordinate of the ruler's SWT control into the according line number of the document of the connected text viewer.- Specified by:
toDocumentLineNumberin interfaceIVerticalRulerInfo- Parameters:
y_coordinate- a y-coordinate of the ruler's SWT control- Returns:
- the line number of that coordinate or
-1if that coordinate does not correspond to a valid document line
-
getModel
public IAnnotationModel getModel()
Description copied from interface:IVerticalRulerReturns the current annotation model of this ruler ornullif the ruler has no model.- Specified by:
getModelin interfaceIVerticalRuler- Returns:
- this ruler's annotation model or
nullif there is no model
-
getAnnotationHeight
public int getAnnotationHeight()
Description copied from interface:IOverviewRulerReturns 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:
getAnnotationHeightin interfaceIOverviewRuler- Returns:
- the visual height of an annotation
-
hasAnnotation
public boolean hasAnnotation(int y)
Description copied from interface:IOverviewRulerReturns whether there is an annotation an the given vertical coordinate. This method takes the compression factor of the overview ruler into account.- Specified by:
hasAnnotationin interfaceIOverviewRuler- Parameters:
y- the y-coordinate- Returns:
trueif there is an annotation,falseotherwise
-
getHeaderControl
public Control getHeaderControl()
Description copied from interface:IOverviewRulerReturns 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:
getHeaderControlin interfaceIOverviewRuler- Returns:
- the header control of this overview ruler.
-
addHeaderAnnotationType
public void addHeaderAnnotationType(Object annotationType)
Description copied from interface:IOverviewRulerAdds 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:
addHeaderAnnotationTypein interfaceIOverviewRuler- Parameters:
annotationType- the annotation type to be tracked
-
removeHeaderAnnotationType
public void removeHeaderAnnotationType(Object annotationType)
Description copied from interface:IOverviewRulerRemoves 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:
removeHeaderAnnotationTypein 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:
setUseSaturatedColorsin interfaceIOverviewRulerExtension- Parameters:
useSaturatedColor-trueif saturated colors should be used,falseotherwise- Since:
- 3.8
-
-