public static enum Map.Direction extends java.lang.Enum<Map.Direction>
| Modifier and Type | Field and Description |
|---|---|
static java.util.List<Map.Direction> |
allDirections |
static java.util.List<Map.Direction> |
corners |
private int |
evenDX |
private int |
evenDY |
static java.util.List<Map.Direction> |
longSides |
static int |
NUMBER_OF_DIRECTIONS |
private int |
oddDX
The direction increments.
|
private int |
oddDY |
| Modifier and Type | Method and Description |
|---|---|
static Map.Direction |
angleToDirection(double angle)
Convert an angle (radians) to a direction.
|
Map.Direction[] |
getClosestDirections(java.lang.String logMe,
java.util.Random random)
Creates an array of the directions in an order that favours
a supplied one.
|
java.lang.String |
getNameKey()
Get the name key for this direction.
|
Map.Direction |
getNextDirection()
Get the next direction after this one (clockwise).
|
Map.Direction |
getPreviousDirection()
Get the previous direction after this one (anticlockwise).
|
static Map.Direction |
getRandomDirection(java.lang.String logMe,
java.util.Random random)
Gets a random Direction.
|
static Map.Direction[] |
getRandomDirections(java.lang.String logMe,
java.util.Random random)
Creates an array of the eight directions in a random order.
|
Map.Direction |
getReverseDirection()
Gets the reverse direction of this one.
|
private Map.Direction |
rotate(int n)
Gets this direction rotated by n places.
|
int |
stepX(int x,
int y)
Step an x coordinate in this direction.
|
int |
stepY(int x,
int y)
Step a y coordinate in this direction.
|
static Map.Direction |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static Map.Direction[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final Map.Direction N
public static final Map.Direction NE
public static final Map.Direction E
public static final Map.Direction SE
public static final Map.Direction S
public static final Map.Direction SW
public static final Map.Direction W
public static final Map.Direction NW
public static final int NUMBER_OF_DIRECTIONS
public static final java.util.List<Map.Direction> allDirections
public static final java.util.List<Map.Direction> longSides
public static final java.util.List<Map.Direction> corners
private final int oddDX
private final int oddDY
private final int evenDX
private final int evenDY
public static Map.Direction[] values()
for (Map.Direction c : Map.Direction.values()) System.out.println(c);
public static Map.Direction valueOf(java.lang.String name)
name - the name of the enum constant to be returned.java.lang.IllegalArgumentException - if this enum type has no constant with the specified namejava.lang.NullPointerException - if the argument is nullpublic java.lang.String getNameKey()
public int stepX(int x,
int y)
x - The x coordinate.y - The y coordinate.public int stepY(int x,
int y)
x - The x coordinate.y - The y coordinate.private Map.Direction rotate(int n)
n - The number of places to rotate
(-#directions <= n <= #directions).public Map.Direction getNextDirection()
Direction.public Map.Direction getPreviousDirection()
Direction.public Map.Direction getReverseDirection()
Direction.public static Map.Direction getRandomDirection(java.lang.String logMe, java.util.Random random)
logMe - A string to log with the random results.random - A Random number source.Direction value.public static Map.Direction[] getRandomDirections(java.lang.String logMe, java.util.Random random)
logMe - A string to log with the random results.random - A Random number source.Directions in a random order.public Map.Direction[] getClosestDirections(java.lang.String logMe, java.util.Random random)
logMe - A string to log with the random results.random - A Random number source.Directions favouring this one.public static Map.Direction angleToDirection(double angle)
angle - The angle to convert.Direction.