/** @see javax.swing.plaf.basic.BasicTextUI#getPreferredSize(javax.swing.JComponent) */
  public Dimension getPreferredSize(JComponent c) {
    // The following code has been derived from BasicTextUI.
    Document doc = ((JTextComponent) c).getDocument();
    Insets i = c.getInsets();
    Dimension d = c.getSize();
    View rootView = getRootView((JTextComponent) c);

    if (doc instanceof AbstractDocument) {
      ((AbstractDocument) doc).readLock();
    }

    try {
      if ((d.width > (i.left + i.right)) && (d.height > (i.top + i.bottom))) {
        rootView.setSize(d.width - i.left - i.right, d.height - i.top - i.bottom);
      } else if (d.width == 0 && d.height == 0) {
        // Probably haven't been layed out yet, force some sort of
        // initial sizing.
        rootView.setSize(Integer.MAX_VALUE, Integer.MAX_VALUE);
      }

      d.width =
          (int)
              Math.min(
                  (long) rootView.getPreferredSpan(View.X_AXIS) + (long) i.left + (long) i.right,
                  Integer.MAX_VALUE);
      d.height =
          (int)
              Math.min(
                  (long) rootView.getPreferredSpan(View.Y_AXIS) + (long) i.top + (long) i.bottom,
                  Integer.MAX_VALUE);
    } finally {
      if (doc instanceof AbstractDocument) {
        ((AbstractDocument) doc).readUnlock();
      }
    }

    // Fix: The preferred width is always two pixels too small on a Mac.
    d.width += 2;

    // We'd like our heights to be odd by default.
    if ((d.height & 1) == 0) {
      d.height--;
    }

    return d;
  }
  /**
   * Sets the size of the view. This should cause layout of the view if it has any layout duties.
   *
   * @param width the width >= 0
   * @param height the height >= 0
   */
  @Override
  public void setSize(float width, float height) {
    sync();

    if (getImage() == null) {
      View view = getAltView();

      if (view != null) {
        view.setSize(
            Math.max(0f, width - (DEFAULT_WIDTH + leftInset + rightInset)),
            Math.max(0f, height - (topInset + bottomInset)));
      }
    }
  }
 protected int getPreferredRowHeight(JTable table, SymbolEditorComponent editorComponent) {
   View v =
       editorComponent.getTextComponent().getUI().getRootView(editorComponent.getTextComponent());
   v.setSize(table.getWidth(), Integer.MAX_VALUE);
   return (int) v.getPreferredSpan(View.Y_AXIS);
 }
 @Override
 public void setSize(float width, float height) {
   super.setSize(width, height);
   updateMetrics();
 }