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
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.
-
Property Summary
TypePropertyDescription -
Constructor Summary
ConstructorDescriptionAbstractAnchor
(Node anchorage) Creates a newAbstractAnchor
for the given anchorageNode
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
protected abstract Point
computePosition
(AnchorKey key) Recomputes the position for the given attachedAnchorKey
by delegating to the respectiveIComputationStrategy
.void
Gets the value of the property anchorage.getKeys()
Returns all keys maintained by this anchor.protected SetMultimap<Node,
AnchorKey> getPosition
(AnchorKey key) Provides a position for the givenAnchorKey
.Gets the value of the property positionsUnmodifiable.boolean
isAttached
(AnchorKey key) protected void
registerVCL
(Node anchored) Registers aVisualChangeListener
for the given anchoredNode
.protected void
RegistersVisualChangeListener
s for all anchoredNode
s, or schedules their registration if the VCL cannot be registered yet.protected void
setAnchorage
(Node anchorage) Sets the anchorage of thisAbstractAnchor
to the given value.protected void
unregisterVCL
(Node anchored) Unregisters theVisualChangeListener
s for the given anchoredNode
.protected void
Unregisters theVisualChangeListener
s for all anchoredNode
s.protected void
updatePosition
(AnchorKey key) Updates the position for the givenAnchorKey
, i.e.protected void
Updates the positions for all attachedAnchorKey
s.
-
Property Details
-
anchorage
- Specified by:
anchorageProperty
in interfaceIAnchor
- Returns:
- A read-only property storing the anchorage
Node
. - See Also:
-
positionsUnmodifiable
- Specified by:
positionsUnmodifiableProperty
in interfaceIAnchor
- Returns:
- A read-only (map) property storing positions for all attached
AnchorKey
s. - See Also:
-
-
Constructor Details
-
AbstractAnchor
Creates a newAbstractAnchor
for the given anchorageNode
.- Parameters:
anchorage
- The anchorageNode
for thisAbstractAnchor
.
-
-
Method Details
-
anchorageProperty
Description copied from interface:IAnchor
Provides a read-only property with the anchorageNode
thisIAnchor
is bound to. The property value may benull
in case thisIAnchor
is not bound to an anchorageNode
.- Specified by:
anchorageProperty
in 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 attachedAnchorKey
by delegating to the respectiveIComputationStrategy
. -
detach
Description copied from interface:IAnchor
-
getAnchorage
Gets the value of the property anchorage.- Specified by:
getAnchorage
in interfaceIAnchor
- Property description:
- Returns:
- The value of the
IAnchor.anchorageProperty()
.
-
getKeys
Returns all keys maintained by this anchor.- Returns:
- A set containing all
AnchorKey
s.
-
getKeysByNode
-
getPosition
Description copied from interface:IAnchor
Provides a position for the givenAnchorKey
. The providedAnchorKey
has to be attached to thisIAnchor
(seeIAnchor.attach(AnchorKey)
).- Specified by:
getPosition
in interfaceIAnchor
- Parameters:
key
- TheAnchorKey
to retrieve a position for. It has to be attached (IAnchor.attach(AnchorKey)
) to thisIAnchor
before.- Returns:
- The position for the given
AnchorKey
within local coordinates of theAnchorKey
's anchoredNode
.
-
getPositionsUnmodifiable
Gets the value of the property positionsUnmodifiable.- Specified by:
getPositionsUnmodifiable
in interfaceIAnchor
- Property description:
- Returns:
- A read-only observable map storing positions for all attached
AnchorKey
s.
-
isAttached
Description copied from interface:IAnchor
- Specified by:
isAttached
in interfaceIAnchor
- Parameters:
key
- TheAnchorKey
to test.- Returns:
true
if the given key is attached, otherwisefalse
.
-
positionsUnmodifiableProperty
Description copied from interface:IAnchor
Provides a read-only (map) property with positions (in local coordinates of the anchoredNode
s) for all attachedAnchorKey
s. The positions will be updated for all attachedAnchorKey
s if the attachedNode
s or the anchorageNode
, theIAnchor
is bound to, or any of their ancestors changes in a way that will effect the positions (within the local coordinate space of the attachedNode
s).- Specified by:
positionsUnmodifiableProperty
in interfaceIAnchor
- Returns:
- A read-only (map) property storing positions for all attached
AnchorKey
s. - See Also:
-
registerVCL
Registers aVisualChangeListener
for the given anchoredNode
.- Parameters:
anchored
- The anchoredNode
to register aVisualChangeListener
at.
-
registerVCLs
protected void registerVCLs()RegistersVisualChangeListener
s for all anchoredNode
s, or schedules their registration if the VCL cannot be registered yet. -
setAnchorage
Sets the anchorage of thisAbstractAnchor
to the given value.- Parameters:
anchorage
- The new anchorage for thisAbstractAnchor
.
-
unregisterVCL
Unregisters theVisualChangeListener
s for the given anchoredNode
.- Parameters:
anchored
- The anchored Node to unregister aVisualChangeListener
from.
-
unregisterVCLs
protected void unregisterVCLs()Unregisters theVisualChangeListener
s for all anchoredNode
s. -
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
- TheAnchorKey
for which the position is updated.
-
updatePositions
protected void updatePositions()Updates the positions for all attachedAnchorKey
s.
-