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

The `DynamicAnchor` computes anchor positions through a `IComputationStrategy`. The strategy performs the position calculation based on `IComputationStrategy.Parameter`s, which are controlled by the `DynamicAnchor`.

### Property Summary

All Methods Instance Methods Concrete Methods
`protected ReadOnlySetProperty<IComputationStrategy.Parameter<?>>` `anchorageComputationParameters` Returns a `ReadOnlySetProperty` that provides the `computation parameters` of kind `IComputationStrategy.Parameter.Kind.ANCHORAGE`.
`protected ReadOnlySetMultimapProperty<AnchorKey,IComputationStrategy.Parameter<?>>` `anchoredComputationParameters` Returns a `ReadOnlySetMultimapProperty` that provides the `computation parameters` of kind `IComputationStrategy.Parameter.Kind.ANCHORED` per `AnchorKey`.

### Properties inherited from class org.eclipse.gef.fx.anchors.AbstractAnchor

`anchorage, positionsUnmodifiable`

### Nested Class Summary

Nested Classes
`static class` `DynamicAnchor.AnchorageReferenceGeometry` An `IComputationStrategy.Parameter` that encapsulates an (anchorage) reference geometry.
`static class` `DynamicAnchor.AnchorageReferencePosition` An `IComputationStrategy.Parameter` that encapsulates an (anchorage) reference point.
`static class` `DynamicAnchor.AnchoredReferencePoint` An `IComputationStrategy.Parameter` that encapsulates a projection reference point.
`static class` `DynamicAnchor.PreferredOrientation` An `IComputationStrategy.Parameter` that encapsulates the preferred orientation to be used for orthogonal projections.

### Constructor Summary

Constructors
Constructor and Description
`DynamicAnchor(Node anchorage)` Constructs a new `DynamicAnchor` for the given anchorage visual that uses a `ChopBoxStrategy` as computation strategy.
`DynamicAnchor(Node anchorage, IComputationStrategy computationStrategy)` Constructs a new `DynamicAnchor` for the given anchorage visual using the given `IComputationStrategy`.

### Method Summary

All Methods Instance Methods Concrete Methods
`protected ReadOnlySetProperty<IComputationStrategy.Parameter<?>>` `anchorageComputationParametersProperty()` Returns a `ReadOnlySetProperty` that provides the `computation parameters` of kind `IComputationStrategy.Parameter.Kind.ANCHORAGE`.
`protected ReadOnlySetMultimapProperty<AnchorKey,IComputationStrategy.Parameter<?>>` `anchoredComputationParametersProperty()` Returns a `ReadOnlySetMultimapProperty` that provides the `computation parameters` of kind `IComputationStrategy.Parameter.Kind.ANCHORED` per `AnchorKey`.
`void` `attach(AnchorKey key)` Attaches the given `AnchorKey` to this `IAnchor`.
`protected Point` `computePosition(AnchorKey key)` Recomputes the position for the given attached `AnchorKey` by delegating to the respective `IComputationStrategy`.
`void` `detach(AnchorKey key)` Detaches the given `AnchorKey` from this `IAnchor`.
`<T extends IComputationStrategy.Parameter<?>> T` `getComputationParameter(AnchorKey key, Class<T> parameterType)` Retrieves a computation parameter of the respective type for the given `AnchorKey`.
`<T extends IComputationStrategy.Parameter<?>> T` `getComputationParameter(Class<T> parameterType)` Retrieves a computation parameter of the respective type.
`IComputationStrategy` `getComputationStrategy()` Returns the `IComputationStrategy` used by this `DynamicAnchor`.
`protected Set<IComputationStrategy.Parameter<?>>` `getParameters(AnchorKey key)` Retrieves the relevant parameters for the computation of the given `AnchorKey`.
`void` `setComputationStrategy(IComputationStrategy computationStrategy)` Sets the given `IComputationStrategy` to be used by this `IAnchor`.

### 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`

### Methods inherited from class java.lang.Object

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

### Property Detail

#### anchorageComputationParameters

    protected ReadOnlySetProperty<IComputationStrategy.Parameter<?>> anchorageComputationParametersProperty

Returns a `ReadOnlySetProperty` that provides the `computation parameters` of kind `IComputationStrategy.Parameter.Kind.ANCHORAGE`.

