Rectangle
Inheritance: java.lang.Object, com.aspose.ms.System.ValueType, com.aspose.ms.lang.Struct
public class Rectangle extends Struct<Rectangle>
Stores a set of four integers that represent the location and size of a rectangle.
Constructors
Constructor | Description |
---|---|
Rectangle() | |
Rectangle(int x, int y, int width, int height) | Initializes a new instance of the com.aspose.imaging.Rectangle structure with the specified location and size. |
Rectangle(Point location, Size size) | Initializes a new instance of the com.aspose.imaging.Rectangle structure with the specified location and size. |
Methods
Method | Description |
---|---|
getEmpty() | Gets a new instance of the com.aspose.imaging.Rectangle structure that has com.aspose.imaging.Rectangle.X , com.aspose.imaging.Rectangle.Y , com.aspose.imaging.Rectangle.Width and com.aspose.imaging.Rectangle.Height values set to zero. |
fromPoints(Point point1, Point point2) | Creates a new Rectangle from two points specified. |
ceiling(RectangleF value) | Converts the specified com.aspose.imaging.RectangleF structure to a com.aspose.imaging.Rectangle structure by rounding the com.aspose.imaging.RectangleF values to the next higher integer values. |
truncate(RectangleF value) | Converts the specified com.aspose.imaging.RectangleF to a com.aspose.imaging.Rectangle by truncating the com.aspose.imaging.RectangleF values. |
round(RectangleF value) | Converts the specified com.aspose.imaging.RectangleF to a com.aspose.imaging.Rectangle by rounding the com.aspose.imaging.RectangleF values to the nearest integer values. |
inflate(Rectangle rect, int x, int y) | Creates and returns an inflated copy of the specified com.aspose.imaging.Rectangle structure. |
intersect(Rectangle a, Rectangle b) | Returns a third com.aspose.imaging.Rectangle structure that represents the intersection of two other com.aspose.imaging.Rectangle structures. |
union(Rectangle a, Rectangle b) | Gets a com.aspose.imaging.Rectangle structure that contains the union of two com.aspose.imaging.Rectangle structures. |
op_Equality(Rectangle left, Rectangle right) | Tests whether two com.aspose.imaging.Rectangle structures have equal location and size. |
op_Inequality(Rectangle left, Rectangle right) | Tests whether two com.aspose.imaging.Rectangle structures differ in location or size. |
fromLeftTopRightBottom(int left, int top, int right, int bottom) | Creates a com.aspose.imaging.Rectangle structure with the specified edge locations. |
isEquals(Rectangle obj1, Rectangle obj2) | |
getLocation() | Gets or sets the coordinates of the upper-left corner of this com.aspose.imaging.Rectangle structure. |
setLocation(Point value) | Gets or sets the coordinates of the upper-left corner of this com.aspose.imaging.Rectangle structure. |
getSize() | Gets or sets the size of this com.aspose.imaging.Rectangle . |
setSize(Size value) | Gets or sets the size of this com.aspose.imaging.Rectangle . |
getX() | Gets or sets the x-coordinate of the upper-left corner of this com.aspose.imaging.Rectangle structure. |
setX(int value) | Gets or sets the x-coordinate of the upper-left corner of this com.aspose.imaging.Rectangle structure. |
getY() | Gets or sets the y-coordinate of the upper-left corner of this com.aspose.imaging.Rectangle structure. |
setY(int value) | Gets or sets the y-coordinate of the upper-left corner of this com.aspose.imaging.Rectangle structure. |
getWidth() | Gets the width of this com.aspose.imaging.Rectangle structure. |
setWidth(int value) | Sets the width of this com.aspose.imaging.Rectangle structure. |
getHeight() | Gets or sets the height of this com.aspose.imaging.Rectangle structure. |
setHeight(int value) | Gets or sets the height of this com.aspose.imaging.Rectangle structure. |
getLeft() | Gets or sets the x-coordinate of the left edge of this com.aspose.imaging.Rectangle structure. |
setLeft(int value) | Gets or sets the x-coordinate of the left edge of this com.aspose.imaging.Rectangle structure. |
getTop() | Gets or sets the y-coordinate of the top edge of this com.aspose.imaging.Rectangle structure. |
setTop(int value) | Gets or sets the y-coordinate of the top edge of this com.aspose.imaging.Rectangle structure. |
getRight() | Gets or sets the x-coordinate that is the sum of com.aspose.imaging.Rectangle.X and com.aspose.imaging.Rectangle.Width property values of this com.aspose.imaging.Rectangle structure. |
setRight(int value) | Gets or sets the x-coordinate that is the sum of com.aspose.imaging.Rectangle.X and com.aspose.imaging.Rectangle.Width property values of this com.aspose.imaging.Rectangle structure. |
getBottom() | Gets or sets the y-coordinate that is the sum of the com.aspose.imaging.Rectangle.Y and com.aspose.imaging.Rectangle.Height property values of this com.aspose.imaging.Rectangle structure. |
setBottom(int value) | Gets or sets the y-coordinate that is the sum of the com.aspose.imaging.Rectangle.Y and com.aspose.imaging.Rectangle.Height property values of this com.aspose.imaging.Rectangle structure. |
isEmpty() | Gets a value indicating whether all numeric properties of this com.aspose.imaging.Rectangle have values of zero. |
contains(int x, int y) | Determines if the specified point is contained within this com.aspose.imaging.Rectangle structure. |
contains(Point point) | Determines if the specified point is contained within this com.aspose.imaging.Rectangle structure. |
contains(Rectangle rect) | Determines if the rectangular region represented by rect is entirely contained within this com.aspose.imaging.Rectangle structure. |
inflate(int width, int height) | Inflates this com.aspose.imaging.Rectangle by the specified amount. |
inflate(Size size) | Inflates this com.aspose.imaging.Rectangle by the specified amount. |
intersect(Rectangle rect) | Replaces this com.aspose.imaging.Rectangle with the intersection of itself and the specified com.aspose.imaging.Rectangle . |
intersectsWith(Rectangle rect) | Determines if this rectangle intersects with rect . |
offset(Point pos) | Adjusts the location of this rectangle by the specified amount. |
offset(int x, int y) | Adjusts the location of this rectangle by the specified amount. |
normalize() | Normalizes the rectangle by making it’s width and height positive, left less than right and top less than bottom. |
equals(Object obj) | Tests whether obj is a com.aspose.imaging.Rectangle structure with the same location and size of this com.aspose.imaging.Rectangle structure. |
hashCode() | Returns the hash code for this com.aspose.imaging.Rectangle structure. |
toString() | Converts the attributes of this com.aspose.imaging.Rectangle to a human-readable string. |
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)
Initializes a new instance of the com.aspose.imaging.Rectangle
structure with the specified location and size.
Parameters:
Parameter | Type | Description |
---|---|---|
x | int | The x-coordinate of the upper-left corner of the rectangle. |
y | int | The y-coordinate of the upper-left corner of the rectangle. |
width | int | The width of the rectangle. |
height | int | The height of the rectangle. |
Rectangle(Point location, Size size)
public Rectangle(Point location, Size size)
Initializes a new instance of the com.aspose.imaging.Rectangle
structure with the specified location and size.
Parameters:
Parameter | Type | Description |
---|---|---|
location | Point | A com.aspose.imaging.Point that represents the upper-left corner of the rectangular region. |
size | Size | A com.aspose.imaging.Size that represents the width and height of the rectangular region. |
getEmpty()
public static Rectangle getEmpty()
Gets a new instance of the com.aspose.imaging.Rectangle
structure that has com.aspose.imaging.Rectangle.X
, com.aspose.imaging.Rectangle.Y
, com.aspose.imaging.Rectangle.Width
and com.aspose.imaging.Rectangle.Height
values set to zero.
Returns: Rectangle
fromPoints(Point point1, Point point2)
public static Rectangle fromPoints(Point point1, Point point2)
Creates a new Rectangle
from two points specified. Two verticals of the created Rectangle
will be equal to the passed point1
and point2
. These would be typically the opposite vertices.
Parameters:
Parameter | Type | Description |
---|---|---|
point1 | Point | The first Point for the new rectangle. |
point2 | Point | The second Point for the new rectangle. |
Returns:
Rectangle - A newly created Rectangle
.
ceiling(RectangleF value)
public static Rectangle ceiling(RectangleF value)
Converts the specified com.aspose.imaging.RectangleF
structure to a com.aspose.imaging.Rectangle
structure by rounding the com.aspose.imaging.RectangleF
values to the next higher integer values.
Parameters:
Parameter | Type | Description |
---|---|---|
value | RectangleF | The com.aspose.imaging.RectangleF structure to be converted. |
Returns:
Rectangle - Returns a com.aspose.imaging.Rectangle
.
truncate(RectangleF value)
public static Rectangle truncate(RectangleF value)
Converts the specified com.aspose.imaging.RectangleF
to a com.aspose.imaging.Rectangle
by truncating the com.aspose.imaging.RectangleF
values.
Parameters:
Parameter | Type | Description |
---|---|---|
value | RectangleF | The com.aspose.imaging.RectangleF to be converted. |
Returns:
Rectangle - A new com.aspose.imaging.Rectangle
.
round(RectangleF value)
public static Rectangle round(RectangleF value)
Converts the specified com.aspose.imaging.RectangleF
to a com.aspose.imaging.Rectangle
by rounding the com.aspose.imaging.RectangleF
values to the nearest integer values.
Parameters:
Parameter | Type | Description |
---|---|---|
value | RectangleF | The com.aspose.imaging.RectangleF to be converted. |
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)
Creates and returns an inflated copy of the specified com.aspose.imaging.Rectangle
structure. The copy is inflated by the specified amount. The original com.aspose.imaging.Rectangle
structure remains unmodified.
Parameters:
Parameter | Type | Description |
---|---|---|
rect | Rectangle | The com.aspose.imaging.Rectangle with which to start. This rectangle is not modified. |
x | int | The amount to inflate this com.aspose.imaging.Rectangle horizontally. |
y | int | The amount to inflate this com.aspose.imaging.Rectangle vertically. |
Returns:
Rectangle - The inflated com.aspose.imaging.Rectangle
.
intersect(Rectangle a, Rectangle b)
public static Rectangle intersect(Rectangle a, Rectangle b)
Returns a third com.aspose.imaging.Rectangle
structure that represents the intersection of two other com.aspose.imaging.Rectangle
structures. If there is no intersection, an empty com.aspose.imaging.Rectangle
is returned.
Parameters:
Parameter | Type | Description |
---|---|---|
a | Rectangle | A first rectangle to intersect. |
b | Rectangle | A second rectangle to intersect. |
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)
Gets a com.aspose.imaging.Rectangle
structure that contains the union of two com.aspose.imaging.Rectangle
structures.
Parameters:
Parameter | Type | Description |
---|---|---|
a | Rectangle | A first rectangle to union. |
b | Rectangle | A second rectangle to union. |
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)
Tests whether two com.aspose.imaging.Rectangle
structures have equal location and size.
Parameters:
Parameter | Type | Description |
---|---|---|
left | Rectangle | The com.aspose.imaging.Rectangle structure that is to the left of the equality operator. |
right | Rectangle | The com.aspose.imaging.Rectangle structure that is to the right of the equality operator. |
Returns:
boolean - This operator returns true if the two com.aspose.imaging.Rectangle
structures have equal com.aspose.imaging.Rectangle.X
, com.aspose.imaging.Rectangle.Y
, com.aspose.imaging.Rectangle.Width
, and com.aspose.imaging.Rectangle.Height
properties.
op_Inequality(Rectangle left, Rectangle right)
public static boolean op_Inequality(Rectangle left, Rectangle right)
Tests whether two com.aspose.imaging.Rectangle
structures differ in location or size.
Parameters:
Parameter | Type | Description |
---|---|---|
left | Rectangle | The com.aspose.imaging.Rectangle structure that is to the left of the inequality operator. |
right | Rectangle | The com.aspose.imaging.Rectangle structure that is to the right of the inequality operator. |
Returns:
boolean - This operator returns true if any of the com.aspose.imaging.Rectangle.X
, com.aspose.imaging.Rectangle.Y
, com.aspose.imaging.Rectangle.Width
or com.aspose.imaging.Rectangle.Height
properties of the two com.aspose.imaging.Rectangle
structures are unequal; otherwise false.
fromLeftTopRightBottom(int left, int top, int right, int bottom)
public static Rectangle fromLeftTopRightBottom(int left, int top, int right, int bottom)
Creates a com.aspose.imaging.Rectangle
structure with the specified edge locations.
Parameters:
Parameter | Type | Description |
---|---|---|
left | int | The x-coordinate of the upper-left corner of this com.aspose.imaging.Rectangle structure. |
top | int | The y-coordinate of the upper-left corner of this com.aspose.imaging.Rectangle structure. |
right | int | The x-coordinate of the lower-right corner of this com.aspose.imaging.Rectangle structure. |
bottom | int | The y-coordinate of the lower-right corner of this com.aspose.imaging.Rectangle structure. |
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:
Parameter | Type | Description |
---|---|---|
obj1 | Rectangle | |
obj2 | Rectangle |
Returns: boolean
getLocation()
public Point getLocation()
Gets or sets the coordinates of the upper-left corner of this com.aspose.imaging.Rectangle
structure.
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)
Gets or sets the coordinates of the upper-left corner of this com.aspose.imaging.Rectangle
structure.
Parameters:
Parameter | Type | Description |
---|---|---|
value | Point | A Point that represents the upper-left corner of this com.aspose.imaging.Rectangle structure. |
getSize()
public Size getSize()
Gets or sets the size of this 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)
Gets or sets the size of this com.aspose.imaging.Rectangle
.
Parameters:
Parameter | Type | Description |
---|---|---|
value | Size | A com.aspose.imaging.Size that represents the width and height of this com.aspose.imaging.Rectangle structure. |
getX()
public int getX()
Gets or sets the x-coordinate of the upper-left corner of this com.aspose.imaging.Rectangle
structure.
Returns:
int - The x-coordinate of the upper-left corner of this com.aspose.imaging.Rectangle
structure.
setX(int value)
public void setX(int value)
Gets or sets the x-coordinate of the upper-left corner of this com.aspose.imaging.Rectangle
structure.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int | The x-coordinate of the upper-left corner of this com.aspose.imaging.Rectangle structure. |
getY()
public int getY()
Gets or sets the y-coordinate of the upper-left corner of this com.aspose.imaging.Rectangle
structure.
Returns:
int - The y-coordinate of the upper-left corner of this com.aspose.imaging.Rectangle
structure.
setY(int value)
public void setY(int value)
Gets or sets the y-coordinate of the upper-left corner of this com.aspose.imaging.Rectangle
structure.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int | The y-coordinate of the upper-left corner of this com.aspose.imaging.Rectangle structure. |
getWidth()
public int getWidth()
Gets the width of this com.aspose.imaging.Rectangle
structure.
Returns:
int - The width of this com.aspose.imaging.Rectangle
structure.
setWidth(int value)
public void setWidth(int value)
Sets the width of this com.aspose.imaging.Rectangle
structure.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int | The width of this com.aspose.imaging.Rectangle structure. |
getHeight()
public int getHeight()
Gets or sets the height of this com.aspose.imaging.Rectangle
structure.
Returns:
int - The height of this com.aspose.imaging.Rectangle
structure.
setHeight(int value)
public void setHeight(int value)
Gets or sets the height of this com.aspose.imaging.Rectangle
structure.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int | The height of this com.aspose.imaging.Rectangle structure. |
getLeft()
public int getLeft()
Gets or sets the x-coordinate of the left edge of this com.aspose.imaging.Rectangle
structure.
Returns:
int - The x-coordinate of the left edge of this com.aspose.imaging.Rectangle
structure.
setLeft(int value)
public void setLeft(int value)
Gets or sets the x-coordinate of the left edge of this com.aspose.imaging.Rectangle
structure.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int | The x-coordinate of the left edge of this com.aspose.imaging.Rectangle structure. |
getTop()
public int getTop()
Gets or sets the y-coordinate of the top edge of this com.aspose.imaging.Rectangle
structure.
Returns:
int - The y-coordinate of the top edge of this com.aspose.imaging.Rectangle
structure.
setTop(int value)
public void setTop(int value)
Gets or sets the y-coordinate of the top edge of this com.aspose.imaging.Rectangle
structure.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int | The y-coordinate of the top edge of this com.aspose.imaging.Rectangle structure. |
getRight()
public int getRight()
Gets or sets the x-coordinate that is the sum of com.aspose.imaging.Rectangle.X
and com.aspose.imaging.Rectangle.Width
property values of this com.aspose.imaging.Rectangle
structure.
Returns:
int - The x-coordinate that is the sum of com.aspose.imaging.Rectangle.X
and com.aspose.imaging.Rectangle.Width
of this com.aspose.imaging.Rectangle
.
setRight(int value)
public void setRight(int value)
Gets or sets the x-coordinate that is the sum of com.aspose.imaging.Rectangle.X
and com.aspose.imaging.Rectangle.Width
property values of this com.aspose.imaging.Rectangle
structure.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int | The x-coordinate that is the sum of com.aspose.imaging.Rectangle.X and com.aspose.imaging.Rectangle.Width of this com.aspose.imaging.Rectangle . |
getBottom()
public int getBottom()
Gets or sets the y-coordinate that is the sum of the com.aspose.imaging.Rectangle.Y
and com.aspose.imaging.Rectangle.Height
property values of this com.aspose.imaging.Rectangle
structure.
Returns:
int - The y-coordinate that is the sum of com.aspose.imaging.Rectangle.Y
and com.aspose.imaging.Rectangle.Height
of this com.aspose.imaging.Rectangle
.
setBottom(int value)
public void setBottom(int value)
Gets or sets the y-coordinate that is the sum of the com.aspose.imaging.Rectangle.Y
and com.aspose.imaging.Rectangle.Height
property values of this com.aspose.imaging.Rectangle
structure.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int | The y-coordinate that is the sum of com.aspose.imaging.Rectangle.Y and com.aspose.imaging.Rectangle.Height of this com.aspose.imaging.Rectangle . |
isEmpty()
public boolean isEmpty()
Gets a value indicating whether all numeric properties of this com.aspose.imaging.Rectangle
have values of zero.
Returns:
boolean - This property returns true if the com.aspose.imaging.Rectangle.Width
, com.aspose.imaging.Rectangle.Height
, com.aspose.imaging.Rectangle.X
, and com.aspose.imaging.Rectangle.Y
properties of this com.aspose.imaging.Rectangle
all have values of zero; otherwise, false.
contains(int x, int y)
public boolean contains(int x, int y)
Determines if the specified point is contained within this com.aspose.imaging.Rectangle
structure.
Parameters:
Parameter | Type | Description |
---|---|---|
x | int | The x-coordinate of the point to test. |
y | int | The y-coordinate of the point to test. |
Returns:
boolean - This method returns true if the point defined by x
and y
is contained within this com.aspose.imaging.Rectangle
structure; otherwise false.
contains(Point point)
public boolean contains(Point point)
Determines if the specified point is contained within this com.aspose.imaging.Rectangle
structure.
Parameters:
Parameter | Type | Description |
---|---|---|
point | Point | The com.aspose.imaging.Point to test. |
Returns:
boolean - This method returns true if the point represented by point
is contained within this com.aspose.imaging.Rectangle
structure; otherwise false.
contains(Rectangle rect)
public boolean contains(Rectangle rect)
Determines if the rectangular region represented by rect
is entirely contained within this com.aspose.imaging.Rectangle
structure.
Parameters:
Parameter | Type | Description |
---|---|---|
rect | Rectangle | The com.aspose.imaging.Rectangle to test. |
Returns:
boolean - This method returns true if the rectangular region represented by rect
is entirely contained within this com.aspose.imaging.Rectangle
structure; otherwise false.
inflate(int width, int height)
public void inflate(int width, int height)
Inflates this com.aspose.imaging.Rectangle
by the specified amount.
Parameters:
Parameter | Type | Description |
---|---|---|
width | int | The amount to inflate this com.aspose.imaging.Rectangle horizontally. |
height | int | The amount to inflate this com.aspose.imaging.Rectangle vertically. |
inflate(Size size)
public void inflate(Size size)
Inflates this com.aspose.imaging.Rectangle
by the specified amount.
Parameters:
Parameter | Type | Description |
---|---|---|
size | Size | The amount to inflate this rectangle. |
intersect(Rectangle rect)
public void intersect(Rectangle rect)
Replaces this com.aspose.imaging.Rectangle
with the intersection of itself and the specified com.aspose.imaging.Rectangle
.
Parameters:
Parameter | Type | Description |
---|---|---|
rect | Rectangle | The com.aspose.imaging.Rectangle with which to intersect. |
intersectsWith(Rectangle rect)
public boolean intersectsWith(Rectangle rect)
Determines if this rectangle intersects with rect
.
Parameters:
Parameter | Type | Description |
---|---|---|
rect | Rectangle | The rectangle to test. |
Returns: boolean - This method returns true if there is any intersection, otherwise false.
offset(Point pos)
public void offset(Point pos)
Adjusts the location of this rectangle by the specified amount.
Parameters:
Parameter | Type | Description |
---|---|---|
pos | Point | Amount to offset the location. |
offset(int x, int y)
public void offset(int x, int y)
Adjusts the location of this rectangle by the specified amount.
Parameters:
Parameter | Type | Description |
---|---|---|
x | int | The horizontal offset. |
y | int | The vertical offset. |
normalize()
public void normalize()
Normalizes the rectangle by making it’s width and height positive, left less than right and top less than bottom.
equals(Object obj)
public boolean equals(Object obj)
Tests whether obj
is a com.aspose.imaging.Rectangle
structure with the same location and size of this com.aspose.imaging.Rectangle
structure.
Parameters:
Parameter | Type | Description |
---|---|---|
obj | java.lang.Object | The System.Object to test. |
Returns:
boolean - This method returns true if obj
is a com.aspose.imaging.Rectangle
structure and its com.aspose.imaging.Rectangle.X
, com.aspose.imaging.Rectangle.Y
, com.aspose.imaging.Rectangle.Width
, and com.aspose.imaging.Rectangle.Height
properties are equal to the corresponding properties of this com.aspose.imaging.Rectangle
structure; otherwise, false.
hashCode()
public int hashCode()
Returns the hash code for this com.aspose.imaging.Rectangle
structure.
Returns: int - An integer that represents the hash code for this rectangle.
toString()
public String toString()
Converts the attributes of this com.aspose.imaging.Rectangle
to a human-readable string.
Returns:
java.lang.String - A string that contains the position, width, and height of this com.aspose.imaging.Rectangle
structure.
CloneTo(Rectangle that)
public void CloneTo(Rectangle that)
Parameters:
Parameter | Type | Description |
---|---|---|
that | Rectangle |
Clone()
public Rectangle Clone()
Returns: Rectangle