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

## Class GFAbstractRotatableDecoration

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

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

Direct Known Subclasses:
  `GFEllipseDecoration`

    public abstract class GFAbstractRotatableDecoration
    extends GFAbstractShape
    implements org.eclipse.draw2d.RotatableDecoration

This class is an abstract super-class for all RotatableDecorations in Graphiti. The main idea is, that the outline and fill-area of a RotatableDecoration is defined by a Path. Sub-classes usually only have to implement the abstract methods `GFAbstractShape.createPath(Rectangle, Graphics, boolean)` and `getInitialTouchPoint()`.

### Nested Class Summary

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

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

### 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, 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
`GFAbstractRotatableDecoration​(IPictogramElementDelegate pictogramElementDelegate, GraphicsAlgorithm graphicsAlgorithm)` Creates a new GFAbstractRotatableDecoration.

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`boolean` `containsPointInFigure​(int x, int y)` Returns true, if the point is inside the translated/rotated rectangle.
`boolean` `containsPointInInitialFigure​(int x, int y)` Returns true, if the point is inside the initial figure, meaning the figure in the `getInitialBounds()` before translation/rotation.
`org.eclipse.draw2d.geometry.Rectangle` `getBounds()` Returns the bounds of this decorator shape.
`protected org.eclipse.draw2d.geometry.Point` `getDecoratorLocation()` Returns the decorator-location.
`protected org.eclipse.draw2d.geometry.Point` `getDecoratorReferencePoint()` Returns the decorator-reference-point.
`protected org.eclipse.draw2d.geometry.Rectangle` `getInitialBounds()` Returns the initial-bounds.
`protected abstract org.eclipse.draw2d.geometry.Point` `getInitialTouchPoint()` Returns the initial touch-point of the decorator-shape.
`protected double` `getPhiDegrees()` Returns the angle "phi" in degrees.
`protected double` `getPhiRadians()` Returns the angle "phi" in radians.
`protected org.eclipse.draw2d.geometry.Point` `getTouchPointDelta()` Returns the touch-point delta.
`protected void` `paintShape​(org.eclipse.draw2d.Graphics graphics, boolean isFill)` Fills this Shape on the given Graphics.
`protected void` `processRotatableDecorationValues()` After the decorator-location or decorator-reference-point changed, the translated/rotated rectangle has to be re-calculated.
`protected org.eclipse.draw2d.geometry.PrecisionPoint` `rotateTargetToInitial​(double x, double y)` Returns the initial point for the given target point.
`protected void` `setInitialBounds​(org.eclipse.draw2d.geometry.Rectangle initialBounds)` Sets the initial-bounds.
`void` `setLocation​(org.eclipse.draw2d.geometry.Point p)` Sets the decorator-location.
`void` `setReferencePoint​(org.eclipse.draw2d.geometry.Point ref)` Sets the decorator-reference-point.

### Methods inherited from class org.eclipse.graphiti.ui.internal.figures.GFAbstractShape

`containsPoint, containsPointInArea, createPath, fillPath, fillShape, getClickArea, getConfigurationProvider, getGraphicsAlgorithm, getHandleBounds, getLineWidth, getPictogramElementDelegate, getPreferences, getSelectionBorder, getVisualState, getZoomLevel, outlineShape, paintFigure, setClickArea, setSelectionBorder, transformToFillBounds, visualStateChanged`

### 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, addNotify, addPropertyChangeListener, addPropertyChangeListener, containsPoint, erase, findDescendantAtExcluding, findFigureAt, findFigureAt, findFigureAt, findFigureAtExcluding, findMouseEventTargetAt, findMouseEventTargetInDescendantsAt, fireCoordinateSystemChanged, fireFigureMoved, fireMoved, firePropertyChange, firePropertyChange, firePropertyChange, getBackgroundColor, getBorder, getChildren, getClientArea, getClientArea, getClippingStrategy, 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, setClippingStrategy, setConstraint, setCursor, setEnabled, setFlag, setFocusTraversable, setFont, setForegroundColor, setLayoutManager, 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, getChildren, getClientArea, getClientArea, getClippingStrategy, 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, setClippingStrategy, setConstraint, setCursor, setEnabled, setFocusTraversable, setFont, setForegroundColor, setLayoutManager, setMaximumSize, setMinimumSize, setOpaque, setParent, setPreferredSize, setRequestFocusEnabled, setSize, setSize, setToolTip, setVisible, translate, translateFromParent, translateToAbsolute, translateToParent, translateToRelative, validate`

### Constructor Detail

#### GFAbstractRotatableDecoration

    public GFAbstractRotatableDecoration​(IPictogramElementDelegate pictogramElementDelegate,
                                         GraphicsAlgorithm graphicsAlgorithm)

Creates a new GFAbstractRotatableDecoration.

Parameters:
  `pictogramElementDelegate` - The PictogramElementDelegate which provides the GraphicsAlgorithm.
  `graphicsAlgorithm` - The GraphicsAlgorithm which provides the values to paint this Shape.

### Method Detail

#### getInitialTouchPoint

    protected abstract org.eclipse.draw2d.geometry.Point getInitialTouchPoint()

