java.lang.Object
org.sejda.sambox.pdmodel.common.PDRectangle
- All Implemented Interfaces:
COSObjectable
A rectangle in a PDF document.
- Author:
- Ben Litchfield
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PDRectangleA rectangle the size of A0 Paper.static final PDRectangleA rectangle the size of A1 Paper.static final PDRectangleA rectangle the size of A2 Paper.static final PDRectangleA rectangle the size of A3 Paper.static final PDRectangleA rectangle the size of A4 Paper.static final PDRectangleA rectangle the size of A5 Paper.static final PDRectangleA rectangle the size of A6 Paper.static final PDRectangleA rectangle the size of U.S.static final PDRectangleA rectangle the size of U.S. -
Constructor Summary
ConstructorsConstructorDescriptionInitializes to 0,0,0,0PDRectangle(float width, float height) PDRectangle(float x, float y, float width, float height) PDRectangle(Rectangle2D rectange) PDRectangle(org.apache.fontbox.util.BoundingBox box) PDRectangle(COSArray array) -
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(float x, float y) Method to determine if the x/y point is inside this rectangle.This will create a translated rectangle based off of this rectangle, such that the new rectangle retains the same dimensions(height/width), but the lower left x,y values are zero.booleanfloatThis will get the height of this rectangle as calculated by upperRightY - lowerLeftY.floatThis will get the lower left x coordinate.floatThis will get the lower left y coordinate.floatThis will get the upper right x coordinate.floatThis will get the upper right y coordinate.floatgetWidth()This will get the width of this rectangle as calculated by upperRightX - lowerLeftX.inthashCode()static PDRectanglerectangleFrom(COSArray array) rotate()rotate(int degrees) voidsetLowerLeftX(float value) This will set the lower left x coordinate.voidsetLowerLeftY(float value) This will set the lower left y coordinate.voidsetUpperRightX(float value) This will set the upper right x coordinate.voidsetUpperRightY(float value) This will set the upper right y coordinate.Returns a general path equivalent to this rectangle.toString()This will return a string representation of this rectangle.Returns a path which represents this rectangle having been transformed by the given matrix.
-
Field Details
-
LETTER
A rectangle the size of U.S. Letter, 8.5" x 11". -
LEGAL
A rectangle the size of U.S. Legal, 8.5" x 14". -
A0
A rectangle the size of A0 Paper. -
A1
A rectangle the size of A1 Paper. -
A2
A rectangle the size of A2 Paper. -
A3
A rectangle the size of A3 Paper. -
A4
A rectangle the size of A4 Paper. -
A5
A rectangle the size of A5 Paper. -
A6
A rectangle the size of A6 Paper.
-
-
Constructor Details
-
PDRectangle
public PDRectangle()Initializes to 0,0,0,0 -
PDRectangle
public PDRectangle(float width, float height) - Parameters:
width- The width of the rectangle.height- The height of the rectangle.
-
PDRectangle
public PDRectangle(float x, float y, float width, float height) - Parameters:
x- the x coordinate of the rectangley- the y coordinate of the rectanglewidth- The width of the rectangle.height- The height of the rectangle.
-
PDRectangle
-
PDRectangle
public PDRectangle(org.apache.fontbox.util.BoundingBox box) - Parameters:
box- the bounding box to be used for the rectangle
-
PDRectangle
- Parameters:
array- An array of numbers as specified in the PDF Reference for a rectangle type.
-
-
Method Details
-
contains
public boolean contains(float x, float y) Method to determine if the x/y point is inside this rectangle.- Parameters:
x- The x-coordinate to test.y- The y-coordinate to test.- Returns:
- True if the point is inside this rectangle.
-
createRetranslatedRectangle
This will create a translated rectangle based off of this rectangle, such that the new rectangle retains the same dimensions(height/width), but the lower left x,y values are zero.
100, 100, 400, 400 (llx, lly, urx, ury )
will be translated to 0,0,300,300- Returns:
- A new rectangle that has been translated back to the origin.
-
getLowerLeftX
public float getLowerLeftX()This will get the lower left x coordinate.- Returns:
- The lower left x.
-
setLowerLeftX
public void setLowerLeftX(float value) This will set the lower left x coordinate.- Parameters:
value- The lower left x.
-
getLowerLeftY
public float getLowerLeftY()This will get the lower left y coordinate.- Returns:
- The lower left y.
-
setLowerLeftY
public void setLowerLeftY(float value) This will set the lower left y coordinate.- Parameters:
value- The lower left y.
-
getUpperRightX
public float getUpperRightX()This will get the upper right x coordinate.- Returns:
- The upper right x .
-
setUpperRightX
public void setUpperRightX(float value) This will set the upper right x coordinate.- Parameters:
value- The upper right x .
-
getUpperRightY
public float getUpperRightY()This will get the upper right y coordinate.- Returns:
- The upper right y.
-
setUpperRightY
public void setUpperRightY(float value) This will set the upper right y coordinate.- Parameters:
value- The upper right y.
-
getWidth
public float getWidth()This will get the width of this rectangle as calculated by upperRightX - lowerLeftX.- Returns:
- The width of this rectangle.
-
getHeight
public float getHeight()This will get the height of this rectangle as calculated by upperRightY - lowerLeftY.- Returns:
- The height of this rectangle.
-
transform
Returns a path which represents this rectangle having been transformed by the given matrix. Note that the resulting path need not be rectangular. -
getCOSObject
- Specified by:
getCOSObjectin interfaceCOSObjectable- Returns:
- The
COSBasethat matches this Java object.
-
toGeneralPath
Returns a general path equivalent to this rectangle. This method avoids the problems caused by Rectangle2D not working well with -ve rectangles. -
rotate
- Returns:
- a new rectangle at the same coordinates but rotated clockwise by 90 degrees
-
rotate
- Returns:
- a new rectangle at the same coordinates but rotated clockwise by in degrees
-
equals
-
hashCode
public int hashCode() -
toString
This will return a string representation of this rectangle. -
rectangleFrom
- Parameters:
array-- Returns:
- a
PDRectangleif the the array is not null and has enough elements, null otherwise
-