public abstract class Point2D extends Object implements Cloneable
Modifier and Type | Class and Description |
---|---|
static class |
Point2D.Double
This class defines a point in
double precision. |
static class |
Point2D.Float
This class defines a point in
float precision. |
Modifier | Constructor and Description |
---|---|
protected |
Point2D()
The default constructor.
|
Modifier and Type | Method and Description |
---|---|
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.
|
protected Point2D()
Point
,
Point2D.Float
,
Point2D.Double
public abstract double getX()
public abstract double getY()
public abstract void setLocation(double x, double y)
x
- the new x coordinatey
- the new y coordinatepublic void setLocation(Point2D p)
p
- the point to copyNullPointerException
- if p is nullpublic static double distanceSq(double x1, double y1, double x2, double y2)
x1
- the x coordinate of point 1y1
- the y coordinate of point 1x2
- the x coordinate of point 2y2
- the y coordinate of point 2public static double distance(double x1, double y1, double x2, double y2)
x1
- the x coordinate of point 1y1
- the y coordinate of point 1x2
- the x coordinate of point 2y2
- the y coordinate of point 2public double distanceSq(double x, double y)
x
- the x coordinate of the other pointy
- the y coordinate of the other pointpublic double distanceSq(Point2D p)
p
- the other pointNullPointerException
- if p is nullpublic double distance(double x, double y)
x
- the x coordinate of the other pointy
- the y coordinate of the other pointpublic double distance(Point2D p)
p
- the other pointNullPointerException
- if p is nullpublic Object clone()
public int hashCode()
long l = Double.doubleToLongBits(getY()); l = l * 31 ^ Double.doubleToLongBits(getX()); return (int) ((l >> 32) ^ l);
hashCode
in class Object
Object.equals(Object)
,
System.identityHashCode(Object)
public boolean equals(Object o)
equals
in class Object
o
- the point to compareObject.hashCode()