Class SimpleDrawing

All Implemented Interfaces:
Drawing, Figure, LockableFigure, StyleableFigure, TransformCachingFigure, ViewBoxableDrawing, PropertyBean, StyleableBean, StyleablePropertyBean, TreeNode<Figure>

public class SimpleDrawing extends AbstractViewBoxDrawing implements StyleableFigure, LockableFigure
A simple implementation of Drawing.
  • Constructor Details

    • SimpleDrawing

      public SimpleDrawing(double width, double height)
    • SimpleDrawing

      public SimpleDrawing()
  • Method Details

    • isSuitableChild

      public boolean isSuitableChild(@NonNull Figure newChild)
      Description copied from interface: Figure
      This method returns whether the provided figure is a suitable child for this figure.
      Specified by:
      isSuitableChild in interface Figure
      Specified by:
      isSuitableChild in interface TreeNode<Figure>
      Parameters:
      newChild - The new child figure.
      Returns:
      true if newChild is an acceptable child
    • reshapeInParent

      public void reshapeInParent(@NonNull javafx.scene.transform.Transform transform)
      Description copied from interface: Figure
      Attempts to change the parent bounds of the figure.

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

      This method may also call reshapeInLocal on child figures.

      Specified by:
      reshapeInParent in interface Figure
      Parameters:
      transform - the desired transformation in parent coordinates
    • transformInLocal

      public void transformInLocal(@NonNull javafx.scene.transform.Transform transform)
      Description copied from interface: Figure
      Attempts to transform the figure.

      The figure may choose to only partially change its transformation.

      Specified by:
      transformInLocal in interface Figure
      Parameters:
      transform - the desired transformation in local coordinates
    • transformInParent

      public void transformInParent(@NonNull javafx.scene.transform.Transform transform)
      Description copied from interface: Figure
      Attempts to transform the figure.

      The figure may choose to only partially change its transformation.

      Specified by:
      transformInParent in interface Figure
      Parameters:
      transform - the desired transformation in parent coordinates
    • updateNode

      public void updateNode(@NonNull RenderContext ctx, @NonNull 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
      Overrides:
      updateNode in class AbstractViewBoxDrawing
      Parameters:
      ctx - the render context
      n - the node which was created with Figure.createNode(org.jhotdraw8.draw.render.RenderContext)