RectangleF

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 RectangleF extends Struct<RectangleF> implements System.IEquatable<RectangleF>, Cloneable

Stores a set of four floating-point numbers that represent the location and size of a rectangle. For more advanced region functions, use a Region object.

Constructors

ConstructorDescription
RectangleF()
RectangleF(PointF location, SizeF size)Initializes a new instance of the RectangleF structure with the specified location and size.
RectangleF(float x, float y, float width, float height)Initializes a new instance of the RectangleF structure with the specified location and size.

Methods

MethodDescription
fromPoints(PointF point1, PointF point2)Creates a new rectangle from two points.
to_RectangleF(Rectangle r)Converts the specified Rectangle structure to a RectangleF structure.
op_Equality(RectangleF left, RectangleF right)Tests whether two RectangleF structures have equal location and size.
op_Inequality(RectangleF left, RectangleF right)Tests whether two RectangleF structures differ in location or size.
fromLTRB(float left, float top, float right, float bottom)Creates a RectangleF structure with upper-left corner and lower-right corner at the specified locations.
inflate(RectangleF rect, float x, float y)Creates and returns an inflated copy of the specified RectangleF structure.
intersect(RectangleF a, RectangleF b)Returns a RectangleF structure that represents the intersection of two rectangles.
union(RectangleF a, RectangleF b)Creates the smallest possible third rectangle that can contain both of two rectangles that form a union.
isEquals(RectangleF obj1, RectangleF obj2)
getEmpty()
isEmpty()Gets a value indicating whether the RectangleF.Width or RectangleF.Height property of this RectangleF has a value of zero.
getX()Gets the x-coordinate of the upper-left corner of this RectangleF structure.
setX(float value)Sets the x-coordinate of the upper-left corner of this RectangleF structure.
getY()Gets the x-coordinate of the upper-left corner of this RectangleF structure.
setY(float value)Sets the x-coordinate of the upper-left corner of this RectangleF structure.
getLocation()Gets the coordinates of the upper-left corner of this RectangleF structure.
setLocation(PointF value)Sets the coordinates of the upper-left corner of this RectangleF structure.
getWidth()Gets the width of this RectangleF structure.
setWidth(float value)Sets the width of this RectangleF structure.
getHeight()Gets the height of this RectangleF structure.
setHeight(float value)Sets the height of this RectangleF structure.
getSize()Gets the size of this RectangleF.
setSize(SizeF value)Sets the size of this RectangleF.
getLeft()Gets the x-coordinate of the left edge of this RectangleF structure.
getTop()Gets the y-coordinate of the top edge of this RectangleF structure.
getRight()Gets the x-coordinate that is the sum of X and Width of this RectangleF structure.
getBottom()Gets the y-coordinate that is the sum of Y and Height of this RectangleF structure.
toString()
inflate(float x, float y)Inflates this RectangleF structure by the specified amount.
inflate(SizeF size)Inflates this RectangleF by the specified amount.
intersect(RectangleF rect)Replaces this RectangleF structure with the intersection of itself and the specified RectangleF structure.
intersectsWith(RectangleF rect)Determines if this rectangle intersects with rect.
offset(PointF pos)Adjusts the location of this rectangle by the specified amount.
offset(float x, float y)Adjusts the location of this rectangle by the specified amount.
contains(float x, float y)Determines if the specified point is contained within this RectangleF structure.
contains(PointF pt)Determines if the specified point is contained within this RectangleF structure.
contains(RectangleF rect)Determines if the rectangular region represented by rect is entirely contained within this RectangleF structure.
equals(Object obj)Determines whether the specified Object, is equal to this instance.
hashCode()Returns a hash code for this instance.
equals(RectangleF other)Tests whether other RectangleF structure has the same location and size of this RectangleF structure.
CloneTo(RectangleF that)
Clone()
clone()

RectangleF()

public RectangleF()

RectangleF(PointF location, SizeF size)

public RectangleF(PointF location, SizeF size)

Initializes a new instance of the RectangleF structure with the specified location and size.

Parameters:

ParameterTypeDescription
locationPointFA PointF that represents the upper-left corner of the rectangular region.
sizeSizeFA SizeF that represents the width and height of the rectangular region.

RectangleF(float x, float y, float width, float height)

public RectangleF(float x, float y, float width, float height)

Initializes a new instance of the RectangleF structure with the specified location and size.

Parameters:

ParameterTypeDescription
xfloatThe x-coordinate of the upper-left corner of the rectangle.
yfloatThe y-coordinate of the upper-left corner of the rectangle.
widthfloatThe width of the rectangle.
heightfloatThe height of the rectangle.

fromPoints(PointF point1, PointF point2)

