Ejemplo n.º 1
0
  protected void installDefaults(AbstractButton b) {
    // load shared instance defaults
    String pp = getPropertyPrefix();

    defaultTextShiftOffset = UIManager.getInt(pp + "textShiftOffset");

    // set the following defaults on the button
    if (b.isContentAreaFilled()) {
      LookAndFeel.installProperty(b, "opaque", Boolean.TRUE);
    } else {
      LookAndFeel.installProperty(b, "opaque", Boolean.FALSE);
    }

    if (b.getMargin() == null || (b.getMargin() instanceof UIResource)) {
      b.setMargin(UIManager.getInsets(pp + "margin"));
    }

    LookAndFeel.installColorsAndFont(b, pp + "background", pp + "foreground", pp + "font");
    LookAndFeel.installBorder(b, pp + "border");

    Object rollover = UIManager.get(pp + "rollover");
    if (rollover != null) {
      LookAndFeel.installProperty(b, "rolloverEnabled", rollover);
    }

    LookAndFeel.installProperty(b, "iconTextGap", new Integer(4));
  }
Ejemplo n.º 2
0
 public CellBorder() {
   expandedIcon = (Icon) UIManager.get(TREE_EXPANDED_ICON_KEY);
   collapsedIcon = (Icon) UIManager.get(TREE_COLLAPSED_ICON_KEY);
   if (expandedIcon == null) {
     expandedIcon = new ExpandedIcon();
   }
   if (collapsedIcon == null) {
     collapsedIcon = new CollapsedIcon();
   }
 }
Ejemplo n.º 3
0
  public IdeaMenuUI() {
    myMaxGutterIconWidth = 18;

    if (UIUtil.isUnderAquaLookAndFeel()) {
      if (myAquaSelectedBackgroundPainter == null)
        myAquaSelectedBackgroundPainter =
            (Border) UIManager.get("MenuItem.selectedBackgroundPainter");
      if (myAquaInvertedArrowIcon == null)
        myAquaInvertedArrowIcon = (Icon) UIManager.get("Menu.invertedArrowIcon");
      if (myAquaDisabledArrowIcon == null)
        myAquaDisabledArrowIcon = (Icon) UIManager.get("Menu.disabledArrowIcon");
    }
  }
  @SuppressWarnings("HardCodedStringLiteral")
  private boolean togglePopup(KeyEvent e) {
    final KeyStroke stroke = KeyStroke.getKeyStroke(e.getKeyCode(), e.getModifiers());
    final Object action = ((InputMap) UIManager.get("ComboBox.ancestorInputMap")).get(stroke);
    if ("selectNext".equals(action)) {
      if (!isPopupShowing()) {
        return true;
      } else {
        return false;
      }
    } else if ("togglePopup".equals(action)) {
      if (isPopupShowing()) {
        closePopup();
      } else {
        suggestCompletion(true, true);
      }
      return true;
    } else {
      final Keymap active = KeymapManager.getInstance().getActiveKeymap();
      final String[] ids = active.getActionIds(stroke);
      if (ids.length > 0 && IdeActions.ACTION_CODE_COMPLETION.equals(ids[0])) {
        suggestCompletion(true, true);
      }
    }

    return false;
  }
 private InputMap getInputMap(int condition) {
   if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) {
     return (InputMap) UIManager.get("Grid.ancestorInputMap");
   } else {
     return null;
   }
 }
Ejemplo n.º 6
0
  /** Creates new form gui */
  public gui() {
    super(new BorderLayout());
    initComponents();

    // Load user list and images
    images = new ImageIcon[userStrings.length];
    Integer[] intArray = new Integer[userStrings.length];
    for (int i = 0; i < userStrings.length; i++) {
      intArray[i] = new Integer(i);
      images[i] = createImageIcon("images/" + userStrings[i] + ".png");
      if (images[i] != null) {
        images[i].setDescription(userStrings[i]);
      }
    }
    users = new JComboBox(intArray);
    Color bg = (Color) UIManager.get("ComboBox.background");
    Color fg = (Color) UIManager.get("ComboBox.foreground");
    UIManager.put("ComboBox.selectionBackground", bg);
    UIManager.put("ComboBox.selectionForeground", fg);
    users.setUI(new MetalComboBoxUI());
    // ComboBoxRenderer renderer = new ComboBoxRenderer();
    ComboBoxRenderer renderer = new ComboBoxRenderer(userStrings, images);
    renderer.setPreferredSize(new Dimension(650, 150));
    users.setRenderer(renderer);
    users.setSize(renderer.getPreferredSize());
    users.setMaximumRowCount(4);
    users.setBounds(150, 250, 650, 200);
    add(users);
    // setBorder(BorderFactory.createEmptyBorder(20,20,20,20));

    // Set the user satisfaction labels
    jSlider1.setPaintTicks(true);
    Hashtable labelTable = new Hashtable();
    for (int i = 0; i < labels.length; i++) {
      labelTable.put(new Integer(i), new JLabel(labels[i]));
    }

    jSlider1.setLabelTable(labelTable);

    jSlider1.setPaintLabels(true);

    socket = new generalSocket(machine, 1099);

    statusThread thread = new statusThread(socket, jLabel4);
    Thread theThread = new Thread(thread);
    theThread.start();
  }
Ejemplo n.º 7
0
  @Nullable
  private static Icon getAquaMenuDisabledIcon() {
    final Icon arrowIcon = (Icon) UIManager.get("Menu.arrowIcon");
    if (arrowIcon != null) {
      return IconLoader.getDisabledIcon(arrowIcon);
    }

    return null;
  }
 private ActionMap getActionMap() {
   ActionMap actionMap = (ActionMap) UIManager.get("Grid.actionMap");
   if (actionMap == null) {
     actionMap = createActionMap();
     if (actionMap != null) {
       UIManager.put("Grid.actionMap", actionMap);
     }
   }
   return actionMap;
 }
  @Override
  protected void installDefaults(AbstractButton b) {
    super.installDefaults(b);

    String pp = getPropertyPrefix();
    // b.setOpaque(QuaquaManager.getBoolean(pp+"opaque"));
    QuaquaUtilities.installProperty(b, "opaque", UIManager.get(pp + "opaque"));
    b.setRequestFocusEnabled(UIManager.getBoolean(pp + "requestFocusEnabled"));
    b.setFocusable(UIManager.getBoolean(pp + "focusable"));
  }
Ejemplo n.º 10
0
 /**
  * Implements the standard Icon interface's paintIcon method as the standard synth stub passes
  * null for the context and this will cause us to not paint any thing, so we override here so that
  * we can paint the enabled state if no synth context is available
  */
 @Override
 public void paintIcon(Component c, Graphics g, int x, int y) {
   Painter painter = (Painter) UIManager.get(prefix + "[Enabled]." + key);
   if (painter != null) {
     JComponent jc = (c instanceof JComponent) ? (JComponent) c : null;
     Graphics2D gfx = (Graphics2D) g;
     gfx.translate(x, y);
     painter.paint(gfx, jc, width, height);
     gfx.translate(-x, -y);
   }
 }
Ejemplo n.º 11
0
  public HelpFrame(String helpFileName) {
    super("Help", true, true, true, true);

    setFrameIcon(
        (Icon)
            UIManager.get(
                "Tree.openIcon")); // PENDING(steve) need more general palce to get this icon
    setBounds(200, 25, 400, 400);
    HtmlPane html = new HtmlPane(helpFileName);
    setContentPane(html);
  }
