Package org.eclipse.jface.text.source
Class LineNumberRulerColumn
java.lang.Object
org.eclipse.jface.text.source.LineNumberRulerColumn
- All Implemented Interfaces:
IVerticalRulerColumn
- Direct Known Subclasses:
LineNumberChangeRulerColumn
A vertical ruler column displaying line numbers.
Clients usually instantiate and configure object of this class.
- Since:
- 2.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidComputes the indentations for the given font and stores them infIndentation.protected intDoes the real computation of the number of digits.createControl(CompositeRuler parentRuler, Composite parentControl) Creates the column's SWT control.protected StringcreateDisplayString(int line) Computes the string to be printed forline.protected ColorgetBackground(Display display) Returns the System background color for list widgets.Returns the column's SWT control.protected ColorReturns the foreground color being used to print the line numbers.protected CompositeRulerReturns the parent (composite) ruler of this ruler column.protected intDeprecated.as of 3.2 the number of lines in the viewport cannot be computed because StyledText supports variable line heightsintgetWidth()Returns the width of this column's control.protected voidDisposes the column's resources.protected final booleanReturnstrueif the viewport displays the entire viewer contents, i.e. the viewer is not vertically scrollable.protected voidlayout(boolean redraw) Layouts the enclosing viewer to adapt the layout to changes of the size of the individual components.protected voidPaints the line.protected final voidTriggers a redraw in the display thread.voidredraw()Redraws this column.voidsetBackground(Color background) Sets the background color of this column.voidSets the font of this ruler column.voidsetForeground(Color foreground) Sets the foreground color of this column.voidsetModel(IAnnotationModel model) Associates an annotation model with this ruler column.protected booleanComputes the number of digits to be displayed.
-
Constructor Details
-
LineNumberRulerColumn
public LineNumberRulerColumn()Constructs a new vertical ruler column.
-
-
Method Details
-
setForeground
Sets the foreground color of this column.- Parameters:
foreground- the foreground color
-
getForeground
Returns the foreground color being used to print the line numbers.- Returns:
- the configured foreground color
- Since:
- 3.0
-
setBackground
Sets the background color of this column.- Parameters:
background- the background color
-
getBackground
Returns the System background color for list widgets.- Parameters:
display- the display- Returns:
- the System background color for list widgets
-
getControl
Description copied from interface:IVerticalRulerColumnReturns the column's SWT control.- Specified by:
getControlin interfaceIVerticalRulerColumn- Returns:
- the column's SWT control
-
getWidth
public int getWidth()Description copied from interface:IVerticalRulerColumnReturns the width of this column's control.- Specified by:
getWidthin interfaceIVerticalRulerColumn- Returns:
- the width of this column's control
-
updateNumberOfDigits
protected boolean updateNumberOfDigits()Computes the number of digits to be displayed. Returnstrueif the number of digits changed compared to the previous call of this method. If the method is called for the first time, the return value is alsotrue.- Returns:
- whether the number of digits has been changed
- Since:
- 3.0
-
computeNumberOfDigits
protected int computeNumberOfDigits()Does the real computation of the number of digits. Subclasses may override this method if they need extra space on the line number ruler.- Returns:
- the number of digits to be displayed on the line number ruler.
-
layout
protected void layout(boolean redraw) Layouts the enclosing viewer to adapt the layout to changes of the size of the individual components.- Parameters:
redraw-trueif this column can be redrawn
-
computeIndentations
protected void computeIndentations()Computes the indentations for the given font and stores them infIndentation. -
createControl
Description copied from interface:IVerticalRulerColumnCreates the column's SWT control.- Specified by:
createControlin interfaceIVerticalRulerColumn- Parameters:
parentRuler- the parent ruler of this columnparentControl- the control of the parent ruler- Returns:
- the column's SWT control
-
handleDispose
protected void handleDispose()Disposes the column's resources. -
getVisibleLinesInViewport
Deprecated.as of 3.2 the number of lines in the viewport cannot be computed because StyledText supports variable line heightsReturns the view port height in lines.- Returns:
- the view port height in lines
-
isViewerCompletelyShown
protected final boolean isViewerCompletelyShown()Returnstrueif the viewport displays the entire viewer contents, i.e. the viewer is not vertically scrollable.- Returns:
trueif the viewport displays the entire contents,falseotherwise- Since:
- 3.2
-
createDisplayString
Computes the string to be printed forline. The default implementation returnsInteger.toString(line + 1).- Parameters:
line- the line number for which the line number string is generated- Returns:
- the string to be printed on the line number bar for
line - Since:
- 3.0
-
paintLine
Paints the line. After this method is called the line numbers are painted on top of the result of this method.- Parameters:
line- the line of the document which the ruler is painted fory- the y-coordinate of the box being painted forline, relative togclineheight- the height of one line (and therefore of the box being painted)gc- the drawing context the client may choose to draw on.display- the display the drawing occurs on- Since:
- 3.0
-
postRedraw
protected final void postRedraw()Triggers a redraw in the display thread.- Since:
- 3.0
-
redraw
public void redraw()Description copied from interface:IVerticalRulerColumnRedraws this column.- Specified by:
redrawin interfaceIVerticalRulerColumn
-
setModel
Description copied from interface:IVerticalRulerColumnAssociates an annotation model with this ruler column. A valuenullis acceptable and clears the ruler.- Specified by:
setModelin interfaceIVerticalRulerColumn- Parameters:
model- the new annotation model, may benull
-
setFont
Description copied from interface:IVerticalRulerColumnSets the font of this ruler column.- Specified by:
setFontin interfaceIVerticalRulerColumn- Parameters:
font- the new font of the ruler column
-
getParentRuler
Returns the parent (composite) ruler of this ruler column.- Returns:
- the parent ruler
- Since:
- 3.0
-