Package org.eclipse.graphiti.ui.internal.figures

# Class GFAbstractShape

java.lang.Object
org.eclipse.draw2d.Figure
org.eclipse.draw2d.Shape
org.eclipse.graphiti.ui.internal.figures.GFAbstractShape

All Implemented Interfaces:
  `org.eclipse.draw2d.IFigure`, `org.eclipse.gef.handles.HandleBounds`, `IVisualStateChangeListener`, `IVisualStateHolder`

Direct Known Subclasses:
  `GFAbstractPointListShape`, `GFAbstractRotatableDecoration`, `GFEllipse`, `GFRectangleFigure`, `GFRoundedRectangle`

public abstract class GFAbstractShape extends org.eclipse.draw2d.Shape implements org.eclipse.gef.handles.HandleBounds, IVisualStateHolder, IVisualStateChangeListener
This class is an abstract super-class for all Shapes in Graphiti. The main idea is, that the outline and fill-area of a Shape is defined by a Path. Sub-classes usually only have to implement the abstract method `createPath(Rectangle, Graphics, boolean)`

## Nested Class Summary

## Nested classes/interfaces inherited from class org.eclipse.draw2d.Figure

`org.eclipse.draw2d.Figure.FigureIterator, org.eclipse.draw2d.Figure.IdentitySearch, org.eclipse.draw2d.Figure.ReverseFigureChildrenIterator`

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

`org.eclipse.draw2d.IFigure.NoInsets`

## Field Summary

### Fields inherited from class org.eclipse.draw2d.Shape

`lineStyle, lineWidth`

### 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

Constructors
Constructor
Description
`GFAbstractShape(IPictogramElementDelegate pictogramElementDelegate, GraphicsAlgorithm graphicsAlgorithm)`
Creates a new GFAbstractShape.

## Method Summary

Modifier and Type
Method
Description
`final boolean`
`containsPoint(int x, int y)`
Returns true, if the given point is contained inside this Shape.
`protected Boolean`
`containsPointInArea(int x, int y)`
Returns true, if the given point is contained inside one of the selection-area GraphicsAlgorithms defined in `getClickArea()`.
`protected boolean`
`containsPointInFigure(int x, int y)`
Returns true, if the given point is contained inside this Shape.
`protected abstract org.eclipse.swt.graphics.Path`
`createPath(org.eclipse.draw2d.geometry.Rectangle outerBounds, org.eclipse.draw2d.Graphics graphics, boolean isFill)`
Returns the Path which shall be painted in `paintShape(Graphics, boolean)`.
`protected void`
`fillPath(org.eclipse.draw2d.Graphics graphics, org.eclipse.swt.graphics.Path path)`
A helper method, which fills the Path according to the fill-colors of this figures GraphicsAlgorithm.
`protected void`
`fillShape(org.eclipse.draw2d.Graphics graphics)`
Fills this Shape on the given Graphics.
`protected GraphicsAlgorithm[]`
`getClickArea()`
Returns the selection-area GraphicsAlgorithms of this Shape.
`protected IConfigurationProviderInternal`
`getConfigurationProvider()`
Returns the IConfigurationProviderInternal.
`protected GraphicsAlgorithm`
`getGraphicsAlgorithm()`
Returns the GraphicsAlgorithm, which was given in the constructor.
`org.eclipse.draw2d.geometry.Rectangle`
`getHandleBounds()`
Returns the selection handle bounds of this Shape.
`protected int`
`getLineWidth(org.eclipse.draw2d.Graphics graphics)`
Returns the line-width of this figure adjusted according to the given Graphics.
`protected IPictogramElementDelegate`
`getPictogramElementDelegate()`
Returns the PictogramElementDelegate, which was given in the constructor.
`protected GFPreferences`
`getPreferences()`
`protected GraphicsAlgorithm`
`getSelectionBorder()`
Returns the selection GraphicsAlgorithm of this Shape.
`IVisualState`
`getVisualState()`
Returns the visual state of this shape.
`protected double`
`getZoomLevel(org.eclipse.draw2d.Graphics graphics)`
Resolves the current zoom level for the graphical context.
`protected void`
`outlineShape(org.eclipse.draw2d.Graphics graphics)`
Outlines this Shape on the given Graphics.
`void`
`paintFigure(org.eclipse.draw2d.Graphics graphics)`
First initializes the given Graphics with settings like alpha-value, antialias-value, ...
`protected void`
`paintShape(org.eclipse.draw2d.Graphics graphics, boolean isFill)`
Outlines or fills this Shape on the given Graphics.
`void`
`setClickArea(GraphicsAlgorithm[] clickArea)`
`void`
`setSelectionBorder(GraphicsAlgorithm selectionBorder)`
`protected void`
`transformToFillBounds(org.eclipse.draw2d.geometry.Rectangle outlineBounds, org.eclipse.draw2d.Graphics graphics)`
Changes the given outline-bounds which should be calculated by
invalid reference

    #getSingletonOutlineBounds(Graphics)

) to the fill-bounds.
`void`
`visualStateChanged(VisualStateChangedEvent e)`
Is called after the visual state changed.

