Package org.refcodes.checkerboard
Enum MooreNeighbourhood
- java.lang.Object
-
- java.lang.Enum<MooreNeighbourhood>
-
- org.refcodes.checkerboard.MooreNeighbourhood
-
- All Implemented Interfaces:
Neighbourhood<MooreNeighbourhood>
,org.refcodes.graphical.Position
,org.refcodes.graphical.PosXAccessor
,org.refcodes.graphical.PosYAccessor
public enum MooreNeighbourhood extends java.lang.Enum<MooreNeighbourhood> implements Neighbourhood<MooreNeighbourhood>
Definitions of the Moore neighbourhood.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.graphical.Position
org.refcodes.graphical.Position.PositionBuilder<B extends org.refcodes.graphical.Position.PositionBuilder<B>>, org.refcodes.graphical.Position.PositionMutator, org.refcodes.graphical.Position.PositionProperty, org.refcodes.graphical.Position.PositionPropertyBuilder
-
-
Enum Constant Summary
Enum Constants Enum Constant Description BOTTOM
BOTTOM_LEFT
BOTTOM_RIGHT
LEFT
RIGHT
TOP
TOP_LEFT
TOP_RIGHT
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MooreNeighbourhood
clockwiseNext()
Returns the next clockwise state relative to the current state.MooreNeighbourhood
clockwisePrevious()
Returns the next anti-clockwise state relative to the current state.int
getPositionX()
Returns the relative X position to position (0, 0).int
getPositionY()
Returns the relative Y position to position (0, 0).static MooreNeighbourhood
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static MooreNeighbourhood[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.-
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Methods inherited from interface org.refcodes.checkerboard.Neighbourhood
next
-
-
-
-
Enum Constant Detail
-
LEFT
public static final MooreNeighbourhood LEFT
-
TOP_LEFT
public static final MooreNeighbourhood TOP_LEFT
-
TOP
public static final MooreNeighbourhood TOP
-
TOP_RIGHT
public static final MooreNeighbourhood TOP_RIGHT
-
RIGHT
public static final MooreNeighbourhood RIGHT
-
BOTTOM_RIGHT
public static final MooreNeighbourhood BOTTOM_RIGHT
-
BOTTOM
public static final MooreNeighbourhood BOTTOM
-
BOTTOM_LEFT
public static final MooreNeighbourhood BOTTOM_LEFT
-
-
Method Detail
-
values
public static MooreNeighbourhood[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (MooreNeighbourhood c : MooreNeighbourhood.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static MooreNeighbourhood valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
getPositionX
public int getPositionX()
Returns the relative X position to position (0, 0).- Specified by:
getPositionX
in interfaceorg.refcodes.graphical.PosXAccessor
- Returns:
- The relative position X to the (0,0) coordinate.
-
getPositionY
public int getPositionY()
Returns the relative Y position to position (0, 0).- Specified by:
getPositionY
in interfaceorg.refcodes.graphical.PosYAccessor
- Returns:
- The relative position Y to the (0,0) coordinate.
-
clockwiseNext
public MooreNeighbourhood clockwiseNext()
Returns the next clockwise state relative to the current state. Imagine the states as the positions on a clock, next toTOP
would beTOP_RIGHT
, next toTOP_RIGHT
would beRIGHT
, and so on (clockwise).- Specified by:
clockwiseNext
in interfaceNeighbourhood<MooreNeighbourhood>
- Returns:
- The next state relative to the current state.
-
clockwisePrevious
public MooreNeighbourhood clockwisePrevious()
Returns the next anti-clockwise state relative to the current state. Imagine the states as the positions on a clock, next toTOP
would beTOP_LEFT
, next toTOP_LEFT
would beLEFT
, and so on (anti-clockwise).- Specified by:
clockwisePrevious
in interfaceNeighbourhood<MooreNeighbourhood>
- Returns:
- The next state relative to the current state.
-
-