Returns the initial touch-point of the decorator-shape. This is the point of the decorator-shape inside the initial-bounds (see `getInitialBounds()`), which shall touch the decorated figure at the decorator-location (see `getDecoratorLocation()`. It is called "inital" because it is the point before translation/rotation.

Example: for an Ellipse the point `(0, getInitialBounds().height / 2)` is returned.

Returns:
  The initial touch-point of the decorator-shape.

#### setLocation

    public void setLocation​(org.eclipse.draw2d.geometry.Point p)

Sets the decorator-location.

Specified by:
  `setLocation` in interface `org.eclipse.draw2d.IFigure`
Specified by:
  `setLocation` in interface `org.eclipse.draw2d.RotatableDecoration`
Overrides:
  `setLocation` in class `org.eclipse.draw2d.Figure`
Parameters:
  `p` - The decorator-location to set.
See Also:
  `getDecoratorLocation()`

#### setReferencePoint

    public void setReferencePoint​(org.eclipse.draw2d.geometry.Point ref)

Sets the decorator-reference-point. Calls `processRotatableDecorationValues()` afterwards to initialize the rotated rectangle values.

Specified by:
  `setReferencePoint` in interface `org.eclipse.draw2d.RotatableDecoration`
Parameters:
  `ref` - The decorator-reference-point to set.
See Also:
  `getDecoratorReferencePoint()`

#### processRotatableDecorationValues

    protected void processRotatableDecorationValues()

After the decorator-location or decorator-reference-point changed, the translated/rotated rectangle has to be re-calculated. This includes `getPhiDegrees()`, `getPhiRadians()`, `getBounds()`, `getTouchPointDelta()`.

#### getBounds

    public org.eclipse.draw2d.geometry.Rectangle getBounds()

Returns the bounds of this decorator shape. This implementation bases on a rough calculation, which returns a bigger rectangle than necessary.

Specified by:
  `getBounds` in interface `org.eclipse.draw2d.IFigure`
Overrides:
  `getBounds` in class `org.eclipse.draw2d.Figure`
Returns:
  The bounds of this decorator shape.

#### paintShape

    protected void paintShape​(org.eclipse.draw2d.Graphics graphics,
                              boolean isFill)

Fills this Shape on the given Graphics. It enhances the implementation of the super-class by adding a rotation and translation according to the values set via `RotatableDecoration`.

Overrides:
  `paintShape` in class `GFAbstractShape`
Parameters:
  `graphics` - The Graphics on which to outline this Shape.
  `isFill` - if true, fills this Shape, otherwise outlines this Shape.

#### containsPointInFigure

    public boolean containsPointInFigure​(int x,
                                         int y)

Returns true, if the point is inside the translated/rotated rectangle. Specifics of the decorator Shape are ignored, but can be added by overwriting `containsPointInInitialFigure(int, int)`.

Overrides:
  `containsPointInFigure` in class `GFAbstractShape`
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:
  `GFAbstractShape.containsPoint(int, int)`

#### containsPointInInitialFigure

    public boolean containsPointInInitialFigure​(int x,
                                                int y)

Returns true, if the point is inside the initial figure, meaning the figure in the `getInitialBounds()` before translation/rotation.

This implementation just returns true, but sub-classes can overwrite it to make decorator-shape specific checks.

#### rotateTargetToInitial

    protected org.eclipse.draw2d.geometry.PrecisionPoint rotateTargetToInitial​(double x,
                                                                               double y)

Returns the initial point for the given target point. This means, that it translates/rotates the given target point from the coordinates of the target-rectangle backwards to the coordinates of the initial bounds.

Parameters:
  `x` - The x-coordinate of the target point to translate/rotate.
  `y` - The y-coordinate of the target point to translate/rotate.
Returns:
  The initial point for the given target point.

#### setInitialBounds

    protected final void setInitialBounds​(org.eclipse.draw2d.geometry.Rectangle initialBounds)

Sets the initial-bounds. The initial-bounds are a rectangle which starts at (0,0) and has the (width, height) of the figure before rotation. The initial-bounds are set in the constructor and not changed afterwards.

Parameters:
  `initialBounds` - The initial-bounds to set.

#### getInitialBounds

    protected final org.eclipse.draw2d.geometry.Rectangle getInitialBounds()

Returns the initial-bounds. The initial-bounds are a rectangle which starts at (0,0) and has the (width, height) of the figure before rotation. The initial-bounds are set in the constructor and not changed afterwards.

Returns:
  The initial-bounds.

#### getDecoratorLocation

    protected final org.eclipse.draw2d.geometry.Point getDecoratorLocation()

Returns the decorator-location. The decorator-location is the start-point of the connection. This means that at this point the decorator and the figure shall touch.

Returns:
  The decorator-location.
See Also:
  `setLocation(Point)`

#### getDecoratorReferencePoint

    protected final org.eclipse.draw2d.geometry.Point getDecoratorReferencePoint()

Returns the decorator-reference-point. The decorator-reference-point is the end-point of the connection. It is used to calculate the angle "phi".

Returns:
  The decorator-reference-point.
See Also:
  `setReferencePoint(Point)`, `getPhiDegrees()`, `getPhiRadians()`

#### getPhiDegrees

    protected final double getPhiDegrees()

Returns the angle "phi" in degrees. This is the angle between the x-axis and the line through [decorator-location, decorator-reference-point].

Returns:
  The angle "phi" in degrees.
See Also:
  `getPhiRadians()`

#### getPhiRadians

    protected final double getPhiRadians()

Returns the angle "phi" in radians. This is the angle between the x-axis and the line through [decorator-location, decorator-reference-point].

Returns:
  The angle "phi" in radians.
See Also:
  `getPhiDegrees()`

#### getTouchPointDelta

    protected final org.eclipse.draw2d.geometry.Point getTouchPointDelta()

Returns the touch-point delta. This is the distance which the decorator has to be moved, so that the initial touchpoint touches the decorator-location after the rotation.

Returns:
  The touch-point delta.