public class Area extends Object implements Shape, Cloneable
Area
对象存储和操纵一个分辨率独立描述封闭区域的二维空间。
Area
对象可以转化,可以执行各种建筑面积几何(CAG)操作时结合其他
Area
对象。CAG业务包括地区
addition
,
subtraction
,
intersection
,和
exclusive or
。查看链接的方法文档的各种操作的例子。
的Area
类实现Shape
接口并提供其所有命中测试和路径迭代设施的全面支持,但Area
比在许多方面更具体的广义路径:
Area
对象隐式关闭施工期间如果这些路径被Graphics2D.fill
方法填充。Area
纲要相似路径从它只因为它描述同一封闭的二维区域,但可能会使用完全不同的类型和排序的路径段这样做。Area
包括:
Area
(开)Shape
结果在Area
对象封闭轮廓。Shape
包围没有面积Area
(即使“封闭”)产生一个空的Area
。这个问题的一个常见的例子是,从生产线Area
将空自线包围面积没。一个空的Area
迭代没有几何对象的PathIterator
。Shape
可能分裂成两个(或更多)的子路径围绕一种非相交的部分原始路径。Area
可能需要更多的路径段来描述同一个几何即使原始轮廓是显而易见的。这Area
类必须对路径进行分析可能不反映同一概念的“浅显”作为人类感知。Constructor and Description |
---|
Area()
创建一个空区域的默认构造函数。
|
Area(Shape s)
Area 类创建的对象从指定的
Shape 面积几何。
|
Modifier and Type | Method and Description |
---|---|
void |
add(Area rhs)
添加指定
Area 形状这
Area 形状。
|
Object |
clone()
返回该对象的精确副本
Area 。
|
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 。
|
Area |
createTransformedArea(AffineTransform t)
创建一个新的
Area 对象具有相同几何这
Area 由指定的
AffineTransform 转化。
|
boolean |
equals(Area other)
测试是否两
Area 物体的几何形状是平等的。
|
void |
exclusiveOr(Area rhs)
集是其目前的形状组合区域的指定
Area 和形状这
Area 形状,减它们的交集。
|
Rectangle |
getBounds()
返回一个包围
Rectangle 完全包围这
Area 。
|
Rectangle2D |
getBounds2D()
返回一个高精度的边界
Rectangle2D 完全包围这
Area 。
|
PathIterator |
getPathIterator(AffineTransform at)
创建一个物体的轮廓
PathIterator 这
Area 。
|
PathIterator |
getPathIterator(AffineTransform at, double flatness)
创建一个扁平的轮廓,这
Area 对象
PathIterator 。
|
void |
intersect(Area rhs)
集在其目前的形状交指定的
Area 和形状这
Area 形状。
|
boolean |
intersects(double x, double y, double w, double h)
如果
Shape 测试的内部与一个指定的矩形区域内。
|
boolean |
intersects(Rectangle2D r)
如果
Shape 测试的内部与指定的
Rectangle2D 内部。
|
boolean |
isEmpty()
测试是否
Area 对象封装任何地区。
|
boolean |
isPolygonal()
测试是否
Area 完全由直边的多边形几何。
|
boolean |
isRectangular()
测试是否
Area 形状为矩形。
|
boolean |
isSingular()
测试是否
Area 是由一个单一的封闭路径。
|
void |
reset()
删除所有从这个
Area 几何和恢复到空白区域。
|
void |
subtract(Area rhs)
从这
Area 形状减去指定的
Area 形状。
|
void |
transform(AffineTransform t)
将几何这
Area 使用指定的
AffineTransform 。
|
public Area()
public Area(Shape s)
s
-
Shape
从该地区的构造
NullPointerException
-如果
s
是空的
public void add(Area rhs)
Area
形状这
Area
形状。由此产生的形状,这
Area
将包括两个形状的结合,或所有的地区,包含在这或指定的
Area
。
/ /例如:A1区=新地区([三角0,0 = > 8,0 = > 0.8 ]);区A2 =新地区([三角0,0 = > 8,0 = > 8,8 ]);添加A1(A2);A1(前)+ A2 = A1(后)################ ################ ############################## ############## ############################ ############ ########################## ########## ######################## ######## ###################### ###### ###### ####### # # # # # # # # # # # # # # ## # # # # # # #
rhs
-
Area
被添加到当前的形状
NullPointerException
-如果
rhs
是空的
public void subtract(Area rhs)
Area
形状减去指定的
Area
形状。产生的形状,这
Area
将包括,只包含在这
Area
不在指定的
Area
/ /例如:A1区=新地区([三角0,0 = > 8,0 = > 0.8 ]);区A2 =新地区([三角0,0 = > 8,0 = > 8,8 ]);A1减(A2);A1(前)- A2 = A1(后)################ ############################## ############## # ############# ############ # # # ########### ########## ############## ######## ############## ###### ####### # # # # # # # # # # ## # # # # #地区。
rhs
-
Area
应该从当前的形状中减去
NullPointerException
-如果
rhs
是空的
public void intersect(Area rhs)
Area
和形状这
Area
形状。由此产生的形状,这
Area
将只包括地区被包含在这
Area
并在指定的
Area
。
/ /例如:A1区=新地区([三角0,0 = > 8,0 = > 0.8 ]);区A2 =新地区([三角0,0 = > 8,0 = > 8,8 ]);A1相交(A2);A1(前)相交A2 = A1(后)################ ################ ############################## ############## ######################## ############ ################## ########## # # # ######### ############## ####### # # # # # # ## # # #
rhs
-
Area
是相交的这
Area
NullPointerException
-如果
rhs
是空的
public void exclusiveOr(Area rhs)
Area
和形状这
Area
形状,减它们的交集。由此产生的形状,这
Area
将只包括区域是包含在这
Area
或在指定的
Area
,但不在。
/ /例如:A1区=新地区([三角0,0 = > 8,0 = > 0.8 ]);区A2 =新地区([三角0,0 = > 8,0 = > 8,8 ]);A1。异或(A2);A1(前)异或A2 = A1(后)################ ############################## ############## # # # ############# ############ # # # # # # # ########### ########## ###### ############## ######## ###################### ###### ###### ####### # # # # # # # # # # # # # # ## # # # # # # #
rhs
-
Area
是异或这
Area
。
NullPointerException
-如果
rhs
是空的
public void reset()
Area
几何和恢复到空白区域。
public boolean isEmpty()
Area
对象封装任何地区。
true
Area
对象代表一个空区;
false
否则。
public boolean isPolygonal()
Area
完全由直边的多边形几何。
true
如果这
Area
几何完全由直线段;
false
否则。
public boolean isRectangular()
Area
形状为矩形。
true
如果这
Area
几何形状为矩形;
false
否则。
public boolean isSingular()
true
如果
Area
是由一个单一的基本几何;
false
否则。
public Rectangle2D getBounds2D()
getBounds2D
接口
Shape
Rectangle2D
为
Area
。
Shape.getBounds()
public Rectangle getBounds()
Rectangle
这
Area
地区等级将尝试返回严密包围盒的形状可能。包围盒将不会被填充包括在轮廓轮廓中的曲线的控制点,但应该紧密贴合轮廓本身的实际几何形状。由于返回的对象表示具有整数的包围盒,包围盒只能是紧的,因为最近的整数坐标,包括形状的几何形状。
完全封闭。getBounds
接口
Shape
Rectangle
为
Area
。
Shape.getBounds2D()
public Object clone()
Area
。
public boolean equals(Area other)
Area
物体的几何形状是平等的。如果参数为空,则此方法将返回错误。
other
-
Area
加以比较,这
Area
true
如果两个几何体都是平等的;
false
否则。
public void transform(AffineTransform t)
Area
使用指定的
AffineTransform
。几何变换的位置,它永久性地改变由这个对象定义的封闭区域。
t
-用于转换区的改造
NullPointerException
-如果
t
是空的
public Area createTransformedArea(AffineTransform t)
Area
对象具有相同几何这
Area
由指定的
AffineTransform
转化。这
Area
对象是不变的。
t
-指定
AffineTransform
用来变换新的
Area
Area
表示转化为几何。
NullPointerException
-如果
t
是空的
public boolean contains(double x, double y)
Shape
边界内,由
definition of insideness描述。
public boolean contains(Point2D p)
public 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
对象,因此可以更准确的答案是需要用。
contains
接口
Shape
x
-指定的矩形区域左上角的x坐标
y
-指定的矩形区域的左上角的Y坐标
w
-指定的矩形区域的宽度
h
-指定矩形区域的高度
true
如果的
Shape
内部完全包含指定矩形区域;
false
否则,如果
Shape
包含矩形面积和
intersects
方法返回
true
和遏制的计算是执行太贵。
Area
,
Shape.intersects(double, double, double, double)
public boolean contains(Rectangle2D r)
Shape
测试的内部完全包含指定的
Rectangle2D
。的
Shape.contains()
方法允许
Shape
实施保守的回报
false
时:
true
和intersect
Shape
完全包含Rectangle2D
是昂贵的计算。Shapes
这个方法可能返回
false
即使
Shape
包含
Rectangle2D
。的
Area
类执行更精确的几何计算比大多数
Shape
对象,因此可以更准确的答案是需要用。
contains
接口
Shape
r
-指定
Rectangle2D
true
如果的
Shape
内部完全包含
false
Rectangle2D
;否则,如果
Shape
包含
Rectangle2D
和
intersects
方法返回
true
和遏制的计算是执行太贵。
Shape.contains(double, double, double, double)
public boolean intersects(double x, double y, double w, double h)
Shape
测试的内部与一个指定的矩形区域内。矩形区域是相交的
Shape
如果任何点是否包含在内部的
Shape
和指定的矩形区域。
的Shape.intersects()
方法允许Shape
实施保守的回报true
时:
Shape
相交,但Shapes
这个方法可能返回
true
即使矩形区域不相交的
Shape
。的
Area
类执行更精确的计算几何相交比大多数
Shape
对象,因此可以更准确的答案是需要用。
intersects
接口
Shape
x
-指定的矩形区域左上角的x坐标
y
-指定的矩形区域的左上角的Y坐标
w
-指定的矩形区域的宽度
h
-指定矩形区域的高度
true
如果的
Shape
内部与矩形区域内相交,或是相交,相交计算高度可能会执行
false
否则太贵。
Area
public boolean intersects(Rectangle2D r)
Shape
测试的内部与指定的
Rectangle2D
内部,
Shape.intersects()
方法允许
Shape
实施保守的回报
true
时:
Rectangle2D
和Shape
相交,但Shapes
这个方法可能返回
true
即使
Rectangle2D
不相交的
Shape
,
Area
类执行更精确的计算几何相交比大多数
Shape
对象,因此可以更准确的答案是需要用。
intersects
接口
Shape
r
-指定
Rectangle2D
true
如果的
Shape
内部和指定的
Rectangle2D
内部相交,或是相交,相交计算高度可能会执行
false
否则太贵。
Shape.intersects(double, double, double, double)
public PathIterator getPathIterator(AffineTransform at)
getPathIterator
接口
Shape
at
可选
AffineTransform
被应用到坐标作为他们在迭代返回,或
null
如果需要转化的坐标
PathIterator
对象,返回该
Area
轮廓的几何,每次一段。
public PathIterator getPathIterator(AffineTransform at, double flatness)
Area
对象
PathIterator
。只有弯曲的路径段的seg_moveto,seg_lineto表示,和seg_close点类型通过返回的迭代器。这
Area
对象是不变的。
getPathIterator
接口
Shape
at
可选
AffineTransform
被应用到坐标作为他们在迭代返回,或
null
如果需要转化的坐标
flatness
,给定曲线的控制点可以从之前的细分曲线是通过共线直线连接终结点替换的最大数量
PathIterator
对象,返回该
Area
轮廓的几何,每次一段。
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.