world
Class Location

java.lang.Object
  extended byworld.Location

public class Location
extends java.lang.Object

A location.

Author:
Piotrek

Field Summary
static java.lang.String CONTINENTAL_PART
          A special value for the property of @see #islandName indicating this location lies on the continental part of the land.
 java.lang.String continentName
          A name of the continentName this location belongs to.
 java.lang.String islandName
          A name of the island this point lies on or a special value of @see #CONTINENTAL_PART.
 int x
          The x coordinate of the object.
 int y
          The y coordinate of the object.
 
Constructor Summary
Location(int x, int y)
          Constructor.
 
Method Summary
 boolean equals(java.lang.Object other)
           
static double GetDistance(Location x, Location y)
          Gets the distance between two locations.
 boolean IsEqual(Location other)
          Compares this location to the other one.
 boolean IsInRange(int x1, int y1, int x2, int y2)
          Gets a boolean value indicating whether this location lies in the given rectangle.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

x

public int x
The x coordinate of the object.


y

public int y
The y coordinate of the object.


continentName

public java.lang.String continentName
A name of the continentName this location belongs to. An empty string, if no info is available.


CONTINENTAL_PART

public static final java.lang.String CONTINENTAL_PART
A special value for the property of @see #islandName indicating this location lies on the continental part of the land.

See Also:
Constant Field Values

islandName

public java.lang.String islandName
A name of the island this point lies on or a special value of @see #CONTINENTAL_PART. An empty string, if no info is available.

Constructor Detail

Location

public Location(int x,
                int y)
Constructor.

Parameters:
x - The x coordinate of object.
y - The y coordinate of object.
Method Detail

IsEqual

public boolean IsEqual(Location other)
Compares this location to the other one. Two locations are equal if they have the same x and y and all the other values equal if they are set in both locations.

Parameters:
other - The location this one is to be compared to.
Returns:
A value indicating whether both locations are equal.

equals

public boolean equals(java.lang.Object other)
See Also:
Object.equals(java.lang.Object)

GetDistance

public static double GetDistance(Location x,
                                 Location y)
Gets the distance between two locations. The world is a square, but the roundness of the world is simulated (East-West continuity).

Parameters:
x - One of the points.
y - The second of the points.
Returns:
The distance between the two given locations.

IsInRange

public boolean IsInRange(int x1,
                         int y1,
                         int x2,
                         int y2)
Gets a boolean value indicating whether this location lies in the given rectangle. The world is a square, but the roundness of the world is simulated (East-West continuity). The order of the given corners of the rectangle is irrelevant - in both cases they are treated the same; the rectangle with the diagonal (0, 0) - (1, 1) is the same as the one with the diagonal (1, 1) - (0, 0).

Parameters:
x1 - The X coordinate of the first corner of the rectangle.
y1 - The Y coordinate of the first corner of the rectangle.
x2 - The X coordinate of the second corner of the rectangle.
y2 - The Y coordinate of the second corner of the rectangle.
Returns:
A boolean value indicating whether this location lies in the given rectangle.