#### anchoredComputationParameters

    protected ReadOnlySetMultimapProperty<AnchorKey,IComputationStrategy.Parameter<?>> anchoredComputationParametersProperty

Returns a `ReadOnlySetMultimapProperty` that provides the `computation parameters` of kind `IComputationStrategy.Parameter.Kind.ANCHORED` per `AnchorKey`. The set of computation parameters for each `AnchorKey` is initialed by the responsible computation strategy.

### Constructor Detail

#### DynamicAnchor

    public DynamicAnchor(Node anchorage)

Constructs a new `DynamicAnchor` for the given anchorage visual that uses a `ChopBoxStrategy` as computation strategy. The anchor will also add a default binding for the `DynamicAnchor.AnchorageReferenceGeometry` computation parameter, which is required by the `ChopBoxStrategy`, that infers the geometry from the anchorage's shape outline.

Parameters:
  `anchorage` - The anchorage visual.

#### DynamicAnchor

    public DynamicAnchor(Node anchorage,
                         IComputationStrategy computationStrategy)

Constructs a new `DynamicAnchor` for the given anchorage visual using the given `IComputationStrategy`. The anchor will also add a default binding for the `DynamicAnchor.AnchorageReferenceGeometry` computation parameter, inferring the geometry from the anchorage's shape outline, in case this parameter is required by the given `IComputationStrategy`.

Parameters:
  `anchorage` - The anchorage visual.
  `computationStrategy` - The `IComputationStrategy` to use.

### Method Detail

#### anchorageComputationParametersProperty

    protected ReadOnlySetProperty<IComputationStrategy.Parameter<?>> anchorageComputationParametersProperty()

Returns a `ReadOnlySetProperty` that provides the `computation parameters` of kind `IComputationStrategy.Parameter.Kind.ANCHORAGE`.

#### anchoredComputationParametersProperty

    protected ReadOnlySetMultimapProperty<AnchorKey,IComputationStrategy.Parameter<?>> anchoredComputationParametersProperty()

Returns a `ReadOnlySetMultimapProperty` that provides the `computation parameters` of kind `IComputationStrategy.Parameter.Kind.ANCHORED` per `AnchorKey`. The set of computation parameters for each `AnchorKey` is initialed by the responsible computation strategy.

#### attach

    public void attach(AnchorKey key)

Description copied from interface: `IAnchor`
Attaches the given `AnchorKey` to this `IAnchor`.

Specified by:
  `attach` in interface `IAnchor`
Overrides:
  `attach` in class `AbstractAnchor`
Parameters:
  `key` - The `AnchorKey` to be attached.

#### computePosition

    protected Point computePosition(AnchorKey key)

Recomputes the position for the given attached `AnchorKey` by delegating to the respective `IComputationStrategy`.

Specified by:
  `computePosition` in class `AbstractAnchor`
Parameters:
  `key` - The `AnchorKey` for which to compute an anchor position.
Returns:
  The point for the given `AnchorKey` in local coordinates of the anchored `Node`.

#### detach

    public void detach(AnchorKey key)

Description copied from interface: `IAnchor`
Detaches the given `AnchorKey` from this `IAnchor`.

Specified by:
  `detach` in interface `IAnchor`
Overrides:
  `detach` in class `AbstractAnchor`
Parameters:
  `key` - The `AnchorKey` to be detached.

#### getComputationParameter

    public <T extends IComputationStrategy.Parameter<?>> T getComputationParameter(AnchorKey key,
                                                                                   Class<T> parameterType)

Retrieves a computation parameter of the respective type for the given `AnchorKey`.

Type Parameters:
  `T` - The value type of the computation parameter.
Parameters:
  `key` - The `AnchorKey` 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(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 the `IComputationStrategy` used by this `DynamicAnchor`.

Returns:
  The `IComputationStrategy`.

#### getParameters

    protected Set<IComputationStrategy.Parameter<?>> getParameters(AnchorKey key)

Retrieves the relevant parameters for the computation of the given `AnchorKey`.

Parameters:
  `key` - The `AnchorKey` of relevance.
Returns:
  The parameters required by the computation strategy to compute the position for the given `AnchorKey`.

#### setComputationStrategy

    public void setComputationStrategy(IComputationStrategy computationStrategy)

Sets the given `IComputationStrategy` to be used by this `IAnchor`.

Parameters:
  `computationStrategy` - The `IComputationStrategy` that will be used to compute positions for all attached `AnchorKey`s.