/**
   * Given a label figure object, this will calculate the correct Font needed to display into screen
   * coordinates, taking into account the current mapmode. This will typically be used by direct
   * edit cell editors that need to display independent of the zoom or any coordinate mapping that
   * is taking place on the drawing surface.
   *
   * @param label the label to use for the font calculation
   * @return the <code>Font</code> that is scaled to the screen coordinates. Note: the returned
   *     <code>Font</code> should not be disposed since it is cached by a common resource manager.
   */
  protected Font getScaledFont(IFigure label) {
    Font scaledFont = label.getFont();
    FontData data = scaledFont.getFontData()[0];
    Dimension fontSize = new Dimension(0, MapModeUtil.getMapMode(label).DPtoLP(data.getHeight()));
    label.translateToAbsolute(fontSize);

    if (Math.abs(data.getHeight() - fontSize.height) < 2) fontSize.height = data.getHeight();

    try {
      FontDescriptor fontDescriptor = FontDescriptor.createFrom(data);
      cachedFontDescriptors.add(fontDescriptor);
      return getResourceManager().createFont(fontDescriptor);
    } catch (DeviceResourceException e) {
      Trace.catching(
          DiagramUIPlugin.getInstance(),
          DiagramUIDebugOptions.EXCEPTIONS_CATCHING,
          getClass(),
          "getScaledFont",
          e); //$NON-NLS-1$
      Log.error(
          DiagramUIPlugin.getInstance(),
          DiagramUIStatusCodes.IGNORED_EXCEPTION_WARNING,
          "getScaledFont",
          e); //$NON-NLS-1$
    }
    return JFaceResources.getDefaultFont();
  }
  public void show() {
    super.show();

    IFigure fig = getEditPart().getFigure();

    Control control = getCellEditor().getControl();
    this.zoomLevelFont = getZoomLevelFont(fig.getFont(), control.getDisplay());

    control.setFont(this.zoomLevelFont);

    // since the font's have been resized, we need to resize the Text
    // control...
    getLocator().relocate(getCellEditor());
  }