矩形

Inheritance: java.lang.Object, com.aspose.ms.System.ValueType, com.aspose.ms.lang.Struct

public class Rectangle extends Struct<Rectangle>

存储表示矩形位置和大小的四个整数。

构造函数

构造函数描述
Rectangle()
Rectangle(int x, int y, int width, int height)使用指定的位置和大小初始化 com.aspose.imaging.Rectangle 结构的新实例。
Rectangle(Point location, Size size)使用指定的位置和大小初始化 com.aspose.imaging.Rectangle 结构的新实例。

方法

方法描述
getEmpty()获取一个 com.aspose.imaging.Rectangle 结构的新实例,其 com.aspose.imaging.Rectangle.Xcom.aspose.imaging.Rectangle.Ycom.aspose.imaging.Rectangle.Widthcom.aspose.imaging.Rectangle.Height 值均为零。
fromPoints(Point point1, Point point2)根据指定的两个点创建一个新的 Rectangle
ceiling(RectangleF value)通过将指定的 com.aspose.imaging.RectangleF 结构的值向上取整为下一个更高的整数,将其转换为 com.aspose.imaging.Rectangle 结构。
truncate(RectangleF value)通过截断指定的 com.aspose.imaging.RectangleF 的值,将其转换为 com.aspose.imaging.Rectangle
round(RectangleF value)将指定的 com.aspose.imaging.RectangleF 转换为 com.aspose.imaging.Rectangle,通过将 com.aspose.imaging.RectangleF 的值四舍五入为最接近的整数值。
inflate(Rectangle rect, int x, int y)创建并返回指定的 com.aspose.imaging.Rectangle 结构的膨胀副本。
intersect(Rectangle a, Rectangle b)返回第三个 com.aspose.imaging.Rectangle 结构,表示另外两个 com.aspose.imaging.Rectangle 结构的交集。
union(Rectangle a, Rectangle b)获取一个包含两个 com.aspose.imaging.Rectangle 结构并集的 com.aspose.imaging.Rectangle 结构。
op_Equality(Rectangle left, Rectangle right)测试两个 com.aspose.imaging.Rectangle 结构的位置和大小是否相等。
op_Inequality(Rectangle left, Rectangle right)测试两个 com.aspose.imaging.Rectangle 结构的位置或大小是否不同。
fromLeftTopRightBottom(int left, int top, int right, int bottom)使用指定的边缘位置创建一个 com.aspose.imaging.Rectangle 结构。
isEquals(Rectangle obj1, Rectangle obj2)
getLocation()获取或设置此 com.aspose.imaging.Rectangle 结构左上角的坐标。
setLocation(Point value)获取或设置此 com.aspose.imaging.Rectangle 结构左上角的坐标。
getSize()获取或设置此 com.aspose.imaging.Rectangle 的大小。
setSize(Size value)获取或设置此 com.aspose.imaging.Rectangle 的大小。
getX()获取或设置此 com.aspose.imaging.Rectangle 结构左上角的 x 坐标。
setX(int value)获取或设置此 com.aspose.imaging.Rectangle 结构左上角的 x 坐标。
getY()获取或设置此 com.aspose.imaging.Rectangle 结构左上角的 y 坐标。
setY(int value)获取或设置此 com.aspose.imaging.Rectangle 结构左上角的 y 坐标。
getWidth()获取此 com.aspose.imaging.Rectangle 结构的宽度。
setWidth(int value)设置此 com.aspose.imaging.Rectangle 结构的宽度。
getHeight()获取或设置此 com.aspose.imaging.Rectangle 结构的高度。
setHeight(int value)获取或设置此 com.aspose.imaging.Rectangle 结构的高度。
getLeft()获取或设置此 com.aspose.imaging.Rectangle 结构左边缘的 x 坐标。
setLeft(int value)获取或设置此 com.aspose.imaging.Rectangle 结构左边缘的 x 坐标。
getTop()获取或设置此 com.aspose.imaging.Rectangle 结构顶部边缘的 y 坐标。
setTop(int value)获取或设置此 com.aspose.imaging.Rectangle 结构顶部边缘的 y 坐标。
getRight()获取或设置此 com.aspose.imaging.Rectangle 结构的 x 坐标,该坐标为 com.aspose.imaging.Rectangle.Xcom.aspose.imaging.Rectangle.Width 属性值之和。
setRight(int value)获取或设置此 com.aspose.imaging.Rectangle 结构的 x 坐标,该坐标为 com.aspose.imaging.Rectangle.Xcom.aspose.imaging.Rectangle.Width 属性值之和。
getBottom()获取或设置此 com.aspose.imaging.Rectangle 结构的 y 坐标,该坐标为 com.aspose.imaging.Rectangle.Ycom.aspose.imaging.Rectangle.Height 属性值之和。
setBottom(int value)获取或设置此 com.aspose.imaging.Rectangle 结构的 y 坐标,该坐标为 com.aspose.imaging.Rectangle.Ycom.aspose.imaging.Rectangle.Height 属性值之和。
isEmpty()获取一个值,指示此 com.aspose.imaging.Rectangle 的所有数值属性是否为零。
contains(int x, int y)确定指定的点是否包含在此 com.aspose.imaging.Rectangle 结构中。
contains(Point point)确定指定的点是否包含在此 com.aspose.imaging.Rectangle 结构中。
contains(Rectangle rect)确定由 rect 表示的矩形区域是否完全包含在此 com.aspose.imaging.Rectangle 结构中。
inflate(int width, int height)按指定量膨胀此 com.aspose.imaging.Rectangle
inflate(Size size)按指定量膨胀此 com.aspose.imaging.Rectangle
intersect(Rectangle rect)用自身与指定的 com.aspose.imaging.Rectangle 的交集替换此 com.aspose.imaging.Rectangle
intersectsWith(Rectangle rect)确定此矩形是否与 rect 相交。
offset(Point pos)按指定量调整此矩形的位置。
offset(int x, int y)按指定量调整此矩形的位置。
normalize()通过使宽度和高度为正、左侧小于右侧、顶部小于底部来规范化矩形。
equals(Object obj)测试 obj 是否为具有此 com.aspose.imaging.Rectangle 结构相同位置和大小的 com.aspose.imaging.Rectangle 结构。
hashCode()返回此 com.aspose.imaging.Rectangle 结构的哈希码。
toString()将此 com.aspose.imaging.Rectangle 的属性转换为可读的字符串。
CloneTo(Rectangle that)
Clone()

Rectangle()

public Rectangle()

Rectangle(int x, int y, int width, int height)

public Rectangle(int x, int y, int width, int height)

使用指定的位置和大小初始化 com.aspose.imaging.Rectangle 结构的新实例。

Parameters:

参数类型描述
xint矩形左上角的 x 坐标。
yint矩形左上角的 y 坐标。
宽度int矩形的宽度。
高度int矩形的高度。

Rectangle(Point location, Size size)

public Rectangle(Point location, Size size)

使用指定的位置和大小初始化 com.aspose.imaging.Rectangle 结构的新实例。

Parameters:

参数类型描述
locationPointcom.aspose.imaging.Point 表示矩形区域的左上角。
sizeSizecom.aspose.imaging.Size 表示矩形区域的宽度和高度。

getEmpty()

public static Rectangle getEmpty()

获取一个 com.aspose.imaging.Rectangle 结构的新实例,其 com.aspose.imaging.Rectangle.Xcom.aspose.imaging.Rectangle.Ycom.aspose.imaging.Rectangle.Widthcom.aspose.imaging.Rectangle.Height 值均为零。

Returns: Rectangle

fromPoints(Point point1, Point point2)

public static Rectangle fromPoints(Point point1, Point point2)

从指定的两个点创建一个新的 Rectangle。创建的 Rectangle 的两个垂直边将等于传入的 point1point2。这些通常是相对的顶点。

Parameters:

参数类型描述
point1Point新矩形的第一个 Point
point2Point新矩形的第二个 Point

Returns: Rectangle - A newly created Rectangle.

ceiling(RectangleF value)

public static Rectangle ceiling(RectangleF value)

通过将指定的 com.aspose.imaging.RectangleF 结构的值向上取整为下一个更高的整数,将其转换为 com.aspose.imaging.Rectangle 结构。

Parameters:

参数类型描述
valueRectangleF要转换的 com.aspose.imaging.RectangleF 结构。

Returns: Rectangle - Returns a com.aspose.imaging.Rectangle.

truncate(RectangleF value)

public static Rectangle truncate(RectangleF value)

通过截断指定的 com.aspose.imaging.RectangleF 的值,将其转换为 com.aspose.imaging.Rectangle

Parameters:

参数类型描述
valueRectangleF要转换的 com.aspose.imaging.RectangleF

Returns: Rectangle - A new com.aspose.imaging.Rectangle.

round(RectangleF value)

public static Rectangle round(RectangleF value)

将指定的 com.aspose.imaging.RectangleF 转换为 com.aspose.imaging.Rectangle,通过将 com.aspose.imaging.RectangleF 的值四舍五入为最接近的整数值。

Parameters:

参数类型描述
valueRectangleF要转换的 com.aspose.imaging.RectangleF

Returns: Rectangle - A new com.aspose.imaging.Rectangle.

inflate(Rectangle rect, int x, int y)

public static Rectangle inflate(Rectangle rect, int x, int y)

创建并返回指定 com.aspose.imaging.Rectangle 结构的膨胀副本。副本按指定量膨胀。原始的 com.aspose.imaging.Rectangle 结构保持不变。

Parameters:

参数类型描述
rectRectangle用于开始的 com.aspose.imaging.Rectangle。此矩形不会被修改。
xint水平膨胀此 com.aspose.imaging.Rectangle 的量。
yint垂直膨胀此 com.aspose.imaging.Rectangle 的量。

Returns: Rectangle - The inflated com.aspose.imaging.Rectangle.

intersect(Rectangle a, Rectangle b)

public static Rectangle intersect(Rectangle a, Rectangle b)

返回一个第三个 com.aspose.imaging.Rectangle 结构,表示两个其他 com.aspose.imaging.Rectangle 结构的交集。如果没有交集,则返回一个空的 com.aspose.imaging.Rectangle

Parameters:

参数类型描述
aRectangle第一个用于交集的矩形。
bRectangle第二个用于交集的矩形。

Returns: Rectangle - A com.aspose.imaging.Rectangle that represents the intersection of a and b.

union(Rectangle a, Rectangle b)

public static Rectangle union(Rectangle a, Rectangle b)

获取一个包含两个 com.aspose.imaging.Rectangle 结构并集的 com.aspose.imaging.Rectangle 结构。

Parameters:

参数类型描述
aRectangle第一个用于并集的矩形。
bRectangle第二个用于并集的矩形。

Returns: Rectangle - A com.aspose.imaging.Rectangle structure that bounds the union of the two com.aspose.imaging.Rectangle structures.

op_Equality(Rectangle left, Rectangle right)

public static boolean op_Equality(Rectangle left, Rectangle right)

测试两个 com.aspose.imaging.Rectangle 结构的位置和大小是否相等。

Parameters:

参数类型描述
leftRectangle等号运算符左侧的 com.aspose.imaging.Rectangle 结构。
rightRectangle等号运算符右侧的 com.aspose.imaging.Rectangle 结构。

Returns: boolean - 如果两个 com.aspose.imaging.Rectangle 结构的 com.aspose.imaging.Rectangle.Xcom.aspose.imaging.Rectangle.Ycom.aspose.imaging.Rectangle.Widthcom.aspose.imaging.Rectangle.Height 属性相等,则此运算符返回 true。

op_Inequality(Rectangle left, Rectangle right)

public static boolean op_Inequality(Rectangle left, Rectangle right)

测试两个 com.aspose.imaging.Rectangle 结构的位置或大小是否不同。

Parameters:

参数类型描述
leftRectangle不等号运算符左侧的 com.aspose.imaging.Rectangle 结构。
rightRectangle不等号运算符右侧的 com.aspose.imaging.Rectangle 结构。

Returns: boolean - 如果两个 com.aspose.imaging.Rectangle 结构的 com.aspose.imaging.Rectangle.Xcom.aspose.imaging.Rectangle.Ycom.aspose.imaging.Rectangle.Widthcom.aspose.imaging.Rectangle.Height 属性中有任何不相等,则此运算符返回 true;否则返回 false。

fromLeftTopRightBottom(int left, int top, int right, int bottom)

public static Rectangle fromLeftTopRightBottom(int left, int top, int right, int bottom)

使用指定的边缘位置创建一个 com.aspose.imaging.Rectangle 结构。

Parameters:

参数类型描述
intcom.aspose.imaging.Rectangle 结构左上角的 x 坐标。
intcom.aspose.imaging.Rectangle 结构左上角的 y 坐标。
intcom.aspose.imaging.Rectangle 结构右下角的 x 坐标。
intcom.aspose.imaging.Rectangle 结构右下角的 y 坐标。

Returns: Rectangle - The new com.aspose.imaging.Rectangle that this method creates.

isEquals(Rectangle obj1, Rectangle obj2)

public static boolean isEquals(Rectangle obj1, Rectangle obj2)

Parameters:

参数类型描述
obj1Rectangle
obj2Rectangle

Returns: boolean

getLocation()

public Point getLocation()

获取或设置此 com.aspose.imaging.Rectangle 结构左上角的坐标。

Returns: Point - A com.aspose.imaging.Point that represents the upper-left corner of this com.aspose.imaging.Rectangle structure.

setLocation(Point value)

public void setLocation(Point value)

获取或设置此 com.aspose.imaging.Rectangle 结构左上角的坐标。

Parameters:

参数类型描述
valuePointPoint 表示此 com.aspose.imaging.Rectangle 结构左上角。

getSize()

public Size getSize()

获取或设置此 com.aspose.imaging.Rectangle 的大小。

Returns: Size - A com.aspose.imaging.Size that represents the width and height of this com.aspose.imaging.Rectangle structure.

setSize(Size value)

public void setSize(Size value)

获取或设置此 com.aspose.imaging.Rectangle 的大小。

Parameters:

参数类型描述
valueSizecom.aspose.imaging.Size 表示此 com.aspose.imaging.Rectangle 结构的宽度和高度。

getX()

public int getX()

获取或设置此 com.aspose.imaging.Rectangle 结构左上角的 x 坐标。

Returns: int - 此 com.aspose.imaging.Rectangle 结构左上角的 x 坐标。

setX(int value)

public void setX(int value)

获取或设置此 com.aspose.imaging.Rectangle 结构左上角的 x 坐标。

Parameters:

参数类型描述
valueintcom.aspose.imaging.Rectangle 结构左上角的 x 坐标。

getY()

public int getY()

获取或设置此 com.aspose.imaging.Rectangle 结构左上角的 y 坐标。

Returns: int - 此 com.aspose.imaging.Rectangle 结构左上角的 y 坐标。

setY(int value)

public void setY(int value)

获取或设置此 com.aspose.imaging.Rectangle 结构左上角的 y 坐标。

Parameters:

参数类型描述
valueintcom.aspose.imaging.Rectangle 结构左上角的 y 坐标。

getWidth()

public int getWidth()

获取此 com.aspose.imaging.Rectangle 结构的宽度。

Returns: int - 此 com.aspose.imaging.Rectangle 结构的宽度。

setWidth(int value)

public void setWidth(int value)

设置此 com.aspose.imaging.Rectangle 结构的宽度。

Parameters:

参数类型描述
valueintcom.aspose.imaging.Rectangle 结构的宽度。

getHeight()

public int getHeight()

获取或设置此 com.aspose.imaging.Rectangle 结构的高度。

Returns: int - 此 com.aspose.imaging.Rectangle 结构的高度。

setHeight(int value)

public void setHeight(int value)

获取或设置此 com.aspose.imaging.Rectangle 结构的高度。

Parameters:

参数类型描述
valueintcom.aspose.imaging.Rectangle 结构的高度。

getLeft()

public int getLeft()

获取或设置此 com.aspose.imaging.Rectangle 结构左边缘的 x 坐标。

Returns: int - 此 com.aspose.imaging.Rectangle 结构左边缘的 x 坐标。

setLeft(int value)

public void setLeft(int value)

获取或设置此 com.aspose.imaging.Rectangle 结构左边缘的 x 坐标。

Parameters:

参数类型描述
valueintcom.aspose.imaging.Rectangle 结构左边缘的 x 坐标。

getTop()

public int getTop()

获取或设置此 com.aspose.imaging.Rectangle 结构顶部边缘的 y 坐标。

Returns: int - 此 com.aspose.imaging.Rectangle 结构顶部边缘的 y 坐标。

setTop(int value)

public void setTop(int value)

获取或设置此 com.aspose.imaging.Rectangle 结构顶部边缘的 y 坐标。

Parameters:

参数类型描述
valueintcom.aspose.imaging.Rectangle 结构顶部边缘的 y 坐标。

getRight()

public int getRight()

获取或设置此 com.aspose.imaging.Rectangle 结构的 x 坐标,该坐标为 com.aspose.imaging.Rectangle.Xcom.aspose.imaging.Rectangle.Width 属性值之和。

Returns: int - 此 com.aspose.imaging.Rectanglecom.aspose.imaging.Rectangle.Xcom.aspose.imaging.Rectangle.Width 的和所得到的 x 坐标。

setRight(int value)

public void setRight(int value)

获取或设置此 com.aspose.imaging.Rectangle 结构的 x 坐标,该坐标为 com.aspose.imaging.Rectangle.Xcom.aspose.imaging.Rectangle.Width 属性值之和。

Parameters:

参数类型描述
valueintcom.aspose.imaging.Rectanglecom.aspose.imaging.Rectangle.Xcom.aspose.imaging.Rectangle.Width 的和所得到的 x 坐标。

getBottom()

public int getBottom()

获取或设置此 com.aspose.imaging.Rectangle 结构的 y 坐标,该坐标为 com.aspose.imaging.Rectangle.Ycom.aspose.imaging.Rectangle.Height 属性值之和。

Returns: int - 此 com.aspose.imaging.Rectanglecom.aspose.imaging.Rectangle.Ycom.aspose.imaging.Rectangle.Height 的和所得到的 y 坐标。

setBottom(int value)

public void setBottom(int value)

获取或设置此 com.aspose.imaging.Rectangle 结构的 y 坐标,该坐标为 com.aspose.imaging.Rectangle.Ycom.aspose.imaging.Rectangle.Height 属性值之和。

Parameters:

参数类型描述
valueintcom.aspose.imaging.Rectanglecom.aspose.imaging.Rectangle.Ycom.aspose.imaging.Rectangle.Height 的和所得到的 y 坐标。

isEmpty()

public boolean isEmpty()

获取一个值,指示此 com.aspose.imaging.Rectangle 的所有数值属性是否为零。

Returns: boolean - 如果此 com.aspose.imaging.Rectanglecom.aspose.imaging.Rectangle.Widthcom.aspose.imaging.Rectangle.Heightcom.aspose.imaging.Rectangle.Xcom.aspose.imaging.Rectangle.Y 属性全部为零,则此属性返回 true;否则返回 false。

contains(int x, int y)

public boolean contains(int x, int y)

确定指定的点是否包含在此 com.aspose.imaging.Rectangle 结构中。

Parameters:

参数类型描述
xint要测试的点的 x 坐标。
yint要测试的点的 y 坐标。

Returns: boolean - 如果由 xy 定义的点位于此 com.aspose.imaging.Rectangle 结构内部,则此方法返回 true;否则返回 false。

contains(Point point)

public boolean contains(Point point)

确定指定的点是否包含在此 com.aspose.imaging.Rectangle 结构中。

Parameters:

参数类型描述
pointPoint要测试的 com.aspose.imaging.Point

Returns: boolean - 如果由 point 表示的点位于此 com.aspose.imaging.Rectangle 结构内部,则此方法返回 true;否则返回 false。

contains(Rectangle rect)

public boolean contains(Rectangle rect)

确定由 rect 表示的矩形区域是否完全包含在此 com.aspose.imaging.Rectangle 结构中。

Parameters:

参数类型描述
rectRectangle要测试的 com.aspose.imaging.Rectangle

Returns: boolean - 如果由 rect 表示的矩形区域完全位于此 com.aspose.imaging.Rectangle 结构内部,则此方法返回 true;否则返回 false。

inflate(int width, int height)

public void inflate(int width, int height)

按指定量膨胀此 com.aspose.imaging.Rectangle

Parameters:

参数类型描述
宽度int水平膨胀此 com.aspose.imaging.Rectangle 的量。
高度int垂直膨胀此 com.aspose.imaging.Rectangle 的量。

inflate(Size size)

public void inflate(Size size)

按指定量膨胀此 com.aspose.imaging.Rectangle

Parameters:

参数类型描述
sizeSize膨胀此矩形的量。

intersect(Rectangle rect)

public void intersect(Rectangle rect)

用自身与指定的 com.aspose.imaging.Rectangle 的交集替换此 com.aspose.imaging.Rectangle

Parameters:

参数类型描述
rectRectangle用于相交的 com.aspose.imaging.Rectangle

intersectsWith(Rectangle rect)

public boolean intersectsWith(Rectangle rect)

确定此矩形是否与 rect 相交。

Parameters:

参数类型描述
rectRectangle要测试的矩形。

Returns: boolean - 如果存在任何相交,则此方法返回 true;否则返回 false。

offset(Point pos)

public void offset(Point pos)

按指定量调整此矩形的位置。

Parameters:

参数类型描述
posPoint位置的偏移量。

offset(int x, int y)

public void offset(int x, int y)

按指定量调整此矩形的位置。

Parameters:

参数类型描述
xint水平偏移量。
yint垂直偏移量。

normalize()

public void normalize()

通过使宽度和高度为正、左侧小于右侧、顶部小于底部来规范化矩形。

equals(Object obj)

public boolean equals(Object obj)

测试 obj 是否为具有此 com.aspose.imaging.Rectangle 结构相同位置和大小的 com.aspose.imaging.Rectangle 结构。

Parameters:

参数类型描述
objjava.lang.Object用于测试的 System.Object

Returns: boolean - 如果 objcom.aspose.imaging.Rectangle 结构且其 com.aspose.imaging.Rectangle.Xcom.aspose.imaging.Rectangle.Ycom.aspose.imaging.Rectangle.Widthcom.aspose.imaging.Rectangle.Height 属性等于此 com.aspose.imaging.Rectangle 结构的对应属性,则此方法返回 true;否则返回 false。

hashCode()

public int hashCode()

返回此 com.aspose.imaging.Rectangle 结构的哈希码。

Returns: int - 表示此矩形哈希码的整数。

toString()

public String toString()

将此 com.aspose.imaging.Rectangle 的属性转换为可读的字符串。

Returns: java.lang.String - 包含此 com.aspose.imaging.Rectangle 结构的位置、宽度和高度的字符串。

CloneTo(Rectangle that)

public void CloneTo(Rectangle that)

Parameters:

参数类型描述
thatRectangle

Clone()

public Rectangle Clone()

Returns: Rectangle