Search in sources :

Example 6 with JochreDocument

use of com.joliciel.jochre.doc.JochreDocument in project jochre by urieli.

the class JochreCorpusImageProcessor method process.

public void process() {
    this.initialiseStream();
    JochreDocument currentDoc = null;
    JochrePage currentPage = null;
    for (JochreImage image : this.getImages()) {
        if (!image.getPage().equals(currentPage)) {
            if (currentPage != null) {
                for (DocumentObserver observer : observers) {
                    observer.onPageComplete(currentPage);
                }
                LOG.debug("completed page: " + currentPage);
            }
        }
        if (!image.getPage().getDocument().equals(currentDoc)) {
            if (currentDoc != null) {
                for (DocumentObserver observer : observers) {
                    observer.onDocumentComplete(currentDoc);
                }
                LOG.debug("completed doc: " + currentDoc);
            }
            currentDoc = image.getPage().getDocument();
            LOG.debug("next doc: " + currentDoc);
            for (DocumentObserver observer : observers) {
                observer.onDocumentStart(currentDoc);
            }
        }
        if (!image.getPage().equals(currentPage)) {
            currentPage = image.getPage();
            LOG.debug("next page: " + currentPage);
            for (DocumentObserver observer : observers) {
                observer.onPageStart(currentPage);
            }
        }
        LOG.debug("next image: " + image);
        for (DocumentObserver observer : observers) {
            observer.onImageStart(image);
        }
        for (DocumentObserver observer : observers) {
            observer.onImageComplete(image);
        }
        LOG.debug("completed image: " + image);
        image.clearMemory();
    }
    if (currentPage != null) {
        for (DocumentObserver observer : observers) {
            observer.onPageComplete(currentPage);
        }
        LOG.debug("completed page: " + currentPage);
    }
    if (currentDoc != null) {
        for (DocumentObserver observer : observers) {
            observer.onDocumentComplete(currentDoc);
        }
        LOG.debug("completed doc: " + currentDoc);
    }
    for (DocumentObserver observer : observers) {
        observer.onAnalysisComplete();
    }
}
Also used : DocumentObserver(com.joliciel.jochre.doc.DocumentObserver) JochreDocument(com.joliciel.jochre.doc.JochreDocument) JochrePage(com.joliciel.jochre.doc.JochrePage)

Example 7 with JochreDocument

use of com.joliciel.jochre.doc.JochreDocument in project jochre by urieli.

the class DocumentController method onClick$btnNewDoc.

@Listen("onClick = #btnNewDoc")
public void onClick$btnNewDoc() {
    LOG.debug("onClick$btnNewDoc");
    Window winUpdateDoc = (Window) Path.getComponent("//pgDocs/winUpdateDocument");
    JochreDocument newDoc = new JochreDocument(jochreSession);
    newDoc.setLocale(jochreSession.getLocale());
    newDoc.setOwner(this.currentUser);
    newDoc.setYear(1900);
    winUpdateDoc.setAttribute(UpdateDocumentController.ATTR_DOC, newDoc);
    winUpdateDoc.setAttribute(UpdateDocumentController.ATTR_DOC_CONTROLLER, this);
    Event modalEvent = new Event("onModalOpen", Path.getComponent("//pgDocs/winUpdateDocument"), newDoc);
    Events.sendEvent(modalEvent);
    winUpdateDoc.doModal();
}
Also used : Window(org.zkoss.zul.Window) Event(org.zkoss.zk.ui.event.Event) JochreDocument(com.joliciel.jochre.doc.JochreDocument) Listen(org.zkoss.zk.ui.select.annotation.Listen)

Example 8 with JochreDocument

use of com.joliciel.jochre.doc.JochreDocument in project jochre by urieli.

the class DocumentController method getDocumentTree.

public TreeModel<TreeNode<DocOrImage>> getDocumentTree() {
    LOG.debug("getDocumentTree2");
    DocumentDao documentDao = DocumentDao.getInstance(jochreSession);
    List<JochreDocument> docs = documentDao.findDocuments();
    List<TreeNode<DocOrImage>> docNodeList = new ArrayList<>();
    for (JochreDocument doc : docs) {
        List<TreeNode<DocOrImage>> imageNodeList = new ArrayList<>();
        for (JochrePage page : doc.getPages()) {
            LOG.debug("page " + page.getIndex());
            for (JochreImage image : page.getImages()) {
                DefaultTreeNode<DocOrImage> imageNode = new DefaultTreeNode<DocumentController.DocOrImage>(new DocOrImage(image));
                imageNodeList.add(imageNode);
                if (imageId == image.getId())
                    currentImage = image;
            }
        // have images?
        }
        boolean open = docId == doc.getId();
        if (open)
            currentDoc = doc;
        DefaultTreeNode<DocOrImage> docNode = new DirectoryTreeNode<DocumentController.DocOrImage>(new DocOrImage(doc), imageNodeList, open);
        docNodeList.add(docNode);
    }
    DefaultTreeNode<DocOrImage> root = new DefaultTreeNode<DocumentController.DocOrImage>(null, docNodeList);
    TreeModel<TreeNode<DocOrImage>> docTree = new DefaultTreeModel<>(root);
    this.reloadDoc();
    this.reloadImage();
    return docTree;
}
Also used : JochreImage(com.joliciel.jochre.graphics.JochreImage) DefaultTreeNode(org.zkoss.zul.DefaultTreeNode) ArrayList(java.util.ArrayList) DocumentDao(com.joliciel.jochre.doc.DocumentDao) JochreDocument(com.joliciel.jochre.doc.JochreDocument) DefaultTreeModel(org.zkoss.zul.DefaultTreeModel) JochrePage(com.joliciel.jochre.doc.JochrePage) TreeNode(org.zkoss.zul.TreeNode) DefaultTreeNode(org.zkoss.zul.DefaultTreeNode)

