Class SimpleDrawingView

All Implemented Interfaces:
DrawingView, RenderContext, WritableRenderContext, PropertyBean, ReadOnlyPropertyBean

public class SimpleDrawingView extends AbstractDrawingView
A simple implementation of DrawingView.

The SimpleDrawingView has the following scene structure:

The scene node of the SimpleDrawingView has the following structure and CSS style classes:
  • Property Details

    • activeParent

      public javafx.beans.property.ObjectProperty<Figure> activeParentProperty
      Returns:
      the active layer of the drawing. Returns null if the drawing has no layers or no layer has been activated.
      See Also:
    • constrainer

      public NonNullObjectProperty<Constrainer> constrainerProperty
      Returns:
      the constrainer property, with getBean() returning this drawing view, and getName() returning CONSTRAINER_PROPERTY.
      See Also:
    • drawing

      public javafx.beans.property.ReadOnlyObjectProperty<Drawing> drawingProperty
      Returns:
      the drawing model property
      See Also:
    • focused

      public javafx.beans.property.ReadOnlyBooleanProperty focusedProperty
      Returns:
      the focused property, with getBean() returning this drawing view, and getName() returning FOCUSED_PROPERTY.
      See Also:
    • handles

      public javafx.beans.property.ReadOnlySetProperty<Handle> handlesProperty
      Returns:
      the handles that are currently being displayed on this drawing view.
      See Also:
    • model

      public NonNullObjectProperty<DrawingModel> modelProperty
      Returns:
      the drawing model property, with getBean() returning this drawing view, and getName() returning DRAWING_PROPERTY.
      See Also:
    • zoomFactor

      public javafx.beans.property.DoubleProperty zoomFactorProperty
      Returns:
      The zoom factor. The value is always greater than 0. Values larger than 1 cause a magnification. Values between 0 and 1 causes a minification.
      See Also:
  • Field Details

    • CANVAS_REGION_STYLE_CLASS

      public static final String CANVAS_REGION_STYLE_CLASS
      The style class of the canvas pane is "jhotdraw8-drawing-view-canvas-region".
      See Also:
    • DRAWING_VIEW_STYLE_CLASS

      public static final String DRAWING_VIEW_STYLE_CLASS
      The style class of the drawing view is "jhotdraw8-drawing-view".
      See Also:
  • Constructor Details

    • SimpleDrawingView

      public SimpleDrawingView()
  • Method Details

    • activeParentProperty

      public javafx.beans.property.ObjectProperty<Figure> activeParentProperty()
      Description copied from interface: DrawingView
      The active layer of the drawing.
      Returns:
      the activeParent property
      See Also:
    • clearSelection

      public void clearSelection()
    • constrainerProperty

      public NonNullObjectProperty<Constrainer> constrainerProperty()
      Description copied from interface: DrawingView
      The constrainer.
      Returns:
      the constrainer property
      See Also:
    • deleteSelection

      public void deleteSelection()
    • drawingProperty

      public javafx.beans.property.ReadOnlyObjectProperty<Drawing> drawingProperty()
      Description copied from interface: DrawingView
      The drawing model.
      Returns:
      the drawing property
      See Also:
    • duplicateSelection

      public void duplicateSelection()
    • findFigureNode

      public @Nullable javafx.scene.Node findFigureNode(Figure figure, double vx, double vy)
      Description copied from interface: DrawingView
      Finds the front-most node of the specified figure that contains the specified view coordinates.
      Parameters:
      figure - the figure
      vx - x in view coordinates
      vy - y in view coordinates
      Returns:
      A node or null
    • findFigures

      public List<Map.Entry<Figure,Double>> findFigures(double vx, double vy, boolean decompose, Predicate<Figure> predicate)
      Description copied from interface: DrawingView
      Finds the figure at the given view coordinates behind the given figure. Figures are searched in Z-order from front to back.
      Parameters:
      vx - x in view coordinates
      vy - y in view coordinates
      decompose - whether to decompose the figures
      Returns:
      A list of figures from front to back. Each entry contains the figure and the distance of the figure to vx,vy. Distance 0 means that vx,vy is inside the figure.
    • findFiguresInside

      public List<Map.Entry<Figure,Double>> findFiguresInside(double vx, double vy, double vwidth, double vheight, boolean decompose)
      Description copied from interface: DrawingView
      Returns all figures that lie within the specified bounds given in view coordinates. The figures are returned in Z-order from back to front. Skips disabled figures.
      Parameters:
      vx - x in view coordinates
      vy - y in view coordinates
      vwidth - width in view coordinates
      vheight - height in view coordinates
      decompose - whether to decompose the figures
      Returns:
      A list of figures from front to back. Each entry contains the figure and the distance of the figure to vx,vy. Distance 0 means that vx,vy is inside the figure.
    • findFiguresIntersecting

      public List<Map.Entry<Figure,Double>> findFiguresIntersecting(double vx, double vy, double vwidth, double vheight, boolean decompose, Predicate<Figure> predicate)
      Description copied from interface: DrawingView
      Returns all figures that intersect the specified bounds given in view coordinates. The figures are returned in Z-order from front to back. Skips disabled figures.
      Parameters:
      vx - x in view coordinates
      vy - y in view coordinates
      vwidth - width in view coordinates
      vheight - height in view coordinates
      decompose - whether to decompose the figures
      predicate - predicate for filtering figures
      Returns:
      A list of figures from front to back
    • findHandle

      public @Nullable Handle findHandle(double vx, double vy)
      Description copied from interface: DrawingView
      Finds the handle at the given view coordinates. Handles are searched in Z-order from front to back. Skips handles which are not selectable.
      Parameters:
      vx - x in view coordinates
      vy - y in view coordinates
      Returns:
      A handle or null
    • focusedProperty

      public javafx.beans.property.ReadOnlyBooleanProperty focusedProperty()
      Description copied from interface: DrawingView
      The focused property is set to true, when the DrawingView has input focus.
      Returns:
      the focused property
    • getFiguresWithCompatibleHandle

      public Set<Figure> getFiguresWithCompatibleHandle(Collection<Figure> figures, Handle handle)
      Description copied from interface: DrawingView
      Gets selected figures with the same handle.
      Parameters:
      figures - selected figures
      handle - a handle
      Returns:
      A collection containing the figures with compatible handles.
    • getNode

      public javafx.scene.Node getNode()
      Description copied from interface: DrawingView
      Returns the javafx.scene.Node of the DrawingView.
      Returns:
      a node
    • getNode

      public @Nullable javafx.scene.Node getNode(Figure f)
      Description copied from interface: DrawingView
      Gets the node which is used to render the specified figure by the drawing view.
      Parameters:
      f - The figure
      Returns:
      The node associated to the figure
    • getViewToWorld

      public javafx.scene.transform.Transform getViewToWorld()
      Description copied from interface: DrawingView
      Returns the view to world transformation.
      Returns:
      the transformation;
    • getVisibleRect

      public javafx.geometry.Bounds getVisibleRect()
      Description copied from interface: DrawingView
      Returns the visible rectangle of the drawing view in view coordinates.
      Returns:
      the portion of the DrawingView that is visible on screen.
    • getWorldToView

      public javafx.scene.transform.Transform getWorldToView()
      Description copied from interface: DrawingView
      Returns the world to view transformation.
      Returns:
      the transformation
    • handlesProperty

      public javafx.beans.property.ReadOnlySetProperty<Handle> handlesProperty()
      Description copied from interface: DrawingView
      The handles.

      Note: The handles are represented by a SequencedSet because the sequence of the handles is important.

      Returns:
      the handles property
      See Also:
    • initBehavior

      protected void initBehavior()
    • initStyle

      protected void initStyle()
    • invalidateHandles

      protected void invalidateHandles()
      Specified by:
      invalidateHandles in class AbstractDrawingView
    • jiggleHandles

      public void jiggleHandles()
      Description copied from interface: DrawingView
      Plays a short animation on the handles to make them easier discoverable.
    • modelProperty

      public NonNullObjectProperty<DrawingModel> modelProperty()
      Description copied from interface: DrawingView
      The drawing model.
      Returns:
      the model property
      See Also:
    • onToolChanged

      protected void onToolChanged(javafx.beans.Observable observable, @Nullable Tool oldValue, @Nullable Tool newValue)
      Specified by:
      onToolChanged in class AbstractDrawingView
    • paintImmediately

      public void paintImmediately()
      For testing: paints the drawing immediately.
    • recreateHandles

      public void recreateHandles()
    • repaint

      protected void repaint()
      Specified by:
      repaint in class AbstractDrawingView
    • scrollRectToVisible

      public void scrollRectToVisible(javafx.geometry.Bounds boundsInView)
      Description copied from interface: DrawingView
      Scrolls the specified rectangle to visible.
      Parameters:
      boundsInView - A rectangle in view coordinates.
    • selectAll

      public void selectAll()
      Selects all enabled and selectable figures in all enabled layers.
    • zoomFactorProperty

      public javafx.beans.property.DoubleProperty zoomFactorProperty()
      Description copied from interface: DrawingView
      The scale factor of the drawing view.
      Returns:
      the zoomFactor property
      See Also: