public abstract class AbstractAnchor extends Object implements IAnchor
AbstractAnchor is the abstract base implementation for
IAnchors. It provides the facility to bind an anchor to an anchorage
Node (anchorageProperty()), to attach and detach
Nodes via AnchorKeys, and to provide positions (
positionsUnmodifiableProperty()) for the attached AnchorKey
s.
It also registers the necessary listeners at the anchorage Node and
the attached Nodes as well as relevant ancestor Nodes, 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
AnchorKeys, 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.
| Type | Property and Description |
|---|---|
ReadOnlyObjectProperty<Node> |
anchorage
|
ReadOnlyMapProperty<AnchorKey,Point> |
positionsUnmodifiable
|
| Constructor and Description |
|---|
AbstractAnchor(Node anchorage)
Creates a new
AbstractAnchor for the given anchorage
Node. |
| Modifier and Type | Method and Description |
|---|---|
ReadOnlyObjectProperty<Node> |
anchorageProperty()
|
void |
attach(AnchorKey key)
|
protected abstract Point |
computePosition(AnchorKey key)
Recomputes the position for the given attached
AnchorKey by
delegating to the respective IComputationStrategy. |
void |
detach(AnchorKey key)
|
Node |
getAnchorage()
Gets the value of the property anchorage.
|
protected Set<AnchorKey> |
getKeys()
Returns all keys maintained by this anchor.
|
protected com.google.common.collect.SetMultimap<Node,AnchorKey> |
getKeysByNode()
|
Point |
getPosition(AnchorKey key)
Provides a position for the given
AnchorKey. |
ObservableMap<AnchorKey,Point> |
getPositionsUnmodifiable()
Gets the value of the property positionsUnmodifiable.
|
boolean |
isAttached(AnchorKey key)
|
ReadOnlyMapProperty<AnchorKey,Point> |
positionsUnmodifiableProperty()
|
protected void |
registerVCL(Node anchored)
Registers a
VisualChangeListener for the given anchored
Node. |
protected void |
registerVCLs()
Registers
VisualChangeListeners for all anchored Nodes,
or schedules their registration if the VCL cannot be registered yet. |
protected void |
setAnchorage(Node anchorage)
Sets the anchorage of this
AbstractAnchor to the given value. |
protected void |
unregisterVCL(Node anchored)
Unregisters the
VisualChangeListeners for the given anchored
Node. |
protected void |
unregisterVCLs()
Unregisters the
VisualChangeListeners for all anchored
Nodes. |
protected void |
updatePosition(AnchorKey key)
Updates the position for the given
AnchorKey, i.e. |
protected void |
updatePositions()
Updates the positions for all attached
AnchorKeys. |
public ReadOnlyObjectProperty<Node> anchorageProperty
anchorageProperty in interface IAnchorNode.getAnchorage(),
setAnchorage(Node)public ReadOnlyMapProperty<AnchorKey,Point> positionsUnmodifiableProperty
positionsUnmodifiableProperty in interface IAnchorAnchorKeys.getPositionsUnmodifiable()public AbstractAnchor(Node anchorage)
AbstractAnchor for the given anchorage
Node.anchorage - The anchorage Node for this AbstractAnchor.public ReadOnlyObjectProperty<Node> anchorageProperty()
IAnchorNode this
IAnchor is bound to. The property value may be null
in case this IAnchor is not bound to an anchorage Node.anchorageProperty in interface IAnchorNode.getAnchorage(),
setAnchorage(Node)protected abstract Point computePosition(AnchorKey key)
AnchorKey by
delegating to the respective IComputationStrategy.public Node getAnchorage()
getAnchorage in interface IAnchorIAnchor.anchorageProperty().protected Set<AnchorKey> getKeys()
AnchorKeys.public Point getPosition(AnchorKey key)
IAnchorAnchorKey. The provided
AnchorKey has to be attached to this IAnchor (see
IAnchor.attach(AnchorKey)).getPosition in interface IAnchorkey - The AnchorKey to retrieve a position for. It has to be
attached (IAnchor.attach(AnchorKey)) to this IAnchor
before.AnchorKey within local
coordinates of the AnchorKey's anchored Node.public ObservableMap<AnchorKey,Point> getPositionsUnmodifiable()
getPositionsUnmodifiable in interface IAnchorAnchorKeys.public boolean isAttached(AnchorKey key)
IAnchorisAttached in interface IAnchorkey - The AnchorKey to test.true if the given key is attached, otherwise
false.public ReadOnlyMapProperty<AnchorKey,Point> positionsUnmodifiableProperty()
IAnchorNodes) for all attached AnchorKeys. The
positions will be updated for all attached AnchorKeys if the
attached Nodes 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
Nodes).positionsUnmodifiableProperty in interface IAnchorAnchorKeys.getPositionsUnmodifiable()protected void registerVCL(Node anchored)
VisualChangeListener for the given anchored
Node.anchored - The anchored Node to register a
VisualChangeListener at.protected void registerVCLs()
VisualChangeListeners for all anchored Nodes,
or schedules their registration if the VCL cannot be registered yet.protected void setAnchorage(Node anchorage)
AbstractAnchor to the given value.anchorage - The new anchorage for this AbstractAnchor.protected void unregisterVCL(Node anchored)
VisualChangeListeners for the given anchored
Node.anchored - The anchored Node to unregister a VisualChangeListener
from.protected void unregisterVCLs()
VisualChangeListeners for all anchored
Nodes.protected void updatePosition(AnchorKey key)
AnchorKey, i.e.
positionsUnmodifiableProperty()key - The AnchorKey for which the position is updated.protected void updatePositions()
AnchorKeys.Copyright (c) 2014, 2016 itemis AG and others. All rights reserved.