util
Enum Corner

java.lang.Object
  extended by java.lang.Enum<Corner>
      extended by util.Corner
All Implemented Interfaces:
Serializable, Comparable<Corner>, Orientation

public enum Corner
extends Enum<Corner>
implements Orientation

Representation of the four corners in a rectangular figure.

Version:
April 25, 2007

Enum Constant Summary
LOWER_LEFT
           
LOWER_RIGHT
           
UPPER_LEFT
           
UPPER_RIGHT
           
 
Method Summary
 Corner clockwise()
          Returns the next clockwise rotation.
 Corner counterClockwise()
          Returns the next counter-clockwise rotation.
static Corner fromString(String str)
          Returns the enum representation of a string.
 Point getOffset(Point loc)
          Returns a point offset in this direction according to inverted cartesian coordinates (the same as Graphics objects).
 boolean isLeft()
          Returns if the corner is left or right.
 boolean isUpper()
          Returns if the corner is upper or lower.
static Corner random()
          Returns a random corner.
 Corner reverse()
          Returns the opposite facing direction.
 String toString()
           
static Corner valueOf(String name)
          Returns the enum constant of this type with the specified name.
static Corner[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
compareTo, equals, getDeclaringClass, hashCode, name, ordinal, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

UPPER_LEFT

public static final Corner UPPER_LEFT

UPPER_RIGHT

public static final Corner UPPER_RIGHT

LOWER_RIGHT

public static final Corner LOWER_RIGHT

LOWER_LEFT

public static final Corner LOWER_LEFT
Method Detail

values

public static Corner[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (Corner c : Corner.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static Corner valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

fromString

public static Corner fromString(String str)
Returns the enum representation of a string. This is case sensitive.

Parameters:
str - toString representation of this enum
Returns:
enum associated with a string
Throws:
IllegalArgumentException - if argument is not represented by this enum.

random

public static Corner random()
Returns a random corner.

Returns:
randomly generated corner

clockwise

public Corner clockwise()
Description copied from interface: Orientation
Returns the next clockwise rotation.

Specified by:
clockwise in interface Orientation
Returns:
next clockwise orientation

counterClockwise

public Corner counterClockwise()
Description copied from interface: Orientation
Returns the next counter-clockwise rotation.

Specified by:
counterClockwise in interface Orientation
Returns:
next counter-clockwise orientation

reverse

public Corner reverse()
Description copied from interface: Orientation
Returns the opposite facing direction.

Specified by:
reverse in interface Orientation
Returns:
opposing direction

getOffset

public Point getOffset(Point loc)
Description copied from interface: Orientation
Returns a point offset in this direction according to inverted cartesian coordinates (the same as Graphics objects). In other words coordinates grow toward the lower-right, with shifts as follows: Up = -Y Down = +Y Left = -X Right = +X

Specified by:
getOffset in interface Orientation
Parameters:
loc - location to be offset
Returns:
shifted point

isUpper

public boolean isUpper()
Returns if the corner is upper or lower.

Returns:
true if enum is upper, false otherwise

isLeft

public boolean isLeft()
Returns if the corner is left or right.

Returns:
true if enum is left, false otherwise

toString

public String toString()
Overrides:
toString in class Enum<Corner>