com.qoppa.pdf
Class TextPosition

java.lang.Object
  extended by com.qoppa.pdf.TextPosition
All Implemented Interfaces:
TextSelection
Direct Known Subclasses:
TextPositionWithContext

public class TextPosition
extends Object
implements TextSelection

Object that holds information about the location of a text string in a PDF file. This information is returned by the library when text information is needed by the host application. The information includes the text position, its angle and its "quadrilateral", the four points that enclose the text on the display.

Author:
Qoppa Software

Field Summary
 int m_PageNumber
           
 
Constructor Summary
TextPosition(String text, Shape textShape, Point2D[] quad, double angle)
           
TextPosition(String text, Shape textShape, Point2D[] quad, double angle, int pageNumber)
           
 
Method Summary
 double getAngle()
          Returns the angle that this text is displayed at on the page.
 Shape getEnclosingShape()
          Returns a shape that encloses the text on the page.
 int getPageNumber()
           
 Point2D[] getQuadrilateral()
          Returns a quadrilateral with the four corners for this text string.
 Vector getQuadrilaterals()
          Returns a list of quadrilaterals that will enclose the text elements in this object.
 Shape getSelectionShape()
          Returns the shape that will enclose the text on the display.
 String getText()
          Returns the text string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_PageNumber

public int m_PageNumber
Constructor Detail

TextPosition

public TextPosition(String text,
                    Shape textShape,
                    Point2D[] quad,
                    double angle)

TextPosition

public TextPosition(String text,
                    Shape textShape,
                    Point2D[] quad,
                    double angle,
                    int pageNumber)
Method Detail

getEnclosingShape

public Shape getEnclosingShape()
Returns a shape that encloses the text on the page. The shape's coordinate system is in 'display' coordinates: The origin of the coordinates are page.getCropBox().getX() and page.getCropBox().getY().

Returns:
A Shape that holds the string.

getText

public String getText()
Returns the text string.

Specified by:
getText in interface TextSelection
Returns:
The text.

getQuadrilateral

public Point2D[] getQuadrilateral()
Returns a quadrilateral with the four corners for this text string. The coordinates of the quadrilaterals is in MediaBox space.

Returns:
An array of 4 Point2D object. The points in can be connected by lines in the array order to form the quadrilateral enclosing the text.

getAngle

public double getAngle()
Returns the angle that this text is displayed at on the page.

Returns:
The angle of the text

getQuadrilaterals

public Vector getQuadrilaterals()
Returns a list of quadrilaterals that will enclose the text elements in this object. This method is here to fulfill the TextSelection interface and will always return a Vector with a single element.

Specified by:
getQuadrilaterals in interface TextSelection
Returns:
A list of one quadrilateral - the four around the text

getSelectionShape

public Shape getSelectionShape()
Returns the shape that will enclose the text on the display. This method is here to fulfill the TextSelection interface.

Specified by:
getSelectionShape in interface TextSelection
Returns:
The shape that will enclose the text on the screen.

getPageNumber

public int getPageNumber()