Package com.itextpdf.text.pdf.parser
Class LocationTextExtractionStrategy.TextChunk
- java.lang.Object
-
- com.itextpdf.text.pdf.parser.LocationTextExtractionStrategy.TextChunk
-
- All Implemented Interfaces:
java.lang.Comparable<LocationTextExtractionStrategy.TextChunk>
- Enclosing class:
- LocationTextExtractionStrategy
public static class LocationTextExtractionStrategy.TextChunk extends java.lang.Object implements java.lang.Comparable<LocationTextExtractionStrategy.TextChunk>
Represents a chunk of text, it's orientation, and location relative to the orientation vector
-
-
Field Summary
Fields Modifier and Type Field Description private LocationTextExtractionStrategy.TextChunkLocation
location
private java.lang.String
text
the text of the chunk
-
Constructor Summary
Constructors Constructor Description TextChunk(java.lang.String string, LocationTextExtractionStrategy.TextChunkLocation loc)
TextChunk(java.lang.String string, Vector startLocation, Vector endLocation, float charSpaceWidth)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(LocationTextExtractionStrategy.TextChunk rhs)
Compares based on orientation, perpendicular distance, then parallel distancefloat
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.float
getCharSpaceWidth()
Vector
getEndLocation()
LocationTextExtractionStrategy.TextChunkLocation
getLocation()
Vector
getStartLocation()
java.lang.String
getText()
private void
printDiagnostics()
private boolean
sameLine(LocationTextExtractionStrategy.TextChunk lastChunk)
-
-
-
Field Detail
-
text
private final java.lang.String text
the text of the chunk
-
location
private final LocationTextExtractionStrategy.TextChunkLocation location
-
-
Constructor Detail
-
TextChunk
public TextChunk(java.lang.String string, Vector startLocation, Vector endLocation, float charSpaceWidth)
-
TextChunk
public TextChunk(java.lang.String string, LocationTextExtractionStrategy.TextChunkLocation loc)
-
-
Method Detail
-
getText
public java.lang.String getText()
- Returns:
- the text captured by this chunk
-
getLocation
public LocationTextExtractionStrategy.TextChunkLocation getLocation()
- Returns:
- an object holding location data about this TextChunk
-
getStartLocation
public Vector getStartLocation()
- Returns:
- the start location of the text
-
getEndLocation
public Vector getEndLocation()
- Returns:
- the end location of the text
-
getCharSpaceWidth
public float getCharSpaceWidth()
- Returns:
- the width of a single space character as rendered by this chunk
-
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
- the otherLocationTextExtractionStrategy.TextChunk
- Returns:
- the number of spaces between the end of 'other' and the beginning of this chunk
-
printDiagnostics
private void printDiagnostics()
-
compareTo
public int compareTo(LocationTextExtractionStrategy.TextChunk rhs)
Compares based on orientation, perpendicular distance, then parallel distance- Specified by:
compareTo
in interfacejava.lang.Comparable<LocationTextExtractionStrategy.TextChunk>
- Parameters:
rhs
- the other object- See Also:
Comparable.compareTo(java.lang.Object)
-
sameLine
private boolean sameLine(LocationTextExtractionStrategy.TextChunk lastChunk)
-
-