Enum Class CompassDirection
- All Implemented Interfaces:
Serializable, Comparable<CompassDirection>, Constable
Represents one of the 9 compass-like positions in a 3x3 grid:
the eight cardinal/intercardinal directions plus the
CENTER.
Useful for things like UI grids and spatial layouts where both axis and directional grouping queries are needed.
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionbooleanisBottom()booleanbooleanbooleanisLeft()booleanisRight()booleanisTop()static final CompassDirectionof01(int x, int y) Returns theCompassDirectionthat corresponds to a given XY coordinate that ranges from [-1, -1] to [1, 1], where [0, 0] is theCENTER.static CompassDirectionReturns the enum constant of this class with the specified name.static CompassDirection[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
NORTH_WEST
-
NORTH
-
NORTH_EAST
-
WEST
-
CENTER
-
EAST
-
SOUTH_WEST
-
SOUTH
-
SOUTH_EAST
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified nameNullPointerException- if the argument is null
-
isLeft
public boolean isLeft()- Returns:
- true if this direction is on the left column
-
isCenterX
public boolean isCenterX()- Returns:
- true if this direction is on the middle column
-
isRight
public boolean isRight()- Returns:
- true if this direction is on the right column
-
isTop
public boolean isTop()- Returns:
- true if this direction is on the top row
-
isCenterY
public boolean isCenterY()- Returns:
- true if this direction is on the middle row
-
isBottom
public boolean isBottom()- Returns:
- true if this direction is on the bottom row
-
of01
Returns theCompassDirectionthat corresponds to a given XY coordinate that ranges from [-1, -1] to [1, 1], where [0, 0] is theCENTER.Negative X corresponds to western directions, whereas negative Y corresponds to northern directions.
-