Class SimpleDrawingModel

All Implemented Interfaces:
javafx.beans.Observable, DrawingModel, ObservableMixin, TreeModel<Figure>

public class SimpleDrawingModel extends AbstractDrawingModel
A DrawingModel for drawings which can handle TransformableFigures, ChildLayoutingFigure and layout observing figures, like LineConnectionFigure.
Author:
Werner Randelshofer
  • Property Details

  • Constructor Details

    • SimpleDrawingModel

      public SimpleDrawingModel()
    • SimpleDrawingModel

      public SimpleDrawingModel(boolean listenOnDrawing)
  • Method Details

    • drawingProperty

      public @NonNull javafx.beans.property.ObjectProperty<Drawing> drawingProperty()
      Description copied from interface: DrawingModel
      The root of the drawing model.
      Returns:
      the drawing property
      See Also:
    • rootProperty

      public @NonNull javafx.beans.property.ObjectProperty<Figure> rootProperty()
      Returns:
      the root property
    • removeFromParent

      public void removeFromParent(@NonNull Figure child)
      Description copied from interface: DrawingModel
      Removes the specified child from its parent and fires appropriate DrawingModelEvents.
      Parameters:
      child - the figure
    • removeFromParent

      public Figure removeFromParent(@NonNull Figure parent, int index)
      Description copied from interface: DrawingModel
      Removes the specified child from its parent and fires appropriate DrawingModelEvents.
      Parameters:
      parent - the parent figure
      index - the index
    • insertChildAt

      public void insertChildAt(@NonNull Figure child, @NonNull Figure parent, int index)
      Description copied from interface: DrawingModel
      Adds the specified child to a parent and fires appropriate DrawingModelEvents.
      Parameters:
      child - the new child
      parent - the parent.
      index - the index
    • setNonNull

      public <T> @NonNull T setNonNull(@NonNull Figure figure, @NonNull NonNullMapAccessor<T> key, @NonNull T newValue)
      Description copied from interface: DrawingModel
      Sets the specified property on the figure and fires appropriate DrawingModelEvents.
      Type Parameters:
      T - the value type
      Parameters:
      figure - the figure
      key - the key
      newValue - the new value
      Returns:
      the old value
    • set

      public <T> T set(@NonNull Figure figure, @NonNull MapAccessor<T> key, @Nullable T newValue)
      Description copied from interface: DrawingModel
      Sets the specified property on the figure and fires appropriate DrawingModelEvents.
      Type Parameters:
      T - the value type
      Parameters:
      figure - the figure
      key - the key
      newValue - the new value
      Returns:
      the old value
    • remove

      public <T> T remove(@NonNull Figure figure, @NonNull MapAccessor<T> key)
    • remove

      public <T> T remove(@NonNull Figure figure, @NonNull Key<T> key)
      Description copied from interface: DrawingModel
      Removes the specified key from the figure.
      Type Parameters:
      T - the value type
      Parameters:
      figure - a figure
      key - a key
      Returns:
      the old value
    • propertyAt

      public <T> @NonNull javafx.beans.property.Property<T> propertyAt(Figure f, Key<T> key)
      Description copied from interface: DrawingModel
      Creates a property for the specified figure and property key.
      Type Parameters:
      T - the property type
      Parameters:
      f - a figure
      key - a property key
      Returns:
      a property
    • reshapeInLocal

      public void reshapeInLocal(@NonNull Figure f, javafx.scene.transform.Transform transform)
      Description copied from interface: DrawingModel
      Attempts to change the local bounds of the figure and fires appropriate DrawingModelEvents.
      Parameters:
      f - the figure
      transform - the desired transformation in the local coordinate system
    • reshapeInParent

      public void reshapeInParent(@NonNull Figure f, javafx.scene.transform.Transform transform)
      Description copied from interface: DrawingModel
      Attempts to change the parent bounds of the figure and fires appropriate DrawingModelEvents.
      Parameters:
      f - the figure
      transform - the desired transformation in the parent coordinate system
    • translateInParent

      public void translateInParent(@NonNull Figure f, CssPoint2D delta)
    • transformInParent

      public void transformInParent(@NonNull Figure f, javafx.scene.transform.Transform transform)
      Description copied from interface: DrawingModel
      Invokes "transformInParent" on the specified figure.
      Parameters:
      f - a figure
      transform - the desired transformation
    • transformInLocal

      public void transformInLocal(@NonNull Figure f, javafx.scene.transform.Transform transform)
      Description copied from interface: DrawingModel
      Invokes "transformInLocal" on the specified figure.
      Parameters:
      f - a figure
      transform - the desired transformation
    • reshapeInLocal

      public void reshapeInLocal(@NonNull Figure f, double x, double y, double width, double height)
      Description copied from interface: DrawingModel
      Attempts to change the local bounds of the figure and fires appropriate DrawingModelEvents.
      Parameters:
      f - the figure
      x - desired x-position in the local coordinate system
      y - desired y-position in the local coordinate system
      width - desired width in the local coordinate system, may be negative
      height - desired height in the local coordinat system, may be negative
    • reshapeInLocal

      public void reshapeInLocal(@NonNull Figure f, @NonNull CssSize x, @NonNull CssSize y, @NonNull CssSize width, @NonNull CssSize height)
    • layout

      public void layout(@NonNull Figure f, @NonNull RenderContext ctx)
      Description copied from interface: DrawingModel
      Invokes the layout method of the figure and fires appropriate / DrawingModelEvents.
      Parameters:
      f - the figure
      ctx - the render context (optional)
    • isValidating

      public boolean isValidating()
      Gets the value of the validating property.
      Property description:
      Returns:
      the value of the validating property
      See Also:
    • validatingProperty

      public javafx.beans.property.ReadOnlyBooleanProperty validatingProperty()
      Description copied from interface: DrawingModel
      This property returns true if the drawing model is validating its figures.
      Returns:
      the validating property
      See Also:
    • disconnect

      public void disconnect(@NonNull Figure f)
      Description copied from interface: DrawingModel
      Invokes the disconnect method of the figure and fires appropriate DrawingModelEvents.
      Parameters:
      f - the figure
    • updateCss

      public void updateCss(@NonNull Figure figure)
      Description copied from interface: DrawingModel
      Invokes the updateCss method of the figure and fires appropriate DrawingModelEvents.
      Parameters:
      figure - the figure
    • validate

      public void validate(@NonNull RenderContext ctx)
      Description copied from interface: DrawingModel
      Validates the model. This method is invoked by DrawingView each time before it renders the model.
      Parameters:
      ctx - the render context (optional)
    • fireDrawingModelEvent

      public void fireDrawingModelEvent(@NonNull DrawingModelEvent event)
      Description copied from interface: DrawingModel
      Fires the specified event.
      Parameters:
      event - the event
    • fireTreeModelEvent

      public void fireTreeModelEvent(@NonNull TreeModelEvent<Figure> event)
    • onDrawingModelEvent

      protected void onDrawingModelEvent(@NonNull DrawingModelEvent event)
    • onTreeModelEvent

      protected void onTreeModelEvent(@NonNull TreeModelEvent<Figure> event)