public static RectangleF fromPoints(PointF point1, PointF point2)

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

Parameters:

ParameterTypeDescription
point1PointFThe first point.
point2PointFThe second point.

Returns: RectangleF - A newly created rectangle.

to_RectangleF(Rectangle r)

public static RectangleF to_RectangleF(Rectangle r)

Converts the specified Rectangle structure to a RectangleF structure.

Parameters:

ParameterTypeDescription
rRectangleThe Rectangle structure to convert.

Returns: RectangleF - The RectangleF structure that is converted from the specified Rectangle structure.

op_Equality(RectangleF left, RectangleF right)

public static boolean op_Equality(RectangleF left, RectangleF right)

Tests whether two RectangleF structures have equal location and size.

Parameters:

ParameterTypeDescription
leftRectangleFThe RectangleF structure that is to the left of the equality operator.
rightRectangleFThe RectangleF structure that is to the right of the equality operator.

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

op_Inequality(RectangleF left, RectangleF right)

public static boolean op_Inequality(RectangleF left, RectangleF right)

Tests whether two RectangleF structures differ in location or size.

Parameters:

ParameterTypeDescription
leftRectangleFThe RectangleF structure that is to the left of the inequality operator.
rightRectangleFThe RectangleF structure that is to the right of the inequality operator.

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

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

public static RectangleF fromLTRB(float left, float top, float right, float bottom)

Creates a RectangleF structure with upper-left corner and lower-right corner at the specified locations.

Parameters:

ParameterTypeDescription
leftfloatThe x-coordinate of the upper-left corner of the rectangular region.
topfloatThe y-coordinate of the upper-left corner of the rectangular region.
rightfloatThe x-coordinate of the lower-right corner of the rectangular region.
bottomfloatThe y-coordinate of the lower-right corner of the rectangular region.

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

inflate(RectangleF rect, float x, float y)

public static RectangleF inflate(RectangleF rect, float x, float y)

Creates and returns an inflated copy of the specified RectangleF structure. The copy is inflated by the specified amount. The original rectangle remains unmodified.

Parameters:

ParameterTypeDescription
rectRectangleFThe RectangleF to be copied. This rectangle is not modified.
xfloatThe amount to inflate the copy of the rectangle horizontally.
yfloatThe amount to inflate the copy of the rectangle vertically.

Returns: RectangleF - The inflated RectangleF.

intersect(RectangleF a, RectangleF b)

public static RectangleF intersect(RectangleF a, RectangleF b)

Returns a RectangleF structure that represents the intersection of two rectangles. If there is no intersection, and empty RectangleF is returned.

Parameters:

ParameterTypeDescription
aRectangleFFirst rectangle to intersect.
bRectangleFSecond rectangle to intersect.

Returns: RectangleF - A third RectangleF structure the size of which represents the overlapped area of the two specified rectangles.

union(RectangleF a, RectangleF b)

public static RectangleF union(RectangleF a, RectangleF b)

Creates the smallest possible third rectangle that can contain both of two rectangles that form a union.

Parameters:

ParameterTypeDescription
aRectangleFFirst rectangle to union.
bRectangleFSecond rectangle to union.

Returns: RectangleF - A third RectangleF structure that contains both of the two rectangles that form the union.

isEquals(RectangleF obj1, RectangleF obj2)

public static boolean isEquals(RectangleF obj1, RectangleF obj2)

Parameters:

ParameterTypeDescription
obj1RectangleF
obj2RectangleF

Returns: boolean

getEmpty()

public static RectangleF getEmpty()

Returns: RectangleF

isEmpty()

public final boolean isEmpty()

Gets a value indicating whether the RectangleF.Width or RectangleF.Height property of this RectangleF has a value of zero.

Returns: boolean - This property returns true if the RectangleF.Width or P:RectangleF.Height property of this RectangleF has a value of zero; otherwise, false.

getX()

public final float getX()

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

Returns: float - the x-coordinate of the upper-left corner of this RectangleF structure.

setX(float value)

public final void setX(float value)

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

Parameters:

ParameterTypeDescription
valuefloatthe x-coordinate of the upper-left corner of this RectangleF structure.

getY()

public final float getY()

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

Returns: float - the x-coordinate of the upper-left corner of this RectangleF structure.

setY(float value)

public final void setY(float value)

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

Parameters:

ParameterTypeDescription
valuefloatthe x-coordinate of the upper-left corner of this RectangleF structure.

getLocation()

public final PointF getLocation()

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

Returns: PointF - A PointF that represents the upper-left corner of this RectangleF structure.

setLocation(PointF value)

public final void setLocation(PointF value)

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

Parameters:

