Esempio n. 1
0
  public void showFontTag(FontTag ft) {
    SWF swf = ft.getSwf();
    fontTag = ft;
    fontNameIntagLabel.setText(ft.getFontNameIntag());
    fontNameTextArea.setText(ft.getFontName());
    fontCopyrightTextArea.setText(ft.getFontCopyright());

    fontIsBoldCheckBox.setSelected(ft.isBold());
    fontIsItalicCheckBox.setSelected(ft.isItalic());
    fontDescentLabel.setText(
        ft.getDescent() == -1 ? translate("value.unknown") : Integer.toString(ft.getDescent()));
    fontAscentLabel.setText(
        ft.getAscent() == -1 ? translate("value.unknown") : Integer.toString(ft.getAscent()));
    fontLeadingLabel.setText(
        ft.getLeading() == -1 ? translate("value.unknown") : Integer.toString(ft.getLeading()));
    String chars = ft.getCharacters();
    fontCharactersTextArea.setText(chars);
    fontCharactersScrollPane.getVerticalScrollBar().scrollRectToVisible(new Rectangle(0, 0, 1, 1));
    setAllowSave(false);

    Font selFont = ft.getSystemFont();
    fontFamilyNameSelection.setSelectedItem(new FontFamily(selFont));
    fontFaceSelection.setSelectedItem(new FontFace(selFont));

    setAllowSave(true);
    setEditable(false);
  }
Esempio n. 2
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();
  }