us.zuercher.gpx2map.util
Class Point

java.lang.Object
  extended by us.zuercher.gpx2map.util.Point
Direct Known Subclasses:
Pixel

public class Point
extends Object

Point represents a location within an image.

Author:
Stephan Zuercher

Field Summary
private  int x
          X coordinate of point.
private  int y
          Y coordinate of point.
 
Constructor Summary
Point(int x, int y)
          Constructs a new Point with the given X and Y coordinates.
 
Method Summary
 boolean above(Point other)
          Tests if this pixel is strictly above another Point.
 boolean below(Point other)
          Tests if this pixel is strictly below another Point.
 double distanceTo(Point other)
          Computes the distance, in pixels, between this Point and another Point.
 boolean equals(Object other)
          Tests whether this Point is equal to another Point.
 boolean equals(Point other)
          Tests whether this Point is equal to another Point.
 int getX()
          Returns the X coordinate for this Point.
 int getY()
          Returns the Y coordinate for this Point.
 int hashCode()
          Computes a hash code for this Point.
 boolean leftOf(Point other)
          Tests if this pixel is strictly to the left of another Point.
 boolean rightOf(Point other)
          Tests if this pixel is strictly to the right of another Point.
 String toString()
          Returns a string representation of this Point.
 boolean within(Dimension bounds)
          Tests whether this Point lies within the given Dimension.
 boolean within(Rectangle rectangle)
          Tests whether this Point lies within the given Rectangle.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

x

private final int x
X coordinate of point.


y

private final int y
Y coordinate of point.

Constructor Detail

Point

public Point(int x,
             int y)
Constructs a new Point with the given X and Y coordinates.

Parameters:
x - x coordinate
y - y coordinate
Method Detail

getX

public int getX()
Returns the X coordinate for this Point.

Returns:
the X coordinate for this Point.

getY

public int getY()
Returns the Y coordinate for this Point.

Returns:
the Y coordinate for this Point.

distanceTo

public double distanceTo(Point other)
Computes the distance, in pixels, between this Point and another Point.

Parameters:
other - another Point
Returns:
distance between this and other in pixels

above

public boolean above(Point other)
Tests if this pixel is strictly above another Point.

Parameters:
other - another Point
Returns:
true if this.y < other.y

below

public boolean below(Point other)
Tests if this pixel is strictly below another Point.

Parameters:
other - another Point
Returns:
true if this.y > other.y

leftOf

public boolean leftOf(Point other)
Tests if this pixel is strictly to the left of another Point.

Parameters:
other - another Point
Returns:
true if this.x < other.x

rightOf

public boolean rightOf(Point other)
Tests if this pixel is strictly to the right of another Point.

Parameters:
other - another Point
Returns:
true if this.x > other.x

within

public boolean within(Dimension bounds)
Tests whether this Point lies within the given Dimension.

Parameters:
bounds - dimensions to test against
Returns:
true if this Point lies within the given Dimension

within

public boolean within(Rectangle rectangle)
Tests whether this Point lies within the given Rectangle.

Parameters:
rectangle - the recentangle to test against
Returns:
true if this Point lies within (including on the edges of) the given rectangle.

toString

public String toString()
Returns a string representation of this Point.

Overrides:
toString in class Object
Returns:
a string representation of this Point.

hashCode

public int hashCode()
Computes a hash code for this Point.

Overrides:
hashCode in class Object
Returns:
a hash code for this Point.

equals

public boolean equals(Point other)
Tests whether this Point is equal to another Point.

Parameters:
other - the other Point
Returns:
true if the X and Y coordinates of this and other match exactly.

equals

public boolean equals(Object other)
Tests whether this Point is equal to another Point.

Overrides:
equals in class Object
Parameters:
other - the other Point
Returns:
true if the X and Y coordinates of this and other match exactly.
Throws:
ClassCastException - if other is not a Point