GOV.nasa.gsfc.sea.util
Class DoublePoint

java.lang.Object
  |
  +--GOV.nasa.gsfc.sea.util.DoublePoint
All Implemented Interfaces:
java.io.Serializable

public final class DoublePoint
extends java.lang.Object
implements java.io.Serializable

DoublePoint is a version of java.awt.Point that stores the x and y components as doubles rather than ints. The code is an almost exact copy of java.awt.Point with the ints replaced with doubles.

This code was developed by NASA, Goddard Space Flight Center, Code 588 for the Scientist's Expert Assistant (SEA) project.

Author:
J. Jones / 588
See Also:
Point, Serialized Form

Field Summary
 double x
          The x coordinate.
 double y
          The y coordinate.
 
Constructor Summary
DoublePoint()
          Constructs and initializes a point at the origin (0, 0) of the coordinate space.
DoublePoint(double x, double y)
          Constructs and initializes a point at the specified (x, y) location in the coordinate space.
DoublePoint(DoublePoint p)
          Constructs and initializes a point with the same location as the specified DoublePoint object.
DoublePoint(java.awt.Point p)
          Constructs and initializes a point with the same location as the specified Point object.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Determines whether two points are equal.
 int hashCode()
          Returns the hashcode for this DoublePoint.
 void move(double x, double y)
          Moves this point to the specificed location in the (x, y) coordinate plane.
 java.lang.String toString()
          Returns a string representation of this point and its location in the (x, y) coordinate space.
 void translate(double dx, double dy)
          Translates this point, at location (x, y), by dx along the x axis and dy along the y axis so that it now represents the point (x + dx, y + dy).
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public double x
The x coordinate.

y

public double y
The y coordinate.
Constructor Detail

DoublePoint

public DoublePoint()
Constructs and initializes a point at the origin (0, 0) of the coordinate space.

DoublePoint

public DoublePoint(DoublePoint p)
Constructs and initializes a point with the same location as the specified DoublePoint object.

DoublePoint

public DoublePoint(java.awt.Point p)
Constructs and initializes a point with the same location as the specified Point object.

DoublePoint

public DoublePoint(double x,
                   double y)
Constructs and initializes a point at the specified (x, y) location in the coordinate space.
Method Detail

move

public void move(double x,
                 double y)
Moves this point to the specificed location in the (x, y) coordinate plane.

translate

public void translate(double dx,
                      double dy)
Translates this point, at location (x, y), by dx along the x axis and dy along the y axis so that it now represents the point (x + dx, y + dy).

equals

public boolean equals(java.lang.Object obj)
Determines whether two points are equal. Two instances of DoublePoint are equal if the values of their x and y member fields, representing their position in the coordinate space, are the same.
Overrides:
equals in class java.lang.Object
Parameters:
obj - an object to be compared with this point.
Returns:
true if the object to be compared is an instance of DoublePoint and has the same values; false otherwise.

hashCode

public int hashCode()
Returns the hashcode for this DoublePoint. Hashing algorithm taken from java.awt.geom.Point2D.
Overrides:
hashCode in class java.lang.Object
Returns:
a hash code for this DoublePoint.

toString

public java.lang.String toString()
Returns a string representation of this point and its location in the (x, y) coordinate space.
Overrides:
toString in class java.lang.Object
Returns:
a string representation of this point.