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

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

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

The LinePositionComparator is optionally called by text extraction algorithms to help insure text lines found on a page are ordered using the y coordinates of the bounding box in the cartesian plane's fourth quadrant. The sorting tries to order the line blocks via the coordinate system rather then the order that they were plotted in.

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

Since:
5.0.6

Constructor Summary
LinePositionComparator()
           
 
Method Summary
 int compare(AbstractText lt1, AbstractText lt2)
          Compares the y coordinates of the AbstractText bounding box's y 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

LinePositionComparator

public LinePositionComparator()
Method Detail

compare

public int compare(AbstractText lt1,
                   AbstractText lt2)
Compares the y coordinates of the AbstractText bounding box's y 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.y is numerically equal to lt2.y; a value less than 0 if lt1.y is numerically less than lt2.y; and a value greater than 0 if lt1.y is numerically greater than lt2.y.