Class GridConstrainer

All Implemented Interfaces:
javafx.beans.Observable, Constrainer, ObservableMixin

public class GridConstrainer extends AbstractConstrainer
GridConstrainer.
Author:
Werner Randelshofer
  • Property Details

    • angle

      public javafx.beans.property.DoubleProperty angleProperty
      The angle for constrained rotations on the grid (in degrees). The value 0 turns the constrainer off for rotations.
      See Also:
    • drawGrid

      public javafx.beans.property.BooleanProperty drawGridProperty
      Whether to draw the grid.
      See Also:
    • gridColor

      public javafx.beans.property.Property<CssColor> gridColorProperty
      See Also:
    • height

      public javafx.beans.property.ObjectProperty<CssSize> heightProperty
      Height of a grid cell. The value 0 turns the constrainer off for the vertical axis.
      See Also:
    • majorX

      public javafx.beans.property.IntegerProperty majorXProperty
      The x-factor for the major grid of the grid.
      See Also:
    • majorY

      public javafx.beans.property.IntegerProperty majorYProperty
      The x-factor for the major grid of the grid.
      See Also:
    • snapToGrid

      public javafx.beans.property.BooleanProperty snapToGridProperty
      Whether to snap to the grid.
      See Also:
    • width

      public javafx.beans.property.ObjectProperty<CssSize> widthProperty
      Width of a grid cell. The value 0 turns the constrainer off for the horizontal axis.
      See Also:
    • x

      public javafx.beans.property.ObjectProperty<CssSize> xProperty
      The x-origin of the grid.
      See Also:
    • y

      public javafx.beans.property.ObjectProperty<CssSize> yProperty
      The y-origin of the grid.
      See Also:
  • Constructor Details

    • GridConstrainer

      public GridConstrainer()
      Creates a grid of 10x10 pixels at origin 0,0 and 22.5 degree rotations.
    • GridConstrainer

      public GridConstrainer(double width, double height)
      Creates a grid of width x height pixels at origin 0,0 and 22.5 degree rotations.
      Parameters:
      width - The width of the grid. 0 turns the grid of for the x-axis.
      height - The width of the grid. 0 turns the grid of for the y-axis.
    • GridConstrainer

      public GridConstrainer(double x, double y, double width, double height, double angle, int majorx, int majory)
      Creates a grid with the specified constraints.
      Parameters:
      x - The x-origin of the grid
      y - The y-origin of the grid
      width - The width of the grid. 0 turns the grid of for the x-axis.
      height - The width of the grid. 0 turns the grid of for the y-axis.
      angle - The angular grid (in degrees). 0 turns the grid off for rotations.
      majorx - the interval for major grid lines on the x-axis
      majory - the interval for major grid lines on the y-axis
    • GridConstrainer

      public GridConstrainer(CssSize x, CssSize y, CssSize width, CssSize height, double angle, int majorx, int majory)
  • Method Details

    • angleProperty

      public javafx.beans.property.DoubleProperty angleProperty()
      The angle for constrained rotations on the grid (in degrees). The value 0 turns the constrainer off for rotations.
      Returns:
      the angle property
    • drawGridProperty

      public javafx.beans.property.BooleanProperty drawGridProperty()
      Whether to draw the grid.
      Returns:
      the drawGrid property
    • getGridColor

      public CssColor getGridColor()
      Gets the value of the gridColor property.
      Property description:
      Returns:
      the value of the gridColor property
      See Also:
    • setGridColor

      public void setGridColor(CssColor newValue)
      Sets the value of the gridColor property.
      Property description:
      Parameters:
      newValue - the value for the gridColor property
      See Also:
    • getHeight

      public CssSize getHeight()
      Gets the value of the height property.
      Property description:
      Height of a grid cell. The value 0 turns the constrainer off for the vertical axis.
      Returns:
      the value of the height property
      See Also:
    • getMajorX

      public int getMajorX()
      Gets the value of the majorX property.
      Property description:
      The x-factor for the major grid of the grid.
      Returns:
      the value of the majorX property
      See Also:
    • getMajorY

      public int getMajorY()
      Gets the value of the majorY property.
      Property description:
      The x-factor for the major grid of the grid.
      Returns:
      the value of the majorY property
      See Also:
    • getNode

      public javafx.scene.Node getNode()
      Description copied from interface: Constrainer
      Returns a node that renders the grid in view coordinates.
      Returns:
      the node
    • getWidth

      public CssSize getWidth()
      Gets the value of the width property.
      Property description:
      Width of a grid cell. The value 0 turns the constrainer off for the horizontal axis.
      Returns:
      the value of the width property
      See Also:
    • getX

      public CssSize getX()
      Gets the value of the x property.
      Property description:
      The x-origin of the grid.
      Returns:
      the value of the x property
      See Also:
    • getY

      public CssSize getY()
      Gets the value of the y property.
      Property description:
      The y-origin of the grid.
      Returns:
      the value of the y property
      See Also:
    • gridColorProperty

      public javafx.beans.property.Property<CssColor> gridColorProperty()
      Returns:
      the gridColor property
      See Also:
    • heightProperty

      public javafx.beans.property.ObjectProperty<CssSize> heightProperty()
      Height of a grid cell. The value 0 turns the constrainer off for the vertical axis.
      Returns:
      the height property
      See Also:
    • majorXProperty

      public javafx.beans.property.IntegerProperty majorXProperty()
      The x-factor for the major grid of the grid.
      Returns:
      the majorX property
      See Also:
    • majorYProperty

      public javafx.beans.property.IntegerProperty majorYProperty()
      The x-factor for the major grid of the grid.
      Returns:
      the majorY property
      See Also:
    • snapToGridProperty

      public javafx.beans.property.BooleanProperty snapToGridProperty()
      Whether to snap to the grid.
      Returns:
      the snapToGrid property
    • translateAngle

      public double translateAngle(Figure f, double angle, double dir)
      Description copied from interface: Constrainer
      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.
    • translatePoint

      public CssPoint2D translatePoint(Figure f, CssPoint2D cssp, CssPoint2D dir)
      Description copied from interface: Constrainer
      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.
      cssp - 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.
    • translateRectangle

      public CssRectangle2D translateRectangle(Figure f, CssRectangle2D cssr, CssPoint2D cssdir)
      Description copied from interface: Constrainer
      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.
      cssr - A rectangle on the drawing.
      cssdir - A direction vector. If the vector length is zero, then the nearest constrained location is used.
      Returns:
      Returns the constrained rectangle.
    • updateNode

      public void updateNode(DrawingView drawingView)
      Description copied from interface: Constrainer
      Updates the node.
      Parameters:
      drawingView - the drawing view
    • widthProperty

      public javafx.beans.property.ObjectProperty<CssSize> widthProperty()
      Width of a grid cell. The value 0 turns the constrainer off for the horizontal axis.
      Returns:
      the width property
      See Also:
    • xProperty

      public javafx.beans.property.ObjectProperty<CssSize> xProperty()
      The x-origin of the grid.
      Returns:
      the x property
      See Also:
    • yProperty

      public javafx.beans.property.ObjectProperty<CssSize> yProperty()
      The y-origin of the grid.
      Returns:
      the y property
      See Also: