Search in sources :

Example 1 with LetterLabelUpdater

use of com.joliciel.jochre.web.ImageController.LetterLabelUpdater in project jochre by urieli.

the class FixTextWindowController method onClick$btnOK.

@Listen("onClick = #btnOK")
public void onClick$btnOK(Event event) {
    // TODO: replacing all occurrences of the same word on the line instead
    // of just the current one
    LOG.debug("onClick$btnOK");
    winFixText.setVisible(false);
    String rowText = (String) winFixText.getAttribute(FixTextWindowController.ATTR_ROW_TEXT);
    Textbox rowTextBox = (Textbox) winFixText.getAttribute(FixTextWindowController.ATTR_ROW_TEXTBOX);
    LetterLabelUpdater updater = (LetterLabelUpdater) winFixText.getAttribute(FixTextWindowController.ATTR_LETTER_UPDATER);
    GroupOfShapes group = (GroupOfShapes) winFixText.getAttribute(FixTextWindowController.ATTR_GROUP);
    group.setSkip(chkSkip.isChecked());
    group.setHardHyphen(chkHardHyphen.isChecked());
    group.setBrokenWord(chkBrokenWord.isChecked());
    group.setSegmentationProblem(chkSegmentProblem.isChecked());
    group.save();
    List<Textbox> letterBoxes = new ArrayList<Textbox>();
    for (Object child : letterBoxRow.getChildren()) {
        if (child instanceof Textbox) {
            letterBoxes.add((Textbox) child);
        }
    }
    StringBuilder sb = new StringBuilder();
    // for (Textbox letterBox : letterBoxes) {
    for (Shape shape : group.getShapes()) {
        Textbox letterBox = (Textbox) letterBoxRow.getFellow("FixTextLetterBox_" + shape.getId());
        String letter = letterBox.getText();
        String newLetter = ImageController.getLetterForDisplay(letter);
        LOG.debug("Letter: " + letter + ", newLetter: " + newLetter);
        sb.append(newLetter);
    }
    LOG.debug(sb.toString());
    String newText = rowText.replace(FixTextWindowController.ROW_TEXT_PLACE_HOLDER, sb.toString());
    rowTextBox.setText(newText);
    updater.updateLetterLabels();
}
Also used : Shape(com.joliciel.jochre.graphics.Shape) GroupOfShapes(com.joliciel.jochre.graphics.GroupOfShapes) Textbox(org.zkoss.zul.Textbox) ArrayList(java.util.ArrayList) LetterLabelUpdater(com.joliciel.jochre.web.ImageController.LetterLabelUpdater) Listen(org.zkoss.zk.ui.select.annotation.Listen)

Aggregations

GroupOfShapes (com.joliciel.jochre.graphics.GroupOfShapes)1 Shape (com.joliciel.jochre.graphics.Shape)1 LetterLabelUpdater (com.joliciel.jochre.web.ImageController.LetterLabelUpdater)1 ArrayList (java.util.ArrayList)1 Listen (org.zkoss.zk.ui.select.annotation.Listen)1 Textbox (org.zkoss.zul.Textbox)1