public class PdfRect extends Object implements Cloneable
PdfRect
object is specified by x-y coordinates of
its top-left corner, its width, and its height. These
specifications of a rectangle are applied in a literal sense. As a
result, the actual position and size of a rectangle object on a
page is wholly dependent on whatever measurement unit that is
currently applicable.
For example, on a page where the measurement unit is inch, the height and width of a rectangle will be applied in inches, literally. On a page with pixel as the measurement unit, the rectangle's position and size will be applied in pixels, literally. As this can cause serious shifts in position, care has to be taken when reusing a rectangle in different places or in different situations.
Some classes may have methods that specify a PdfRect
object and a particular measurement unit as arguments. In these
cases, the position and size of the rectangle are applied in the
specified measurement unit. When no measurement unit is specified
or cannot be determined, the height, width, and x-y coordinates
of its top-left corner will be applied in points, or or points as
in "one inch equals 72 points equals 96 pixels."
Constructor and Description |
---|
PdfRect(double x,
double y,
double width,
double height)
Constructs a
PdfRect object at position
(x , y ) with specified width and
height. |
PdfRect(PdfArray array,
double pageHeight) |
PdfRect(Rectangle rect)
Constructs a
PdfRect object with specified
Rectangle object. |
PdfRect(Rectangle2D rect)
Constructs a
PdfRect object with specified
Rectangle2D object. |
Modifier and Type | Method and Description |
---|---|
double |
bottom()
Returns distance from top of page to bottom of this rectangle.
|
Object |
clone() |
double |
getX()
Returns x-coordinate of top-left corner of this rectangle.
|
double |
getY()
Returns y-coordinate of top-left corner of this rectangle.
|
double |
height()
Returns height of this rectangle.
|
double |
left()
Returns distance from left side of page to left side of this
rectangle.
|
double |
right()
Returns distance from left side of page to right side of this
rectangle.
|
double |
top()
Returns distance from top side of page to top side of this
rectangle.
|
String |
toString()
Returns a string representation of the rectangle.
|
double |
width()
Returns width of this rectangle.
|
public PdfRect(double x, double y, double width, double height)
PdfRect
object at position
(x
, y
) with specified width and
height.x
- x-coordinate of the top-left corner of the
rectangley
- y-coordinate of the top-left corner of the
rectanglewidth
- width of the rectangleheight
- height of the rectanglepublic PdfRect(Rectangle rect)
PdfRect
object with specified
Rectangle
object.rect
- a rectanglepublic PdfRect(Rectangle2D rect)
PdfRect
object with specified
Rectangle2D
object.rect
- a rectanglepublic PdfRect(PdfArray array, double pageHeight)
public double height()
public double width()
public double getX()
public double getY()
public double bottom()
public double left()
public double right()
public double top()
public String toString()
[x = 200.0 y = 100.0 w = 250.0 h = 100.0]
.