Package org.eclipse.gef.fx.listeners
Class VisualChangeListener
java.lang.Object
org.eclipse.gef.fx.listeners.VisualChangeListener
You can use a VisualChangeListener to register/unregister specific listeners
for catching changes in the visual representation of a JavaFX
Node
.
Depending on the changed property, either the
boundsInLocalChanged(Bounds, Bounds)
or the
localToParentTransformChanged(Node, Transform, Transform)
method is
called. A bounds-in-local change occurs when the target node's effect, clip,
stroke, local transformations, or geometric bounds change. A
local-to-parent-transform change occurs when the node undergoes a
transformation change. Transformation listeners are registered for all nodes
in the hierarchy up to a specific parent.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
boundsInLocalChanged
(Bounds oldBounds, Bounds newBounds) This method is called upon a bounds-in-local change.boolean
protected abstract void
localToParentTransformChanged
(Node observed, Transform oldTransform, Transform newTransform) This method is called upon a local-to-parent-transform change.protected void
Called upon changes to the "bounds-in-local" or any of the local-to-parent-transform up to the common ancestor of observer and observedNode
.void
Registers this listener on the given pair of observed and observer nodes to recognize visual changes of the observed node relative to the common parent of observer and observed node.void
Unregisters all previously registered listeners.
-
Constructor Details
-
VisualChangeListener
public VisualChangeListener()
-
-
Method Details
-
boundsInLocalChanged
This method is called upon a bounds-in-local change. -
isRegistered
public boolean isRegistered()- Returns:
true
if thisVisualChangeListener
is currently registered, otherwisefalse
.
-
localToParentTransformChanged
protected abstract void localToParentTransformChanged(Node observed, Transform oldTransform, Transform newTransform) This method is called upon a local-to-parent-transform change. -
onBoundsChanged
protected void onBoundsChanged()Called upon changes to the "bounds-in-local" or any of the local-to-parent-transform up to the common ancestor of observer and observedNode
. -
register
Registers this listener on the given pair of observed and observer nodes to recognize visual changes of the observed node relative to the common parent of observer and observed node.In detail, two kind of changes will be reported as visual changes:
- changes to the bounds-in-local property of the observed node (
boundsInLocalChanged(Bounds, Bounds)
) itself - changes to the local-to-parent-transform property of any node in the
observed node hierarchy up to (but excluding) the common parent of the
observed and observer nodes (
localToParentTransformChanged(Node, Transform, Transform)
).
The use of a visual change lister allows to react to relative transform changes only. If the common parent of both nodes is for instance nested below an
InfiniteCanvas
, this allows to ignore transform changes that result from scrolling, as these will (in most cases) not indicate a visual change.- Parameters:
observed
- The observedNode
to be observed for visual changes, which includes bounds-in-local changes for the source node itself, as well as local-to-parent-transform changes for all ancestor nodes (including the source node) up to (but excluding) the common parent node of source and target.observer
- ANode
in the sameScene
as the given observed node, relative to which transform changes will be reported. That is, local-to-parent-transform changes will only be reported for all nodes in the hierarchy up to (but excluding) the common parent of observed and observer.
- changes to the bounds-in-local property of the observed node (
-
unregister
public void unregister()Unregisters all previously registered listeners.
-