public static class Rectangle2D.Float extends Rectangle2D implements Serializable
Float类定义了一个在浮点坐标中指定的矩形。
Rectangle2D.Double, Rectangle2D.Float| Modifier and Type | Field and Description |
|---|---|
float |
height
这个
Rectangle2D的高度。
|
float |
width
这个宽度
Rectangle2D 。
|
float |
x
这个
Rectangle2D的X
Rectangle2D 。
|
float |
y
这个
Rectangle2D的Y
Rectangle2D 。
|
OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP| Constructor and Description |
|---|
Float()
构造一个新的
Rectangle2D ,初始化为位置(0.0,0.0)和大小(0.0,0.0)。
|
Float(float x, float y, float w, float h)
构造并初始化一个
Rectangle2D从指定的
float坐标。
|
| Modifier and Type | Method and Description |
|---|---|
Rectangle2D |
createIntersection(Rectangle2D r)
返回一个新的
Rectangle2D对象,表示此
Rectangle2D与指定的Rectangle2D的
Rectangle2D 。
|
Rectangle2D |
createUnion(Rectangle2D r)
返回一个新的
Rectangle2D对象,表示此
Rectangle2D与指定的Rectangle2D的并
Rectangle2D 。
|
Rectangle2D |
getBounds2D()
返回一个高精度和更准确的边界框
Shape比
getBounds方法。
|
double |
getHeight()
返回
double精度框架矩形的高度。
|
double |
getWidth()
返回
double精度的框架矩形的宽度。
|
double |
getX()
以double精度返回成帧矩形左上角的
double坐标。
|
double |
getY()
返回double精度的框架矩形左上角的
double坐标。
|
boolean |
isEmpty()
确定是否
RectangularShape是空的。
|
int |
outcode(double x, double y)
确定与Rectangle2D有关的指定
Rectangle2D 。
|
void |
setRect(double x, double y, double w, double h)
将此
Rectangle2D的位置和大小设置为指定的
double值。
|
void |
setRect(float x, float y, float w, float h)
将此
Rectangle2D的位置和大小设置为指定的
float值。
|
void |
setRect(Rectangle2D r)
将此
Rectangle2D设置为与指定的
Rectangle2D相同。
|
String |
toString()
返回此
String String
Rectangle2D 。
|
add, add, add, contains, contains, equals, getPathIterator, getPathIterator, hashCode, intersect, intersects, intersectsLine, intersectsLine, outcode, setFrame, unionclone, contains, contains, getBounds, getCenterX, getCenterY, getFrame, getMaxX, getMaxY, getMinX, getMinY, intersects, setFrame, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonalpublic float x
Rectangle2D的X
Rectangle2D 。
public float y
Rectangle2D的Y
Rectangle2D 。
public float width
Rectangle2D 。
public float height
Rectangle2D的高度。
public Float()
Rectangle2D ,初始化为位置(0.0,0.0)和大小(0.0,0.0)。
public Float(float x,
float y,
float w,
float h)
Rectangle2D从指定的
float坐标。
x - 新构建的左上角的X坐标
Rectangle2D
y - 新构建的左上角的Y坐标
Rectangle2D
w -的新构造的宽度
Rectangle2D
h -的新构造的高度
Rectangle2D
public double getX()
double坐标。
getX类
RectangularShape
public double getY()
double坐标。
getY在
RectangularShape
public double getWidth()
double精度返回框架矩形的宽度。
getWidth在
RectangularShape
public double getHeight()
double精度返回框架矩形的高度。
getHeight在类别
RectangularShape
public boolean isEmpty()
RectangularShape是空的。
当RectangularShape为空时,它不包含任何区域。
isEmpty在
RectangularShape
true如果RectangularShape是空的;
false否则。
public void setRect(float x,
float y,
float w,
float h)
Rectangle2D的位置和大小设置为指定的
float值。
x - 这个
Rectangle2D左上角的X
Rectangle2D
y - 这个
Rectangle2D左上角的Y
Rectangle2D
w - 这个宽度
Rectangle2D
h - 这个
Rectangle2D的高度
public void setRect(double x,
double y,
double w,
double h)
Rectangle2D的位置和大小设置为指定的
double值。
setRect在
Rectangle2D
x - 这个
Rectangle2D左上角的X
Rectangle2D
y - 这个
Rectangle2D左上角的Y
Rectangle2D
w - 这个宽度
Rectangle2D
h - 这个
Rectangle2D的高度
public void setRect(Rectangle2D r)
Rectangle2D设置为与指定的
Rectangle2D相同。
setRect在类别
Rectangle2D
r - 指定的
Rectangle2D
public int outcode(double x,
double y)
Rectangle2D 。
该方法计算适当的掩码值的二进制OR,该掩码值表示对于该Rectangle2D的每一边, Rectangle2D是否与该Rectangle2D的其余部分位于边的同一侧。
outcode在
Rectangle2D
x - 指定的X坐标
y - 指定的Y坐标
Rectangle2D.OUT_LEFT ,
Rectangle2D.OUT_TOP ,
Rectangle2D.OUT_RIGHT ,
Rectangle2D.OUT_BOTTOM
public Rectangle2D getBounds2D()
Shape比getBounds方法更高精度和更准确的边界框。
需要注意的是没有保证返回Rectangle2D是最小的边框包围Shape ,只表示Shape完全在指定的范围内Rectangle2D 。
通过此方法返回的边界框通常比通过返回的更紧密getBounds方法,而且永远不会因为溢出问题,因为返回值可以是实例Rectangle2D一个使用双精度值存储尺寸。
需要注意的是definition of insideness可能会导致出现对的定义轮廓点的情况下shape可能不被认为包含在返回bounds对象,但只有在这些点也未审议了原有的情况下shape 。
如果一个point是在shape内,根据contains(point)的方法,那么它必须在返回的Rectangle2D边界内的对象根据contains(point)方法的bounds 。 特别:
shape.contains(p)要求bounds.contains(p)
如果point不在shape ,那么它可能仍然包含在bounds对象中:
bounds.contains(p)并不表示shape.contains(p)
getBounds2D在界面
Shape
getBounds2D在类别
Rectangle2D
Rectangle2D那是一个高精度边界框
Shape 。
Shape.getBounds()
public Rectangle2D createIntersection(Rectangle2D r)
Rectangle2D对象,表示此
Rectangle2D与指定的Rectangle2D的
Rectangle2D 。
createIntersection在
Rectangle2D
r -
Rectangle2D要与此
Rectangle2D
Rectangle2D包含在指定的
Rectangle2D和在这
Rectangle2D 。
public Rectangle2D createUnion(Rectangle2D r)
Rectangle2D对象,表示该
Rectangle2D与指定的Rectangle2D的并
Rectangle2D 。
createUnion在类别
Rectangle2D
r -在
Rectangle2D与此相结合
Rectangle2D
Rectangle2D包含指定的
Rectangle2D和这
Rectangle2D 。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.