java.lang.Object
org.jhotdraw8.fxbase.beans.SimpleObservable
org.jhotdraw8.draw.constrain.AbstractConstrainer
org.jhotdraw8.draw.constrain.FigureSpecificConstrainer
- All Implemented Interfaces:
javafx.beans.Observable,Constrainer,ObservableMixin
Allows to use different constrainers for different figure types.
XXX This could be an abstract class with abstract method getConstrainer. The constrainerMap and the defaultConstrainer could be moved into a concrete subclass.
- Author:
- Werner Randelshofer
-
Property Summary
PropertiesTypePropertyDescriptionjavafx.collections.ObservableMap<Class<?>, Constrainer> Maps figure classes to constrainers.All figures which are not in the map use the default constrainer. -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal StringThe name of the "constrainerMap" property.final StringThe name of the "defaultConstrainer" property.Fields inherited from interface org.jhotdraw8.draw.constrain.Constrainer
DIRECTION_NEAREST, STYLECLASS_CONSTRAINER_MAJOR_GRID, STYLECLASS_CONSTRAINER_MINOR_GRID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleconstrainAngle(Figure f, double angle) Constrains the given angle (in degrees).javafx.collections.ObservableMap<Class<?>, Constrainer> Maps figure classes to constrainers.constrainPoint(Figure f, CssPoint2D p) Constrains the placement of a point towards the closest constraint in any direction.Constrains the placement of a rectangle towards the closest constraint in any direction.All figures which are not in the map use the default constrainer.Map<Class<?>, Constrainer> Gets the value of theconstrainerMapproperty.Gets the value of thedefaultConstrainerproperty.javafx.scene.NodegetNode()Returns a node that renders the grid in view coordinates.voidsetDefaultConstrainer(Constrainer newValue) Sets the value of thedefaultConstrainerproperty.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 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 javafx.beans.Observable
subscribeMethods inherited from interface org.jhotdraw8.fxbase.beans.ObservableMixin
addListener, fireInvalidated, fireInvalidated, invalidated, removeListener
-
Property Details
-
constrainerMap
Maps figure classes to constrainers.- See Also:
-
defaultConstrainer
All figures which are not in the map use the default constrainer.- See Also:
-
-
Field Details
-
CONSTRAINER_MAP_PROPERTY
The name of the "constrainerMap" property.- See Also:
-
DEFAULT_CONSTRAINER_PROPERTY
The name of the "defaultConstrainer" property.- See Also:
-
-
Constructor Details
-
FigureSpecificConstrainer
public FigureSpecificConstrainer()
-
-
Method Details
-
constrainerMapProperty
Maps figure classes to constrainers.- Returns:
- the
constrainerMapproperty - See Also:
-
defaultConstrainerProperty
All figures which are not in the map use the default constrainer.- Returns:
- the
defaultConstrainerproperty - See Also:
-
getConstrainerMap
Gets the value of theconstrainerMapproperty.- Property description:
- Maps figure classes to constrainers.
- Returns:
- the value of the
constrainerMapproperty - See Also:
-
getDefaultConstrainer
Gets the value of thedefaultConstrainerproperty.- Property description:
- All figures which are not in the map use the default constrainer.
- Returns:
- the value of the
defaultConstrainerproperty - See Also:
-
setDefaultConstrainer
Sets the value of thedefaultConstrainerproperty.- Property description:
- All figures which are not in the map use the default constrainer.
- Parameters:
newValue- the value for thedefaultConstrainerproperty- See Also:
-
translatePoint
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.
- Specified by:
translatePointin interfaceConstrainer- 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.
-
translateRectangle
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.
- Specified by:
translateRectanglein interfaceConstrainer- 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.
-
translateAngle
Description copied from interface:ConstrainerSnaps an angle (in degrees) to the closest constrained orientation in the specified direction.- Specified by:
translateAnglein interfaceConstrainer- 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.
-
constrainPoint
Description copied from interface:ConstrainerConstrains the placement of a point towards the closest constraint in any direction.This method changes the point which is passed as a parameter.
- Specified by:
constrainPointin interfaceConstrainer- Parameters:
f- The figure for which the point is to be constrained.p- A point on the drawing.- Returns:
- Returns the constrained point.
-
constrainRectangle
Description copied from interface:ConstrainerConstrains 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.
- Specified by:
constrainRectanglein interfaceConstrainer- Parameters:
f- The figure for which the rectangle is to be constrained.r- A rectangle on the drawing.- Returns:
- Returns the constrained rectangle.
-
constrainAngle
Description copied from interface:ConstrainerConstrains the given angle (in degrees). This method changes the angle which is passed as a parameter.- Specified by:
constrainAnglein interfaceConstrainer- Parameters:
f- The figure for which the angle is to be constrained.angle- The angle (in degrees).- Returns:
- The closest constrained angle (in radians).
-
getNode
public javafx.scene.Node getNode()Description copied from interface:ConstrainerReturns a node that renders the grid in view coordinates.- Specified by:
getNodein interfaceConstrainer- Returns:
- the node
-
updateNode
Description copied from interface:ConstrainerUpdates the node.- Specified by:
updateNodein interfaceConstrainer- Parameters:
drawingView- the drawing view
-