|
ReportCat 1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectli.netcat.print.util.LabelDrawer
This is a lightweight equivalent to the JLabel
that implements the Drawer
interface.
It has an Icon and a Text that can be positioned relative to each other and the text can be aligned in horixontal
and vertical direction. If the text does not fit into the bounding box, it gets clipped by adding "..." at th end
of the visible text.
Constructor Summary | |
LabelDrawer()
Constructs a new LabelDrawer with non text and no icon and a left horizontal alignment. |
|
LabelDrawer(javax.swing.Icon icon)
Constructs a new LabelDrawer with the given icon and a centered horizontal alignment. |
|
LabelDrawer(javax.swing.Icon icon,
int horizontalAlignment)
Constructs a new LabelDrawer with the given properties. |
|
LabelDrawer(java.lang.String text)
Constructs a new LabelDrawer with the given text and a left horizontal alignment. |
|
LabelDrawer(java.lang.String text,
javax.swing.Icon icon,
int horizontalAlignment)
Constructs a new LabelDrawer with the given properties. |
|
LabelDrawer(java.lang.String text,
int horizontalAlignment)
Constructs a new LabelDrawer with the given properties. |
Method Summary | |
void |
draw(java.awt.Graphics g,
int x,
int y,
int width,
int height)
Draws the target on the given Graphics object. |
java.awt.Font |
getFont()
Returns the font of the LabelDrawer . |
int |
getHorizontalAlignment()
Returns the horizontal alignment. |
int |
getHorizontalTextPosition()
Returns the horizontal text position. |
javax.swing.Icon |
getIcon()
Returns the icon property. |
int |
getIconTextGap()
Returns the gap between icon and text. |
java.awt.Insets |
getInsets(java.awt.Insets out)
Returns the insets of this LabelDrawer . |
int |
getPreferredHeight(java.awt.Graphics g,
int availableWith)
Returns the preferred height of this label. |
java.awt.Dimension |
getPreferredSize(java.awt.Graphics g,
java.awt.Dimension out)
Returns the preferred size of the target. |
int |
getPreferredWidth(java.awt.Graphics g)
Returns the preferred width of this label. |
java.awt.Dimension |
getSize(java.awt.Graphics g)
Returns the size of the Painter . |
java.lang.String |
getText()
Returns the text property. |
int |
getVerticalAlignment()
Returns the vertical alignment. |
int |
getVerticalTextPosition()
Returns the vertical text position. |
void |
paint(java.awt.Graphics g,
int x,
int y)
Paints the target on the given Graphics . |
void |
setFont(java.awt.Font font)
Sets the font of the LabelDrawer . |
void |
setHorizontalAlignment(int alignment)
Sets the horizontal alignment. |
void |
setHorizontalTextPosition(int textPosition)
Sets the horizontal text position. |
void |
setIcon(javax.swing.Icon icon)
Sets the icon property. |
void |
setIconTextGap(int iconTextGap)
Sets the gap between icon and text. |
void |
setInsets(int top,
int left,
int bottom,
int right)
Sets the insets to the given values. |
void |
setText(java.lang.String text)
Sets the text property. |
void |
setVerticalAlignment(int alignment)
Sets the vertical alignment. |
void |
setVerticalTextPosition(int textPosition)
Sets the vertical text position. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public LabelDrawer(java.lang.String text, javax.swing.Icon icon, int horizontalAlignment)
LabelDrawer
with the given properties.
text
- The text of the LabelDrawer, can be null
.icon
- The icon of the LabelDrawer, can be null
.horizontalAlignment
- The horizontal alignment of the LabelDrawer
, one of LEFT
, CENTER
or RIGHT
.public LabelDrawer(java.lang.String text, int horizontalAlignment)
LabelDrawer
with the given properties.
text
- The text of the LabelDrawer
, can be null
.horizontalAlignment
- The horizontalAlignment of the LabelDrawer
, one of LEFT
, CENTER
or RIGHT
.public LabelDrawer(java.lang.String text)
text
- The text of the LabelDrawer
, can be null
.public LabelDrawer(javax.swing.Icon icon, int horizontalAlignment)
LabelDrawer
with the given properties.
icon
- The icon of the LabelDrawer
, can be null
.horizontalAlignment
- The horizontalAlignment of the LabelDrawer
, one of LEFT
, CENTER
or RIGHT
.public LabelDrawer(javax.swing.Icon icon)
LabelDrawer
with the given icon and a centered horizontal alignment.
icon
- The icon of the LabelDrawer
, can be null
.public LabelDrawer()
LabelDrawer
with non text and no icon and a left horizontal alignment.
Method Detail |
public java.lang.String getText()
public void setText(java.lang.String text)
text
- The text property, can be null
.public javax.swing.Icon getIcon()
public void setIcon(javax.swing.Icon icon)
icon
- The icon property, can be null
.public int getIconTextGap()
public void setIconTextGap(int iconTextGap)
iconTextGap
- The gap between icon and text in pixel.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 int getVerticalTextPosition()
TOP
, CENTER
or BOTTOM
.public void setVerticalTextPosition(int textPosition)
textPosition
- One of the values TOP
, CENTER
or BOTTOM
.public int getHorizontalTextPosition()
LEFT
, CENTER
or RIGHT
.public void setHorizontalTextPosition(int textPosition)
textPosition
- One of the values LEFT
, CENTER
or RIGHT
.public java.awt.Insets getInsets(java.awt.Insets out)
LabelDrawer
.
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()
LabelDrawer
.
LabelDrawer
, never null
.public void setFont(java.awt.Font font)
LabelDrawer
.
font
- The font of the LabelDrawer
, must not be null.public java.awt.Dimension getPreferredSize(java.awt.Graphics g, java.awt.Dimension out)
g
- The relevant Graphics
object.out
- An instance of Dimension
that is used as return value, not null
.
This avoids the allocation of many rectangles, especially in connection with renderers (e.g. table).
public int getPreferredWidth(java.awt.Graphics g)
g
- The relevant graphics object.
public int getPreferredHeight(java.awt.Graphics g, int availableWith)
g
- The relevant graphics object.availableWith
- The available width that can be used to paint on.
public java.awt.Dimension getSize(java.awt.Graphics g)
Painter
Painter
.
getSize
in interface Painter
g
- The relevant Graphics
context.
Painter
.public void paint(java.awt.Graphics g, int x, int y)
Painter
Graphics
.
paint
in interface Painter
g
- The Graphics
object that is used to paint.x
- The x coordinate of the upper left corner of the target.y
- The y coordinate of the upper left corner of the target.public void draw(java.awt.Graphics g, int x, int y, int width, int height)
Drawer
Graphics
object.
draw
in interface Drawer
g
- The Graphics
object that is used to draw.x
- The x coordinate of the upper left corner of the target.y
- The y coordinate of the upper left corner of the target.width
- The width that the target should use for drawing.height
- The height that the target should use for drawing.
|
ReportCat 1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |