public class FXBendPolicy extends AbstractTransactionPolicy<javafx.scene.Node>
FXBendPolicy can be used to manipulate the points constituting an
Connection, i.e. its start, way, and end points. Each point is
realized though an IAnchor, which may either be local to the
Connection (i.e. the anchor refers to the Connection as
anchorage), or it may be provided by another IVisualPart (i.e. the
anchor is provided by a Provider adapted to the part), to which the
connection is being connected.
When moving a point the policy takes care of:
IVisualPart under mouse when
applicable.| Modifier and Type | Field and Description |
|---|---|
protected static double |
DEFAULT_OVERLAY_THRESHOLD
The overlay threshold, i.e. the distance between two points so that they
are regarded as overlying.
|
| Constructor and Description |
|---|
FXBendPolicy() |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
canConnect(int pointIndex)
Returns
true if the currently modified start, end, or way
point can be connected, i.e. realized by an anchor that is not anchored
to the Connection itself (see IAnchor.getAnchorage() ),
but provided through a IVisualPart's anchor provider (i.e. a
Provider<IAnchor> adapted to the
IVisualPart). |
ITransactionalOperation |
commit()
Returns an
ITransactionalOperation that performs all
manipulations applied by the policy since the last AbstractTransactionPolicy.init() call. |
void |
createAndSelectPoint(int segmentIndex,
Point mouseInScene)
Creates a new point at the given segment.
|
protected FXBendOperation |
createOperation()
Creates an
ITransactionalOperation that is used to encapsulate
the changes that are applied by this AbstractTransactionPolicy
through its "work" methods. |
protected ReverseUndoCompositeOperation |
createReselectOperation()
Create an
IUndoableOperation to re-select the host part. |
protected IAnchor |
createUnconnectedAnchor(Point selectedPointCurrentPositionInLocal)
Creates an (unconnected) anchor (i.e. one anchored on the
Connection) for the given position (in scene coordinates). |
protected IAnchor |
findOrCreateAnchor(Point positionInLocal,
boolean canConnect)
Determines the
IAnchor that should replace the anchor of the
currently selected point. |
protected FXBendOperation |
getBendOperation()
Returns an
FXBendOperation that is extracted from the operation
created by createOperation(). |
protected Connection |
getConnection()
Returns the
Connection that is manipulated by this policy. |
IVisualPart<javafx.scene.Node,Connection> |
getHost()
|
protected Point |
getMouseDeltaInLocal(Point currentMousePositionInScene)
Computes the mouse movement delta (w.r.t. to the initial mouse position)
in local coordinates .
|
protected IAnchor |
getOverlayAnchor(int candidateIndex,
Point mouseInScene)
If the point at the given index is overlain by the currently selected
point, i.e. their distance is smaller than the
overlay threshold and they are above the
same anchorage, returns the anchor that can be found at the candidate
location. |
protected double |
getOverlayThreshold()
Removes the overlay threshold, i.e. the distance between two points, so
that they are regarded as overlaying.
|
protected Point |
getSelectedPointInitialPositionInLocal()
Returns the initial position of the currently selected point in the local
coordinate system of the
Connection. |
protected void |
handleOverlay(Point mouseInScene)
Handles the hiding of an overlain point as well as the expose of a
previously overlain point.
|
void |
init()
Initializes the policy, so that the policy's "work" methods can be used.
|
void |
moveSelectedPoint(Point mouseInScene)
Moves the currently selected point to the given mouse position in scene
coordinates.
|
void |
selectPoint(int segmentIndex,
double segmentParameter,
Point mouseInScene)
Selects the point specified by the given segment index and parameter for
manipulation.
|
java.lang.String |
toString() |
checkInitialized, getOperation, isInitialized, locallyExecuteOperation, rollbackgetAdaptable, setAdaptableprotected static final double DEFAULT_OVERLAY_THRESHOLD
protected boolean canConnect(int pointIndex)
true if the currently modified start, end, or way
point can be connected, i.e. realized by an anchor that is not anchored
to the Connection itself (see IAnchor.getAnchorage() ),
but provided through a IVisualPart's anchor provider (i.e. a
Provider<IAnchor> adapted to the
IVisualPart). Otherwise returns false. Per default,
only the start and the end point can be attached.pointIndex - The index of the currently modified connection point.true if the currently modified point can be realized
through an IAnchor not anchored on the Connection
. Otherwise returns false.Connection.isStartConnected(),
Connection.isWayConnected(int),
Connection.isEndConnected()public ITransactionalOperation commit()
AbstractTransactionPolicyITransactionalOperation that performs all
manipulations applied by the policy since the last AbstractTransactionPolicy.init() call.
When called multiple times in sequence, only the first call will yield an
operation, the subsequent calls will yield null.commit in class AbstractTransactionPolicy<javafx.scene.Node>ITransactionalOperation that performs all
manipulations applied by the policy since the last
AbstractTransactionPolicy.init() call.public void createAndSelectPoint(int segmentIndex,
Point mouseInScene)
segmentIndex - The index of the segment for which a new way point is created.mouseInScene - The mouse position in scene coordinates.protected FXBendOperation createOperation()
AbstractTransactionPolicyITransactionalOperation that is used to encapsulate
the changes that are applied by this AbstractTransactionPolicy
through its "work" methods. The created operation should allow for
local execution at each time.createOperation in class AbstractTransactionPolicy<javafx.scene.Node>ITransactionalOperation to encapsulate all applied
changes.protected ReverseUndoCompositeOperation createReselectOperation()
IUndoableOperation to re-select the host part.IUndoableOperation that deselects and selects the root
part.protected IAnchor createUnconnectedAnchor(Point selectedPointCurrentPositionInLocal)
Connection) for the given position (in scene coordinates).selectedPointCurrentPositionInLocal - The location in local coordinates of the connectionIAnchor that yields the given position.protected IAnchor findOrCreateAnchor(Point positionInLocal, boolean canConnect)
IAnchor that should replace the anchor of the
currently selected point. If the point can connect, the
IVisualPart at the mouse position is queried for an
IAnchor via a Provider<IAnchor> adapter.
Otherwise an (unconnected) anchor is create using
createUnconnectedAnchor(Point) .positionInLocal - A position in local coordinates of the connection.canConnect - true if the point can be attached to an
underlying IVisualPart, otherwise false.IAnchor that replaces the anchor of the currently
modified point.protected FXBendOperation getBendOperation()
FXBendOperation that is extracted from the operation
created by createOperation().FXBendOperation that is extracted from the operation
created by createOperation().protected Connection getConnection()
Connection that is manipulated by this policy.Connection that is manipulated by this policy.public IVisualPart<javafx.scene.Node,Connection> getHost()
IPolicygetHost in interface IPolicy<javafx.scene.Node>getHost in class AbstractPolicy<javafx.scene.Node>IPolicy.protected Point getMouseDeltaInLocal(Point currentMousePositionInScene)
currentMousePositionInScene - The current mouse position in scene coordinates.protected IAnchor getOverlayAnchor(int candidateIndex, Point mouseInScene)
overlay threshold and they are above the
same anchorage, returns the anchor that can be found at the candidate
location.candidateIndex - The candidate index.mouseInScene - The current mouse position in scene coordinates.IAnchor to be used for the currently
selected pointprotected double getOverlayThreshold()
GridModel.isShowGrid(), then the grid cell size is used to
determine the overlay threshold. Otherwise, the
DEFAULT_OVERLAY_THRESHOLD is used.protected Point getSelectedPointInitialPositionInLocal()
Connection.Connection.selectPoint(int, double, Point)protected void handleOverlay(Point mouseInScene)
Connection. The overlaid point is removed and saved so that it
can be restored later.mouseInScene - The current mouse position in scene coordinates.public void init()
AbstractTransactionPolicyIllegalStateException. It is safe to call AbstractTransactionPolicy.init()
multiple times in sequence.init in class AbstractTransactionPolicy<javafx.scene.Node>public void moveSelectedPoint(Point mouseInScene)
handleOverlay(Point).mouseInScene - The current mouse position in scene coordinates.public void selectPoint(int segmentIndex,
double segmentParameter,
Point mouseInScene)
getSelectedPointInitialPositionInLocal()) and the related
initial mouse location.segmentIndex - The index of the segment of which a point is to be
manipulated.segmentParameter - The parameter on the segment to identify if its the end point.mouseInScene - The current mouse position in scene coordinates.public java.lang.String toString()
toString in class java.lang.ObjectCopyright (c) 2014 itemis AG and others. All rights reserved.