com.itextpdf.text.pdf.parser
Class LocationTextExtractionStrategy.TextChunk

java.lang.Object
  extended by com.itextpdf.text.pdf.parser.LocationTextExtractionStrategy.TextChunk
All Implemented Interfaces:
Comparable<LocationTextExtractionStrategy.TextChunk>
Enclosing class:
LocationTextExtractionStrategy

private static class LocationTextExtractionStrategy.TextChunk
extends Object
implements Comparable<LocationTextExtractionStrategy.TextChunk>

Represents a chunk of text, it's orientation, and location relative to the orientation vector


Field Summary
(package private)  float charSpaceWidth
          the width of a single space character in the font of the chunk
(package private)  float distParallelEnd
          distance of the end of the chunk parallel to the orientation unit vector (i.e.
(package private)  float distParallelStart
          distance of the start of the chunk parallel to the orientation unit vector (i.e.
(package private)  int distPerpendicular
          perpendicular distance to the orientation unit vector (i.e.
(package private)  Vector endLocation
          the ending location of the chunk
(package private)  int orientationMagnitude
          the orientation as a scalar for quick sorting
(package private)  Vector orientationVector
          unit vector in the orientation of the chunk
(package private)  Vector startLocation
          the starting location of the chunk
(package private)  String text
          the text of the chunk
 
Constructor Summary
LocationTextExtractionStrategy.TextChunk(String string, Vector startLocation, Vector endLocation, float charSpaceWidth)
           
 
Method Summary
private static int compareInts(int int1, int int2)
           
 int compareTo(LocationTextExtractionStrategy.TextChunk rhs)
          Compares based on orientation, perpendicular distance, then parallel distance
 float distanceFromEndOf(LocationTextExtractionStrategy.TextChunk other)
          Computes the distance between the end of 'other' and the beginning of this chunk in the direction of this chunk's orientation vector.
private  void printDiagnostics()
           
 boolean sameLine(LocationTextExtractionStrategy.TextChunk as)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

text

final String text
the text of the chunk


startLocation

final Vector startLocation
the starting location of the chunk


endLocation

final Vector endLocation
the ending location of the chunk


orientationVector

final Vector orientationVector
unit vector in the orientation of the chunk


orientationMagnitude

final int orientationMagnitude
the orientation as a scalar for quick sorting


distPerpendicular

final int distPerpendicular
perpendicular distance to the orientation unit vector (i.e. the Y position in an unrotated coordinate system) we round to the nearest integer to handle the fuzziness of comparing floats


distParallelStart

final float distParallelStart
distance of the start of the chunk parallel to the orientation unit vector (i.e. the X position in an unrotated coordinate system)


distParallelEnd

final float distParallelEnd
distance of the end of the chunk parallel to the orientation unit vector (i.e. the X position in an unrotated coordinate system)


charSpaceWidth

final float charSpaceWidth
the width of a single space character in the font of the chunk

Constructor Detail

LocationTextExtractionStrategy.TextChunk

public LocationTextExtractionStrategy.TextChunk(String string,
                                                Vector startLocation,
                                                Vector endLocation,
                                                float charSpaceWidth)
Method Detail

printDiagnostics

private void printDiagnostics()

sameLine

public boolean sameLine(LocationTextExtractionStrategy.TextChunk as)
Parameters:
as - the location to compare to
Returns:
true is this location is on the the same line as the other

distanceFromEndOf

public float distanceFromEndOf(LocationTextExtractionStrategy.TextChunk other)
Computes the distance between the end of 'other' and the beginning of this chunk in the direction of this chunk's orientation vector. Note that it's a bad idea to call this for chunks that aren't on the same line and orientation, but we don't explicitly check for that condition for performance reasons.

Parameters:
other -
Returns:
the number of spaces between the end of 'other' and the beginning of this chunk

compareTo

public int compareTo(LocationTextExtractionStrategy.TextChunk rhs)
Compares based on orientation, perpendicular distance, then parallel distance

Specified by:
compareTo in interface Comparable<LocationTextExtractionStrategy.TextChunk>
See Also:
Comparable.compareTo(java.lang.Object)

compareInts

private static int compareInts(int int1,
                               int int2)
Parameters:
int1 -
int2 -
Returns:
comparison of the two integers

Hosted by openminds