Beispiel #1
0
  private void updateBody() {
    StringBuilder sb = new StringBuilder("<html>");
    int count = 0;

    Subtitle defSub = project.getDefSub();
    for (Subtitle sub : project.getSubs()) {
      if (sub.isEnabled()) {
        if (count++ < MAX_SUBS_BODY) {
          sb.append(sub.getIndex()).append(": ");
          if (sub == defSub) {
            sb.append("<b>").append(sub.getLanguage().toShortString()).append("</b>");
          } else {
            sb.append(sub.getLanguage().toShortString());
          }
          sb.append("<br>");
        }
      }
    }

    if (count == 0) {
      sb.append("<i>").append(B.getString("pane.subs.none")).append("</i>");
    } else if (count > MAX_SUBS_BODY) {
      sb.append("<i>");
      sb.append(MessageFormat.format(B.getString("pane.subs.more"), count - MAX_SUBS_BODY));
      sb.append("</i>");
    }

    getPowerTabModel().setBody(sb.toString());
  }
Beispiel #2
0
  /**
   * Creates a Subtitle with the given parameters.
   *
   * @param index Subtitle index
   * @param streamId Stream ID of this subtitle
   * @param vts Stream VTS
   * @param ds {@link DvdSubtitle} with further data
   * @param format {@link SubtitleFormat} of this subtitle
   * @return Created {@link Subtitle}
   */
  private Subtitle createSubtitle(
      int index, int streamId, int vts, DvdSubtitle ds, SubtitleFormat format) {
    Subtitle sub = new Subtitle();
    sub.setIndex(index);
    sub.setStreamId(String.format("0x%02X", streamId));
    sub.setFormat(format);
    sub.setVts(vts);

    Language language = LanguageUtils.findLanguage(ds.getLanguage());
    if (language != null) {
      sub.setLanguage(language);
      sub.setEnabled(format == SubtitleFormat.STANDARD || format == SubtitleFormat.WIDE);
    } else {
      sub.setLanguage(LanguageUtils.getMissing());
      sub.setEnabled(false);
    }

    sub.setType(SubtitleType.NOT_SPECIFIED);
    if (ds.getType() != null) {
      try {
        sub.setType(SubtitleType.valueOf(ds.getType().name()));
      } catch (IllegalArgumentException ex) {
        // ignore
      }
    }

    return sub;
  }