|
ReportCat 1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectli.netcat.print.table.TextTableCellDrawer
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.
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 |
public TextTableCellDrawer(int horizontalAlignment, int verticalAlignment)
TextTableCellDrawer
with the given alignment.
horizontalAlignment
- The horizontal alignment of the TextTableCellDrawer
, one of LEFT
, CENTER
or RIGHT
.verticalAlignment
- One of the values TOP
, CENTER
or BOTTOM
.public TextTableCellDrawer(int horizontalAlignment)
TextTableCellDrawer
with a top vertical alignment and the given horizontal alignment.
horizontalAlignment
- The horizontalAlignment of the TextTableCellDrawer
, one of LEFT
, CENTER
or RIGHT
.public TextTableCellDrawer()
TextTableCellDrawer
with a top left alignment.
Method Detail |
public int getVerticalAlignment()
TOP
, CENTER
or BOTTOM
.public void setVerticalAlignment(int alignment)
alignment
- One of the values TOP
, CENTER
or BOTTOM
.public int getHorizontalAlignment()
LEFT
, CENTER
or RIGHT
.public void setHorizontalAlignment(int alignment)
alignment
- One of the values LEFT
, CENTER
or RIGHT
.public java.awt.Insets getInsets(java.awt.Insets out)
TextTableCellDrawer
.
out
- An insets object, not null
.
public void setInsets(int top, int left, int bottom, int right)
top
- The top inset.left
- The left inset.bottom
- The bottom inset.right
- The right inset.public java.awt.Font getFont()
TextTableCellDrawer
, never null
.public void setFont(java.awt.Font font)
font
- The font of the TextTableCellDrawer
, must not be null.public java.awt.Color getForeground()
null
.public void setForeground(java.awt.Color color)
color
- The foreground color, must not be null.public java.awt.Color getBackground()
null
.public void setBackground(java.awt.Color color)
color
- The background color, can be null (i.e. transparent).public void setMinimumTextWidth(int minWidth)
minWidth
- The minimum text with.public void setPreferredTextWidth(int preferredWidth)
preferredWidth
- The preferred text width.public int getMinimumWidth(java.awt.Graphics g, java.lang.Object value, java.lang.Object type, int rowIndex, int columnIndex)
getMinimumWidth
in interface TableCellDrawer
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.
public int getPreferredWidth(java.awt.Graphics g, java.lang.Object value, java.lang.Object type, int rowIndex, int columnIndex)
getPreferredWidth
in interface TableCellDrawer
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.
public int getPreferredHeight(java.awt.Graphics g, java.lang.Object value, java.lang.Object type, int rowIndex, int columnIndex, int availableWidth)
TableCellDrawer
getPreferredHeight
in interface TableCellDrawer
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.
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)
TableCellDrawer
draw
in interface TableCellDrawer
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.protected java.lang.String toText(java.lang.Object value, java.lang.Object type, int rowIndex, int columnIndex)
null
if the value is null
else it returns value.toString()
. Override this
callback if you want an other conversion to text.
value
- The value retrieved from the model.type
- The type retrieved from the model.rowIndex
- The absolute row index.columnIndex
- The absolute column index.
|
ReportCat 1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |