org.icepdf.core.pobjects.graphics.text
Class WordPositionComparator

java.lang.Object
  extended by org.icepdf.core.pobjects.graphics.text.WordPositionComparator
All Implemented Interfaces:
java.util.Comparator<AbstractText>

public class WordPositionComparator
extends java.lang.Object
implements java.util.Comparator<AbstractText>

The WordPositionComparator is optionally called by text extraction algorithms to help insure words found in a line are ordered using the x coordinates of the bounding box in the cartesian plane's fourth quadrant. The sorting tries to order the word blocks via the coordinate system rather then the order that they were plotted in and thus shouldn't effect LTR or RTL writing formats.

It's assumed that all WordText that is a child of LineText will not be sorted on the y access. The class LinePositionComparator will be used to insure that lines are ordered correctly in the parent PageText array.

Since:
5.0.6

Constructor Summary
WordPositionComparator()
           
 
Method Summary
 int compare(AbstractText lt1, AbstractText lt2)
          Compares the x coordinates of the AbstractText bounding box's x coordinate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

WordPositionComparator

public WordPositionComparator()
Method Detail

compare

public int compare(AbstractText lt1,
                   AbstractText lt2)
Compares the x coordinates of the AbstractText bounding box's x coordinate.

Specified by:
compare in interface java.util.Comparator<AbstractText>
Parameters:
lt1 - word text object to compare
lt2 - word text object to compare
Returns:
the value 0 if lt1.x is numerically equal to lt2.x; a value less than 0 if lt1.x is numerically less than lt2.x; and a value greater than 0 if lt1.x is numerically greater than lt2.x.