diva.sketch.parser2d
Class BasicConstraint

java.lang.Object
  extended by diva.sketch.parser2d.BasicConstraint
All Implemented Interfaces:
RelationConstraint

public class BasicConstraint
extends 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.8 $
Author:
Michael Shilman (michaels@eecs.berkeley.edu)

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(String s)
          Debugging output.
static double parseMinMax(String s)
          Parse a number string, NO_MIN, or NO_MAX into the corresponding range boundary.
static String printMinMax(double d)
          Parse a number string, NO_MIN, or NO_MAX into the corresponding range boundary.
 boolean test(SceneElement e1, SceneElement e2)
          Test the constraint on the given elements; return true if all constraints are met, false otherwise.
 String toString()
          Print out the contents of this constraint.
 String toString(String e1Name, String e2Name)
          Print out the contents of this constraint in a grammar format.
 
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(String s)
Debugging output.


parseMinMax

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


printMinMax

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


test

public boolean test(SceneElement e1,
                    SceneElement e2)
Test the constraint on the given elements; return true if all constraints are met, false otherwise.

Specified by:
test in interface RelationConstraint

toString

public String toString(String e1Name,
                       String e2Name)
Print out the contents of this constraint in a grammar format.


toString

public String toString()
Print out the contents of this constraint.

Overrides:
toString in class Object


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.