Class AbstractRulerColumn
- All Implemented Interfaces:
- IVerticalRulerColumn,- IVerticalRulerInfo,- IVerticalRulerInfoExtension
IVerticalRulerColumn that
 uses a Canvas to draw the ruler contents and which
 handles scrolling and mouse selection.
 Painting
Subclasses can hook into the paint loop at three levels:- Override paint(GC, ILineRange)to control the entire painting of the ruler.
- Override paintLine(GC, int, int, int, int)to control the painting of a line.
- Leave the painting to the default implementation, but override computeBackground(int),computeForeground(int)andcomputeText(int)to specify the ruler appearance for a line.
Invalidation
Subclasses may callredraw() to mark the entire ruler as needing to be redrawn.
 Alternatively, use redraw(ILineRange) to only invalidate a certain line range, for
 example due to changes to the display model.
 Configuration
Subclasses can set the following properties. Setting them may trigger redrawing.- The fontused to draw text inpaintLine(GC, int, int, int, int).
- The horizontal text insetfor text drawn.
- The default background colorof the ruler.
- The widthof the ruler.
- Since:
- 3.3
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidRegisters a vertical ruler listener to be informed if an annotation gets selected on the vertical ruler.protected ColorcomputeBackground(int line) Returns the background color drawn for a certain line bypaintLine(GC, int, int, int, int).protected ColorcomputeForeground(int line) Returns the foreground color drawn for a certain line bypaintLine(GC, int, int, int, int).protected StringcomputeText(int line) Returns the text to be drawn for a certain line bypaintLine(GC, int, int, int, int),nullfor no text.createControl(CompositeRuler parentRuler, Composite parentControl) Creates the column's SWT control.voiddispose()Disposes this ruler column.protected intReturns the SWT style bits used when creating the ruler canvas.final ControlReturns the column's SWT control.protected final ColorReturns the background color.protected final FontgetFont()Returns the current font.getHover()Returns the hover for this vertical ruler (column).final intReturns the line number of the last mouse button activity.final IAnnotationModelgetModel()Returns the model currently used by the receiver.protected final CompositeRulerReturns the parent ruler,nullbeforecreateControl(CompositeRuler, Composite)has been called.protected final intReturns the text inset for text drawn bypaintLine(GC, int, int, int, int).final intgetWidth()Returns the width of this column's control.protected voidpaint(GC gc, ILineRange lines) Paints the ruler.protected voidPaints the ruler representation of a single line.final voidredraw()Redraws this column.protected final voidredraw(ILineRange lines) Marks the region covered bylinesas needing to be redrawn.voidRemoves a previously registered listener.protected final voidsetDefaultBackground(Color background) Sets the default background color for this column.final voidSets the font of this ruler column.protected final voidsetHover(IAnnotationHover hover) Sets the annotation hover.voidsetModel(IAnnotationModel model) Associates an annotation model with this ruler column.protected final voidsetTextInset(int textInset) Sets the text inset (padding) used to draw text inpaintLine(GC, int, int, int, int).protected final voidsetWidth(int width) The new width in pixels.final 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.
- 
Constructor Details- 
AbstractRulerColumnprotected AbstractRulerColumn()Creates a new ruler.
 
- 
- 
Method Details- 
createControlDescription copied from interface:IVerticalRulerColumnCreates the column's SWT control.- Specified by:
- createControlin interface- IVerticalRulerColumn
- Parameters:
- parentRuler- the parent ruler of this column
- parentControl- the control of the parent ruler
- Returns:
- the column's SWT control
 
- 
getCanvasStyleprotected int getCanvasStyle()Returns the SWT style bits used when creating the ruler canvas.The default implementation returns SWT.NO_BACKGROUND.Clients may reimplement this method to create a canvas with their desired style bits. - Returns:
- the SWT style bits, or SWT.NONEif none
 
- 
getControlDescription copied from interface:IVerticalRulerColumnReturns the column's SWT control.- Specified by:
- getControlin interface- IVerticalRulerColumn
- Specified by:
- getControlin interface- IVerticalRulerInfo
- Returns:
- the column's SWT control
 
- 
setWidthprotected final void setWidth(int width) The new width in pixels. TheDEFAULT_WIDTHconstant specifies the default width.- Parameters:
- width- the new width
 
- 
getWidthpublic final int getWidth()Description copied from interface:IVerticalRulerColumnReturns the width of this column's control.- Specified by:
- getWidthin interface- IVerticalRulerColumn
- Specified by:
- getWidthin interface- IVerticalRulerInfo
- Returns:
- the width of this column's control
 
- 
getParentRulerReturns the parent ruler,nullbeforecreateControl(CompositeRuler, Composite)has been called.- Returns:
- the parent ruler or null
 
- 
setFontSets the font of this ruler column.- Specified by:
- setFontin interface- IVerticalRulerColumn
- Parameters:
- font- the font or- nullto use the default font
 
- 
getFontReturns the current font. If a font has not been explicitly set, the widget's font is returned.- Returns:
- the font used to render text on the ruler.
 
