diva.sketch.parser2d
Class BasicConstraint

java.lang.Object
  |
  +--diva.sketch.parser2d.BasicConstraint

public class BasicConstraint
extends java.lang.Object
implements RelationConstraint

An object that returns whether a pair of rectangles satisfies constraints on the values of a specified relation. Constraints are specified as a range from minimum to maximum value, inclusive. Constants NO_MIN_CONSTRAINT and NO_MAX_CONSTRAINT are used to specify an open range in either or both directions.

Version:
$Revision: 1.1 $

Field Summary
static double NO_MAX_CONSTRAINT
          Use this constant to specify no maximum constraint for a particular relation.
static double NO_MIN_CONSTRAINT
          Use this to constant specify no minimum constraint for a particular relation.
 
Constructor Summary
BasicConstraint(Relation r, double minVal, double maxVal)
          Create the constraints object with the given relations and given min/max constraints.
 
Method Summary
static void debug(java.lang.String s)
          Debugging output.
static double parseMinMax(java.lang.String s)
          Parse a number string, NO_MIN, or NO_MAX into the corresponding range boundary.
static java.lang.String printMinMax(double d)
          Parse a number string, NO_MIN, or NO_MAX into the corresponding range boundary.
 boolean test(java.awt.geom.Rectangle2D r1, java.awt.geom.Rectangle2D r2)
          Test the constraints on the given rectangles; return true if all constraints are met, false otherwise.
 java.lang.String toString()
          Print out the contents of this constraint.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_MAX_CONSTRAINT

public static double NO_MAX_CONSTRAINT
Use this constant to specify no maximum constraint for a particular relation.

NO_MIN_CONSTRAINT

public static double NO_MIN_CONSTRAINT
Use this to constant specify no minimum constraint for a particular relation.
Constructor Detail

BasicConstraint

public BasicConstraint(Relation r,
                       double minVal,
                       double maxVal)
Create the constraints object with the given relations and given min/max constraints. The relations will be applied sequentially in the order given, so put the cheaper ones or the more discriminatory ones first in the input.
Method Detail

debug

public static void debug(java.lang.String s)
Debugging output.

parseMinMax

public static double parseMinMax(java.lang.String s)
Parse a number string, NO_MIN, or NO_MAX into the corresponding range boundary.

printMinMax

public static java.lang.String printMinMax(double d)
Parse a number string, NO_MIN, or NO_MAX into the corresponding range boundary.

test

public boolean test(java.awt.geom.Rectangle2D r1,
                    java.awt.geom.Rectangle2D r2)
Test the constraints on the given rectangles; return true if all constraints are met, false otherwise.
Specified by:
test in interface RelationConstraint

toString

public java.lang.String toString()
Print out the contents of this constraint.
Overrides:
toString in class java.lang.Object