Class VisualChangeListener

java.lang.Object
org.eclipse.gef.fx.listeners.VisualChangeListener

public abstract class VisualChangeListener extends Object
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 Details

    • VisualChangeListener

      public VisualChangeListener()
  • Method Details

    • boundsInLocalChanged

      protected abstract void boundsInLocalChanged(Bounds oldBounds, Bounds newBounds)
      This method is called upon a bounds-in-local change.
      Parameters:
      oldBounds - The old Bounds.
      newBounds - The new Bounds.
    • isRegistered

      public boolean isRegistered()
      Returns true if this VisualChangeListener is currently registered, otherwise returns false.
      Returns:
      true if this VisualChangeListener is currently registered, otherwise false.
    • localToParentTransformChanged

      protected abstract void localToParentTransformChanged(Node observed, Transform oldTransform, Transform newTransform)
      This method is called upon a local-to-parent-transform change.
      Parameters:
      observed - The Node whose local-to-parent-transform changed.
      oldTransform - The old Transform.
      newTransform - The new Transform.
    • 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 observed Node.
    • register

      public void register(Node observed, Node observer)
      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:

      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 observed Node 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 - A Node in the same Scene 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.
    • unregister

      public void unregister()
      Unregisters all previously registered listeners.