Class Position

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable

    public class Position
    extends java.lang.Object
    implements java.io.Serializable, java.lang.Cloneable
    A position has two coordinates.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int x
      The x position.
      protected int y
      The y position.
    • Constructor Summary

      Constructors 
      Constructor Description
      Position()
      Create a position.
      Position​(int x, int y)
      Create a position.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object clone()
      Clone the object.
      boolean equals​(java.lang.Object o)
      Test if two positions are equal.
      static Position fromString​(java.lang.String spos)
      Convert a position string back to a position object.
      java.lang.String getPrintableX()
      Get the string representation for x.
      java.lang.String getPrintableY()
      Get the string representation for y.
      int getX()
      Get the x value.
      int getY()
      Get the y value.
      int hashCode()
      Calculate the hash code.
      void setX​(int x)
      Set x.
      void setY​(int y)
      Set y.
      java.lang.String toString()
      Get the string representation.
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • x

        protected int x
        The x position.
      • y

        protected int y
        The y position.
    • Constructor Detail

      • Position

        public Position()
        Create a position.
      • Position

        public Position​(int x,
                        int y)
        Create a position.
    • Method Detail

      • getX

        public int getX()
        Get the x value.
      • getY

        public int getY()
        Get the y value.
      • setX

        public void setX​(int x)
        Set x.
        Parameters:
        x -
      • setY

        public void setY​(int y)
        Set y.
        Parameters:
        y -
      • equals

        public boolean equals​(java.lang.Object o)
        Test if two positions are equal.
        Overrides:
        equals in class java.lang.Object
        Returns:
        True, if equal.
      • hashCode

        public int hashCode()
        Calculate the hash code.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        The hash code.
      • toString

        public java.lang.String toString()
        Get the string representation.
        Overrides:
        toString in class java.lang.Object
        Returns:
        The string representation.
      • getPrintableX

        public java.lang.String getPrintableX()
        Get the string representation for x.
        Returns:
        The string representation for y.
      • getPrintableY

        public java.lang.String getPrintableY()
        Get the string representation for y.
        Returns:
        The string representation for y.
      • clone

        public java.lang.Object clone()
        Clone the object.
        Overrides:
        clone in class java.lang.Object
        Returns:
        The clone.
      • fromString

        public static Position fromString​(java.lang.String spos)
        Convert a position string back to a position object. It can covert either "x y" and also the printable notation "[A..X] [1..X]".
        Parameters:
        spos - The position as string.
        Returns:
        The position object.