### Methods inherited from class org.eclipse.draw2d.Shape

`getAlpha, getAntialias, getLineAttributes, getLineCap, getLineDash, getLineDashOffset, getLineJoin, getLineMiterLimit, getLineStyle, getLineWidth, getLineWidthFloat, setAlpha, setAlpha, setAntialias, setAntialias, setFill, setFillXOR, setLineAttributes, setLineCap, setLineDash, setLineDashOffset, setLineJoin, setLineMiterLimit, setLineStyle, setLineWidth, setLineWidthFloat, setOutline, setOutlineXOR, setXOR`

### Methods inherited from class org.eclipse.draw2d.Figure

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

## Constructor Details

### GFAbstractShape

public GFAbstractShape(IPictogramElementDelegate pictogramElementDelegate, GraphicsAlgorithm graphicsAlgorithm)
Creates a new GFAbstractShape.

Parameters:
  `pictogramElementDelegate` - The PictogramElementDelegate which provides the GraphicsAlgorithm.
  `graphicsAlgorithm` - The GraphicsAlgorithm which provides the values to paint this Shape. It is either the immediate GraphicsAlgorithm of the PictogramElementDelegate or a child of that immediate GraphicsAlgorithm. It must not be null.

## Method Details

### createPath

protected abstract org.eclipse.swt.graphics.Path createPath(org.eclipse.draw2d.geometry.Rectangle outerBounds, org.eclipse.draw2d.Graphics graphics, boolean isFill)
Returns the Path which shall be painted in `paintShape(Graphics, boolean)`.

Parameters:
  `outerBounds` - The outer bounds which shall contain the Path. They are calculated from the bounds of this figure by `GFFigureUtil.getAdjustedRectangle(Rectangle, double, int)` . Note, that those outline-bounds are just a suggestion which works fine for many cases.
  `graphics` - The Graphics on which the outline Path shall be painted. It can be used to react on Graphics specific values, like the zoom-level of the Graphics.
  `isFill` - if true, the Path is used for filling the Shape, otherwise for outlining the Shape.
Returns:
  The Path which shall be painted in `paintShape(Graphics, boolean)`.

### getPictogramElementDelegate

protected IPictogramElementDelegate getPictogramElementDelegate()
Returns the PictogramElementDelegate, which was given in the constructor.

Returns:
  The PictogramElementDelegate, which was given in the constructor.

### getGraphicsAlgorithm

protected GraphicsAlgorithm getGraphicsAlgorithm()
Returns the GraphicsAlgorithm, which was given in the constructor.

Returns:
  The GraphicsAlgorithm, which was given in the constructor.

### getConfigurationProvider

