- 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 Summary
FieldsModifier and TypeFieldDescriptionstatic final CssPoint2DA direction vector with distance of zero.static final StringStyle class for constrainers which draw a grid.static final StringStyle class for constrainers which draw a grid. -
Method Summary
Modifier and TypeMethodDescriptiondefault doubleconstrainAngle(Figure f, double angle) Constrains the given angle (in degrees).default CssPoint2DconstrainPoint(Figure f, CssPoint2D p) Constrains the placement of a point towards the closest constraint in any direction.default CssRectangle2DConstrains the placement of a rectangle towards the closest constraint in any direction.javafx.scene.NodegetNode()Returns a node that renders the grid in view coordinates.doubletranslateAngle(Figure f, double angle, double dir) Snaps an angle (in degrees) to the closest constrained orientation in the specified direction.translatePoint(Figure f, CssPoint2D p, CssPoint2D dir) Snaps a point to the next constrained location in the specified direction.translateRectangle(Figure f, CssRectangle2D r, CssPoint2D dir) Snaps a rectangle into the the closest constraint position in the given direction.voidupdateNode(DrawingView drawingView) Updates the node.Methods inherited from interface javafx.beans.Observable
addListener, removeListener, subscribe
-
Field Details
-
STYLECLASS_CONSTRAINER_MINOR_GRID
Style class for constrainers which draw a grid.- See Also:
-
STYLECLASS_CONSTRAINER_MAJOR_GRID
Style class for constrainers which draw a grid.- See Also:
-
DIRECTION_NEAREST
A direction vector with distance of zero.
-
-
Method Details
-
constrainPoint
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
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
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
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
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
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
Updates the node.- Parameters:
drawingView- the drawing view
-