public class Rectangle extends Object implements Cloneable, Serializable
Modifier and Type | Field and Description |
---|---|
protected float |
height |
protected float |
width |
protected float |
x |
protected float |
y |
Constructor and Description |
---|
Rectangle(float width, float height)
Creates new instance of rectangle with (0, 0) as the lower left point.
|
Rectangle(float x, float y, float width, float height)
Creates new instance.
|
Rectangle(Rectangle rect)
Creates the copy of given Rectangle
|
Modifier and Type | Method and Description |
---|---|
Rectangle |
applyMargins(float topIndent, float rightIndent, float bottomIndent, float leftIndent, boolean reverse)
Change the rectangle according the specified margins.
|
static Rectangle |
calculateBBox(List<Point> points)
Calculates the bounding box of passed points.
|
Rectangle |
clone()
Creates a "deep copy" of this rectangle, meaning the object returned by this method will be independent of the object being cloned.
|
boolean |
contains(Rectangle rect)
Check if this rectangle contains the passed rectangle.
|
static Rectangle |
createBoundingRectangleFromQuadPoint(PdfArray quadPoints)
Create the bounding rectangle for the given array of quadpoints.
|
static List<Rectangle> |
createBoundingRectanglesFromQuadPoint(PdfArray quadPoints)
Create a list of bounding rectangles from an 8 x n array of Quadpoints.
|
Rectangle |
decreaseHeight(float extra)
Decreases the height of rectangle by the given value.
|
boolean |
equalsWithEpsilon(Rectangle that)
Compares instance of this rectangle with given deviation equals to 0.0001
|
boolean |
equalsWithEpsilon(Rectangle that, float eps)
Compares instance of this rectangle with given deviation.
|
float |
getBottom()
Gets the Y coordinate of the lower edge of the rectangle.
|
static Rectangle |
getCommonRectangle(Rectangle... rectangles)
Calculates the common rectangle which includes all the input rectangles.
|
float |
getHeight()
Gets the height of rectangle.
|
Rectangle |
getIntersection(Rectangle rect)
Get the rectangle representation of the intersection between this rectangle and the passed rectangle
|
float |
getLeft()
Gets the X coordinate of the left edge of the rectangle.
|
static Rectangle |
getRectangleOnRotatedPage(Rectangle rect, PdfPage page)
Gets the rectangle as it looks on the rotated page and returns the rectangle in coordinates relevant to the true page origin.
|
float |
getRight()
Gets the X coordinate of the right edge of the rectangle.
|
float |
getTop()
Gets the Y coordinate of the upper edge of the rectangle.
|
float |
getWidth()
Gets the width of rectangle.
|
float |
getX()
Gets the X coordinate of lower left point.
|
float |
getY()
Gets the Y coordinate of lower left point.
|
Rectangle |
increaseHeight(float extra)
Increases the height of rectangle by the given value.
|
boolean |
intersectsLine(float x1, float y1, float x2, float y2)
Checks if rectangle have common points with line, specified by two points.
|
Rectangle |
moveDown(float move)
Decreases the y coordinate.
|
Rectangle |
moveLeft(float move)
Decreases the x coordinate.
|
Rectangle |
moveRight(float move)
Increases the x coordinate.
|
Rectangle |
moveUp(float move)
Increases the y coordinate.
|
boolean |
overlaps(Rectangle rect)
Check if this rectangle and the passed rectangle overlap
|
Rectangle |
setBbox(float llx, float lly, float urx, float ury)
Sets the rectangle by the coordinates, specifying its lower left and upper right points.
|
Rectangle |
setHeight(float height)
Sets the height of rectangle.
|
Rectangle |
setWidth(float width)
Sets the width of rectangle.
|
Rectangle |
setX(float x)
Sets the X coordinate of lower left point.
|
Rectangle |
setY(float y)
Sets the Y coordinate of lower left point.
|
Point[] |
toPointsArray()
Convert rectangle to an array of points
|
String |
toString()
Gets the string representation of rectangle.
|
protected float x
protected float y
protected float width
protected float height
public Rectangle(float x, float y, float width, float height)
x
- the x coordinate of lower left point
y
- the y coordinate of lower left point
width
- the width value
height
- the height value
public Rectangle(float width, float height)
width
- the width value
height
- the height value
public static Rectangle getCommonRectangle(Rectangle... rectangles)
rectangles
- list of input rectangles.
public static Rectangle getRectangleOnRotatedPage(Rectangle rect, PdfPage page)
rect
- the rectangle as it looks on the rotated page.
page
- the page on which one want to process the rectangle.
public static Rectangle calculateBBox(List<Point> points)
points
- the points which appear inside the area
public Point[] toPointsArray()
public Rectangle getIntersection(Rectangle rect)
rect
- the rectangle to find the intersection with
public boolean contains(Rectangle rect)
rect
the expression rect.contains(rect)
always returns true.
rect
- a rectangle which is to be checked if it is fully contained inside this rectangle.
public boolean overlaps(Rectangle rect)
rect
-
public Rectangle setBbox(float llx, float lly, float urx, float ury)
llx
- the X coordinate of lower left point
lly
- the Y coordinate of lower left point
urx
- the X coordinate of upper right point
ury
- the Y coordinate of upper right point
Rectangle
instance.
public float getX()
public Rectangle setX(float x)
x
- the X coordinate of lower left point to be set.
Rectangle
instance.
public float getY()
public Rectangle setY(float y)
y
- the Y coordinate of lower left point to be set.
Rectangle
instance.
public float getWidth()
public Rectangle setWidth(float width)
width
- the the width of rectangle to be set.
Rectangle
instance.
public float getHeight()
public Rectangle setHeight(float height)
height
- the the width of rectangle to be set.
Rectangle
instance.
public Rectangle increaseHeight(float extra)
extra
- the value of the extra height to be added.
Rectangle
instance.
public Rectangle decreaseHeight(float extra)
extra
- the value of the extra height to be subtracted.
Rectangle
instance.
public float getLeft()
getX()
.
public float getRight()
getX() + getWidth()
.
public float getTop()
getY() + getHeight()
.
public float getBottom()
getY()
.
public Rectangle moveDown(float move)
move
- the value on which the position will be changed.
Rectangle
instance.
public Rectangle moveUp(float move)
move
- the value on which the position will be changed.
Rectangle
instance.
public Rectangle moveRight(float move)
move
- the value on which the position will be changed.
Rectangle
instance.
public Rectangle moveLeft(float move)
move
- the value on which the position will be changed.
Rectangle
instance.
public Rectangle applyMargins(float topIndent, float rightIndent, float bottomIndent, float leftIndent, boolean reverse)
topIndent
- the value on which the top y coordinate will change.
rightIndent
- the value on which the right x coordinate will change.
bottomIndent
- the value on which the bottom y coordinate will change.
leftIndent
- the value on which the left x coordinate will change.
reverse
- if true
the rectangle will expand, otherwise it will shrink
public boolean intersectsLine(float x1, float y1, float x2, float y2)
x1
- the x coordinate of first line's point.
y1
- the y coordinate of first line's point.
x2
- the x coordinate of second line's point.
y2
- the y coordinate of second line's point.
true
if rectangle have common points with line and false
otherwise.
public String toString()
public Rectangle clone()
public boolean equalsWithEpsilon(Rectangle that)
that
- the Rectangle
to compare with.
true
if the difference between corresponding rectangle values is less than deviation and false
otherwise.
public boolean equalsWithEpsilon(Rectangle that, float eps)
that
- the Rectangle
to compare with.
eps
- the deviation value.
true
if the difference between corresponding rectangle values is less than deviation and false
otherwise.
public static List<Rectangle> createBoundingRectanglesFromQuadPoint(PdfArray quadPoints) throws PdfException
quadPoints
- 8xn array of numbers representing 4 points
PdfException
- if the passed array's size is not a multiple of 8.
public static Rectangle createBoundingRectangleFromQuadPoint(PdfArray quadPoints) throws PdfException
quadPoints
- an array containing 8 numbers that correspond to 4 points.
PdfException
- if the passed array's size is not a multiple of 8.
Copyright © 1998–2020 iText Group NV. All rights reserved.