br.uff.puro.dct
Class LineNumberedBorder

java.lang.Object
  extended by javax.swing.border.AbstractBorder
      extended by br.uff.puro.dct.LineNumberedBorder
All Implemented Interfaces:
java.io.Serializable, javax.swing.border.Border

public class LineNumberedBorder
extends javax.swing.border.AbstractBorder

Draws line numbers next to each line, in the same font as the text. Currently, this can only be used with a JTextArea , since it relies on the getRows() and getLineCount() methods. A possible extension, create an interface to return this rows/linecount.

See Also:
Serialized Form

Field Summary
static int LEFT_JUSTIFY
          The line number should be left justified.
static int LEFT_SIDE
          The line numbers should be drawn on the left side of the component.
static int RIGHT_JUSTIFY
          The line number should be right justified.
static int RIGHT_SIDE
          The line numbers should be drawn on the right side of the component.
 
Constructor Summary
LineNumberedBorder(int location, int justify)
           
 
Method Summary
 java.awt.Insets getBorderInsets(java.awt.Component c)
           
 java.awt.Insets getBorderInsets(java.awt.Component c, java.awt.Insets insets)
          This modifies the insets, by adding space for the line number on the left.
 int getLineNumberJustification()
           
 int getLocation()
           
 void paintBorder(java.awt.Component c, java.awt.Graphics g, int x, int y, int width, int height)
           
 void setLineNumberJustification(int justify)
           
 void setLocation(int loc)
           
 
Methods inherited from class javax.swing.border.AbstractBorder
getBaseline, getBaselineResizeBehavior, getInteriorRectangle, getInteriorRectangle, isBorderOpaque
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LEFT_SIDE

public static int LEFT_SIDE
The line numbers should be drawn on the left side of the component.


RIGHT_SIDE

public static int RIGHT_SIDE
The line numbers should be drawn on the right side of the component.


RIGHT_JUSTIFY

public static int RIGHT_JUSTIFY
The line number should be right justified.


LEFT_JUSTIFY

public static int LEFT_JUSTIFY
The line number should be left justified.

Constructor Detail

LineNumberedBorder

public LineNumberedBorder(int location,
                          int justify)
Method Detail

getBorderInsets

public java.awt.Insets getBorderInsets(java.awt.Component c)
Specified by:
getBorderInsets in interface javax.swing.border.Border
Overrides:
getBorderInsets in class javax.swing.border.AbstractBorder

getBorderInsets

public java.awt.Insets getBorderInsets(java.awt.Component c,
                                       java.awt.Insets insets)
This modifies the insets, by adding space for the line number on the left. Should be modified to add space on the right, depending upon Locale.

Overrides:
getBorderInsets in class javax.swing.border.AbstractBorder
Parameters:
c - Description of the Parameter
insets - Description of the Parameter
Returns:
The borderInsets value

getLineNumberJustification

public int getLineNumberJustification()

setLineNumberJustification

public void setLineNumberJustification(int justify)

getLocation

public int getLocation()

setLocation

public void setLocation(int loc)

paintBorder

public void paintBorder(java.awt.Component c,
                        java.awt.Graphics g,
                        int x,
                        int y,
                        int width,
                        int height)
Specified by:
paintBorder in interface javax.swing.border.Border
Overrides:
paintBorder in class javax.swing.border.AbstractBorder