looks-2.2.0

D-Core Version:    0.7.1
 */
package com.jgoodies.looks.plastic;

import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;
import javax.swing.border.AbstractBorder;
import javax.swing.plaf.UIResource;

final class PlasticBorders$ThinRaisedBorder
  extends AbstractBorder
  implements UIResource
{
  PlasticBorders$ThinRaisedBorder(PlasticBorders.1 x0)
  {
    this();
  }
  
  private static final Insets INSETS = new Insets(2, 2, 2, 2);
  
  public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
  {
    PlasticUtils.drawThinFlush3DBorder(g, x, y, w, h);
  }
  
  public Insets getBorderInsets(Component c)
  {
    return INSETS;
  }
  
  private PlasticBorders$ThinRaisedBorder() {}
}

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

import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;
import javax.swing.AbstractButton;
import javax.swing.ButtonModel;

final class PlasticBorders$ToggleButtonBorder
  extends PlasticBorders.ButtonBorder
{
  PlasticBorders$ToggleButtonBorder(Insets x0, PlasticBorders.1 x1)
  {
    this(x0);
  }
  
  private PlasticBorders$ToggleButtonBorder(Insets insets)
  {
    super(insets);
  }
  
  public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
  {
    if (!c.isEnabled())
    {
      PlasticUtils.drawDisabledBorder(g, x, y, w - 1, h - 1);
    }
    else
    {
      AbstractButton button = (AbstractButton)c;
      ButtonModel model = button.getModel();
      if ((model.isPressed()) && (model.isArmed())) {
        PlasticUtils.drawPressed3DBorder(g, x, y, w, h);
      } else if (model.isSelected()) {
        PlasticUtils.drawDark3DBorder(g, x, y, w, h);
      } else {
        PlasticUtils.drawFlush3DBorder(g, x, y, w, h);
      }
    }
  }
}

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

import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;
import javax.swing.border.AbstractBorder;
import javax.swing.plaf.UIResource;

final class PlasticBorders$ToolBarHeaderBorder
  extends AbstractBorder
  implements UIResource
{
  PlasticBorders$ToolBarHeaderBorder(PlasticBorders.1 x0)
  {
    this();
  }
  
  private static final Insets INSETS = new Insets(1, 2, 2, 2);
  
  public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
  {
    PlasticUtils.drawThinPressed3DBorder(g, x, y - 1, w, h + 1);
    PlasticUtils.drawThinFlush3DBorder(g, x + 1, y, w - 2, h - 1);
  }
  
  public Insets getBorderInsets(Component c)
  {
    return INSETS;
  }
  
  private PlasticBorders$ToolBarHeaderBorder() {}
}

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

import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;
import javax.swing.AbstractButton;
import javax.swing.ButtonModel;
import javax.swing.JButton;
import javax.swing.JInternalFrame;
import javax.swing.JMenuItem;
import javax.swing.JToggleButton;
import javax.swing.UIManager;
import javax.swing.border.AbstractBorder;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.plaf.BorderUIResource;
import javax.swing.plaf.BorderUIResource.CompoundBorderUIResource;
import javax.swing.plaf.UIResource;
import javax.swing.plaf.basic.BasicBorders.MarginBorder;
import javax.swing.plaf.metal.MetalBorders.ScrollPaneBorder;
import javax.swing.text.JTextComponent;

final class PlasticBorders
{
  private static Border comboBoxEditorBorder;
  private static Border comboBoxArrowButtonBorder;
  private static Border etchedBorder;
  private static Border flush3DBorder;
  private static Border menuBarHeaderBorder;
  private static Border menuBorder;
  private static Border menuItemBorder;
  private static Border popupMenuBorder;
  private static Border noMarginPopupMenuBorder;
  private static Border rolloverButtonBorder;
  private static Border scrollPaneBorder;
  private static Border separatorBorder;
  private static Border textFieldBorder;
  private static Border thinLoweredBorder;
  private static Border thinRaisedBorder;
  private static Border toolBarHeaderBorder;
  
  static Border getButtonBorder(Insets buttonMargin)
  {
    return new BorderUIResource.CompoundBorderUIResource(new ButtonBorder(buttonMargin), new BasicBorders.MarginBorder());
  }
  
  static Border getComboBoxArrowButtonBorder()
  {
    if (comboBoxArrowButtonBorder == null) {
      comboBoxArrowButtonBorder = new CompoundBorder(new ComboBoxArrowButtonBorder(null), new BasicBorders.MarginBorder());
    }
    return comboBoxArrowButtonBorder;
  }
  
  static Border getComboBoxEditorBorder()
  {
    if (comboBoxEditorBorder == null) {
      comboBoxEditorBorder = new CompoundBorder(new ComboBoxEditorBorder(null), new BasicBorders.MarginBorder());
    }
    return comboBoxEditorBorder;
  }
  
  static Border getEtchedBorder()
  {
    if (etchedBorder == null) {
      etchedBorder = new BorderUIResource.CompoundBorderUIResource(new EtchedBorder(null), new BasicBorders.MarginBorder());
    }
    return etchedBorder;
  }
  
