ReportCat 1.1

li.netcat.print.table
Class TextTableCellDrawer

java.lang.Object
  extended byli.netcat.print.table.TextTableCellDrawer
All Implemented Interfaces:
TableCellDrawer

public class TextTableCellDrawer
extends java.lang.Object
implements TableCellDrawer

Implementation of a TableCellDrawer that draws text into the cells of a table. The text lines brake automatically, if the cell width is not wide enough. Manual line breaks ("\n") are also possible. Use the DefaultTableCellDrawer if you need an Icon and/or single line text.

Author:
Arthur Marxer

Constructor Summary
TextTableCellDrawer()
          Constructs a new TextTableCellDrawer with a top left alignment.
TextTableCellDrawer(int horizontalAlignment)
          Constructs a new TextTableCellDrawer with a top vertical alignment and the given horizontal alignment.
TextTableCellDrawer(int horizontalAlignment, int verticalAlignment)
          Constructs a new TextTableCellDrawer with the given alignment.
 
Method Summary
 void draw(java.awt.Graphics g, java.lang.Object value, java.lang.Object type, int x, int y, int width, int height, int rowIndex, int columnIndex)
          Draws the given value to the graphics within the given bounds.
 java.awt.Color getBackground()
          Returns the background color.
 java.awt.Font getFont()
          Returns the font that is used to paint the text.
 java.awt.Color getForeground()
          Returns the foreground color.
 int getHorizontalAlignment()
          Returns the horizontal alignment.
 java.awt.Insets getInsets(java.awt.Insets out)
          Returns the insets of this TextTableCellDrawer.
 int getMinimumWidth(java.awt.Graphics g, java.lang.Object value, java.lang.Object type, int rowIndex, int columnIndex)
          This implementation returns the minimum text with porperty plus the left and right inset.
 int getPreferredHeight(java.awt.Graphics g, java.lang.Object value, java.lang.Object type, int rowIndex, int columnIndex, int availableWidth)
          Returns the preferred height of this cell drawer.
 int getPreferredWidth(java.awt.Graphics g, java.lang.Object value, java.lang.Object type, int rowIndex, int columnIndex)
          This implementation calculates the width of the text without auto line breake and returns the minimum of this calculated width and the preferred width.
 int getVerticalAlignment()
          Returns the vertical alignment.
 void setBackground(java.awt.Color color)
          Sets the background color that is used to paint the text.
 void setFont(java.awt.Font font)
          Sets the font that is used to paint the text.
 void setForeground(java.awt.Color color)
          Sets the foreground color that is used to paint the text.
 void setHorizontalAlignment(int alignment)
          Sets the horizontal alignment.
 void setInsets(int top, int left, int bottom, int right)
          Sets the insets to the given values.
 void setMinimumTextWidth(int minWidth)
          Sets the minimum text width of this table cell drawer.
 void setPreferredTextWidth(int preferredWidth)
          Sets the preferred text width of this table cell drawer.
 void setVerticalAlignment(int alignment)
          Sets the vertical alignment.
protected  java.lang.String toText(java.lang.Object value, java.lang.Object type, int rowIndex, int columnIndex)
          This callback is used to convert the value of a cell to a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextTableCellDrawer

public TextTableCellDrawer(int horizontalAlignment,
                           int verticalAlignment)
Constructs a new TextTableCellDrawer with the given alignment.

Parameters:
horizontalAlignment - The horizontal alignment of the TextTableCellDrawer, one of LEFT, CENTER or RIGHT.
verticalAlignment - One of the values TOP, CENTER or BOTTOM.

TextTableCellDrawer

public TextTableCellDrawer(int horizontalAlignment)
Constructs a new TextTableCellDrawer with a top vertical alignment and the given horizontal alignment.

Parameters:
horizontalAlignment - The horizontalAlignment of the TextTableCellDrawer, one of LEFT, CENTER or RIGHT.

TextTableCellDrawer

public TextTableCellDrawer()
Constructs a new TextTableCellDrawer with a top left alignment.

Method Detail

getVerticalAlignment

public int getVerticalAlignment()
Returns the vertical alignment.

Returns:
One of the values TOP, CENTER or BOTTOM.

setVerticalAlignment

public void setVerticalAlignment(int alignment)
Sets the vertical alignment.

Parameters:
alignment - One of the values TOP, CENTER or BOTTOM.

getHorizontalAlignment

public int getHorizontalAlignment()
Returns the horizontal alignment.

Returns:
One of the values LEFT, CENTER or RIGHT.

setHorizontalAlignment

public void setHorizontalAlignment(int alignment)
Sets the horizontal alignment.

Parameters:
alignment - One of the values LEFT, CENTER or RIGHT.

getInsets

public java.awt.Insets getInsets(java.awt.Insets out)
Returns the insets of this TextTableCellDrawer.

Parameters:
out - An insets object, not null.
Returns:
The modified out patameter.

setInsets

public void setInsets(int top,
                      int left,
                      int bottom,
                      int right)
Sets the insets to the given values.

Parameters:
top - The top inset.
left - The left inset.
bottom - The bottom inset.
right - The right inset.

getFont

public java.awt.Font getFont()
Returns the font that is used to paint the text.

Returns:
The font of the TextTableCellDrawer, never null.

setFont

public void setFont(java.awt.Font font)
Sets the font that is used to paint the text.

Parameters:
font - The font of the TextTableCellDrawer, must not be null.

getForeground

public java.awt.Color getForeground()
Returns the foreground color.

Returns:
The foreground color, never null.

setForeground

