|
Eclipse Draw2d 2.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.eclipse.draw2d.Figure | +--org.eclipse.draw2d.Label
A figure that can display text and/or an image.
Nested Class Summary |
Nested classes inherited from class org.eclipse.draw2d.Figure |
Figure.FigureIterator |
Nested classes inherited from class org.eclipse.draw2d.IFigure |
IFigure.NoInsets |
Field Summary |
Fields inherited from class org.eclipse.draw2d.Figure |
bgColor, border, bounds, fgColor, flags, font, MAX_FLAG, maxSize, minSize, NO_MANAGER, prefSize, toolTip |
Fields inherited from interface org.eclipse.draw2d.PositionConstants |
BOTTOM, CENTER, EAST, EAST_WEST, LEFT, LEFT_CENTER_RIGHT, MIDDLE, NONE, NORTH, NORTH_EAST, NORTH_SOUTH, NORTH_WEST, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TOP_MIDDLE_BOTTOM, WEST |
Fields inherited from interface org.eclipse.draw2d.IFigure |
MAX_DIMENSION, MIN_DIMENSION, NO_INSETS |
Constructor Summary | |
Label()
Construct an empty Label. |
|
Label(Image i)
Construct a Label with passed Image as its icon. |
|
Label(String s)
Construct a Label with passed String as its text. |
|
Label(String s,
Image i)
Construct a Label with passed String as text and passed Image as its icon. |
Method Summary | |
protected Dimension |
calculateLabelSize(Dimension txtSize)
Calculates the size of the Label using the passed Dimension as the size of the Label's text. |
protected Dimension |
calculateSubStringTextSize()
Calculates the size of the Label's text size. |
protected Dimension |
calculateTextSize()
Calculates and returns the size of the Label's text. |
Image |
getIcon()
Returns the Label's icon. |
int |
getIconAlignment()
Returns the current alignment of the Label's icon. |
Rectangle |
getIconBounds()
Returns the bounds of the Label's icon. |
protected Point |
getIconLocation()
Returns the location of the Label's icon relative to the Label. |
int |
getIconTextGap()
Returns the gap in pixels between the Label's icon and its text. |
Dimension |
getMinimumSize(int w,
int h)
Returns a hint indicating the smallest desireable size for the IFigure. |
Dimension |
getPreferredSize(int wHint,
int hHint)
Returns the desireable size for this IFigure using the provided width and height hints. |
String |
getSubStringText()
Calculates the amount of the Label's current text will fit in the Label, including an elipsis "..." if truncation is required. |
protected Dimension |
getSubStringTextSize()
Returns the size of the Label's current text. |
String |
getText()
Returns the text of the label. |
int |
getTextAlignment()
Returns the current alignment of the Label's text. |
Rectangle |
getTextBounds()
Returns the bounds of the label's text. |
protected Point |
getTextLocation()
Returns the location of the label's text relative to the label. |
int |
getTextPlacement()
Returns the current placement of the label's text relative to its icon. |
protected Dimension |
getTextSize()
Returns the size of the label's complete text. |
void |
invalidate()
Invalidates this IFigure. |
boolean |
isTextTruncated()
Returns true if the label's text is currently truncated and is displaying
an ellipsis, false otherwise. |
protected void |
paintFigure(Graphics graphics)
Paints this Figure's primary representation, or background. |
void |
setIcon(Image image)
Sets the label's icon to the passed image. |
void |
setIconAlignment(int align)
Sets the icon alignment relative to the .abel's alignment to the passed value. |
void |
setIconDimension(Dimension d)
Sets the label's icon size to the passed Dimension. |
void |
setIconTextGap(int gap)
Sets the gap in pixels between the label's icon and text to the passed value. |
void |
setLabelAlignment(int align)
Sets the Label's alignment to the passed value. |
void |
setText(String s)
Sets the label's text. |
void |
setTextAlignment(int align)
Sets the text alignment of the Label relative to the label alignment. |
void |
setTextPlacement(int where)
Sets the text placement of the label relative to its icon. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Label()
public Label(String s)
s
- the label textpublic Label(Image i)
i
- the label imagepublic Label(String s, Image i)
s
- the label texti
- the label imageMethod Detail |
protected Dimension calculateLabelSize(Dimension txtSize)
txtSize
- the precalculated size of the label's text
protected Dimension calculateSubStringTextSize()
calculateTextSize()
.
protected Dimension calculateTextSize()
calculateSubStringTextSize()
.
public Image getIcon()
public int getIconAlignment()
PositionConstants.CENTER
.
public Rectangle getIconBounds()
protected Point getIconLocation()
public int getIconTextGap()
public Dimension getMinimumSize(int w, int h)
IFigure
getMinimumSize
in interface IFigure
getMinimumSize
in class Figure
IFigure.getMinimumSize(int, int)
public Dimension getPreferredSize(int wHint, int hHint)
IFigure
getPreferredSize
in interface IFigure
getPreferredSize
in class Figure
IFigure.getPreferredSize(int, int)
public String getSubStringText()
protected Dimension getSubStringTextSize()
public String getText()
getSubStringText()
to return the label's current text contents with truncation considered.
public int getTextAlignment()
PositionConstants.CENTER
.
public Rectangle getTextBounds()
protected Point getTextLocation()
public int getTextPlacement()
PositionConstants.EAST
.
protected Dimension getTextSize()
getSubStringTextSize()
.
public void invalidate()
IFigure
invalidate
in interface IFigure
invalidate
in class Figure
IFigure.invalidate()
public boolean isTextTruncated()
true
if the label's text is currently truncated and is displaying
an ellipsis, false
otherwise.
true
if the label's text is truncatedprotected void paintFigure(Graphics graphics)
Figure
Figure.paintClientArea(Graphics)
and Figure.paintBorder(Graphics)
. Furthermore, it is safe
to call graphics.restoreState()
within this method, and doing so will
restore the graphics to its original state upon entry.
paintFigure
in class Figure
graphics
- The Graphics used to paintFigure.paintFigure(Graphics)
public void setIcon(Image image)
image
- the new label imagepublic void setIconAlignment(int align)
PositionConstants.CENTER
. Other possible values are
PositionConstants.TOP
, PositionConstants.BOTTOM
,
PositionConstants.LEFT
and PositionConstants.RIGHT
.
align
- the icon alignmentpublic void setIconDimension(Dimension d)
d
- the new icon sizepublic void setIconTextGap(int gap)
gap
- the gappublic void setLabelAlignment(int align)
PositionConstants.CENTER
. Other possible values are
PositionConstants.TOP
, PositionConstants.BOTTOM
,
PositionConstants.LEFT
and PositionConstants.RIGHT
.
align
- label alignmentpublic void setText(String s)
s
- the new label textpublic void setTextAlignment(int align)
PositionConstants.CENTER
. Other possible values are
PositionConstants.TOP
, PositionConstants.BOTTOM
,
PositionConstants.LEFT
and PositionConstants.RIGHT
.
align
- the text alignmentpublic void setTextPlacement(int where)
PositionConstants.EAST
. Other possible values are
PositionConstants.NORTH
, PositionConstants.SOUTH
and
PositionConstants.WEST
.
where
- the text placement
|
Eclipse Draw2d 2.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |