All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class att.grappa.DoublePoint

java.lang.Object
   |
   +----att.grappa.DoublePoint

public class DoublePoint
extends Object
implements Serializable
A re-implementation of java.awt.Point using doubles instead of ints.

Version:
1.1, 30 Sep 1999; Copyright 1996 - 1999 by AT&T Corp.
Author:
John Mocenigo, Research @ AT&T Labs

Variable Index

 o x
The x coordinate.
 o y
The y coordinate.

Constructor Index

 o DoublePoint()
Constructs and initializes a point at the origin (0, 0) of the coordinate space.
 o DoublePoint(double, double)
Constructs and initializes a point at the specified (xy) location in the coordinate space.
 o DoublePoint(DoublePoint)
Constructs and initializes a point with the same location as the specified DoublePoint object.
 o DoublePoint(Point)
Constructs and initializes a DoublePoint from the specified Point.

Method Index

 o equals(Object)
Determines whether two points are equal.
 o getApproximation()
Rounds the DoublePoint to a standard (integer) Point
 o hashCode()
Returns the hashcode for this point.
 o interpolate(double, DoublePoint, DoublePoint)
Computes the point that lies some fraction of the distance along the line connecting the two supplied points.
 o scale(double)
Uniformly scales the point.
 o scale(double, double)
Scales the point.
 o setLocation(double, double)
Changes the point to have the specificed location.
 o setLocation(DoublePoint)
Sets the location of the point to the specificed location.
 o setLocation(int, int)
Sets the location of this point.
 o toString()
Returns a representation of this point and its location in the (xy) coordinate space as a string.
 o translate(double, double)
Translates this point, at location (xy), by dx along the x axis and dy along the y axis so that it now represents the point (x + dx, y + dy).

Variables

 o x
 public double x
The x coordinate.

 o y
 public double y
The y coordinate.

Constructors

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

Parameters:
x - the x coordinate.
y - the y coordinate.
 o DoublePoint
 public DoublePoint(DoublePoint p)
Constructs and initializes a point with the same location as the specified DoublePoint object.

Parameters:
p - a point.
 o DoublePoint
 public DoublePoint(double x,
                    double y)
Constructs and initializes a point at the specified (xy) location in the coordinate space.

Parameters:
x - the x coordinate.
y - the y coordinate.
 o DoublePoint
 public DoublePoint(Point pt)
Constructs and initializes a DoublePoint from the specified Point.

Parameters:
pt - the initial java.awt.Point.

Methods

 o setLocation
 public void setLocation(int x,
                         int y)
Sets the location of this point.

Parameters:
x - new X value.
y - new Y value.
 o getApproximation
 public Point getApproximation()
Rounds the DoublePoint to a standard (integer) Point

Returns:
the DoublePoint rounded to the nearest Point
 o scale
 public void scale(double xFactor,
                   double yFactor)
Scales the point.

Parameters:
xFactor - the x-axis scale factor.
yFactor - the y-axis scale factor.
 o scale
 public void scale(double factor)
Uniformly scales the point.

Parameters:
factor - the scale factor.
 o interpolate
 public static DoublePoint interpolate(double fraction,
                                       DoublePoint Pt0,
                                       DoublePoint Pt1) throws IllegalArgumentException
Computes the point that lies some fraction of the distance along the line connecting the two supplied points.

Parameters:
fraction - the fraction of the distance along the line at which to compute the new point (a 0 value indicates point Pt0 and a 1 value indicates point Pt1).
Pt0 - the starting point of the connecting line
Pt1 - the ending point of the connecting line
Returns:
the point lying at the specified portion along the connecting line
Throws: IllegalArgumentException
whenever fraction is not between 0 and 1, inclusive
 o setLocation
 public void setLocation(DoublePoint p)
Sets the location of the point to the specificed location.

Parameters:
p - a point, the new location for this point.
 o setLocation
 public void setLocation(double x,
                         double y)
Changes the point to have the specificed location.

Parameters:
x - the x coordinate of the new location.
y - the y coordinate of the new location.
 o translate
 public void translate(double x,
                       double y)
Translates this point, at location (xy), by dx along the x axis and dy along the y axis so that it now represents the point (x + dx, y + dy).

Parameters:
dx - the distance to move this point along the x axis.
dy - the distance to move this point along the y axis.
 o hashCode
 public int hashCode()
Returns the hashcode for this point.

Returns:
a hash code for this point.
Overrides:
hashCode in class Object
 o equals
 public boolean equals(Object obj)
Determines whether two points are equal. Two instances of Point are equal if the values of their x and y member fields, representing their position in the coordinate space, are the same.

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.
Overrides:
equals in class Object
 o toString
 public String toString()
Returns a representation of this point and its location in the (xy) coordinate space as a string.

Returns:
a string representation of this point, including the values of its member fields.
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index