Search in sources :

Example 1 with TextGetter

use of com.joliciel.jochre.output.TextGetter in project jochre by urieli.

the class TextController method onTimer$startRenderTimer.

@Listen("onTimer = #startRenderTimer")
public void onTimer$startRenderTimer(Event event) {
    try {
        progressBox.setVisible(true);
        if (currentImage != null) {
            Html html = new Html();
            StringWriter out = new StringWriter();
            DocumentObserver textGetter = new TextGetter(out, TextFormat.XHTML);
            textGetter.onImageComplete(currentImage);
            html.setContent(out.toString());
            htmlContent.appendChild(html);
            progressMeter1.setValue(100);
        // progressBox.setVisible(false);
        } else {
            if (currentPageIndex < currentDoc.getPages().size()) {
                JochrePage page = currentDoc.getPages().get(currentPageIndex);
                for (JochreImage image : page.getImages()) {
                    Html html = new Html();
                    StringWriter out = new StringWriter();
                    DocumentObserver textGetter = new TextGetter(out, TextFormat.XHTML);
                    textGetter.onImageComplete(image);
                    out.append("<HR/>");
                    html.setContent(out.toString());
                    htmlContent.appendChild(html);
                }
                page.clearMemory();
                currentPageIndex++;
                double percentComplete = ((double) currentPageIndex / (double) currentDoc.getPages().size()) * 100;
                progressMeter1.setValue(new Double(percentComplete).intValue());
                startRenderTimer.setRunning(true);
            } else {
                progressMeter1.setValue(100);
            // progressBox.setVisible(false);
            }
        }
    } catch (Exception e) {
        LOG.error("Failure in onTimer$startRenderTimer", e);
        throw new RuntimeException(e);
    }
}
Also used : JochreImage(com.joliciel.jochre.graphics.JochreImage) StringWriter(java.io.StringWriter) DocumentObserver(com.joliciel.jochre.doc.DocumentObserver) Html(org.zkoss.zul.Html) JochrePage(com.joliciel.jochre.doc.JochrePage) TextGetter(com.joliciel.jochre.output.TextGetter) Listen(org.zkoss.zk.ui.select.annotation.Listen)

Aggregations

DocumentObserver (com.joliciel.jochre.doc.DocumentObserver)1 JochrePage (com.joliciel.jochre.doc.JochrePage)1 JochreImage (com.joliciel.jochre.graphics.JochreImage)1 TextGetter (com.joliciel.jochre.output.TextGetter)1 StringWriter (java.io.StringWriter)1 Listen (org.zkoss.zk.ui.select.annotation.Listen)1 Html (org.zkoss.zul.Html)1