Class Coordinate2D

java.lang.Object
xyz.calcugames.levelz.coord.Coordinate2D
All Implemented Interfaces:
Comparable<Coordinate>, Coordinate

public final class Coordinate2D extends Object implements Coordinate
Represents a 2-Dimensional Coordinate.
  • Constructor Details

    • Coordinate2D

      public Coordinate2D(int x, int y)
      Constructs a 2D Coordinate.
      Parameters:
      x - X Value
      y - Y Value
    • Coordinate2D

      public Coordinate2D(int[] xy)
      Constructs a 2D Coordinate.
      Parameters:
      xy - Array of X and Y Values
    • Coordinate2D

      public Coordinate2D(double x, double y)
      Constructs a 2D Coordinate.
      Parameters:
      x - X Value
      y - Y Value
    • Coordinate2D

      public Coordinate2D(double[] xy)
      Constructs a 2D Coordinate.
      Parameters:
      xy - Array of X and Y Values
  • Method Details

    • getX

      public double getX()
      Gets the X Value of the Coordinate.
      Returns:
      X Value
    • setX

      public void setX(double x)
      Sets the X Value of the Coordinate.
      Parameters:
      x - X Value
    • setX

      public void setX(int x)
      Gets the Y Value of the Coordinate.
      Parameters:
      x - X Value
    • getY

      public double getY()
      Gets the Y Value of the Coordinate.
      Returns:
      Y Value
    • setY

      public void setY(int y)
      Sets the Y Value of the Coordinate.
      Parameters:
      y - Y Value
    • setY

      public void setY(double y)
      Sets the Y Value of the Coordinate.
      Parameters:
      y - Y Value
    • getMagnitude

      public double getMagnitude()
      Description copied from interface: Coordinate
      Gets the magnitude of the Coordinate.
      Specified by:
      getMagnitude in interface Coordinate
      Returns:
      Coordinate Magnitude
    • getDimension

      public Dimension getDimension()
      Description copied from interface: Coordinate
      Gets the dimension of the Coordinate.
      Specified by:
      getDimension in interface Coordinate
      Returns:
      Coordinate Dimension
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Coordinate
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Specified by:
      toString in interface Coordinate
      Overrides:
      toString in class Object
    • fromString

      @NotNull public static @NotNull Coordinate2D fromString(String point)
      Parses a 2D Coordinate from a string.
      Parameters:
      point - String
      Returns:
      2D Coordinate