Interface Figure

All Superinterfaces:
PropertyBean, StyleableBean, StyleablePropertyBean, TreeNode<Figure>
All Known Subinterfaces:
AnchorableFigure, ChildLayoutingFigure, Clipping, CompositableFigure, ConnectableFigure, ConnectingFigure, DefaultableFigure, Drawing, ElbowableLineFigure, FillableFigure, FillRulableFigure, Grouping, HideableFigure, ImageableFigure, LabelConnectionFigure, Layer, LayeredDrawing, LineConnectingFigure, LockableFigure, LockedFigure, MarkerEndableFigure, MarkerFillableFigure, MarkerMidableFigure, MarkerSegmentableFigure, MarkerStartableFigure, MarkerStrokableFigure, NonTransformableFigure, PaddableFigure, Page, PathIterableFigure, PatternStrokableFigure, RectangularFigure, ResizableFigure, SecondStrokableFigure, SecondStrokeCuttableFigure, ShapeableFigure, Slice, StrokableFigure, StrokeCuttableFigure, StyleableFigure, TextableFigure, TextEditableFigure, TextFillableFigure, TextFontableFigure, TextLayoutableFigure, TextStrokeableFigure, TransformableFigure, TransformCachingFigure, ViewBoxableDrawing
All Known Implementing Classes:
AbstractCompositeFigure, AbstractDrawing, AbstractElbowLineConnectionWithMarkersFigure, AbstractFigure, AbstractLabelConnectionFigure, AbstractLabelFigure, AbstractLeafFigure, AbstractLineConnectionFigure, AbstractPathConnectionWithMarkersFigure, AbstractRegionFigure, AbstractStraightLineConnectionWithMarkersFigure, AbstractViewBoxDrawing, ArcFigure, BezierPathFigure, ClippingFigure, CombinedPathFigure, EllipseFigure, GroupFigure, ImageFigure, LabelFigure, LayerFigure, LineConnectionFigure, LineConnectionWithMarkersFigure, LineFigure, PageFigure, PageLabelFigure, PolygonFigure, PolylineFigure, RectangleFigure, RegionFigure, SimpleDrawing, SimpleLabelConnectionFigure, SimpleLayeredDrawing, SliceFigure, TextAreaFigure, TextFigure

public interface Figure extends StyleablePropertyBean, TreeNode<Figure>
A figure is a graphical (figurative) element of a Drawing.

Rendering. A figure can render a JavaFX scene graph (see Node) with the help of a RenderContext. The contents of the scene graph depends on the class of the figure, the state of the figure, and the state of the render context.

State. The state of a figure is defined by its property values. The state consists of genuine property values and of computed property values.
Genuine property values typically describe the shape and the style of a figure.
Computed property values typically describe the layout of the figure or cached values. Such as cached CSS properties and cached transformation matrices. Computed property values often depend on the state of other figures.

Tree Structure. A figure can be composed of other figures in a tree structure. The composition is implemented with the children property and the parent property.
The composition can be restricted. Typically the parent of Layer objects is restricted to instances of Drawing, and the parent of all other figures is restricted to non-instances of Drawing.

Local Coordinate Systems. A figure may introduce a local coordinate system which affects the graphical representation of itself and of its descendants.
The Figure interface provides methods which allow to transform between the local coordinate system of a figure, the coordinate system of its parent, and the world coordinate system.

Dependent Figures. The state of a figure may depend on the state of other figures. These dependencies are made explicit by parent/child relationships and provider/dependant relationships.
The parent/child relationships are strictly hierarchical, the provider/dependant relationships may include cycles.
The parent/child relationships are typically used for grouping figures into Layers, Groups and into layout hierarchies.
The provider/dependant relationships are typically used for the creation of line connections between figures, such as with LineConnectionFigure. The strategy for updating the state of dependent figures is implement in DrawingModel.

Handles. A figure can produce Handles which allow to graphically change the state of the figure in a drawing view.

Map Accessors. A figure has an open ended set of property values. The property values are accessed using FigureMapAccessors.

