Class Location

  • All Implemented Interfaces:
    Cloneable

    public final class Location
    extends Object
    implements Cloneable
    A location in a two-dimensional plane.
    • Field Detail

      • ZERO

        public static final Location ZERO
    • Constructor Detail

      • Location

        public Location()
      • Location

        public Location​(int x,
                        int y)
        Creates a Location instance.
        Parameters:
        x - The X coordinate of this location.
        y - The Y coordinate of this location.
      • Location

        public Location​(Location other)
        Creates a location from another location instance.
        Parameters:
        other - A location instance from which to create the location.
    • Method Detail

      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • offset

        public Location offset​(int dx,
                               int dy)
        Get a location translated by the specified amount.
        Parameters:
        dx - The amount to offset the x-coordinate.
        dy - The amount to offset the y-coordinate.
        Returns:
        A location translated by the specified amount.
      • offset

        public Location offset​(Location amount)
        Get a location translated by the specified amount.
        Parameters:
        amount - The amount to offset.
        Returns:
        A location translated by the specified amount.
      • scale

        public Location scale​(double scaleRatio)
        Get a scaled location.
        Parameters:
        scaleRatio - The ratio by which to scale the results.
        Returns:
        A scaled copy of the current location.
      • getX

        public int getX()
        Returns:
        The X coordinate of this location.
      • getY

        public int getY()
        Returns:
        The Y coordinate of this location.
      • toStringForFilename

        public String toStringForFilename()