looks-2.2.0

sets i = c.getInsets();
    
    resetRects();
    
    viewRect.setBounds(0, 0, menuWidth, menuHeight);
    
    viewRectx += left;
    viewRecty += top;
    viewRectwidth -= right + viewRectx;
    viewRectheight -= bottom + viewRecty;
    
    Font holdf = g.getFont();
    Font f = c.getFont();
    g.setFont(f);
    FontMetrics fm = g.getFontMetrics(f);
    FontMetrics fmAccel = g.getFontMetrics(acceleratorFont);
    
    KeyStroke accelerator = b.getAccelerator();
    String acceleratorText = "";
    if (accelerator != null)
    {
      int modifiers = accelerator.getModifiers();
      if (modifiers > 0)
      {
        acceleratorText = KeyEvent.getKeyModifiersText(modifiers);
        acceleratorText = acceleratorText + acceleratorDelimiter;
      }
      int keyCode = accelerator.getKeyCode();
      if (keyCode != 0) {
        acceleratorText = acceleratorText + KeyEvent.getKeyText(keyCode);
      } else {
        acceleratorText = acceleratorText + accelerator.getKeyChar();
      }
    }
    Icon wrappedIcon = getWrappedIcon(getIcon(menuItem, checkIcon));
    Icon wrappedArrowIcon = new MinimumSizedIcon(arrowIcon);
    
    String text = layoutMenuItem(fm, b.getText(), fmAccel, acceleratorText, null, wrappedIcon, wrappedArrowIcon, b.getVerticalAlignment(), b.getHorizontalAlignment(), b.getVerticalTextPosition(), b.getHorizontalTextPosition(), viewRect, iconRect, textRect, acceleratorRect, checkIconRect, arrowIconRect, b.getText() == null ? 0 : defaultTextIconGap, defaultTextIconGap);
    
    paintBackground(g, b, background);
    
    Color holdc = g.getColor();
    if ((model.isArmed()) || (((c instanceof JMenu)) && (model.isSelected()))) {
      g.setColor(foreground);
    }
    wrappedIcon.paintIcon(c, g, checkIconRectx, checkIconRecty);
    g.setColor(holdc);
    if (text != null)
    {
      View v = (View)c.getClientProperty("html");
      if (v != null) {
        v.paint(g, textRect);
      } else {
        paintText(g, b, textRect, text);
      }
    }
    if ((acceleratorText != null) && (!acceleratorText.equals("")))
    {
      int accOffset = 0;
      Container parent = menuItem.getParent();
      if ((parent != null) && ((parent instanceof JComponent)))
      {
        JComponent p = (JComponent)parent;
        Integer maxValueInt = (Integer)p.getClientProperty("maxAccWidth");
        int maxValue = maxValueInt != null ? maxValueInt.intValue() : acceleratorRectwidth;
        
        accOffset = isLeftToRight(menuItem) ? maxValue - acceleratorRectwidth : acceleratorRectwidth - maxValue;
      }
      g.setFont(acceleratorFont);
      if (!model.isEnabled())
      {
        if (!disabledTextHasShadow())
        {
          g.setColor(disabledForeground);
          RenderingUtils.drawStringUnderlineCharAt(c, g, acceleratorText, -1, acceleratorRectx - accOffset, acceleratorRecty + fmAccel.getAscent());
        }
        else
        {
          g.setColor(b.getBackground().brighter());
          RenderingUtils.drawStringUnderlineCharAt(c, g, acceleratorText, -1, acceleratorRectx - accOffset, acceleratorRecty + fmAccel.getAscent());
          
          g.setColor(b.getBackground().darker());
          RenderingUtils.drawStringUnderlineCharAt(c, g, acceleratorText, -1, acceleratorRectx - accOffset - 1, acceleratorRecty + fmAccel.getAscent() - 1);
        }
      }
      else
      {
        if ((model.isArmed()) || (((c instanceof JMenu)) && (model.isSelected()))) {
          g.setColor(acceleratorSelectionForeground);
        } else {
          g.setColor(acceleratorForeground);
        }
        RenderingUtils.drawStringUnderlineCharAt(c, g, acceleratorText, -1, acceleratorRectx - accOffset, acceleratorRecty + fmAccel.getAscent());
      }
    }
    if (arrowIcon != null)
    {
      if ((model.isArmed()) || (((c instanceof JMenu)) && (model.isSelected()))) {
        g.setColor(foreground);
      }
      if (useCheckAndArrow()) {
        wrappedArrowIcon.paintIcon(c, g, arrowIconRectx, arrowIconRecty);
      }
    }
    g.setColor(holdc);
    g.setFont(holdf);
  }
  
  private String layoutMenuItem(FontMetrics fm, String text, FontMetrics fmAccel, String acceleratorText, Icon icon, Icon checkIcon, Icon arrowIcon, int verticalAlignment, int horizontalAlignment, int verticalTextPosition, int horizontalTextPosition, Rectangle viewRectangle, Rectangle iconRectangle, Rectangle textRectangle, Rectangle acceleratorRectangle, Rectangle checkIconRectangle, Rectangle arrowIconRectangle, int textIconGap, int menuItemGap)
  {
    SwingUtilities.layoutCompoundLabel(menuItem, fm, text, icon, verticalAlignment, horizontalAlignment, verticalTextPosition, horizontalTextPosition, viewRectangle, iconRectangle, textRectangle, textIconGap);
    if ((acceleratorText == null) || (acceleratorText.equals("")))
    {
      width = (height = 0);
      acceleratorText = "";
    }
    else
    {
      width = SwingUtilities.computeStringWidth(fmAccel, acceleratorText);
      height = fmAccel.getHeight();
    }
    boolean useCheckAndArrow = useCheckAndArrow();
    if (useCheckAndArrow)
    {
      if (checkIcon != null)
      {
        width = checkIcon.getIconWidth();
        height = checkIcon.getIconHeight();
      }
      else
      {
        width = (height = 0);
      }
      if (arrowIcon != null)
      {
        width = arrowIcon.getIconWidth();
        height = arrowIcon.getIconHeight();
      }
      else
      {
        width = (height = 0);
      }
    }
    Rectangle labelRect = iconRectangle.union(textRectangle);
    if (isLeftToRight(menuItem))
    {
      x += menuItemGap;
      x += menuItemGap;
      
      x = (x + width - width - menuItemGap - width);
      if (useCheckAndArrow)
      {
        x = x;
        x += menuItemGap + width;
        x += menuItemGap + width;
        x = (x + width - menuItemGap - width);
      }
    }
    else
    {
      x -= menuItemGap;
      x -= menuItemGap;
      
      x = (x + width + menuItemGap);
      if (useCheckAndArrow)
      {
        x = (x + width - width);
        x -= menuItemGap + width;
        x -= menuItemGap + width;
        x += menuItemGap;
      }
    }
    y = (y + height / 2 - height / 2);
    if (useCheckAndArrow)
    {
      y = (y + height / 2 - height / 2);
      y = (y + height / 2 - height / 2);
    }
    return text;
  }
  
  private boolean useCheckAndArrow()
  {
    boolean isTopLevelMenu = ((menuItem instanceof JMenu)) && (((JMenu)menuItem).isTopLevelMenu());
    
    return !isTopLevelMenu;
  }
  
  private boolean isLeftToRight(Component c)
  {
    return c.getComponentOrientation().isLeftToRight();
  }
  
  private void paintBackground(Graphics g, JMenuItem aMenuItem, Color bgColor)
  {
    ButtonModel model = aMenuItem.getModel();
    if (aMenuItem.isOpaque())
    {
      int menuWidth = aMenuItem.getWidth();
      int menuHeight = aMenuItem.getHeight();
      Color c = (model.isArmed()) || (((aMenuItem instanceof JMenu)) && (model.isSelected())) ? bgColor : aMenuItem.getBackground();
      
      Color oldColor = g.getColor();
      g.setColor(c);
      g.fillRect(0, 0, menuWidth, menuHeight);
      g.setColor(oldColor);
    }
  }
  
  private void paintText(Graphics g, JMenuItem aMenuItem, Rectangle textRectangle, String text)
  {
    ButtonModel model = aMenuItem.getModel();
    FontMetrics fm = g.getFontMetrics();
    int mnemIndex = aMenuItem.getDisplayedMnemonicIndex();
    if (isMnemonicHidden()) {
      mnemIndex = -1;
    }
    if (!model.isEnabled())
    {
      if (!disabledTextHasShadow())
      {
        g.setColor(UIManager.getColor("MenuItem.disabledForeground"));
        RenderingUtils.drawStringUnderlineCharAt(aMenuItem, g, text, mnemIndex, x, y + fm.getAscent());
      }
      else
      {
        g.setColor(aMenuItem.getBackground().brighter());
        RenderingUtils.drawStringUnderlineCharAt(aMenuItem, g, text, mnemIndex, x, y + fm.getAscent());
        
        g.setColor(aMenuItem.getBackground().darker());
        RenderingUtils.drawStringUnderlineCharAt(aMenuItem, g, text, mnemIndex, x - 1, y + fm.getAscent() - 1);
      }
    }
    else
    {
      if ((model.isArmed()) || (((aMenuItem instanceof JMenu)) && (model.isSelected()))) {
        g.setColor(selectionForeground);
      }
      RenderingUtils.drawStringUnderlineCharAt(aMenuItem, g, text, mnemIndex, x, y + fm.getAscent());
    }
  }
  
  protected boolean isMnemonicHidden()
  {
    return false;
  }
  
  protected boolean disabledTextHasShadow()
  {
    return false;
  }
  
  private boolean hideIcons()
  {
    Component parent = menuItem.getParent();
    if (!(parent instanceof JPopupMenu)) {
      return false;
    }
    JPopupMenu popupMenu = (JPopupMenu)parent;
    Object value = popupMenu.getClientProperty("jgoodies.noIcons");
    if (value == null)
    {
      Component invoker = popupMenu.getInvoker();
      if ((invoker != null) && ((invoker instanceof JMenu))) {
        value = ((JMenu)invoker).getClientProperty("jgoodies.noIcons");
      }
    }
    return Boolean.TRUE.equals(value);
  }
  
  private static class NullIcon
    implements Icon
  {
    NullIcon(MenuItemRenderer.1 x0)
    {
      this();
    }
    
    public int getIconWidth()
    {
      return 0;
    }
    
    public int getIconHeight()
    {
      return 0;
    }
    
    private NullIcon() {}
    
    public void paintIcon(Component c, Graphics g, int x, int y) {}
  }
}

/* Location:
 * Qualified Name:     com.jgoodies.looks.common.MenuItemRenderer
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks.common;

import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import javax.swing.ButtonModel;
import javax.swing.Icon;
import javax.swing.JMenuItem;
import javax.swing.UIManager;

public final class MinimumSizedCheckIcon
  extends MinimumSizedIcon
{
  private final JMenuItem menuItem;
  
  public MinimumSizedCheckIcon(Icon icon, JMenuItem menuItem)
  {
    super(icon);
    this.menuItem = menuItem;
  }
  
  public void paintIcon(Component c, Graphics g, int x, int y)
  {
    paintState(g, x, y);
    super.paintIcon(c, g, x, y);
  }
  
  private void paintState(Graphics g, int x, int y)
  {
    ButtonModel model = menuItem.getModel();
    
    int w = getIconWidth();
    int h = getIconHeight();
    
    g.translate(x, y);
    if ((model.isSelected()) || (model.isArmed()))
    {
      Color background = model.isArmed() ? UIManager.getColor("MenuItem.background") : UIManager.getColor("ScrollBar.track");
      
      Color upColor = UIManager.getColor("controlLtHighlight");
      Color downColor = UIManager.getColor("controlDkShadow");
      
      g.setColor(background);
      g.fillRect(0, 0, w, h);
      
      g.setColor(model.isSelected() ? downColor : upColor);
      g.drawLine(0, 0, w - 2, 0);
      g.drawLine(0, 0, 0, h - 2);
      
      g.setColor(model.isSelected() ? upColor : downColor);
      g.drawLine(0, h - 1, w - 1, h - 1);
      g.drawLine(w - 1, 0, w - 1, h - 1);
    }
    g.translate(-x, -y);
    g.setColor(UIManager.getColor("textText"));
  }
}

/* Location:
 * Qualified Name:     com.jgoodies.looks.common.MinimumSizedCheckIcon
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks.common;

import com.jgoodies.looks.Options;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import javax.swing.Icon;

public class MinimumSizedIcon
  implements Icon
{
  private final Icon icon;
  private final int width;
  private final int height;
  private final int xOffset;
  private final int yOffset;
  
  public MinimumSizedIcon()
  {
    this(null);
  }
  
  public MinimumSizedIcon(Icon icon)
  {
    Dimension minimumSize = Options.getDefaultIconSize();
    this.icon = icon;
    int iconWidth = icon == null ? 0 : icon.getIconWidth();
    int iconHeight = icon == null ? 0 : icon.getIconHeight();
    width = Math.max(iconWidth, Math.max(20, width));
    height = Math.max(iconHeight, Math.max(20, height));
    xOffset = Math.max(0, (width - iconWidth) / 2);
    yOffset = Math.max(0, (height - iconHeight) / 2);
  }
  
  public int getIconHeight()
  {
    return height;
  }
  
  public int getIconWidth()
  {
    return width;
  }
  
  public void paintIcon(Component c, Graphics g, int x, int y)
  {
    if (icon != null) {
      icon.paintIcon(c, g, x + xOffset, y + yOffset);
    }
  }
}

/* Location:
 * Qualified Name:     com.jgoodies.looks.common.MinimumSizedIcon
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks.common;

import java.awt.Container;
import javax.swing.BoxLayout;
import javax.swing.JPopupMenu;
import javax.swing.plaf.UIResource;

public final class PopupMenuLayout
  extends BoxLayout
  implements UIResource
{
  public PopupMenuLayout(Container target, int axis)
  {
    super(target, axis);
  }
  
  public synchronized void invalidateLayout(Container target)
  {
    if ((target instanceof JPopupMenu))
    {
      JPopupMenu menu = (JPopupMenu)target;
      menu.putClientProperty("maxTextWidth", null);
      menu.putClientProperty("maxAccWidth", null);
    }
    super.invalidateLayout(target);
  }
}

/* Location:
 * Qualified Name:     com.jgoodies.looks.common.PopupMenuLayout
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks.common;

import com.jgoodies.looks.LookUtils;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.PrintGraphics;
import java.awt.RenderingHints;
import java.awt.RenderingHints.Key;
import java.awt.Toolkit;
import java.awt.print.PrinterGraphics;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import javax.swing.JComponent;
import javax.swing.plaf.basic.BasicGraphicsUtils;

public final class RenderingUtils
{
  private static final String PROP_DESKTOPHINTS = "awt.font.desktophints";
  private static final String SWING_UTILITIES2_NAME = LookUtils.IS_JAVA_6_OR_LATER ? "sun.swing.SwingUtilities2" : "com.sun.java.swing.SwingUtilities2";
  private static Method drawStringUnderlineCharAtMethod = null;
  
  static
  {
    if (LookUtils.IS_JAVA_5_OR_LATER) {
      drawStringUnderlineCharAtMethod = getMethodDrawStringUnderlineCharAt();
    }
  }
  
  public static void drawStringUnderlineCharAt(JComponent c, Graphics g, String text, int underlinedIndex, int x, int y)
  {
    if (LookUtils.IS_JAVA_5_OR_LATER)
    {
      if (drawStringUnderlineCharAtMethod != null) {
        try
        {
          drawStringUnderlineCharAtMethod.invoke(null, new Object[] { c, g, text, new Integer(underlinedIndex), new Integer(x), new Integer(y) });
          
          return;
        }
        catch (IllegalArgumentException e) {}catch (IllegalAccessException e) {}catch (InvocationTargetException e) {}
      }
      Graphics2D g2 = (Graphics2D)g;
      Map oldRenderingHints = installDesktopHints(g2);
      BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, underlinedIndex, x, y);
      if (oldRenderingHints != null) {
        g2.addRenderingHints(oldRenderingHints);
      }
      return;
    }
    BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, underlinedIndex, x, y);
  }
  
  private static Method getMethodDrawStringUnderlineCharAt()
  {
    try
    {
      Class clazz = Class.forName(SWING_UTILITIES2_NAME);
      return clazz.getMethod("drawStringUnderlineCharAt", new Class[] { JComponent.class, Graphics.class, String.class, Integer.TYPE, Integer.TYPE, Integer.TYPE });
    }
    catch (ClassNotFoundException e) {}catch (SecurityException e) {}catch (NoSuchMethodException e) {}
    return null;
  }
  
  private static Map installDesktopHints(Graphics2D g2)
  {
    Map oldRenderingHints = null;
    if (LookUtils.IS_JAVA_6_OR_LATER)
    {
      Map desktopHints = desktopHints(g2);
      if ((desktopHints != null) && (!desktopHints.isEmpty()))
      {
        oldRenderingHints = new HashMap(desktopHints.size());
        for (Iterator i = desktopHints.keySet().iterator(); i.hasNext();)
        {
          RenderingHints.Key key = (RenderingHints.Key)i.next();
          oldRenderingHints.put(key, g2.getRenderingHint(key));
        }
        g2.addRenderingHints(desktopHints);
      }
    }
    return oldRenderingHints;
  }
  
  private static Map desktopHints(Graphics2D g2)
  {
    if (isPrinting(g2)) {
      return null;
    }
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    GraphicsDevice device = g2.getDeviceConfiguration().getDevice();
    Map desktopHints = (Map)toolkit.getDesktopProperty("awt.font.desktophints." + device.getIDstring());
    if (desktopHints == null) {
      desktopHints = (Map)toolkit.getDesktopProperty("awt.font.desktophints");
    }
    if (desktopHints != null)
    {
      Object aaHint = desktopHints.get(RenderingHints.KEY_TEXT_ANTIALIASING);
      if ((aaHint == RenderingHints.VALUE_TEXT_ANTIALIAS_OFF) || (aaHint == RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT)) {
        desktopHints = null;
      }
    }
    return desktopHints;
  }
  
  private static boolean isPrinting(Graphics g)
  {
    return ((g instanceof PrintGraphics)) || ((g instanceof PrinterGraphics));
  }
}

/* Location:
 * Qualified Name:     com.jgoodies.looks.common.RenderingUtils
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks.common;

import com.jgoodies.looks.Options;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.awt.image.FilteredImageSource;
import java.awt.image.ImageProducer;
import java.awt.image.RGBImageFilter;
import javax.swing.GrayFilter;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JComponent;

public final class RGBGrayFilter
  extends RGBImageFilter
{
  private RGBGrayFilter()
  {
    canFilterIndexColorModel = true;
  }
  
  public static Icon getDisabledIcon(JComponent component, Icon icon)
  {
    if ((icon == null) || (component == null) || (icon.getIconWidth() == 0) || (icon.getIconHeight() == 0)) {
      return null;
    }
    Image img;
    Image img;
    if ((icon instanceof ImageIcon))
    {
      img = ((ImageIcon)icon).getImage();
    }
    else
    {
      img = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), 2);
      
      icon.paintIcon(component, img.getGraphics(), 0, 0);
    }
    if ((!Options.isHiResGrayFilterEnabled()) || (Boolean.FALSE.equals(component.getClientProperty("generateHiResDisabledIcon")))) {
      return new ImageIcon(GrayFilter.createDisabledImage(img));
    }
    ImageProducer producer = new FilteredImageSource(img.getSource(), new RGBGrayFilter());
    
    return new ImageIcon(component.createImage(producer));
  }
  
  public int filterRGB(int x, int y, int rgb)
  {
    float avg = ((rgb >> 16 & 0xFF) / 255.0F + (rgb >> 8 & 0xFF) / 255.0F + (rgb & 0xFF) / 255.0F) / 3.0F;
    
    float alpha = (rgb >> 24 & 0xFF) / 255.0F;
    
    avg = Math.min(1.0F, 0.35F + 0.65F * avg);
    
    int rgbval = (int)(alpha * 255.0F) << 24 | (int)(avg * 255.0F) << 16 | (int)(avg * 255.0F) << 8 | (int)(avg * 255.0F);
    
    return rgbval;
  }
}

/* Location:
 * Qualified Name:     com.jgoodies.looks.common.RGBGrayFilter
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks.common;

import java.awt.AWTException;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Panel;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Window;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JApplet;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JInternalFrame;
import javax.swing.JRootPane;
import javax.swing.JWindow;
import javax.swing.Popup;
import javax.swing.SwingUtilities;
import javax.swing.border.Border;

public final class ShadowPopup
  extends Popup
{
  private static final int MAX_CACHE_SIZE = 5;
  private static List cache;
  private static final Border SHADOW_BORDER = ;
  private static final int SHADOW_SIZE = 5;
  private static boolean canSnapshot = true;
  private Component owner;
  private Component contents;
  private int x;
  private int y;
  private Popup popup;
  private Border oldBorder;
  private boolean oldOpaque;
  private Container heavyWeightContainer;
  
  static Popup getInstance(Component owner, Component contents, int x, int y, Popup delegate)
  {
    ShadowPopup result;
    synchronized (ShadowPopup.class)
    {
      if (cache == null) {
        cache = new ArrayList(5);
      }
      ShadowPopup result;
      if (cache.size() > 0) {
        result = (ShadowPopup)cache.remove(0);
      } else {
        result = new ShadowPopup();
      }
    }
    result.reset(owner, contents, x, y, delegate);
    return result;
  }
  
  private static void recycle(ShadowPopup popup)
  {
    synchronized (ShadowPopup.class)
    {
      if (cache.size() < 5) {
        cache.add(popup);
      }
    }
  }
  
  public static boolean canSnapshot()
  {
    return canSnapshot;
  }
  
  public void hide()
  {
    if (contents == null) {
      return;
    }
    JComponent parent = (JComponent)contents.getParent();
    popup.hide();
    if ((parent != null) && (parent.getBorder() == SHADOW_BORDER))
    {
      parent.setBorder(oldBorder);
      parent.setOpaque(oldOpaque);
      oldBorder = null;
      if (heavyWeightContainer != null)
      {
        parent.putClientProperty("jgoodies.hShadowBg", null);
        parent.putClientProperty("jgoodies.vShadowBg", null);
        heavyWeightContainer = null;
      }
    }
    owner = null;
    contents = null;
    popup = null;
    recycle(this);
  }
  
  public void show()
  {
    if (heavyWeightContainer != null) {
      snapshot();
    }
    popup.show();
  }
  
  private void reset(Component owner, Component contents, int x, int y, Popup popup)
  {
    this.owner = owner;
    this.contents = contents;
    this.popup = popup;
    this.x = x;
    this.y = y;
    if ((owner instanceof JComboBox)) {
      return;
    }
    Dimension contentsPrefSize = contents.getPreferredSize();
    if ((width <= 0) || (height <= 0)) {
      return;
    }
    for (Container p = contents.getParent(); p != null; p = p.getParent()) {
      if (((p instanceof JWindow)) || ((p instanceof Panel)))
      {
        p.setBackground(contents.getBackground());
        heavyWeightContainer = p;
        break;
      }
    }
    JComponent parent = (JComponent)contents.getParent();
    oldOpaque = parent.isOpaque();
    oldBorder = parent.getBorder();
    parent.setOpaque(false);
    parent.setBorder(SHADOW_BORDER);
    if (heavyWeightContainer != null) {
      heavyWeightContainer.setSize(heavyWeightContainer.getPreferredSize());
    } else {
      parent.setSize(parent.getPreferredSize());
    }
  }
  
  private static final Point POINT = new Point();
  private static final Rectangle RECT = new Rectangle();
  
  private void snapshot()
  {
    try
    {
      Dimension size = heavyWeightContainer.getPreferredSize();
      int width = width;
      int height = height;
      if ((width <= 0) || (height <= 5)) {
        return;
      }
      Robot robot = new Robot();
      
      RECT.setBounds(x, y + height - 5, width, 5);
      BufferedImage hShadowBg = robot.createScreenCapture(RECT);
      
      RECT.setBounds(x + width - 5, y, 5, height - 5);
      
      BufferedImage vShadowBg = robot.createScreenCapture(RECT);
      
      JComponent parent = (JComponent)contents.getParent();
      parent.putClientProperty("jgoodies.hShadowBg", hShadowBg);
      parent.putClientProperty("jgoodies.vShadowBg", vShadowBg);
      
      Container layeredPane = getLayeredPane();
      if (layeredPane == null) {
        return;
      }
      int layeredPaneWidth = layeredPane.getWidth();
      int layeredPaneHeight = layeredPane.getHeight();
      
      POINTx = x;
      POINTy = y;
      SwingUtilities.convertPointFromScreen(POINT, layeredPane);
      
      RECTx = POINTx;
      RECTy = (POINTy + height - 5);
      RECTwidth = width;
      RECTheight = 5;
      if (RECTx + RECTwidth > layeredPaneWidth) {
        RECTwidth = (layeredPaneWidth - RECTx);
      }
      if (RECTy + RECTheight > layeredPaneHeight) {
        RECTheight = (layeredPaneHeight - RECTy);
      }
      if (!RECT.isEmpty())
      {
        Graphics g = hShadowBg.createGraphics();
        g.translate(-RECTx, -RECTy);
        g.setClip(RECT);
        if ((layeredPane instanceof JComponent))
        {
          JComponent c = (JComponent)layeredPane;
          boolean doubleBuffered = c.isDoubleBuffered();
          c.setDoubleBuffered(false);
          c.paintAll(g);
          c.setDoubleBuffered(doubleBuffered);
        }
        else
        {
          layeredPane.paintAll(g);
        }
        g.dispose();
      }
      RECTx = (POINTx + width - 5);
      RECTy = POINTy;
      RECTwidth = 5;
      RECTheight = (height - 5);
      if (RECTx + RECTwidth > layeredPaneWidth) {
        RECTwidth = (layeredPaneWidth - RECTx);
      }
      if (RECTy + RECTheight > layeredPaneHeight) {
        RECTheight = (layeredPaneHeight - RECTy);
      }
      if (!RECT.isEmpty())
      {
        Graphics g = vShadowBg.createGraphics();
        g.translate(-RECTx, -RECTy);
        g.setClip(RECT);
        if ((layeredPane instanceof JComponent))
        {
          JComponent c = (JComponent)layeredPane;
          boolean doubleBuffered = c.isDoubleBuffered();
          c.setDoubleBuffered(false);
          c.paintAll(g);
          c.setDoubleBuffered(doubleBuffered);
        }
        else
        {
          layeredPane.paintAll(g);
        }
        g.dispose();
      }
    }
    catch (AWTException e)
    {
      canSnapshot = false;
    }
    catch (SecurityException e)
    {
      canSnapshot = false;
    }
  }
  
  private Container getLayeredPane()
  {
    Container parent = null;
    if (owner != null) {
      parent = (owner instanceof Container) ? (Container)owner : owner.getParent();
    }
    for (Container p = parent; p != null; p = p.getParent()) {
      if ((p instanceof JRootPane))
      {
        if (!(p.getParent() instanceof JInternalFrame)) {
          parent = ((JRootPane)p).getLayeredPane();
        }
      }
      else if ((p instanceof Window))
      {
        if (parent == null) {
          parent = p;
        }
      }
      else {
        if ((p instanceof JApplet)) {
          break;
        }
      }
    }
    return parent;
  }
}

/* Location:
 * Qualified Name:     com.jgoodies.looks.common.ShadowPopup
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks.common;

import java.awt.Component;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Insets;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.border.AbstractBorder;

final class ShadowPopupBorder
  extends AbstractBorder
{
  private static final int SHADOW_SIZE = 5;
  private static ShadowPopupBorder instance = new ShadowPopupBorder();
  private static Image shadow = new ImageIcon(ShadowPopupBorder.class.getResource("shadow.png")).getImage();
  
  public static ShadowPopupBorder getInstance()
  {
    return instance;
  }
  
  public void paintBorder(Component c, Graphics g, int x, int y, int width, int height)
  {
    JComponent popup = (JComponent)c;
    Image hShadowBg = (Image)popup.getClientProperty("jgoodies.hShadowBg");
    if (hShadowBg != null) {
      g.drawImage(hShadowBg, x, y + height - 5, c);
    }
    Image vShadowBg = (Image)popup.getClientProperty("jgoodies.vShadowBg");
    if (vShadowBg != null) {
      g.drawImage(vShadowBg, x + width - 5, y, c);
    }
    g.drawImage(shadow, x + 5, y + height - 5, x + 10, y + height, 0, 6, 5, 11, null, c);
    g.drawImage(shadow, x + 10, y + height - 5, x + width - 5, y + height, 5, 6, 6, 11, null, c);
    g.drawImage(shadow, x + width - 5, y + 5, x + width, y + 10, 6, 0, 11, 5, null, c);
    g.drawImage(shadow, x + width - 5, y + 10, x + width, y + height - 5, 6, 5, 11, 6, null, c);
    g.drawImage(shadow, x + width - 5, y + height - 5, x + width, y + height, 6, 6, 11, 11, null, c);
  }
  
  public Insets getBorderInsets(Component c)
  {
    return new Insets(0, 0, 5, 5);
  }
  
  public Insets getBorderInsets(Component c, Insets insets)
  {
    left = (top = 0);
    right = (bottom = 5);
    return insets;
  }
}

/* Location:
 * Qualified Name:     com.jgoodies.looks.common.ShadowPopupBorder
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks.common;

import com.jgoodies.looks.LookUtils;
import com.jgoodies.looks.Options;
import java.awt.Component;
import javax.swing.Popup;
import javax.swing.PopupFactory;

public final class ShadowPopupFactory
  extends PopupFactory
{
  static final String PROP_HORIZONTAL_BACKGROUND = "jgoodies.hShadowBg";
  static final String PROP_VERTICAL_BACKGROUND = "jgoodies.vShadowBg";
  private final PopupFactory storedFactory;
  
  private ShadowPopupFactory(PopupFactory storedFactory)
  {
    this.storedFactory = storedFactory;
  }
  
  public static void install()
  {
    if (LookUtils.IS_OS_MAC) {
      return;
    }
    PopupFactory factory = PopupFactory.getSharedInstance();
    if ((factory instanceof ShadowPopupFactory)) {
      return;
    }
    PopupFactory.setSharedInstance(new ShadowPopupFactory(factory));
  }
  
  public static void uninstall()
  {
    PopupFactory factory = PopupFactory.getSharedInstance();
    if (!(factory instanceof ShadowPopupFactory)) {
      return;
    }
    PopupFactory stored = storedFactory;
    PopupFactory.setSharedInstance(stored);
  }
  
  public Popup getPopup(Component owner, Component contents, int x, int y)
    throws IllegalArgumentException
  {
    Popup popup = super.getPopup(owner, contents, x, y);
    return Options.isPopupDropShadowActive() ? ShadowPopup.getInstance(owner, contents, x, y, popup) : popup;
  }
}

/* Location:
 * Qualified Name:     com.jgoodies.looks.common.ShadowPopupFactory
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks;

class FontPolicies$1 {}

/* Location:
 * Qualified Name:     com.jgoodies.looks.FontPolicies.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks;

import javax.swing.UIDefaults;

final class FontPolicies$CustomSettingsPolicy
  implements FontPolicy
{
  private final FontPolicy wrappedPolicy;
  
  FontPolicies$CustomSettingsPolicy(FontPolicy wrappedPolicy)
  {
    this.wrappedPolicy = wrappedPolicy;
  }
  
  public FontSet getFontSet(String lafName, UIDefaults table)
  {
    FontPolicy customPolicy = FontPolicies.access$300(lafName);
    if (customPolicy != null) {
      return customPolicy.getFontSet(null, table);
    }
    FontSet customFontSet = FontPolicies.access$400(lafName);
    if (customFontSet != null) {
      return customFontSet;
    }
    return wrappedPolicy.getFontSet(lafName, table);
  }
}

/* Location:
 * Qualified Name:     com.jgoodies.looks.FontPolicies.CustomSettingsPolicy
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks;

import java.awt.Font;
import javax.swing.UIDefaults;

final class FontPolicies$DefaultPlasticOnWindowsPolicy
  implements FontPolicy
{
  FontPolicies$DefaultPlasticOnWindowsPolicy(FontPolicies.1 x0)
  {
    this();
  }
  
  public FontSet getFontSet(String lafName, UIDefaults table)
  {
    Font windowsControlFont = Fonts.getWindowsControlFont();
    Font controlFont;
    Font controlFont;
    if (windowsControlFont != null)
    {
      controlFont = windowsControlFont;
    }
    else
    {
      Font controlFont;
      if (table != null) {
        controlFont = table.getFont("Button.font");
      } else {
        controlFont = new Font("Dialog", 0, 12);
      }
    }
    Font menuFont = table == null ? controlFont : table.getFont("Menu.font");
    
    Font titleFont = controlFont.deriveFont(1);
    
    return FontSets.createDefaultFontSet(controlFont, menuFont, titleFont);
  }
  
  private FontPolicies$DefaultPlasticOnWindowsPolicy() {}
}

/* Location:
 * Qualified Name:     com.jgoodies.looks.FontPolicies.DefaultPlasticOnWindowsPolicy
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks;

import java.awt.Font;
import javax.swing.UIDefaults;

final class FontPolicies$DefaultWindowsPolicy
  implements FontPolicy
{
  FontPolicies$DefaultWindowsPolicy(FontPolicies.1 x0)
  {
    this();
  }
  
  public FontSet getFontSet(String lafName, UIDefaults table)
  {
    Font windowsControlFont = Fonts.getWindowsControlFont();
    Font controlFont;
    Font controlFont;
    if (windowsControlFont != null)
    {
      controlFont = windowsControlFont;
    }
    else
    {
      Font controlFont;
      if (table != null) {
        controlFont = table.getFont("Button.font");
      } else {
        controlFont = new Font("Dialog", 0, 12);
      }
    }
    Font menuFont = table == null ? controlFont : table.getFont("Menu.font");
    
    Font titleFont = controlFont;
    Font messageFont = table == null ? controlFont : table.getFont("OptionPane.font");
    
    Font smallFont = table == null ? controlFont.deriveFont(controlFont.getSize2D() - 2.0F) : table.getFont("ToolTip.font");
    
    Font windowTitleFont = table == null ? controlFont : table.getFont("InternalFrame.titleFont");
    
    return FontSets.createDefaultFontSet(controlFont, menuFont, titleFont, messageFont, smallFont, windowTitleFont);
  }
  
  private FontPolicies$DefaultWindowsPolicy() {}
}

/* Location:
 * Qualified Name:     com.jgoodies.looks.FontPolicies.DefaultWindowsPolicy
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks;

import javax.swing.UIDefaults;

final class FontPolicies$FixedPolicy
  implements FontPolicy
{
  private final FontSet fontSet;
  
  FontPolicies$FixedPolicy(FontSet fontSet)
  {
    this.fontSet = fontSet;
  }
  
  public FontSet getFontSet(String lafName, UIDefaults table)
  {
    return fontSet;
  }
}

/* Location:
 * Qualified Name:     com.jgoodies.looks.FontPolicies.FixedPolicy
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks;

import java.awt.Font;
import javax.swing.UIDefaults;

final class FontPolicies$Looks1xWindowsPolicy
  implements FontPolicy
{
  FontPolicies$Looks1xWindowsPolicy(FontPolicies.1 x0)
  {
    this();
  }
  
  public FontSet getFontSet(String lafName, UIDefaults table)
  {
    Font windowsControlFont = Fonts.getLooks1xWindowsControlFont();
    Font controlFont;
    Font controlFont;
    if (windowsControlFont != null)
    {
      controlFont = windowsControlFont;
    }
    else
    {
      Font controlFont;
      if (table != null) {
        controlFont = table.getFont("Button.font");
      } else {
        controlFont = new Font("Dialog", 0, 12);
      }
    }
    return FontSets.createDefaultFontSet(controlFont);
  }
  
  private FontPolicies$Looks1xWindowsPolicy() {}
}

/* Location:
 * Qualified Name:     com.jgoodies.looks.FontPolicies.Looks1xWindowsPolicy
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks;

import java.awt.Font;
import javax.swing.UIDefaults;

public final class FontPolicies
{
  public static FontPolicy createFixedPolicy(FontSet fontSet)
  {
    return new FixedPolicy(fontSet);
  }
  
  public static FontPolicy customSettingsPolicy(FontPolicy defaultPolicy)
  {
    return new CustomSettingsPolicy(defaultPolicy);
  }
  
  public static FontPolicy getDefaultPlasticOnWindowsPolicy()
  {
    return new DefaultPlasticOnWindowsPolicy(null);
  }
  
  public static FontPolicy getDefaultPlasticPolicy()
  {
    if (LookUtils.IS_OS_WINDOWS) {
      return getDefaultPlasticOnWindowsPolicy();
    }
    return getLogicalFontsPolicy();
  }
  
  public static FontPolicy getDefaultWindowsPolicy()
  {
    return new DefaultWindowsPolicy(null);
  }
  
  public static FontPolicy getLogicalFontsPolicy()
  {
    return createFixedPolicy(FontSets.getLogicalFontSet());
  }
  
  public static FontPolicy getLooks1xPlasticPolicy()
  {
    Font controlFont = Fonts.getDefaultGUIFontWesternModernWindowsNormal();
    Font menuFont = controlFont;
    Font titleFont = controlFont.deriveFont(1);
    FontSet fontSet = FontSets.createDefaultFontSet(controlFont, menuFont, titleFont);
    return createFixedPolicy(fontSet);
  }
  
  public static FontPolicy getLooks1xWindowsPolicy()
  {
    return new Looks1xWindowsPolicy(null);
  }
  
  public static FontPolicy getTransitionalPlasticPolicy()
  {
    return LookUtils.IS_OS_WINDOWS ? getDefaultPlasticOnWindowsPolicy() : getLooks1xPlasticPolicy();
  }
  
  private static FontSet getCustomFontSet(String lafName)
  {
    String controlFontKey = lafName + ".controlFont";
    String menuFontKey = lafName + ".menuFont";
    String decodedControlFont = LookUtils.getSystemProperty(controlFontKey);
    if (decodedControlFont == null) {
      return null;
    }
    Font controlFont = Font.decode(decodedControlFont);
    String decodedMenuFont = LookUtils.getSystemProperty(menuFontKey);
    Font menuFont = decodedMenuFont != null ? Font.decode(decodedMenuFont) : null;
    
    Font titleFont = "Plastic".equals(lafName) ? controlFont.deriveFont(1) : controlFont;
    
    return FontSets.createDefaultFontSet(controlFont, menuFont, titleFont);
  }
  
  private static FontPolicy getCustomPolicy(String lafName)
  {
    return null;
  }
  
  private static final class CustomSettingsPolicy
    implements FontPolicy
  {
    private final FontPolicy wrappedPolicy;
    
    CustomSettingsPolicy(FontPolicy wrappedPolicy)
    {
      this.wrappedPolicy = wrappedPolicy;
    }
    
    public FontSet getFontSet(String lafName, UIDefaults table)
    {
      FontPolicy customPolicy = FontPolicies.getCustomPolicy(lafName);
      if (customPolicy != null) {
        return customPolicy.getFontSet(null, table);
      }
      FontSet customFontSet = FontPolicies.getCustomFontSet(lafName);
      if (customFontSet != null) {
        return customFontSet;
      }
      return wrappedPolicy.getFontSet(lafName, table);
    }
  }
  
  private static final class DefaultPlasticOnWindowsPolicy
    implements FontPolicy
  {
    DefaultPlasticOnWindowsPolicy(FontPolicies.1 x0)
    {
      this();
    }
    
    public FontSet getFontSet(String lafName, UIDefaults table)
    {
      Font windowsControlFont = Fonts.getWindowsControlFont();
      Font controlFont;
      Font controlFont;
      if (windowsControlFont != null)
      {
        controlFont = windowsControlFont;
      }
      else
      {
        Font controlFont;
        if (table != null) {
          controlFont = table.getFont("Button.font");
        } else {
          controlFont = new Font("Dialog", 0, 12);
        }
      }
      Font menuFont = table == null ? controlFont : table.getFont("Menu.font");
      
      Font titleFont = controlFont.deriveFont(1);
      
      return FontSets.createDefaultFontSet(controlFont, menuFont, titleFont);
    }
    
    private DefaultPlasticOnWindowsPolicy() {}
  }
  
  private static final class DefaultWindowsPolicy
    implements FontPolicy
  {
    DefaultWindowsPolicy(FontPolicies.1 x0)
    {
      this();
    }
    
    public FontSet getFontSet(String lafName, UIDefaults table)
    {
      Font windowsControlFont = Fonts.getWindowsControlFont();
      Font controlFont;
      Font controlFont;
      if (windowsControlFont != null)
      {
        controlFont = windowsControlFont;
      }
      else
      {
        Font controlFont;
        if (table != null) {
          controlFont = table.getFont("Button.font");
        } else {
          controlFont = new Font("Dialog", 0, 12
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd