public class Label extends Figure implements PositionConstants
Figure.FigureIterator, Figure.IdentitySearch
IFigure.NoInsets
bgColor, border, bounds, fgColor, flags, font, MAX_FLAG, maxSize, minSize, NO_MANAGER, prefSize, toolTip
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
MAX_DIMENSION, MIN_DIMENSION, NO_INSETS
Constructor and Description |
---|
Label()
Construct an empty Label.
|
Label(Image i)
Construct a Label with passed Image as its icon.
|
Label(java.lang.String s)
Construct a Label with passed String as its text.
|
Label(java.lang.String s,
Image i)
Construct a Label with passed String as text and passed Image as its
icon.
|
Modifier and Type | Method and Description |
---|---|
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.
|
protected Dimension |
getIconSize()
Gets the icon size
|
int |
getIconTextGap()
Returns the gap in pixels between the Label's icon and its text.
|
int |
getLabelAlignment()
Returns the alignment of the entire label (icon and 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.
|
java.lang.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.
|
java.lang.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.
|
TextUtilities |
getTextUtilities()
Gets the
TextUtilities instance to be used in measurement
calculations. |
protected java.lang.String |
getTruncationString()
Gets the string that will be appended to the text when the label is
truncated.
|
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)
This method sets the alignment of the icon within the bounds of the
label.
|
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 label (icon and text) within the figure.
|
void |
setText(java.lang.String s)
Sets the label's text.
|
void |
setTextAlignment(int align)
Sets the alignment of the text relative to the icon within the label.
|
void |
setTextPlacement(int where)
Sets the placement of the text relative to the icon within the label.
|
add, add, add, add, addAncestorListener, addCoordinateListener, addFigureListener, addFocusListener, addKeyListener, addLayoutListener, addListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, containsPoint, containsPoint, erase, findDescendantAtExcluding, findFigureAt, findFigureAt, findFigureAt, findFigureAtExcluding, findMouseEventTargetAt, findMouseEventTargetInDescendantsAt, fireCoordinateSystemChanged, fireFigureMoved, fireMoved, firePropertyChange, firePropertyChange, firePropertyChange, getBackgroundColor, getBorder, getBounds, getChildren, getClientArea, getClientArea, getClippingStrategy, getCursor, getFlag, getFont, getForegroundColor, getInsets, getLayoutManager, getListeners, getLocalBackgroundColor, getLocalFont, getLocalForegroundColor, getLocation, getMaximumSize, getMinimumSize, getParent, getPreferredSize, getSize, getToolTip, getUpdateManager, handleFocusGained, handleFocusLost, handleKeyPressed, handleKeyReleased, handleMouseDoubleClicked, handleMouseDragged, handleMouseEntered, handleMouseExited, handleMouseHover, handleMouseMoved, handleMousePressed, handleMouseReleased, hasFocus, internalGetEventDispatcher, intersects, invalidateTree, isCoordinateSystem, isEnabled, isFocusTraversable, isMirrored, isMouseEventTarget, isOpaque, isRequestFocusEnabled, isShowing, isValid, isValidationRoot, isVisible, layout, paint, paintBorder, paintChildren, paintClientArea, primTranslate, remove, removeAll, removeAncestorListener, removeCoordinateListener, removeFigureListener, removeFocusListener, removeKeyListener, removeLayoutListener, removeListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, revalidate, setBackgroundColor, setBorder, setBounds, setChildrenDirection, setChildrenEnabled, setChildrenOrientation, setClippingStrategy, setConstraint, setCursor, setEnabled, setFlag, setFocusTraversable, setFont, setForegroundColor, setLayoutManager, setLocation, setMaximumSize, setMinimumSize, setOpaque, setParent, setPreferredSize, setPreferredSize, setRequestFocusEnabled, setSize, setSize, setToolTip, setValid, setVisible, translate, translateFromParent, translateToAbsolute, translateToParent, translateToRelative, useLocalCoordinates, validate
public Label()
public Label(java.lang.String s)
s
- the label textpublic Label(Image i)
i
- the label imagepublic Label(java.lang.String s, Image i)
s
- the label texti
- the label imageprotected Dimension calculateLabelSize(Dimension txtSize)
txtSize
- the precalculated size of the label's textprotected 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
w
- the width hinth
- the height hintIFigure.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
wHint
- a width hinthHint
- a height hintIFigure.getPreferredSize(int, int)
public java.lang.String getSubStringText()
protected Dimension getSubStringTextSize()
public java.lang.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)
align
- label alignmentpublic void setText(java.lang.String s)
s
- the new label textpublic void setTextAlignment(int align)
align
- the text alignmentsetLabelAlignment(int)
public void setTextPlacement(int where)
where
- the text placementpublic TextUtilities getTextUtilities()
TextUtilities
instance to be used in measurement
calculations.TextUtilities
instanceprotected java.lang.String getTruncationString()
protected Dimension getIconSize()
public int getLabelAlignment()
PositionConstants.CENTER
.Copyright (c) IBM Corp. and others 2000, 2011. All Rights Reserved.