ParameterTypeDescription
valuePointFthe coordinates of the upper-left corner of this RectangleF structure.

getWidth()

public final float getWidth()

Gets the width of this RectangleF structure.

Returns: float - the width of this RectangleF structure.

setWidth(float value)

public final void setWidth(float value)

Sets the width of this RectangleF structure.

Parameters:

ParameterTypeDescription
valuefloatthe width of this RectangleF structure.

getHeight()

public final float getHeight()

Gets the height of this RectangleF structure.

Returns: float - the height of this RectangleF structure.

setHeight(float value)

public final void setHeight(float value)

Sets the height of this RectangleF structure.

Parameters:

ParameterTypeDescription
valuefloatthe height of this RectangleF structure.

getSize()

public final SizeF getSize()

Gets the size of this RectangleF.

Returns: SizeF - A SizeF that represents the width and height of this RectangleF structure.

setSize(SizeF value)

public final void setSize(SizeF value)

Sets the size of this RectangleF.

Parameters:

ParameterTypeDescription
valueSizeFthe size of this RectangleF.

getLeft()

public final float getLeft()

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

Returns: float - the x-coordinate of the left edge of this RectangleF structure.

getTop()

public final float getTop()

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

Returns: float - the y-coordinate of the top edge of this RectangleF structure.

getRight()

public final float getRight()

Gets the x-coordinate that is the sum of X and Width of this RectangleF structure.

Returns: float - the x-coordinate that is the sum of X and Width of this RectangleF structure.

getBottom()

public final float getBottom()

Gets the y-coordinate that is the sum of Y and Height of this RectangleF structure.

Returns: float - the y-coordinate that is the sum of Y and Height of this RectangleF structure.

toString()

public String toString()

Returns: java.lang.String

inflate(float x, float y)

public final void inflate(float x, float y)

Inflates this RectangleF structure by the specified amount.

Parameters:

ParameterTypeDescription
xfloatThe amount to inflate this RectangleF structure horizontally.
yfloatThe amount to inflate this RectangleF structure vertically.

inflate(SizeF size)

public final void inflate(SizeF size)

Inflates this RectangleF by the specified amount.

Parameters:

ParameterTypeDescription
sizeSizeFThe amount to inflate this rectangle.

intersect(RectangleF rect)

public final void intersect(RectangleF rect)

Replaces this RectangleF structure with the intersection of itself and the specified RectangleF structure.

Parameters:

ParameterTypeDescription
rectRectangleFThe rectangle to intersect.

intersectsWith(RectangleF rect)

public final boolean intersectsWith(RectangleF rect)

Determines if this rectangle intersects with rect.

Parameters:

ParameterTypeDescription
rectRectangleFThe rectangle to test.

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

offset(PointF pos)

public final void offset(PointF pos)

Adjusts the location of this rectangle by the specified amount.

Parameters:

ParameterTypeDescription
posPointFThe amount to offset the location.

offset(float x, float y)

public final void offset(float x, float y)

Adjusts the location of this rectangle by the specified amount.

Parameters:

ParameterTypeDescription
xfloatThe amount to offset the location horizontally.
yfloatThe amount to offset the location vertically.

contains(float x, float y)

public final boolean contains(float x, float y)

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

Parameters:

ParameterTypeDescription
xfloathe x-coordinate of the point to test.
yfloatThe 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 RectangleF structure; otherwise false.

contains(PointF pt)

public final boolean contains(PointF pt)

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

Parameters:

ParameterTypeDescription
ptPointFThe PointF to test.

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

contains(RectangleF rect)

public final boolean contains(RectangleF rect)

Determines if the rectangular region represented by rect is entirely contained within this RectangleF structure.

Parameters:

ParameterTypeDescription
rectRectangleFThe RectangleF to test.

Returns: boolean - This method returns true if the rectangular region represented by rect is entirely contained within the rectangular region represented by this RectangleF; otherwise false.

equals(Object obj)

public boolean equals(Object obj)

Determines whether the specified Object, is equal to this instance.

Parameters:

ParameterTypeDescription
objjava.lang.ObjectThe Object to compare with this instance.

Returns: boolean - true if the specified Object is equal to this instance; otherwise, false.

hashCode()

public int hashCode()

Returns a hash code for this instance.

Returns: int - A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.

equals(RectangleF other)

public final boolean equals(RectangleF other)

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

Parameters:

ParameterTypeDescription
otherRectangleFOther rectangle to test

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

CloneTo(RectangleF that)

public void CloneTo(RectangleF that)

Parameters:

ParameterTypeDescription
thatRectangleF

Clone()

public RectangleF Clone()

Returns: RectangleF

clone()

public Object clone()

Returns: java.lang.Object