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.ReverseFigureChildrenIteratorNested 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, lineWidthFields inherited from class org.eclipse.draw2d.Figure
bgColor, border, bounds, fgColor, flags, font, MAX_FLAG, maxSize, minSize, NO_MANAGER, prefSize, toolTipFields inherited from interface org.eclipse.draw2d.IFigure
MAX_DIMENSION, MIN_DIMENSION, NO_INSETS -
Constructor Summary
ConstructorsConstructorDescriptionGFAbstractShape(IPictogramElementDelegate pictogramElementDelegate, GraphicsAlgorithm graphicsAlgorithm) Creates a new GFAbstractShape. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleancontainsPoint(int x, int y) Returns true, if the given point is contained inside this Shape.protected BooleancontainsPointInArea(int x, int y) Returns true, if the given point is contained inside one of the selection-area GraphicsAlgorithms defined ingetClickArea().protected booleancontainsPointInFigure(int x, int y) Returns true, if the given point is contained inside this Shape.protected abstract org.eclipse.swt.graphics.PathcreatePath(org.eclipse.draw2d.geometry.Rectangle outerBounds, org.eclipse.draw2d.Graphics graphics, boolean isFill) Returns the Path which shall be painted inpaintShape(Graphics, boolean).protected voidfillPath(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 voidfillShape(org.eclipse.draw2d.Graphics graphics) Fills this Shape on the given Graphics.protected GraphicsAlgorithm[]Returns the selection-area GraphicsAlgorithms of this Shape.protected IConfigurationProviderInternalReturns the IConfigurationProviderInternal.protected GraphicsAlgorithmReturns the GraphicsAlgorithm, which was given in the constructor.org.eclipse.draw2d.geometry.RectangleReturns the selection handle bounds of this Shape.protected intgetLineWidth(org.eclipse.draw2d.Graphics graphics) Returns the line-width of this figure adjusted according to the given Graphics.protected IPictogramElementDelegateReturns the PictogramElementDelegate, which was given in the constructor.protected GFPreferencesprotected GraphicsAlgorithmReturns the selection GraphicsAlgorithm of this Shape.Returns the visual state of this shape.protected doublegetZoomLevel(org.eclipse.draw2d.Graphics graphics) Returns the zoom-level of the given Graphics.protected voidoutlineShape(org.eclipse.draw2d.Graphics graphics) Outlines this Shape on the given Graphics.voidpaintFigure(org.eclipse.draw2d.Graphics graphics) First initializes the given Graphics with settings like alpha-value, antialias-value, ...protected voidpaintShape(org.eclipse.draw2d.Graphics graphics, boolean isFill) Outlines or fills this Shape on the given Graphics.voidsetClickArea(GraphicsAlgorithm[] clickArea) voidsetSelectionBorder(GraphicsAlgorithm selectionBorder) protected voidtransformToFillBounds(org.eclipse.draw2d.geometry.Rectangle outlineBounds, org.eclipse.draw2d.Graphics graphics) Changes the given outline-bounds which should be calculated by#getSingletonOutlineBounds(Graphics)) to the fill-bounds.voidIs 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, setXORMethods 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, 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, hasFocus, internalGetEventDispatcher, 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, 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, validateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.draw2d.IFigure
add, add, add, add, addAncestorListener, addCoordinateListener, addFigureListener, addFocusListener, addKeyListener, addLayoutListener, addMouseListener, addMouseMotionListener, 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, 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, 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 inpaintShape(Graphics, boolean).- Parameters:
outerBounds- The outer bounds which shall contain the Path. They are calculated from the bounds of this figure byGFFigureUtil.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
Returns the PictogramElementDelegate, which was given in the constructor.- Returns:
- The PictogramElementDelegate, which was given in the constructor.
-
getGraphicsAlgorithm
Returns the GraphicsAlgorithm, which was given in the constructor.- Returns:
- The GraphicsAlgorithm, which was given in the constructor.
-
getConfigurationProvider
Returns the IConfigurationProviderInternal. This is just a convenience forgetPictogramElementDelegate().getConfigurationProvider().- Returns:
- The IConfigurationProviderInternal.
-
getZoomLevel
protected double getZoomLevel(org.eclipse.draw2d.Graphics graphics) Returns the zoom-level of the given Graphics.- Parameters:
graphics- The Graphics for which to return the zoom-level.- Returns:
- The zoom-level of the given Graphics.
-
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#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#getSingletonOutlineBounds(Graphics).graphics- The Graphics used to calculate the bounds.
-
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 (seecontainsPoint(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
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:
-
containsPointInArea
Returns true, if the given point is contained inside one of the selection-area GraphicsAlgorithms defined ingetClickArea().- 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:
-
containsPointInFigure
protected boolean containsPointInFigure(int x, int y) Returns true, if the given point is contained inside this Shape. This implementation just forwards tosuper.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:
-
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 callingcreatePath(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 callssuper.paintFigure(graphics)to continue with the default painting mechanisms.- Overrides:
paintFigurein classorg.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 topaintShape(Graphics, boolean).- Specified by:
fillShapein classorg.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 topaintShape(Graphics, boolean).- Specified by:
outlineShapein classorg.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 callscontainsPointInArea(int, int)to check if there is a special selection-area defined for this Shape. If not, it returnscontainsPointInFigure(int, int).This method is final. Override
containsPointInFigure(int, int)if needed.- Specified by:
containsPointin interfaceorg.eclipse.draw2d.IFigure- Overrides:
containsPointin classorg.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 (seegetSelectionBorder(). Otherwise it just returns the bounds of this Shape.- Specified by:
getHandleBoundsin interfaceorg.eclipse.gef.handles.HandleBounds- Returns:
- The selection handle bounds of this Shape.
-
getVisualState
Returns the visual state of this shape.- Specified by:
getVisualStatein interfaceIVisualStateHolder- Returns:
- The visual state of this shape.
-
visualStateChanged
Is called after the visual state changed.- Specified by:
visualStateChangedin interfaceIVisualStateChangeListener
-
setSelectionBorder
- Parameters:
selectionBorder- the selectionBorder to set
-
setClickArea
- Parameters:
clickArea- the clickArea to set
-
getPreferences
-