Package org.eclipse.gef.fx.anchors
Class DynamicAnchor
- java.lang.Object
-
- org.eclipse.gef.fx.anchors.AbstractAnchor
-
- org.eclipse.gef.fx.anchors.DynamicAnchor
-
- All Implemented Interfaces:
IAnchor
public class DynamicAnchor extends AbstractAnchor
TheDynamicAnchor
computes anchor positions through aIComputationStrategy
. The strategy performs the position calculation based onIComputationStrategy.Parameter
s, which are controlled by theDynamicAnchor
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DynamicAnchor.AnchorageReferenceGeometry
AnIComputationStrategy.Parameter
that encapsulates an (anchorage) reference geometry.static class
DynamicAnchor.AnchorageReferencePosition
AnIComputationStrategy.Parameter
that encapsulates an (anchorage) reference point.static class
DynamicAnchor.AnchoredReferencePoint
AnIComputationStrategy.Parameter
that encapsulates a projection reference point.static class
DynamicAnchor.PreferredOrientation
AnIComputationStrategy.Parameter
that encapsulates the preferred orientation to be used for orthogonal projections.
-
Constructor Summary
Constructors Constructor Description DynamicAnchor(javafx.scene.Node anchorage)
Constructs a newDynamicAnchor
for the given anchorage visual that uses aChopBoxStrategy
as computation strategy.DynamicAnchor(javafx.scene.Node anchorage, IComputationStrategy computationStrategy)
Constructs a newDynamicAnchor
for the given anchorage visual using the givenIComputationStrategy
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected javafx.beans.property.ReadOnlySetProperty<IComputationStrategy.Parameter<?>>
anchorageComputationParametersProperty()
Returns aReadOnlySetProperty
that provides thecomputation parameters
of kindIComputationStrategy.Parameter.Kind.ANCHORAGE
.protected ReadOnlySetMultimapProperty<AnchorKey,IComputationStrategy.Parameter<?>>
anchoredComputationParametersProperty()
Returns aReadOnlySetMultimapProperty
that provides thecomputation parameters
of kindIComputationStrategy.Parameter.Kind.ANCHORED
perAnchorKey
.void
attach(AnchorKey key)
protected Point
computePosition(AnchorKey key)
Recomputes the position for the given attachedAnchorKey
by delegating to the respectiveIComputationStrategy
.void
detach(AnchorKey key)
<T extends IComputationStrategy.Parameter<?>>
TgetComputationParameter(java.lang.Class<T> parameterType)
Retrieves a computation parameter of the respective type.<T extends IComputationStrategy.Parameter<?>>
TgetComputationParameter(AnchorKey key, java.lang.Class<T> parameterType)
Retrieves a computation parameter of the respective type for the givenAnchorKey
.IComputationStrategy
getComputationStrategy()
Returns theIComputationStrategy
used by thisDynamicAnchor
.protected java.util.Set<IComputationStrategy.Parameter<?>>
getParameters(AnchorKey key)
Retrieves the relevant parameters for the computation of the givenAnchorKey
.void
setComputationStrategy(IComputationStrategy computationStrategy)
Sets the givenIComputationStrategy
to be used by thisIAnchor
.-
Methods inherited from class org.eclipse.gef.fx.anchors.AbstractAnchor
anchorageProperty, getAnchorage, getKeys, getKeysByNode, getPosition, getPositionsUnmodifiable, isAttached, positionsUnmodifiableProperty, registerVCL, registerVCLs, setAnchorage, unregisterVCL, unregisterVCLs, updatePosition, updatePositions
-
-
-
-
Constructor Detail
-
DynamicAnchor
public DynamicAnchor(javafx.scene.Node anchorage)
Constructs a newDynamicAnchor
for the given anchorage visual that uses aChopBoxStrategy
as computation strategy. The anchor will also add a default binding for theDynamicAnchor.AnchorageReferenceGeometry
computation parameter, which is required by theChopBoxStrategy
, that infers the geometry from the anchorage's shape outline.- Parameters:
anchorage
- The anchorage visual.
-
DynamicAnchor
public DynamicAnchor(javafx.scene.Node anchorage, IComputationStrategy computationStrategy)
Constructs a newDynamicAnchor
for the given anchorage visual using the givenIComputationStrategy
. The anchor will also add a default binding for theDynamicAnchor.AnchorageReferenceGeometry
computation parameter, inferring the geometry from the anchorage's shape outline, in case this parameter is required by the givenIComputationStrategy
.- Parameters:
anchorage
- The anchorage visual.computationStrategy
- TheIComputationStrategy
to use.
-
-
Method Detail
-
anchorageComputationParametersProperty
protected javafx.beans.property.ReadOnlySetProperty<IComputationStrategy.Parameter<?>> anchorageComputationParametersProperty()
Returns aReadOnlySetProperty
that provides thecomputation parameters
of kindIComputationStrategy.Parameter.Kind.ANCHORAGE
.- Returns:
- A
ReadOnlySetProperty
providing theIComputationStrategy.Parameter
s.
-
anchoredComputationParametersProperty
protected ReadOnlySetMultimapProperty<AnchorKey,IComputationStrategy.Parameter<?>> anchoredComputationParametersProperty()
Returns aReadOnlySetMultimapProperty
that provides thecomputation parameters
of kindIComputationStrategy.Parameter.Kind.ANCHORED
perAnchorKey
. The set of computation parameters for eachAnchorKey
is initialed by the responsible computation strategy.- Returns:
- A
ReadOnlySetMultimapProperty
that provides anObject
perAnchorKey
.
-
attach
public void attach(AnchorKey key)
Description copied from interface:IAnchor
- Specified by:
attach
in interfaceIAnchor
- Overrides:
attach
in classAbstractAnchor
- Parameters:
key
- TheAnchorKey
to be attached.
-
computePosition
protected Point computePosition(AnchorKey key)
Recomputes the position for the given attachedAnchorKey
by delegating to the respectiveIComputationStrategy
.- Specified by:
computePosition
in classAbstractAnchor
- Parameters:
key
- TheAnchorKey
for which to compute an anchor position.- Returns:
- The point for the given
AnchorKey
in local coordinates of the anchoredNode
.
-
detach
public void detach(AnchorKey key)
Description copied from interface:IAnchor
- Specified by:
detach
in interfaceIAnchor
- Overrides:
detach
in classAbstractAnchor
- Parameters:
key
- TheAnchorKey
to be detached.
-
getComputationParameter
public <T extends IComputationStrategy.Parameter<?>> T getComputationParameter(AnchorKey key, java.lang.Class<T> parameterType)
Retrieves a computation parameter of the respective type for the givenAnchorKey
.- Type Parameters:
T
- The value type of the computation parameter.- Parameters:
key
- TheAnchorKey
for which to retrieve the anchored parameter.parameterType
- The type of computation parameter.- Returns:
- The anchored computation parameter.
-
getComputationParameter
public <T extends IComputationStrategy.Parameter<?>> T getComputationParameter(java.lang.Class<T> parameterType)
Retrieves a computation parameter of the respective type.- Type Parameters:
T
- The value type of the computation parameter.- Parameters:
parameterType
- The type of computation parameter.- Returns:
- The anchored computation parameter.
-
getComputationStrategy
public IComputationStrategy getComputationStrategy()
Returns theIComputationStrategy
used by thisDynamicAnchor
.- Returns:
- The
IComputationStrategy
.
-
getParameters
protected java.util.Set<IComputationStrategy.Parameter<?>> getParameters(AnchorKey key)
Retrieves the relevant parameters for the computation of the givenAnchorKey
.
-
setComputationStrategy
public void setComputationStrategy(IComputationStrategy computationStrategy)
Sets the givenIComputationStrategy
to be used by thisIAnchor
.- Parameters:
computationStrategy
- TheIComputationStrategy
that will be used to compute positions for all attachedAnchorKey
s.
-
-