public static List<java.lang.Float> columnPositions(List<Line> lines) {

        List<Rectangle> regions = new ArrayList<>();
        for (TextChunk tc: lines.get(0).getTextElements()) {
            if (tc.isSameChar(Line.WHITE_SPACE_CHARS)) { 
                continue; 
            }
            Rectangle r = new Rectangle();
            r.setRect(tc);
            regions.add(r);
        }
        
        for (Line l: lines.subList(1, lines.size())) {
            List<TextChunk> lineTextElements = new ArrayList<>();
            for (TextChunk tc: l.getTextElements()) {
                if (!tc.isSameChar(Line.WHITE_SPACE_CHARS)) { 
                    lineTextElements.add(tc);
                }
            }
            
            for (Rectangle cr: regions) {

                List<TextChunk> overlaps = new ArrayList<>();
                for (TextChunk te: lineTextElements) {
                    if (cr.horizontallyOverlaps(te)) {
                        overlaps.add(te);
                    }
                }
                
                for (TextChunk te: overlaps) {
                    cr.merge(te);
                }
                
                lineTextElements.removeAll(overlaps);
            }
            
            for (TextChunk te: lineTextElements) {
                Rectangle r = new Rectangle();
                r.setRect(te);
                regions.add(r);
            }
        }
        
        List<java.lang.Float> rv = new ArrayList<>();
        for (Rectangle r: regions) {
            rv.add(r.getRight());
        }
        
        Collections.sort(rv);
        
        return rv;
        
    }
public static List < java . lang . Float > columnPositions ( List < Line > lines ) { List < Rectangle > regions = new ArrayList < > ( ) ; for ( TextChunk tc : lines . get ( 0 ) . getTextElements ( ) ) { if ( tc . isSameChar ( Line . WHITE_SPACE_CHARS ) ) { continue ; } Rectangle r = new Rectangle ( ) ; r . setRect ( tc ) ; regions . add ( r ) ; } for ( Line l : lines . subList ( 1 , lines . size ( ) ) ) { List < TextChunk > lineTextElements = new ArrayList < > ( ) ; for ( TextChunk tc : l . getTextElements ( ) ) { if ( ! tc . isSameChar ( Line . WHITE_SPACE_CHARS ) ) { lineTextElements . add ( tc ) ; } } for ( Rectangle cr : regions ) { List < TextChunk > overlaps = new ArrayList < > ( ) ; for ( TextChunk te : lineTextElements ) { if ( cr . horizontallyOverlaps ( te ) ) { overlaps . add ( te ) ; } } for ( TextChunk te : overlaps ) { cr . merge ( te ) ; } lineTextElements . removeAll ( overlaps ) ; } for ( TextChunk te : lineTextElements ) { Rectangle r = new Rectangle ( ) ; r . setRect ( te ) ; regions . add ( r ) ; } } List < java . lang . Float > rv = new ArrayList < > ( ) ; for ( Rectangle r : regions ) { rv . add ( r . getRight ( ) ) ; } Collections . sort ( rv ) ; return rv ; }
@param lines must be an array of lines sorted by their +top+ attribute
@return a list of column boundaries (x axis)