voji.report
Class ReportText

java.lang.Object
  |
  +--voji.report.ReportComponent
        |
        +--voji.report.ReportText
All Implemented Interfaces:
javax.swing.SwingConstants
Direct Known Subclasses:
ReportPageNumber

public class ReportText
extends ReportComponent

This report component draws a text


Field Summary
 int align
          The horizontal alignment of the text.
static int CHAR
          Break at any character
 java.awt.Font font
          The font of the text
 boolean hasInsets
          Says whether the text should have insets
 double left
          The left extension of the text
static int NEWLINE
          Break only at '\n'
 double right
          The right extension of the text
 java.lang.String text
          The displayed text
 int type
          The break type of the text.
static int WORD
          Break at words and newlines
 
Fields inherited from class voji.report.ReportComponent
position
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Constructor Summary
ReportText(java.lang.String text, double left, double right, java.awt.Font font)
          Constructs a new ReportText instance representing the given string in the given font.
ReportText(java.lang.String text, double left, double right, java.awt.Font font, int align)
          Constructs a new ReportText instance representing the given string in the given font.
ReportText(java.lang.String text, double left, double right, java.awt.Font font, int align, int type, boolean hasInsets)
          Constructs a new ReportText instance representing the given string in the given font
 
Method Summary
 void draw(PageGraphics g)
          Draws this component
protected  void drawLine(java.awt.Graphics g, java.lang.String text, int x1, int x2, int y)
          Draws a single line
protected  java.awt.Insets getInsets(PageGraphics g)
          Returns the insets of this text component
protected  java.util.Vector getLines(PageGraphics g)
          Splits the current text into lines
protected  int getOwnHeight(PageGraphics g)
          Returns the local height of this component
protected  void updateText(PageGraphics g)
          Updates the text.
 
Methods inherited from class voji.report.ReportComponent
add, add, draw, getHeight, iterator, remove
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

text

public java.lang.String text
The displayed text


left

public double left
The left extension of the text


right

public double right
The right extension of the text


font

public java.awt.Font font
The font of the text


hasInsets

public boolean hasInsets
Says whether the text should have insets


align

public int align
The horizontal alignment of the text. It's either LEFT, RIGHT or CENTER.


type

public int type
The break type of the text. It's either NEWLINE, WORD or CHAR.


NEWLINE

public static final int NEWLINE
Break only at '\n'

See Also:
Constant Field Values

WORD

public static final int WORD
Break at words and newlines

See Also:
Constant Field Values

CHAR

public static final int CHAR
Break at any character

See Also:
Constant Field Values
Constructor Detail

ReportText

public ReportText(java.lang.String text,
                  double left,
                  double right,
                  java.awt.Font font,
                  int align,
                  int type,
                  boolean hasInsets)
Constructs a new ReportText instance representing the given string in the given font

Parameters:
text - the text to draw
left - the left extension of the text
right - the right extension of the text
font - the font of the text
align - the horizontal alignment of the text
type - the break type of the text
hasInsets - whether the text should have insets

ReportText

public ReportText(java.lang.String text,
                  double left,
                  double right,
                  java.awt.Font font,
                  int align)
Constructs a new ReportText instance representing the given string in the given font. It uses a WORD break type and no insets for text.

Parameters:
text - the text to draw
left - the left extension of the text
right - the right extension of the text
font - the font of the text
align - the horizontal alignment of the text

ReportText

public ReportText(java.lang.String text,
                  double left,
                  double right,
                  java.awt.Font font)
Constructs a new ReportText instance representing the given string in the given font. It uses a WORD break type, no insets and a LEFT alignment for text.

Parameters:
text - the text to draw
left - the left extension of the text
right - the right extension of the text
font - the font of the text
Method Detail

getOwnHeight

protected int getOwnHeight(PageGraphics g)
Returns the local height of this component

Overrides:
getOwnHeight in class ReportComponent
Parameters:
g - a graphical context to determine font sizes etc.
See Also:
ReportComponent.getHeight(PageGraphics)

draw

public void draw(PageGraphics g)
Draws this component

Overrides:
draw in class ReportComponent
Parameters:
g - the graphical context where to draw to
See Also:
ReportComponent.getHeight(PageGraphics)

drawLine

protected void drawLine(java.awt.Graphics g,
                        java.lang.String text,
                        int x1,
                        int x2,
                        int y)
Draws a single line

Parameters:
g - the graphical context where to draw to
text - the text to draw
x1 - the left border
x2 - the right border
y - the baseline

getInsets

protected java.awt.Insets getInsets(PageGraphics g)
Returns the insets of this text component

Parameters:
g - a graphical context to determine font sizes etc.

getLines

protected java.util.Vector getLines(PageGraphics g)
Splits the current text into lines

Parameters:
g - a graphical context to determine font sizes etc.
Returns:
a Vector of strings containing the lines

updateText

protected void updateText(PageGraphics g)
Updates the text. This method is useful for changing text report components. It is called immediately before determining the text height and before drawing it.

Parameters:
g - a graphical context to determine font sizes etc.