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();
}
}
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();
}
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;
}
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);
}
}
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);
}
}
}
Aggregations