|
Eclipse Draw2d 3.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.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, Figure.IdentitySearch |
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 |
ALWAYS_LEFT, ALWAYS_RIGHT, BOTTOM, CENTER, EAST, EAST_WEST, HORIZONTAL, LEFT, LEFT_CENTER_RIGHT, MIDDLE, NONE, NORTH, NORTH_EAST, NORTH_SOUTH, NORTH_WEST, NSEW, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TOP_MIDDLE_BOTTOM, VERTICAL, 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 preferred 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)
Deprecated. The icons should be displayed at 1:1 |
void |
setIconDimension(Dimension d)
Deprecated. the icon is automatically displayed at 1:1 |
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 alignment of the entire label (icon and text). |
void |
setText(String s)
Sets the label's text. |
void |
setTextAlignment(int align)
Sets the alignment of the Text relative to the icon. |
void |
setTextPlacement(int where)
Sets the placement of text relative to the label's 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
-1
indicates that there is no constraint in that
direction.
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
LayoutManager.invalidate()
should be called on that layout.
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)
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
PositionConstants.TOP
PositionConstants.BOTTOM
PositionConstants.LEFT
PositionConstants.RIGHT
align
- label alignmentpublic void setText(String s)
s
- the new label textpublic void setTextAlignment(int align)
PositionConstants.CENTER
PositionConstants.TOP
PositionConstants.BOTTOM
PositionConstants.LEFT
PositionConstants.RIGHT
align
- the text alignmentsetLabelAlignment(int)
public void setTextPlacement(int where)
where
- the text placement
|
Eclipse Draw2d 3.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |