org.apache.pdfbox.pdmodel.common
Class PDRectangle

java.lang.Object
  extended by org.apache.pdfbox.pdmodel.common.PDRectangle
All Implemented Interfaces:
COSObjectable

public class PDRectangle
extends Object
implements COSObjectable

This represents a rectangle in a PDF document.

Version:
$Revision: 1.12 $
Author:
Ben Litchfield

Constructor Summary
PDRectangle()
          Constructor.
PDRectangle(org.apache.fontbox.util.BoundingBox box)
          Constructor.
PDRectangle(COSArray array)
          Constructor.
PDRectangle(float width, float height)
          Constructor.
 
Method Summary
 boolean contains(float x, float y)
          Method to determine if the x/y point is inside this rectangle.
 Dimension createDimension()
          A convenience method to create a dimension object for AWT operations.
 PDRectangle 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.
 COSArray getCOSArray()
          This will get the underlying array for this rectangle.
 COSBase getCOSObject()
          Convert this standard java object to a COS object.
 float getHeight()
          This will get the height of this rectangle as calculated by upperRightY - lowerLeftY.
 float getLowerLeftX()
          This will get the lower left x coordinate.
 float getLowerLeftY()
          This will get the lower left y coordinate.
 float getUpperRightX()
          This will get the upper right x coordinate.
 float getUpperRightY()
          This will get the upper right y coordinate.
 float getWidth()
          This will get the width of this rectangle as calculated by upperRightX - lowerLeftX.
 void move(float horizontalAmount, float verticalAmount)
          This will move the rectangle the given relative amount.
 void setLowerLeftX(float value)
          This will set the lower left x coordinate.
 void setLowerLeftY(float value)
          This will set the lower left y coordinate.
 void setUpperRightX(float value)
          This will set the upper right x coordinate.
 void setUpperRightY(float value)
          This will set the upper right y coordinate.
 String toString()
          This will return a string representation of this rectangle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PDRectangle

public PDRectangle()
Constructor. Initializes to 0,0,0,0


PDRectangle

public PDRectangle(float width,
                   float height)
Constructor.

Parameters:
width - The width of the rectangle.
height - The height of the rectangle.

PDRectangle

public PDRectangle(org.apache.fontbox.util.BoundingBox box)
Constructor.

Parameters:
box - The non PD bouding box.

PDRectangle

public PDRectangle(COSArray array)
Constructor.

Parameters:
array - An array of numbers as specified in the PDF Reference for a rectangle type.
Method Detail

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

public PDRectangle 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.

getCOSArray

public COSArray getCOSArray()
This will get the underlying array for this rectangle.

Returns:
The cos array.

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.

createDimension

public Dimension createDimension()
A convenience method to create a dimension object for AWT operations.

Returns:
A dimension that matches the width and height of this rectangle.

move

public void move(float horizontalAmount,
                 float verticalAmount)
This will move the rectangle the given relative amount.

Parameters:
horizontalAmount - positive values will move rectangle to the right, negative's to the left.
verticalAmount - positive values will move the rectangle up, negative's down.

getCOSObject

public COSBase getCOSObject()
Convert this standard java object to a COS object.

Specified by:
getCOSObject in interface COSObjectable
Returns:
The cos object that matches this Java object.

toString

public String toString()
This will return a string representation of this rectangle.

Overrides:
toString in class Object
Returns:
This object as a string.


Copyright © 2002-2010 The Apache Software Foundation. All Rights Reserved.