java.lang.Object
org.eclipse.gef.common.adapt.IAdaptable.Bound.Impl<org.eclipse.gef.mvc.fx.parts.IVisualPart<? extends javafx.scene.Node>>
org.eclipse.gef.mvc.fx.policies.AbstractPolicy
com.amalgamasimulation.graphicaleditor.policies.BendArcPolicy
All Implemented Interfaces:
org.eclipse.gef.common.adapt.IAdaptable.Bound<org.eclipse.gef.mvc.fx.parts.IVisualPart<? extends javafx.scene.Node>>, org.eclipse.gef.mvc.fx.policies.IPolicy

public class BendArcPolicy extends org.eclipse.gef.mvc.fx.policies.AbstractPolicy
  • Property Summary

    Properties inherited from class org.eclipse.gef.common.adapt.IAdaptable.Bound.Impl

    adaptable

    Properties inherited from interface org.eclipse.gef.common.adapt.IAdaptable.Bound

    adaptable
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.eclipse.gef.common.adapt.IAdaptable.Bound

    org.eclipse.gef.common.adapt.IAdaptable.Bound.Impl<T extends org.eclipse.gef.common.adapt.IAdaptable>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final double
    The overlay threshold, i.e.
    protected static final double
    The overlay threshold, i.e.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected boolean
    canConnect(int explicitAnchorIndex)
    Determines if the anchor at the given explicit index can be replaced with an anchor that is obtained from an underlying visual part.
    org.eclipse.gef.mvc.fx.operations.ITransactionalOperation
     
    int
    createAfter(int explicitAnchorIndex, org.eclipse.gef.geometry.planar.Point mouseInScene, org.eclipse.gef.mvc.fx.parts.AbstractSegmentHandlePart<? extends javafx.scene.Node> bendPointPart)
    Creates a new anchor after the anchor specified by the given explicit anchor index.
    int
    createBefore(int explicitAnchorIndex, org.eclipse.gef.geometry.planar.Point mouseInScene)
    Creates a new anchor before the anchor specified by the given explicit anchor index.
    protected org.eclipse.gef.mvc.fx.operations.ITransactionalOperation
     
    protected org.eclipse.gef.mvc.fx.operations.BendVisualOperation
    Returns an BendVisualOperation that is extracted from the operation created by createOperation().
    protected List<org.eclipse.gef.mvc.fx.parts.IBendableContentPart.BendPoint>
    Returns the current control points of the content.
    org.eclipse.gef.mvc.fx.parts.IBendableContentPart<? extends javafx.scene.Node>
     
    protected List<org.eclipse.gef.mvc.fx.parts.IBendableContentPart.BendPoint>
    Returns the initial bend points before bending the content.
    List<javafx.scene.Node>
    getNodesAt(javafx.scene.Node root, double sceneX, double sceneY)
     
    javafx.geometry.Orientation
    If a segment, i.e.
    protected double
    Removes the overlay threshold, i.e.
    protected List<Integer>
    Returns the list of indices selected via select(int).
    List<org.eclipse.gef.geometry.planar.Point>
    Returns the initial positions of the selected points in the local coordinate system of the host visual.
    protected org.eclipse.gef.geometry.planar.Point
    getVisualPoint(int bendPointIndex)
    Returns the current position for the given explicit anchor index, within the local coordinate system of the Connection.
    void
     
    protected void
    insertExplicitAnchor(int insertionIndex, org.eclipse.gef.geometry.planar.Point mouseInScene)
    Creates a new static anchor for the given position and inserts it at the given index.
    boolean
    Checks whether the shift is active.
    protected void
     
    org.eclipse.gef.geometry.planar.Point
    move(org.eclipse.gef.geometry.planar.Point initialMouseInScene, org.eclipse.gef.geometry.planar.Point currentMouseInScene)
    Moves the currently selected point to the given mouse position in scene coordinates.
    protected void
    Removes any bend points overlain during the movement of selected ones.
    protected void
    Restores the initial bend points prior to moving.
    void
    select(int index)
    Selects the point specified by the given segment index and parameter for manipulation.
    void
    selectSegment(int from, int to)
    Selects the end points of the segment specified by the given indices.
    void
    setShiftDown(boolean isShiftDown)
    Sets the state of the shift key.

    Methods inherited from class org.eclipse.gef.mvc.fx.policies.AbstractPolicy

    checkInitialized, getOperation, isInitialized, rollback

    Methods inherited from class org.eclipse.gef.common.adapt.IAdaptable.Bound.Impl

    adaptableProperty, getAdaptable, setAdaptable

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.eclipse.gef.common.adapt.IAdaptable.Bound

    adaptableProperty, getAdaptable, setAdaptable
  • Field Details

    • DEFAULT_SEGMENT_OVERLAY_THRESHOLD

      protected static final double DEFAULT_SEGMENT_OVERLAY_THRESHOLD
      The overlay threshold, i.e. the distance between two points so that they are regarded as overlying.
      See Also:
    • DEFAULT_OVERLAY_THRESHOLD

      protected static final double DEFAULT_OVERLAY_THRESHOLD
      The overlay threshold, i.e. the distance between two points so that they are regarded as overlying.
      See Also:
  • Constructor Details

    • BendArcPolicy

      public BendArcPolicy()
  • Method Details

    • canConnect

      protected boolean canConnect(int explicitAnchorIndex)
      Determines if the anchor at the given explicit index can be replaced with an anchor that is obtained from an underlying visual part. Per default, only the start and the end index can be connected.
      Parameters:
      explicitAnchorIndex - The explicit anchor index for which to determine if it can be connected.
      Returns:
      true if the anchor at the given index can be connected, otherwise false.
    • commit

      public org.eclipse.gef.mvc.fx.operations.ITransactionalOperation commit()
      Specified by:
      commit in interface org.eclipse.gef.mvc.fx.policies.IPolicy
      Overrides:
      commit in class org.eclipse.gef.mvc.fx.policies.AbstractPolicy
    • createAfter

      public int createAfter(int explicitAnchorIndex, org.eclipse.gef.geometry.planar.Point mouseInScene, org.eclipse.gef.mvc.fx.parts.AbstractSegmentHandlePart<? extends javafx.scene.Node> bendPointPart)
      Creates a new anchor after the anchor specified by the given explicit anchor index. Returns the new anchor's explicit index.
      Parameters:
      explicitAnchorIndex - An explicit anchor index that references the explicit anchor after which the new anchor is inserted.
      mouseInScene - The position for the new anchor in scene coordinates.
      bendPointPart - selected bendPointPart (reserved for subclass overrides)
      Returns:
      The index for the new anchor.
    • createBefore

      public int createBefore(int explicitAnchorIndex, org.eclipse.gef.geometry.planar.Point mouseInScene)
      Creates a new anchor before the anchor specified by the given explicit anchor index. Returns the new anchor's explicit index.
      Parameters:
      explicitAnchorIndex - An explicit anchor index that references the explicit anchor before which the new anchor is inserted.
      mouseInScene - The position for the new anchor in scene coordinates.
      Returns:
      The index for the new anchor.
    • createOperation

      protected org.eclipse.gef.mvc.fx.operations.ITransactionalOperation createOperation()
      Specified by:
      createOperation in class org.eclipse.gef.mvc.fx.policies.AbstractPolicy
    • getNodesAt

      public List<javafx.scene.Node> getNodesAt(javafx.scene.Node root, double sceneX, double sceneY)
    • getBendOperation

      protected org.eclipse.gef.mvc.fx.operations.BendVisualOperation getBendOperation()
      Returns an BendVisualOperation that is extracted from the operation created by createOperation().
      Returns:
      an BendVisualOperation that is extracted from the operation created by createOperation().
    • getCurrentBendPoints

      protected List<org.eclipse.gef.mvc.fx.parts.IBendableContentPart.BendPoint> getCurrentBendPoints()
      Returns the current control points of the content.
      Returns:
      The current control points.
    • getHost

      public org.eclipse.gef.mvc.fx.parts.IBendableContentPart<? extends javafx.scene.Node> getHost()
    • getInitialBendPoints

      protected List<org.eclipse.gef.mvc.fx.parts.IBendableContentPart.BendPoint> getInitialBendPoints()
      Returns the initial bend points before bending the content.
      Returns:
      The initial bend points.
    • getOrientation

      public javafx.geometry.Orientation getOrientation()
      If a segment, i.e. two bend points is selected, returns the orientation of the selection.
      Returns:
      true if the selected points are on a horizontal line, otherwise false.
    • getOverlayThreshold

      protected double getOverlayThreshold()
      Removes the overlay threshold, i.e. the distance between two points, so that they are regarded as overlaying. When the background grid is enables ( GridModel.isShowGrid(), then the grid cell size is used to determine the overlay threshold. Otherwise, the DEFAULT_OVERLAY_THRESHOLD is used.
      Returns:
      The overlay threshold.
    • getSelectedIndices

      protected List<Integer> getSelectedIndices()
      Returns the list of indices selected via select(int).
      Returns:
      The list of selected indices in the order of their selection.
    • getSelectedInitialPositions

      public List<org.eclipse.gef.geometry.planar.Point> getSelectedInitialPositions()
      Returns the initial positions of the selected points in the local coordinate system of the host visual. May be null prior to the first move(Point, Point) call.
      Returns:
      The initial positions of the selected points in the local coordinate system of the host visual.
    • getVisualPoint

      protected org.eclipse.gef.geometry.planar.Point getVisualPoint(int bendPointIndex)
      Returns the current position for the given explicit anchor index, within the local coordinate system of the Connection.
      Parameters:
      bendPointIndex - The index
      Returns:
      The Point in local Connection coordinates.
    • init

      public void init()
      Specified by:
      init in interface org.eclipse.gef.mvc.fx.policies.IPolicy
      Overrides:
      init in class org.eclipse.gef.mvc.fx.policies.AbstractPolicy
    • insertExplicitAnchor

      protected void insertExplicitAnchor(int insertionIndex, org.eclipse.gef.geometry.planar.Point mouseInScene)
      Creates a new static anchor for the given position and inserts it at the given index.
      Parameters:
      insertionIndex - The explicit anchor index at which the new anchor is inserted.
      mouseInScene - The position for the new anchor in scene coordinates.
    • locallyExecuteOperation

      protected void locallyExecuteOperation()
      Overrides:
      locallyExecuteOperation in class org.eclipse.gef.mvc.fx.policies.AbstractPolicy
    • move

      public org.eclipse.gef.geometry.planar.Point move(org.eclipse.gef.geometry.planar.Point initialMouseInScene, org.eclipse.gef.geometry.planar.Point currentMouseInScene)
      Moves the currently selected point to the given mouse position in scene coordinates.
      Parameters:
      initialMouseInScene - The initial mouse position in scene coordinates.
      currentMouseInScene - The current mouse position in scene coordinates.
      Returns:
      The point to which the move was performed, in scene coordinates.
    • removeOverlain

      protected void removeOverlain()
      Removes any bend points overlain during the movement of selected ones.
    • restorePreMoveBendpoints

      protected void restorePreMoveBendpoints()
      Restores the initial bend points prior to moving.
    • select

      public void select(int index)
      Selects the point specified by the given segment index and parameter for manipulation. Captures the initial position of the selected point and the related initial mouse location.
      Parameters:
      index - Index of the bend point to select for manipulation.
    • selectSegment

      public void selectSegment(int from, int to)
      Selects the end points of the segment specified by the given indices. Will introduce new bend points in case the start or the end bend point are connected.
      Parameters:
      from - The start index of a segment.
      to - The end index of the segment.
    • setShiftDown

      public void setShiftDown(boolean isShiftDown)
      Sets the state of the shift key.
      Parameters:
      isShiftDown - true indicates the shift is pressed, false indicates it is not pressed
    • isShiftDown

      public boolean isShiftDown()
      Checks whether the shift is active.
      Returns:
      true if shift is pressed false otherwise