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
| Constructor | Description |
|---|---|
| Rectangle | Constructor of Rectangle. |
| Rectangle | Constructor of Rectangle. |
Methods
| Method | Description |
|---|---|
| _Intersect | Intersects rectangles. Obsolete method. Please use Intersect instead. |
| center | Returncs coordinates of center of the rectangle. |
| clone | Clones the Rectangle object. |
| compareTo | CompareTo |
| contains | Determinces whether given point is inside of the rectangle. |
| contains | Determinces whether given point is inside of the rectangle. |
| containsLine | Determines whether the rectangle contains a line represented by two points. |
| containsPoint | Determines whether the given point is contained within the rectangle. |
| deepClone | Clones the Rectangle 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 | Calculates the area of the rectangle. |
| getEmpty | Gets empty rectangle |
| getHeight | Get height of rectangle. |
| getLLX | Gets X-coordinate of lower - left corner. |
| getLLY | Gets Y - coordinate of lower-left corner. |
| getTrivial | Initializes trivial rectangle i.e. rectangle with zero position and size. |
| getURX | Gets X - coordinate of upper-right corner. |
| getURY | Gets Y - coordinate of upper-right corner. |
| getWidth | Gets width of rectangle. |
| 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:
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.) |
| intersect | Intersects to rectangles. |
| isEmpty | Checks if rectangle is empty. |
| 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 | Checks if rectangle is point i.e. LLX is equal URX and LLY is equal URY. |
| isTrivial | Checks if rectangle is trivial i.e. has zero size and position. |
| join | Joins rectangles. |
| moveBy | Shift rectangle by the specified deltas. |
| 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 | Rotate rectangle by the specified angle. |
| setLLX | Sets X-coordinate of lower - left corner. |
| setLLY | Sets Y - coordinate of lower-left corner. |
| setURX | Sets X - coordinate of upper-right corner. |
| setURY | Sets Y - coordinate of upper-right corner. |
| toArray | |
| toPoints | Converts rectangle into array of points (“QuadPoints”). |
| toRect | Converts rectangle to instance of System.Drawing.Rectangle. Floating-point positions and size are truncated. |
| toString | Gets rectangle string representation. |
Rectangle
public Rectangle(double llx, double lly, double urx, double ury)
Constructor of Rectangle.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| llx | X of lower left corner. | |
| lly | Y of lower left corner. | |
| urx | X of upper right corner. | |
| ury | Y of upper right corner. |
Rectangle
public Rectangle(double llx, double lly, double urx, double ury, boolean normalizeCoordinates)
Constructor of Rectangle.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| llx | X of lower left corner. | |
| lly | Y of lower left corner. | |
| urx | X of upper right corner. | |
| ury | Y of upper right corner. | |
| normalizeCoordinates | Normalize 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:
| Parameter | Type | Description |
|---|---|---|
| x1 | The X coordinate of the start point of the line. | |
| y1 | The Y coordinate of the start point of the line. | |
| x2 | The X coordinate of the end point of the line. | |
| y2 | The 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:
| Parameter | Type | Description |
|---|---|---|
| x | X-coordinate of the point. | |
| y | Y-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:
| Parameter | Type | Description |
|---|---|---|
| dx | Value of shift by X axis. | |
| dy | Value 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:
| Parameter | Type | Description |
|---|---|---|
| angle | Angle of rotation in degrees between 0 and 360. |
setLLX
public void setLLX(double value)
Sets X-coordinate of lower - left corner.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| value | double value |
setLLY
public void setLLY(double value)
Sets Y - coordinate of lower-left corner.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| value | double value |
setURX
public void setURX(double value)
Sets X - coordinate of upper-right corner.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| value | double value |
setURY
public void setURY(double value)
Sets Y - coordinate of upper-right corner.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| value | double 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.