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
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.
-
Property Summary
Properties -
Constructor Summary
ConstructorsConstructorDescriptionAbstractAnchor(javafx.scene.Node anchorage) Creates a newAbstractAnchorfor the given anchorageNode. -
Method Summary
Modifier and TypeMethodDescriptionjavafx.beans.property.ReadOnlyObjectProperty<javafx.scene.Node>Provides a read-only property with the anchorageNodethisIAnchoris bound to.voidprotected abstract PointcomputePosition(AnchorKey key) Recomputes the position for the given attachedAnchorKeyby delegating to the respectiveIComputationStrategy.voidjavafx.scene.NodeGets the value of the property anchorage.getKeys()Returns all keys maintained by this anchor.protected SetMultimap<javafx.scene.Node,AnchorKey> getPosition(AnchorKey key) Provides a position for the givenAnchorKey.Gets the value of the property positionsUnmodifiable.booleanisAttached(AnchorKey key) Provides a read-only (map) property with positions (in local coordinates of the anchoredNodes) for all attachedAnchorKeys.protected voidregisterVCL(javafx.scene.Node anchored) Registers aVisualChangeListenerfor the given anchoredNode.protected voidRegistersVisualChangeListeners for all anchoredNodes, or schedules their registration if the VCL cannot be registered yet.protected voidsetAnchorage(javafx.scene.Node anchorage) Sets the anchorage of thisAbstractAnchorto the given value.protected voidunregisterVCL(javafx.scene.Node anchored) Unregisters theVisualChangeListeners for the given anchoredNode.protected voidUnregisters theVisualChangeListeners for all anchoredNodes.protected voidupdatePosition(AnchorKey key) Updates the position for the givenAnchorKey, i.e.protected voidUpdates the positions for all attachedAnchorKeys.
-
Property Details
-
anchorage
public javafx.beans.property.ReadOnlyObjectProperty<javafx.scene.Node> anchorageProperty- Specified by:
anchoragePropertyin interfaceIAnchor- Returns:
- A read-only property storing the anchorage
Node. - See Also:
-
positionsUnmodifiable
- Specified by:
positionsUnmodifiablePropertyin interfaceIAnchor- Returns:
- A read-only (map) property storing positions for all attached
AnchorKeys. - See Also:
-
-
Constructor Details
-
AbstractAnchor
public AbstractAnchor(javafx.scene.Node anchorage) Creates a newAbstractAnchorfor the given anchorageNode.- Parameters:
anchorage- The anchorageNodefor thisAbstractAnchor.
-
-
Method Details
-
anchorageProperty
public javafx.beans.property.ReadOnlyObjectProperty<javafx.scene.Node> anchorageProperty()Description copied from interface:IAnchorProvides a read-only property with the anchorageNodethisIAnchoris bound to. The property value may benullin case thisIAnchoris not bound to an anchorageNode.- Specified by:
anchoragePropertyin interfaceIAnchor- Returns:
- A read-only property storing the anchorage
Node. - See Also:
-
attach
Description copied from interface:IAnchor -
computePosition
Recomputes the position for the given attachedAnchorKeyby delegating to the respectiveIComputationStrategy. -
detach
Description copied from interface:IAnchor -
getAnchorage
public javafx.scene.Node getAnchorage()Gets the value of the property anchorage.- Specified by:
getAnchoragein interfaceIAnchor- Property description:
- Returns:
- The value of the
IAnchor.anchorageProperty().
-
getKeys
Returns all keys maintained by this anchor.- Returns:
- A set containing all
AnchorKeys.
-
getKeysByNode
-
getPosition
Description copied from interface:IAnchorProvides a position for the givenAnchorKey. The providedAnchorKeyhas to be attached to thisIAnchor(seeIAnchor.attach(AnchorKey)).- Specified by:
getPositionin interfaceIAnchor- Parameters:
key- TheAnchorKeyto retrieve a position for. It has to be attached (IAnchor.attach(AnchorKey)) to thisIAnchorbefore.- Returns:
- The position for the given
AnchorKeywithin local coordinates of theAnchorKey's anchoredNode.
-
getPositionsUnmodifiable
Gets the value of the property positionsUnmodifiable.- Specified by:
getPositionsUnmodifiablein interfaceIAnchor- Property description:
- Returns:
- A read-only observable map storing positions for all attached
AnchorKeys.
-
isAttached
Description copied from interface:IAnchor- Specified by:
isAttachedin interfaceIAnchor- Parameters:
key- TheAnchorKeyto test.- Returns:
trueif the given key is attached, otherwisefalse.
-
positionsUnmodifiableProperty
Description copied from interface:IAnchorProvides a read-only (map) property with positions (in local coordinates of the anchoredNodes) for all attachedAnchorKeys. The positions will be updated for all attachedAnchorKeys if the attachedNodes or the anchorageNode, theIAnchoris bound to, or any of their ancestors changes in a way that will effect the positions (within the local coordinate space of the attachedNodes).- Specified by:
positionsUnmodifiablePropertyin interfaceIAnchor- Returns:
- A read-only (map) property storing positions for all attached
AnchorKeys. - See Also:
-
registerVCL
protected void registerVCL(javafx.scene.Node anchored) Registers aVisualChangeListenerfor the given anchoredNode.- Parameters:
anchored- The anchoredNodeto register aVisualChangeListenerat.
-
registerVCLs
protected void registerVCLs()RegistersVisualChangeListeners for all anchoredNodes, or schedules their registration if the VCL cannot be registered yet. -
setAnchorage
protected void setAnchorage(javafx.scene.Node anchorage) Sets the anchorage of thisAbstractAnchorto the given value.- Parameters:
anchorage- The new anchorage for thisAbstractAnchor.
-
unregisterVCL
protected void unregisterVCL(javafx.scene.Node anchored) Unregisters theVisualChangeListeners for the given anchoredNode.- Parameters:
anchored- The anchored Node to unregister aVisualChangeListenerfrom.
-
unregisterVCLs
protected void unregisterVCLs()Unregisters theVisualChangeListeners for all anchoredNodes. -
updatePosition
Updates the position for the givenAnchorKey, i.e.- Queries its current position.
- Computes its new position.
- Checks if the position changed, and fires an appropriate event by
putting the new position into the
positionsUnmodifiableProperty()
- Parameters:
key- TheAnchorKeyfor which the position is updated.
-
updatePositions
protected void updatePositions()Updates the positions for all attachedAnchorKeys.
-