Class BendArcPolicy
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
adaptableProperties 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
FieldsModifier and TypeFieldDescriptionprotected static final doubleThe overlay threshold, i.e.protected static final doubleThe overlay threshold, i.e. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancanConnect(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.ITransactionalOperationcommit()intcreateAfter(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.intcreateBefore(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.ITransactionalOperationprotected org.eclipse.gef.mvc.fx.operations.BendVisualOperationReturns anBendVisualOperationthat is extracted from the operation created bycreateOperation().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> getHost()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.OrientationIf a segment, i.e.protected doubleRemoves the overlay threshold, i.e.Returns the list of indices selected viaselect(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.PointgetVisualPoint(int bendPointIndex) Returns the current position for the given explicit anchor index, within the local coordinate system of theConnection.voidinit()protected voidinsertExplicitAnchor(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.booleanChecks whether the shift is active.protected voidorg.eclipse.gef.geometry.planar.Pointmove(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 voidRemoves any bend points overlain during the movement of selected ones.protected voidRestores the initial bend points prior to moving.voidselect(int index) Selects the point specified by the given segment index and parameter for manipulation.voidselectSegment(int from, int to) Selects the end points of the segment specified by the given indices.voidsetShiftDown(boolean isShiftDown) Sets the state of the shift key.Methods inherited from class org.eclipse.gef.mvc.fx.policies.AbstractPolicy
checkInitialized, getOperation, isInitialized, rollbackMethods inherited from class org.eclipse.gef.common.adapt.IAdaptable.Bound.Impl
adaptableProperty, getAdaptable, setAdaptableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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_THRESHOLDThe 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_THRESHOLDThe 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:
trueif the anchor at the given index can be connected, otherwisefalse.
-
commit
public org.eclipse.gef.mvc.fx.operations.ITransactionalOperation commit()- Specified by:
commitin interfaceorg.eclipse.gef.mvc.fx.policies.IPolicy- Overrides:
commitin classorg.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:
createOperationin classorg.eclipse.gef.mvc.fx.policies.AbstractPolicy
-
getNodesAt
-
getBendOperation
protected org.eclipse.gef.mvc.fx.operations.BendVisualOperation getBendOperation()Returns anBendVisualOperationthat is extracted from the operation created bycreateOperation().- Returns:
- an
BendVisualOperationthat is extracted from the operation created bycreateOperation().
-
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
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:
trueif the selected points are on a horizontal line, otherwisefalse.
-
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, theDEFAULT_OVERLAY_THRESHOLDis used.- Returns:
- The overlay threshold.
-
getSelectedIndices
Returns the list of indices selected viaselect(int).- Returns:
- The list of selected indices in the order of their selection.
-
getSelectedInitialPositions
Returns the initial positions of the selected points in the local coordinate system of the host visual. May benullprior to the firstmove(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 theConnection.- Parameters:
bendPointIndex- The index- Returns:
- The
Pointin localConnectioncoordinates.
-
init
public void init()- Specified by:
initin interfaceorg.eclipse.gef.mvc.fx.policies.IPolicy- Overrides:
initin classorg.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:
locallyExecuteOperationin classorg.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-trueindicates the shift is pressed,falseindicates it is not pressed
-
isShiftDown
public boolean isShiftDown()Checks whether the shift is active.- Returns:
trueif shift is pressedfalseotherwise
-