diva.sketch.parser2d
Class RelationUtilities

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

public class RelationUtilities
extends java.lang.Object

A set of static utilties for dealing with relationships between rectangles, specifying important sites on rectangles, or angular directions.

Version:
$Revision: 1.1 $

Field Summary
static int ADJACENT
          Positional constraint: is B adjacent to A?
static int CENTER
          The center direction constant.
static int CONTAINS
          Positional constraint: does A contain B?
static int EAST
          The east direction constant.
static int INTERSECTS
          Positional constraint: does A intersect B?
static int NO_SIZE_RATIO
          No size constant.
static int NORTH
          The north direction constant.
static int NORTH_EAST
          The north-east direction constant.
static int NORTH_WEST
          The north-west direction constant.
static int SOUTH
          The south direction constant.
static int SOUTH_EAST
          The south-east direction constant.
static int SOUTH_WEST
          The south-west direction constant.
static int WEST
          The west direction constant.
 
Method Summary
static void checkSite(int site)
          Check the given site's validity; throw an illegal argument exception if it is not valid.
static double directionToAngle(int direction)
          Return the angle in radians corresponding to the given direction constant (EAST is 0 radians).
static int parseDirection(java.lang.String dir)
          Return a direction constant given a string.
static int parseOverlap(java.lang.String overlap)
          Return a position constant given a string.
static java.lang.String printDirection(int direction)
          Return a string given a direction constant.
static java.lang.String printOverlap(int overlap)
          Return a string given a position constant.
static double siteX(java.awt.geom.Rectangle2D r, int site)
          Return the X coordinate of the given site for the given rectangle.
static double siteY(java.awt.geom.Rectangle2D r, int site)
          Return the Y coordinate of the given site for the given rectangle.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INTERSECTS

public static final int INTERSECTS
Positional constraint: does A intersect B?

CONTAINS

public static final int CONTAINS
Positional constraint: does A contain B?

ADJACENT

public static final int ADJACENT
Positional constraint: is B adjacent to A?

NORTH_EAST

public static final int NORTH_EAST
The north-east direction constant.

NORTH

public static final int NORTH
The north direction constant.

NORTH_WEST

public static final int NORTH_WEST
The north-west direction constant.

NO_SIZE_RATIO

public static final int NO_SIZE_RATIO
No size constant.

WEST

public static final int WEST
The west direction constant.

SOUTH_WEST

public static final int SOUTH_WEST
The south-west direction constant.

SOUTH

public static final int SOUTH
The south direction constant.

SOUTH_EAST

public static final int SOUTH_EAST
The south-east direction constant.

EAST

public static final int EAST
The east direction constant.

CENTER

public static final int CENTER
The center direction constant.
Method Detail

checkSite

public static void checkSite(int site)
Check the given site's validity; throw an illegal argument exception if it is not valid.

directionToAngle

public static double directionToAngle(int direction)
Return the angle in radians corresponding to the given direction constant (EAST is 0 radians). This method throws an IllegalArgumentException if it gets CENTER or an input it doesn't recognize.

parseDirection

public static int parseDirection(java.lang.String dir)
Return a direction constant given a string. This method is case insensitive, and accepts input of format "NORTH_EAST", "NORTH-EAST" or "NORTHEAST". This method throws an IllegalArgumentException if it gets an input it doesn't recognize.

parseOverlap

public static int parseOverlap(java.lang.String overlap)
Return a position constant given a string. This method is case insensitive, and throws an illegal argument exception if it gets an input it doesn't recognize.

printOverlap

public static java.lang.String printOverlap(int overlap)
Return a string given a position constant. This method throws an IllegalArgumentException if it gets an input it doesn't recognize.

printDirection

public static java.lang.String printDirection(int direction)
Return a string given a direction constant. This method throws an IllegalArgumentException if it gets an input it doesn't recognize.

siteX

public static double siteX(java.awt.geom.Rectangle2D r,
                           int site)
Return the X coordinate of the given site for the given rectangle.

siteY

public static double siteY(java.awt.geom.Rectangle2D r,
                           int site)
Return the Y coordinate of the given site for the given rectangle.