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
Constructor | Description |
---|---|
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
Method | Description |
---|---|
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. |
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. rectangle with zero position and size. |
isTrivial() | Checks if rectangle is trivial i.e. has zero size and position. |
isEmpty() | Checks if rectangle is empty. |
isPoint() | Checks if rectangle is point i.e. |
equals(Object other) | Check if rectangles are equal i.e. have same position and sizes. |
nearEquals(Rectangle other, double delta) | Check if rectangles are near equal i.e. have near same (up to delta) position and sizes. |
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:
Parameter | Type | Description |
---|---|---|
llx | double | X of lower left corner. |
lly | double | Y of lower left corner. |
urx | double | X of upper right corner. |
ury | double | Y 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:
Parameter | Type | Description |
---|---|---|
llx | double | X of lower left corner. |
lly | double | Y of lower left corner. |
urx | double | X of upper right corner. |
ury | double | Y of upper right corner. |
normalizeCoordinates | boolean | Normalize 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:
Parameter | Type | Description |
---|---|---|
value | double | double 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:
Parameter | Type | Description |
---|---|---|
value | double | double 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:
Parameter | Type | Description |
---|---|---|
value | double | double 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:
Parameter | Type | Description |
---|---|---|
value | double | double 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:
Parameter | Type | Description |
---|---|---|
src | java.awt.Rectangle | Source rectangle which position and size will be set to new rectangle. |
Returns: Rectangle - New rectangle.
toArray(ITrailerable trailerable)
public PdfArray toArray(ITrailerable trailerable)
Parameters:
Parameter | Type | Description |
---|---|---|
trailerable | ITrailerable |
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:
Parameter | Type | Description |
---|---|---|
value | java.lang.String | String 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:
Parameter | Type | Description |
---|---|---|
other | java.lang.Object | Rectangle 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:
Parameter | Type | Description |
---|---|---|
other | Rectangle | Rectangle which will be compared. |
delta | double | Value 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:
Parameter | Type | Description |
---|---|---|
otherRect | Rectangle | Rectangle 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:
Parameter | Type | Description |
---|---|---|
otherRect | Rectangle | Rectangle 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:
Parameter | Type | Description |
---|---|---|
otherRect | Rectangle | Rectangle object |
isIntersect(Rectangle otherRect)
public boolean isIntersect(Rectangle otherRect)
Determines whether this rectangle intersects with other rectangle.
Parameters:
Parameter | Type | Description |
---|---|---|
otherRect | Rectangle | Intersection 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:
Parameter | Type | Description |
---|---|---|
point | Point | Point 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:
Parameter | Type | Description |
---|---|---|
otherRect | Rectangle | Rectangle for which including is checked. |
rotationAngle | double | Rotation 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:
Parameter | Type | Description |
---|---|---|
angle | int | Angle of rotation. Member of Rotation enumeration. |
rotateAngle(int angle)
public void rotateAngle(int angle)
Rotate rectangle by the specified angle.
Parameters:
Parameter | Type | Description |
---|---|---|
angle | int | Angle of rotation in degrees between 0 and 360. |
compareTo(Object arg0)
public int compareTo(Object arg0)
CompareTo
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | java.lang.Object | Object 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.