public void setForeground(java.awt.Color color)
Sets the foreground color that is used to paint the text.

Parameters:
color - The foreground color, must not be null.

getBackground

public java.awt.Color getBackground()
Returns the background color.

Returns:
The background color, can be null.

setBackground

public void setBackground(java.awt.Color color)
Sets the background color that is used to paint the text.

Parameters:
color - The background color, can be null (i.e. transparent).

setMinimumTextWidth

public void setMinimumTextWidth(int minWidth)
Sets the minimum text width of this table cell drawer. The minimum width of the cell is defined as the minimum text width plus the left and right inset.

Parameters:
minWidth - The minimum text with.

setPreferredTextWidth

public void setPreferredTextWidth(int preferredWidth)
Sets the preferred text width of this table cell drawer. The prefered width of the cell is defined as the preferred text width plus the left and right inset.

Parameters:
preferredWidth - The preferred text width.

getMinimumWidth

public int getMinimumWidth(java.awt.Graphics g,
                           java.lang.Object value,
                           java.lang.Object type,
                           int rowIndex,
                           int columnIndex)
This implementation returns the minimum text with porperty plus the left and right inset. It ignores all parameters. Override this method if you want an other behavior.

Specified by:
getMinimumWidth in interface TableCellDrawer
Parameters:
g - The relevant Graphics object.
value - The data value retrieved from the model.
type - The data type retrieved from the model.
rowIndex - The absolute index of the row. For a header cell, this value is defined as -1, for a footer cell, it is Integer.MAX_VALUE.
columnIndex - The index of the column.
Returns:
The preferred width of this cell drawer.

getPreferredWidth

public int getPreferredWidth(java.awt.Graphics g,
                             java.lang.Object value,
                             java.lang.Object type,
                             int rowIndex,
                             int columnIndex)
This implementation calculates the width of the text without auto line breake and returns the minimum of this calculated width and the preferred width. Override this method if you want an other behavior.

Specified by:
getPreferredWidth in interface TableCellDrawer
Parameters:
g - The relevant Graphics object.
value - The data value retrieved from the model.
type - The data type retrieved from the model.
rowIndex - The absolute index of the row. For a header cell, this value is defined as -1, for a footer cell, it is Integer.MAX_VALUE.
columnIndex - The index of the column.
Returns:
The preferred width of this cell drawer.

getPreferredHeight

public int getPreferredHeight(java.awt.Graphics g,
                              java.lang.Object value,
                              java.lang.Object type,
                              int rowIndex,
                              int columnIndex,
                              int availableWidth)
Description copied from interface: TableCellDrawer
Returns the preferred height of this cell drawer. At this point, the cell drawer assumes, that the available height is infinite and the width of the cell will be as wide as the given width.

Specified by:
getPreferredHeight in interface TableCellDrawer
Parameters:
g - The relevant Graphics object.
value - The data value retrieved from the model.
type - The data type retrieved from the model.
rowIndex - The absolute index of the row. For a header cell, this value is defined as -1, for a footer cell, it is Integer.MAX_VALUE.
columnIndex - The index of the column.
availableWidth - The final available width of the cell.
Returns:
The preferred height of this cell drawer.

draw

public void draw(java.awt.Graphics g,
                 java.lang.Object value,
                 java.lang.Object type,
                 int x,
                 int y,
                 int width,
                 int height,
                 int rowIndex,
                 int columnIndex)
Description copied from interface: TableCellDrawer
Draws the given value to the graphics within the given bounds.

Specified by:
draw in interface TableCellDrawer
Parameters:
g - The relevant graphics object to paint on.
value - The data value retrieved from the model.
type - The data type retrieved from the model.
x - The x coordinate of the upper left corner of the cell.
y - The y coordinate of the upper left corner of the cell.
width - The width of the cell.
height - The height of the cell.
rowIndex - The absolute index of the row. For a header cell, this value is defined as -1, for a footer cell, it is Integer.MAX_VALUE.
columnIndex - The index of the column.

toText

protected java.lang.String toText(java.lang.Object value,
                                  java.lang.Object type,
                                  int rowIndex,
                                  int columnIndex)
This callback is used to convert the value of a cell to a string. If returns null if the value is null else it returns value.toString(). Override this callback if you want an other conversion to text.

Parameters:
value - The value retrieved from the model.
type - The type retrieved from the model.
rowIndex - The absolute row index.
columnIndex - The absolute column index.
Returns:
The text used for rendering.

ReportCat 1.1

Copyright © 2003 - 2005 NetCat Inc.. All rights reserved. Feedback

Print,Printing,Printer,Java,Java Print,SDK,Java Printing,Printing Java,Print Java,Library,Java Library,Print Library,Report,Reports,Java Report,Java Programming,Java Output,Layout,Page,API,Preview,Print Preview,Content,A4,Free,Output,Header,Footer,Download,Package,Jar,Evaluation, Print,Printing,Printer,Java,Java Print,SDK,Java Printing,Printing Java,Print Java,Library,Java Library,Print Library,Report,Reports,Java Report,Java Programming,Java Output,Layout,Page,API,Preview,Print Preview,Content,A4,Free,Output,Header,Footer,Download,Package,Jar,Evaluation, Print,Printing,Printer,Java,Java Print,SDK,Java Printing,Printing Java,Print Java,Library,Java Library,Print Library,Report,Reports,Java Report,Java Programming,Java Output,Layout,Page,API,Preview,Print Preview,Content,A4,Free,Output,Header,Footer,Download,Package,Jar,Evaluation