Class GFPolylineConnection

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

public class GFPolylineConnection extends GFPolyline implements org.eclipse.draw2d.Connection, org.eclipse.draw2d.AnchorListener
A Graphiti Polyline Connection. The "polyline functionality" is inherited from the super-class, the "connection functionality" is added in this class.

Important difference: The super-class denotes a polyline-shape. There the points are translated towards the center depending on the line-width, so that the bounds of the polyline-shape are only dependent on the points of the polyline but not on the current line-width. Otherwise it would be difficult to align its positions/sizes with the neighbor-shapes or parent-shapes. This class on the other hand denotes a polyline-connection. Here the points are not translated towards the center, because the polyline must always go directly through the given points.

  • 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.Connection

    PROPERTY_CONNECTION_ROUTER, PROPERTY_POINTS

    Fields inherited from interface org.eclipse.draw2d.IFigure

    MAX_DIMENSION, MIN_DIMENSION, NO_INSETS
  • Constructor Summary

    Constructors
    Constructor
    Description
    GFPolylineConnection(IPictogramElementDelegate pictogramElementDelegate, GraphicsAlgorithm graphicsAlgorithm)
    Creates a new GFPolylineConnection.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addDecoration(org.eclipse.draw2d.IFigure decoration, boolean distanceToStart, double relativeDistance, int absoluteDistance, double rotateDegrees)
    Adds a decoration to this connection.
    void
    Hooks the source and target anchors.
    void
    addRoutingListener(org.eclipse.draw2d.RoutingListener listener)
    Appends the given routing listener to the list of listeners.
    void
    anchorMoved(org.eclipse.draw2d.ConnectionAnchor anchor)
    Called by the anchors of this connection when they have moved, revalidating this polyline connection.
    protected org.eclipse.draw2d.geometry.PointList
    getAdjustedPointList(org.eclipse.draw2d.geometry.PointList points, double zoom, double lw)
    Returns a new instance of the input point-list, which is adjusted regarding the given zoom-factor and line-width.
    List<org.eclipse.draw2d.IFigure>
    Returns a list of all decorations, which are currently added to this connection.
    protected List<BezierPoint>
    getBezierPoints(org.eclipse.draw2d.geometry.PointList points, double zoom)
    Returns a new list of bezier-points, which is calculated from the given point list.
    org.eclipse.draw2d.geometry.Rectangle
    Returns the bounds which holds all the points in this polyline connection.
    org.eclipse.draw2d.ConnectionRouter
    Returns the ConnectionRouter used to layout this connection.
    Returns this connection's routing constraint from its connection router.
    org.eclipse.draw2d.ConnectionAnchor
     
    org.eclipse.draw2d.ConnectionAnchor
     
    void
    Layouts this polyline.
    void
    Removes all currently added decorations from the connection.
    void
    Called just before the receiver is being removed from its parent.
    void
    removeRoutingListener(org.eclipse.draw2d.RoutingListener listener)
    Removes the first occurence of the given listener.
    void
     
    void
    setConnectionRouter(org.eclipse.draw2d.ConnectionRouter cr)
    Sets the connection router which handles the layout of this polyline.
    void
    Sets the routing constraint for this connection.
    void
    setSourceAnchor(org.eclipse.draw2d.ConnectionAnchor anchor)
    Sets the anchor to be used at the start of this polyline connection.
    void
    setSpecificBezierDistances(int[] bezierDistances)
    Sets the specific distances used to calculate the rounding of the bezier-curve.
    void
    setTargetAnchor(org.eclipse.draw2d.ConnectionAnchor anchor)
    Sets the anchor to be used at the end of the polyline connection.

    Methods inherited from class org.eclipse.graphiti.ui.internal.figures.GFAbstractPointListShape

    addPoint, getEnd, getPoints, getStart, insertPoint, removeAllPoints, removePoint, setEnd, setPoint, setPoints, setStart

    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, 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, addPropertyChangeListener, addPropertyChangeListener, containsPoint, erase, findDescendantAtExcluding, findFigureAt, findFigureAt, findFigureAt, findFigureAtExcluding, findMouseEventTargetAt, findMouseEventTargetInDescendantsAt, fireCoordinateSystemChanged, fireFigureMoved, fireMoved, firePropertyChange, firePropertyChange, firePropertyChange, getBackgroundColor, getBorder, 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, optimizeClip, paint, paintBorder, paintChildren, paintClientArea, remove, removeAll, removeAncestorListener, removeCoordinateListener, removeFigureListener, removeFocusListener, removeKeyListener, removeLayoutListener, removeListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, 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, 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.Connection

    getPoints, setPoints

    Methods inherited from interface org.eclipse.draw2d.IFigure

    add, add, add, add, addAncestorListener, addCoordinateListener, addFigureListener, addFocusListener, addKeyListener, addLayoutListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, containsPoint, containsPoint, erase, findFigureAt, findFigureAt, findFigureAt, findFigureAtExcluding, findMouseEventTargetAt, getBackgroundColor, getBorder, 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, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, 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

    • GFPolylineConnection

      public GFPolylineConnection(IPictogramElementDelegate pictogramElementDelegate, GraphicsAlgorithm graphicsAlgorithm)
      Creates a new GFPolylineConnection.
      Parameters:
      pictogramElementDelegate - The PictogramElementDelegate which provides the GraphicsAlgorithm.
      graphicsAlgorithm - The GraphicsAlgorithm which provides the values to paint this Shape.
  • Method Details

    • getAdjustedPointList

      protected org.eclipse.draw2d.geometry.PointList getAdjustedPointList(org.eclipse.draw2d.geometry.PointList points, double zoom, double lw)
      Returns a new instance of the input point-list, which is adjusted regarding the given zoom-factor and line-width.

      The implementation only zooms the points regarding the zoom-factor. It does not translate the points towards the center depending on the line-width. See explanation in the javadoc of this class.

      Overrides:
      getAdjustedPointList in class GFPolyline
      Parameters:
      points - The point-list which to adjust.
      zoom - The zoom-factor to regard.
      lw - The line-width to regard.
    • getBounds

      public org.eclipse.draw2d.geometry.Rectangle getBounds()
      Returns the bounds which holds all the points in this polyline connection. Note, that the childrens bounds are also added to the super-class bounds.

      The implementation adds the half line-width to the bounds of the super-class, because the points are not translated towards the center (see getAdjustedPointList(PointList, double, double)), so that bounds must expand depending on the line-width.

      Specified by:
      getBounds in interface org.eclipse.draw2d.IFigure
      Overrides:
      getBounds in class GFPolyline
      Returns:
      The bounds which holds all the points in this polyline connection.
    • getBezierPoints

      protected List<BezierPoint> getBezierPoints(org.eclipse.draw2d.geometry.PointList points, double zoom)
      Description copied from class: GFPolyline
      Returns a new list of bezier-points, which is calculated from the given point list.
      Overrides:
      getBezierPoints in class GFPolyline
      Parameters:
      points - The point list, from which to calculate the bezier-points.
      zoom - The zoom-level used to adjust the bezier distances.
      Returns:
      a new list of bezier-points, which is calculated from the given point list.
    • setSpecificBezierDistances

      public void setSpecificBezierDistances(int[] bezierDistances)
      Description copied from class: GFPolyline
      Sets the specific distances used to calculate the rounding of the bezier-curve. This means, that for each point of the polyline the before-distance and the after distance have to be specified. If this attribute is null, then the value of the attribute in GFPolyline.setGeneralBezierDistance(int) will be used. See GFFigureUtil.getBezierPath(List, boolean) for a more details.
      Overrides:
      setSpecificBezierDistances in class GFPolyline
      Parameters:
      bezierDistances - The specific distance used to calculate the rounding of the bezier-curve.
    • addNotify

      public void addNotify()
      Hooks the source and target anchors.
      Specified by:
      addNotify in interface org.eclipse.draw2d.IFigure
      Overrides:
      addNotify in class org.eclipse.draw2d.Figure
      See Also:
      • Figure.addNotify()
    • addRoutingListener

      public void addRoutingListener(org.eclipse.draw2d.RoutingListener listener)
      Appends the given routing listener to the list of listeners.
      Parameters:
      listener - the routing listener
      Since:
      3.2
    • anchorMoved

      public void anchorMoved(org.eclipse.draw2d.ConnectionAnchor anchor)
      Called by the anchors of this connection when they have moved, revalidating this polyline connection.
      Specified by:
      anchorMoved in interface org.eclipse.draw2d.AnchorListener
      Parameters:
      anchor - the anchor that moved
    • getConnectionRouter

      public org.eclipse.draw2d.ConnectionRouter getConnectionRouter()
      Returns the ConnectionRouter used to layout this connection. Will not return null.
      Specified by:
      getConnectionRouter in interface org.eclipse.draw2d.Connection
      Returns:
      this connection's router
    • getRoutingConstraint

      public Object getRoutingConstraint()
      Returns this connection's routing constraint from its connection router. May return null.
      Specified by:
      getRoutingConstraint in interface org.eclipse.draw2d.Connection
      Returns:
      the connection's routing constraint
    • getSourceAnchor

      public org.eclipse.draw2d.ConnectionAnchor getSourceAnchor()
      Specified by:
      getSourceAnchor in interface org.eclipse.draw2d.Connection
      Returns:
      the anchor at the start of this polyline connection (may be null)
    • getTargetAnchor

      public org.eclipse.draw2d.ConnectionAnchor getTargetAnchor()
      Specified by:
      getTargetAnchor in interface org.eclipse.draw2d.Connection
      Returns:
      the anchor at the end of this polyline connection (may be null)
    • layout

      public void layout()
      Layouts this polyline. If the start and end anchors are present, the connection router is used to route this, after which it is laid out. It also fires a moved method.
      Overrides:
      layout in class org.eclipse.draw2d.Figure
    • removeNotify

      public void removeNotify()
      Called just before the receiver is being removed from its parent. Results in removing itself from the connection router.
      Specified by:
      removeNotify in interface org.eclipse.draw2d.IFigure
      Overrides:
      removeNotify in class org.eclipse.draw2d.Figure
      Since:
      2.0
    • removeRoutingListener

      public void removeRoutingListener(org.eclipse.draw2d.RoutingListener listener)
      Removes the first occurence of the given listener.
      Parameters:
      listener - the listener being removed
      Since:
      3.2
    • revalidate

      public void revalidate()
      Specified by:
      revalidate in interface org.eclipse.draw2d.IFigure
      Overrides:
      revalidate in class org.eclipse.draw2d.Figure
      See Also:
      • IFigure.revalidate()
    • setConnectionRouter

      public void setConnectionRouter(org.eclipse.draw2d.ConnectionRouter cr)
      Sets the connection router which handles the layout of this polyline. Generally set by the parent handling the polyline connection.
      Specified by:
      setConnectionRouter in interface org.eclipse.draw2d.Connection
      Parameters:
      cr - the connection router
    • setRoutingConstraint

      public void setRoutingConstraint(Object cons)
      Sets the routing constraint for this connection.
      Specified by:
      setRoutingConstraint in interface org.eclipse.draw2d.Connection
      Parameters:
      cons - the constraint
    • setSourceAnchor

      public void setSourceAnchor(org.eclipse.draw2d.ConnectionAnchor anchor)
      Sets the anchor to be used at the start of this polyline connection.
      Specified by:
      setSourceAnchor in interface org.eclipse.draw2d.Connection
      Parameters:
      anchor - the new source anchor
    • addDecoration

      public void addDecoration(org.eclipse.draw2d.IFigure decoration, boolean distanceToStart, double relativeDistance, int absoluteDistance, double rotateDegrees)
      Adds a decoration to this connection. The decoration is located depending on the distance values.
      Parameters:
      decoration - The decoration to add.
      distanceToStart - If the distance values refer to the start-point or the end-point. See FlexibleRotatableLocator.
      relativeDistance - The relative distance. See FlexibleRotatableLocator.
      absoluteDistance - The absolute distance. See FlexibleRotatableLocator.
      rotateDegrees - The rotation in degrees. See FlexibleRotatableLocator.
    • removeAllDecorations

      public void removeAllDecorations()
      Removes all currently added decorations from the connection.
      See Also:
    • getAllDecorations

      public List<org.eclipse.draw2d.IFigure> getAllDecorations()
      Returns a list of all decorations, which are currently added to this connection. Can be empty but not null.
      Returns:
      A list of all decorations, which are currently added to this connection.
      See Also:
      • #addDecoration(IFigure, boolean, double, int)
    • setTargetAnchor

      public void setTargetAnchor(org.eclipse.draw2d.ConnectionAnchor anchor)
      Sets the anchor to be used at the end of the polyline connection. Removes this listener from the old anchor and adds it to the new anchor.
      Specified by:
      setTargetAnchor in interface org.eclipse.draw2d.Connection
      Parameters:
      anchor - the new target anchor