  static Border getFlush3DBorder()
  {
    if (flush3DBorder == null) {
      flush3DBorder = new Flush3DBorder(null);
    }
    return flush3DBorder;
  }
  
  static Border getInternalFrameBorder()
  {
    return new InternalFrameBorder(null);
  }
  
  static Border getMenuBarHeaderBorder()
  {
    if (menuBarHeaderBorder == null) {
      menuBarHeaderBorder = new BorderUIResource.CompoundBorderUIResource(new MenuBarHeaderBorder(null), new BasicBorders.MarginBorder());
    }
    return menuBarHeaderBorder;
  }
  
  static Border getMenuBorder()
  {
    if (menuBorder == null) {
      menuBorder = new BorderUIResource.CompoundBorderUIResource(new MenuBorder(null), new BasicBorders.MarginBorder());
    }
    return menuBorder;
  }
  
  static Border getMenuItemBorder()
  {
    if (menuItemBorder == null) {
      menuItemBorder = new BorderUIResource(new BasicBorders.MarginBorder());
    }
    return menuItemBorder;
  }
  
  static Border getPopupMenuBorder()
  {
    if (popupMenuBorder == null) {
      popupMenuBorder = new PopupMenuBorder(null);
    }
    return popupMenuBorder;
  }
  
  static Border getNoMarginPopupMenuBorder()
  {
    if (noMarginPopupMenuBorder == null) {
      noMarginPopupMenuBorder = new NoMarginPopupMenuBorder(null);
    }
    return noMarginPopupMenuBorder;
  }
  
  static Border getPaletteBorder()
  {
    return new PaletteBorder(null);
  }
  
  static Border getRolloverButtonBorder()
  {
    if (rolloverButtonBorder == null) {
      rolloverButtonBorder = new CompoundBorder(new RolloverButtonBorder(null), new RolloverMarginBorder());
    }
    return rolloverButtonBorder;
  }
  
  static Border getScrollPaneBorder()
  {
    if (scrollPaneBorder == null) {
      scrollPaneBorder = new ScrollPaneBorder(null);
    }
    return scrollPaneBorder;
  }
  
  static Border getSeparatorBorder()
  {
    if (separatorBorder == null) {
      separatorBorder = new BorderUIResource.CompoundBorderUIResource(new SeparatorBorder(null), new BasicBorders.MarginBorder());
    }
    return separatorBorder;
  }
  
  static Border getTextFieldBorder()
  {
    if (textFieldBorder == null) {
      textFieldBorder = new BorderUIResource.CompoundBorderUIResource(new TextFieldBorder(null), new BasicBorders.MarginBorder());
    }
    return textFieldBorder;
  }
  
  static Border getThinLoweredBorder()
  {
    if (thinLoweredBorder == null) {
      thinLoweredBorder = new ThinLoweredBorder(null);
    }
    return thinLoweredBorder;
  }
  
  static Border getThinRaisedBorder()
  {
    if (thinRaisedBorder == null) {
      thinRaisedBorder = new ThinRaisedBorder(null);
    }
    return thinRaisedBorder;
  }
  
  static Border getToggleButtonBorder(Insets buttonMargin)
  {
    return new BorderUIResource.CompoundBorderUIResource(new ToggleButtonBorder(buttonMargin, null), new BasicBorders.MarginBorder());
  }
  
  static Border getToolBarHeaderBorder()
  {
    if (toolBarHeaderBorder == null) {
      toolBarHeaderBorder = new BorderUIResource.CompoundBorderUIResource(new ToolBarHeaderBorder(null), new BasicBorders.MarginBorder());
    }
    return toolBarHeaderBorder;
  }
  
  private static class Flush3DBorder
    extends AbstractBorder
    implements UIResource
  {
    Flush3DBorder(PlasticBorders.1 x0)
    {
      this();
    }
    
    private static final Insets INSETS = new Insets(2, 2, 2, 2);
    
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
    {
      if (c.isEnabled()) {
        PlasticUtils.drawFlush3DBorder(g, x, y, w, h);
      } else {
        PlasticUtils.drawDisabledBorder(g, x, y, w, h);
      }
    }
    
    public Insets getBorderInsets(Component c)
    {
      return INSETS;
    }
    
    public Insets getBorderInsets(Component c, Insets newInsets)
    {
      top = INSETStop;
      left = INSETSleft;
      bottom = INSETSbottom;
      right = INSETSright;
      return newInsets;
    }
    
    private Flush3DBorder() {}
  }
  
  private static class ButtonBorder
    extends AbstractBorder
    implements UIResource
  {
    protected final Insets insets;
    
    protected ButtonBorder(Insets insets)
    {
      this.insets = insets;
    }
    
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
    {
      AbstractButton button = (AbstractButton)c;
      ButtonModel model = button.getModel();
      if (model.isEnabled())
      {
        boolean isPressed = (model.isPressed()) && (model.isArmed());
        boolean isDefault = ((button instanceof JButton)) && (((JButton)button).isDefaultButton());
        if ((isPressed) && (isDefault)) {
          PlasticUtils.drawDefaultButtonPressedBorder(g, x, y, w, h);
        } else if (isPressed) {
          PlasticUtils.drawPressed3DBorder(g, x, y, w, h);
        } else if (isDefault) {
          PlasticUtils.drawDefaultButtonBorder(g, x, y, w, h, false);
        } else {
          PlasticUtils.drawButtonBorder(g, x, y, w, h, false);
        }
      }
      else
      {
        PlasticUtils.drawDisabledBorder(g, x, y, w - 1, h - 1);
      }
    }
    
    public Insets getBorderInsets(Component c)
    {
      return insets;
    }
    
    public Insets getBorderInsets(Component c, Insets newInsets)
    {
      top = insets.top;
      left = insets.left;
      bottom = insets.bottom;
      right = insets.right;
      return newInsets;
    }
  }
  
  private static final class ComboBoxArrowButtonBorder
    extends AbstractBorder
    implements UIResource
  {
    ComboBoxArrowButtonBorder(PlasticBorders.1 x0)
    {
      this();
    }
    
    protected static final Insets INSETS = new Insets(1, 1, 1, 1);
    
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
    {
      AbstractButton button = (AbstractButton)c;
      ButtonModel model = button.getModel();
      if (model.isEnabled())
      {
        boolean isPressed = (model.isPressed()) && (model.isArmed());
        if (isPressed) {
          PlasticUtils.drawPressed3DBorder(g, x, y, w, h);
        } else {
          PlasticUtils.drawButtonBorder(g, x, y, w, h, false);
        }
      }
      else
      {
        PlasticUtils.drawDisabledBorder(g, x, y, w - 1, h - 1);
      }
    }
    
    public Insets getBorderInsets(Component c)
    {
      return INSETS;
    }
    
    private ComboBoxArrowButtonBorder() {}
  }
  
  private static final class ComboBoxEditorBorder
    extends AbstractBorder
  {
    ComboBoxEditorBorder(PlasticBorders.1 x0)
    {
      this();
    }
    
    private static final Insets INSETS = new Insets(2, 2, 2, 0);
    
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
    {
      if (c.isEnabled())
      {
        PlasticUtils.drawFlush3DBorder(g, x, y, w + 2, h);
      }
      else
      {
        PlasticUtils.drawDisabledBorder(g, x, y, w + 2, h - 1);
        g.setColor(UIManager.getColor("control"));
        g.drawLine(x, y + h - 1, x + w, y + h - 1);
      }
    }
    
    public Insets getBorderInsets(Component c)
    {
      return INSETS;
    }
    
    private ComboBoxEditorBorder() {}
  }
  
  private static final class InternalFrameBorder
    extends AbstractBorder
    implements UIResource
  {
    InternalFrameBorder(PlasticBorders.1 x0)
    {
      this();
    }
    
    private static final Insets NORMAL_INSETS = new Insets(1, 1, 1, 1);
    private static final Insets MAXIMIZED_INSETS = new Insets(1, 1, 0, 0);
    
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
    {
      JInternalFrame frame = (JInternalFrame)c;
      if (frame.isMaximum()) {
        paintMaximizedBorder(g, x, y, w, h);
      } else {
        PlasticUtils.drawThinFlush3DBorder(g, x, y, w, h);
      }
    }
    
    private void paintMaximizedBorder(Graphics g, int x, int y, int w, int h)
    {
      g.translate(x, y);
      g.setColor(PlasticLookAndFeel.getControlHighlight());
      g.drawLine(0, 0, w - 2, 0);
      g.drawLine(0, 0, 0, h - 2);
      g.translate(-x, -y);
    }
    
    public Insets getBorderInsets(Component c)
    {
      return ((JInternalFrame)c).isMaximum() ? MAXIMIZED_INSETS : NORMAL_INSETS;
    }
    
    private InternalFrameBorder() {}
  }
  
  private static final class PaletteBorder
    extends AbstractBorder
    implements UIResource
  {
    PaletteBorder(PlasticBorders.1 x0)
    {
      this();
    }
    
    private static final Insets INSETS = new Insets(1, 1, 1, 1);
    
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
    {
      g.translate(x, y);
      g.setColor(PlasticLookAndFeel.getControlDarkShadow());
      g.drawRect(0, 0, w - 1, h - 1);
      g.translate(-x, -y);
    }
    
    public Insets getBorderInsets(Component c)
    {
      return INSETS;
    }
    
    private PaletteBorder() {}
  }
  
  private static final class SeparatorBorder
    extends AbstractBorder
    implements UIResource
  {
    SeparatorBorder(PlasticBorders.1 x0)
    {
      this();
    }
    
    private static final Insets INSETS = new Insets(0, 0, 2, 1);
    
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
    {
      g.translate(x, y);
      g.setColor(UIManager.getColor("Separator.foreground"));
      g.drawLine(0, h - 2, w - 1, h - 2);
      
      g.setColor(UIManager.getColor("Separator.background"));
      g.drawLine(0, h - 1, w - 1, h - 1);
      g.translate(-x, -y);
    }
    
    public Insets getBorderInsets(Component c)
    {
      return INSETS;
    }
    
    private SeparatorBorder() {}
  }
  
  private static final class ThinRaisedBorder
    extends AbstractBorder
    implements UIResource
  {
    ThinRaisedBorder(PlasticBorders.1 x0)
    {
      this();
    }
    
    private static final Insets INSETS = new Insets(2, 2, 2, 2);
    
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
    {
      PlasticUtils.drawThinFlush3DBorder(g, x, y, w, h);
    }
    
    public Insets getBorderInsets(Component c)
    {
      return INSETS;
    }
    
    private ThinRaisedBorder() {}
  }
  
  private static final class ThinLoweredBorder
    extends AbstractBorder
    implements UIResource
  {
    ThinLoweredBorder(PlasticBorders.1 x0)
    {
      this();
    }
    
    private static final Insets INSETS = new Insets(2, 2, 2, 2);
    
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
    {
      PlasticUtils.drawThinPressed3DBorder(g, x, y, w, h);
    }
    
    public Insets getBorderInsets(Component c)
    {
      return INSETS;
    }
    
    private ThinLoweredBorder() {}
  }
  
  private static final class EtchedBorder
    extends AbstractBorder
    implements UIResource
  {
    EtchedBorder(PlasticBorders.1 x0)
    {
      this();
    }
    
    private static final Insets INSETS = new Insets(2, 2, 2, 2);
    
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
    {
      PlasticUtils.drawThinPressed3DBorder(g, x, y, w, h);
      PlasticUtils.drawThinFlush3DBorder(g, x + 1, y + 1, w - 2, h - 2);
    }
    
    public Insets getBorderInsets(Component c)
    {
      return INSETS;
    }
    
    private EtchedBorder() {}
  }
  
  private static final class MenuBarHeaderBorder
    extends AbstractBorder
    implements UIResource
  {
    MenuBarHeaderBorder(PlasticBorders.1 x0)
    {
      this();
    }
    
    private static final Insets INSETS = new Insets(2, 2, 1, 2);
    
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
    {
      PlasticUtils.drawThinPressed3DBorder(g, x, y, w, h + 1);
      PlasticUtils.drawThinFlush3DBorder(g, x + 1, y + 1, w - 2, h - 1);
    }
    
    public Insets getBorderInsets(Component c)
    {
      return INSETS;
    }
    
    private MenuBarHeaderBorder() {}
  }
  
  private static final class ToolBarHeaderBorder
    extends AbstractBorder
    implements UIResource
  {
    ToolBarHeaderBorder(PlasticBorders.1 x0)
    {
      this();
    }
    
    private static final Insets INSETS = new Insets(1, 2, 2, 2);
    
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
    {
      PlasticUtils.drawThinPressed3DBorder(g, x, y - 1, w, h + 1);
      PlasticUtils.drawThinFlush3DBorder(g, x + 1, y, w - 2, h - 1);
    }
    
    public Insets getBorderInsets(Component c)
    {
      return INSETS;
    }
    
    private ToolBarHeaderBorder() {}
  }
  
  private static final class MenuBorder
    extends AbstractBorder
    implements UIResource
  {
    MenuBorder(PlasticBorders.1 x0)
    {
      this();
    }
    
    private static final Insets INSETS = new Insets(2, 2, 2, 2);
    
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
    {
      JMenuItem b = (JMenuItem)c;
      ButtonModel model = b.getModel();
      if ((model.isArmed()) || (model.isSelected()))
      {
        g.setColor(PlasticLookAndFeel.getControlDarkShadow());
        g.drawLine(0, 0, w - 2, 0);
        g.drawLine(0, 0, 0, h - 1);
        
        g.setColor(PlasticLookAndFeel.getPrimaryControlHighlight());
        g.drawLine(w - 1, 0, w - 1, h - 1);
      }
      else if (model.isRollover())
      {
        g.translate(x, y);
        PlasticUtils.drawFlush3DBorder(g, x, y, w, h);
        g.translate(-x, -y);
      }
    }
    
    public Insets getBorderInsets(Component c)
    {
      return INSETS;
    }
    
    public Insets getBorderInsets(Component c, Insets newInsets)
    {
      top = INSETStop;
      left = INSETSleft;
      bottom = INSETSbottom;
      right = INSETSright;
      return newInsets;
    }
    
    private MenuBorder() {}
  }
  
  private static final class PopupMenuBorder
    extends AbstractBorder
    implements UIResource
  {
    PopupMenuBorder(PlasticBorders.1 x0)
    {
      this();
    }
    
    private static final Insets INSETS = new Insets(3, 3, 3, 3);
    
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
    {
      g.translate(x, y);
      g.setColor(PlasticLookAndFeel.getControlDarkShadow());
      g.drawRect(0, 0, w - 1, h - 1);
      g.setColor(PlasticLookAndFeel.getMenuItemBackground());
      g.drawRect(1, 1, w - 3, h - 3);
      g.drawRect(2, 2, w - 5, h - 5);
      g.translate(-x, -y);
    }
    
    public Insets getBorderInsets(Component c)
    {
      return INSETS;
    }
    
    private PopupMenuBorder() {}
  }
  
  private static final class NoMarginPopupMenuBorder
    extends AbstractBorder
    implements UIResource
  {
    NoMarginPopupMenuBorder(PlasticBorders.1 x0)
    {
      this();
    }
    
    private static final Insets INSETS = new Insets(1, 1, 1, 1);
    
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
    {
      g.translate(x, y);
      g.setColor(PlasticLookAndFeel.getControlDarkShadow());
      g.drawRect(0, 0, w - 1, h - 1);
      g.translate(-x, -y);
    }
    
    public Insets getBorderInsets(Component c)
    {
      return INSETS;
    }
    
    private NoMarginPopupMenuBorder() {}
  }
  
  private static class RolloverButtonBorder
    extends PlasticBorders.ButtonBorder
  {
    RolloverButtonBorder(PlasticBorders.1 x0)
    {
      this();
    }
    
    private RolloverButtonBorder()
    {
      super();
    }
    
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
    {
      AbstractButton b = (AbstractButton)c;
      ButtonModel model = b.getModel();
      if (!model.isEnabled()) {
        return;
      }
      if (!(c instanceof JToggleButton))
      {
        if ((model.isRollover()) && ((!model.isPressed()) || (model.isArmed()))) {
          super.paintBorder(c, g, x, y, w, h);
        }
        return;
      }
      if (model.isRollover())
      {
        if ((model.isPressed()) && (model.isArmed())) {
          PlasticUtils.drawPressed3DBorder(g, x, y, w, h);
        } else {
          PlasticUtils.drawFlush3DBorder(g, x, y, w, h);
        }
      }
      else if (model.isSelected()) {
        PlasticUtils.drawDark3DBorder(g, x, y, w, h);
      }
    }
  }
  
  static final class RolloverMarginBorder
    extends EmptyBorder
  {
    RolloverMarginBorder()
    {
      super(1, 1, 1);
    }
    
    public Insets getBorderInsets(Component c)
    {
      return getBorderInsets(c, new Insets(0, 0, 0, 0));
    }
    
    public Insets getBorderInsets(Component c, Insets insets)
    {
      Insets margin = null;
      if ((c instanceof AbstractButton)) {
        margin = ((AbstractButton)c).getMargin();
      }
      if ((margin == null) || ((margin instanceof UIResource)))
      {
        left = left;
        top = top;
        right = right;
        bottom = bottom;
      }
      else
      {
        left = left;
        top = top;
        right = right;
        bottom = bottom;
      }
      return insets;
    }
  }
  
  private static final class ScrollPaneBorder
    extends MetalBorders.ScrollPaneBorder
  {
    ScrollPaneBorder(PlasticBorders.1 x0)
    {
      this();
    }
    
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
    {
      g.translate(x, y);
      
      g.setColor(PlasticLookAndFeel.getControlDarkShadow());
      g.drawRect(0, 0, w - 2, h - 2);
      g.setColor(PlasticLookAndFeel.getControlHighlight());
      g.drawLine(w - 1, 0, w - 1, h - 1);
      g.drawLine(0, h - 1, w - 1, h - 1);
      
      g.translate(-x, -y);
    }
    
    private ScrollPaneBorder() {}
  }
  
  private static final class TextFieldBorder
    extends PlasticBorders.Flush3DBorder
  {
    private TextFieldBorder()
    {
      super();
    }
    
    TextFieldBorder(PlasticBorders.1 x0)
    {
      this();
    }
    
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
    {
      if (!(c instanceof JTextComponent))
      {
        if (c.isEnabled()) {
          PlasticUtils.drawFlush3DBorder(g, x, y, w, h);
        } else {
          PlasticUtils.drawDisabledBorder(g, x, y, w, h);
        }
        return;
      }
      if ((c.isEnabled()) && (((JTextComponent)c).isEditable())) {
        PlasticUtils.drawFlush3DBorder(g, x, y, w, h);
      } else {
        PlasticUtils.drawDisabledBorder(g, x, y, w, h);
      }
    }
  }
  
  private static final class ToggleButtonBorder
    extends PlasticBorders.ButtonBorder
  {
    ToggleButtonBorder(Insets x0, PlasticBorders.1 x1)
    {
      this(x0);
    }
    
    private ToggleButtonBorder(Insets insets)
    {
      super();
    }
    
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
    {
      if (!c.isEnabled())
      {
        PlasticUtils.drawDisabledBorder(g, x, y, w - 1, h - 1);
      }
      else
      {
        AbstractButton button = (AbstractButton)c;
        ButtonModel model = button.getModel();
        if ((model.isPressed()) && (model.isArmed())) {
          PlasticUtils.drawPressed3DBorder(g, x, y, w, h);
        } else if (model.isSelected()) {
          PlasticUtils.drawDark3DBorder(g, x, y, w, h);
        } else {
          PlasticUtils.drawFlush3DBorder(g, x, y, w, h);
        }
      }
    }
  }
}

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

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.util.Enumeration;
import java.util.Vector;
import javax.swing.Icon;

final class PlasticBumps
  implements Icon
{
  protected int xBumps;
  protected int yBumps;
  protected Color topColor;
  protected Color shadowColor;
  protected Color backColor;
  protected static Vector buffers = new Vector();
  protected BumpBuffer buffer;
  
  public PlasticBumps(Dimension bumpArea)
  {
    this(width, height);
  }
  
  public PlasticBumps(int width, int height)
  {
    this(width, height, PlasticLookAndFeel.getPrimaryControlHighlight(), PlasticLookAndFeel.getPrimaryControlDarkShadow(), PlasticLookAndFeel.getPrimaryControlShadow());
  }
  
  public PlasticBumps(int width, int height, Color newTopColor, Color newShadowColor, Color newBackColor)
  {
    setBumpArea(width, height);
    setBumpColors(newTopColor, newShadowColor, newBackColor);
  }
  
  private BumpBuffer getBuffer(GraphicsConfiguration gc, Color aTopColor, Color aShadowColor, Color aBackColor)
  {
    if ((buffer != null) && (buffer.hasSameConfiguration(gc, aTopColor, aShadowColor, aBackColor))) {
      return buffer;
    }
    BumpBuffer result = null;
    Enumeration elements = buffers.elements();
    while (elements.hasMoreElements())
    {
      BumpBuffer aBuffer = (BumpBuffer)elements.nextElement();
      if (aBuffer.hasSameConfiguration(gc, aTopColor, aShadowColor, aBackColor))
      {
        result = aBuffer;
        break;
      }
    }
    if (result == null)
    {
      result = new BumpBuffer(gc, topColor, shadowColor, backColor);
      buffers.addElement(result);
    }
    return result;
  }
  
  public void setBumpArea(Dimension bumpArea)
  {
    setBumpArea(width, height);
  }
  
  public void setBumpArea(int width, int height)
  {
    xBumps = (width / 2);
    yBumps = (height / 2);
  }
  
  public void setBumpColors(Color newTopColor, Color newShadowColor, Color newBackColor)
  {
    topColor = newTopColor;
    shadowColor = newShadowColor;
    backColor = newBackColor;
  }
  
  public void paintIcon(Component c, Graphics g, int x, int y)
  {
    GraphicsConfiguration gc = (g instanceof Graphics2D) ? ((Graphics2D)g).getDeviceConfiguration() : null;
    
    buffer = getBuffer(gc, topColor, shadowColor, backColor);
    
    int bufferWidth = buffer.getImageSize().width;
    int bufferHeight = buffer.getImageSize().height;
    int iconWidth = getIconWidth();
    int iconHeight = getIconHeight();
    int x2 = x + iconWidth;
    int y2 = y + iconHeight;
    int savex = x;
    while (y < y2)
    {
      int h = Math.min(y2 - y, bufferHeight);
      for (x = savex; x < x2; x += bufferWidth)
      {
        int w = Math.min(x2 - x, bufferWidth);
        g.drawImage(buffer.getImage(), x, y, x + w, y + h, 0, 0, w, h, null);
      }
      y += bufferHeight;
    }
  }
  
  public int getIconWidth()
  {
    return xBumps * 2;
  }
  
  public int getIconHeight()
  {
    return yBumps * 2;
  }
}

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

import java.awt.Container;
import java.awt.Graphics;
import java.awt.Rectangle;
import javax.swing.AbstractButton;
import javax.swing.ButtonModel;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JToolBar;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.metal.MetalButtonUI;

public class PlasticButtonUI
  extends MetalButtonUI
{
  private static final PlasticButtonUI INSTANCE = new PlasticButtonUI();
  private boolean borderPaintsFocus;
  
  public static ComponentUI createUI(JComponent b)
  {
    return INSTANCE;
  }
  
  public void installDefaults(AbstractButton b)
  {
    super.installDefaults(b);
    borderPaintsFocus = Boolean.TRUE.equals(UIManager.get("Button.borderPaintsFocus"));
  }
  
  public void update(Graphics g, JComponent c)
  {
    if (c.isOpaque())
    {
      AbstractButton b = (AbstractButton)c;
      if (isToolBarButton(b))
      {
        c.setOpaque(false);
      }
      else if (b.isContentAreaFilled())
      {
        g.setColor(c.getBackground());
        g.fillRect(0, 0, c.getWidth(), c.getHeight());
        if (is3D(b))
        {
          Rectangle r = new Rectangle(1, 1, c.getWidth() - 2, c.getHeight() - 1);
          
          PlasticUtils.add3DEffekt(g, r);
        }
      }
    }
    paint(g, c);
  }
  
  protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect)
  {
    if (borderPaintsFocus) {
      return;
    }
    boolean isDefault = ((b instanceof JButton)) && (((JButton)b).isDefaultButton());
    
    int topLeftInset = isDefault ? 3 : 2;
    int width = b.getWidth() - 1 - topLeftInset * 2;
    int height = b.getHeight() - 1 - topLeftInset * 2;
    
    g.setColor(getFocusColor());
    g.drawRect(topLeftInset, topLeftInset, width - 1, height - 1);
  }
  
  protected boolean isToolBarButton(AbstractButton b)
  {
    Container parent = b.getParent();
    return (parent != null) && (((parent instanceof JToolBar)) || ((parent.getParent() instanceof JToolBar)));
  }
  
  protected boolean is3D(AbstractButton b)
  {
    if (PlasticUtils.force3D(b)) {
      return true;
    }
    if (PlasticUtils.forceFlat(b)) {
      return false;
    }
    ButtonModel model = b.getModel();
    return (PlasticUtils.is3D("Button.")) && (b.isBorderPainted()) && (model.isEnabled()) && ((!model.isPressed()) || (!model.isArmed()));
  }
}

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

import javax.swing.DefaultButtonModel;

final class PlasticComboBoxButton$1
  extends DefaultButtonModel
{
  private final PlasticComboBoxButton this$0;
  
  PlasticComboBoxButton$1(PlasticComboBoxButton paramPlasticComboBoxButton) {}
  
  public void setArmed(boolean armed)
  {
    super.setArmed((isPressed()) || (armed));
  }
}

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

import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;
import javax.swing.ButtonModel;
import javax.swing.CellRendererPane;
import javax.swing.DefaultButtonModel;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.plaf.basic.BasicComboBoxRenderer.UIResource;

final class PlasticComboBoxButton
  extends JButton
{
  private static final Insets EMPTY_INSETS = new Insets(0, 0, 0, 0);
  private static final Border EMPTY_BORDER = new EmptyBorder(EMPTY_INSETS);
  private static final int LEFT_MARGIN = 2;
  private static final int RIGHT_MARGIN = 2;
  private final JList listBox;
  private final CellRendererPane rendererPane;
  private JComboBox comboBox;
  private Icon comboIcon;
  private boolean iconOnly = false;
  private final boolean borderPaintsFocus;
  
  PlasticComboBoxButton(JComboBox comboBox, Icon comboIcon, boolean iconOnly, CellRendererPane rendererPane, JList listBox)
  {
    super("");
    setModel(new DefaultButtonModel()
    {
      public void setArmed(boolean armed)
      {
        super.setArmed((isPressed()) || (armed));
      }
    });
    this.comboBox = comboBox;
    this.comboIcon = comboIcon;
    this.iconOnly = iconOnly;
    this.rendererPane = rendererPane;
    this.listBox = listBox;
    setEnabled(comboBox.isEnabled());
    setFocusable(false);
    setRequestFocusEnabled(comboBox.isEnabled());
    setBorder(UIManager.getBorder("ComboBox.arrowButtonBorder"));
    setMargin(new Insets(0, 2, 0, 2));
    borderPaintsFocus = UIManager.getBoolean("ComboBox.borderPaintsFocus");
  }
  
  public JComboBox getComboBox()
  {
    return comboBox;
  }
  
  public void setComboBox(JComboBox cb)
  {
    comboBox = cb;
  }
  
  public Icon getComboIcon()
  {
    return comboIcon;
  }
  
  public void setComboIcon(Icon i)
  {
    comboIcon = i;
  }
  
  public boolean isIconOnly()
  {
    return iconOnly;
  }
  
  public void setIconOnly(boolean b)
  {
    iconOnly = b;
  }
  
  public void setEnabled(boolean enabled)
  {
    super.setEnabled(enabled);
    if (enabled)
    {
      setBackground(comboBox.getBackground());
      setForeground(comboBox.getForeground());
    }
    else
    {
      setBackground(UIManager.getColor("ComboBox.disabledBackground"));
      setForeground(UIManager.getColor("ComboBox.disabledForeground"));
    }
  }
  
  public boolean isFocusTraversable()
  {
    return false;
  }
  
  public void paintComponent(Graphics g)
  {
    super.paintComponent(g);
    boolean leftToRight = PlasticUtils.isLeftToRight(comboBox);
    Insets insets = getInsets();
    int width = getWidth() - (left + right);
    int height = getHeight() - (top + bottom);
    if ((height <= 0) || (width <= 0)) {
      return;
    }
    int left = left;
    int top = top;
    int right = left + (width - 1);
    
    int iconWidth = 0;
    int iconLeft = leftToRight ? right : left;
    if (comboIcon != null)
    {
      iconWidth = comboIcon.getIconWidth();
      int iconHeight = comboIcon.getIconHeight();
      int iconTop;
      int iconTop;
      if (iconOnly)
      {
        iconLeft = (getWidth() - iconWidth) / 2;
        iconTop = (getHeight() - iconHeight) / 2;
      }
      else
      {
        iconLeft = leftToRight ? left + (width - 1) - iconWidth : left;
        
        iconTop = (getHeight() - iconHeight) / 2;
      }
      comboIcon.paintIcon(this, g, iconLeft, iconTop);
    }
    if ((!iconOnly) && (comboBox != null))
    {
      ListCellRenderer renderer = comboBox.getRenderer();
      boolean renderPressed = getModel().isPressed();
      Component c = renderer.getListCellRendererComponent(listBox, comboBox.getSelectedItem(), -1, renderPressed, false);
      
      int x = leftToRight ? left : left + iconWidth;
      int y = top;
      int w = getWidth() - left - PlasticComboBoxUI.getEditableButtonWidth();
      int h = height;
      
      Border oldBorder = null;
      if (((c instanceof JComponent)) && (!isTableCellEditor()))
      {
        JComponent component = (JComponent)c;
        if ((c instanceof BasicComboBoxRenderer.UIResource))
        {
          oldBorder = component.getBorder();
          component.setBorder(EMPTY_BORDER);
        }
        Insets rendererInsets = component.getInsets();
        Insets editorInsets = UIManager.getInsets("ComboBox.editorInsets");
        int offsetTop = Math.max(0, top - top);
        int offsetBottom = Math.max(0, bottom - bottom);
        y += offsetTop;
        h -= offsetTop + offsetBottom;
      }
      c.setFont(rendererPane.getFont());
      configureColors(c);
      
      boolean shouldValidate = c instanceof JPanel;
      if ((!is3D()) || (!(c instanceof JComponent)) || (!c.isOpaque()))
      {
        rendererPane.paintComponent(g, c, this, x, y, w, h, shouldValidate);
      }
      else
      {
        JComponent component = (JComponent)c;
        boolean oldOpaque = component.isOpaque();
        component.setOpaque(false);
        rendererPane.paintComponent(g, c, this, x, y, w, h, shouldValidate);
        component.setOpaque(oldOpaque);
      }
      if (oldBorder != null) {
        ((JComponent)c).setBorder(oldBorder);
      }
    }
    if (comboIcon != null)
    {
      boolean hasFocus = comboBox.hasFocus();
      if ((!borderPaintsFocus) && (hasFocus))
      {
        g.setColor(PlasticLookAndFeel.getFocusColor());
        g.drawRect(2, 2, getWidth() - 6, getHeight() - 6);
      }
    }
  }
  
  private void configureColors(Component c)
  {
    if ((model.isArmed()) && (model.isPressed()))
    {
      if (isOpaque()) {
        c.setBackground(UIManager.getColor("Button.select"));
      }
      c.setForeground(comboBox.getForeground());
    }
    else if (!comboBox.isEnabled())
    {
      if (isOpaque()) {
        c.setBackground(UIManager.getColor("ComboBox.disabledBackground"));
      }
      c.setForeground(UIManager.getColor("ComboBox.disabledForeground"));
    }
    else
    {
      c.setForeground(comboBox.getForeground());
      c.setBackground(comboBox.getBackground());
    }
  }
  
  private boolean is3D()
  {
    if (PlasticUtils.force3D(comboBox)) {
      return true;
    }
    if (PlasticUtils.forceFlat(comboBox)) {
      return false;
    }
    return PlasticUtils.is3D("ComboBox.");
  }
  
  private boolean isTableCellEditor()
  {
    return Boolean.TRUE.equals(comboBox.getClientProperty("JComboBox.isTableCellEditor"));
  }
}

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

