Rectangle

Inheritance: java.lang.Object, com.aspose.pdf.Rectangle

All Implemented Interfaces: Cloneable, Comparable < Object >

public final class Rectangle extends Object implements Comparable < Object >, Cloneable

Class represents rectangle.

Constructors

ConstructorDescription
RectangleConstructor of Rectangle.
RectangleConstructor of Rectangle.

Methods

MethodDescription
_IntersectIntersects rectangles. Obsolete method. Please use Intersect instead.
centerReturncs coordinates of center of the rectangle.
cloneClones the Rectangle object.
compareToCompareTo
containsDeterminces whether given point is inside of the rectangle.
containsDeterminces whether given point is inside of the rectangle.
containsLineDetermines whether the rectangle contains a line represented by two points.
containsPointDetermines whether the given point is contained within the rectangle.
deepCloneClones the Rectangle object.
equalsCheck if rectangles are equal i.e. have same position and sizes.
fromRectInitializes new rectangle from given instance of System.Drawing.Rectangle.
fromRectInitializes new rectangle from given instance of System.Drawing.Rectangle.
fromRectInternal
getAreaCalculates the area of the rectangle.
getEmptyGets empty rectangle
getHeightGet height of rectangle.
getLLXGets X-coordinate of lower - left corner.
getLLYGets Y - coordinate of lower-left corner.
getTrivialInitializes trivial rectangle i.e. rectangle with zero position and size.
getURXGets X - coordinate of upper-right corner.
getURYGets Y - coordinate of upper-right corner.
getWidthGets width of rectangle.
hashCodeReturns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by {@link java.util.HashMap}.

The general contract of {@code hashCode} is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the {@code hashCode} method must consistently return the same integer, provided no information used in {@code equals} comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the {@code equals(Object)} method, then calling the {@code hashCode} method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the {@link java.lang.Object#equals(java.lang.Object)} method, then calling the {@code hashCode} method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

As much as is reasonably practical, the hashCode method defined by class {@code Object} does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)

intersectIntersects to rectangles.
isEmptyChecks if rectangle is empty.
isIncludeChecks that this rectangle includes whole another rectangle. I.e. whole another rectangle is inside this rectangle. Difference with IsIntersect method is that IsIntersect will true for partly intersected rectangles but IsInclude will false.
isIntersectDetermines whether this rectangle intersects with other rectangle.
isPointChecks if rectangle is point i.e. LLX is equal URX and LLY is equal URY.
isTrivialChecks if rectangle is trivial i.e. has zero size and position.
joinJoins rectangles.
moveByShift rectangle by the specified deltas.
nearEqualsCheck if rectangles are near equal i.e. have near same (up to delta) position and sizes.
parseTry to parse string and extract from it rectangle components llx, lly, urx, ury.
rotateRotate rectangle by the specified angle.
rotateAngleRotate rectangle by the specified angle.
setLLXSets X-coordinate of lower - left corner.
setLLYSets Y - coordinate of lower-left corner.
setURXSets X - coordinate of upper-right corner.
setURYSets Y - coordinate of upper-right corner.
toArray
toPointsConverts rectangle into array of points (“QuadPoints”).
toRectConverts rectangle to instance of System.Drawing.Rectangle. Floating-point positions and size are truncated.
toStringGets rectangle string representation.

Rectangle

public Rectangle(double llx, double lly, double urx, double ury)

Constructor of Rectangle.

Parameters:

ParameterTypeDescription
llxX of lower left corner.
llyY of lower left corner.
urxX of upper right corner.
uryY of upper right corner.

Rectangle

public Rectangle(double llx, double lly, double urx, double ury, boolean normalizeCoordinates)

Constructor of Rectangle.

Parameters:

ParameterTypeDescription
llxX of lower left corner.
llyY of lower left corner.
urxX of upper right corner.
uryY of upper right corner.
normalizeCoordinatesNormalize coordinates of rectangle.

_Intersect

Intersects rectangles. Obsolete method. Please use Intersect instead.

center

public Point center()

Returncs coordinates of center of the rectangle.

Returns: Point which is center of the rectangle.

clone

public Rectangle clone()

Clones the Rectangle object.

Returns: Clone object.

compareTo

CompareTo

contains

Determinces whether given point is inside of the rectangle.

contains

Determinces whether given point is inside of the rectangle.

containsLine

public final boolean containsLine(double x1, double y1, double x2, double y2)

Determines whether the rectangle contains a line represented by two points.

Parameters:

ParameterTypeDescription
x1The X coordinate of the start point of the line.
y1The Y coordinate of the start point of the line.
x2The X coordinate of the end point of the line.
y2The Y coordinate of the end point of the line.

Returns: {@code true} if the rectangle contains the line; otherwise, {@code false}.

containsPoint

public final boolean containsPoint(double x, double y)

Determines whether the given point is contained within the rectangle.

Parameters:

ParameterTypeDescription
xX-coordinate of the point.
yY-coordinate of the point.

Returns: {@code true} if the point is contained within the rectangle; otherwise, {@code false}.

deepClone

public Rectangle deepClone()

Clones the Rectangle object.

Returns: Clone object.

equals

Check if rectangles are equal i.e. have same position and sizes.

fromRect

Initializes new rectangle from given instance of System.Drawing.Rectangle.

fromRect

Initializes new rectangle from given instance of System.Drawing.Rectangle.

fromRectInternal

getArea

public final double getArea()

Calculates the area of the rectangle.

Returns: The area of the rectangle as a double, calculated by multiplying the width and height.

getEmpty

public static Rectangle getEmpty()

Gets empty rectangle

Returns: new Rectangle object

getHeight

public double getHeight()

Get height of rectangle.

Returns: double value

getLLX

public double getLLX()

Gets X-coordinate of lower - left corner.

Returns: double value

getLLY

public double getLLY()

Gets Y - coordinate of lower-left corner.

Returns: double value

getTrivial

public static Rectangle getTrivial()

Initializes trivial rectangle i.e. rectangle with zero position and size.

Returns: new Rectangle object

getURX

public double getURX()

Gets X - coordinate of upper-right corner.

Returns: double value

getURY

public double getURY()

Gets Y - coordinate of upper-right corner.

Returns: double value

getWidth

public double getWidth()

Gets width of rectangle.

Returns: double value

hashCode

public int hashCode()

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by {@link java.util.HashMap}.

The general contract of {@code hashCode} is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the {@code hashCode} method must consistently return the same integer, provided no information used in {@code equals} comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the {@code equals(Object)} method, then calling the {@code hashCode} method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the {@link java.lang.Object#equals(java.lang.Object)} method, then calling the {@code hashCode} method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

As much as is reasonably practical, the hashCode method defined by class {@code Object} does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)

Returns: a hash code value for this object. @see java.lang.Object#equals(java.lang.Object) @see java.lang.System#identityHashCode

intersect

Intersects to rectangles.

isEmpty

public boolean isEmpty()

Checks if rectangle is empty.

Returns: boolean value

isInclude

Checks that this rectangle includes whole another rectangle. I.e. whole another rectangle is inside this rectangle. Difference with IsIntersect method is that IsIntersect will true for partly intersected rectangles but IsInclude will false.

isIntersect

Determines whether this rectangle intersects with other rectangle.

isPoint

public boolean isPoint()

Checks if rectangle is point i.e. LLX is equal URX and LLY is equal URY.

Returns: boolean value

isTrivial

public boolean isTrivial()

Checks if rectangle is trivial i.e. has zero size and position.

Returns: boolean value

join

Joins rectangles.

moveBy

public final void moveBy(double dx, double dy)

Shift rectangle by the specified deltas.

Parameters:

ParameterTypeDescription
dxValue of shift by X axis.
dyValue of shift by Y axis.

nearEquals

Check if rectangles are near equal i.e. have near same (up to delta) position and sizes.

parse

Try to parse string and extract from it rectangle components llx, lly, urx, ury.

rotate

Rotate rectangle by the specified angle.

rotateAngle

public void rotateAngle(int angle)

Rotate rectangle by the specified angle.

Parameters:

ParameterTypeDescription
angleAngle of rotation in degrees between 0 and 360.

setLLX

public void setLLX(double value)

Sets X-coordinate of lower - left corner.

Parameters:

ParameterTypeDescription
valuedouble value

setLLY

public void setLLY(double value)

Sets Y - coordinate of lower-left corner.

Parameters:

ParameterTypeDescription
valuedouble value

setURX

public void setURX(double value)

Sets X - coordinate of upper-right corner.

Parameters:

ParameterTypeDescription
valuedouble value

setURY

public void setURY(double value)

Sets Y - coordinate of upper-right corner.

Parameters:

ParameterTypeDescription
valuedouble value

toArray

toPoints

public final Point [] toPoints()

Converts rectangle into array of points (“QuadPoints”).

Returns: Array of points.

toRect

public Rectangle toRect()

Converts rectangle to instance of System.Drawing.Rectangle. Floating-point positions and size are truncated.

Returns: Result of conversion.

toString

public String toString()

Gets rectangle string representation.

Returns: String has format llx,lly,urx,ury.