diva.sketch.parser2d
Class AngleRelation

java.lang.Object
  |
  +--diva.sketch.parser2d.DirectedRelation
        |
        +--diva.sketch.parser2d.AngleRelation

public class AngleRelation
extends DirectedRelation

Calculate the direction angle (between 0 and 2*PI) between user-specified sites on a pair of rectangles. The angle is given relative to an "origin" rectangle, which is specified by the which parameter of the relation.

Version:
$Revision: 1.1 $

Fields inherited from class diva.sketch.parser2d.DirectedRelation
FIRST_RECT, SECOND_RECT
 
Constructor Summary
AngleRelation(int which)
          Use the center sites to calculate the relation, by default.
AngleRelation(int which, int site1, int site2)
          The sites of interest on the first and second rectangles, respectively.
 
Method Summary
 double apply(java.awt.geom.Rectangle2D r1, java.awt.geom.Rectangle2D r2)
          Return the angle between the constructor-specified sites on r1 and r2, respectively.
static void debug(java.lang.String s)
          Debugging output.
 java.lang.String getName()
          The name of this relation.
 int getSite1()
          Get the site for the first rectangle.
 int getSite2()
          Get the site for the second rectangle.
 void setSite1(int site1)
          Set the site for the first rectangle.
 void setSite2(int site2)
          Set the site for the second rectangle.
 java.lang.String toString()
          Print out the contents of this relation.
 
Methods inherited from class diva.sketch.parser2d.DirectedRelation
getWhich, parseWhich, printWhich, setWhich
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AngleRelation

public AngleRelation(int which)
Use the center sites to calculate the relation, by default.
See Also:
AngleRelation(int, int, int)

AngleRelation

public AngleRelation(int which,
                     int site1,
                     int site2)
The sites of interest on the first and second rectangles, respectively. The which argument specifies which rectangle (first or second) the angle is being measured relative to.
Method Detail

apply

public double apply(java.awt.geom.Rectangle2D r1,
                    java.awt.geom.Rectangle2D r2)
Return the angle between the constructor-specified sites on r1 and r2, respectively. The answer is given in degrees between 0 and 360.
Overrides:
apply in class DirectedRelation

debug

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

getName

public java.lang.String getName()
The name of this relation.
Overrides:
getName in class DirectedRelation

getSite1

public int getSite1()
Get the site for the first rectangle.

getSite2

public int getSite2()
Get the site for the second rectangle.

setSite1

public void setSite1(int site1)
Set the site for the first rectangle.

setSite2

public void setSite2(int site2)
Set the site for the second rectangle.

toString

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