public abstract class RectangularShape extends Object implements Shape, Cloneable
RectangularShape是多个Shape对象的基类,其几何由矩形框架定义。
该类本身并不直接指定任何特定的几何体,而只是提供由Shape对象的整个类别Shape操作方法。
该类提供的操作方法可用于查询和修改矩形框架,为框架子集定义几何图形提供了参考。
| Modifier | Constructor and Description |
|---|---|
protected |
RectangularShape()
这是一个无法直接实例化的抽象类。
|
| Modifier and Type | Method and Description |
|---|---|
Object |
clone()
创建与该对象相同的类和新内容相同的新对象。
|
boolean |
contains(Point2D p)
测试指定 Point2D是的边界内Shape ,如所描述的definition of insideness 。
|
boolean |
contains(Rectangle2D r)
测试
Shape的内部
Shape全部包含指定的
Rectangle2D 。
|
Rectangle |
getBounds()
返回一个整数 Rectangle完全包围Shape 。
|
double |
getCenterX()
返回的框架矩形的中心的X坐标
Shape在
double精度。
|
double |
getCenterY()
返回
Shape中
double的框架矩形中心的Y坐标。
|
Rectangle2D |
getFrame()
返回定义此对象的整体形状的框架 Rectangle2D 。
|
abstract double |
getHeight()
返回
double精度框架矩形的高度。
|
double |
getMaxX()
返回的框架矩形的最大X坐标
Shape在
double精度。
|
double |
getMaxY()
返回最大的窗体矩形的Y坐标
Shape在
double精度。
|
double |
getMinX()
返回的框架矩形的最小X坐标
Shape在
double精度。
|
double |
getMinY()
返回最小的框架矩形的Y坐标
Shape在
double精度。
|
PathIterator |
getPathIterator(AffineTransform at, double flatness)
返回一个迭代器对象,该对象沿
Shape对象的边界进行迭代,并提供对
Shape对象的几何体轮廓的平坦化视图的访问。
|
abstract double |
getWidth()
以
double精度返回框架矩形的宽度。
|
abstract double |
getX()
返回double精度中框架矩形左上角的
double坐标。
|
abstract double |
getY()
以double精度返回框架矩形左上角的
double坐标。
|
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)
设置的位置和此的框架矩形的大小 Shape到指定Point2D和Dimension2D ,分别。
|
void |
setFrame(Rectangle2D r)
设置此窗体矩形
Shape是指定的
Rectangle2D 。
|
void |
setFrameFromCenter(double centerX, double centerY, double cornerX, double cornerY)
根据指定的中心点坐标和角点坐标设置此
Shape的框架矩形。
|
void |
setFrameFromCenter(Point2D center, Point2D corner)
根据指定的中心
Point2D和角
Point2D设置此
Shape的框架
Point2D 。
|
void |
setFrameFromDiagonal(double x1, double y1, double x2, double y2)
根据两个指定坐标设置此
Shape框架矩形的对角线。
|
void |
setFrameFromDiagonal(Point2D p1, Point2D p2)
基于两个指定的
Point2D对象设置此
Shape的框架矩形的对角线。
|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcontains, contains, getBounds2D, getPathIterator, intersectsprotected RectangularShape()
Arc2D , Ellipse2D , Rectangle2D , RoundRectangle2D
public abstract double getX()
double坐标。
public abstract double getY()
double坐标。
public abstract double getWidth()
double精度框架矩形的宽度。
public abstract double getHeight()
double精度框架矩形的高度。
public double getMinX()
Shape在
double精度。
Shape 。
public double getMinY()
Shape在
double精度。
Shape 。
public double getMaxX()
Shape在
double精度。
Shape 。
public double getMaxY()
Shape在
double精度。
Shape 。
public double getCenterX()
Shape在
double精度。
Shape 。
public double getCenterY()
Shape在
double精度。
Shape 。
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)
Shape到指定Point2D和Dimension2D ,分别。
框架矩形由RectangularShape的RectangularShape用于定义其几何。
loc - 指定的
Point2D
size - 指定的
Dimension2D
getFrame()
public void setFrame(Rectangle2D r)
Shape是指定的Rectangle2D 。
框架矩形由RectangularShape的RectangularShape用于定义其几何。
r - 指定的
Rectangle2D
getFrame()
public void setFrameFromDiagonal(double x1,
double y1,
double x2,
double y2)
Shape的框架矩形的对角线。
框架矩形由RectangularShape的RectangularShape用于定义其几何。
x1 - 指定对角线起始点的X坐标
y1 - 指定对角线起始点的Y坐标
x2 - 指定对角线的终点的X坐标
y2 - 指定对角线的终点的Y坐标
public void setFrameFromDiagonal(Point2D p1, Point2D p2)
Point2D对象设置此Shape框架矩形的对角线。
框架矩形由RectangularShape的RectangularShape用于定义其几何。
p1 - 指定对角线的起始
Point2D
p2 - 指定对角线的末端
Point2D
public void setFrameFromCenter(double centerX,
double centerY,
double cornerX,
double cornerY)
Shape的框架矩形。
框架矩形由RectangularShape的RectangularShape用于定义其几何。
centerX - 指定
centerX的X坐标
centerY - 指定
centerY的Y坐标
cornerX - 指定角点的X坐标
cornerY - 指定角点的Y坐标
public void setFrameFromCenter(Point2D center, Point2D corner)
Point2D和角Point2D设置此Shape的框架Point2D 。
框架矩形由RectangularShape的RectangularShape用于定义其几何。
center - 指定中心
Point2D
corner - 指定的角
Point2D
public boolean contains(Point2D p)
Point2D是的边界内Shape ,如所描述的definition of insideness 。
public boolean intersects(Rectangle2D r)
Shape相交指定的内部Rectangle2D 。
该Shape.intersects()方法允许Shape实现谨慎地返回true时:
Rectangle2D和Shape相交的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的内部Shape全部包含指定的Rectangle2D 。
Shape.contains()方法允许一个Shape保守地返回false当:
intersect方法返回true和 Shape完全包含Rectangle2D的代价太高。 Shapes这种方法也可能返回false即使Shape包含Rectangle2D 。
所述Area类比大多数执行更精确的几何计算Shape对象,因此可以在需要更精确的答案一起使用。
contains在界面
Shape
r - 指定的
Rectangle2D
true如果内部的Shape完全包含Rectangle2D ;
false否则或如果Shape包含Rectangle2D和intersects方法返回true并且包含计算将太昂贵执行。
Shape.contains(double, double, double, double)
public Rectangle getBounds()
Rectangle完全包围Shape 。
需要注意的是没有保证返回Rectangle是最小的边框包围Shape ,只表示Shape完全在指定的范围内Rectangle 。
如果Shape溢出了整数数据类型的有限范围,那么返回的Rectangle也可能无法完全包含Shape 。
getBounds2D方法通常返回更严格的边界框,因为它具有更大的表示灵活性。
需要注意的是definition of insideness可能会导致出现对的定义轮廓点的情况下shape可能不被认为包含在返回bounds对象,但只有在这些点也未审议了原有的情况下shape 。
如果point是内部shape根据contains(point)方法,那么它必须是内部返回Rectangle界限根据对象contains(point)所述的方法bounds 。 特别:
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 - 要在迭代中返回时应用于
at的可选
AffineTransform ,如果需要未转换的
null ,则为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.