/**
   * Determine the number of lines in the annotation text and the length of the longest line.
   *
   * @param annoText the annotation text.
   * @return the length of the longest line (width) and number of lines (height).
   */
  protected Dimension computeLengths(String annoText) {
    String[] lines = Util.splitLines(annoText);
    int lineLength = 0;
    for (String line : lines) {
      if (line.length() > lineLength) lineLength = line.length();
    }

    return new Dimension(
        lineLength + 5, lines.length + 1); // the 5 and 1 account for slight sizing discrepancies
  }
  /**
   * Split a collection of lines into a new collection whose lines are all less than the maximum
   * allowed line length.
   *
   * @param origText the original lines.
   * @return the new lines.
   */
  protected String splitLines(String origText) {
    StringBuilder newText = new StringBuilder();

    String[] lines = Util.splitLines(origText);
    for (String line : lines) {
      // Append the line to the output buffer if it's within size, other wise split it and append
      // the result.
      newText
          .append(line.length() <= this.maxLineLength ? line : this.splitLine(line))
          .append("\n");
    }

    return newText.toString();
  }