Package ptolemy.vergil.toolbox
Class SnapConstraint
- java.lang.Object
-
- ptolemy.vergil.toolbox.SnapConstraint
-
- All Implemented Interfaces:
PointConstraint
public class SnapConstraint extends java.lang.Object implements PointConstraint
This constraint ensures that a point is a multiple of a constant that defaults to 5.0.- Since:
- Ptolemy II 2.0
- Version:
- $Id$
- Author:
- Edward A. Lee
- Pt.AcceptedRating:
- Red (johnr)
- Pt.ProposedRating:
- Red (eal)
-
-
Constructor Summary
Constructors Constructor Description SnapConstraint()Construct a new instance of a snap constraint.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description double[]constrain(double[] point)Modify the specified point to snap to grid using the local resolution.double[]constrain(double x, double y)Modify the specified point to snap to grid using the local resolution.voidconstrain(java.awt.geom.Point2D point)Modify the specified point to snap to grid using the local resolution.static double[]constrainPoint(double[] point)Modify the specified point to snap to grid using the global default resolution.static double[]constrainPoint(double x, double y)Modify the specified point to snap to grid using the global default resolution.static java.awt.geom.Point2DconstrainPoint(java.awt.geom.Point2D point)Modify the specified point to snap to grid using the global default resolution.static doublegetDefaultResolution()Return the default resolution.doublegetResolution()Return the resolution for this instance.voidsetResolution(double resolution)Set the resolution for this instance.booleansnapped()Return true to indicate that this does snap to grid.
-
-
-
Method Detail
-
constrain
public void constrain(java.awt.geom.Point2D point)
Modify the specified point to snap to grid using the local resolution.- Specified by:
constrainin interfacePointConstraint- Parameters:
point- The point to modify.
-
constrain
public double[] constrain(double[] point)
Modify the specified point to snap to grid using the local resolution.- Parameters:
point- The point to modify (a dimension 2 array).- Returns:
- The constrained point.
-
constrain
public double[] constrain(double x, double y)Modify the specified point to snap to grid using the local resolution.- Parameters:
x- The x dimension of the point to modify.y- The y dimension of the point to modify.- Returns:
- The constrained point.
-
constrainPoint
public static java.awt.geom.Point2D constrainPoint(java.awt.geom.Point2D point)
Modify the specified point to snap to grid using the global default resolution.- Parameters:
point- The point to modify.- Returns:
- The constrained point.
-
constrainPoint
public static double[] constrainPoint(double[] point)
Modify the specified point to snap to grid using the global default resolution.- Parameters:
point- The point to modify (a dimension 2 array).- Returns:
- The constrained point.
-
constrainPoint
public static double[] constrainPoint(double x, double y)Modify the specified point to snap to grid using the global default resolution.- Parameters:
x- The x dimension of the point to modify.y- The y dimension of the point to modify.- Returns:
- The constrained point.
-
getDefaultResolution
public static double getDefaultResolution()
Return the default resolution.- Returns:
- The global default resolution.
-
getResolution
public double getResolution()
Return the resolution for this instance.- Returns:
- The global default resolution.
- See Also:
setResolution(double)
-
snapped
public boolean snapped()
Return true to indicate that this does snap to grid.- Specified by:
snappedin interfacePointConstraint- Returns:
- True.
-
setResolution
public void setResolution(double resolution)
Set the resolution for this instance.- Parameters:
resolution- The new resolution.- See Also:
getResolution()
-
-