Ejemplo n.º 12
0
 static Icon getOceanDisabledButtonIcon(Image image) {
   Object[] range = (Object[]) UIManager.get("Button.disabledGrayRange");
   int min = 180;
   int max = 215;
   if (range != null) {
     min = ((Integer) range[0]).intValue();
     max = ((Integer) range[1]).intValue();
   }
   ImageProducer prod =
       new FilteredImageSource(image.getSource(), new OceanDisabledButtonImageFilter(min, max));
   return new ImageIconUIResource(Toolkit.getDefaultToolkit().createImage(prod));
 }
Ejemplo n.º 13
0
  private int getMnemonic(String key, Locale l) {
    String value = (String) UIManager.get(key, l);

    if (value == null) {
      return 0;
    }
    try {
      return Integer.parseInt(value);
    } catch (NumberFormatException nfe) {
    }
    return 0;
  }
 protected void installDefaults() {
   Color defaultGridColor = UIManager.getColor("Table.gridColor");
   Color defaultForegroundColor = UIManager.getColor("Table.foreground");
   Color defaultBackgroundColor = UIManager.getColor("Table.background");
   Border defaultBorder = UIManager.getBorder("Table.scrollPaneBorder");
   Color defaultSelectionForeground = UIManager.getColor("Table.selectionForeground");
   Color defaultSelectionBackground = UIManager.getColor("Table.selectionBackground");
   Color defaultFocusCellForeground = UIManager.getColor("Table.focusCellForeground");
   Color defaultFocusCellBackground = new Color(153, 153, 204);
   Font defaultFont = UIManager.getFont("Table.font");
   Border defaultGridBorder = UIManager.getBorder("Table.border");
   InputMap inputMap = (InputMap) UIManager.get("Table.ancestorInputMap");
   if (!installed) {
     UIManager.getDefaults().put("Grid.gridColor", defaultGridColor);
     UIManager.getDefaults().put("Grid.foreground", defaultForegroundColor);
     UIManager.getDefaults().put("Grid.background", defaultBackgroundColor);
     UIManager.getDefaults().put("Grid.selectionForegroundColor", defaultSelectionForeground);
     UIManager.getDefaults().put("Grid.selectionBackgroundColor", defaultSelectionBackground);
     UIManager.getDefaults().put("Grid.focusForegroundColor", defaultFocusCellForeground);
     UIManager.getDefaults().put("Grid.focusBackgroundColor", defaultFocusCellBackground);
     UIManager.getDefaults().put("Grid.border", defaultGridBorder);
     UIManager.getDefaults().put("Grid.font", defaultFont);
     UIManager.getDefaults().put("Grid.scrollPaneBorder", defaultBorder);
     UIManager.getDefaults().put("Grid.ancestorInputMap", inputMap);
     installed = true;
   }
   Color foregroundColor = grid.getForeground();
   Color backgroundColor = grid.getBackground();
   Font font = grid.getFont();
   Border border = grid.getBorder();
   Color gridColor = grid.getGridColor();
   Color selectionForeground = grid.getSelectionForegroundColor();
   Color selectionBackground = grid.getSelectionBackgroundColor();
   Color focusForeground = grid.getFocusForegroundColor();
   Color focusBackground = grid.getFocusBackgroundColor();
   if (foregroundColor == null || foregroundColor instanceof UIResource)
     grid.setForeground(defaultForegroundColor);
   if (backgroundColor == null || backgroundColor instanceof UIResource)
     grid.setBackground(defaultBackgroundColor);
   if (font == null || font instanceof UIResource) grid.setFont(defaultFont);
   if (gridColor == null || gridColor instanceof UIResource) grid.setGridColor(defaultGridColor);
   if (border == null || border instanceof UIResource) grid.setBorder(defaultGridBorder);
   if (selectionForeground == null || selectionForeground instanceof UIResource)
     grid.setSelectionForegroundColor(defaultSelectionForeground);
   if (selectionBackground == null || selectionBackground instanceof UIResource)
     grid.setSelectionBackgroundColor(defaultSelectionBackground);
   if (focusForeground == null || focusForeground instanceof UIResource)
     grid.setFocusForegroundColor(defaultFocusCellForeground);
   if (focusBackground == null || focusBackground instanceof UIResource)
     grid.setFocusBackgroundColor(defaultFocusCellBackground);
 }
Ejemplo n.º 15
0
  /**
   * Draws a radial type gradient. The gradient will be drawn vertically if <code>vertical</code> is
   * true, otherwise horizontally. The UIManager key consists of five values: r1 r2 c1 c2 c3. The
   * gradient is broken down into four chunks drawn in order from the origin.
   *
   * <ol>
   *   <li>Gradient r1 % of the size from c1 to c2
   *   <li>Rectangle r2 % of the size in c2.
   *   <li>Gradient r1 % of the size from c2 to c1
   *   <li>The remaining size will be filled with a gradient from c1 to c3.
   * </ol>
   *
   * @param c Component rendering to
   * @param g Graphics to draw to.
   * @param key UIManager key used to look up gradient values.
   * @param x X coordinate to draw from
   * @param y Y coordinate to draw from
   * @param w Width to draw to
   * @param h Height to draw to
   * @param vertical Direction of the gradient
   * @return true if <code>key</code> exists, otherwise false.
   */
  static boolean drawGradient(
      Component c, Graphics g, String key, int x, int y, int w, int h, boolean vertical) {
    java.util.List gradient = (java.util.List) UIManager.get(key);
    if (gradient == null || !(g instanceof Graphics2D)) {
      return false;
    }

    if (w <= 0 || h <= 0) {
      return true;
    }

    GradientPainter.INSTANCE.paint(c, (Graphics2D) g, gradient, x, y, w, h, vertical);
    return true;
  }
Ejemplo n.º 16
0
  static int getInt(Object key, int defaultValue) {
    Object value = UIManager.get(key);

    if (value instanceof Integer) {
      return ((Integer) value).intValue();
    }
    if (value instanceof String) {
      try {
        return Integer.parseInt((String) value);
      } catch (NumberFormatException nfe) {
      }
    }
    return defaultValue;
  }
Ejemplo n.º 17
0
 /**
  * Returns the baseline for the specified component, or a value less than 0 if the baseline can
  * not be determined. The baseline is measured from the top of the component.
  *
  * @param component JComponent to calculate baseline for
  * @param width Width of the component to determine baseline for.
  * @param height Height of the component to determine baseline for.
  * @return baseline for the specified component
  */
 public static int getBaseline(JComponent component, int width, int height) {
   Method baselineMethod = getBaselineMethod(component);
   if (baselineMethod != null) {
     return invokeBaseline(baselineMethod, component, width, height);
   }
   Object baselineImpl = UIManager.get("Baseline.instance");
   if (baselineImpl != null && (baselineImpl instanceof Baseline)) {
     return ((Baseline) baselineImpl).getComponentBaseline(component, width, height);
   }
   if (!isKnownLookAndFeel()) {
     return -1;
   }
   String uid = component.getUIClassID();
   int baseline = -1;
   if (uid == "ButtonUI"
       || uid == "CheckBoxUI"
       || uid == "RadioButtonUI"
       || uid == "ToggleButtonUI") {
     baseline = getButtonBaseline((AbstractButton) component, height);
   } else if (uid == "ComboBoxUI") {
     return getComboBoxBaseline((JComboBox) component, height);
   } else if (uid == "TextAreaUI") {
     return getTextAreaBaseline((JTextArea) component, height);
   } else if (uid == "FormattedTextFieldUI" || uid == "PasswordFieldUI" || uid == "TextFieldUI") {
     baseline = getSingleLineTextBaseline((JTextComponent) component, height);
   } else if (uid == "LabelUI") {
     baseline = getLabelBaseline((JLabel) component, height);
   } else if (uid == "ListUI") {
     baseline = getListBaseline((JList) component, height);
   } else if (uid == "PanelUI") {
     baseline = getPanelBaseline((JPanel) component, height);
   } else if (uid == "ProgressBarUI") {
     baseline = getProgressBarBaseline((JProgressBar) component, height);
   } else if (uid == "SliderUI") {
     baseline = getSliderBaseline((JSlider) component, height);
   } else if (uid == "SpinnerUI") {
     baseline = getSpinnerBaseline((JSpinner) component, height);
   } else if (uid == "ScrollPaneUI") {
     baseline = getScrollPaneBaseline((JScrollPane) component, height);
   } else if (uid == "TabbedPaneUI") {
     baseline = getTabbedPaneBaseline((JTabbedPane) component, height);
   } else if (uid == "TableUI") {
     baseline = getTableBaseline((JTable) component, height);
   } else if (uid == "TreeUI") {
     baseline = getTreeBaseline((JTree) component, height);
   }
   return Math.max(baseline, -1);
 }
Ejemplo n.º 18
0
  @Nullable
  private static Icon getAquaMenuInvertedIcon() {
    if (!UIUtil.isUnderAquaLookAndFeel()) return null;
    final Icon arrow = (Icon) UIManager.get("Menu.arrowIcon");
    if (arrow == null) return null;

    try {
      final Method method = ReflectionUtil.getMethod(arrow.getClass(), "getInvertedIcon");
      if (method != null) {
        return (Icon) method.invoke(arrow);
      }
      return null;
    } catch (InvocationTargetException e1) {
      return null;
    } catch (IllegalAccessException e1) {
      return null;
    }
  }
Ejemplo n.º 19
0
  @Override
  public Object[] createLookAndFeelCustomizationKeysAndValues() {
    int fontsize = 11;
    Integer in = (Integer) UIManager.get(CUSTOM_FONT_SIZE); // NOI18N
    if (in != null) {
      fontsize = in.intValue();
    }

    Object[] result =
        new Object[] {
          // Work around a bug in windows which sets the text area font to
          // "MonoSpaced", causing all accessible dialogs to have monospaced text
          "TextArea.font",
          new GuaranteedValue("Label.font", new Font("Dialog", Font.PLAIN, fontsize)),
          EDITOR_ERRORSTRIPE_SCROLLBAR_INSETS,
          new Insets(17, 0, 17, 0),
        };

    return result;
  }
Ejemplo n.º 20
0
 private void configureEnclosingScrollPaneUI() {
   final Container p = getParent();
   if (p instanceof JViewport) {
     final Container gp = p.getParent();
     if (gp instanceof JScrollPane) {
       final JScrollPane scrollPane = (JScrollPane) gp;
       // Make certain we are the viewPort's view and not, for
       // example, the rowHeaderView of the scrollPane -
       // an implementor of fixed columns might do this.
       final JViewport viewport = scrollPane.getViewport();
       if (viewport == null || viewport.getView() != this) {
         return;
       }
       //  scrollPane.getViewport().setBackingStoreEnabled(true);
       //                Border border = scrollPane.getBorder ();
       //                if ( border == null || border instanceof UIResource )
       //                {
       //                    Border scrollPaneBorder = UIManager.getBorder (
       // "Table.scrollPaneBorder" );
       //                    if ( scrollPaneBorder != null )
       //                    {
       //                        scrollPane.setBorder ( scrollPaneBorder );
       //                    }
       //                }
       // add JScrollBar corner component if available from LAF and not already set by the user
       Component corner = scrollPane.getCorner(JScrollPane.UPPER_TRAILING_CORNER);
       if (corner == null || corner instanceof UIResource) {
         corner = null;
         final Object componentClass = UIManager.get("Table.scrollPaneCornerComponent");
         if (componentClass instanceof Class) {
           try {
             corner = (Component) ((Class) componentClass).newInstance();
           } catch (final Exception e) {
             // just ignore and don't set corner
           }
         }
         scrollPane.setCorner(JScrollPane.UPPER_TRAILING_CORNER, corner);
       }
     }
   }
 }
Ejemplo n.º 21
0
 public static void main(String[] argv) {
   try {
     String os = System.getProperty("os.name");
     if (os.startsWith("Windows")) {
       String laf = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
       UIManager.setLookAndFeel(laf);
     } else {
       UIManager.put("swing.boldMetal", Boolean.FALSE);
       javax.swing.plaf.FontUIResource f =
           new javax.swing.plaf.FontUIResource("SansSerif", Font.PLAIN, 11);
       java.util.Enumeration keys = UIManager.getDefaults().keys();
       while (keys.hasMoreElements()) {
         Object key = keys.nextElement();
         Object value = UIManager.get(key);
         if (value instanceof javax.swing.plaf.FontUIResource) UIManager.put(key, f);
       }
     }
     UIManager.put("TitledBorder.titleColor", Color.blue);
   } catch (java.lang.Exception exc) {
   }
   VncViewer viewer = new VncViewer(argv);
   viewer.start();
 }
Ejemplo n.º 22
0
 public void updateUI() {
   if (UIManager.get(getUIClassID()) != null) setUI((ZPopupGalleryUI) UIManager.getUI(this));
   else setUI(new FSXPPopupGalleryUI());
 }
Ejemplo n.º 23
0
  @Override
  public Object[] createApplicationSpecificKeysAndValues() {
    UIBootstrapValue editorTabsUI =
        new XPEditorColorings("org.netbeans.swing.tabcontrol.plaf.WinXPEditorTabDisplayerUI");

    Object viewTabsUI =
        editorTabsUI.createShared("org.netbeans.swing.tabcontrol.plaf.WinXPViewTabDisplayerUI");

    Image explorerIcon =
        UIUtils.loadImage("org/netbeans/swing/plaf/resources/xp-explorer-folder.gif");

    Object propertySheetValues = new XPPropertySheetColorings();

    Object[] uiDefaults = {
      EDITOR_TAB_DISPLAYER_UI,
      editorTabsUI,
      VIEW_TAB_DISPLAYER_UI,
      viewTabsUI,
      DESKTOP_BACKGROUND,
      new Color(226, 223, 214), // NOI18N
      SCROLLPANE_BORDER_COLOR,
      new Color(127, 157, 185),
      DESKTOP_BORDER,
      new EmptyBorder(6, 5, 4, 6),
      SCROLLPANE_BORDER,
      UIManager.get("ScrollPane.border"),
      EXPLORER_STATUS_BORDER,
      new StatusLineBorder(StatusLineBorder.TOP),
      EXPLORER_FOLDER_ICON,
      explorerIcon,
      EXPLORER_FOLDER_OPENED_ICON,
      explorerIcon,
      EDITOR_STATUS_LEFT_BORDER,
      new StatusLineBorder(StatusLineBorder.TOP | StatusLineBorder.RIGHT),
      EDITOR_STATUS_RIGHT_BORDER,
      new StatusLineBorder(StatusLineBorder.TOP | StatusLineBorder.LEFT),
      EDITOR_STATUS_INNER_BORDER,
      new StatusLineBorder(StatusLineBorder.TOP | StatusLineBorder.LEFT | StatusLineBorder.RIGHT),
      EDITOR_STATUS_ONLYONEBORDER,
      new StatusLineBorder(StatusLineBorder.TOP),
      EDITOR_TOOLBAR_BORDER,
      new EditorToolbarBorder(),
      OUTPUT_SELECTION_BACKGROUND,
      new Color(164, 180, 255),
      PROPERTYSHEET_BOOTSTRAP,
      propertySheetValues,
      WORKPLACE_FILL,
      new Color(226, 223, 214),
      DESKTOP_SPLITPANE_BORDER,
      BorderFactory.createEmptyBorder(4, 0, 0, 0),
      SLIDING_BUTTON_UI,
      "org.netbeans.swing.tabcontrol.plaf.WinXPSlidingButtonUI",

      // progress component related
      "nbProgressBar.Foreground",
      new Color(49, 106, 197),
      "nbProgressBar.Background",
      Color.WHITE,
      "nbProgressBar.popupDynaText.foreground",
      new Color(141, 136, 122),
      "nbProgressBar.popupText.background",
      new Color(249, 249, 249),
      "nbProgressBar.popupText.foreground",
      UIManager.getColor("TextField.foreground"),
      "nbProgressBar.popupText.selectBackground",
      UIManager.getColor("List.selectionBackground"),
      "nbProgressBar.popupText.selectForeground",
      UIManager.getColor("List.selectionForeground"),
      PROGRESS_CANCEL_BUTTON_ICON,
      UIUtils.loadImage("org/netbeans/swing/plaf/resources/cancel_task_win_xp.png"),
      // slide bar
      "NbSlideBar.GroupSeparator.Gap.Before",
      8,
      "NbSlideBar.GroupSeparator.Gap.After",
      2,
      "NbSlideBar.RestoreButton.Gap",
      1,
    }; // NOI18N

    // Workaround for JDK 1.5.0 bug 5080144 - Disabled JTextFields stay white
    // XPTheme uses Color instead of ColorUIResource
    convert("TextField.background"); // NOI18N
    convert("TextField.inactiveBackground"); // NOI18N
    convert("TextField.disabledBackground"); // NOI18N

    // #108517 - turn off ctrl+page_up and ctrl+page_down mapping
    return UIUtils.addInputMapsWithoutCtrlPageUpAndCtrlPageDown(uiDefaults);
  }
Ejemplo n.º 24
0
  @Override
  public Object get(SynthContext context, Object key) {
    // See if this is a class specific value.
    String classKey = CLASS_SPECIFIC_MAP.get(key);
    if (classKey != null) {
      Object value = getClassSpecificValue(classKey);
      if (value != null) {
        return value;
      }
    }

    // Is it a specific value ?
    if (key == "ScrollPane.viewportBorderInsets") {
      return getThicknessInsets(context, new Insets(0, 0, 0, 0));
    } else if (key == "Slider.tickColor") {
      return getColorForState(context, ColorType.FOREGROUND);
    } else if (key == "ScrollBar.minimumThumbSize") {
      int len = getClassSpecificIntValue(context, "min-slider-length", 21);
      JScrollBar sb = (JScrollBar) context.getComponent();
      if (sb.getOrientation() == JScrollBar.HORIZONTAL) {
        return new DimensionUIResource(len, 0);
      } else {
        return new DimensionUIResource(0, len);
      }
    } else if (key == "Separator.thickness") {
      JSeparator sep = (JSeparator) context.getComponent();
      if (sep.getOrientation() == JSeparator.HORIZONTAL) {
        return getYThickness();
      } else {
        return getXThickness();
      }
    } else if (key == "ToolBar.separatorSize") {
      int size = getClassSpecificIntValue(WidgetType.TOOL_BAR, "space-size", 12);
      return new DimensionUIResource(size, size);
    } else if (key == "ScrollBar.buttonSize") {
      JScrollBar sb = (JScrollBar) context.getComponent().getParent();
      boolean horiz = (sb.getOrientation() == JScrollBar.HORIZONTAL);
      WidgetType wt = horiz ? WidgetType.HSCROLL_BAR : WidgetType.VSCROLL_BAR;
      int sliderWidth = getClassSpecificIntValue(wt, "slider-width", 14);
      int stepperSize = getClassSpecificIntValue(wt, "stepper-size", 14);
      return horiz
          ? new DimensionUIResource(stepperSize, sliderWidth)
          : new DimensionUIResource(sliderWidth, stepperSize);
    } else if (key == "ArrowButton.size") {
      String name = context.getComponent().getName();
      if (name != null && name.startsWith("Spinner")) {
        // Believe it or not, the size of a spinner arrow button is
        // dependent upon the size of the spinner's font.  These
        // calculations come from gtkspinbutton.c (version 2.8.20),
        // spin_button_get_arrow_size() method.
        String pangoFontName;
        synchronized (sun.awt.UNIXToolkit.GTK_LOCK) {
          pangoFontName = nativeGetPangoFontName(WidgetType.SPINNER.ordinal());
        }
        int arrowSize = (pangoFontName != null) ? PangoFonts.getFontSize(pangoFontName) : 10;
        return (arrowSize + (getXThickness() * 2));
      }
      // For all other kinds of arrow buttons (e.g. combobox arrow
      // buttons), we will simply fall back on the value of
      // ArrowButton.size as defined in the UIDefaults for
      // GTKLookAndFeel when we call UIManager.get() below...
    } else if ("CheckBox.iconTextGap".equals(key) || "RadioButton.iconTextGap".equals(key)) {
      // The iconTextGap value needs to include "indicator-spacing"
      // and it also needs to leave enough space for the focus line,
      // which falls between the indicator icon and the text.
      // See getRadioInsets() and 6489585 for more details.
      int indicatorSpacing = getClassSpecificIntValue(context, "indicator-spacing", 2);
      int focusSize = getClassSpecificIntValue(context, "focus-line-width", 1);
      int focusPad = getClassSpecificIntValue(context, "focus-padding", 1);
      return indicatorSpacing + focusSize + focusPad;
    }

    // Is it a stock icon ?
    GTKStockIcon stockIcon = null;
    synchronized (ICONS_MAP) {
      stockIcon = ICONS_MAP.get(key);
    }

    if (stockIcon != null) {
      return stockIcon;
    }

    // Is it another kind of value ?
    if (key != "engine") {
      // For backward compatibility we'll fallback to the UIManager.
      // We don't go to the UIManager for engine as the engine is GTK
      // specific.
      Object value = UIManager.get(key);
      if (key == "Table.rowHeight") {
        int focusLineWidth = getClassSpecificIntValue(context, "focus-line-width", 0);
        if (value == null && focusLineWidth > 0) {
          value = Integer.valueOf(16 + 2 * focusLineWidth);
        }
      }
      return value;
    }

    // Don't call super, we don't want to pick up defaults from
    // SynthStyle.
    return null;
  }
/**
 * Class that manages a JLF title bar
 *
 * @author Steve Wilson
 * @author Brian Beck
 * @since 1.3
 */
public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane {

  protected boolean isPalette = false;
  protected Icon paletteCloseIcon;
  protected int paletteTitleHeight;

  private static final Border handyEmptyBorder = new EmptyBorder(0, 0, 0, 0);

  /**
   * Key used to lookup Color from UIManager. If this is null, <code>getWindowTitleBackground</code>
   * is used.
   */
  private String selectedBackgroundKey;
  /**
   * Key used to lookup Color from UIManager. If this is null, <code>getWindowTitleForeground</code>
   * is used.
   */
  private String selectedForegroundKey;
  /**
   * Key used to lookup shadow color from UIManager. If this is null, <code>
   * getPrimaryControlDarkShadow</code> is used.
   */
  private String selectedShadowKey;
  /**
   * Boolean indicating the state of the <code>JInternalFrame</code>s closable property at <code>
   * updateUI</code> time.
   */
  private boolean wasClosable;

  int buttonsWidth = 0;

  MetalBumps activeBumps =
      new MetalBumps(
          0,
          0,
          MetalLookAndFeel.getPrimaryControlHighlight(),
          MetalLookAndFeel.getPrimaryControlDarkShadow(),
          (UIManager.get("InternalFrame.activeTitleGradient") != null)
              ? null
              : MetalLookAndFeel.getPrimaryControl());
  MetalBumps inactiveBumps =
      new MetalBumps(
          0,
          0,
          MetalLookAndFeel.getControlHighlight(),
          MetalLookAndFeel.getControlDarkShadow(),
          (UIManager.get("InternalFrame.inactiveTitleGradient") != null)
              ? null
              : MetalLookAndFeel.getControl());
  MetalBumps paletteBumps;

  private Color activeBumpsHighlight = MetalLookAndFeel.getPrimaryControlHighlight();
  private Color activeBumpsShadow = MetalLookAndFeel.getPrimaryControlDarkShadow();

  public MetalInternalFrameTitlePane(JInternalFrame f) {
    super(f);
  }

  public void addNotify() {
    super.addNotify();
    // This is done here instead of in installDefaults as I was worried
    // that the BasicInternalFrameUI might not be fully initialized, and
    // that if this resets the closable state the BasicInternalFrameUI
    // Listeners that get notified might be in an odd/uninitialized state.
    updateOptionPaneState();
  }

  protected void installDefaults() {
    super.installDefaults();
    setFont(UIManager.getFont("InternalFrame.titleFont"));
    paletteTitleHeight = UIManager.getInt("InternalFrame.paletteTitleHeight");
    paletteCloseIcon = UIManager.getIcon("InternalFrame.paletteCloseIcon");
    wasClosable = frame.isClosable();
    selectedForegroundKey = selectedBackgroundKey = null;
    if (MetalLookAndFeel.usingOcean()) {
      setOpaque(true);
    }
  }

  protected void uninstallDefaults() {
    super.uninstallDefaults();
    if (wasClosable != frame.isClosable()) {
      frame.setClosable(wasClosable);
    }
  }

  protected void createButtons() {
    super.createButtons();

    Boolean paintActive = frame.isSelected() ? Boolean.TRUE : Boolean.FALSE;
    iconButton.putClientProperty("paintActive", paintActive);
    iconButton.setBorder(handyEmptyBorder);

    maxButton.putClientProperty("paintActive", paintActive);
    maxButton.setBorder(handyEmptyBorder);

    closeButton.putClientProperty("paintActive", paintActive);
    closeButton.setBorder(handyEmptyBorder);

    // The palette close icon isn't opaque while the regular close icon is.
    // This makes sure palette close buttons have the right background.
    closeButton.setBackground(MetalLookAndFeel.getPrimaryControlShadow());

    if (MetalLookAndFeel.usingOcean()) {
      iconButton.setContentAreaFilled(false);
      maxButton.setContentAreaFilled(false);
      closeButton.setContentAreaFilled(false);
    }
  }

  /** Override the parent's method to do nothing. Metal frames do not have system menus. */
  protected void assembleSystemMenu() {}

  /** Override the parent's method to do nothing. Metal frames do not have system menus. */
  protected void addSystemMenuItems(JMenu systemMenu) {}

  /** Override the parent's method to do nothing. Metal frames do not have system menus. */
  protected void showSystemMenu() {}

  /**
   * Override the parent's method avoid creating a menu bar. Metal frames do not have system menus.
   */
  protected void addSubComponents() {
    add(iconButton);
    add(maxButton);
    add(closeButton);
  }

  protected PropertyChangeListener createPropertyChangeListener() {
    return new MetalPropertyChangeHandler();
  }

  protected LayoutManager createLayout() {
    return new MetalTitlePaneLayout();
  }

  class MetalPropertyChangeHandler extends BasicInternalFrameTitlePane.PropertyChangeHandler {
    public void propertyChange(PropertyChangeEvent evt) {
      String prop = (String) evt.getPropertyName();
      if (prop.equals(JInternalFrame.IS_SELECTED_PROPERTY)) {
        Boolean b = (Boolean) evt.getNewValue();
        iconButton.putClientProperty("paintActive", b);
        closeButton.putClientProperty("paintActive", b);
        maxButton.putClientProperty("paintActive", b);
      } else if ("JInternalFrame.messageType".equals(prop)) {
        updateOptionPaneState();
        frame.repaint();
      }
      super.propertyChange(evt);
    }
  }

  class MetalTitlePaneLayout extends TitlePaneLayout {
    public void addLayoutComponent(String name, Component c) {}

    public void removeLayoutComponent(Component c) {}

    public Dimension preferredLayoutSize(Container c) {
      return minimumLayoutSize(c);
    }

    public Dimension minimumLayoutSize(Container c) {
      // Compute width.
      int width = 30;
      if (frame.isClosable()) {
        width += 21;
      }
      if (frame.isMaximizable()) {
        width += 16 + (frame.isClosable() ? 10 : 4);
      }
      if (frame.isIconifiable()) {
        width += 16 + (frame.isMaximizable() ? 2 : (frame.isClosable() ? 10 : 4));
      }
      FontMetrics fm = frame.getFontMetrics(getFont());
      String frameTitle = frame.getTitle();
      int title_w = frameTitle != null ? SwingUtilities2.stringWidth(frame, fm, frameTitle) : 0;
      int title_length = frameTitle != null ? frameTitle.length() : 0;

      if (title_length > 2) {
        int subtitle_w =
            SwingUtilities2.stringWidth(frame, fm, frame.getTitle().substring(0, 2) + "...");
        width += (title_w < subtitle_w) ? title_w : subtitle_w;
      } else {
        width += title_w;
      }

      // Compute height.
      int height = 0;
      if (isPalette) {
        height = paletteTitleHeight;
      } else {
        int fontHeight = fm.getHeight();
        fontHeight += 7;
        Icon icon = frame.getFrameIcon();
        int iconHeight = 0;
        if (icon != null) {
          // SystemMenuBar forces the icon to be 16x16 or less.
          iconHeight = Math.min(icon.getIconHeight(), 16);
        }
        iconHeight += 5;
        height = Math.max(fontHeight, iconHeight);
      }

      return new Dimension(width, height);
    }

    public void layoutContainer(Container c) {
      boolean leftToRight = MetalUtils.isLeftToRight(frame);

      int w = getWidth();
      int x = leftToRight ? w : 0;
      int y = 2;
      int spacing;

      // assumes all buttons have the same dimensions
      // these dimensions include the borders
      int buttonHeight = closeButton.getIcon().getIconHeight();
      int buttonWidth = closeButton.getIcon().getIconWidth();

      if (frame.isClosable()) {
        if (isPalette) {
          spacing = 3;
          x += leftToRight ? -spacing - (buttonWidth + 2) : spacing;
          closeButton.setBounds(x, y, buttonWidth + 2, getHeight() - 4);
          if (!leftToRight) x += (buttonWidth + 2);
        } else {
          spacing = 4;
          x += leftToRight ? -spacing - buttonWidth : spacing;
          closeButton.setBounds(x, y, buttonWidth, buttonHeight);
          if (!leftToRight) x += buttonWidth;
        }
      }

      if (frame.isMaximizable() && !isPalette) {
        spacing = frame.isClosable() ? 10 : 4;
        x += leftToRight ? -spacing - buttonWidth : spacing;
        maxButton.setBounds(x, y, buttonWidth, buttonHeight);
        if (!leftToRight) x += buttonWidth;
      }

      if (frame.isIconifiable() && !isPalette) {
        spacing = frame.isMaximizable() ? 2 : (frame.isClosable() ? 10 : 4);
        x += leftToRight ? -spacing - buttonWidth : spacing;
        iconButton.setBounds(x, y, buttonWidth, buttonHeight);
        if (!leftToRight) x += buttonWidth;
      }

      buttonsWidth = leftToRight ? w - x : x;
    }
  }

  public void paintPalette(Graphics g) {
    boolean leftToRight = MetalUtils.isLeftToRight(frame);

    int width = getWidth();
    int height = getHeight();

    if (paletteBumps == null) {
      paletteBumps =
          new MetalBumps(
              0,
              0,
              MetalLookAndFeel.getPrimaryControlHighlight(),
              MetalLookAndFeel.getPrimaryControlInfo(),
              MetalLookAndFeel.getPrimaryControlShadow());
    }

    Color background = MetalLookAndFeel.getPrimaryControlShadow();
    Color darkShadow = MetalLookAndFeel.getPrimaryControlDarkShadow();

    g.setColor(background);
    g.fillRect(0, 0, width, height);

    g.setColor(darkShadow);
    g.drawLine(0, height - 1, width, height - 1);

    int xOffset = leftToRight ? 4 : buttonsWidth + 4;
    int bumpLength = width - buttonsWidth - 2 * 4;
    int bumpHeight = getHeight() - 4;
    paletteBumps.setBumpArea(bumpLength, bumpHeight);
    paletteBumps.paintIcon(this, g, xOffset, 2);
  }

  public void paintComponent(Graphics g) {
    if (isPalette) {
      paintPalette(g);
      return;
    }

    boolean leftToRight = MetalUtils.isLeftToRight(frame);
    boolean isSelected = frame.isSelected();

    int width = getWidth();
    int height = getHeight();

    Color background = null;
    Color foreground = null;
    Color shadow = null;

    MetalBumps bumps;
    String gradientKey;

    if (isSelected) {
      if (!MetalLookAndFeel.usingOcean()) {
        closeButton.setContentAreaFilled(true);
        maxButton.setContentAreaFilled(true);
        iconButton.setContentAreaFilled(true);
      }
      if (selectedBackgroundKey != null) {
        background = UIManager.getColor(selectedBackgroundKey);
      }
      if (background == null) {
        background = MetalLookAndFeel.getWindowTitleBackground();
      }
      if (selectedForegroundKey != null) {
        foreground = UIManager.getColor(selectedForegroundKey);
      }
      if (selectedShadowKey != null) {
        shadow = UIManager.getColor(selectedShadowKey);
      }
      if (shadow == null) {
        shadow = MetalLookAndFeel.getPrimaryControlDarkShadow();
      }
      if (foreground == null) {
        foreground = MetalLookAndFeel.getWindowTitleForeground();
      }
      activeBumps.setBumpColors(
          activeBumpsHighlight,
          activeBumpsShadow,
          UIManager.get("InternalFrame.activeTitleGradient") != null ? null : background);
      bumps = activeBumps;
      gradientKey = "InternalFrame.activeTitleGradient";
    } else {
      if (!MetalLookAndFeel.usingOcean()) {
        closeButton.setContentAreaFilled(false);
        maxButton.setContentAreaFilled(false);
        iconButton.setContentAreaFilled(false);
      }
      background = MetalLookAndFeel.getWindowTitleInactiveBackground();
      foreground = MetalLookAndFeel.getWindowTitleInactiveForeground();
      shadow = MetalLookAndFeel.getControlDarkShadow();
      bumps = inactiveBumps;
      gradientKey = "InternalFrame.inactiveTitleGradient";
    }

    if (!MetalUtils.drawGradient(this, g, gradientKey, 0, 0, width, height, true)) {
      g.setColor(background);
      g.fillRect(0, 0, width, height);
    }

    g.setColor(shadow);
    g.drawLine(0, height - 1, width, height - 1);
    g.drawLine(0, 0, 0, 0);
    g.drawLine(width - 1, 0, width - 1, 0);

    int titleLength = 0;
    int xOffset = leftToRight ? 5 : width - 5;
    String frameTitle = frame.getTitle();

    Icon icon = frame.getFrameIcon();
    if (icon != null) {
      if (!leftToRight) xOffset -= icon.getIconWidth();
      int iconY = ((height / 2) - (icon.getIconHeight() / 2));
      icon.paintIcon(frame, g, xOffset, iconY);
      xOffset += leftToRight ? icon.getIconWidth() + 5 : -5;
    }

    if (frameTitle != null) {
      Font f = getFont();
      g.setFont(f);
      FontMetrics fm = SwingUtilities2.getFontMetrics(frame, g, f);
      int fHeight = fm.getHeight();

      g.setColor(foreground);

      int yOffset = ((height - fm.getHeight()) / 2) + fm.getAscent();

      Rectangle rect = new Rectangle(0, 0, 0, 0);
      if (frame.isIconifiable()) {
        rect = iconButton.getBounds();
      } else if (frame.isMaximizable()) {
        rect = maxButton.getBounds();
      } else if (frame.isClosable()) {
        rect = closeButton.getBounds();
      }
      int titleW;

      if (leftToRight) {
        if (rect.x == 0) {
          rect.x = frame.getWidth() - frame.getInsets().right - 2;
        }
        titleW = rect.x - xOffset - 4;
        frameTitle = getTitle(frameTitle, fm, titleW);
      } else {
        titleW = xOffset - rect.x - rect.width - 4;
        frameTitle = getTitle(frameTitle, fm, titleW);
        xOffset -= SwingUtilities2.stringWidth(frame, fm, frameTitle);
      }

      titleLength = SwingUtilities2.stringWidth(frame, fm, frameTitle);
      SwingUtilities2.drawString(frame, g, frameTitle, xOffset, yOffset);
      xOffset += leftToRight ? titleLength + 5 : -5;
    }

    int bumpXOffset;
    int bumpLength;
    if (leftToRight) {
      bumpLength = width - buttonsWidth - xOffset - 5;
      bumpXOffset = xOffset;
    } else {
      bumpLength = xOffset - buttonsWidth - 5;
      bumpXOffset = buttonsWidth + 5;
    }
    int bumpYOffset = 3;
    int bumpHeight = getHeight() - (2 * bumpYOffset);
    bumps.setBumpArea(bumpLength, bumpHeight);
    bumps.paintIcon(this, g, bumpXOffset, bumpYOffset);
  }

  public void setPalette(boolean b) {
    isPalette = b;

    if (isPalette) {
      closeButton.setIcon(paletteCloseIcon);
      if (frame.isMaximizable()) remove(maxButton);
      if (frame.isIconifiable()) remove(iconButton);
    } else {
      closeButton.setIcon(closeIcon);
      if (frame.isMaximizable()) add(maxButton);
      if (frame.isIconifiable()) add(iconButton);
    }
    revalidate();
    repaint();
  }

  /**
   * Updates any state dependant upon the JInternalFrame being shown in a <code>JOptionPane</code>.
   */
  private void updateOptionPaneState() {
    int type = -2;
    boolean closable = wasClosable;
    Object obj = frame.getClientProperty("JInternalFrame.messageType");

    if (obj == null) {
      // Don't change the closable state unless in an JOptionPane.
      return;
    }
    if (obj instanceof Integer) {
      type = ((Integer) obj).intValue();
    }
    switch (type) {
      case JOptionPane.ERROR_MESSAGE:
        selectedBackgroundKey = "OptionPane.errorDialog.titlePane.background";
        selectedForegroundKey = "OptionPane.errorDialog.titlePane.foreground";
        selectedShadowKey = "OptionPane.errorDialog.titlePane.shadow";
        closable = false;
        break;
      case JOptionPane.QUESTION_MESSAGE:
        selectedBackgroundKey = "OptionPane.questionDialog.titlePane.background";
        selectedForegroundKey = "OptionPane.questionDialog.titlePane.foreground";
        selectedShadowKey = "OptionPane.questionDialog.titlePane.shadow";
        closable = false;
        break;
      case JOptionPane.WARNING_MESSAGE:
        selectedBackgroundKey = "OptionPane.warningDialog.titlePane.background";
        selectedForegroundKey = "OptionPane.warningDialog.titlePane.foreground";
        selectedShadowKey = "OptionPane.warningDialog.titlePane.shadow";
        closable = false;
        break;
      case JOptionPane.INFORMATION_MESSAGE:
      case JOptionPane.PLAIN_MESSAGE:
        selectedBackgroundKey = selectedForegroundKey = selectedShadowKey = null;
        closable = false;
        break;
      default:
        selectedBackgroundKey = selectedForegroundKey = selectedShadowKey = null;
        break;
    }
    if (closable != frame.isClosable()) {
      frame.setClosable(closable);
    }
  }
}
  public void paintComponent(Graphics g) {
    if (isPalette) {
      paintPalette(g);
      return;
    }

    boolean leftToRight = MetalUtils.isLeftToRight(frame);
    boolean isSelected = frame.isSelected();

    int width = getWidth();
    int height = getHeight();

    Color background = null;
    Color foreground = null;
    Color shadow = null;

    MetalBumps bumps;
    String gradientKey;

    if (isSelected) {
      if (!MetalLookAndFeel.usingOcean()) {
        closeButton.setContentAreaFilled(true);
        maxButton.setContentAreaFilled(true);
        iconButton.setContentAreaFilled(true);
      }
      if (selectedBackgroundKey != null) {
        background = UIManager.getColor(selectedBackgroundKey);
      }
      if (background == null) {
        background = MetalLookAndFeel.getWindowTitleBackground();
      }
      if (selectedForegroundKey != null) {
        foreground = UIManager.getColor(selectedForegroundKey);
      }
      if (selectedShadowKey != null) {
        shadow = UIManager.getColor(selectedShadowKey);
      }
      if (shadow == null) {
        shadow = MetalLookAndFeel.getPrimaryControlDarkShadow();
      }
      if (foreground == null) {
        foreground = MetalLookAndFeel.getWindowTitleForeground();
      }
      activeBumps.setBumpColors(
          activeBumpsHighlight,
          activeBumpsShadow,
          UIManager.get("InternalFrame.activeTitleGradient") != null ? null : background);
      bumps = activeBumps;
      gradientKey = "InternalFrame.activeTitleGradient";
    } else {
      if (!MetalLookAndFeel.usingOcean()) {
        closeButton.setContentAreaFilled(false);
        maxButton.setContentAreaFilled(false);
        iconButton.setContentAreaFilled(false);
      }
      background = MetalLookAndFeel.getWindowTitleInactiveBackground();
      foreground = MetalLookAndFeel.getWindowTitleInactiveForeground();
      shadow = MetalLookAndFeel.getControlDarkShadow();
      bumps = inactiveBumps;
      gradientKey = "InternalFrame.inactiveTitleGradient";
    }

    if (!MetalUtils.drawGradient(this, g, gradientKey, 0, 0, width, height, true)) {
      g.setColor(background);
      g.fillRect(0, 0, width, height);
    }

    g.setColor(shadow);
    g.drawLine(0, height - 1, width, height - 1);
    g.drawLine(0, 0, 0, 0);
    g.drawLine(width - 1, 0, width - 1, 0);

    int titleLength = 0;
    int xOffset = leftToRight ? 5 : width - 5;
    String frameTitle = frame.getTitle();

    Icon icon = frame.getFrameIcon();
    if (icon != null) {
      if (!leftToRight) xOffset -= icon.getIconWidth();
      int iconY = ((height / 2) - (icon.getIconHeight() / 2));
      icon.paintIcon(frame, g, xOffset, iconY);
      xOffset += leftToRight ? icon.getIconWidth() + 5 : -5;
    }

    if (frameTitle != null) {
      Font f = getFont();
      g.setFont(f);
      FontMetrics fm = SwingUtilities2.getFontMetrics(frame, g, f);
      int fHeight = fm.getHeight();

      g.setColor(foreground);

      int yOffset = ((height - fm.getHeight()) / 2) + fm.getAscent();

      Rectangle rect = new Rectangle(0, 0, 0, 0);
      if (frame.isIconifiable()) {
        rect = iconButton.getBounds();
      } else if (frame.isMaximizable()) {
        rect = maxButton.getBounds();
      } else if (frame.isClosable()) {
        rect = closeButton.getBounds();
      }
      int titleW;

      if (leftToRight) {
        if (rect.x == 0) {
          rect.x = frame.getWidth() - frame.getInsets().right - 2;
        }
        titleW = rect.x - xOffset - 4;
        frameTitle = getTitle(frameTitle, fm, titleW);
      } else {
        titleW = xOffset - rect.x - rect.width - 4;
        frameTitle = getTitle(frameTitle, fm, titleW);
        xOffset -= SwingUtilities2.stringWidth(frame, fm, frameTitle);
      }

      titleLength = SwingUtilities2.stringWidth(frame, fm, frameTitle);
      SwingUtilities2.drawString(frame, g, frameTitle, xOffset, yOffset);
      xOffset += leftToRight ? titleLength + 5 : -5;
    }

    int bumpXOffset;
    int bumpLength;
    if (leftToRight) {
      bumpLength = width - buttonsWidth - xOffset - 5;
      bumpXOffset = xOffset;
    } else {
      bumpLength = xOffset - buttonsWidth - 5;
      bumpXOffset = buttonsWidth + 5;
    }
    int bumpYOffset = 3;
    int bumpHeight = getHeight() - (2 * bumpYOffset);
    bumps.setBumpArea(bumpLength, bumpHeight);
    bumps.paintIcon(this, g, bumpXOffset, bumpYOffset);
  }
