public class PRectangle
extends java.awt.geom.Rectangle2D.Float
A rectangle in a PDF document is slightly different than the Rectangle class
in Java. A PDF rectangle is written as an array of four numbers giving the
coordinates of a pair of diagonally opposite corners. Typically, the
array takes the form:
This specifies the lower-left x, lower-left y, upper-right x, and upper-right y coordinates of the rectangle, in that order. However, this format is not guaranteed and this class normalizes such rectangles.
Another very important difference between PRectangles Rectangles is that PRectangles use the Cartesian Coordinate system, where Rectangles use the Java2D coordinates system. As a result, the user of this class must know the context in which the PRectangle is being used. For example there is a significant difference between the inherited method createIntersection and PRectangles createCartesianIntersection.
| Constructor and Description |
|---|
PRectangle(java.util.List coordinates)
Creates a new PRectangle object.
|
PRectangle(java.awt.geom.Point2D.Float p1,
java.awt.geom.Point2D.Float p2)
Creates a new PRectangle object.
|
| Modifier and Type | Method and Description |
|---|---|
PRectangle |
createCartesianIntersection(PRectangle src2)
Returns a new PRectangle object representing the intersection of this
PRectangle with the specified PRectangle using the Cartesian coordinate
system.
|
java.awt.geom.Rectangle2D.Float |
getOriginalPoints()
Gets the orgional two points that created the PRectangle object.
|
static java.util.List |
getPRectangleVector(java.awt.geom.Rectangle2D rect)
Converts a rectangle defined in user page in Java2D coordinates back
to PDF space and in the vector for of the rectangle.
|
java.awt.geom.Rectangle2D.Float |
toJava2dCoordinates()
Converts the Cartesian representation of the Rectangle into Rectangle in
the Java2D coordinate space.
|
createIntersection, createUnion, getBounds2D, getHeight, getWidth, getX, getY, isEmpty, outcode, setRect, setRect, setRect, toStringadd, add, add, contains, contains, equals, getPathIterator, getPathIterator, hashCode, intersect, intersects, intersectsLine, intersectsLine, outcode, setFrame, unionpublic PRectangle(java.awt.geom.Point2D.Float p1,
java.awt.geom.Point2D.Float p2)
Creates a new PRectangle object. The points are automatically normalized by the constructor. These two coordinates represent the diagonal corners of the rectangle.
p1 - first point of diagonal, in the Cartesian coordinate spacep2 - second point of diagonal, in the Cartesian coordinate spacepublic PRectangle(java.util.List coordinates)
throws java.lang.IllegalArgumentException
coordinates - a vector containing four elements where the first and
second elements represent the x and y coordinates of one point and the
third and fourth elements represent the x and y cooordinates of the second
point. These two coordinates represent the diagonal corners of the
rectangle.java.lang.IllegalArgumentException - thrown if coordinates is null or does not
have four elementspublic PRectangle createCartesianIntersection(PRectangle src2)
toJava2dCoordinates().src2 - the Rectangle2D to be intersected with this Rectangle2D.public java.awt.geom.Rectangle2D.Float getOriginalPoints()
Gets the orgional two points that created the PRectangle object. The first point is represented by the the rectangle positions x, y and the second poitn is represented by the width and height of the rectangle.
public java.awt.geom.Rectangle2D.Float toJava2dCoordinates()
Converts the Cartesian representation of the Rectangle into Rectangle in the Java2D coordinate space.
public static java.util.List getPRectangleVector(java.awt.geom.Rectangle2D rect)
rect - user space rectangle in Java2D coordinates space.