use of com.itextpdf.kernel.pdf.canvas.parser.listener.ILocationExtractionStrategy in project i7j-pdfsweep by itext.
the class CompositeCleanupStrategy method getResultantLocations.
@Override
public Collection<IPdfTextLocation> getResultantLocations() {
locations.clear();
// build return value
Set<IPdfTextLocation> retval = new LinkedHashSet<>();
for (int i = 0; i < strategies.size(); i++) {
ILocationExtractionStrategy s = strategies.get(i);
Collection<IPdfTextLocation> rects = s.getResultantLocations();
retval.addAll(rects);
locations.put(i, new HashSet<>(rects));
}
List<IPdfTextLocation> rectangles = new ArrayList<>(retval);
java.util.Collections.sort(rectangles, new Comparator<IPdfTextLocation>() {
@Override
public int compare(IPdfTextLocation l1, IPdfTextLocation l2) {
Rectangle r1 = l1.getRectangle();
Rectangle r2 = l2.getRectangle();
if (r1.getY() == r2.getY()) {
return r1.getX() == r2.getX() ? 0 : (r1.getX() < r2.getX() ? -1 : 1);
} else {
return r1.getY() < r2.getY() ? -1 : 1;
}
}
});
// return
return rectangles;
}
Aggregations