Interface Constrainer

All Superinterfaces:
javafx.beans.Observable
All Known Implementing Classes:
AbstractConstrainer, FigureSpecificConstrainer, GridConstrainer, NullConstrainer

public interface Constrainer extends javafx.beans.Observable
A constrainer constrains editing operations performed by Tools and Handles on a DrawingView.

Constrainer objects are associated to DrawingView's.

Constrainers can draw themselves onto the drawing view to visualize the constraints that they impose. Typically by drawing a grid of some kind.

Author:
Werner Randelshofer
  • Field Details

    • STYLECLASS_CONSTRAINER_MINOR_GRID

      static final String STYLECLASS_CONSTRAINER_MINOR_GRID
      Style class for constrainers which draw a grid.
      See Also:
    • STYLECLASS_CONSTRAINER_MAJOR_GRID

      static final String STYLECLASS_CONSTRAINER_MAJOR_GRID
      Style class for constrainers which draw a grid.
      See Also:
    • DIRECTION_NEAREST

      static final CssPoint2D DIRECTION_NEAREST
      A direction vector with distance of zero.
  • Method Details

    • constrainPoint

      default CssPoint2D constrainPoint(Figure f, CssPoint2D p)
      Constrains the placement of a point towards the closest constraint in any direction.

      This method changes the point which is passed as a parameter.

      Parameters:
      f - The figure for which the point is to be constrained.
      p - A point on the drawing.
      Returns:
      Returns the constrained point.
    • translatePoint

      CssPoint2D translatePoint(Figure f, CssPoint2D p, CssPoint2D dir)
      Snaps a point to the next constrained location in the specified direction.

      This method changes the point which is passed as a parameter.

      Parameters:
      f - The figure for which the point is to be constrained.
      p - A point on the drawing.
      dir - A direction vector. If the vector length is zero, then the nearest constrained location is used.
      Returns:
      Returns the constrained point.
    • constrainRectangle

      default CssRectangle2D constrainRectangle(Figure f, CssRectangle2D r)
      Constrains the placement of a rectangle towards the closest constraint in any direction.

      This method changes the location of the rectangle which is passed as a parameter. This method does not change the size of the rectangle.

      Parameters:
      f - The figure for which the rectangle is to be constrained.
      r - A rectangle on the drawing.
      Returns:
      Returns the constrained rectangle.
    • translateRectangle

      CssRectangle2D translateRectangle(Figure f, CssRectangle2D r, CssPoint2D dir)
      Snaps a rectangle into the the closest constraint position in the given direction.

      This method changes the location of the rectangle which is passed as a parameter. This method does not change the size of the rectangle.

      Parameters:
      f - The figure for which points are to be constrained.
      r - A rectangle on the drawing.
      dir - A direction vector. If the vector length is zero, then the nearest constrained location is used.
      Returns:
      Returns the constrained rectangle.
    • constrainAngle

      default double constrainAngle(Figure f, double angle)
      Constrains the given angle (in degrees). This method changes the angle which is passed as a parameter.
      Parameters:
      f - The figure for which the angle is to be constrained.
      angle - The angle (in degrees).
      Returns:
      The closest constrained angle (in radians).
    • translateAngle

      double translateAngle(Figure f, double angle, double dir)
      Snaps an angle (in degrees) to the closest constrained orientation in the specified direction.
      Parameters:
      f - The figure for which the angle is to be constrained.
      angle - The angle (in degrees).
      dir - A direction. If the direction is zero, then the nearest constrained location is used.
      Returns:
      The closest constrained angle (in radians) in the specified direction.
    • getNode

      javafx.scene.Node getNode()
      Returns a node that renders the grid in view coordinates.
      Returns:
      the node
    • updateNode

      void updateNode(DrawingView drawingView)
      Updates the node.
      Parameters:
      drawingView - the drawing view