Rectangle

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

All Implemented Interfaces: com.aspose.ms.System.IEquatable, java.lang.Cloneable

public class Rectangle extends Struct<Rectangle> implements System.IEquatable<Rectangle>, Cloneable

Stores a set of four integers that represent the location and size of a rectangle.

Constructors

ConstructorDescription
Rectangle()
Rectangle(int x, int y, int width, int height)Initializes a new instance of the Rectangle structure with the specified location and size.
Rectangle(Point location, Size size)Initializes a new instance of the Rectangle struct with the specified location and size.

Methods

MethodDescription
fromLTRB(int left, int top, int right, int bottom)Creates a Rectangle structure with the specified edge locations.
intersect(Rectangle a, Rectangle b)Returns a third Rectangle structure that represents the intersection of two other Rectangle structures.
op_Equality(Rectangle left, Rectangle right)Tests whether two Rectangle structures have equal location and size.
op_Inequality(Rectangle left, Rectangle right)Tests whether two Rectangle structures differ in location or size.
ceiling(RectangleF value)Converts the specified RectangleF structure to a Rectangle structure by rounding the RectangleF values to the next higher integer values.
truncate(RectangleF value)Converts the specified RectangleF to a Rectangle by truncating the RectangleF values.
round(RectangleF value)Converts the specified RectangleF to a Rectangle by rounding the RectangleF values to the nearest integer values.
union(Rectangle a, Rectangle b)Gets a Rectangle structure that contains the union of two Rectangle structures.
inflate(Rectangle rect, int x, int y)
isEquals(Rectangle obj1, Rectangle obj2)
fromPoints(Point point1, Point point2)Creates a new rectangle from two points.
getEmpty()Gets a new instance of the Rectangle structure that has Rectangle.X, Rectangle.Y, Rectangle.Width and Rectangle.Height values set to zero.
getX()Gets the x-coordinate of the upper-left corner of this Rectangle structure.
setX(int value)Sets the x-coordinate of the upper-left corner of this Rectangle structure.
getY()Gets the y-coordinate of the upper-left corner of this Rectangle structure.
setY(int value)Sets the y-coordinate of the upper-left corner of this Rectangle structure.
getLocation()Gets the coordinates of the upper-left corner of this Rectangle structure.
setLocation(Point value)Sets the coordinates of the upper-left corner of this Rectangle structure.
getWidth()Gets the width of this Rectangle structure.
setWidth(int value)Sets the width of this Rectangle structure.
getHeight()Gets the height of this Rectangle structure.
setHeight(int value)Sets the height of this Rectangle structure.
getSize()Gets the size of this Rectangle.
setSize(Size value)Sets the size of this Rectangle.
getLeft()Gets the x-coordinate of the left edge of this Rectangle structure.
getTop()Gets the y-coordinate of the top edge of this Rectangle structure.
getRight()Gets the x-coordinate that is the sum of X and Width property values of this Rectangle structure.
getBottom()Gets the y-coordinate that is the sum of the Y and Height property values of this Rectangle structure.
isEmpty()Gets a value indicating whether all numeric properties of this Rectangle have values of zero.
equals(Object obj)Tests whether obj is a Rectangle structure with the same location and size of this Rectangle structure.
hashCode()Returns the hash code for this Rectangle structure.
toString()
intersect(Rectangle rect)Replaces this Rectangle with the intersection of itself and the specified Rectangle.
inflate(int width, int height)Enlarges this Rectangle by the specified amount.
inflate(Size size)Enlarges this Rectangle by the specified amount.
contains(int x, int y)Determines if the specified point is contained within this Rectangle structure.
contains(Point pt)Determines if the specified point is contained within this Rectangle structure.
contains(Rectangle rect)
intersectsWith(Rectangle rect)Determines if this rectangle intersects with rect.
offset(int x, int y)Adjusts the location of this rectangle by the specified amount.
offset(Point pos)Adjusts the location of this rectangle by the specified amount.
equals(Rectangle other)Tests whether other Rectangle structure has the same location and size of this Rectangle structure.
CloneTo(Rectangle that)
Clone()
clone()
normalize()Normalizes the rectangle by making it’s width and height positive, left less than right and top less than bottom.

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 Rectangle structure with the specified location and size.

Parameters:

ParameterTypeDescription
xintThe x-coordinate of the upper-left corner of the rectangle.
yintThe y-coordinate of the upper-left corner of the rectangle.
widthintThe width of the rectangle.
heightintThe height of the rectangle.

Rectangle(Point location, Size size)

public Rectangle(Point location, Size size)

Initializes a new instance of the Rectangle struct with the specified location and size.

Parameters:

ParameterTypeDescription
locationPointA Point that represents the upper-left corner of the rectangular region.
sizeSizeA Size(.getSize/.setSize(Size)) that represents the width and height of the rectangular region.

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

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

Creates a Rectangle structure with the specified edge locations.

Parameters:

ParameterTypeDescription
leftintThe x-coordinate of the upper-left corner of this Rectangle structure.
topintThe y-coordinate of the upper-left corner of this Rectangle structure.
rightintThe x-coordinate of the lower-right corner of this Rectangle structure.
bottomintThe y-coordinate of the lower-right corner of this Rectangle structure.

Returns: Rectangle - The new Rectangle that this method creates.

intersect(Rectangle a, Rectangle b)

public static Rectangle intersect(Rectangle a, Rectangle b)

Returns a third Rectangle structure that represents the intersection of two other Rectangle structures. If there is no intersection, an empty Rectangle is returned.

Parameters:

ParameterTypeDescription
aRectangleFirst rectangle to intersect.
bRectangleSecond rectangle to intersect.

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

op_Equality(Rectangle left, Rectangle right)

public static boolean op_Equality(Rectangle left, Rectangle right)

Tests whether two Rectangle structures have equal location and size.

Parameters:

ParameterTypeDescription
leftRectangleThe Rectangle structure that is to the left of the equality operator.
rightRectangleThe Rectangle structure that is to the right of the equality operator.

Returns: boolean - This operator returns true if the two Rectangle structures have equal X, Y, Width, and Height properties.

op_Inequality(Rectangle left, Rectangle right)

public static boolean op_Inequality(Rectangle left, Rectangle right)

Tests whether two Rectangle structures differ in location or size.

Parameters:

ParameterTypeDescription
leftRectangleThe Rectangle structure that is to the left of the inequality operator.
rightRectangleThe Rectangle structure that is to the right of the inequality operator.

Returns: boolean - This operator returns true if any of the X, Y, Width or Height properties of the two Rectangle structures are unequal; otherwise false.

ceiling(RectangleF value)

public static Rectangle ceiling(RectangleF value)

Converts the specified RectangleF structure to a Rectangle structure by rounding the RectangleF values to the next higher integer values.

Parameters:

ParameterTypeDescription
valueRectangleFThe RectangleF structure to be converted.

Returns: Rectangle - Returns a Rectangle.

truncate(RectangleF value)

public static Rectangle truncate(RectangleF value)

Converts the specified RectangleF to a Rectangle by truncating the RectangleF values.

Parameters:

ParameterTypeDescription
valueRectangleFThe RectangleF to be converted.

Returns: Rectangle - The truncated value of the Rectangle.

round(RectangleF value)

public static Rectangle round(RectangleF value)

Converts the specified RectangleF to a Rectangle by rounding the RectangleF values to the nearest integer values.

Parameters:

ParameterTypeDescription
valueRectangleFThe RectangleF to be converted.

Returns: Rectangle - A Rectangle.

union(Rectangle a, Rectangle b)

public static Rectangle union(Rectangle a, Rectangle b)

Gets a Rectangle structure that contains the union of two Rectangle structures.

Parameters:

ParameterTypeDescription
aRectangleA first rectangle to union.
bRectangleA second rectangle to union.

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

inflate(Rectangle rect, int x, int y)

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

Parameters:

ParameterTypeDescription
rectRectangle
xint
yint

Returns: Rectangle

isEquals(Rectangle obj1, Rectangle obj2)

public static boolean isEquals(Rectangle obj1, Rectangle obj2)

Parameters:

ParameterTypeDescription
obj1Rectangle
obj2Rectangle

Returns: boolean

fromPoints(Point point1, Point point2)

public static Rectangle fromPoints(Point point1, Point point2)

Creates a new rectangle from two points. The created rectangle will be normalized with (left,top) lower than (right,bottom).

Parameters:

ParameterTypeDescription
point1PointThe first point.
point2PointThe second point.

Returns: Rectangle - A newly created rectangle.

getEmpty()

public static Rectangle getEmpty()

Gets a new instance of the Rectangle structure that has Rectangle.X, Rectangle.Y, Rectangle.Width and Rectangle.Height values set to zero.

Returns: Rectangle

getX()

public final int getX()

Gets the x-coordinate of the upper-left corner of this Rectangle structure.

Returns: int - the x-coordinate of the upper-left corner of this Rectangle structure.

setX(int value)

public final void setX(int value)

Sets the x-coordinate of the upper-left corner of this Rectangle structure.

Parameters:

ParameterTypeDescription
valueintthe x-coordinate of the upper-left corner of this Rectangle structure.

getY()

public final int getY()

Gets the y-coordinate of the upper-left corner of this Rectangle structure.

Returns: int - the y-coordinate of the upper-left corner of this Rectangle structure.

setY(int value)

public final void setY(int value)

Sets the y-coordinate of the upper-left corner of this Rectangle structure.

Parameters:

ParameterTypeDescription
valueintthe y-coordinate of the upper-left corner of this Rectangle structure.

getLocation()

public final Point getLocation()

Gets the coordinates of the upper-left corner of this Rectangle structure.

Returns: Point - the coordinates of the upper-left corner of this Rectangle structure.

setLocation(Point value)

public final void setLocation(Point value)

Sets the coordinates of the upper-left corner of this Rectangle structure.

Parameters:

ParameterTypeDescription
valuePointthe coordinates of the upper-left corner of this Rectangle structure.

getWidth()

public final int getWidth()

Gets the width of this Rectangle structure.

Returns: int - the width of this Rectangle structure.

setWidth(int value)

public final void setWidth(int value)

Sets the width of this Rectangle structure.

Parameters:

ParameterTypeDescription
valueintthe width of this Rectangle structure.

getHeight()

public final int getHeight()

Gets the height of this Rectangle structure.

Returns: int - the height of this Rectangle structure.

setHeight(int value)

public final void setHeight(int value)

Sets the height of this Rectangle structure.

Parameters:

ParameterTypeDescription
valueintthe height of this Rectangle structure.

getSize()

public final Size getSize()

Gets the size of this Rectangle.

Returns: Size - the size of this Rectangle.

setSize(Size value)

public final void setSize(Size value)

Sets the size of this Rectangle.

Parameters:

ParameterTypeDescription
valueSizethe size of this Rectangle.

getLeft()

public final int getLeft()

Gets the x-coordinate of the left edge of this Rectangle structure.

Returns: int - the x-coordinate of the left edge of this Rectangle structure.

getTop()

public final int getTop()

Gets the y-coordinate of the top edge of this Rectangle structure.

Returns: int - the y-coordinate of the top edge of this Rectangle structure.

getRight()

public final int getRight()

Gets the x-coordinate that is the sum of X and Width property values of this Rectangle structure.

Returns: int - the x-coordinate that is the sum of X and Width property values of this Rectangle structure.

getBottom()

public final int getBottom()

Gets the y-coordinate that is the sum of the Y and Height property values of this Rectangle structure.

