Class AxisConverter

Object
AxisConverter

public class AxisConverter extends Object
Converts to/from Axis to a String and int representations, checking for invalid input.

The int representation is is 0 for the X-axis, 1 for the Y-axis, and 2 for the Z-axis.

Author:
Owen Feehan
  • Field Details

    • INVALID_AXIS_STRING

      public static final String INVALID_AXIS_STRING
      Human-readable error message used when an invalid String-value for axis is passed.
      See Also:
    • INVALID_AXIS_INDEX

      public static final String INVALID_AXIS_INDEX
      Human-readable error message used when an invalid int-value for axis is passed.
      See Also:
  • Method Details

    • createFromString

      public static Axis createFromString(String axisAsString) throws AxisConversionException
      Maps a string of x, y, z (case ignored) to a corresponding axis type.
      Parameters:
      axisAsString - the string indicating the axis.
      Returns:
      the corresponding Axis for axisAsString.
      Throws:
      AxisConversionException - if axisAsString does not correspond to an axis.
    • dimensionIndexFor

      public static int dimensionIndexFor(Axis axis) throws AxisConversionException
      A corresponding index representing for the dimension an Axis represents.

      This is 0 for the X-axis, 1 for the Y-axis, and 2 for the Z-axis.

      Parameters:
      axis - the axis to find an index for.
      Returns:
      the index corresponding to axis.
      Throws:
      AxisConversionException - if axis is unrecognized.
    • valueFor

      public static int valueFor(Axis axis, int x, int y, int z)
      Multiplexes the a value corresponding to a particular axis.
      Parameters:
      axis - the axis used to select a value.
      x - a possible-value, representing the X-axis.
      y - a possible-value, representing the Y-axis.
      z - a possible-value, representing the Z-axis.
      Returns:
      one of x or y or z corresponding to axis.