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
-
x
- The x coordinate.
-
y
- The y coordinate.
-
DoublePoint()
- Constructs and initializes a point at the origin
(0, 0) of the coordinate space.
-
DoublePoint(double, double)
- Constructs and initializes a point at the specified
(x, y) location in the coordinate space.
-
DoublePoint(DoublePoint)
- Constructs and initializes a point with the same location as
the specified
DoublePoint
object.
-
DoublePoint(Point)
- Constructs and initializes a
DoublePoint
from the specified Point
.
-
equals(Object)
- Determines whether two points are equal.
-
getApproximation()
- Rounds the
DoublePoint
to a standard (integer) Point
-
hashCode()
- Returns the hashcode for this point.
-
interpolate(double, DoublePoint, DoublePoint)
- Computes the point that lies some fraction of the distance along the line
connecting the two supplied points.
-
scale(double)
- Uniformly scales the point.
-
scale(double, double)
- Scales the point.
-
setLocation(double, double)
- Changes the point to have the specificed location.
-
setLocation(DoublePoint)
- Sets the location of the point to the specificed location.
-
setLocation(int, int)
- Sets the location of this point.
-
toString()
- Returns a representation of this point and its location
in the (x, y) coordinate space as a string.
-
translate(double, double)
- 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
).
x
public double x
- The x coordinate.
y
public double y
- The y coordinate.
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.
DoublePoint
public DoublePoint(DoublePoint p)
- Constructs and initializes a point with the same location as
the specified
DoublePoint
object.
- Parameters:
- p - a point.
DoublePoint
public DoublePoint(double x,
double y)
- Constructs and initializes a point at the specified
(x, y) location in the coordinate space.
- Parameters:
- x - the x coordinate.
- y - the y coordinate.
DoublePoint
public DoublePoint(Point pt)
- Constructs and initializes a
DoublePoint
from the specified Point
.
- Parameters:
- pt - the initial
java.awt.Point
.
setLocation
public void setLocation(int x,
int y)
- Sets the location of this point.
- Parameters:
- x - new X value.
- y - new Y value.
getApproximation
public Point getApproximation()
- Rounds the
DoublePoint
to a standard (integer) Point
- Returns:
- the
DoublePoint
rounded to the nearest Point
scale
public void scale(double xFactor,
double yFactor)
- Scales the point.
- Parameters:
- xFactor - the x-axis scale factor.
- yFactor - the y-axis scale factor.
scale
public void scale(double factor)
- Uniformly scales the point.
- Parameters:
- factor - the scale factor.
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
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.
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.
translate
public void translate(double x,
double y)
- 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
).
- Parameters:
- dx - the distance to move this point
along the x axis.
- dy - the distance to move this point
along the y axis.
hashCode
public int hashCode()
- Returns the hashcode for this point.
- Returns:
- a hash code for this point.
- Overrides:
- hashCode in class Object
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
toString
public String toString()
- Returns a representation of this point and its location
in the (x, y) 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