- 
setTextInsetprotected final void setTextInset(int textInset) Sets the text inset (padding) used to draw text inpaintLine(GC, int, int, int, int).- Parameters:
- textInset- the new text inset
 
- 
getTextInsetprotected final int getTextInset()Returns the text inset for text drawn bypaintLine(GC, int, int, int, int). TheDEFAULT_TEXT_INSETconstant specifies the default inset in pixels.- Returns:
- the text inset for text
 
- 
setModelDescription copied from interface:IVerticalRulerColumnAssociates an annotation model with this ruler column. A valuenullis acceptable and clears the ruler.- Specified by:
- setModelin interface- IVerticalRulerColumn
- Parameters:
- model- the new annotation model, may be- null
 
- 
getModelDescription copied from interface:IVerticalRulerInfoExtensionReturns the model currently used by the receiver.- Specified by:
- getModelin interface- IVerticalRulerInfoExtension
- Returns:
- the model of the receiver, or nullif no model is installed.
 
- 
setDefaultBackgroundSets the default background color for this column. The default background is used as default implementation ofcomputeBackground(int)and also to paint the area of the ruler that does not correspond to any lines (when the viewport is not entirely filled with lines).- Parameters:
- background- the default background color,- nullto use the text widget's background
 
- 
getDefaultBackgroundReturns the background color. May returnnullif the system is shutting down.- Returns:
- the background color
 
- 
setHoverSets the annotation hover.- Parameters:
- hover- the annotation hover,- nullfor no hover
 
- 
getHoverDescription copied from interface:IVerticalRulerInfoExtensionReturns the hover for this vertical ruler (column).- Specified by:
- getHoverin interface- IVerticalRulerInfoExtension
- Returns:
- the hover for this column
 
- 
disposepublic void dispose()Disposes this ruler column.Subclasses may extend this method. Clients who created this column are responsible to call this method once the column is no longer used. 
- 
redrawpublic final void redraw()Description copied from interface:IVerticalRulerColumnRedraws this column.- Specified by:
- redrawin interface- IVerticalRulerColumn
 
- 
redrawMarks the region covered bylinesas needing to be redrawn.- Parameters:
- lines- the lines to be redrawn in document coordinates
 
- 
paintPaints the ruler. Note thatlinesreference widget line indices, and thatlinesmay not cover the entire viewport, but only the lines that need to be painted. The lines may not be entirely visible.Subclasses may replace or extend. The default implementation calls paintLine(GC, int, int, int, int)for every visible line.- Parameters:
- gc- the graphics context to paint on
- lines- the lines to paint in widget coordinates
 
- 
paintLinePaints the ruler representation of a single line.Subclasses may replace or extend. The default implementation draws the text obtained by computeText(int)in theforeground colorand fills the entire width using thebackground color. The text is drawngetTextInset()pixels to the right of the left border.- Parameters:
- gc- the graphics context to paint on
- modelLine- the model line (based on document coordinates)
- widgetLine- the line in the text widget corresponding to- modelLine
- linePixel- the first y-pixel of the widget line
- lineHeight- the line height in pixels
 
- 
computeTextReturns the text to be drawn for a certain line bypaintLine(GC, int, int, int, int),nullfor no text. The default implementation returnsnull.Subclasses may replace or extend. - Parameters:
- line- the document line number
- Returns:
- the text to be drawn for the given line, nullfor no text
 
- 
computeBackgroundReturns the background color drawn for a certain line bypaintLine(GC, int, int, int, int). The default implementation returnsgetDefaultBackground().Subclasses may replace or extend. - Parameters:
- line- the document line number
- Returns:
- the background color for drawn for the given line
 
- 
computeForegroundReturns the foreground color drawn for a certain line bypaintLine(GC, int, int, int, int). The default implementation returns aSWT.COLOR_DARK_GRAYcolor.Subclasses may replace or extend. - Parameters:
- line- the document line number
- Returns:
- the foreground color for drawn for the given line
 
- 
getLineOfLastMouseButtonActivitypublic final 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 interface- IVerticalRulerInfo
- Returns:
- the line number of the last mouse button activity or -1if the last mouse activity does not correspond to a valid document line
 
- 
toDocumentLineNumberpublic final 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 interface- IVerticalRulerInfo
- 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
 
- 
addVerticalRulerListenerDescription copied from interface:IVerticalRulerInfoExtensionRegisters a vertical ruler listener to be informed if an annotation gets selected on the vertical ruler.- Specified by:
- addVerticalRulerListenerin interface- IVerticalRulerInfoExtension
- Parameters:
- listener- the listener to be informed
 
- 
removeVerticalRulerListenerDescription copied from interface:IVerticalRulerInfoExtensionRemoves a previously registered listener. Iflisteneris not registered with the receiver, calling this method has no effect.- Specified by:
- removeVerticalRulerListenerin interface- IVerticalRulerInfoExtension
- Parameters:
- listener- the listener to be removed
 
 
-