Class VisualChangeListener


  • public abstract class VisualChangeListener
    extends java.lang.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.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract void boundsInLocalChanged​(javafx.geometry.Bounds oldBounds, javafx.geometry.Bounds newBounds)
      This method is called upon a bounds-in-local change.
      boolean isRegistered()
      Returns true if this VisualChangeListener is currently registered, otherwise returns false.
      protected abstract void localToParentTransformChanged​(javafx.scene.Node observed, javafx.scene.transform.Transform oldTransform, javafx.scene.transform.Transform newTransform)
      This method is called upon a local-to-parent-transform change.
      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.
      void register​(javafx.scene.Node observed, javafx.scene.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.
      void unregister()
      Unregisters all previously registered listeners.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • VisualChangeListener

        public VisualChangeListener()
    • Method Detail

      • boundsInLocalChanged

        protected abstract void boundsInLocalChanged​(javafx.geometry.Bounds oldBounds,
                                                     javafx.geometry.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​(javafx.scene.Node observed,
                                                              javafx.scene.transform.Transform oldTransform,
                                                              javafx.scene.transform.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​(javafx.scene.Node observed,
                             javafx.scene.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.