JavaTM 2 Platform
Standard Ed. 6

java.awt.geom
类 Point2D

java.lang.Object
  继承者 java.awt.geom.Point2D
所有已实现的接口:
Cloneable
直接已知子类:
Point, Point2D.Double, Point2D.Float

public abstract class Point2D
extends Object
implements Cloneable

Point2D 类定义表示 (x,y) 坐标空间中位置的点。

此类是所有存储 2D 坐标的对象的惟一抽象超类。坐标的实际存储表示形式由子类决定。

从以下版本开始:
1.2

嵌套类摘要
static class Point2D.Double
          Double 类以 double 精度定义指定的点。
static class Point2D.Float
          Float 类以 float 精度定义指定的点。
 
构造方法摘要
protected Point2D()
          这是一个无法直接实例化的抽象类。
 
方法摘要
 Object clone()
          创建一个与此对象具有相同类和相同内容的新对象。
 double distance(double px, double py)
          返回从此 Point2D 到指定点的距离。
static double distance(double x1, double y1, double x2, double y2)
          返回两个点之间距离。
 double distance(Point2D pt)
          返回从此 Point2D 到指定 Point2D 的距离。
 double distanceSq(double px, double py)
          返回从此 Point2D 到指定点的距离的平方。
static double distanceSq(double x1, double y1, double x2, double y2)
          返回两个点之间距离的平方。
 double distanceSq(Point2D pt)
          返回从此 Point2D 到指定 Point2D 的距离的平方。
 boolean equals(Object obj)
          确定两个点是否相等。
abstract  double getX()
          以 double 精度返回此 Point2D 的 X 坐标。
abstract  double getY()
          以 double 精度返回此 Point2D 的 Y 坐标。
 int hashCode()
          返回此 Point2D 的哈希码。
abstract  void setLocation(double x, double y)
          将此 Point2D 的位置设为指定的 double 坐标。
 void setLocation(Point2D p)
          将此 Point2D 的位置设为指定 Point2D 对象的坐标。
 
从类 java.lang.Object 继承的方法
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

Point2D

protected Point2D()
这是一个无法直接实例化的抽象类。特定于类型的实现子类可用于实例化,并提供用于存储满足以下各种存取方法所需信息的多种格式。

从以下版本开始:
1.2
另请参见:
Point2D.Float, Point2D.Double, Point
方法详细信息

getX

public abstract double getX()
double 精度返回此 Point2D 的 X 坐标。

返回:
Point2D 的 X 坐标。
从以下版本开始:
1.2

getY

public abstract double getY()
double 精度返回此 Point2D 的 Y 坐标。

返回:
Point2D 的 Y 坐标。
从以下版本开始:
1.2

setLocation

public abstract void setLocation(double x,
                                 double y)
将此 Point2D 的位置设为指定的 double 坐标。

参数:
x - 此 Point2D 的新 X 坐标
y - 此 Point2D 的新 Y 坐标
从以下版本开始:
1.2

setLocation

public void setLocation(Point2D p)
将此 Point2D 的位置设为指定 Point2D 对象的坐标。

参数:
p - 用于设置此 Point2D 的指定 Point2D
从以下版本开始:
1.2

distanceSq

public static double distanceSq(double x1,
                                double y1,
                                double x2,
                                double y2)
返回两个点之间距离的平方。

参数:
x1 - 第一个指定点的 X 坐标
y1 - 第一个指定点的 Y 坐标
x2 - 第二个指定点的 X 坐标
y2 - 第二个指定点的 Y 坐标
返回:
两组指定坐标之间距离的平方。
从以下版本开始:
1.2

distance

public static double distance(double x1,
                              double y1,
                              double x2,
                              double y2)
返回两个点之间距离。

参数:
x1 - 第一个指定点的 X 坐标
y1 - 第一个指定点的 Y 坐标
x2 - 第二个指定点的 X 坐标
y2 - 第二个指定点的 Y 坐标
返回:
两组指定坐标之间的距离。
从以下版本开始:
1.2

distanceSq

public double distanceSq(double px,
                         double py)
返回从此 Point2D 到指定点的距离的平方。

参数:
px - 将对照此 Point2D 进行测量的指定点的 X 坐标
py - 将对照此 Point2D 进行测量的指定点的 X 坐标
返回:
Point2D 与指定点之间距离的平方。
从以下版本开始:
1.2

distanceSq

public double distanceSq(Point2D pt)
返回从此 Point2D 到指定 Point2D 的距离的平方。 将对照此 Point2D 进行测量的指定点的 X 坐标

参数:
py - 将对照此 Point2D 进行测量的指定点的 X 坐标
返回:
Point2D 与指定点之间的距离。
从以下版本开始:
1.2

distance

public double distance(double px,
                       double py)
返回从此 Point2D 到指定点的距离。

参数:
px - 将对照此 Point2D 进行测量的指定点的 X 坐标
py - 将对照此 Point2D 进行测量的指定点的 X 坐标
返回:
Point2D 与指定点之间的距离。
从以下版本开始:
1.2

distance

public double distance(Point2D pt)
返回从此 Point2D 到指定 Point2D 的距离。

参数:
pt - 将对照此 Point2D 进行测量的指定点
返回:
Point2D 和指定 Point2D 之间的距离。
从以下版本开始:
1.2

clone

public Object clone()
创建一个与此对象具有相同类和相同内容的新对象。

覆盖:
Object 中的 clone
返回:
此实例的一个副本。
抛出:
OutOfMemoryError - 如果没有足够的内存。
从以下版本开始:
1.2
另请参见:
Cloneable

hashCode

public int hashCode()
返回此 Point2D 的哈希码。

覆盖:
Object 中的 hashCode
返回:
Point2D 的哈希码
另请参见:
Object.equals(java.lang.Object), Hashtable

equals

public boolean equals(Object obj)
确定两个点是否相等。如果 Point2D 的两个实例的 xy 成员字段值相同,则它们是相等的,这表示它们在坐标空间中的位置是一样的。

覆盖:
Object 中的 equals
参数:
obj - 要与此 Point2D 的实例进行比较的对象
返回:
如果要比较的对象是 Point2D 的实例且值相同,则返回 true;否则返回 false
从以下版本开始:
1.2
另请参见:
Object.hashCode(), Hashtable

JavaTM 2 Platform
Standard Ed. 6

提交错误或意见
有关更多的 API 参考资料和开发人员文档,请参阅 Java 2 SDK SE 开发人员文档。该文档包含更详细的、面向开发人员的描述,以及总体概述、术语定义、使用技巧和工作代码示例。

版权所有 2004 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策