public interface Shape
Shape
接口提供对象代表了某种形式的几何定义。的
Shape
由
PathIterator
对象描述,可以表达的
Shape
概要以及规则确定如何将二维平面轮廓分为内部和外部的点。每个
Shape
对象提供回调得到几何边界框,确定点或矩形部分或完全在撒谎的
Shape
内部,和检索
PathIterator
对象描述的
Shape
轮廓的运动轨迹。
Definition of insideness:一点是躺在一个Shape
当且仅当:
Shape
边空或Shape
边空和空间紧邻在增加X
方向的点是完全或边界内的空Y
方向的点是在边界。的contains
和intersects
方法考虑一个Shape
内部是区域包围仿佛充满了。这意味着,这些方法考虑未闭合的形状是隐式关闭决定的目的,如果一个形状包含或相交的矩形或者形状包含一点。
PathIterator
,
AffineTransform
,
FlatteningPathIterator
,
GeneralPath
Modifier and Type | Method and Description |
---|---|
boolean |
contains(double x, double y)
如果指定的坐标的
Shape 边界内,由
definition of insideness描述。
|
boolean |
contains(double x, double y, double w, double h)
如果
Shape 测试的内部完全包含指定的矩形区域。
|
boolean |
contains(Point2D p)
|
boolean |
contains(Rectangle2D r)
如果
Shape 测试的内部完全包含指定的
Rectangle2D 。
|
Rectangle |
getBounds()
返回一个整数
Rectangle 完全封闭
Shape 。
|
Rectangle2D |
getBounds2D()
返回一个高的精度和更精确的包围盒的
Shape 比
getBounds 方法。
|
PathIterator |
getPathIterator(AffineTransform at)
返回一个迭代器对象沿
Shape 迭代边界提供了访问的
Shape 轮廓的几何。
|
PathIterator |
getPathIterator(AffineTransform at, double flatness)
返回一个迭代器对象沿
Shape 迭代边界提供了一个扁平的
Shape 外形几何。
|
boolean |
intersects(double x, double y, double w, double h)
如果
Shape 测试的内部与一个指定的矩形区域内。
|
boolean |
intersects(Rectangle2D r)
如果
Shape 测试的内部与指定的
Rectangle2D 内部。
|
Rectangle getBounds()
Rectangle
完全封闭
Shape
。需要注意的是不能保证返回的
Rectangle
是最小包围盒包围
Shape
,只有
Shape
完全在于在显示
Rectangle
。返回的
Rectangle
也未能完全封闭
Shape
如果
Shape
溢出整数数据类型的范围。的
getBounds2D
方法一般返回一个紧密的包围盒由于在表示其更大的灵活性。
请注意, definition of insideness可导致的情况下,点上的shape
定义轮廓可能不被视为包含在返回的bounds
对象,但只有在这些点的情况下,也不被认为是包含在原始的shape
。
如果一个point
在shape
根据contains(point)
方法,那么它必须在返回的Rectangle
界根据的bounds
的contains(point)
方法对象。明确地:
shape.contains(x,y)
需要bounds.contains(x,y)
如果一个point
是不是在shape
,那么它可能仍然包含在bounds
对象:
bounds.contains(x,y)
并不意味着shape.contains(x,y)
Rectangle
完全封闭
Shape
。
getBounds2D()
Rectangle2D getBounds2D()
Shape
比
getBounds
方法。需要注意的是不能保证返回的
Rectangle2D
是最小包围盒包围
Shape
,只有
Shape
完全在于在显示
Rectangle2D
。包围盒返回此方法通常是更严格的比
getBounds
返回的方法,永远不会失败由于溢出的问题由于返回值可以是使用双精度值存储维度的
Rectangle2D
实例。
请注意, definition of insideness可导致的情况下,点上的shape
定义轮廓可能不被视为包含在返回的bounds
对象,但只有在这些点的情况下,也不被认为是包含在原始的shape
。
如果一个point
在shape
根据contains(point)
方法,那么它必须在返回的Rectangle2D
界根据的bounds
的contains(point)
方法对象。明确地:
shape.contains(p)
需要bounds.contains(p)
如果一个point
是不是在shape
,那么它可能仍然包含在bounds
对象:
bounds.contains(p)
并不意味着shape.contains(p)
Rectangle2D
包围盒的
Shape
实例。
getBounds()
boolean contains(double x, double y)
Shape
边界内,由
definition of insideness描述。
x
-指定的x坐标进行测试
y
-指定的y坐标进行测试
true
如果指定坐标的
Shape
边界内;
false
否则。
boolean contains(Point2D p)
p
-指定
Point2D
进行测试
true
如果指定
Point2D
的
Shape
边界内;
false
否则。
boolean intersects(double x, double y, double w, double h)
Shape
测试的内部与一个指定的矩形区域内。矩形区域是相交的
Shape
如果任何点是否包含在内部的
Shape
和指定的矩形区域。
的Shape.intersects()
方法允许Shape
实施保守的回报true
时:
Shape
相交,但Shapes
这个方法可能返回
true
即使矩形区域不相交的
Shape
。的
Area
类执行更精确的计算几何相交比大多数
Shape
对象,因此可以更准确的答案是需要用。
x
-指定的矩形区域左上角的x坐标
y
-指定的矩形区域的左上角的Y坐标
w
-指定的矩形区域的宽度
h
-指定矩形区域的高度
true
如果的
Shape
内部与矩形区域内相交,或是相交,相交计算高度可能会执行
false
否则太贵。
Area
boolean intersects(Rectangle2D r)
Shape
测试的内部与指定的
Rectangle2D
内部。的
Shape.intersects()
方法允许
Shape
实施保守的回报
true
时:
Rectangle2D
和Shape
相交,但Shapes
这个方法可能返回
true
即使
Rectangle2D
不相交的
Shape
。的
Area
类执行更精确的计算几何相交比大多数
Shape
对象,因此可以更准确的答案是需要用。
r
-指定
Rectangle2D
true
如果的
Shape
内部和指定的
Rectangle2D
内部相交,或是相交,相交计算高度可能会执行
false
否则太贵。
intersects(double, double, double, double)
boolean contains(double x, double y, double w, double h)
Shape
测试的内部完全包含指定的矩形区域。所有的坐标,在矩形区域必须位于
Shape
整个矩形区域被认为是包含在
Shape
。
的Shape.contains()
方法允许Shape
实施保守的回报false
时:
true
和intersect
Shape
完全包含矩形区域是昂贵的计算。Shapes
这个方法可能返回
false
即使
Shape
包含矩形区域。的
Area
类执行更精确的几何计算比大多数
Shape
对象,因此可以更准确的答案是需要用。
x
-指定的矩形区域左上角的x坐标
y
-指定的矩形区域的左上角的Y坐标
w
-指定的矩形区域的宽度
h
-指定矩形区域的高度
true
如果的
Shape
内部完全包含指定矩形区域;
false
否则,如果
Shape
包含矩形面积和
intersects
方法返回
true
和遏制的计算是执行太贵。
Area
,
intersects(double, double, double, double)
boolean contains(Rectangle2D r)
Shape
测试的内部完全包含指定的
Rectangle2D
。的
Shape.contains()
方法允许
Shape
实施保守的回报
false
时:
true
和intersect
Shape
完全包含Rectangle2D
是昂贵的计算。Shapes
这个方法可能返回
false
即使
Shape
包含
Rectangle2D
。的
Area
类执行更精确的几何计算比大多数
Shape
对象,因此可以更准确的答案是需要用。
r
-指定
Rectangle2D
true
如果的
Shape
内部完全包含
false
Rectangle2D
;否则,如果
Shape
包含
Rectangle2D
和
intersects
方法返回
true
和遏制的计算是执行太贵。
contains(double, double, double, double)
PathIterator getPathIterator(AffineTransform at)
Shape
迭代边界提供了访问的
Shape
轮廓的几何。如果一个可选的
AffineTransform
指定返回的坐标在迭代进行相应的转换。
每次调用此方法返回一个新的PathIterator
对象遍历的Shape
几何对象独立于使用任何其他PathIterator
对象同时。
这是建议,但不保证,对象实施Shape
界面分离迭代过程中任何发生在原物体的几何形状的变化可能在这样的迭代。
at
可选
AffineTransform
被应用到坐标作为他们在迭代返回,或
null
如果需要转化的坐标
PathIterator
对象,独立的
Shape
几何遍历。
PathIterator getPathIterator(AffineTransform at, double flatness)
Shape
迭代边界提供了一个扁平的
Shape
外形几何。
只有seg_moveto,seg_lineto,和seg_close点类型通过返回的迭代器。
如果一个可选的AffineTransform
指定返回的坐标在迭代进行相应的转换。
对弯曲段细分总量由flatness
参数控制,它指定在不平的转化曲线任意点偏离回到平坦的路径段的最大距离。请注意,平坦的路径的精度上的限制可能会被悄悄地施加,导致非常小的平坦化参数被视为更大的值。这个限制,如果有一个,是由所使用的特定的实现定义的。
每次调用此方法返回一个新的PathIterator
对象遍历Shape
对象几何独立使用任何其他PathIterator
对象同时。
这是建议,但不保证,对象实施Shape
界面分离迭代过程中任何发生在原物体的几何形状的变化可能在这样的迭代。
at
可选
AffineTransform
被应用到坐标作为他们在迭代返回,或
null
如果需要转化的坐标
flatness
,用近似曲线线段的线段偏离原始曲线上的任何点的最大距离
PathIterator
独立穿越平坦的
Shape
几何角度。
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.