Ejemplo n.º 27
0
 /** If necessary <code>c</code> is made opaque. */
 private void maybeMakeButtonOpaque(JComponent c) {
   Object opaque = UIManager.get("SplitPane.oneTouchButtonsOpaque");
   if (opaque != null) {
     c.setOpaque(((Boolean) opaque).booleanValue());
   }
 }
Ejemplo n.º 28
0
  private static int getSliderBaseline(JSlider slider, int height) {
    // We don't handle GTK as too much is hidden to be able to calculate it
    if (slider.getPaintLabels() && !isGTK()) {
      boolean isAqua = isAqua();
      FontMetrics metrics = slider.getFontMetrics(slider.getFont());
      Insets insets = slider.getInsets();
      Insets focusInsets = (Insets) UIManager.get("Slider.focusInsets");
      if (slider.getOrientation() == JSlider.HORIZONTAL) {
        int tickLength = 8;
        int contentHeight =
            height - insets.top - insets.bottom - focusInsets.top - focusInsets.bottom;
        int thumbHeight = 20;
        if (isMetal()) {
          tickLength = ((Integer) UIManager.get("Slider.majorTickLength")).intValue() + 5;
          thumbHeight = UIManager.getIcon("Slider.horizontalThumbIcon").getIconHeight();
        } else if (isWindows() && isXP()) {
          // NOTE: this is not correct, this should come from
          // the skin (in >= 1.5), but short of reflection
          // hacks we don't have access to the real value.
          thumbHeight++;
        }
        int centerSpacing = thumbHeight;
        if (isAqua || slider.getPaintTicks()) {
          // centerSpacing += getTickLength();
          centerSpacing += tickLength;
        }
        // Assume uniform labels.
        centerSpacing += metrics.getAscent() + metrics.getDescent();
        int trackY = insets.top + focusInsets.top + (contentHeight - centerSpacing - 1) / 2;
        if (isAqua) {
          if (slider.getPaintTicks()) {
            int prefHeight = slider.getUI().getPreferredSize(slider).height;
            int prefDelta = height - prefHeight;
            if (prefDelta > 0) {
              trackY -= Math.min(1, prefDelta);
            }
          } else {
            trackY--;
          }
        }

        int trackHeight = thumbHeight;
        int tickY = trackY + trackHeight;
        int tickHeight = tickLength;
        if (!isAqua && !slider.getPaintTicks()) {
          tickHeight = 0;
        }
        int labelY = tickY + tickHeight;
        return labelY + metrics.getAscent();
      } else { // vertical
        boolean inverted = slider.getInverted();
        Integer value = inverted ? getMinSliderValue(slider) : getMaxSliderValue(slider);
        if (value != null) {
          int thumbHeight = 11;
          if (isMetal()) {
            thumbHeight = UIManager.getIcon("Slider.verticalThumbIcon").getIconHeight();
          }
          int trackBuffer = Math.max(metrics.getHeight() / 2, thumbHeight / 2);
          int contentY = focusInsets.top + insets.top;
          int trackY = contentY + trackBuffer;
          int trackHeight =
              height
                  - focusInsets.top
                  - focusInsets.bottom
                  - insets.top
                  - insets.bottom
                  - trackBuffer
                  - trackBuffer;
          int maxValue = getMaxSliderValue(slider).intValue();
          int min = slider.getMinimum();
          int max = slider.getMaximum();
          double valueRange = (double) max - (double) min;
          double pixelsPerValue = (double) trackHeight / (double) valueRange;
          int trackBottom = trackY + (trackHeight - 1);
          if (isAqua) {
            trackY -= 3;
            trackBottom += 6;
          }
          int yPosition = trackY;
          double offset;

          if (!inverted) {
            offset = pixelsPerValue * ((double) max - value.intValue());
          } else {
            offset = pixelsPerValue * ((double) value.intValue() - min);
          }
          if (isAqua) {
            yPosition += Math.floor(offset);
          } else {
            yPosition += Math.round(offset);
          }
          yPosition = Math.max(trackY, yPosition);
          yPosition = Math.min(trackBottom, yPosition);
          if (isAqua) {
            return yPosition + metrics.getAscent();
          }
          return yPosition - metrics.getHeight() / 2 + metrics.getAscent();
        }
      }
    }
    return -1;
  }
Ejemplo n.º 29
0
  @Override
  public void paintIcon(SynthContext context, Graphics g, int x, int y, int w, int h) {
    Painter painter = null;
    if (context != null) {
      painter = (Painter) context.getStyle().get(context, key);
    }
    if (painter == null) {
      painter = (Painter) UIManager.get(prefix + "[Enabled]." + key);
    }

    if (painter != null && context != null) {
      JComponent c = context.getComponent();
      boolean rotate = false;
      boolean flip = false;
      // translatex and translatey are additional translations that
      // must occur on the graphics context when rendering a toolbar
      // icon
      int translatex = 0;
      int translatey = 0;
      if (c instanceof JToolBar) {
        JToolBar toolbar = (JToolBar) c;
        rotate = toolbar.getOrientation() == JToolBar.VERTICAL;
        flip = !toolbar.getComponentOrientation().isLeftToRight();
        Object o = NimbusLookAndFeel.resolveToolbarConstraint(toolbar);
        // we only do the +1 hack for UIResource borders, assuming
        // that the border is probably going to be our border
        if (toolbar.getBorder() instanceof UIResource) {
          if (o == BorderLayout.SOUTH) {
            translatey = 1;
          } else if (o == BorderLayout.EAST) {
            translatex = 1;
          }
        }
      }
      if (g instanceof Graphics2D) {
        Graphics2D gfx = (Graphics2D) g;
        gfx.translate(x, y);
        gfx.translate(translatex, translatey);
        if (rotate) {
          gfx.rotate(Math.toRadians(90));
          gfx.translate(0, -w);
          painter.paint(gfx, context.getComponent(), h, w);
          gfx.translate(0, w);
          gfx.rotate(Math.toRadians(-90));
        } else if (flip) {
          gfx.scale(-1, 1);
          gfx.translate(-w, 0);
          painter.paint(gfx, context.getComponent(), w, h);
          gfx.translate(w, 0);
          gfx.scale(-1, 1);
        } else {
          painter.paint(gfx, context.getComponent(), w, h);
        }
        gfx.translate(-translatex, -translatey);
        gfx.translate(-x, -y);
      } else {
        // use image if we are printing to a Java 1.1 PrintGraphics as
        // it is not a instance of Graphics2D
        BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
        Graphics2D gfx = img.createGraphics();
        if (rotate) {
          gfx.rotate(Math.toRadians(90));
          gfx.translate(0, -w);
          painter.paint(gfx, context.getComponent(), h, w);
        } else if (flip) {
          gfx.scale(-1, 1);
          gfx.translate(-w, 0);
          painter.paint(gfx, context.getComponent(), w, h);
        } else {
          painter.paint(gfx, context.getComponent(), w, h);
        }
        gfx.dispose();
        g.drawImage(img, x, y, null);
        img = null;
      }
    }
  }
Ejemplo n.º 30
0
 protected Image createCrayonsImage() {
   return (Image) UIManager.get("ColorChooser.crayonsImage");
 }