Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse Draw2d
3.3

org.eclipse.draw2d
Class Label

java.lang.Object
  extended by

org.eclipse.draw2d.Figure
      extended by
org.eclipse.draw2d.Label
All Implemented Interfaces:
IFigure, PositionConstants

public class Label
extends Figure
implements PositionConstants

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 (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.
 
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.
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.
 
Methods inherited from class org.eclipse.draw2d. Figure
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, 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, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Label

public Label()
Construct an empty Label.

Since:
2.0

Label

public Label(java.lang.String s)
Construct a Label with passed String as its text.

Parameters:
s - the label text
Since:
2.0

Label

public Label(java.lang.String s,
             Image i)
Construct 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 Detail

calculateLabelSize

protected 
Dimension calculateLabelSize(
Dimension txtSize)
Calculates 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

calculateSubStringTextSize

protected 
Dimension calculateSubStringTextSize()
Calculates 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, use calculateTextSize().

Returns:
the size of the label's text, taking into account truncation
Since:
2.0

calculateTextSize

protected 
Dimension calculateTextSize()
Calculates 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, use calculateSubStringTextSize().

Returns:
the size of the label's text, ignoring truncation
Since:
2.0

getIcon

public Image getIcon()
Returns the Label's icon.

Returns:
the label icon
Since:
2.0

getIconAlignment

public int getIconAlignment()
Returns the current alignment of the Label's icon. The default is PositionConstants.CENTER.

Returns:
the icon alignment
Since:
2.0

getIconBounds

public 
Rectangle getIconBounds()
Returns the bounds of the Label's icon.

Returns:
the icon's bounds
Since:
2.0

getIconLocation

protected 
Point getIconLocation()
Returns the location of the Label's icon relative to the Label.

Returns:
the icon's location
Since:
2.0

getIconTextGap

public int getIconTextGap()
Returns the gap in pixels between the Label's icon and its text.

Returns:
the gap
Since:
2.0

getMinimumSize

public 
Dimension getMinimumSize(int w,
                                int h)
Description copied from interface: IFigure
Returns 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:
getMinimumSize in interface IFigure
Overrides:
getMinimumSize in class Figure
See Also:
IFigure.getMinimumSize(int, int)

getPreferredSize

public 
Dimension getPreferredSize(int wHint,
                                  int hHint)
Description copied from interface: IFigure
Returns 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 -1 indicates that there is no constraint in that direction.

Specified by:
getPreferredSize in interface IFigure
Overrides:
getPreferredSize in class Figure
See Also:
IFigure.getPreferredSize(int, int)

getSubStringText

public 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.

Returns:
the substring
Since:
2.0

getSubStringTextSize

protected 
Dimension getSubStringTextSize()
Returns 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

getText

public java.lang.String getText()
Returns the text of the label. Note that this is the complete text of the label, regardless of whether it is currently being truncated. Call getSubStringText() to return the label's current text contents with truncation considered.

Returns:
the complete text of this label
Since:
2.0

getTextAlignment

public int getTextAlignment()
Returns the current alignment of the Label's text. The default text alignment is PositionConstants.CENTER.

Returns:
the text alignment

getTextBounds

public 
Rectangle getTextBounds()
Returns 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

getTextLocation

protected 
Point getTextLocation()
Returns the location of the label's text relative to the label.

Returns:
the text location
Since:
2.0

getTextPlacement

public int getTextPlacement()
Returns the current placement of the label's text relative to its icon. The default text placement is PositionConstants.EAST.

Returns:
the text placement
Since:
2.0

getTextSize

protected 
Dimension getTextSize()
Returns 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, call getSubStringTextSize().

Returns:
the size of this label's complete text
Since:
2.0

invalidate

public void invalidate()
Description copied from interface: IFigure
Invalidates this IFigure. If this figure has a LayoutManager, then LayoutManager.invalidate() should be called on that layout.

Specified by:
invalidate in interface IFigure
Overrides:
invalidate in class Figure
See Also:
IFigure.invalidate()

isTextTruncated

public boolean isTextTruncated()
Returns true if the label's text is currently truncated and is displaying an ellipsis, false otherwise.

Returns:
true if the label's text is truncated
Since:
2.0

paintFigure

protected void paintFigure(
Graphics graphics)
Description copied from class: Figure
Paints this Figure's primary representation, or background. Changes made to the graphics to the graphics current state will not affect the subsequent calls to 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.

Overrides:
paintFigure in class Figure
Parameters:
graphics - The Graphics used to paint
See Also:
Figure.paintFigure(Graphics)

setIcon

public void setIcon(Image image)
Sets the label's icon to the passed image.

Parameters:
image - the new label image
Since:
2.0

setIconAlignment

public 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

setIconDimension

public void setIconDimension(
Dimension d)
Deprecated. the icon is automatically displayed at 1:1

Sets the label's icon size to the passed Dimension.

Parameters:
d - the new icon size
Since:
2.0

setIconTextGap

public 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

setLabelAlignment

public 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

setText

public void setText(java.lang.String s)
Sets the label's text.

Parameters:
s - the new label text
Since:
2.0

setTextAlignment

public 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:
setLabelAlignment(int)

setTextPlacement

public 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

getTextUtilities

public 
TextUtilities getTextUtilities()
Gets the TextUtilities instance to be used in measurement calculations.

Returns:
a TextUtilities instance
Since:
3.4

getTruncationString

protected java.lang.String getTruncationString()
Gets 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

getIconSize

protected 
Dimension getIconSize()
Gets the icon size

Returns:
the icon size
Since:
3.4

getLabelAlignment

public int getLabelAlignment()
Returns the alignment of the entire label (icon and text). The default label alignment is PositionConstants.CENTER.

Returns:
the label alignment
Since:
3.5

Eclipse Draw2d
3.3

Copyright (c) IBM Corp. and others 2000, 2007. All Rights Reserved.

 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire