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