java.awt.geom
Class Point2D
- Cloneable
This class implements a generic point in 2D Cartesian space. The storage
representation is left up to the subclass. Point includes two useful
nested classes, for float and double storage respectively.
static class | Point2D.Double - This class defines a point in
double precision.
|
static class | Point2D.Float - This class defines a point in
float precision.
|
Object | clone() - Create a new point of the same run-time type with the same contents as
this one.
|
double | distance(double x, double y) - Return the distance from this point to the given one.
|
static double | distance(double x1, double y1, double x2, double y2) - Return the distance between two points.
|
double | distance(Point2D p) - Return the distance from this point to the given one.
|
double | distanceSq(double x, double y) - Return the square of the distance from this point to the given one.
|
static double | distanceSq(double x1, double y1, double x2, double y2) - Return the square of the distance between two points.
|
double | distanceSq(Point2D p) - Return the square of the distance from this point to the given one.
|
boolean | equals(Object o) - Compares two points for equality.
|
abstract double | getX() - Get the X coordinate, in double precision.
|
abstract double | getY() - Get the Y coordinate, in double precision.
|
int | hashCode() - Return the hashcode for this point.
|
abstract void | setLocation(double x, double y) - Set the location of this point to the new coordinates.
|
void | setLocation(Point2D p) - Set the location of this point to the new coordinates.
|
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
Point2D
protected Point2D()
The default constructor.
clone
public Object clone()
Create a new point of the same run-time type with the same contents as
this one.
- clone in interface Object
distance
public double distance(double x,
double y)
Return the distance from this point to the given one.
x
- the x coordinate of the other pointy
- the y coordinate of the other point
distance
public static double distance(double x1,
double y1,
double x2,
double y2)
Return the distance between two points.
x1
- the x coordinate of point 1y1
- the y coordinate of point 1x2
- the x coordinate of point 2y2
- the y coordinate of point 2
- the distance from (x1,y1) to (x2,y2)
distance
public double distance(Point2D p)
Return the distance from this point to the given one.
distanceSq
public double distanceSq(double x,
double y)
Return the square of the distance from this point to the given one.
x
- the x coordinate of the other pointy
- the y coordinate of the other point
- the square of the distance
distanceSq
public static double distanceSq(double x1,
double y1,
double x2,
double y2)
Return the square of the distance between two points.
x1
- the x coordinate of point 1y1
- the y coordinate of point 1x2
- the x coordinate of point 2y2
- the y coordinate of point 2
- (x2 - x1)^2 + (y2 - y1)^2
distanceSq
public double distanceSq(Point2D p)
Return the square of the distance from this point to the given one.
- the square of the distance
equals
public boolean equals(Object o)
Compares two points for equality. This returns true if they have the
same coordinates.
- equals in interface Object
getX
public abstract double getX()
Get the X coordinate, in double precision.
getY
public abstract double getY()
Get the Y coordinate, in double precision.
hashCode
public int hashCode()
Return the hashcode for this point. The formula is not documented, but
appears to be the same as:
long l = Double.doubleToLongBits(getY());
l = l * 31 ^ Double.doubleToLongBits(getX());
return (int) ((l >> 32) ^ l);
- hashCode in interface Object
setLocation
public abstract void setLocation(double x,
double y)
Set the location of this point to the new coordinates. There may be a
loss of precision.
x
- the new x coordinatey
- the new y coordinate
setLocation
public void setLocation(Point2D p)
Set the location of this point to the new coordinates. There may be a
loss of precision.
Point2D.java -- generic point in 2-D space
Copyright (C) 1999, 2000, 2002, 2004, 2006, Free Software Foundation
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.