diva.sketch.parser2d
Class DirectedRelation

java.lang.Object
  |
  +--diva.sketch.parser2d.DirectedRelation
Direct Known Subclasses:
AngleRelation, AreaRatioRelation, HeightRatioRelation, OverlapRelation, WidthRatioRelation

public abstract class DirectedRelation
extends java.lang.Object
implements Relation

A directed relation is a relation where the value being calculated is relative to one of the rectangles in particular. The DirectedRelation abstract class provides constants by which the user can specify which rectangle the relation is relative to. An example of a directed relation is the angle between two rectangles: calculating relative to one rectangle might produce 30 degrees; relative to the other would be 210 degrees.

The significance of the "which" rectangle is totally dependent on the implementation of the relation and should be documented in the subclass documentation.

Version:
$Revision: 1.1 $

Field Summary
static int FIRST_RECT
          Specify the first rectangle of the relational query.
static int SECOND_RECT
          Specify the second rectangle of the relational query.
 
Constructor Summary
DirectedRelation(int which)
          Construct the relation query whose ratio is determined by the "which" argument as either the FIRST_RECT or SECOND_RECT.
 
Method Summary
abstract  double apply(java.awt.geom.Rectangle2D r1, java.awt.geom.Rectangle2D r2)
          Apply the directed relation.
abstract  java.lang.String getName()
          The name of this relation.
 int getWhich()
          Return which rectangle the calculation is relative to.
static int parseWhich(java.lang.String which)
          Parse the string constants FIRST_RECT or SECOND_RECT to their integer constant equivalents.
static java.lang.String printWhich(int which)
          Convert the integer constant FIRST_RECT or SECOND_RECT to a string for printing.
 void setWhich(int which)
          Set which rectangle the calculation is relative to.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FIRST_RECT

public static int FIRST_RECT
Specify the first rectangle of the relational query.

SECOND_RECT

public static int SECOND_RECT
Specify the second rectangle of the relational query.
Constructor Detail

DirectedRelation

public DirectedRelation(int which)
Construct the relation query whose ratio is determined by the "which" argument as either the FIRST_RECT or SECOND_RECT.
See Also:
setWhich(int)
Method Detail

apply

public abstract double apply(java.awt.geom.Rectangle2D r1,
                             java.awt.geom.Rectangle2D r2)
Apply the directed relation.
Specified by:
apply in interface Relation

getName

public abstract java.lang.String getName()
The name of this relation.
Specified by:
getName in interface Relation

getWhich

public int getWhich()
Return which rectangle the calculation is relative to.
See Also:
setWhich(int)

setWhich

public void setWhich(int which)
Set which rectangle the calculation is relative to. The significance of the "which" rectangle totally depends on the implementation of the relation and should be documented in the subclass documentation.

printWhich

public static java.lang.String printWhich(int which)
Convert the integer constant FIRST_RECT or SECOND_RECT to a string for printing.

parseWhich

public static int parseWhich(java.lang.String which)
Parse the string constants FIRST_RECT or SECOND_RECT to their integer constant equivalents.