Search in sources :

Example 1 with Split

use of com.joliciel.jochre.boundaries.Split in project jochre by urieli.

the class Shape method addSplit.

/**
 * Add a split to this shape at the indicated position.
 */
public Split addSplit(int position) {
    List<Split> splits = this.getSplits();
    Split split = new Split(this, jochreSession);
    split.setPosition(position);
    splits.add(split);
    return split;
}
Also used : Split(com.joliciel.jochre.boundaries.Split)

Example 2 with Split

use of com.joliciel.jochre.boundaries.Split in project jochre by urieli.

the class Shape method getSplits.

/**
 * Return any splits marked on this shape.
 */
public List<Split> getSplits() {
    if (splits == null) {
        splits = new PersistentListImpl<Split>();
        BoundaryDao boundaryDao = BoundaryDao.getInstance(jochreSession);
        splits.addAll(boundaryDao.findSplits(this));
    }
    return splits;
}
Also used : BoundaryDao(com.joliciel.jochre.boundaries.BoundaryDao) Split(com.joliciel.jochre.boundaries.Split)

Example 3 with Split

use of com.joliciel.jochre.boundaries.Split 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)

Aggregations

Split (com.joliciel.jochre.boundaries.Split)3 JochreSession (com.joliciel.jochre.JochreSession)1 BoundaryDao (com.joliciel.jochre.boundaries.BoundaryDao)1 JochreDocument (com.joliciel.jochre.doc.JochreDocument)1 JochrePage (com.joliciel.jochre.doc.JochrePage)1 GraphicsDao (com.joliciel.jochre.graphics.GraphicsDao)1 Shape (com.joliciel.jochre.graphics.Shape)1 Session (org.zkoss.zk.ui.Session)1 Cell (org.zkoss.zul.Cell)1 Div (org.zkoss.zul.Div)1 Image (org.zkoss.zul.Image)1 Label (org.zkoss.zul.Label)1 Row (org.zkoss.zul.Row)1