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
TheDynamicAnchorcomputes anchor positions through aIComputationStrategy. The strategy performs the position calculation based onIComputationStrategy.Parameters, which are controlled by theDynamicAnchor.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDynamicAnchor.AnchorageReferenceGeometryAnIComputationStrategy.Parameterthat encapsulates an (anchorage) reference geometry.static classDynamicAnchor.AnchorageReferencePositionAnIComputationStrategy.Parameterthat encapsulates an (anchorage) reference point.static classDynamicAnchor.AnchoredReferencePointAnIComputationStrategy.Parameterthat encapsulates a projection reference point.static classDynamicAnchor.PreferredOrientationAnIComputationStrategy.Parameterthat encapsulates the preferred orientation to be used for orthogonal projections.
-
Constructor Summary
Constructors Constructor Description DynamicAnchor(javafx.scene.Node anchorage)Constructs a newDynamicAnchorfor the given anchorage visual that uses aChopBoxStrategyas computation strategy.DynamicAnchor(javafx.scene.Node anchorage, IComputationStrategy computationStrategy)Constructs a newDynamicAnchorfor 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 aReadOnlySetPropertythat provides thecomputation parametersof kindIComputationStrategy.Parameter.Kind.ANCHORAGE.protected ReadOnlySetMultimapProperty<AnchorKey,IComputationStrategy.Parameter<?>>anchoredComputationParametersProperty()Returns aReadOnlySetMultimapPropertythat provides thecomputation parametersof kindIComputationStrategy.Parameter.Kind.ANCHOREDperAnchorKey.voidattach(AnchorKey key)protected PointcomputePosition(AnchorKey key)Recomputes the position for the given attachedAnchorKeyby delegating to the respectiveIComputationStrategy.voiddetach(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.IComputationStrategygetComputationStrategy()Returns theIComputationStrategyused by thisDynamicAnchor.protected java.util.Set<IComputationStrategy.Parameter<?>>getParameters(AnchorKey key)Retrieves the relevant parameters for the computation of the givenAnchorKey.voidsetComputationStrategy(IComputationStrategy computationStrategy)Sets the givenIComputationStrategyto 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 newDynamicAnchorfor the given anchorage visual that uses aChopBoxStrategyas computation strategy. The anchor will also add a default binding for theDynamicAnchor.AnchorageReferenceGeometrycomputation 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 newDynamicAnchorfor the given anchorage visual using the givenIComputationStrategy. The anchor will also add a default binding for theDynamicAnchor.AnchorageReferenceGeometrycomputation 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- TheIComputationStrategyto use.
-
-
Method Detail
-
anchorageComputationParametersProperty
protected javafx.beans.property.ReadOnlySetProperty<IComputationStrategy.Parameter<?>> anchorageComputationParametersProperty()
Returns aReadOnlySetPropertythat provides thecomputation parametersof kindIComputationStrategy.Parameter.Kind.ANCHORAGE.- Returns:
- A
ReadOnlySetPropertyproviding theIComputationStrategy.Parameters.
-
anchoredComputationParametersProperty
protected ReadOnlySetMultimapProperty<AnchorKey,IComputationStrategy.Parameter<?>> anchoredComputationParametersProperty()
Returns aReadOnlySetMultimapPropertythat provides thecomputation parametersof kindIComputationStrategy.Parameter.Kind.ANCHOREDperAnchorKey. The set of computation parameters for eachAnchorKeyis initialed by the responsible computation strategy.- Returns:
- A
ReadOnlySetMultimapPropertythat provides anObjectperAnchorKey.
-
attach
public void attach(AnchorKey key)
Description copied from interface:IAnchor- Specified by:
attachin interfaceIAnchor- Overrides:
attachin classAbstractAnchor- Parameters:
key- TheAnchorKeyto be attached.
-
computePosition
protected Point computePosition(AnchorKey key)
Recomputes the position for the given attachedAnchorKeyby delegating to the respectiveIComputationStrategy.- Specified by:
computePositionin classAbstractAnchor- Parameters:
key- TheAnchorKeyfor which to compute an anchor position.- Returns:
- The point for the given
AnchorKeyin local coordinates of the anchoredNode.
-
detach
public void detach(AnchorKey key)
Description copied from interface:IAnchor- Specified by:
detachin interfaceIAnchor- Overrides:
detachin classAbstractAnchor- Parameters:
key- TheAnchorKeyto 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- TheAnchorKeyfor 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 theIComputationStrategyused 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 givenIComputationStrategyto be used by thisIAnchor.- Parameters:
computationStrategy- TheIComputationStrategythat will be used to compute positions for all attachedAnchorKeys.
-
-