public abstract class RectangularShape extends Object implements Shape, Cloneable
RectangularShape
是一些
Shape
物体的几何是由一个矩形框定义的基类。这类不直接指定任何特定的几何本身,而只是提供操作方法的全品类
Shape
对象继承。由这个类提供的操作方法可以用来查询和修改矩形框,它提供了一个参考的子类来定义它们的几何形状。
Modifier | Constructor and Description |
---|---|
protected |
RectangularShape()
这是一个抽象类不能被直接实例化。
|
Modifier and Type | Method and Description |
---|---|
Object |
clone()
创建同一个类的新对象,并具有与此对象相同的内容。
|
boolean |
contains(Point2D p)
|
boolean |
contains(Rectangle2D r)
如果
Shape 测试的内部完全包含指定的
Rectangle2D 。
|
Rectangle |
getBounds()
返回一个整数
Rectangle 完全封闭
Shape 。
|
double |
getCenterX()
返回的
double 精度
Shape 框架矩形的中心坐标。
|
double |
getCenterY()
返回的
double 精度
Shape 框架矩形中心的Y坐标。
|
Rectangle2D |
getFrame()
返回帧
Rectangle2D 定义这个物体的整体形状。
|
abstract double |
getHeight()
返回框架矩形
double 精度高。
|
double |
getMaxX()
收益最大的X坐标的精度
double
Shape 框架矩形。
|
double |
getMaxY()
返回Y中最大
double 精度
Shape 框架矩形坐标。
|
double |
getMinX()
返回最小的x坐标的精度
double
Shape 框架矩形。
|
double |
getMinY()
返回Y最小精度在
double
Shape 框架矩形坐标。
|
PathIterator |
getPathIterator(AffineTransform at, double flatness)
返回一个迭代器对象沿
Shape 迭代对象的边界,提供了一个扁平的视角对
Shape 对象的几何轮廓。
|
abstract double |
getWidth()
返回框架矩形的宽度
double 精度。
|
abstract double |
getX()
返回的
double 精度框架矩形左上角的x坐标。
|
abstract double |
getY()
返回的
double 精度框架矩形左上角的Y坐标。
|
boolean |
intersects(Rectangle2D r)
如果
Shape 测试的内部与指定的
Rectangle2D 内部。
|
abstract boolean |
isEmpty()
确定
RectangularShape 是空的。
|
abstract void |
setFrame(double x, double y, double w, double h)
设置指定的矩形值位置的
Shape 框架矩形尺寸。
|
void |
setFrame(Point2D loc, Dimension2D size)
|
void |
setFrame(Rectangle2D r)
将指定的
Rectangle2D 这
Shape 框架矩形。
|
void |
setFrameFromCenter(double centerX, double centerY, double cornerX, double cornerY)
设置框架的长方形这
Shape 基于指定的中心点坐标和角点坐标。
|
void |
setFrameFromCenter(Point2D center, Point2D corner)
设置此
Shape 框架矩形的基础上指定的中心
Point2D 角
Point2D 。
|
void |
setFrameFromDiagonal(double x1, double y1, double x2, double y2)
这套框架矩形
Shape 基于两个指定坐标的对角线。
|
void |
setFrameFromDiagonal(Point2D p1, Point2D p2)
设置该
Shape 基于指定两
Point2D 对象框架矩形的对角线。
|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
contains, contains, getBounds2D, getPathIterator, intersects
protected RectangularShape()
Arc2D
,
Ellipse2D
,
Rectangle2D
,
RoundRectangle2D
public abstract double getX()
double
精度框架矩形左上角的x坐标。
public abstract double getY()
double
精度框架矩形左上角的Y坐标。
public abstract double getWidth()
double
精度。
public abstract double getHeight()
double
精度高。
public double getMinX()
double
Shape
框架矩形。
Shape
框架矩形。
public double getMinY()
double
Shape
框架矩形坐标。
Shape
框架矩形坐标。
public double getMaxX()
double
Shape
框架矩形。
Shape
框架矩形。
public double getMaxY()
double
精度
Shape
框架矩形坐标。
Shape
框架矩形坐标。
public double getCenterX()
double
精度
Shape
框架矩形的中心坐标。
Shape
框架矩形的中心坐标。
public double getCenterY()
double
精度
Shape
框架矩形中心的Y坐标。
Shape
框架矩形中心的Y坐标。
public Rectangle2D getFrame()
Rectangle2D
定义这个物体的整体形状。
Rectangle2D
,指定
double
坐标。
setFrame(double, double, double, double)
,
setFrame(Point2D, Dimension2D)
,
setFrame(Rectangle2D)
public abstract boolean isEmpty()
RectangularShape
是空的。当
RectangularShape
是空的,它包含的任何地区。
true
如果
RectangularShape
是空的;
false
否则。
public abstract void setFrame(double x, double y, double w, double h)
Shape
框架矩形尺寸。
x
-指定的矩形的左上角的x坐标
y
-指定的矩形的左上角的Y坐标
w
-指定矩形的宽度
h
-指定矩形的高度
getFrame()
public void setFrame(Point2D loc, Dimension2D size)
loc
-指定
Point2D
size
-指定
Dimension2D
getFrame()
public void setFrame(Rectangle2D r)
Rectangle2D
这
Shape
框架矩形。框架矩形是由
RectangularShape
子类用来定义几何。
r
-指定
Rectangle2D
getFrame()
public void setFrameFromDiagonal(double x1, double y1, double x2, double y2)
Shape
基于两个指定坐标的对角线。框架矩形是由
RectangularShape
子类用来定义几何。
x1
-指定的对角线的出发点的X坐标
y1
-指定的对角出发点的Y坐标
x2
-指定的对角线的结束点的X坐标
y2
-指定的对角线的终点坐标
public void setFrameFromDiagonal(Point2D p1, Point2D p2)
Shape
基于指定两
Point2D
对象框架矩形的对角线。框架矩形是由
RectangularShape
子类用来定义几何。
p1
-指定对角开始
Point2D
p2
-指定对角端
Point2D
public void setFrameFromCenter(double centerX, double centerY, double cornerX, double cornerY)
Shape
基于指定的中心点坐标和角点坐标。框架矩形是由
RectangularShape
子类用来定义几何。
centerX
-指定中心点的x坐标
centerY
-指定中心点的Y坐标
cornerX
-指定角点的X坐标
cornerY
-指定角点的Y坐标
public void setFrameFromCenter(Point2D center, Point2D corner)
Shape
框架矩形的基础上指定的中心
Point2D
角
Point2D
。框架矩形是由
RectangularShape
子类用来定义几何。
center
-指定的中心
Point2D
corner
-指定的角落
Point2D
public boolean contains(Point2D p)
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 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 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)
getBounds
接口
Shape
Rectangle
完全封闭
Shape
。
Shape.getBounds2D()
public PathIterator getPathIterator(AffineTransform at, double flatness)
Shape
迭代对象的边界,提供了一个扁平的视角对
Shape
对象的几何轮廓。
只有seg_moveto,seg_lineto,和seg_close点类型将被返回的迭代器。
对弯曲段细分总量由flatness
参数控制,它指定在不平的转化曲线任意点偏离回到平坦的路径段的最大距离。一个可选的AffineTransform
可以指定使迭代返回相应的坐标变换。
getPathIterator
接口
Shape
at
可选
AffineTransform
被应用到坐标作为他们在迭代返回,或
null
如果需要转化的坐标。
flatness
,用近似曲线线段的线段偏离原始曲线上的任何点的最大距离
PathIterator
对象提供了访问对象的
Shape
的扁平的几何形状。
public Object clone()
clone
方法重写,继承类
Object
OutOfMemoryError
-如果没有足够的内存。
Cloneable
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.