Package org.eclipse.draw2d
Class Label
java.lang.Object
org.eclipse.draw2d.Figure
org.eclipse.draw2d.Label
- All Implemented Interfaces:
- IFigure,- PositionConstants
A figure that can display text and/or an image.
- 
Nested Class SummaryNested classes/interfaces inherited from class org.eclipse.draw2d.FigureFigure.FigureIterator, Figure.IdentitySearch, Figure.ReverseFigureChildrenIteratorNested classes/interfaces inherited from interface org.eclipse.draw2d.IFigureIFigure.NoInsets
- 
Field SummaryFields inherited from class org.eclipse.draw2d.FigurebgColor, border, bounds, fgColor, flags, font, MAX_FLAG, maxSize, minSize, NO_MANAGER, prefSize, toolTipFields inherited from interface org.eclipse.draw2d.IFigureMAX_DIMENSION, MIN_DIMENSION, NO_INSETSFields inherited from interface org.eclipse.draw2d.PositionConstantsALWAYS_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
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected DimensioncalculateLabelSize(Dimension txtSize) Calculates the size of the Label using the passed Dimension as the size of the Label's text.protected DimensionCalculates the size of the Label's text size.protected DimensionCalculates and returns the size of the Label's text.getIcon()Returns the Label's icon.intReturns the current alignment of the Label's icon.Returns the bounds of the Label's icon.protected PointReturns the location of the Label's icon relative to the Label.protected DimensionGets the icon sizeintReturns the gap in pixels between the Label's icon and its text.intReturns the alignment of the entire label (icon and text).getMinimumSize(int w, int h) Returns a hint indicating the smallest desireable size for the IFigure.getPreferredSize(int wHint, int hHint) Returns the preferred size for this IFigure using the provided width and height hints.Calculates the amount of the Label's current text will fit in the Label, including an elipsis "..." if truncation is required.protected DimensionReturns the size of the Label's current text.getText()Returns the text of the label.intReturns the current alignment of the Label's text.Returns the bounds of the label's text.protected PointReturns the location of the label's text relative to the label.intReturns the current placement of the label's text relative to its icon.protected DimensionReturns the size of the label's complete text.Gets theTextUtilitiesinstance to be used in measurement calculations.protected StringGets the string that will be appended to the text when the label is truncated.voidInvalidates this IFigure.booleanReturnstrueif the label's text is currently truncated and is displaying an ellipsis,falseotherwise.protected voidpaintFigure(Graphics graphics) Paints this Figure's primary representation, or background.voidSets the label's icon to the passed image.voidsetIconAlignment(int align) This method sets the alignment of the icon within the bounds of the label.voidDeprecated.the icon is automatically displayed at 1:1voidsetIconTextGap(int gap) Sets the gap in pixels between the label's icon and text to the passed value.voidsetLabelAlignment(int align) Sets the alignment of the label (icon and text) within the figure.voidSets the label's text.voidsetTextAlignment(int align) Sets the alignment of the text relative to the icon within the label.voidsetTextPlacement(int where) Sets the placement of the text relative to the icon within the label.Methods inherited from class org.eclipse.draw2d.Figureadd, add, add, add, addAncestorListener, addCoordinateListener, addFigureListener, addFocusListener, addKeyListener, addLayoutListener, addListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, containsPoint, containsPoint, erase, findDescendantAtExcluding, findFigureAt, findFigureAt, findFigureAt, findFigureAtExcluding, findMouseEventTargetAt, findMouseEventTargetInDescendantsAt, fireCoordinateSystemChanged, fireFigureMoved, fireMoved, firePropertyChange, firePropertyChange, firePropertyChange, getBackgroundColor, getBorder, getBounds, getChildren, getChildrenRevIterable, getClientArea, getClientArea, getClippingStrategy, getCursor, getFlag, getFont, getForegroundColor, getInsets, getLayoutManager, getListeners, getListenersIterable, getLocalBackgroundColor, getLocalFont, getLocalForegroundColor, getLocation, getMaximumSize, getMinimumSize, getParent, getPreferredSize, getSize, getToolTip, getUpdateManager, handleFocusGained, handleFocusLost, handleKeyPressed, handleKeyReleased, handleMouseDoubleClicked, handleMouseDragged, handleMouseEntered, handleMouseExited, handleMouseHover, handleMouseMoved, handleMousePressed, handleMouseReleased, handleMouseWheelScrolled, hasFocus, internalGetEventDispatcher, intersects, invalidateTree, isCoordinateSystem, isEnabled, isFocusTraversable, isMirrored, isMouseEventTarget, isOpaque, isRequestFocusEnabled, isShowing, isValid, isValidationRoot, isVisible, layout, optimizeClip, paint, paintBorder, paintChildren, paintClientArea, primTranslate, remove, removeAll, removeAncestorListener, removeCoordinateListener, removeFigureListener, removeFocusListener, removeKeyListener, removeLayoutListener, removeListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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
- 
Constructor Details- 
Labelpublic Label()Construct an empty Label.- Since:
- 2.0
 
