java.lang.Object
org.jhotdraw8.fxbase.beans.SimpleObservable
org.jhotdraw8.draw.constrain.AbstractConstrainer
org.jhotdraw8.draw.constrain.GridConstrainer
- All Implemented Interfaces:
javafx.beans.Observable,Constrainer,ObservableMixin
GridConstrainer.
- Author:
- Werner Randelshofer
-
Property Summary
PropertiesTypePropertyDescription@NonNull javafx.beans.property.DoublePropertyThe angle for constrained rotations on the grid (in degrees).@NonNull javafx.beans.property.BooleanPropertyWhether to draw the grid.Height of a grid cell.@NonNull javafx.beans.property.IntegerPropertyThe x-factor for the major grid of the grid.@NonNull javafx.beans.property.IntegerPropertyThe x-factor for the major grid of the grid.@NonNull javafx.beans.property.BooleanPropertyWhether to snap to the grid.Width of a grid cell.The x-origin of the grid.The y-origin of the grid. -
Field Summary
Fields inherited from interface org.jhotdraw8.draw.constrain.Constrainer
DIRECTION_NEAREST, STYLECLASS_CONSTRAINER_MAJOR_GRID, STYLECLASS_CONSTRAINER_MINOR_GRID -
Constructor Summary
ConstructorsConstructorDescriptionCreates a grid of 10x10 pixels at origin 0,0 and 22.5 degree rotations.GridConstrainer(double width, double height) Creates a grid of width x height pixels at origin 0,0 and 22.5 degree rotations.GridConstrainer(double x, double y, double width, double height, double angle, int majorx, int majory) Creates a grid with the specified constraints.GridConstrainer(CssSize x, CssSize y, CssSize width, CssSize height, double angle, int majorx, int majory) -
Method Summary
Modifier and TypeMethodDescription@NonNull javafx.beans.property.DoublePropertyThe angle for constrained rotations on the grid (in degrees).@NonNull javafx.beans.property.BooleanPropertyWhether to draw the grid.Gets the value of thegridColorproperty.Gets the value of theheightproperty.intGets the value of themajorXproperty.intGets the value of themajorYproperty.@NonNull javafx.scene.NodegetNode()Returns a node that renders the grid in view coordinates.getWidth()Gets the value of thewidthproperty.getX()Gets the value of thexproperty.getY()Gets the value of theyproperty.Height of a grid cell.@NonNull javafx.beans.property.IntegerPropertyThe x-factor for the major grid of the grid.@NonNull javafx.beans.property.IntegerPropertyThe x-factor for the major grid of the grid.voidsetGridColor(CssColor newValue) Sets the value of thegridColorproperty.@NonNull javafx.beans.property.BooleanPropertyWhether to snap to the grid.doubletranslateAngle(Figure f, double angle, double dir) Snaps an angle (in degrees) to the closest constrained orientation in the specified direction.translatePoint(Figure f, @NonNull CssPoint2D cssp, @NonNull CssPoint2D dir) Snaps a point to the next constrained location in the specified direction.translateRectangle(Figure f, @NonNull CssRectangle2D cssr, @NonNull CssPoint2D cssdir) Snaps a rectangle into the the closest constraint position in the given direction.voidupdateNode(@NonNull DrawingView drawingView) Updates the node.Width of a grid cell.The x-origin of the grid.The y-origin of the grid.Methods inherited from class org.jhotdraw8.fxbase.beans.SimpleObservable
getInvalidationListenersMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jhotdraw8.draw.constrain.Constrainer
constrainAngle, constrainPoint, constrainRectangleMethods inherited from interface javafx.beans.Observable
subscribeMethods inherited from interface org.jhotdraw8.fxbase.beans.ObservableMixin
addListener, fireInvalidated, fireInvalidated, invalidated, removeListener
-
Property Details
-
angle
The angle for constrained rotations on the grid (in degrees). The value 0 turns the constrainer off for rotations.- See Also:
-
drawGrid
Whether to draw the grid.- See Also:
-
gridColor
- See Also:
-
height
Height of a grid cell. The value 0 turns the constrainer off for the vertical axis.- See Also:
-
majorX
The x-factor for the major grid of the grid.- See Also:
-
majorY
The x-factor for the major grid of the grid.- See Also:
-
snapToGrid
Whether to snap to the grid.- See Also:
-
width
Width of a grid cell. The value 0 turns the constrainer off for the horizontal axis.- See Also:
-
x
The x-origin of the grid.- See Also:
-
y
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 gridy- The y-origin of the gridwidth- 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-axismajory- the interval for major grid lines on the y-axis
-
GridConstrainer
-
-
Method Details
-
angleProperty
The angle for constrained rotations on the grid (in degrees). The value 0 turns the constrainer off for rotations.- Returns:
- the
angleproperty
-
drawGridProperty
Whether to draw the grid.- Returns:
- the
drawGridproperty
-
getGridColor
Gets the value of thegridColorproperty.- Property description:
- Returns:
- the value of the
gridColorproperty - See Also:
-
setGridColor
Sets the value of thegridColorproperty.- Property description:
- Parameters:
newValue- the value for thegridColorproperty- See Also:
-
getHeight
Gets the value of theheightproperty.- Property description:
- Height of a grid cell. The value 0 turns the constrainer off for the vertical axis.
- Returns:
- the value of the
heightproperty - See Also:
-
getMajorX
public int getMajorX()Gets the value of themajorXproperty.- Property description:
- The x-factor for the major grid of the grid.
- Returns:
- the value of the
majorXproperty - See Also:
-
getMajorY
public int getMajorY()Gets the value of themajorYproperty.- Property description:
- The x-factor for the major grid of the grid.
- Returns:
- the value of the
majorYproperty - See Also:
-
getNode
Description copied from interface:ConstrainerReturns a node that renders the grid in view coordinates.- Returns:
- the node
-
getWidth
Gets the value of thewidthproperty.- Property description:
- Width of a grid cell. The value 0 turns the constrainer off for the horizontal axis.
- Returns:
- the value of the
widthproperty - See Also:
-
getX
Gets the value of thexproperty.- Property description:
- The x-origin of the grid.
- Returns:
- the value of the
xproperty - See Also:
-
getY
Gets the value of theyproperty.- Property description:
- The y-origin of the grid.
- Returns:
- the value of the
yproperty - See Also:
-
gridColorProperty
- Returns:
- the
gridColorproperty - See Also:
-
heightProperty
Height of a grid cell. The value 0 turns the constrainer off for the vertical axis.- Returns:
- the
heightproperty - See Also:
-
majorXProperty
The x-factor for the major grid of the grid.- Returns:
- the
majorXproperty - See Also:
-
majorYProperty
The x-factor for the major grid of the grid.- Returns:
- the
majorYproperty - See Also:
-
snapToGridProperty
Whether to snap to the grid.- Returns:
- the
snapToGridproperty
-
translateAngle
Description copied from interface:ConstrainerSnaps 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 @NonNull CssPoint2D translatePoint(Figure f, @NonNull CssPoint2D cssp, @NonNull CssPoint2D dir) Description copied from interface:ConstrainerSnaps 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 @NonNull CssRectangle2D translateRectangle(Figure f, @NonNull CssRectangle2D cssr, @NonNull CssPoint2D cssdir) Description copied from interface:ConstrainerSnaps 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
Description copied from interface:ConstrainerUpdates the node.- Parameters:
drawingView- the drawing view
-
widthProperty
Width of a grid cell. The value 0 turns the constrainer off for the horizontal axis.- Returns:
- the
widthproperty - See Also:
-
xProperty
The x-origin of the grid.- Returns:
- the
xproperty - See Also:
-
yProperty
The y-origin of the grid.- Returns:
- the
yproperty - See Also:
-