us.asciiroth.client.core
Class Direction

java.lang.Object
  extended by us.asciiroth.client.core.Direction

public class Direction
extends java.lang.Object

A direction on the map, also representing the information to interact with adjacent terrain on the map or adjacent maps.


Field Summary
static Direction DOWN
          Down.
static Direction EAST
          East.
static Direction NONE
          No direction indicated.
static Direction NORTH
          North.
static Direction NORTHEAST
          Northeast.
static Direction NORTHWEST
          Northwest.
static Direction SOUTH
          South.
static Direction SOUTHEAST
          Southeast.
static Direction SOUTHWEST
          Southwest.
static Direction UP
          Up.
static Direction WEST
          West.
 
Method Summary
static Direction byName(java.lang.String name)
          Retrieve a direction by its name.
static java.util.List<Direction> getAdjacentDirections()
          A list of directions that lead to the adjacent cells on a map, not including up or down.
static java.util.List<Direction> getMapDirections()
          A list of directions that lead to adjacent boards, the cardinal directions as well as up and down.
 java.lang.String getName()
           
 Direction getReverseDirection()
           
 int getXDelta()
           
 int getYDelta()
           
static Direction inferDirection(Cell origin, Cell target)
          Given movement from a start cell to an origin cell, what's the direction that has to be taken?
 boolean isDiagonal()
          A diagonal direction: northeast, northwest, southeast or southwest.
 boolean isEasterly()
          A direction that includes an easterly component.
 boolean isEastWest()
          A direction that leads east or west.
 boolean isNortherly()
          A direction that includes a northerly component.
 boolean isNorthSouth()
          A direction that leads north or south.
 boolean isSoutherly()
          A direction that includes a southerly component.
 boolean isVertical()
          A direction that leads up or down.
 boolean isWesterly()
          A direction that includes a westerly component.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DOWN

public static final Direction DOWN
Down.


EAST

public static final Direction EAST
East.


NONE

public static final Direction NONE
No direction indicated.


NORTH

public static final Direction NORTH
North.


NORTHEAST

public static final Direction NORTHEAST
Northeast.


NORTHWEST

public static final Direction NORTHWEST
Northwest.


SOUTH

public static final Direction SOUTH
South.


SOUTHEAST

public static final Direction SOUTHEAST
Southeast.


SOUTHWEST

public static final Direction SOUTHWEST
Southwest.


UP

public static final Direction UP
Up.


WEST

public static final Direction WEST
West.

Method Detail

byName

public static Direction byName(java.lang.String name)
Retrieve a direction by its name.

Parameters:
name - the name of the direction, in lowercase
Returns:
the direction

getAdjacentDirections

public static java.util.List<Direction> getAdjacentDirections()
A list of directions that lead to the adjacent cells on a map, not including up or down.

Returns:
a list of directions

getMapDirections

public static java.util.List<Direction> getMapDirections()
A list of directions that lead to adjacent boards, the cardinal directions as well as up and down.

Returns:
a list of directions

getName

public java.lang.String getName()
Returns:
the name of this direction

getReverseDirection

public Direction getReverseDirection()
Returns:
the direction in the reverse direction of this one

getXDelta

public int getXDelta()
Returns:
the change in x necessary to move in this direction

getYDelta

public int getYDelta()
Returns:
the change in y necessary to move in this direction

inferDirection

public static Direction inferDirection(Cell origin,
                                       Cell target)
Given movement from a start cell to an origin cell, what's the direction that has to be taken?

Parameters:
origin -
target -
Returns:
the direction necessary to travel from "origin" to "target" cell.

isDiagonal

public boolean isDiagonal()
A diagonal direction: northeast, northwest, southeast or southwest.

Returns:
true if diagonal

isEasterly

public boolean isEasterly()
A direction that includes an easterly component.

Returns:
true if northeast, east, or southeast

isEastWest

public boolean isEastWest()
A direction that leads east or west.

Returns:
true if east or west

isNortherly

public boolean isNortherly()
A direction that includes a northerly component.

Returns:
true if northwest, north, or northeast

isNorthSouth

public boolean isNorthSouth()
A direction that leads north or south.

Returns:
true if north or south

isSoutherly

public boolean isSoutherly()
A direction that includes a southerly component.

Returns:
true if southwest, south, or southeast

isVertical

public boolean isVertical()
A direction that leads up or down.

Returns:
true if vertical

isWesterly

public boolean isWesterly()
A direction that includes a westerly component.

Returns:
true if northwest, west, or southwest

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

0.7

2009 Alx Dark