Rectangle

Inheritance: java.lang.Object

All Implemented Interfaces: java.lang.Comparable, java.lang.Cloneable

public final class Rectangle implements Comparable<Object>, Cloneable

Class represents rectangle.

Constructors

ConstructorDescription
Rectangle(double llx, double lly, double urx, double ury)Constructor of Rectangle.
Rectangle(double llx, double lly, double urx, double ury, boolean normalizeCoordinates)Constructor of Rectangle.

Methods

MethodDescription
getWidth()Gets width of rectangle.
getHeight()Get height of rectangle.
getLLX()Gets X-coordinate of lower - left corner.
setLLX(double value)Sets X-coordinate of lower - left corner.
getLLY()Gets Y - coordinate of lower-left corner.
setLLY(double value)Sets Y - coordinate of lower-left corner.
getURX()Gets X - coordinate of upper-right corner.
setURX(double value)Sets X - coordinate of upper-right corner.
getURY()Gets Y - coordinate of upper-right corner.
setURY(double value)Sets Y - coordinate of upper-right corner.
toRect()Converts rectangle to instance of System.Drawing.Rectangle.
fromRect(Rectangle src)Initializes new rectangle from given instance of System.Drawing.Rectangle.
fromRect(Rectangle2D.Float src)Initializes new rectangle from given instance of System.Drawing.Rectangle.
fromRectInternal(System.Drawing.RectangleF src)
toArray(ITrailerable trailerable)
toString()Gets rectangle string representation.
parse(String value)Try to parse string and extract from it rectangle components llx, lly, urx, ury.
getEmpty()Gets empty rectangle
getTrivial()Initializes trivial rectangle i.e.
isTrivial()Checks if rectangle is trivial i.e.
isEmpty()Checks if rectangle is empty.
isPoint()Checks if rectangle is point i.e.
equals(Object other)Check if rectangles are equal i.e.
nearEquals(Rectangle other, double delta)Check if rectangles are near equal i.e.
hashCode()Returns a hash code value for the object.
intersect(Rectangle otherRect)Intersects to rectangles.
join(Rectangle otherRect)Joins rectangles.
_Intersect(Rectangle otherRect)Intersects rectangles.
isIntersect(Rectangle otherRect)Determines whether this rectangle intersects with other rectangle.
contains(Point point)Determinces whether given point is inside of the rectangle.
center()Returncs coordinates of center of the rectangle.
isInclude(Rectangle otherRect, double rotationAngle)Checks that this rectangle includes whole another rectangle.
rotate(int angle)Rotate rectangle by the specified angle.
rotateAngle(int angle)Rotate rectangle by the specified angle.
compareTo(Object arg0)CompareTo
clone()Clones the Rectangle object.
deepClone()Clones the Rectangle object.
toPoints()Converts rectangle into array of points (“QuadPoints”).

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

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

Constructor of Rectangle.

Parameters:

ParameterTypeDescription
llxdoubleX of lower left corner.
llydoubleY of lower left corner.
urxdoubleX of upper right corner.
urydoubleY of upper right corner.

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

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

Constructor of Rectangle.

Parameters:

ParameterTypeDescription
llxdoubleX of lower left corner.
llydoubleY of lower left corner.
urxdoubleX of upper right corner.
urydoubleY of upper right corner.
normalizeCoordinatesbooleanNormalize coordinates of rectangle.

getWidth()

public double getWidth()

Gets width of rectangle.

Returns: double - double value

getHeight()

public double getHeight()

Get height of rectangle.

Returns: double - double value

getLLX()

public double getLLX()

Gets X-coordinate of lower - left corner.

Returns: double - double value

setLLX(double value)

public void setLLX(double value)

Sets X-coordinate of lower - left corner.

Parameters:

ParameterTypeDescription
valuedoubledouble value

getLLY()

public double getLLY()

Gets Y - coordinate of lower-left corner.

Returns: double - double value

setLLY(double value)

public void setLLY(double value)

Sets Y - coordinate of lower-left corner.

Parameters:

ParameterTypeDescription
valuedoubledouble value

getURX()

public double getURX()

Gets X - coordinate of upper-right corner.

Returns: double - double value

setURX(double value)

public void setURX(double value)

Sets X - coordinate of upper-right corner.

Parameters:

ParameterTypeDescription
valuedoubledouble value

getURY()

public double getURY()

Gets Y - coordinate of upper-right corner.

Returns: double - double value

setURY(double value)

public void setURY(double value)

Sets Y - coordinate of upper-right corner.

Parameters:

ParameterTypeDescription
valuedoubledouble value

toRect()

public Rectangle toRect()

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

Returns: Rectangle - Result of conversion.

fromRect(Rectangle src)

public static Rectangle fromRect(Rectangle src)

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

Parameters:

ParameterTypeDescription
srcjava.awt.RectangleSource rectangle which position and size will be set to new rectangle.

Returns: Rectangle - New rectangle.

fromRect(Rectangle2D.Float src)

