com.strangelight.misc.hex
Class HexDirection

java.lang.Object
  |
  +--com.strangelight.misc.hex.HexDirection
All Implemented Interfaces:
_Testable, java.lang.Cloneable

public class HexDirection
extends java.lang.Object
implements java.lang.Cloneable, _Testable

One of the six points on our hexagonal compass.

Because there are only six possible directions -- and hence no need for more than six distinct HexDirection objects, there is no public constructor. Rather, one "constructs" a HexDirection object simply by assigning or cloning one of these constants (public static final fields): HexDirection.N, HexDirection.NE, HexDirection.SE, HexDirection.S , HexDirection.SW, HexDirection.NW.

For example, one could "construct" a HexDirection object which pointed north-west like so:

     HexDirection nw_pointing_object = HexDirection.NW;


Field Summary
static HexDirection N
          A HexDirection object representing NORTH.
static HexDirection NE
          A HexDirection object representing NORTH-EAST.
static HexDirection NW
          A HexDirection object representing NORTH-WEST.
static HexDirection S
          A HexDirection object representing SOUTH.
static HexDirection SE
          A HexDirection object representing SOUTH-EAST.
static HexDirection SW
          A HexDirection object representing SOUTH-WEST.
 
Constructor Summary
protected HexDirection()
           
 
Method Summary
static void _test_class()
           
 boolean equals(HexDirection x)
           
 HexDirection get_rotated(int steps_clockwise)
          Get the HexDirection obtained by rotating this HexDirection in 60-degree increments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

N

public static final HexDirection N
A HexDirection object representing NORTH.


NE

public static final HexDirection NE
A HexDirection object representing NORTH-EAST.


SE

public static final HexDirection SE
A HexDirection object representing SOUTH-EAST.


S

public static final HexDirection S
A HexDirection object representing SOUTH.


SW

public static final HexDirection SW
A HexDirection object representing SOUTH-WEST.


NW

public static final HexDirection NW
A HexDirection object representing NORTH-WEST.

Constructor Detail

HexDirection

protected HexDirection()
Method Detail

equals

public boolean equals(HexDirection x)

get_rotated

public HexDirection get_rotated(int steps_clockwise)
Get the HexDirection obtained by rotating this HexDirection in 60-degree increments.

Parameters:
steps_clockwise - The returned HexDirection will be obtained by rotating this HexDirection object (60 * steps_clockwise) degrees clockwise. Negative numbers will cause counter-clockwise rotation, as expected.
Returns:
the HexDirection obtained by rotating this HexDirection (60 * steps_clockwise) degrees clockwise.

_test_class

public static void _test_class()
                        throws java.lang.Exception
java.lang.Exception
See Also:
_Testable