Styling. Some property values of a figure can be styled using CSS. The corresponding property key must implement the interface WritableStyleableMapAccessor.

Update Strategy. A figure does not automatically update its computed property values. The update strategy is factored out into DrawingModel.

Author:
Werner Randelshofer
  • Property Details

    • parent

      @NonNull javafx.beans.property.ObjectProperty<Figure> parentProperty
      The parent figure.

      If this figure has not been added as a child to another figure, then this variable will be null.

      By convention the parent is set exclusively by a composite figure on its child figures. The composite figure sets parent to itself on a child immediately after the child figure has been added to the composite figure. The composite figure sets parent to null on a child immediately after the child figure has been removed from the composite figure.
      See Also:
  • Field Details

    • JHOTDRAW_CSS_PREFIX

      static final String JHOTDRAW_CSS_PREFIX
      To avoid name clashes in the stylesheet, all styleable JHotDraw getProperties use the prefix "-jhotdraw-".

      XXX mapping of css attribute names to keys should be done elsewhere!

      See Also:
    • PARENT_PROPERTY

      static final String PARENT_PROPERTY
      The name of the parent property.
      See Also:
    • declaredAndInheritedKeys

      static final Map<Class<?>,ImmutableSet<MapAccessor<?>>> declaredAndInheritedKeys
      FIXME should be private!
  • Method Details

    • bounds

      static @NonNull javafx.geometry.Bounds bounds(@NonNull Collection<? extends Figure> selection)
      Computes the union of the bounds of the provided figures in world coordinates.
      Parameters:
      selection - a set of figures
      Returns:
      bounds
    • getDeclaredMapAccessors

      static ImmutableSet<MapAccessor<?>> getDeclaredMapAccessors(@NonNull Class<?> clazz, @NonNull ImmutableSet<MapAccessor<?>> keys)
    • getDeclaredKeys

      static void getDeclaredKeys(@NonNull Class<?> clazz, @NonNull Collection<Key<?>> keys)
    • getDeclaredAndInheritedMapAccessors

      static ImmutableSet<MapAccessor<?>> getDeclaredAndInheritedMapAccessors(Class<?> clazz)
      Returns all keys declared in this class and inherited from parent classes.
      Parameters:
      clazz - A figure class.
      Returns:
      an unmodifiable set of the keys
    • visualBounds

      static @Nullable javafx.geometry.Bounds visualBounds(@NonNull Collection<Figure> selection)
      Computes the union of the visual bounds of the provided figures in world coordinates.
      Parameters:
      selection - a set of figures
      Returns:
      bounds
    • addChild

      default boolean addChild(@NonNull Figure newChild)
      Adds a new child to the figure if it is a suitable child and this figure is a suitable parent.
      Parameters:
      newChild - the new child
      Returns:
      whether the child was added
    • addedToDrawing

      default void addedToDrawing(@NonNull Drawing drawing)
      Invoked by DrawingModel when the figure was added to a drawing.
      Parameters:
      drawing - the drawing to which this figure has been added
    • createHandles

      default void createHandles(@NonNull HandleType handleType, @NonNull List<Handle> list)
      Creates handles of the specified level and adds them to the provided list.
      Parameters:
      handleType - The desired handle type
      list - The handles.
    • createNode

      @NonNull javafx.scene.Node createNode(@NonNull RenderContext ctx)
      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(@NonNull 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.

      Parameters:
      ctx - the renderer which will use the node
      Returns:
      the newly created node
    • layoutSubjectChanged

      default void layoutSubjectChanged()
      This method is invoked on a figure by DrawingModel when it determines that one or more layout subjects have been added or removed.

      The default implementation of this method is empty.

    • propertyChanged

      default <T> void propertyChanged(Key<T> key, @Nullable T oldValue, @Nullable T newValue)
      This method is invoked on a figure by DrawingModel when it determines that a property has been changed.

      The default implementation of this method is empty.

      Type Parameters:
      T - the value type
      Parameters:
      key - the key
      oldValue - the old value
      newValue - the new value
    • layoutObserverChanged

      default void layoutObserverChanged()
      This method is invoked on a figure by DrawingModel when it determines that one or more layout observers have been added or removed.

      The default implementation of this method is empty.

    • disconnect

      default void disconnect()
      Disconnects all layout subjects and layout observers from this figure.

      This method is called, when the figure is about to be removed from a drawing.

    • firePropertyChangeEvent

      default <T> void firePropertyChangeEvent(Figure source, Key<T> key, @Nullable T oldValue, @Nullable T newValue, boolean wasAdded, boolean wasRemoved)
      Fires a property change event.
      Type Parameters:
      T - the value type
      Parameters:
      source - the event source
      key - the property key
      oldValue - the old property value
      newValue - the new property value
      wasAdded - true if the new property value was added
      wasRemoved - true if the old property value was removed
    • firePropertyChangeEvent

      default void firePropertyChangeEvent(FigurePropertyChangeEvent event)
      Fires a property change event.
      Parameters:
      event - the event
    • getLayoutBounds

      default @NonNull javafx.geometry.Bounds getLayoutBounds()
      The bounds that should be used for transformations of this figure.

      The bounds are given in the untransformed local coordinate space of the figure.

      This method may use caching and return incorrect results if the cache is stale. Invoke layout(org.jhotdraw8.draw.render.RenderContext) if you are not sure that the cache is valid.

      Returns:
      the local bounds
    • getVisualBounds

      default @NonNull javafx.geometry.Bounds getVisualBounds()
      The bounds that should be used for clipping and intersection tests of this figure.
      Returns:
      the visual bounds
    • getBoundsInLocal

      @NonNull javafx.geometry.Bounds getBoundsInLocal()
      The bounds of this figure in local coordinates, including space required for a non-zero stroke.
      Returns:
      the local bounds
    • getCssLayoutBounds

      @NonNull CssRectangle2D getCssLayoutBounds()
    • getLayoutBoundsInParent

      default @NonNull javafx.geometry.Bounds getLayoutBoundsInParent()
      The layout bounds of this figure in parent coordinates.

      The bounds are given in the coordinate space of the parent figure.

      This method may use caching and return incorrect results if the caches are stale. Invoke invalidateTransforms() and layout(org.jhotdraw8.draw.render.RenderContext) if you are not sure that the cache is valid.

      Returns:
      the local bounds
    • getBoundsInParent

      default @NonNull javafx.geometry.Bounds getBoundsInParent()
      The bounds of this figure in parent coordinates including space required for a non-zero stroke.

      The bounds are given in the coordinate space of the parent figure.

      This method may use caching and return incorrect results if the caches are stale. Invoke invalidateTransforms() and layout(org.jhotdraw8.draw.render.RenderContext) if you are not sure that the cache is valid.

      Returns:
      the bounds in parent coordinates
    • getBoundsInWorld

      default @NonNull javafx.geometry.Bounds getBoundsInWorld()
      The bounds of this figure in world coordinates including space required for a non-zero stroke.

      The bounds are given in the coordinate space of the world.

      This method may use caching and return incorrect results if the caches are stale. Invoke invalidateTransforms() and layout(org.jhotdraw8.draw.render.RenderContext) if you are not sure that the cache is valid.

      Returns:
      the bounds in world coordinates
    • getLayoutBoundsInWorld

      default @NonNull javafx.geometry.Bounds getLayoutBoundsInWorld()
      Returns the layout bounds of the figure in world coordinates, including space required for non-zero strokkes.
      Returns:
      the bounds in world coordinates
    • getVisualBoundsInWorld

      default @NonNull javafx.geometry.Bounds getVisualBoundsInWorld()
      Returns the visal bounds of the figure in world coordinates, including space required for non-zero strokkes.
      Returns:
      the bounds in world coordinates
    • getCenterInLocal

      default @NonNull javafx.geometry.Point2D getCenterInLocal()
      Returns the center of the figure in the local coordinates of the figure.
      Returns:
      The center of the figure
    • getCenterInParent

      default @NonNull javafx.geometry.Point2D getCenterInParent()
      Returns the center of the figure in the local coordinates of the figure.
      Returns:
      The center of the figure
    • getChildren

      @NonNull javafx.collections.ObservableList<Figure> getChildren()
      The child figures.

      All changes on this list causes this figure to fire an invalidation event.

      If a child is added to this list, then this figure removes the child from its former parent, and then sets itself as the parent of the child.

      If a child is removed from this list, then this figure sets the parent of the child to null.

      Specified by:
      getChildren in interface TreeNode<Figure>
      Returns:
      the children
    • getLayoutObservers

      @NonNull Set<Figure> getLayoutObservers()
      Returns all figures which observe the layout of this figure.

      When the layout of this figure changes, then the layout of the observers figures must be updated.

      The update strategy is implemented in DrawingModel. DrawingMode observes state changes in figures and updates dependent figures. DrawingModel can coalesce multiple state changes of an observed figure into a smaller number of layout calls on the observers. DrawingModel can also detect cyclic layout dependencies and prevent endless update loops.

      This set must be synchronized, because it is accessed by other figures, when there properties are changed.

      Returns:
      a list of dependent figures
    • getReadOnlyLayoutObservers

      @NonNull ReadOnlySet<Figure> getReadOnlyLayoutObservers()
    • getDrawing

      default @Nullable Drawing getDrawing()
      Returns the ancestor Drawing.
      Returns:
      the drawing or null if no ancestor is a drawing. Returns this, if this figure is a drawing.
    • getLayer

      default @Nullable Layer getLayer()
      Returns the ancestor Layer.
      Returns:
      the drawing or null if no ancestor is a layer. Returns this, if this figure is a layer.
    • getLocalToParent

      @NonNull javafx.scene.transform.Transform getLocalToParent()
      Returns the transformation from local coordinates into parent coordinates.

      This method may use caching and return incorrect results if the cache is stale.

      Returns:
      the transformation
    • getLocalToWorld

      @NonNull javafx.scene.transform.Transform getLocalToWorld()
      Returns the transformation from local coordinates into world coordinates.

      This method may use caching and return incorrect results if the cache is stale.

      Returns:
      the transformation
    • getParent

      default @Nullable Figure getParent()
      Gets the value of the parent property.
      Specified by:
      getParent in interface TreeNode<Figure>
      Property description:
      The parent figure.

      If this figure has not been added as a child to another figure, then this variable will be null.

      By convention the parent is set exclusively by a composite figure on its child figures. The composite figure sets parent to itself on a child immediately after the child figure has been added to the composite figure. The composite figure sets parent to null on a child immediately after the child figure has been removed from the composite figure.
      Returns:
      the value of the parent property
      See Also:
    • setParent

      default void setParent(@Nullable Figure newValue)
      Sets the value of the parent property.
      Specified by:
      setParent in interface TreeNode<Figure>
      Property description:
      The parent figure.

      If this figure has not been added as a child to another figure, then this variable will be null.

      By convention the parent is set exclusively by a composite figure on its child figures. The composite figure sets parent to itself on a child immediately after the child figure has been added to the composite figure. The composite figure sets parent to null on a child immediately after the child figure has been removed from the composite figure.
      Parameters:
      newValue - the value for the parent property
      See Also:
    • getParentToLocal

      @NonNull javafx.scene.transform.Transform getParentToLocal()
      Returns the transformation from parent coordinates into local coordinates.

      This method may use caching and return incorrect results if the cache is stale.

      Returns:
      the transformation
    • getParentToWorld

      @NonNull javafx.scene.transform.Transform getParentToWorld()
      Returns the transformation from world coordinates into drawing coordinates.

      This method may use caching and return incorrect results if the cache is stale.

      Returns:
      the transformation
    • getPreferredAspectRatio

      default double getPreferredAspectRatio()
      Returns the preferred aspect ratio of the figure. The aspect ratio is defined as the height divided by the width of the figure. If a figure does not have a preference it should return its current aspect ratio.
      Returns:
      the preferred aspect ratio of the figure.
    • getPropertyChangeListeners

      CopyOnWriteArrayList<org.jhotdraw8.base.event.Listener<FigurePropertyChangeEvent>> getPropertyChangeListeners()
      List of property change listeners.
      Returns:
      a list of property change listeners
    • getLayoutSubjects

      default @NonNull ReadOnlySet<Figure> getLayoutSubjects()
      Returns all figures which are subject to the layout of this figure.

      When the layout of a layout subject changes, then the layout of this figure needs to be updated.

      See getLayoutObservers() for a description of the update strategy.

      This default implementation returns an unmodifiable empty set.

      Returns:
      a list of layout subjects
    • getRoot

      default @Nullable Figure getRoot()
      Returns the root.
      Returns:
      the root
    • getStyleableParent

      default @Nullable StyleableBean getStyleableParent()
      Specified by:
      getStyleableParent in interface StyleableBean
    • getSupportedKeys

      default @NonNull ImmutableSet<MapAccessor<?>> getSupportedKeys()
      Returns all supported map accessors of the figure.

      The default implementation returns all declared and inherited map accessors.

      Returns:
      an unmodifiable set of keys
    • getWorldToLocal

      @NonNull javafx.scene.transform.Transform getWorldToLocal()
      Returns the transformation from world coordinates into local coordinates.

      This method may use caching and return incorrect results if the cache is stale.

      Returns:
      the transformation
    • getWorldToParent

      @NonNull javafx.scene.transform.Transform getWorldToParent()
      Returns the transformation from world coordinates into parent coordinates.

      This method may use caching and return incorrect results if the cache is stale.

      Returns:
      the transformation
    • hasPropertyChangeListeners

      boolean hasPropertyChangeListeners()
      Whether this figure has property change listeners.
      Returns:
      true if this figure has property change listeners
    • invalidateTransforms

      void invalidateTransforms()
      Invalidates the transformation matrices of this figure.

      This figure does not keep track of changes that cause the invalidation of its transformation matrices. Use a DrawingModel to manage the transformation matrices of the figures in a drawing. Or call this method on a figure and all its descendants, after you have performed a change which invalidated the transform matrices of the figure.

    • isAllowsChildren

      boolean isAllowsChildren()
      Whether children may be added to this figure.
      Returns:
      true if getChildren are allowed
    • isDecomposable

      default boolean isDecomposable()
      Whether the figure is decomposable by the user.
      Returns:
      true if the figure is decomposable
    • isDeletable

      boolean isDeletable()
      Whether the figure is deletable by the user.
      Returns:
      true if the user may delete the figure
    • isEditable

      boolean isEditable()
      Whether the figure is editable by the user.
      Returns:
      true if the user may edit the figure.
    • isGroupReshapeableWith

      default boolean isGroupReshapeableWith(@NonNull Set<Figure> others)
      Whether the figure can be reshaped as a group together with other figures.

      If this figure uses one of the other figures for computing its position or its layout, then it will return false.

      The default implementation always returns true.

      Parameters:
      others - A set of figures.
      Returns:
      true if the user may svgStringReshapeToBuilder this figure together with those in the set.
    • isLayoutable

      default boolean isLayoutable()
      Whether the layout method of this figure does anything.

      The default implementation returns false.

      Returns:
      true if the layout method is not empty.
    • isSelectable

      boolean isSelectable()
      Whether the figure is selectable by the user.
      Returns:
      true if the user may select the figure
    • isSuitableParent

      boolean isSuitableParent(@NonNull Figure newParent)
      This method returns whether the provided figure is a suitable parent for this figure.
      Specified by:
      isSuitableParent in interface TreeNode<Figure>
      Parameters:
      newParent - The new parent figure.
      Returns:
      true if newParent is an acceptable parent
    • isSuitableChild

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

      default boolean isSupportedKey(MapAccessor<?> key)
      Returns true if the specified key is supported by this figure.

      The default implementation returns all declared and inherited map accessors.

      Parameters:
      key - a key
      Returns:
      whether the key is supported
    • isEditableKey

      default boolean isEditableKey(MapAccessor<?> key)
      Returns true if the specified key is user editable.
      Parameters:
      key - a key
      Returns:
      whether the key is user edtiable
    • isShowing

      default boolean isShowing()
      Whether the figure and all its ancestors are visible.
      Returns:
      true if the user can see the figure
    • isVisible

      default boolean isVisible()
      Whether the figure is visible.
      Returns:
      true if the user can see the figure
    • layout

      default void layout(@NonNull RenderContext ctx)
      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).

      Parameters:
      ctx - the render context (optional)
    • layoutChanged

      default void layoutChanged(@NonNull RenderContext ctx)
      This method is invoked on a figure by DrawingModel when it determines that the figure needs to be laid out.

      The default implementation of this method calls layout(org.jhotdraw8.draw.render.RenderContext).

      Parameters:
      ctx - the render context (optional)
    • localToWorld

      default @NonNull javafx.geometry.Point2D localToWorld(@NonNull javafx.geometry.Point2D p)
      Transforms the specified point from local coordinates into world coordinates.

      This method may use caching and return incorrect results if the cache is stale.

      Parameters:
      p - point in local coordinates
      Returns:
      point in world coordinates
    • localToParent

      default @NonNull javafx.geometry.Bounds localToParent(@NonNull javafx.geometry.Bounds p)
      Transforms the specified bounds from local coordinates into parent coordinates.

      This method may use caching and return incorrect results if the cache is stale.

      Parameters:
      p - bounds in local coordinates
      Returns:
      bounds in parent coordinates
    • localToWorld

      default @NonNull javafx.geometry.Bounds localToWorld(@NonNull javafx.geometry.Bounds p)
      Transforms the specified bounds from local coordinates into world coordinates.

      This method may use caching and return incorrect results if the cache is stale.

      Parameters:
      p - bounds in local coordinates
      Returns:
      bounds in world coordinates
    • parentProperty

      @NonNull javafx.beans.property.ObjectProperty<Figure> parentProperty()
      The parent figure.

      If this figure has not been added as a child to another figure, then this variable will be null.

      By convention the parent is set exclusively by a composite figure on its child figures. The composite figure sets parent to itself on a child immediately after the child figure has been added to the composite figure. The composite figure sets parent to null on a child immediately after the child figure has been removed from the composite figure.
      Returns:
      the parent property, with getBean() returning this figure, and getName() returning PARENT_PROPERTY.
      See Also:
    • removeChild

      default void removeChild(Figure child)
      Removes a child from the figure.
      Parameters:
      child - a child of the figure
    • removeAllLayoutSubjects

      void removeAllLayoutSubjects()
      Requests to removeChild all connection targets.
    • removeLayoutSubject

      void removeLayoutSubject(Figure targetFigure)
      Removes the specified connection target.
      Parameters:
      targetFigure - a Figure which is a connection target.
    • removedFromDrawing

      default void removedFromDrawing(Drawing drawing)
      Invoked by DrawingModel when the figure is removed from a drawing.
      Parameters:
      drawing - the drawing from which this figure has been removed
    • reshapeInLocal

      void reshapeInLocal(javafx.scene.transform.Transform transform)
      Attempts to change the local bounds of the figure.

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

      Parameters:
      transform - the desired transformation in local coordinates
    • reshapeInLocal

      default void reshapeInLocal(@NonNull javafx.geometry.Bounds bounds)
      Attempts to change the local bounds of the figure.

      See reshapeInLocal(CssSize, CssSize, CssSize, CssSize) for a description of this method.

      Parameters:
      bounds - the desired bounds
    • reshapeInLocal

      default void reshapeInLocal(double x, double y, double width, double height)
      Attempts to change the local bounds of the figure.

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

      This is a convenience method which takes all parameters in pixel units.

      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
    • reshapeInLocal

      void reshapeInLocal(@NonNull CssSize x, @NonNull CssSize y, @NonNull CssSize width, @NonNull CssSize height)
      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 reshapeInLocal(Transform) using the following code:

      
       void reshapeInLocal(@NonNull CssSize x, @NonNull CssSize y, @NonNull CssSize width, @NonNull CssSize height) {
         Transform tx = Transforms.createReshapeTransform(getCssBoundsInLocal(), x, y, width, height);
         reshapeInLocal(tx);
       }
       
      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
    • reshapeInParent

      void reshapeInParent(@NonNull javafx.scene.transform.Transform transform)
      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.

      Parameters:
      transform - the desired transformation in parent coordinates
    • translateInParent

      default void translateInParent(@NonNull CssPoint2D t)
      Attempts to translate the parent bounds of the figure.
      Parameters:
      t - the translation in x and in y direction
    • translateInLocal

      default void translateInLocal(@NonNull CssPoint2D t)
      Attempts to translate the local bounds of the figure.
      Parameters:
      t - the translation in x and in y direction
    • stylesheetChanged

      default void stylesheetChanged(@NonNull RenderContext ctx)
      This method is invoked on a figure by DrawingModel when it determines that the figure needs to apply its stylesheet again.

      The default implementation of this method calls updateCss(org.jhotdraw8.draw.render.RenderContext).

      Parameters:
      ctx - the render context (optional)
    • transformInLocal

      void transformInLocal(@NonNull javafx.scene.transform.Transform transform)
      Attempts to transform the figure.

      The figure may choose to only partially change its transformation.

      Parameters:
      transform - the desired transformation in local coordinates
    • transformInParent

      void transformInParent(@NonNull javafx.scene.transform.Transform transform)
      Attempts to transform the figure.

      The figure may choose to only partially change its transformation.

      Parameters:
      transform - the desired transformation in parent coordinates
    • transformChanged

      default void transformChanged()
      This method is invoked on a figure and all its descendants by DrawingModel when it determines that the transformation of the figure has changed.

      The default implementation of this method calls invalidateTransforms().

    • updateCss

      void updateCss(@NonNull RenderContext ctx)
      Updates the stylesheet cache of this figure depending on its property values and on the and the property values of its ancestors.

      This figure does not keep track of changes that require CSS updates. Use a DrawingModel to manage CSS updates.

      Parameters:
      ctx - the render context
    • updateNode

      void updateNode(@NonNull RenderContext ctx, @NonNull javafx.scene.Node node)
      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(@NonNull 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.

      Parameters:
      ctx - the render context
      node - the node which was created with createNode(org.jhotdraw8.draw.render.RenderContext)
    • worldToLocal

      default @NonNull javafx.geometry.Point2D worldToLocal(@NonNull javafx.geometry.Point2D pointInWorld)
      Transforms the specified point from world coordinates into local coordinates.

      This method may use caching and return incorrect results if the cache is stale.

      Parameters:
      pointInWorld - point in drawing coordinates
      Returns:
      point in local coordinates
    • worldToLocal

      default @NonNull CssPoint2D worldToLocal(@NonNull CssPoint2D pointInWorld)
    • worldToParent

      default @NonNull javafx.geometry.Point2D worldToParent(@NonNull javafx.geometry.Point2D pointInWorld)
      Transforms the specified point from world coordinates into parent coordinates.

      This method may use caching and return incorrect results if the cache is stale.

      Parameters:
      pointInWorld - point in drawing coordinates
      Returns:
      point in local coordinates
    • worldToParent

      default @NonNull javafx.geometry.Point2D worldToParent(double x, double y)
    • isDeletWithLastLayoutSubject

      default boolean isDeletWithLastLayoutSubject()
      Returns true if this figure should be deleted if its last layout subject is deleted.
      Returns:
      if the deletion of the layout subject should lead to a cascaded delete