robocraft.common
Class Direction

java.lang.Object
  extended byrobocraft.common.CommonEnum
      extended byrobocraft.common.Direction
All Implemented Interfaces:
java.io.Serializable

public class Direction
extends robocraft.common.CommonEnum
implements java.io.Serializable

Direction represents one of the eight directions from a square to an adjacent square. Included are the Directions OMNI and NONE, which are "non-directional". The other Directions are considered "directional".

The only instances of this class are those found in the static fields described below. This means that instances can always be meaningfully compared using ==.

See Also:
Robot.getDirection(), AbstractRobotPlayer.setDirection(robocraft.common.Direction), Serialized Form

Field Summary
static Direction EAST
           
static Direction NONE
          Represents "no direction" for the purposes of methods dealing with Directions that need such a representation.
static Direction NORTH
           
static Direction NORTH_EAST
           
static Direction NORTH_WEST
           
static Direction OMNI
          Represents "every direction" for the purposes of methods dealing with Directions that need such a representation.
static Direction SOUTH
           
static Direction SOUTH_EAST
           
static Direction SOUTH_WEST
           
static Direction WEST
           
 
Method Summary
 boolean isDiagonal()
          Returns whether this direction represents the Direction from one square to an adjacent square that shares only a corner.
 Direction opposite()
          Returns the opposite of a directional Direction.
 Direction rotateLeft()
          Returns a Direction that is the result of rotating this Direction 45 degrees to the left.
 Direction rotateRight()
          Returns a Direction that is the result of rotating this Direction 45 degrees to the right.
 java.lang.String toString()
          Returns a textual representation of the Direction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

OMNI

public static final Direction OMNI
Represents "every direction" for the purposes of methods dealing with Directions that need such a representation.


NONE

public static final Direction NONE
Represents "no direction" for the purposes of methods dealing with Directions that need such a representation.


WEST

public static final Direction WEST

NORTH_WEST

public static final Direction NORTH_WEST

SOUTH_WEST

public static final Direction SOUTH_WEST

EAST

public static final Direction EAST

NORTH_EAST

public static final Direction NORTH_EAST

SOUTH_EAST

public static final Direction SOUTH_EAST

NORTH

public static final Direction NORTH

SOUTH

public static final Direction SOUTH
Method Detail

toString

public java.lang.String toString()
Returns a textual representation of the Direction.


opposite

public Direction opposite()
Returns the opposite of a directional Direction.

Throws:
java.lang.RuntimeException - if this Direction is non-directional

isDiagonal

public boolean isDiagonal()
Returns whether this direction represents the Direction from one square to an adjacent square that shares only a corner. This is true for NORTH_WEST, SOUTH_WEST, NORTH_EAST, and SOUTH_EAST.


rotateLeft

public Direction rotateLeft()
Returns a Direction that is the result of rotating this Direction 45 degrees to the left. Thus NORTH becomes NORTH_WEST, NORTH_WEST becomes WEST, and so on.

Throws:
java.lang.RuntimeException - if this Direction is non-directional

rotateRight

public Direction rotateRight()
Returns a Direction that is the result of rotating this Direction 45 degrees to the right. Thus NORTH becomes NORTH_EAST, NORTH_EAST becomes RIGHT, and so on.

Throws:
java.lang.RuntimeException - if this Direction is non-directional