public static Rectangle fromRect(Rectangle2D.Float src)

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

Parameters:

ParameterTypeDescription
srcjava.awt.geom.Rectangle2D.FloatSource rectangle which position and size will be set to new rectangle.

Returns: Rectangle - New rectangle.

fromRectInternal(System.Drawing.RectangleF src)

public static Rectangle fromRectInternal(System.Drawing.RectangleF src)

Parameters:

ParameterTypeDescription
srccom.aspose.ms.System.Drawing.RectangleF

Returns: Rectangle

toArray(ITrailerable trailerable)

public PdfArray toArray(ITrailerable trailerable)

Parameters:

ParameterTypeDescription
trailerableITrailerable

Returns: PdfArray

toString()

public String toString()

Gets rectangle string representation.

Returns: java.lang.String - String has format llx,lly,urx,ury.

parse(String value)

public static Rectangle parse(String value)

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

Parameters:

ParameterTypeDescription
valuejava.lang.StringString to parse.

Returns: Rectangle - Rectangle object.

getEmpty()

public static Rectangle getEmpty()

Gets empty rectangle

Returns: Rectangle - new Rectangle object

getTrivial()

public static Rectangle getTrivial()

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

Returns: Rectangle - new Rectangle object

isTrivial()

public boolean isTrivial()

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

Returns: boolean - boolean value

isEmpty()

public boolean isEmpty()

Checks if rectangle is empty.

Returns: boolean - boolean value

isPoint()

public boolean isPoint()

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

Returns: boolean - boolean value

equals(Object other)

public boolean equals(Object other)

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

Parameters:

ParameterTypeDescription
otherjava.lang.ObjectRectangle which will be compared.

Returns: boolean - True if rectangles are equals, false otherwise.

nearEquals(Rectangle other, double delta)

public boolean nearEquals(Rectangle other, double delta)

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

Parameters:

ParameterTypeDescription
otherRectangleRectangle which will be compared.
deltadoubleValue of comparation tollerance.

Returns: boolean - True if rectangles are equals, false otherwise.

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 java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in 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 equals(Object) method, then calling the 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 java.lang.Object#equals(java.lang.Object)#equals(java.lang.Object) method, then calling the 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 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: int - a hash code value for this object.

intersect(Rectangle otherRect)

public Rectangle intersect(Rectangle otherRect)

Intersects to rectangles.

Parameters:

ParameterTypeDescription
otherRectRectangleRectangle to which this recatangle be intersected.

Returns: Rectangle - Intersection of rectangles; null if rectangles are not intersected.

join(Rectangle otherRect)

public Rectangle join(Rectangle otherRect)

Joins rectangles.

Parameters:

ParameterTypeDescription
otherRectRectangleRectangle to which this rectangle be joined.

Returns: Rectangle - Described rectangle.

_Intersect(Rectangle otherRect)

public void _Intersect(Rectangle otherRect)

Intersects rectangles. Obsolete method. Please use Intersect instead.

Parameters:

ParameterTypeDescription
otherRectRectangleRectangle object

isIntersect(Rectangle otherRect)

public boolean isIntersect(Rectangle otherRect)

Determines whether this rectangle intersects with other rectangle.

Parameters:

ParameterTypeDescription
otherRectRectangleIntersection will be tested with specified rectangle.

Returns: boolean - True if this rectangle intersects with specified rectangle. Otherwise false.

contains(Point point)

public boolean contains(Point point)

Determinces whether given point is inside of the rectangle.

Parameters:

ParameterTypeDescription
pointPointPoint to check.

Returns: boolean - True if point is inside of the recatngle.

center()

public Point center()

Returncs coordinates of center of the rectangle.

Returns: Point - Point which is center of the rectangle.

isInclude(Rectangle otherRect, double rotationAngle)

public boolean isInclude(Rectangle otherRect, double rotationAngle)

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.

Parameters:

ParameterTypeDescription
otherRectRectangleRectangle for which including is checked.
rotationAngledoubleRotation angle of another rectangle in radians.

Returns: boolean - True if this rectangle includes whole specified rectangle. Otherwise false.

rotate(int angle)

public void rotate(int angle)

Rotate rectangle by the specified angle.

Parameters:

ParameterTypeDescription
angleintAngle of rotation. Member of Rotation enumeration.

rotateAngle(int angle)

public void rotateAngle(int angle)

Rotate rectangle by the specified angle.

Parameters:

ParameterTypeDescription
angleintAngle of rotation in degrees between 0 and 360.

compareTo(Object arg0)

public int compareTo(Object arg0)

CompareTo

Parameters:

ParameterTypeDescription
arg0java.lang.ObjectObject for compare

Returns: int - int value

clone()

public Object clone()

Clones the Rectangle object.

Returns: java.lang.Object - Clone object.

deepClone()

public Object deepClone()

Clones the Rectangle object.

Returns: java.lang.Object - Clone object.

toPoints()

public final Point[] toPoints()

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

Returns: com.aspose.pdf.Point[] - Array of points.