protected IConfigurationProviderInternal getConfigurationProvider()
Returns the IConfigurationProviderInternal. This is just a convenience for `getPictogramElementDelegate().getConfigurationProvider()` .

Returns:
  The IConfigurationProviderInternal.

### getZoomLevel

protected double getZoomLevel(org.eclipse.draw2d.Graphics graphics)
Resolves the current zoom level for the graphical context.

This method prioritizes the `ZoomManager` scale from the active diagram components. If a failure occurs during resolution or the manager is unavailable, it falls back to the absolute scale of the provided `Graphics` context or a default of 1.0.

Parameters:
  `graphics` - the `Graphics` context to provide a fallback scale; may be `null`
Returns:
  the detected zoom level as a `double`

### getLineWidth

protected int getLineWidth(org.eclipse.draw2d.Graphics graphics)
Returns the line-width of this figure adjusted according to the given Graphics. This means especially, that the line-width is multiplied with the zoom-level of the given Graphics.

Parameters:
  `graphics` - The Graphics used to adjust the line-width.
Returns:
  The line-width of this figure adjusted according to the given Graphics.

### transformToFillBounds

protected void transformToFillBounds(org.eclipse.draw2d.geometry.Rectangle outlineBounds, org.eclipse.draw2d.Graphics graphics)
Changes the given outline-bounds which should be calculated by
invalid reference

    #getSingletonOutlineBounds(Graphics)

) to the fill-bounds. In this default implementation the fill-bounds are calculated from the outline-bounds by

- Shrinking by the half line-width, so that the fill-bounds fit exactly inside the outline painted using the line-width

Parameters:
  `outlineBounds` - The outline-bounds to transform. They should be calculated by
  invalid reference

      #getSingletonOutlineBounds(Graphics)

  .
  `graphics` - The Graphics used to calculate the bounds.

### getClickArea

protected GraphicsAlgorithm[] getClickArea()
Returns the selection-area GraphicsAlgorithms of this Shape. By default the bounds of a Shape are used as selection-area to calculate if a Point is inside the Shape (see `containsPoint(int, int)`). With this method the selection area can be changed, so that the selection-area are all bounds of the returned selection-area GraphicsAlgorithm. Can be null, if no special selection-area GraphicsAlgorithms exists.

By default this method returns `IToolBehaviorProvider.getClickArea(PictogramElement)`

Returns:
  The selection-area GraphicsAlgorithms of this Shape. Can be null.
See Also:
  - `getSelectionBorder()`

### getSelectionBorder

protected GraphicsAlgorithm getSelectionBorder()
Returns the selection GraphicsAlgorithm of this Shape. By default the bounds of a Shape are used to give selection feedback, especially the selection handles. With this method the selection feedback can be changed, so that the handle-bounds are the bounds of the returned selection GraphicsAlgorithm. Can be null, if no special selection GraphicsAlgorithm exists.

By default this method returns `IToolBehaviorProvider.getSelectionBorder(PictogramElement)`

Returns:
  The selection GraphicsAlgorithm of this Shape. Can be null.
See Also:
  - `getClickArea()`

### containsPointInArea

protected Boolean containsPointInArea(int x, int y)
Returns true, if the given point is contained inside one of the selection-area GraphicsAlgorithms defined in `getClickArea()`.

Parameters:
  `x` - The x-coordinate of the point to check.
  `y` - The y-coordinate of the point to check.
Returns:
  true, if the given point is contained inside one of the selection-area GraphicsAlgorithms.
See Also:
  - `containsPoint(int, int)`

### containsPointInFigure

protected boolean containsPointInFigure(int x, int y)
Returns true, if the given point is contained inside this Shape. This implementation just forwards to `super.contains(x, y)`.

Parameters:
  `x` - The x-coordinate of the point to check.
  `y` - The y-coordinate of the point to check.
Returns:
  true, if the given point is contained inside this Shape.
See Also:
  - `containsPoint(int, int)`

### fillPath

protected void fillPath(org.eclipse.draw2d.Graphics graphics, org.eclipse.swt.graphics.Path path)
A helper method, which fills the Path according to the fill-colors of this figures GraphicsAlgorithm. This can be a single-color filling or a gradient filling.

Parameters:
  `graphics` - The graphics on which to fill the Path.
  `path` - The Path which to fill.

### paintShape

protected void paintShape(org.eclipse.draw2d.Graphics graphics, boolean isFill)
Outlines or fills this Shape on the given Graphics. First the outline Path is be determined by calling `createPath(Rectangle, Graphics, boolean)`. Afterwards this Path is either outlined on the Graphics using the correct line-width or filled using a single color or color-gradients.

Parameters:
  `graphics` - The Graphics on which to outline or fill this Shape.
  `isFill` - if true, fills this Shape, otherwise outlines this Shape.

### paintFigure

public void paintFigure(org.eclipse.draw2d.Graphics graphics)
First initializes the given Graphics with settings like alpha-value, antialias-value, ... Afterwards calls `super.paintFigure(graphics)` to continue with the default painting mechanisms.

Overrides:
  `paintFigure` in class `org.eclipse.draw2d.Shape`
Parameters:
  `graphics` - The Graphics on which to paint.

### fillShape

protected void fillShape(org.eclipse.draw2d.Graphics graphics)
Fills this Shape on the given Graphics. This implementation just forwards to `paintShape(Graphics, boolean)`.

Specified by:
  `fillShape` in class `org.eclipse.draw2d.Shape`
Parameters:
  `graphics` - The Graphics on which to fill this Shape.

### outlineShape

protected void outlineShape(org.eclipse.draw2d.Graphics graphics)
Outlines this Shape on the given Graphics. This implementation just forwards to `paintShape(Graphics, boolean)`.

Specified by:
  `outlineShape` in class `org.eclipse.draw2d.Shape`
Parameters:
  `graphics` - The Graphics on which to outline this Shape.

### containsPoint

public final boolean containsPoint(int x, int y)
Returns true, if the given point is contained inside this Shape. It first calls `containsPointInArea(int, int)` to check if there is a special selection-area defined for this Shape. If not, it returns `containsPointInFigure(int, int)`.

This method is final. Override `containsPointInFigure(int, int)` if needed.

Specified by:
  `containsPoint` in interface `org.eclipse.draw2d.IFigure`
Overrides:
  `containsPoint` in class `org.eclipse.draw2d.Figure`
Parameters:
  `x` - The x-coordinate of the point to check.
  `y` - The y-coordinate of the point to check.
Returns:
  true, if the given point is contained inside this Shape.

### getHandleBounds

public org.eclipse.draw2d.geometry.Rectangle getHandleBounds()
Returns the selection handle bounds of this Shape. First it checks, if a special selection GraphicsAlgorithm is defined for this Shape (see `getSelectionBorder()`. Otherwise it just returns the bounds of this Shape.

Specified by:
  `getHandleBounds` in interface `org.eclipse.gef.handles.HandleBounds`
Returns:
  The selection handle bounds of this Shape.

### getVisualState

public IVisualState getVisualState()
Returns the visual state of this shape.

Specified by:
  `getVisualState` in interface `IVisualStateHolder`
Returns:
  The visual state of this shape.

### visualStateChanged

public void visualStateChanged(VisualStateChangedEvent e)
Is called after the visual state changed.

Specified by:
  `visualStateChanged` in interface `IVisualStateChangeListener`

### setSelectionBorder

public void setSelectionBorder(GraphicsAlgorithm selectionBorder)

Parameters:
  `selectionBorder` - the selectionBorder to set

### setClickArea

public void setClickArea(GraphicsAlgorithm[] clickArea)

Parameters:
  `clickArea` - the clickArea to set

### getPreferences

protected GFPreferences getPreferences()