- java.lang.Object
-
- java.awt.geom.Point2D
-
- java.awt.Point
-
- All Implemented Interfaces:
-
Serializable,Cloneable
public class Point extends Point2D implements Serializable
表示(x,y)坐标空间中的位置的点,以整数精度指定。- 从以下版本开始:
- 1.0
- 另请参见:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.awt.geom.Point2D
Point2D.Double, Point2D.Float
-
-
方法摘要
所有方法 接口方法 具体的方法 Modifier and Type 方法 描述 booleanequals(Object obj)确定两点是否相等。PointgetLocation()返回这一点的位置。doublegetX()以double精度返回此Point2D的X坐标。doublegetY()返回这个Point2D的Y坐标在double精度。voidmove(int x, int y)将此点移动到(x,y)坐标平面中的指定位置。voidsetLocation(double x, double y)将此点的位置设置为指定的双坐标。voidsetLocation(int x, int y)更改要具有指定位置的点。voidsetLocation(Point p)将点的位置设置为指定的位置。StringtoString()返回此点及其位置在(x,y)坐标空间中的字符串表示形式。voidtranslate(int dx, int dy)转换这一点上,在位置(x,y),通过dx沿x轴和dy沿y轴线,使得其现在代表点(x+dx,y+dy)。-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from class java.awt.geom.Point2D
clone, distance, distance, distance, distanceSq, distanceSq, distanceSq, hashCode, setLocation
-
-
-
-
字段详细信息
-
x
public int x
这个Point的X坐标。 如果没有设置X坐标,它将默认为0。- 从以下版本开始:
- 1.0
- 另请参见:
-
getLocation(),move(int, int)
-
y
public int y
这个Y坐标Point。 如果没有设置Y坐标,则默认为0。- 从以下版本开始:
- 1.0
- 另请参见:
-
getLocation(),move(int, int)
-
-
构造方法详细信息
-
Point
public Point()
构造并初始化坐标空间原点(0,0)的点。- 从以下版本开始:
- 1.1
-
Point
public Point(Point p)
构造并初始化与指定的Point对象相同位置的点。- 参数
-
p- 一点 - 从以下版本开始:
- 1.1
-
Point
public Point(int x, int y)在坐标空间中指定的(x,y)位置构造和初始化点。- 参数
-
x- 新构建的X坐标Point -
y- 新构建的Y坐标Point - 从以下版本开始:
- 1.0
-
-
方法详细信息
-
getX
public double getX()
返回此的X坐标Point2D在double精度。
-
getY
public double getY()
返回Point2D的Y坐标double精度。
-
getLocation
public Point getLocation()
返回这一点的位置。 包括这种方法的完整性,并行getLocation方法Component。- 结果
- 这个点的副本,在同一个位置
- 从以下版本开始:
- 1.1
- 另请参见:
-
Component.getLocation(),setLocation(java.awt.Point),setLocation(int, int)
-
setLocation
public void setLocation(Point p)
将点的位置设置为指定的位置。 此方法是出于完整性考虑,它与所述setLocation的方法Component。- 参数
-
p- 一点,这一点的新位置 - 从以下版本开始:
- 1.1
- 另请参见:
-
Component.setLocation(java.awt.Point),getLocation()
-
setLocation
public void setLocation(int x, int y)更改要具有指定位置的点。包括这种方法的完整性,并行
setLocation方法Component。 其行为与move(int, int)相同。- 参数
-
x- 新位置的X坐标 -
y- 新位置的Y坐标 - 从以下版本开始:
- 1.1
- 另请参见:
-
Component.setLocation(int, int),getLocation(),move(int, int)
-
setLocation
public void setLocation(double x, double y)将此点的位置设置为指定的双坐标。 double值将四舍五入为整数值。 任何小于Integer.MIN_VALUE将重置为MIN_VALUE,任何大于Integer.MAX_VALUE将重置为MAX_VALUE。- Specified by:
-
setLocation在Point2D - 参数
-
x- 新位置的X坐标 -
y- 新位置的Y坐标 - 另请参见:
-
getLocation()
-
move
public void move(int x, int y)将此点移动到(x,y)坐标平面中的指定位置。 此方法与setLocation(int, int)相同。- 参数
-
x- 新位置的X坐标 -
y- 新位置的Y坐标 - 另请参见:
-
Component.setLocation(int, int)
-
translate
public void translate(int dx, int dy)转换这一点上,在位置(x,y),通过dx沿x轴和dy沿y轴线,使得其现在代表点(x+dx,y+dy)。- 参数
-
dx- 沿着X轴移动该点的距离 -
dy- 沿着Y轴移动该点的距离
-
equals
public boolean equals(Object obj)
确定两点是否相等。Point2D两个实例相同,如果它们的x和y成员字段的值表示其在坐标空间中的位置相同。- 重写:
-
equals在Point2D - 参数
-
obj- 要与此Point2D进行比较的对象 - 结果
-
true如果要比较的对象是Point2D的实例,并且具有相同的值; 否则为false。 - 另请参见:
-
Object.hashCode(),HashMap
-
-