Interface Constrainer
-
- All Known Implementing Classes:
- AbstractConstrainer, GridConstrainer
public interface ConstrainerA constrainer constrains editing operations performed byTools andHandles on aDrawingView.Constrainerobjects are associated toDrawingView's.Constrainers can draw themselves onto the drawing view to visualize the constraints that they impose. Typically by drawing a grid of some kind.
Design PatternsStrategy
Editing can be constrained by a constrainer which is associated to a drawing view.
Context:DrawingView; Strategy:Constrainer.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description voidaddChangeListener(javax.swing.event.ChangeListener listener)Adds a change listener.doubleconstrainAngle(double angle)Constrains the given angle (in radians).java.awt.geom.Point2D.DoubleconstrainPoint(java.awt.geom.Point2D.Double p)Constrains the placement of a point towards the closest constraint in any direction.java.awt.geom.Rectangle2D.DoubleconstrainRectangle(java.awt.geom.Rectangle2D.Double r)Constrains the placement of a rectangle towards the closest constrainment in any direction.voiddraw(java.awt.Graphics2D g, DrawingView view)Draws the constrainer grid for the specified drawing view.voidremoveChangeListener(javax.swing.event.ChangeListener listener)Removes a change listener.doublerotateAngle(double angle, RotationDirection dir)Moves the given angle (in radians) to the closest constrained orientation in the specified direction.java.awt.geom.Point2D.DoubletranslatePoint(java.awt.geom.Point2D.Double p, TranslationDirection dir)Moves a point to the closest constrained location in the specified direction.java.awt.geom.Rectangle2D.DoubletranslateRectangle(java.awt.geom.Rectangle2D.Double r, TranslationDirection dir)Moves a rectangle to the closest constrained location in the specified direction.
-
-
-
Method Detail
-
constrainPoint
java.awt.geom.Point2D.Double constrainPoint(java.awt.geom.Point2D.Double 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:
p- A point on the drawing.- Returns:
- Returns the constrained point.
-
translatePoint
java.awt.geom.Point2D.Double translatePoint(java.awt.geom.Point2D.Double p, TranslationDirection dir)Moves a point to the closest constrained location in the specified direction.This method changes the point which is passed as a parameter.
- Parameters:
p- A point on the drawing.dir- A direction.- Returns:
- Returns the constrained point.
-
constrainRectangle
java.awt.geom.Rectangle2D.Double constrainRectangle(java.awt.geom.Rectangle2D.Double r)
Constrains the placement of a rectangle towards the closest constrainment 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:
r- A rectangle on the drawing.- Returns:
- Returns the constrained rectangle.
-
translateRectangle
java.awt.geom.Rectangle2D.Double translateRectangle(java.awt.geom.Rectangle2D.Double r, TranslationDirection dir)Moves a rectangle to the closest constrained location in the specified direction.This method changes the location of the rectangle which is passed as a parameter. This method only performs a translation - it does not change the size of the rectangle.
- Parameters:
r- A rectangle on the drawing.dir- A direction.- Returns:
- Returns the constrained rectangle.
-
constrainAngle
double constrainAngle(double angle)
Constrains the given angle (in radians). This method changes the angle which is passed as a parameter.- Parameters:
angle- The angle (in radians).- Returns:
- The closest constrained angle (in radians).
-
rotateAngle
double rotateAngle(double angle, RotationDirection dir)Moves the given angle (in radians) to the closest constrained orientation in the specified direction.- Parameters:
angle- The angle (in radians).- Returns:
- The closest constrained angle (in radians) in the specified direction.
-
draw
void draw(java.awt.Graphics2D g, DrawingView view)Draws the constrainer grid for the specified drawing view.
-
addChangeListener
void addChangeListener(javax.swing.event.ChangeListener listener)
Adds a change listener.
-
removeChangeListener
void removeChangeListener(javax.swing.event.ChangeListener listener)
Removes a change listener.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG