Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.awt.geom

Class Point2D

java.lang.Object
|
+--java.awt.geom.Point2D

All Implemented Interfaces:

Cloneable


public abstract class Point2D

extends Object

implements 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.

Since:Authors:

Constructor Summary

Point2D()

The default constructor.

Method Summary

java.lang.Objectclone()

Create a new point of the same run-time type with the same contents as this one.
static doubledistance(double x1, double y1, double x2, double y2)

Return the distance between two points.
doubledistance(double x, double y)

Return the distance from this point to the given one.
doubledistance(java.awt.geom.Point2D p)

Return the distance from this point to the given one.
static doubledistanceSq(double x1, double y1, double x2, double y2)

Return the square of the distance between two points.
doubledistanceSq(double x, double y)

Return the square of the distance from this point to the given one.
doubledistanceSq(java.awt.geom.Point2D p)

Return the square of the distance from this point to the given one.
booleanequals(java.lang.Object o)

Compares two points for equality.
doublegetX()

Get the X coordinate, in double precision.
doublegetY()

Get the Y coordinate, in double precision.
inthashCode()

Return the hashcode for this point.
voidsetLocation(double x, double y)

Set the location of this point to the new coordinates.
voidsetLocation(java.awt.geom.Point2D p)

Set the location of this point to the new coordinates.

Constructor Details

Point2D

protected Point2D()

The default constructor.

See Also:


Method Details

clone

public Object clone()

Create a new point of the same run-time type with the same contents as this one.

Returns:


distance

public double distance(double x, double y)

Return the distance from this point to the given one.

Parameters:

Returns:


distance

public static double distance(double x1, double y1, double x2, double y2)

Return the distance between two points.

Parameters:

Returns:


distance

public double distance(java.awt.geom.Point2D p)

Return the distance from this point to the given one.

Parameters:

Returns:

Throws:


distanceSq

public double distanceSq(double x, double y)

Return the square of the distance from this point to the given one.

Parameters:

Returns:


distanceSq

public static double distanceSq(double x1, double y1, double x2, double y2)

Return the square of the distance between two points.

Parameters:

Returns:


distanceSq

public double distanceSq(java.awt.geom.Point2D p)

Return the square of the distance from this point to the given one.

Parameters:

Returns:

Throws:


equals

public boolean equals(java.lang.Object o)

Compares two points for equality. This returns true if they have the same coordinates.

Parameters:

Returns:


getX

public double getX()

Get the X coordinate, in double precision.

Returns:


getY

public double getY()

Get the Y coordinate, in double precision.

Returns:


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);
 

Returns:


setLocation

public void setLocation(double x, double y)

Set the location of this point to the new coordinates. There may be a loss of precision.

Parameters:


setLocation

public void setLocation(java.awt.geom.Point2D p)

Set the location of this point to the new coordinates. There may be a loss of precision.

Parameters:

Throws: