diva.sketch.parser2d
Class RelationUtilities

java.lang.Object
  extended by diva.sketch.parser2d.RelationUtilities

public class RelationUtilities
extends Object

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

Version:
$Revision: 1.9 $
Author:
Michael Shilman (michaels@eecs.berkeley.edu)

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 Relation makeRelation(String relationType)
          Return a relation with the given name and the two given sites.
static Relation makeRelation(String relationType, int site1, int site2)
          Return a relation with the given name and the two given sites.
static int parseDirection(String dir)
          Return a direction constant given a string.
static int parseOverlap(String overlap)
          Return a position constant given a string.
static int parseSite(String site)
          Return a site constant given a string.
static String printDirection(int direction)
          Return a string given a direction constant.
static String printOverlap(int overlap)
          Return a string given a position constant.
static String printSite(int site)
          Return a string given a site constant.
static double siteX(Rectangle2D r, int site)
          Return the X coordinate of the given site for the given rectangle.
static double siteY(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?

See Also:
Constant Field Values

CONTAINS

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

See Also:
Constant Field Values

ADJACENT

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

See Also:
Constant Field Values

NORTH_EAST

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

See Also:
Constant Field Values

NORTH

public static final int NORTH
The north direction constant.

See Also:
Constant Field Values

NORTH_WEST

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

See Also:
Constant Field Values

NO_SIZE_RATIO

public static final int NO_SIZE_RATIO
No size constant.

See Also:
Constant Field Values

WEST

public static final int WEST
The west direction constant.

See Also:
Constant Field Values

SOUTH_WEST

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

See Also:
Constant Field Values

SOUTH

public static final int SOUTH
The south direction constant.

See Also:
Constant Field Values

SOUTH_EAST

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

See Also:
Constant Field Values

EAST

public static final int EAST
The east direction constant.

See Also:
Constant Field Values

CENTER

public static final int CENTER
The center direction constant.

See Also:
Constant Field Values
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.


parseSite

public static int parseSite(String site)
Return a site 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.


parseDirection

public static int parseDirection(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(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 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.


printSite

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


printDirection

public static 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(Rectangle2D r,
                           int site)
Return the X coordinate of the given site for the given rectangle.


makeRelation

public static Relation makeRelation(String relationType)
Return a relation with the given name and the two given sites. If the given relation uses sites, the default RelationUtilities.CENTER will be used.


makeRelation

public static Relation makeRelation(String relationType,
                                    int site1,
                                    int site2)
Return a relation with the given name and the two given sites. If the given relation does not use sites, these arguments are ignored.


siteY

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



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