Class AbstractPathConnectionWithMarkersFigure

All Implemented Interfaces:
ConnectingFigure, Figure, LineConnectingFigure, NonTransformableFigure, PathIterableFigure, TransformCachingFigure, PropertyBean, StyleableBean, StyleablePropertyBean, TreeNode<Figure>

public abstract class AbstractPathConnectionWithMarkersFigure extends AbstractLineConnectionFigure implements PathIterableFigure
AbstractPathConnectionWithMarkersFigure draws a path from start to end.

A subclass can hardcode the markers, or can implement one or multiple "marker-able" interfaces that allow user-definable markers: MarkerStartableFigure, MarkerEndableFigure, MarkerSegmentableFigure.

Author:
Werner Randelshofer
  • Field Details

  • Constructor Details

    • AbstractPathConnectionWithMarkersFigure

      public AbstractPathConnectionWithMarkersFigure()
    • AbstractPathConnectionWithMarkersFigure

      public AbstractPathConnectionWithMarkersFigure(javafx.geometry.Point2D start, javafx.geometry.Point2D end)
    • AbstractPathConnectionWithMarkersFigure

      public AbstractPathConnectionWithMarkersFigure(double startX, double startY, double endX, double endY)
  • Method Details

    • createHandles

      public void createHandles(HandleType handleType, List<Handle> list)
      Description copied from interface: Figure
      Creates handles of the specified level and adds them to the provided list.
      Specified by:
      createHandles in interface Figure
      Parameters:
      handleType - The desired handle type
      list - The handles.
    • createNode

      public javafx.scene.Node createNode(RenderContext drawingView)
      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:
      drawingView - the renderer which will use the node
      Returns:
      the newly created node
    • getMarkerCenterScaleFactor

      public abstract double getMarkerCenterScaleFactor()
    • getMarkerCenterShape

      public abstract @Nullable ImmutableList<javafx.scene.shape.PathElement> getMarkerCenterShape()
    • getMarkerEndScaleFactor

      public abstract double getMarkerEndScaleFactor()
    • getMarkerEndShape

      public abstract @Nullable ImmutableList<javafx.scene.shape.PathElement> getMarkerEndShape()
    • getMarkerStartScaleFactor

      public abstract double getMarkerStartScaleFactor()
    • getMarkerStartShape

      public abstract @Nullable ImmutableList<javafx.scene.shape.PathElement> getMarkerStartShape()
    • getPathIterator

      public PathIterator getPathIterator(RenderContext ctx, @Nullable AffineTransform tx)
      Specified by:
      getPathIterator in interface PathIterableFigure
    • getStrokeCutEnd

      public abstract double getStrokeCutEnd(RenderContext ctx)
    • getStrokeCutStart

      public abstract double getStrokeCutStart(RenderContext ctx)
    • layout

      public void layout(RenderContext ctx)
      Description copied from interface: Figure
      Updates the layout of this figure, based on the layout of its children and the layout of observed layout subjects.

      If the layout of this figure depends on the layout of other figures, then calling layout on this figure will only result in the correct result, if layout of the other figures has been performed first.

      A figure does not keep track of changes that require layout updates. Use DrawingModel to manage layout updates.

      The default implementation is empty.

      To layout a drawing use Drawing.layoutAll(RenderContext).

      Specified by:
      layout in interface Figure
      Parameters:
      ctx - the render context (optional)
    • transformInLocal

      public void transformInLocal(javafx.scene.transform.Transform tx)
      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
      Specified by:
      transformInLocal in interface NonTransformableFigure
      Parameters:
      tx - the desired transformation in local coordinates
    • translateInLocal

      public void translateInLocal(CssPoint2D t)
      Description copied from interface: Figure
      Attempts to translate the local bounds of the figure.
      Specified by:
      translateInLocal in interface Figure
      Parameters:
      t - the translation in x and in y direction
    • reshapeInLocal

      public void reshapeInLocal(javafx.scene.transform.Transform tx)
      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
      Overrides:
      reshapeInLocal in class AbstractLineConnectionFigure
      Parameters:
      tx - the desired transformation in local coordinates
    • updateEndMarkerNode

      protected void updateEndMarkerNode(RenderContext ctx, javafx.scene.shape.Path node)
      This method can be overridden by a subclass to apply styles to the marker node.

      The implementation of this method in this class is empty. So no call to super is necessary.

      Parameters:
      ctx - the context
      node - the node
    • updateLineNode

      protected void updateLineNode(RenderContext ctx, javafx.scene.shape.Path node)
      This method can be overridden by a subclass to apply styles to the line node.
      Parameters:
      ctx - the context
      node - the node
    • updateMarkerNode

      protected void updateMarkerNode(RenderContext ctx, javafx.scene.Group group, javafx.scene.shape.Path markerNode, PointAndDerivative pd, @Nullable ImmutableList<javafx.scene.shape.PathElement> markerShape, double markerScaleFactor)
    • updateNode

      public void updateNode(RenderContext ctx, javafx.scene.Node node)
      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
      node - the node which was created with Figure.createNode(org.jhotdraw8.draw.render.RenderContext)
    • getPathMetrics

      public PathMetrics getPathMetrics()
    • updateStartMarkerNode

      protected void updateStartMarkerNode(RenderContext ctx, javafx.scene.shape.Path node)
      This method can be overridden by a subclass to apply styles to the marker node.

      The implementation of this method in this class is empty. So no call to super is necessary.

      Parameters:
      ctx - the context
      node - the node