Runtime

## org.eclipse.gmf.runtime.gef.ui.figures
Class NodeFigure

    java.lang.Object
      org.eclipse.draw2d.Figure
          org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure

All Implemented Interfaces:
  IFigure, HandleBounds, IAnchorableFigure, IPolygonAnchorableFigure

Direct Known Subclasses:
  DefaultSizeNodeFigure, WrapperNodeFigure

    public class NodeFigure

extends Figure
implements HandleBounds, IAnchorableFigure, IPolygonAnchorableFigure

Base class that most shape figures should extend from to gain default connection anchor behavior.

Nested Class Summary

Nested classes/interfaces inherited from class org.eclipse.draw2d.Figure
`Figure.FigureIterator, Figure.IdentitySearch`

Nested classes/interfaces inherited from interface org.eclipse.draw2d.IFigure
`IFigure.NoInsets`

Field Summary
`static java.lang.String` `szAnchor` `String` that is the identifier for the default anchor

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.IFigure
`MAX_DIMENSION, MIN_DIMENSION, NO_INSETS`

Constructor Summary
`NodeFigure()` Constructor - sets the default colors for all node figures.

Method Summary
`protected void` `applyTransparency(Graphics g)` Converts transparency value from percent range [0, 100] to alpha range [0, 255] and applies converted value. 0% corresponds to alpha 255 and 100% corresponds to alpha 0.
`protected ConnectionAnchor` `createAnchor(PrecisionPoint p)` Creates a slidable anchor at the specified point (from the ratio of the reference's coordinates and bounds of the figure
`protected ConnectionAnchor` `createConnectionAnchor(Point p)` Returns a new anchor for this node figure.
`protected ConnectionAnchor` `createDefaultAnchor()` Creates the default Slidable anchor with a reference point at the center of the figure's bounds
`protected void` `fillGradient(Graphics g)` Fills gradient using default mode SWT.FILL_EVEN_ODD and getPath() to obtain path to fill.
`protected void` `fillGradient(Graphics g, int fillMode)` Fills gradient using getPath() to obtain path to fill.
`protected void` `fillGradient(Graphics g, Path path)` Fills gradient using default mode SWT.FILL_EVEN_ODD.
`protected void` `fillGradient(Graphics g, Path path, int fillMode)` Fills given path by gradient using given fillMode
`ConnectionAnchor` `getConnectionAnchor(java.lang.String terminal)` Given a string identifier, return the associated anchor for that identifier
`protected java.util.Hashtable` `getConnectionAnchors()` Returns the connectionAnchors.
`java.lang.String` `getConnectionAnchorTerminal(ConnectionAnchor c)` Dynamically allocates a new anchor if needed.
`static java.lang.String` `getDefaultAnchorID()`
`int` `getGradientColor1()`
`int` `getGradientColor2()`
`int` `getGradientStyle()`
`Rectangle` `getHandleBounds()`
`int` `getLineStyle()` Returns the line style used to outline this shape.
`int` `getLineWidth()` Returns the line width of this shape's outline.
`protected Path` `getPath()` This method creates and returns figure's path.
`PointList` `getPolygonPoints()` This method allows the implementing class to return a list of points that represent the polygon to be connected to.
`protected double` `getSlidableAnchorArea()` Specifies how large the area of the figure's bounds where `SlidableAnchor` will be created.
`ConnectionAnchor` `getSourceConnectionAnchorAt(Point p)` Gets the source connection anchor at a given point on the figure.
`ConnectionAnchor` `getTargetConnectionAnchorAt(Point p)` Gets the target connection anchor at a given point on the figure.
`int` `getTransparency()` Returns transparency value (belongs to [0, 100] interval)
`protected boolean` `isDefaultAnchorArea(PrecisionPoint p)` Checks whether the <PrecisionPoint> p which is a candidate for a relative reference for the `SlidableAnchor` belongs to the area where the default anchor must be created
`boolean` `isUsingGradient()` Utility method that indicates if gradient should be used as a fill style or not.
`protected void` `paintFigure(Graphics graphics)`
`void` `setGradientData(int gradientColor1, int gradientColor2, int gradientStyle)` Sets values defining gradient data.
`void` `setIsUsingGradient(boolean b)` Sets the value of isUsingGradient
`void` `setLineStyle(int s)` Sets the style of line to be used by this shape.
`void` `setLineWidth(int w)` Sets the line width to be used to outline the shape.
`void` `setTransparency(int transparency)` Sets the transparency if the given parameter is in [0, 100] range

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, getMinimumSize, getParent, getPreferredSize, getPreferredSize, getSize, getToolTip, getUpdateManager, handleFocusGained, handleFocusLost, handleKeyPressed, handleKeyReleased, handleMouseDoubleClicked, handleMouseDragged, handleMouseEntered, handleMouseExited, handleMouseHover, handleMouseMoved, handleMousePressed, handleMouseReleased, hasFocus, internalGetEventDispatcher, intersects, invalidate, 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`

Methods inherited from interface org.eclipse.draw2d.IFigure

`add, add, add, add, addAncestorListener, addCoordinateListener, addFigureListener, addFocusListener, addKeyListener, addLayoutListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, containsPoint, containsPoint, erase, findFigureAt, findFigureAt, findFigureAt, findFigureAtExcluding, findMouseEventTargetAt, getBackgroundColor, getBorder, getBounds, getChildren, getClientArea, getClientArea, getCursor, getFont, getForegroundColor, getInsets, getLayoutManager, getLocalBackgroundColor, getLocalForegroundColor, getMaximumSize, getMinimumSize, getMinimumSize, getParent, getPreferredSize, getPreferredSize, getSize, getToolTip, getUpdateManager, handleFocusGained, handleFocusLost, handleKeyPressed, handleKeyReleased, handleMouseDoubleClicked, handleMouseDragged, handleMouseEntered, handleMouseExited, handleMouseHover, handleMouseMoved, handleMousePressed, handleMouseReleased, hasFocus, internalGetEventDispatcher, intersects, invalidate, invalidateTree, isCoordinateSystem, isEnabled, isFocusTraversable, isMirrored, isOpaque, isRequestFocusEnabled, isShowing, isVisible, paint, remove, removeAncestorListener, removeCoordinateListener, removeFigureListener, removeFocusListener, removeKeyListener, removeLayoutListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, revalidate, setBackgroundColor, setBorder, setBounds, setConstraint, setCursor, setEnabled, setFocusTraversable, setFont, setForegroundColor, setLayoutManager, setLocation, setMaximumSize, setMinimumSize, setOpaque, setParent, setPreferredSize, setRequestFocusEnabled, setSize, setSize, setToolTip, setVisible, translate, translateFromParent, translateToAbsolute, translateToParent, translateToRelative, validate`

Field Detail

### szAnchor

    public static final java.lang.String szAnchor

  `String` that is the identifier for the default anchor

  See Also:
    Constant Field Values

Constructor Detail

### NodeFigure

    public NodeFigure()

  Constructor - sets the default colors for all node figures.

Method Detail

### getHandleBounds

    public Rectangle getHandleBounds()

  Specified by:
    `getHandleBounds` in interface `HandleBounds`

### getConnectionAnchor

    public ConnectionAnchor getConnectionAnchor(java.lang.String terminal)

  Description copied from interface: `IAnchorableFigure`
  Given a string identifier, return the associated anchor for that identifier

  Specified by:
    `getConnectionAnchor` in interface `IAnchorableFigure`
  Parameters:
    `terminal` - `String` identifier associated with the anchor
  Returns:
    `ConnectionAnchor` that is associated with the given string.

### getConnectionAnchorTerminal

    public java.lang.String getConnectionAnchorTerminal(ConnectionAnchor c)

  Description copied from interface: `IAnchorableFigure`
  Dynamically allocates a new anchor if needed. Otherwise, recycles old anchors no longer in use.

  Specified by:
    `getConnectionAnchorTerminal` in interface `IAnchorableFigure`
  Parameters:
    `c` - the `ConnectionAnchor` reference to an anchor associated with the given point on the figure
  Returns:
    a `String` that represents the anchor identifier.

### getSourceConnectionAnchorAt

    public ConnectionAnchor getSourceConnectionAnchorAt(Point p)

  Description copied from interface: `IAnchorableFigure`
  Gets the source connection anchor at a given point on the figure.

  Specified by:
    `getSourceConnectionAnchorAt` in interface `IAnchorableFigure`
  Parameters:
    `p` - `Point` on the figure that gives a hint which anchor to return.
  Returns:
    a `ConnectionAnchor` reference to an anchor associated with the given point on the figure.

### getTargetConnectionAnchorAt

    public ConnectionAnchor getTargetConnectionAnchorAt(Point p)

  Description copied from interface: `IAnchorableFigure`
  Gets the target connection anchor at a given point on the figure.

  Specified by:
    `getTargetConnectionAnchorAt` in interface `IAnchorableFigure`
  Parameters:
    `p` - `Point` on the figure that gives a hint which anchor to return.
  Returns:
    `ConnectionAnchor` reference to an anchor associated with the given point on the figure.

### createConnectionAnchor

    protected ConnectionAnchor createConnectionAnchor(Point p)

  Returns a new anchor for this node figure.

  Parameters:
    `p` - `Point` on the figure that gives a hint which anchor to return.
  Returns:
    `ConnectionAnchor` reference to an anchor associated with the given point on the figure.

### isDefaultAnchorArea

    protected boolean isDefaultAnchorArea(PrecisionPoint p)

  Checks whether the <PrecisionPoint> p which is a candidate for a relative reference for the `SlidableAnchor` belongs to the area where the default anchor must be created

  Parameters:
    `p` -
  Returns:
    `boolean` `true` if <PrecisionPoint> belongs to the area where the default anchor must be created, `false` otherwise

### paintFigure

    protected void paintFigure(Graphics graphics)

  Overrides:
    `paintFigure` in class `Figure`

### getConnectionAnchors

    protected java.util.Hashtable getConnectionAnchors()

  Returns the connectionAnchors.

  Returns:
    Hashtable

### getSlidableAnchorArea

    protected double getSlidableAnchorArea()

  Specifies how large the area of the figure's bounds where `SlidableAnchor` will be created. The result number: 0<=result<=1

  Returns:
    the size of the area of the figure's bounds

### createDefaultAnchor

    protected ConnectionAnchor createDefaultAnchor()

  Creates the default Slidable anchor with a reference point at the center of the figure's bounds

  Returns:
    - default SlidableAnchor, relative reference the center of the figure

### createAnchor

    protected ConnectionAnchor createAnchor(PrecisionPoint p)

  Creates a slidable anchor at the specified point (from the ratio of the reference's coordinates and bounds of the figure

  Parameters:
    `p` - - relative reference for the `SlidableAnchor`
  Returns:
    a `SlidableAnchor` for this figure with relative reference at p

### getDefaultAnchorID

    public static java.lang.String getDefaultAnchorID()

  Returns:
    `String` that is the identifier for the default anchor

### getPolygonPoints

    public PointList getPolygonPoints()

  Description copied from interface: `IPolygonAnchorableFigure`
  This method allows the implementing class to return a list of points that represent the polygon to be connected to.

  Specified by:
    `getPolygonPoints` in interface `IPolygonAnchorableFigure`
  Returns:
    a list of points forming the polygon

### getLineStyle

    public int getLineStyle()

  Returns the line style used to outline this shape.

  Returns:
    the line style
  Since:
    2.1

### getLineWidth

    public int getLineWidth()

  Returns the line width of this shape's outline.

  Returns:
    the line width
  Since:
    2.1

### setLineWidth

    public void setLineWidth(int w)

  Sets the line width to be used to outline the shape.

  Parameters:
    `w` - the new width
  Since:
    2.1

### setLineStyle

    public void setLineStyle(int s)

  Sets the style of line to be used by this shape.

  Parameters:
    `s` - the new line style
  Since:
    2.1

### getGradientColor1

    public int getGradientColor1()

  Returns:
    the gradientColor1
  Since:
    1.2

### getGradientColor2

    public int getGradientColor2()

  Returns:
    the gradientColor2
  Since:
    1.2

### getGradientStyle

    public int getGradientStyle()

  Returns:
    the gradientStyle
  Since:
    1.2

### setGradientData

    public void setGradientData(int gradientColor1,
                                int gradientColor2,
                                int gradientStyle)

  Sets values defining gradient data.

  Parameters:
    `gradientColor1` -
    `gradientColor2` -
    `gradientStyle` -
  Since:
    1.2

### isUsingGradient

    public boolean isUsingGradient()

  Utility method that indicates if gradient should be used as a fill style or not.

  Returns:
    true if gradient should be used, false otherwise (fill color should be used)
  Since:
    1.2

### setIsUsingGradient

    public void setIsUsingGradient(boolean b)

  Sets the value of isUsingGradient

  Parameters:
    `b` - value for isUsingGradient
  Since:
    1.2

### fillGradient

    protected void fillGradient(Graphics g,
                                Path path,
                                int fillMode)

  Fills given path by gradient using given fillMode

  Parameters:
    `g` - The Graphics used to paint
    `path` - Path of shape to be filled with gradient
    `fillMode` - One of SWT.FILL_EVEN_ODD and SWT.FILL_WINDING
  Since:
    1.2

### fillGradient

    protected void fillGradient(Graphics g)

  Fills gradient using default mode SWT.FILL_EVEN_ODD and getPath() to obtain path to fill.

  Parameters:
    `g` - The Graphics used to paint
  Since:
    1.2

### fillGradient

    protected void fillGradient(Graphics g,
                                Path path)

  Fills gradient using default mode SWT.FILL_EVEN_ODD. Use this method when getPath() doesn't return desired path.

  Parameters:
    `g` - The Graphics used to paint
    `path` - Path of shape to be filled with gradient
  Since:
    1.2

### fillGradient

    protected void fillGradient(Graphics g,
                                int fillMode)

  Fills gradient using getPath() to obtain path to fill. Use this method when default fill mode SWT.FILL_EVEN_ODD is not appropriate.

  Parameters:
    `g` - The Graphics used to paint
    `fillMode` - One of SWT.FILL_EVEN_ODD and SWT.FILL_WINDING
  Since:
    1.2

### getPath

    protected Path getPath()

  This method creates and returns figure's path. Default implementation defines path based on figure's bounds and insets. Subclasses should override if needed.

  Returns:
    Created path
  Since:
    1.2

### getTransparency

    public int getTransparency()

  Returns transparency value (belongs to [0, 100] interval)

  Returns:
    transparency
  Since:
    1.2

### setTransparency

    public void setTransparency(int transparency)

  Sets the transparency if the given parameter is in [0, 100] range

  Parameters:
    `transparency` - The transparency to set
  Since:
    1.2

### applyTransparency

    protected void applyTransparency(Graphics g)

  Converts transparency value from percent range [0, 100] to alpha range [0, 255] and applies converted value. 0% corresponds to alpha 255 and 100% corresponds to alpha 0.

  Parameters:
    `g` - The Graphics used to paint
  Since:
    1.2

Runtime

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.