Package org.eclipse.gef.fx.anchors

## Class AbstractAnchor

- java.lang.Object
- - org.eclipse.gef.fx.anchors.AbstractAnchor

All Implemented Interfaces:
  `IAnchor`

Direct Known Subclasses:
  `DynamicAnchor`, `StaticAnchor`

    public abstract class AbstractAnchor
    extends java.lang.Object
    implements IAnchor

`AbstractAnchor` is the abstract base implementation for `IAnchor`s. It provides the facility to bind an anchor to an anchorage `Node` (`anchorageProperty()`), to attach and detach `Node`s via `AnchorKey`s, and to provide positions ( `positionsUnmodifiableProperty()`) for the attached `AnchorKey` s.

It also registers the necessary listeners at the anchorage `Node` and the attached `Node`s as well as relevant ancestor `Node`s, to trigger the (re-)computation of positions.

The actual computation of positions for attached nodes is delegated to `computePosition(AnchorKey)`, thus left to subclasses. If a subclass needs additional information to compute positions for attached `AnchorKey`s, it may request that an `IAdaptable` info gets passed into `attach(AnchorKey)` and `detach(AnchorKey)`, and may overwrite both methods to get access to it.

### Constructor Summary

Constructors
`AbstractAnchor​(javafx.scene.Node anchorage)` Creates a new `AbstractAnchor` for the given anchorage `Node`.

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`javafx.beans.property.ReadOnlyObjectProperty<javafx.scene.Node>` `anchorageProperty()` Provides a read-only property with the anchorage `Node` this `IAnchor` is bound to.
`void` `attach​(AnchorKey key)` Attaches the given `AnchorKey` to this `IAnchor`.
`protected abstract 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`.
`javafx.scene.Node` `getAnchorage()` Provides the anchorage `Node` this `IAnchor` is bound to.
`protected java.util.Set<AnchorKey>` `getKeys()` Returns all keys maintained by this anchor.
`protected SetMultimap<javafx.scene.Node,​AnchorKey>` `getKeysByNode()` Returns the `Map` which stores the registered `AnchorKey`s per `Node` by reference.
`Point` `getPosition​(AnchorKey key)` Provides a position for the given `AnchorKey`.
`javafx.collections.ObservableMap<AnchorKey,​Point>` `getPositionsUnmodifiable()` Provides an observable read-only (map) with positions (in local coordinates of the anchored `Node`s) for all attached `AnchorKey`s.
`boolean` `isAttached​(AnchorKey key)` Determines if the given `AnchorKey` is currently attached to this `IAnchor`.
`javafx.beans.property.ReadOnlyMapProperty<AnchorKey,​Point>` `positionsUnmodifiableProperty()` Provides a read-only (map) property with positions (in local coordinates of the anchored `Node`s) for all attached `AnchorKey`s.
`protected void` `registerVCL​(javafx.scene.Node anchored)` Registers a `VisualChangeListener` for the given anchored `Node`.
`protected void` `registerVCLs()` Registers `VisualChangeListener`s for all anchored `Node`s, or schedules their registration if the VCL cannot be registered yet.
`protected void` `setAnchorage​(javafx.scene.Node anchorage)` Sets the anchorage of this `AbstractAnchor` to the given value.
`protected void` `unregisterVCL​(javafx.scene.Node anchored)` Unregisters the `VisualChangeListener`s for the given anchored `Node`.
`protected void` `unregisterVCLs()` Unregisters the `VisualChangeListener`s for all anchored `Node`s.
`protected void` `updatePosition​(AnchorKey key)` Updates the position for the given `AnchorKey`, i.e.
`protected void` `updatePositions()` Updates the positions for all attached `AnchorKey`s.

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

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

### Constructor Detail

#### AbstractAnchor

    public AbstractAnchor​(javafx.scene.Node anchorage)

Creates a new `AbstractAnchor` for the given anchorage `Node`.

Parameters:
  `anchorage` - The anchorage `Node` for this `AbstractAnchor`.

### Method Detail

#### anchorageProperty

    public javafx.beans.property.ReadOnlyObjectProperty<javafx.scene.Node> anchorageProperty()

Description copied from interface: `IAnchor`
Provides a read-only property with the anchorage `Node` this `IAnchor` is bound to. The property value may be `null` in case this `IAnchor` is not bound to an anchorage `Node`.

Specified by:
  `anchorageProperty` in interface `IAnchor`
Returns:
  A read-only property storing the anchorage `Node`.

#### attach

    public void attach​(AnchorKey key)

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

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

#### computePosition

    protected abstract Point computePosition​(AnchorKey key)

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

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`
Parameters:
  `key` - The `AnchorKey` to be detached.

#### getAnchorage

    public javafx.scene.Node getAnchorage()

Description copied from interface: `IAnchor`
Provides the anchorage `Node` this `IAnchor` is bound to. Will return the value of the `IAnchor.anchorageProperty()`.

Specified by:
  `getAnchorage` in interface `IAnchor`
Returns:
  The value of the `IAnchor.anchorageProperty()`.

#### getKeys

    protected java.util.Set<AnchorKey> getKeys()

Returns all keys maintained by this anchor.

Returns:
  A set containing all `AnchorKey`s.

#### getKeysByNode

    protected SetMultimap<javafx.scene.Node,​AnchorKey> getKeysByNode()

Returns the `Map` which stores the registered `AnchorKey`s per `Node` by reference.

Returns:
  The `Map` which stores the registered `AnchorKey`s per `Node` by reference.

#### getPosition

    public Point getPosition​(AnchorKey key)

Description copied from interface: `IAnchor`
Provides a position for the given `AnchorKey`. The provided `AnchorKey` has to be attached to this `IAnchor` (see `IAnchor.attach(AnchorKey)`).

Specified by:
  `getPosition` in interface `IAnchor`
Parameters:
  `key` - The `AnchorKey` to retrieve a position for. It has to be attached (`IAnchor.attach(AnchorKey)`) to this `IAnchor` before.
Returns:
  The position for the given `AnchorKey` within local coordinates of the `AnchorKey`'s anchored `Node`.

#### getPositionsUnmodifiable

    public javafx.collections.ObservableMap<AnchorKey,​Point> getPositionsUnmodifiable()

Description copied from interface: `IAnchor`
Provides an observable read-only (map) with positions (in local coordinates of the anchored `Node`s) for all attached `AnchorKey`s. The positions will be updated for all attached `AnchorKey`s if the attached `Node`s or the anchorage `Node`, the `IAnchor` is bound to, or any of their ancestors changes in a way that will effect the positions (within the local coordinate space of the attached `Node`s).

Specified by:
  `getPositionsUnmodifiable` in interface `IAnchor`
Returns:
  A read-only observable map storing positions for all attached `AnchorKey`s.

#### isAttached

    public boolean isAttached​(AnchorKey key)

Description copied from interface: `IAnchor`
Determines if the given `AnchorKey` is currently attached to this `IAnchor`.

Specified by:
  `isAttached` in interface `IAnchor`
Parameters:
  `key` - The `AnchorKey` to test.
Returns:
  `true` if the given key is attached, otherwise `false`.

#### positionsUnmodifiableProperty

    public javafx.beans.property.ReadOnlyMapProperty<AnchorKey,​Point> positionsUnmodifiableProperty()

Description copied from interface: `IAnchor`
Provides a read-only (map) property with positions (in local coordinates of the anchored `Node`s) for all attached `AnchorKey`s. The positions will be updated for all attached `AnchorKey`s if the attached `Node`s or the anchorage `Node`, the `IAnchor` is bound to, or any of their ancestors changes in a way that will effect the positions (within the local coordinate space of the attached `Node`s).

Specified by:
  `positionsUnmodifiableProperty` in interface `IAnchor`
Returns:
  A read-only (map) property storing positions for all attached `AnchorKey`s.

#### registerVCL

    protected void registerVCL​(javafx.scene.Node anchored)

Registers a `VisualChangeListener` for the given anchored `Node`.

Parameters:
  `anchored` - The anchored `Node` to register a `VisualChangeListener` at.

#### registerVCLs

    protected void registerVCLs()

Registers `VisualChangeListener`s for all anchored `Node`s, or schedules their registration if the VCL cannot be registered yet.

#### setAnchorage

    protected void setAnchorage​(javafx.scene.Node anchorage)

Sets the anchorage of this `AbstractAnchor` to the given value.

Parameters:
  `anchorage` - The new anchorage for this `AbstractAnchor`.

#### unregisterVCL

    protected void unregisterVCL​(javafx.scene.Node anchored)

Unregisters the `VisualChangeListener`s for the given anchored `Node`.

Parameters:
  `anchored` - The anchored Node to unregister a `VisualChangeListener` from.

#### unregisterVCLs

    protected void unregisterVCLs()

Unregisters the `VisualChangeListener`s for all anchored `Node`s.

#### updatePosition

    protected void updatePosition​(AnchorKey key)

Updates the position for the given `AnchorKey`, i.e.

1. Queries its current position.
2. Computes its new position.
3. Checks if the position changed, and fires an appropriate event by putting the new position into the `positionsUnmodifiableProperty()`

Parameters:
  `key` - The `AnchorKey` for which the position is updated.

#### updatePositions

    protected void updatePositions()

Updates the positions for all attached `AnchorKey`s.