Package com.itextpdf.text.pdf.parser
Class LocationTextExtractionStrategy.TextChunkLocationDefaultImp
java.lang.Object
com.itextpdf.text.pdf.parser.LocationTextExtractionStrategy.TextChunkLocationDefaultImp
- All Implemented Interfaces:
LocationTextExtractionStrategy.TextChunkLocation
,Comparable<LocationTextExtractionStrategy.TextChunkLocation>
- Enclosing class:
LocationTextExtractionStrategy
public static class LocationTextExtractionStrategy.TextChunkLocationDefaultImp
extends Object
implements LocationTextExtractionStrategy.TextChunkLocation
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final float
the width of a single space character in the font of the chunkprivate final float
distance of the end of the chunk parallel to the orientation unit vector (i.e.private final float
distance of the start of the chunk parallel to the orientation unit vector (i.e.private final int
perpendicular distance to the orientation unit vector (i.e.private final Vector
the ending location of the chunkprivate final int
the orientation as a scalar for quick sortingprivate final Vector
unit vector in the orientation of the chunkprivate final Vector
the starting location of the chunk -
Constructor Summary
ConstructorsConstructorDescriptionTextChunkLocationDefaultImp
(Vector startLocation, Vector endLocation, float charSpaceWidth) -
Method Summary
Modifier and TypeMethodDescriptionint
float
Computes the distance between the end of 'other' and the beginning of this chunk in the direction of this chunk's orientation vector.float
float
int
float
boolean
int
boolean
-
Field Details
-
startLocation
the starting location of the chunk -
endLocation
the ending location of the chunk -
orientationVector
unit vector in the orientation of the chunk -
orientationMagnitude
private final int orientationMagnitudethe orientation as a scalar for quick sorting -
distPerpendicular
private final int distPerpendicularperpendicular 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
private final float distParallelStartdistance of the start of the chunk parallel to the orientation unit vector (i.e. the X position in an unrotated coordinate system) -
distParallelEnd
private final float distParallelEnddistance of the end of the chunk parallel to the orientation unit vector (i.e. the X position in an unrotated coordinate system) -
charSpaceWidth
private final float charSpaceWidththe width of a single space character in the font of the chunk
-
-
Constructor Details
-
TextChunkLocationDefaultImp
-
-
Method Details
-
orientationMagnitude
public int orientationMagnitude()- Specified by:
orientationMagnitude
in interfaceLocationTextExtractionStrategy.TextChunkLocation
-
distPerpendicular
public int distPerpendicular()- Specified by:
distPerpendicular
in interfaceLocationTextExtractionStrategy.TextChunkLocation
-
distParallelStart
public float distParallelStart()- Specified by:
distParallelStart
in interfaceLocationTextExtractionStrategy.TextChunkLocation
-
distParallelEnd
public float distParallelEnd()- Specified by:
distParallelEnd
in interfaceLocationTextExtractionStrategy.TextChunkLocation
-
getStartLocation
- Specified by:
getStartLocation
in interfaceLocationTextExtractionStrategy.TextChunkLocation
- Returns:
- the start location of the text
-
getEndLocation
- Specified by:
getEndLocation
in interfaceLocationTextExtractionStrategy.TextChunkLocation
- Returns:
- the end location of the text
-
getCharSpaceWidth
public float getCharSpaceWidth()- Specified by:
getCharSpaceWidth
in interfaceLocationTextExtractionStrategy.TextChunkLocation
- Returns:
- the width of a single space character as rendered by this chunk
-
sameLine
- Specified by:
sameLine
in interfaceLocationTextExtractionStrategy.TextChunkLocation
- Parameters:
as
- the location to compare to- Returns:
- true is this location is on the the same line as the other
-
distanceFromEndOf
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.- Specified by:
distanceFromEndOf
in interfaceLocationTextExtractionStrategy.TextChunkLocation
- Parameters:
other
-- Returns:
- the number of spaces between the end of 'other' and the beginning of this chunk
-
isAtWordBoundary
- Specified by:
isAtWordBoundary
in interfaceLocationTextExtractionStrategy.TextChunkLocation
-
compareTo
- Specified by:
compareTo
in interfaceComparable<LocationTextExtractionStrategy.TextChunkLocation>
-