public abstract class AbstractFXAnchor extends java.lang.Object implements IFXAnchor
AbstractFXAnchor
is the abstract base implementation for
IFXAnchor
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 (
positionProperty()
) 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, IAdaptable)
and
detach(AnchorKey, IAdaptable)
, and may overwrite both methods to get
access to it.
Type | Property and Description |
---|---|
javafx.beans.property.ReadOnlyObjectProperty<javafx.scene.Node> |
anchorage
Provides a read-only property with the anchorage
Node this
IFXAnchor is bound to. |
javafx.beans.property.ReadOnlyMapProperty<AnchorKey,Point> |
position
Provides a read-only (map) property with positions (in local coordinates
of the anchored
Node s) for all attached AnchorKey s. |
Constructor and Description |
---|
AbstractFXAnchor(javafx.scene.Node anchorage)
Creates a new
AbstractFXAnchor for the given anchorage
Node . |
Modifier and Type | Method and Description |
---|---|
javafx.beans.property.ReadOnlyObjectProperty<javafx.scene.Node> |
anchorageProperty()
Provides a read-only property with the anchorage
Node this
IFXAnchor is bound to. |
void |
attach(AnchorKey key,
IAdaptable info)
|
protected abstract Point |
computePosition(AnchorKey key)
Computes and returns the position for the given
AnchorKey . |
void |
detach(AnchorKey key,
IAdaptable info)
|
javafx.scene.Node |
getAnchorage()
Gets the value of the property anchorage.
|
protected java.util.Map<javafx.scene.Node,java.util.Set<AnchorKey>> |
getKeys()
|
Point |
getPosition(AnchorKey key)
Provides a position for the given
AnchorKey . |
boolean |
isAttached(AnchorKey key)
|
javafx.beans.property.ReadOnlyMapProperty<AnchorKey,Point> |
positionProperty()
Provides a read-only (map) property with positions (in local coordinates
of the anchored
Node s) for all attached AnchorKey s. |
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
AbstractFXAnchor to the given value. |
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. |
public javafx.beans.property.ReadOnlyObjectProperty<javafx.scene.Node> anchorageProperty
anchorageProperty
in interface IFXAnchor
Node
.getAnchorage()
,
setAnchorage(Node)
public javafx.beans.property.ReadOnlyMapProperty<AnchorKey,Point> positionProperty
positionProperty
in interface IFXAnchor
AnchorKey
s.public AbstractFXAnchor(javafx.scene.Node anchorage)
AbstractFXAnchor
for the given anchorage
Node
.anchorage
- The anchorage Node
for this AbstractFXAnchor
.public javafx.beans.property.ReadOnlyObjectProperty<javafx.scene.Node> anchorageProperty()
IFXAnchor
Node
this
IFXAnchor
is bound to. The property value may be
null
in case this IFXAnchor
is not bound to an
anchorage Node
.anchorageProperty
in interface IFXAnchor
Node
.getAnchorage()
,
setAnchorage(Node)
public void attach(AnchorKey key, IAdaptable info)
IFXAnchor
protected abstract Point computePosition(AnchorKey key)
AnchorKey
.public void detach(AnchorKey key, IAdaptable info)
IFXAnchor
public javafx.scene.Node getAnchorage()
getAnchorage
in interface IFXAnchor
IFXAnchor.anchorageProperty()
.protected java.util.Map<javafx.scene.Node,java.util.Set<AnchorKey>> getKeys()
Map
which stores the registered AnchorKey
s
per Node
by reference.public Point getPosition(AnchorKey key)
IFXAnchor
AnchorKey
. The provided
AnchorKey
has to be attached to this IFXAnchor
(see
IFXAnchor.attach(AnchorKey, IAdaptable)
).getPosition
in interface IFXAnchor
key
- The AnchorKey
to retrieve a position for. It has to be
attached (IFXAnchor.attach(AnchorKey, IAdaptable)
) to this
IFXAnchor
before.AnchorKey
within local
coordinates of the AnchorKey
's anchored Node
.public boolean isAttached(AnchorKey key)
IFXAnchor
isAttached
in interface IFXAnchor
key
- The AnchorKey
to test.true
if the given key is attached, otherwise
false
.public javafx.beans.property.ReadOnlyMapProperty<AnchorKey,Point> positionProperty()
IFXAnchor
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
IFXAnchor
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).positionProperty
in interface IFXAnchor
AnchorKey
s.protected void registerVCLs()
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)
AbstractFXAnchor
to the given value.anchorage
- The new anchorage for this AbstractFXAnchor
.protected void unregisterVCLs()
VisualChangeListener
s for all anchored
Node
s.protected void updatePosition(AnchorKey key)
AnchorKey
, i.e.
positionProperty()
key
- The AnchorKey
for which the position is updated.Copyright (c) 2014 itemis AG and others. All rights reserved.