src/main/java/eu/digitisation/layout/FR10Page.java
private List<TextComponent> parseWords(Element element) {
        List<TextComponent> words = new ArrayList<TextComponent>();
        NodeList charParams = element.getElementsByTagName("charParams");
        StringBuilder builder = new StringBuilder();
        Polygon points = new Polygon();

        for (int nchar = 0; nchar < charParams.getLength(); ++nchar) {
            Element charParam = (Element) charParams.item(nchar);
            String content = charParam.getTextContent().trim();
            if (!content.matches("\\p{Space}*")) {  // end of word
                int x0 = Integer.parseInt(charParam.getAttribute("l"));
                int y0 = Integer.parseInt(charParam.getAttribute("t"));
                int x1 = Integer.parseInt(charParam.getAttribute("r"));
                int y1 = Integer.parseInt(charParam.getAttribute("b"));
                points.addPoint(x0, y0);
                points.addPoint(x1, y1);
                builder.append(content);
            } else if (builder.length() > 0) {  // some content 
                TextComponent word
                        = new TextComponent(null, ComponentType.WORD, null,
                                builder.toString(), cover(points));
                words.add(word);
                builder = new StringBuilder();
                points = new Polygon();
            }
        }
        // flush 
        if (builder.length() > 0) {
            TextComponent word
                    = new TextComponent(null, ComponentType.WORD, null,
                            builder.toString(), cover(points));
            words.add(word);
        }
        components.addAll(words);
        return words;
    }
/**
     * Specific function to split FR10 formatting elements into smaller
     * components (words). Formatting is a sequence of charParams elements
     * containing characters. An empty charParams element indicates word
     * boundaries.
     *
     * @param element a formatting element
     * @return the TextComponents (words) in this element
     */
Specific function to split FR10 formatting elements into smaller
components (words). Formatting is a sequence of charParams elements
containing characters. An empty charParams element indicates word
boundaries.

@param element a formatting element
@return the TextComponents (words) in this element
Specific function to split FR10 formatting elements into smaller components ( words ) . Formatting is a sequence of charParams elements containing characters . An empty charParams element indicates word boundaries . @param element a formatting element @return the TextComponents ( words ) in this element
private List<TextComponent> parseWords(Element element) {
        List<TextComponent> words = new ArrayList<TextComponent>();
        NodeList charParams = element.getElementsByTagName("charParams");
        StringBuilder builder = new StringBuilder();
        Polygon points = new Polygon();
        for (int nchar = 0; nchar < charParams.getLength(); ++nchar) {
            Element charParam = (Element) charParams.item(nchar);
            String content = charParam.getTextContent().trim();
            if (!content.matches("\\p{Space}*")) {  
                int x0 = Integer.parseInt(charParam.getAttribute("l"));
                int y0 = Integer.parseInt(charParam.getAttribute("t"));
                int x1 = Integer.parseInt(charParam.getAttribute("r"));
                int y1 = Integer.parseInt(charParam.getAttribute("b"));
                points.addPoint(x0, y0);
                points.addPoint(x1, y1);
                builder.append(content);
            } else if (builder.length() > 0) {  
                TextComponent word
                        = new TextComponent(null, ComponentType.WORD, null,
                                builder.toString(), cover(points));
                words.add(word);
                builder = new StringBuilder();
                points = new Polygon();
            }
        }
        if (builder.length() > 0) {
            TextComponent word
                    = new TextComponent(null, ComponentType.WORD, null,
                            builder.toString(), cover(points));
            words.add(word);
        }
        components.addAll(words);
        return words;
    }
private List < TextComponent > parseWords ( Element element ) { List < TextComponent > words = new ArrayList < TextComponent > ( ) ; NodeList charParams = element . getElementsByTagName ( "charParams" ) ; StringBuilder builder = new StringBuilder ( ) ; Polygon points = new Polygon ( ) ; for ( int nchar = 0 ; nchar < charParams . getLength ( ) ; ++ nchar ) { Element charParam = ( Element ) charParams . item ( nchar ) ; String content = charParam . getTextContent ( ) . trim ( ) ; if ( ! content . matches ( "\\p{Space}*" ) ) { int x0 = Integer . parseInt ( charParam . getAttribute ( "l" ) ) ; int y0 = Integer . parseInt ( charParam . getAttribute ( "t" ) ) ; int x1 = Integer . parseInt ( charParam . getAttribute ( "r" ) ) ; int y1 = Integer . parseInt ( charParam . getAttribute ( "b" ) ) ; points . addPoint ( x0 , y0 ) ; points . addPoint ( x1 , y1 ) ; builder . append ( content ) ; } else if ( builder . length ( ) > 0 ) { TextComponent word = new TextComponent ( null , ComponentType . WORD , null , builder . toString ( ) , cover ( points ) ) ; words . add ( word ) ; builder = new StringBuilder ( ) ; points = new Polygon ( ) ; } } if ( builder . length ( ) > 0 ) { TextComponent word = new TextComponent ( null , ComponentType . WORD , null , builder . toString ( ) , cover ( points ) ) ; words . add ( word ) ; } components . addAll ( words ) ; return words ; }
Specific function to split FR10 formatting elements into smaller
 components (words).
Specific function to split FR10 formatting elements into smaller components ( words ) .
// end of word // some content  // flush 