Returns: int - the y-coordinate that is the sum of the Y and Height property values of this Rectangle structure.

isEmpty()

public final boolean isEmpty()

Gets a value indicating whether all numeric properties of this Rectangle have values of zero.

Returns: boolean - This property returns true if the Rectangle.Width, Rectangle.Height, Rectangle.X, and Rectangle.Y properties of this Rectangle all have values of zero; otherwise, false.

equals(Object obj)

public boolean equals(Object obj)

Tests whether obj is a Rectangle structure with the same location and size of this Rectangle structure.

Parameters:

ParameterTypeDescription
objjava.lang.ObjectThe Object to test.

Returns: boolean - This method returns true if obj is a Rectangle structure and its X, Y, Width, and Height properties are equal to the corresponding properties of this Rectangle structure; otherwise, false.

hashCode()

public int hashCode()

Returns the hash code for this Rectangle structure. For information about the use of hash codes, see GetHashCode .

Returns: int - An integer that represents the hash code for this rectangle.

toString()

public String toString()

Returns: java.lang.String

intersect(Rectangle rect)

public final void intersect(Rectangle rect)

Replaces this Rectangle with the intersection of itself and the specified Rectangle.

Parameters:

ParameterTypeDescription
rectRectangleThe Rectangle with which to intersect.

inflate(int width, int height)

public final void inflate(int width, int height)

Enlarges this Rectangle by the specified amount.

Parameters:

ParameterTypeDescription
widthintThe amount to inflate this Rectangle horizontally.
heightintThe amount to inflate this Rectangle vertically.

inflate(Size size)

public final void inflate(Size size)

Enlarges this Rectangle by the specified amount.

Parameters:

ParameterTypeDescription
sizeSizeThe size to inflate this Rectangle.

contains(int x, int y)

public final boolean contains(int x, int y)

Determines if the specified point is contained within this Rectangle structure.

Parameters:

ParameterTypeDescription
xintThe x-coordinate of the point to test.
yintThe 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 Rectangle structure; otherwise false.

contains(Point pt)

public final boolean contains(Point pt)

Determines if the specified point is contained within this Rectangle structure.

Parameters:

ParameterTypeDescription
ptPointThe Point to test.

Returns: boolean - This method returns true if the point represented by pt is contained within this Rectangle structure; otherwise false.

contains(Rectangle rect)

public final boolean contains(Rectangle rect)

Parameters:

ParameterTypeDescription
rectRectangle

Returns: boolean

intersectsWith(Rectangle rect)

public final boolean intersectsWith(Rectangle rect)

Determines if this rectangle intersects with rect.

Parameters:

ParameterTypeDescription
rectRectangleThe rectangle to test.

Returns: boolean - This method returns true if there is any intersection, otherwise false.

offset(int x, int y)

public final void offset(int x, int y)

Adjusts the location of this rectangle by the specified amount.

Parameters:

ParameterTypeDescription
xintThe horizontal offset.
yintThe vertical offset.

offset(Point pos)

public final void offset(Point pos)

Adjusts the location of this rectangle by the specified amount.

Parameters:

ParameterTypeDescription
posPointThe offset.

equals(Rectangle other)

public final boolean equals(Rectangle other)

Tests whether other Rectangle structure has the same location and size of this Rectangle structure.

Parameters:

ParameterTypeDescription
otherRectangleOther rectangle to test

Returns: boolean - This method returns true if other Rectangle structure and its X, Y, Width, and Height properties are equal to the corresponding properties of this Rectangle structure; otherwise, false.

CloneTo(Rectangle that)

public void CloneTo(Rectangle that)

Parameters:

ParameterTypeDescription
thatRectangle

Clone()

public Rectangle Clone()

Returns: Rectangle

clone()

public Object clone()

Returns: java.lang.Object

normalize()

public void normalize()

Normalizes the rectangle by making it’s width and height positive, left less than right and top less than bottom.