Example 9 with JochreDocument

use of com.joliciel.jochre.doc.JochreDocument in project jochre by urieli.

the class SplitController method doAfterCompose.

@Override
public void doAfterCompose(Window window) throws Exception {
    super.doAfterCompose(window);
    String pageTitle = Labels.getLabel("splits.title");
    winSplits.getPage().setTitle(pageTitle);
    Session session = Sessions.getCurrent();
    currentUser = (User) session.getAttribute(LoginController.SESSION_JOCHRE_USER);
    if (currentUser == null)
        Executions.sendRedirect("login.zul");
    GraphicsDao graphicsDao = GraphicsDao.getInstance(jochreSession);
    shapesToSplit = graphicsDao.findShapesToSplit(jochreSession.getLocale());
    for (Shape shape : shapesToSplit) {
        Row shapeRow = new Row();
        Image shapeImage = new Image();
        org.zkoss.image.Image convertedImage = Images.encode("shape_" + shape.getId() + ".png", shape.getImage());
        shapeImage.setContent(convertedImage);
        shapeImage.setWidth(shape.getImage().getWidth() + "px");
        shapeImage.setHeight((shape.getImage().getHeight()) + "px");
        Cell shapeCell = new Cell();
        Div shapeDiv = new Div();
        shapeDiv.setStyle("position: relative;");
        shapeCell.appendChild(shapeDiv);
        int shapeWidth = shape.getImage().getWidth();
        shapeCell.setWidth((shapeWidth + 100) + "px");
        shapeImage.addEventListener("onClick", new ShapeImageOnClickEventListener(shape, shapeDiv));
        shapeDiv.appendChild(shapeImage);
        for (Split split : shape.getSplits()) {
            Div verticalLine = new Div();
            verticalLine.setWidth("1px");
            verticalLine.setHeight("100px");
            verticalLine.setStyle("position: absolute; top:0px; left: " + split.getPosition() + "px;background-color:RED;");
            verticalLine.setId("shape" + shape.getId() + "split" + split.getPosition());
            verticalLine.addEventListener("onClick", new SplitOnClickEventListener(shape, shapeDiv, verticalLine, split));
            shapeDiv.appendChild(verticalLine);
        }
        shapeRow.appendChild(shapeCell);
        Cell letterCell = new Cell();
        Label letterLabel = new Label();
        letterLabel.setValue(shape.getLetter());
        letterCell.appendChild(letterLabel);
        letterCell.setWidth("100px");
        shapeRow.appendChild(letterCell);
        Cell detailsCell = new Cell();
        Label detailsLabel = new Label();
        JochrePage page = shape.getGroup().getRow().getParagraph().getImage().getPage();
        JochreDocument doc = page.getDocument();
        detailsLabel.setValue(doc.getName() + ", page " + page.getIndex());
        detailsCell.appendChild(detailsLabel);
        shapeRow.appendChild(detailsCell);
        splitGridRows.appendChild(shapeRow);
    }
}
Also used : Shape(com.joliciel.jochre.graphics.Shape) Label(org.zkoss.zul.Label) JochreDocument(com.joliciel.jochre.doc.JochreDocument) Image(org.zkoss.zul.Image) JochrePage(com.joliciel.jochre.doc.JochrePage) Div(org.zkoss.zul.Div) GraphicsDao(com.joliciel.jochre.graphics.GraphicsDao) Row(org.zkoss.zul.Row) Split(com.joliciel.jochre.boundaries.Split) Cell(org.zkoss.zul.Cell) JochreSession(com.joliciel.jochre.JochreSession) Session(org.zkoss.zk.ui.Session)

Example 10 with JochreDocument

use of com.joliciel.jochre.doc.JochreDocument in project jochre by urieli.

the class LexiconErrorWriter method onImageStart.

@Override
public void onImageStart(JochreImage jochreImage) {
    JochreDocument doc = jochreImage.getPage().getDocument();
    if (!doc.equals(currentDoc)) {
        currentDoc = doc;
        ErrorStatistics stats = errorMap.get(doc.getName());
        if (stats == null) {
            stats = new ErrorStatistics();
            errorMap.put(doc.getName(), stats);
        }
    }
}
Also used : JochreDocument(com.joliciel.jochre.doc.JochreDocument)

Aggregations

JochreDocument (com.joliciel.jochre.doc.JochreDocument)12 JochrePage (com.joliciel.jochre.doc.JochrePage)8 JochreImage (com.joliciel.jochre.graphics.JochreImage)6 Shape (com.joliciel.jochre.graphics.Shape)5 ArrayList (java.util.ArrayList)5 GroupOfShapes (com.joliciel.jochre.graphics.GroupOfShapes)4 Paragraph (com.joliciel.jochre.graphics.Paragraph)4 RowOfShapes (com.joliciel.jochre.graphics.RowOfShapes)4 Test (org.junit.Test)4 JochreSession (com.joliciel.jochre.JochreSession)3 File (java.io.File)3 DocumentDao (com.joliciel.jochre.doc.DocumentDao)2 DocumentObserver (com.joliciel.jochre.doc.DocumentObserver)2 Config (com.typesafe.config.Config)2 StringWriter (java.io.StringWriter)2 BeamSearchImageAnalyser (com.joliciel.jochre.analyser.BeamSearchImageAnalyser)1 ErrorLogger (com.joliciel.jochre.analyser.ErrorLogger)1 FScoreObserver (com.joliciel.jochre.analyser.FScoreObserver)1 ImageAnalyser (com.joliciel.jochre.analyser.ImageAnalyser)1 LetterAssigner (com.joliciel.jochre.analyser.LetterAssigner)1