java.lang.Object
java.awt.geom.Line2D
java.awt.geom.Line2D.Float
- 所有已实现的接口:
-
Shape,Serializable,Cloneable
- 封闭类:
-
Line2D
使用浮点坐标指定的线段。
- 自版本:
- 1.2
- 另请参阅:
-
Nested Class Summary
Nested classes/interfaces declared in class java.awt.geom.Line2D
Line2D.Double, Line2D.Float -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription返回Shape的高精度和更准确的边界框,比getBounds方法更紧凑。getP1()返回此Line2D的起点Point2D。getP2()返回此Line2D的终点Point2D。doublegetX1()返回起点的X坐标,以双精度表示。doublegetX2()返回终点的X坐标,以双精度表示。doublegetY1()返回起点的Y坐标,以双精度表示。doublegetY2()返回终点的Y坐标,以双精度表示。voidsetLine(double x1, double y1, double x2, double y2) 将此Line2D的端点位置设置为指定的双精度坐标。voidsetLine(float x1, float y1, float x2, float y2) 将此Line2D的端点位置设置为指定的浮点坐标。Methods declared in class java.awt.geom.Line2D
clone, contains, contains, contains, contains, getBounds, getPathIterator, getPathIterator, intersects, intersects, intersectsLine, intersectsLine, linesIntersect, ptLineDist, ptLineDist, ptLineDist, ptLineDistSq, ptLineDistSq, ptLineDistSq, ptSegDist, ptSegDist, ptSegDist, ptSegDistSq, ptSegDistSq, ptSegDistSq, relativeCCW, relativeCCW, relativeCCW, setLine, setLine
-
Field Details
-
x1
public float x1线段起点的X坐标。- 自版本:
- 1.2
-
y1
public float y1线段起点的Y坐标。- 自版本:
- 1.2
-
x2
public float x2线段终点的X坐标。- 自版本:
- 1.2
-
y2
public float y2线段终点的Y坐标。- 自版本:
- 1.2
-
-
Constructor Details
-
Float
public Float()构造并初始化具有坐标(0, 0)→(0, 0)的线段。- 自版本:
- 1.2
-
Float
public Float(float x1, float y1, float x2, float y2) 构造并初始化具有指定坐标的线段。- 参数:
-
x1- 起点的X坐标 -
y1- 起点的Y坐标 -
x2- 终点的X坐标 -
y2- 终点的Y坐标 - 自版本:
- 1.2
-
Float
从指定的Point2D对象构造并初始化Line2D。- 参数:
-
p1- 此线段的起点Point2D -
p2- 此线段的终点Point2D - 自版本:
- 1.2
-
-
Method Details
-
getX1
public double getX1()返回起点的X坐标,以双精度表示。 -
getY1
public double getY1()返回起点的Y坐标,以双精度表示。 -
getP1
返回此Line2D的起点Point2D。 -
getX2
public double getX2()返回终点的X坐标,以双精度表示。 -
getY2
public double getY2()返回终点的Y坐标,以双精度表示。 -
getP2
返回此Line2D的终点Point2D。 -
setLine
public void setLine(double x1, double y1, double x2, double y2) 将此Line2D的端点位置设置为指定的双精度坐标。 -
setLine
public void setLine(float x1, float y1, float x2, float y2) 将此Line2D的端点位置设置为指定的浮点坐标。- 参数:
-
x1- 起点的X坐标 -
y1- 起点的Y坐标 -
x2- 终点的X坐标 -
y2- 终点的Y坐标 - 自版本:
- 1.2
-
getBounds2D
返回Shape的高精度和更准确的边界框,比getBounds方法更紧凑。请注意,返回的Rectangle2D不一定是包围Shape的最小边界框,只是Shape完全位于指示的Rectangle2D内。此方法返回的边界框通常比getBounds方法返回的边界框更紧凑,并且永远不会因溢出问题而失败,因为返回值可以是使用双精度值存储尺寸的Rectangle2D的实例。请注意,内部定义的定义可能导致定义的形状轮廓上的点可能不被认为包含在返回的
bounds对象中,但只有在这些点也不被认为包含在原始shape中的情况下才是如此。如果
point根据contains(point)方法在shape内部,则根据bounds的contains(point)方法,它必须在返回的Rectangle2D边界对象内部。具体来说:shape.contains(p)要求bounds.contains(p)如果
point不在shape内部,则它可能仍然包含在bounds对象中:bounds.contains(p)不意味着shape.contains(p)- 指定者:
-
getBounds2D在接口Shape中 - 返回:
-
一个
Shape的高精度边界框的实例。 - 自版本:
- 1.2
- 另请参阅:
-