Eclipse Platform
Release 3.1

org.eclipse.jface.text.source
Class LineNumberRulerColumn

java.lang.Object
  extended byorg.eclipse.jface.text.source.LineNumberRulerColumn
All Implemented Interfaces:
IVerticalRulerColumn
Direct Known Subclasses:
LineNumberChangeRulerColumn

public class LineNumberRulerColumn
extends Object
implements IVerticalRulerColumn

A vertical ruler column displaying line numbers. Clients usually instantiate and configure object of this class.

Since:
2.0

Constructor Summary
LineNumberRulerColumn()
          Constructs a new vertical ruler column.
 
Method Summary
protected  void computeIndentations()
          Computes the indentations for the given font and stores them in fIndentation.
protected  int computeNumberOfDigits()
          Does the real computation of the number of digits.
 Control createControl(CompositeRuler parentRuler, Composite parentControl)
          Creates the column's SWT control.
protected  String createDisplayString(int line)
          Computes the string to be printed for line.
protected  Color getBackground(Display display)
          Returns the System background color for list widgets.
 Control getControl()
          Returns the column's SWT control.
protected  Color getForeground()
          Returns the foreground color being used to print the line numbers.
protected  CompositeRuler getParentRuler()
          Returns the parent (composite) ruler of this ruler column.
protected  int getVisibleLinesInViewport()
          Returns the viewport height in lines.
 int getWidth()
          Returns the width of this column's control.
protected  void handleDispose()
          Disposes the column's resources.
protected  void layout(boolean redraw)
          Layouts the enclosing viewer to adapt the layout to changes of the size of the individual components.
protected  void paintLine(int line, int y, int lineheight, GC gc, Display display)
          Paints the line.
protected  void postRedraw()
          Triggers a redraw in the display thread.
 void redraw()
          Redraws this column.
 void setBackground(Color background)
          Sets the background color of this column.
 void setFont(Font font)
          Sets the font of this ruler column.
 void setForeground(Color foreground)
          Sets the foreground color of this column.
 void setModel(IAnnotationModel model)
          Associates an annotation model with this ruler column.
protected  boolean updateNumberOfDigits()
          Computes the number of digits to be displayed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineNumberRulerColumn

public LineNumberRulerColumn()
Constructs a new vertical ruler column.

Method Detail

setForeground

public void setForeground(Color foreground)
Sets the foreground color of this column.

Parameters:
foreground - the foreground color

getForeground

protected Color getForeground()
Returns the foreground color being used to print the line numbers.

Returns:
the configured foreground color
Since:
3.0

setBackground

public void setBackground(Color background)
Sets the background color of this column.

Parameters:
background - the background color

getBackground

protected Color getBackground(Display display)
Returns the System background color for list widgets.

Parameters:
display - the display
Returns:
the System background color for list widgets

getControl

public Control getControl()
Description copied from interface: IVerticalRulerColumn
Returns the column's SWT control.

Specified by:
getControl in interface IVerticalRulerColumn
Returns:
the column's SWT control

getWidth

public int getWidth()
Description copied from interface: IVerticalRulerColumn
Returns the width of this column's control.

Specified by:
getWidth in interface IVerticalRulerColumn
Returns:
the width of this column's control

updateNumberOfDigits

protected boolean updateNumberOfDigits()
Computes the number of digits to be displayed. Returns true if 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 also true.

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 - true if this column can be redrawn

computeIndentations

protected void computeIndentations()
Computes the indentations for the given font and stores them in fIndentation.


createControl

public Control createControl(CompositeRuler parentRuler,
                             Composite parentControl)
Description copied from interface: IVerticalRulerColumn
Creates the column's SWT control.

Specified by:
createControl in interface IVerticalRulerColumn
Parameters:
parentRuler - the parent ruler of this column
parentControl - the control of the parent ruler
Returns:
the column's SWT control

handleDispose

protected void handleDispose()
Disposes the column's resources.


getVisibleLinesInViewport

protected int getVisibleLinesInViewport()
Returns the viewport height in lines.

Returns:
the viewport height in lines

createDisplayString

protected String createDisplayString(int line)
Computes the string to be printed for line. The default implementation returns Integer.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

protected void paintLine(int line,
                         int y,
                         int lineheight,
                         GC gc,
                         Display display)
Paints the line. After this method is called the line numbers are painted on top of the result of this method.

This default implementation does nothing.

Parameters:
line - the line of the document which the ruler is painted for
y - the y-coordinate of the box being painted for line, relative to gc
lineheight - 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: IVerticalRulerColumn
Redraws this column.

Specified by:
redraw in interface IVerticalRulerColumn

setModel

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

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

setFont

public void setFont(Font font)
Description copied from interface: IVerticalRulerColumn
Sets the font of this ruler column.

Specified by:
setFont in interface IVerticalRulerColumn
Parameters:
font - the new font of the ruler column

getParentRuler

protected CompositeRuler getParentRuler()
Returns the parent (composite) ruler of this ruler column.

Returns:
the parent ruler
Since:
3.0

Eclipse Platform
Release 3.1

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2005. All rights reserved.