JHotDraw 7.2

org.jhotdraw.draw
Interface Constrainer

All Known Implementing Classes:
AbstractConstrainer, GridConstrainer

public interface Constrainer

Interface to constrain points and figures on a Drawing. This can be used to implement different kinds of grids.

Version:
5.0 2007-04-29 Werner Randelshofer: Refactored interface. Huw Jones: Added constrainAngle() method.
4.0 2007-07-31 Werner Randelshofer: Redesigned to support the constrainement of rectangles.
3.0 2007-04-29 Werner Randelshofer: Method constrainPoint(Point2D.Double, Direction) added.
2.1 2006-07-03 Werner Randelshofer: Method isVisible() added.
2.0 2006-01-17 Werner Randelshofer: Changed to support double precision coordinates.
1.0 2004-03-14 Werner Randelshofer: Created.
Author:
Werner Randelshofer

Method Summary
 void addChangeListener(javax.swing.event.ChangeListener listener)
          Adds a change listener.
 double constrainAngle(double angle)
          Constrains the given angle (in radians).
 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.
 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.
 void draw(java.awt.Graphics2D g, DrawingView view)
          Draws the constrainer grid for the specified drawing view.
 void removeChangeListener(javax.swing.event.ChangeListener listener)
          Removes a change listener.
 double rotateAngle(double angle, RotationDirection dir)
          Moves the given angle (in radians) to the closest constrained orientation in the specified direction.
 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.
 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.
 

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.


Copyright 1996-2009 (c) by the authors and contributors of the JHotDraw project.
Some rights reserved.