- 
LabelConstruct a Label with passed String as its text.- Parameters:
- s- the label text
- Since:
- 2.0
 
- 
LabelConstruct a Label with passed Image as its icon.- Parameters:
- i- the label image
- Since:
- 2.0
 
- 
LabelConstruct a Label with passed String as text and passed Image as its icon.- Parameters:
- s- the label text
- i- the label image
- Since:
- 2.0
 
 
- 
- 
Method Details- 
calculateLabelSizeCalculates the size of the Label using the passed Dimension as the size of the Label's text.- Parameters:
- txtSize- the precalculated size of the label's text
- Returns:
- the label's size
- Since:
- 2.0
 
- 
calculateSubStringTextSizeCalculates the size of the Label's text size. The text size calculated takes into consideration if the Label's text is currently truncated. If text size without considering current truncation is desired, usecalculateTextSize().- Returns:
- the size of the label's text, taking into account truncation
- Since:
- 2.0
 
- 
calculateTextSizeCalculates and returns the size of the Label's text. Note that this Dimension is calculated using the Label's full text, regardless of whether or not its text is currently truncated. If text size considering current truncation is desired, usecalculateSubStringTextSize().- Returns:
- the size of the label's text, ignoring truncation
- Since:
- 2.0
 
- 
getIconReturns the Label's icon.- Returns:
- the label icon
- Since:
- 2.0
 
- 
getIconAlignmentpublic int getIconAlignment()Returns the current alignment of the Label's icon. The default isPositionConstants.CENTER.- Returns:
- the icon alignment
- Since:
- 2.0
 
- 
getIconBoundsReturns the bounds of the Label's icon.- Returns:
- the icon's bounds
- Since:
- 2.0
 
- 
getIconLocationReturns the location of the Label's icon relative to the Label.- Returns:
- the icon's location
- Since:
- 2.0
 
- 
getIconTextGappublic int getIconTextGap()Returns the gap in pixels between the Label's icon and its text.- Returns:
- the gap
- Since:
- 2.0
 
- 
getMinimumSizeDescription copied from interface:IFigureReturns a hint indicating the smallest desireable size for the IFigure. The returned dimension may be by reference, and it must not be modified by the caller.- Specified by:
- getMinimumSizein interface- IFigure
- Overrides:
- getMinimumSizein class- Figure
- Parameters:
- w- the width hint
- h- the height hint
- Returns:
- The minimum size
- See Also:
 
- 
getPreferredSizeDescription copied from interface:IFigureReturns the preferred size for this IFigure using the provided width and height hints. The returned dimension may be by reference, and it must not be modified by the caller. A value of-1indicates that there is no constraint in that direction.- Specified by:
- getPreferredSizein interface- IFigure
- Overrides:
- getPreferredSizein class- Figure
- Parameters:
- wHint- a width hint
- hHint- a height hint
- Returns:
- The preferred size
- See Also:
 
- 
getSubStringTextCalculates the amount of the Label's current text will fit in the Label, including an elipsis "..." if truncation is required.- Returns:
- the substring
- Since:
- 2.0
 
- 
getSubStringTextSizeReturns the size of the Label's current text. If the text is currently truncated, the truncated text with its ellipsis is used to calculate the size.- Returns:
- the size of this label's text, taking into account truncation
- Since:
- 2.0
 
- 
getTextReturns the text of the label. Note that this is the complete text of the label, regardless of whether it is currently being truncated. CallgetSubStringText()to return the label's current text contents with truncation considered.- Returns:
- the complete text of this label
- Since:
- 2.0
 
- 
getTextAlignmentpublic int getTextAlignment()Returns the current alignment of the Label's text. The default text alignment isPositionConstants.CENTER.- Returns:
- the text alignment
 
- 
getTextBoundsReturns the bounds of the label's text. Note that the bounds are calculated using the label's complete text regardless of whether the label's text is currently truncated.- Returns:
- the bounds of this label's complete text
- Since:
- 2.0
 
- 
getTextLocationReturns the location of the label's text relative to the label.- Returns:
- the text location
- Since:
- 2.0
 
- 
getTextPlacementpublic int getTextPlacement()Returns the current placement of the label's text relative to its icon. The default text placement isPositionConstants.EAST.- Returns:
- the text placement
- Since:
- 2.0
 
- 
getTextSizeReturns the size of the label's complete text. Note that the text used to make this calculation is the label's full text, regardless of whether the label's text is currently being truncated and is displaying an ellipsis. If the size considering current truncation is desired, callgetSubStringTextSize().- Returns:
- the size of this label's complete text
- Since:
- 2.0
 
- 
invalidatepublic void invalidate()Description copied from interface:IFigureInvalidates this IFigure. If this figure has a LayoutManager, thenLayoutManager.invalidate()should be called on that layout.- Specified by:
- invalidatein interface- IFigure
- Overrides:
- invalidatein class- Figure
- See Also:
 
- 
isTextTruncatedpublic boolean isTextTruncated()Returnstrueif the label's text is currently truncated and is displaying an ellipsis,falseotherwise.- Returns:
- trueif the label's text is truncated
- Since:
- 2.0
 
- 
paintFigureDescription copied from class:FigurePaints this Figure's primary representation, or background. Changes made to the graphics to the graphics current state will not affect the subsequent calls toFigure.paintClientArea(Graphics)andFigure.paintBorder(Graphics). Furthermore, it is safe to callgraphics.restoreState()within this method, and doing so will restore the graphics to its original state upon entry.- Overrides:
- paintFigurein class- Figure
- Parameters:
- graphics- The Graphics used to paint
- See Also:
 
- 
setIconSets the label's icon to the passed image.- Parameters:
- image- the new label image
- Since:
- 2.0
 
- 
setIconAlignmentpublic void setIconAlignment(int align) This method sets the alignment of the icon within the bounds of the label. If the label is larger than the icon, then the icon will be aligned according to this alignment. Valid values are:- Parameters:
- align- the icon alignment
- Since:
- 2.0
 
- 
setIconDimensionDeprecated.the icon is automatically displayed at 1:1Sets the label's icon size to the passed Dimension.- Parameters:
- d- the new icon size
- Since:
- 2.0
 
- 
setIconTextGappublic void setIconTextGap(int gap) Sets the gap in pixels between the label's icon and text to the passed value. The default is 4.- Parameters:
- gap- the gap
- Since:
- 2.0
 
- 
setLabelAlignmentpublic void setLabelAlignment(int align) Sets the alignment of the label (icon and text) within the figure. If this figure's bounds are larger than the size needed to display the label, the label will be aligned accordingly. Valid values are:- Parameters:
- align- label alignment
 
- 
setTextSets the label's text.- Parameters:
- s- the new label text
- Since:
- 2.0
 
- 
setTextAlignmentpublic void setTextAlignment(int align) Sets the alignment of the text relative to the icon within the label. The text alignment must be orthogonal to the text placement. For example, if the placement is EAST, then the text can be aligned using TOP, CENTER, or BOTTOM. Valid values are:- Parameters:
- align- the text alignment
- Since:
- 2.0
- See Also:
 
- 
setTextPlacementpublic void setTextPlacement(int where) Sets the placement of the text relative to the icon within the label. Valid values are:- Parameters:
- where- the text placement
- Since:
- 2.0
 
- 
getTextUtilitiesGets theTextUtilitiesinstance to be used in measurement calculations.- Returns:
- a TextUtilitiesinstance
- Since:
- 3.4
 
- 
getTruncationStringGets the string that will be appended to the text when the label is truncated. By default, this returns an ellipsis.- Returns:
- the string to append to the text when truncated
- Since:
- 3.4
 
- 
getIconSizeGets the icon size- Returns:
- the icon size
- Since:
- 3.4
 
- 
getLabelAlignmentpublic int getLabelAlignment()Returns the alignment of the entire label (icon and text). The default label alignment isPositionConstants.CENTER.- Returns:
- the label alignment
- Since:
- 3.5
 
 
-