import javax.swing.plaf.UIResource;

final class PlasticComboBoxEditor$UIResource
  extends PlasticComboBoxEditor
  implements UIResource
{
  PlasticComboBoxEditor$UIResource(boolean isTableCellEditor)
  {
    super(isTableCellEditor);
  }
}

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

import com.jgoodies.looks.common.ComboBoxEditorTextField;
import javax.swing.JTextField;
import javax.swing.plaf.UIResource;
import javax.swing.plaf.basic.BasicComboBoxEditor;

class PlasticComboBoxEditor
  extends BasicComboBoxEditor
{
  PlasticComboBoxEditor(boolean isTableCellEditor)
  {
    editor = new ComboBoxEditorTextField(isTableCellEditor);
  }
  
  public void setItem(Object item)
  {
    super.setItem(item);
    editor.selectAll();
  }
  
  static final class UIResource
    extends PlasticComboBoxEditor
    implements UIResource
  {
    UIResource(boolean isTableCellEditor)
    {
      super();
    }
  }
}

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

class PlasticComboBoxUI$1 {}

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

import java.awt.Component;
import java.awt.ComponentOrientation;
import java.awt.Container;
import java.awt.Insets;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.plaf.metal.MetalComboBoxUI.MetalComboBoxLayoutManager;

final class PlasticComboBoxUI$PlasticComboBoxLayoutManager
  extends MetalComboBoxUI.MetalComboBoxLayoutManager
{
  private final PlasticComboBoxUI this$0;
  
  private PlasticComboBoxUI$PlasticComboBoxLayoutManager(PlasticComboBoxUI paramPlasticComboBoxUI
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-2017. Infinite Loop Ltd