模块 java.desktop

类 Line2D.Float

java.lang.Object
java.awt.geom.Line2D
java.awt.geom.Line2D.Float
所有已实现的接口:
Shape , Serializable , Cloneable
封闭类:
Line2D

public static class Line2D.Float extends Line2D implements Serializable
用浮点坐标指定的线段。
自从:
1.2
参见:
  • 字段详细信息

    • 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
  • 构造方法详细信息

    • Float

      public Float()
      构造并初始化坐标为 (0, 0) → (0, 0) 的 Line。
      自从:
      1.2
    • Float

      public Float(float x1, float y1, float x2, float y2)
      从指定坐标构造并初始化一条 Line。
      参数:
      x1 - 起点的X坐标
      y1 - 起点的Y坐标
      x2 - 终点的X坐标
      y2 - 终点的Y坐标
      自从:
      1.2
    • Float

      public Float(Point2D  p1, Point2D  p2)
      从指定的 Point2D 对象构造并初始化 Line2D
      参数:
      p1 - 此线段的起点 Point2D
      p2 - 此线段的结尾 Point2D
      自从:
      1.2
  • 方法详情

    • getX1

      public double getX1()
      以双精度返回起点的 X 坐标。
      指定者:
      getX1 在类 Line2D
      返回:
      Line2D 对象起点的 X 坐标。
      自从:
      1.2
    • getY1

      public double getY1()
      以双精度返回起点的 Y 坐标。
      指定者:
      getY1 在类 Line2D
      返回:
      Line2D 对象起点的 Y 坐标。
      自从:
      1.2
    • getP1

      public Point2D  getP1()
      返回此 Line2D 的开始 Point2D
      指定者:
      getP1 在类 Line2D
      返回:
      这个Line2D的开始Point2D
      自从:
      1.2
    • getX2

      public double getX2()
      以双精度返回终点的 X 坐标。
      指定者:
      getX2 在类 Line2D
      返回:
      Line2D 对象终点的 X 坐标。
      自从:
      1.2
    • getY2

      public double getY2()
      以双精度返回终点的 Y 坐标。
      指定者:
      getY2 在类 Line2D
      返回:
      Line2D 对象终点的 Y 坐标。
      自从:
      1.2
    • getP2

      public Point2D  getP2()
      返回此 Line2D 的结尾 Point2D
      指定者:
      getP2 在类 Line2D
      返回:
      这个Line2D的结尾Point2D
      自从:
      1.2
    • setLine

      public void setLine(double x1, double y1, double x2, double y2)
      将此 Line2D 的端点位置设置为指定的双精度坐标。
      指定者:
      setLine 在类 Line2D
      参数:
      x1 - 起点的X坐标
      y1 - 起点的Y坐标
      x2 - 终点的X坐标
      y2 - 终点的Y坐标
      自从:
      1.2
    • setLine

      public void setLine(float x1, float y1, float x2, float y2)
      将此 Line2D 的终点位置设置为指定的浮点坐标。
      参数:
      x1 - 起点的X坐标
      y1 - 起点的Y坐标
      x2 - 终点的X坐标
      y2 - 终点的Y坐标
      自从:
      1.2
    • getBounds2D

      public Rectangle2D  getBounds2D()
      返回 ShapegetBounds 方法更高精度和更准确的边界框。请注意,不能保证返回的 Rectangle2D 是包围 Shape 的最小边界框,只能保证 Shape 完全位于指示的 Rectangle2D 内。此方法返回的边界框通常比 getBounds 方法返回的边界框更紧密,并且不会因溢出问题而失败,因为返回值可以是使用双精度值存储尺寸的 Rectangle2D 的实例。

      请注意,definition of insideness 可能导致 shape 定义轮廓上的点可能不被视为包含在返回的 bounds 对象中,但仅在这些点也不被视为包含在原始 shape 中的情况下。

      如果根据 contains(point) 方法 pointshape 内部,那么根据 boundscontains(point) 方法,它必须在返回的 Rectangle2D 边界对象内部。具体来说:

      shape.contains(p) 需要 bounds.contains(p)

      如果 point 不在 shape 内,那么它可能仍包含在 bounds 对象中:

      bounds.contains(p) 并不意味着 shape.contains(p)

      指定者:
      getBounds2D 在接口 Shape
      返回:
      Rectangle2D 的一个实例,它是 Shape 的高精度边界框。
      自从:
      1.2
      参见: