Пример #1
0
  private void fontAddChars(FontTag ft, Set<Integer> selChars, Font font) {
    FontTag f = (FontTag) mainPanel.tagTree.getCurrentTreeItem();
    String oldchars = f.getCharacters();
    for (int ic : selChars) {
      char c = (char) ic;
      if (oldchars.indexOf((int) c) == -1) {
        font = font.deriveFont(f.getFontStyle(), 1024);
        if (!font.canDisplay(c)) {
          String msg = translate("error.font.nocharacter").replace("%char%", "" + c);
          Logger.getLogger(FontPanel.class.getName()).log(Level.SEVERE, msg);
          View.showMessageDialog(null, msg, translate("error"), JOptionPane.ERROR_MESSAGE);
          return;
        }
      }
    }

    String[] yesno =
        new String[] {
          translate("button.yes"),
          translate("button.no"),
          translate("button.yes.all"),
          translate("button.no.all")
        };
    boolean yestoall = false;
    boolean notoall = false;
    for (int ic : selChars) {
      char c = (char) ic;
      if (oldchars.indexOf((int) c) > -1) {
        int opt = -1;
        if (!(yestoall || notoall)) {
          opt =
              View.showOptionDialog(
                  null,
                  translate("message.font.add.exists").replace("%char%", "" + c),
                  translate("message.warning"),
                  JOptionPane.YES_NO_OPTION,
                  JOptionPane.WARNING_MESSAGE,
                  null,
                  yesno,
                  translate("button.yes"));
          if (opt == 2) {
            yestoall = true;
          }
          if (opt == 3) {
            notoall = true;
          }
        }

        if (yestoall) {
          opt = 0; // yes
        } else if (notoall) {
          opt = 1; // no
        }

        if (opt == 1) {
          continue;
        }
      }
      f.addCharacter(c, font);
      oldchars += c;
    }

    int fontId = ft.getFontId();
    if (updateTextsCheckBox.isSelected()) {
      SWF swf = ft.getSwf();
      for (Tag tag : swf.getTags()) {
        if (tag instanceof TextTag) {
          TextTag textTag = (TextTag) tag;
          if (textTag.getFontIds().contains(fontId)) {
            String text = textTag.getFormattedText().text;
            mainPanel.saveText(textTag, text, null);
          }
        }
      }
    }
    ft.setModified(true);
    ft.getSwf().clearImageCache();
  }