Class ClippingFigure

All Implemented Interfaces:
Clipping, Figure, LockedFigure, NonTransformableFigure, StyleableFigure, TransformCachingFigure, PropertyBean, StyleableBean, StyleablePropertyBean, TreeNode<Figure>

public class ClippingFigure extends AbstractCompositeFigure implements Clipping, StyleableFigure, LockedFigure, NonTransformableFigure
ClippingFigure.
Author:
Werner Randelshofer
  • Constructor Details

    • ClippingFigure

      public ClippingFigure()
    • ClippingFigure

      public ClippingFigure(Collection<Figure> children)
  • Method Details

    • reshapeInLocal

      public void reshapeInLocal(javafx.scene.transform.Transform transform)
      Description copied from interface: Figure
      Attempts to change the local bounds of the figure.

      The figure may choose to only partially change its local bounds.

      Specified by:
      reshapeInLocal in interface Figure
      Specified by:
      reshapeInLocal in interface NonTransformableFigure
      Parameters:
      transform - the desired transformation in local coordinates
    • reshapeInLocal

      public void reshapeInLocal(CssSize x, CssSize y, CssSize width, CssSize height)
      Description copied from interface: Figure
      Attempts to change the local bounds of the figure.

      See {#link #reshapeInLocal(Transform)} for a description of this method.

      This method takes parameters as CssSizes. This can be used to avoid rounding errors when the figure is reshaped in non-pixel units.

      This method can forward a call to Figure.reshapeInLocal(Transform) using the following code:

      
       void reshapeInLocal(CssSize x, CssSize y, CssSize width, CssSize height) {
         Transform tx = Transforms.createReshapeTransform(getCssBoundsInLocal(), x, y, width, height);
         reshapeInLocal(tx);
       }
       
      Specified by:
      reshapeInLocal in interface Figure
      Parameters:
      x - desired x-position in parent coordinates
      y - desired y-position in parent coordinates
      width - desired width in parent coordinates, may be negative
      height - desired height in parent coordinates, may be negative
    • updateNode

      public void updateNode(RenderContext ctx, javafx.scene.Node n)
      Description copied from interface: Figure
      This method is invoked by a RenderContext, when it needs to update the node which represents the scene graph in the figure.

      A figure which is composed from child figures, must addChild the nodes of its getChildren to its node. This ensures that coordinate space transformations of the composed figure are properly propagated to its getChildren.

       public void updateNode(RenderContext rc, Node n) {
           ObservableList<Node> group = ((Group) n).getChildren();
       group.clear();
       for (Figure child : children()) {
       group.addChild(rc.getNode(child));
       }
       

      A figure may be shown in multiple RenderContexts. Each RenderContext uses this method to update the a JavaFX node for the figure.

      Note that the figure must retrieve the JavaFX node from other figures from the render context by invoking rc.getNode(child) rather than creating new nodes using child.createNode(rc). This convention allows to implement a cache in the render context for the Java FX node. Also, render contexts like a drawing view need to associate input events on Java FX nodes to the corresponding figure.

      This figure does not keep track of changes that require node updates. DrawingModel to manage node updates.

      Specified by:
      updateNode in interface Figure
      Parameters:
      ctx - the render context
      n - the node which was created with Figure.createNode(org.jhotdraw8.draw.render.RenderContext)
    • createNode

      public javafx.scene.Node createNode(RenderContext ctx)
      Description copied from interface: Figure
      This method is invoked by a RenderContext, when it needs a node to create a JavaFX scene graph for a figure.

      A typical implementation should look like this:

      
       public Node createNode(RenderContext v) {
       return new ...desired subclass of Node...();
       }
       

      A figure may be rendered with multiple RenderContexts simultaneously. Each RenderContext uses this method to instantiate a JavaFX node for the figure and associate it to the figure.

      This method must create a new instance because returning an already existing instance may cause undesired side effects on other RenderContexts.

      Note that by convention this method may only be invoked by a RenderContext object.

      Specified by:
      createNode in interface Figure
      Parameters:
      ctx - the renderer which will use the node
      Returns:
      the newly created node
    • isSelectable

      public boolean isSelectable()
      Layer figures always return false for isSelectable.
      Specified by:
      isSelectable in interface Clipping
      Specified by:
      isSelectable in interface Figure
      Specified by:
      isSelectable in interface LockedFigure
      Returns:
      false
    • isSuitableParent

      public boolean isSuitableParent(Figure newParent)
      This method returns false for all new parents.
      Specified by:
      isSuitableParent in interface Figure
      Specified by:
      isSuitableParent in interface TreeNode<Figure>
      Parameters:
      newParent - The new parent figure.
      Returns:
      false
    • isSuitableChild

      public boolean isSuitableChild(Figure newChild)
      This method returns true for all children.
      Specified by:
      isSuitableChild in interface Figure
      Specified by:
      isSuitableChild in interface TreeNode<Figure>
      Parameters:
      newChild - The new child figure.
      Returns:
      true
    • createHandles

      public void createHandles(HandleType handleType, List<Handle> list)
      Layers never create handles.
      Specified by:
      createHandles in interface Figure
      Parameters:
      handleType - The desired handle type
      list - The handles.
    • getBoundsInLocal

      public javafx.geometry.Bounds getBoundsInLocal()
      Description copied from interface: Figure
      The bounds of this figure in local coordinates, including space required for a non-zero stroke.
      Specified by:
      getBoundsInLocal in interface Figure
      Overrides:
      getBoundsInLocal in class AbstractCompositeFigure
      Returns:
      the local bounds