Update of /cvsroot/squirrel-sql/mavenize/thirdparty-non-maven/tinylaf-1_4_0/src/de/muntjak/tinylookandfeel
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv29130/thirdparty-non-maven/tinylaf-1_4_0/src/de/muntjak/tinylookandfeel
Added Files:
TinyRootPaneUI.java TinyRadioButtonMenuItemUI.java
TinyMenuItemUI.java TinyUtils.java TinyTextAreaUI.java
TinyTabbedPaneUI.java overview.html
TinyToolBarSeparatorUI.java TinySplitPaneDivider.java
ThemeDescription.java LinuxFontMappings.properties
TinyRadioButtonUI.java package.html TinyDirectoryModel.java
TinyComboBoxEditor.java TinyWindowButtonUI.java
TinySpinnerButtonUI.java TinyFileChooserUI.java
TinyTitlePane.java TinySplitPaneUI.java TinyTableHeaderUI.java
TinyCheckBoxUI.java TinyInternalFrameTitlePane.java
TinyTreeUI.java SpecialUIButton.java TinyTextFieldUI.java
TinySeparatorUI.java Theme.java TinyRadioButtonIcon.java
TinyComboBoxButton.java MenuItemIconFactory.java
TinyToolTipUI.java TinyLookAndFeel.java
TinyInternalFrameUI.java TinyButtonUI.java
TinyPopupFactory.java TinyTableUI.java
TinyPasswordFieldUI.java TinyMenuBarUI.java TinyLabelUI.java
TinySliderUI.java TinyDesktopPaneUI.java TinyScrollBarUI.java
TinyEditorPaneUI.java TinyTextPaneUI.java
TinyScrollPaneUI.java TinyScrollButton.java TinySpinnerUI.java
TinyToolBarUI.java TinyMenuUI.java MacFontMappings.properties
TinyListUI.java TinyFormattedTextFieldUI.java
TinyCheckBoxIcon.java TinyPopupMenuSeparatorUI.java
TinyCheckBoxMenuItemUI.java TinyDefaultTheme.java
TinyComboBoxUI.java TinyProgressBarUI.java
Log Message:
Source for thirdparty dependency. Maven central requires a valid source code repository for artifacts that it hosts. This project has none, so we host it here for the time being.
--- NEW FILE: TinyProgressBarUI.java ---
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This file is part of the Tiny Look and Feel *
* Copyright 2003 - 2008 Hans Bickel *
* *
* For licensing information and credits, please refer to the *
* comment in file de.muntjak.tinylookandfeel.TinyLookAndFeel *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
package de.muntjak.tinylookandfeel;
import java.awt.*;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.HashMap;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicGraphicsUtils;
import javax.swing.plaf.basic.BasicProgressBarUI;
import de.muntjak.tinylookandfeel.controlpanel.*;
import de.muntjak.tinylookandfeel.util.ColorRoutines;
/**
* TinyProgressBarUI
*
* @version 1.1
* @author Hans Bickel
*/
public class TinyProgressBarUI extends BasicProgressBarUI {
private static final HashMap cache = new HashMap();
/* "Override" the dimensions from BasicProgressBarUI */
private static final Dimension PREFERRED_YQ_HORIZONTAL = new Dimension(146, 7);
private static final Dimension PREFERRED_YQ_VERTICAL = new Dimension(7, 146);
public static void clearCache() {
cache.clear();
}
protected Dimension getPreferredInnerHorizontal() {
return PREFERRED_YQ_HORIZONTAL;
}
protected Dimension getPreferredInnerVertical() {
return PREFERRED_YQ_VERTICAL;
}
/**
* Creates the UI delegate for the given component.
*
* @param mainColor The component to create its UI delegate.
* @return The UI delegate for the given component.
*/
public static ComponentUI createUI(JComponent c) {
return new TinyProgressBarUI();
}
protected void paintDeterminate(Graphics g, JComponent c) {
Insets b = progressBar.getInsets(); // area for border
int barRectWidth = progressBar.getWidth() - (b.right + b.left);
int barRectHeight = progressBar.getHeight() - (b.top + b.bottom);
if(progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
int amountFull = getAmountFull(b, barRectWidth, barRectHeight);
drawXpHorzProgress(g, b.left, b.top, barRectWidth, barRectHeight, amountFull);
// Deal with possible text painting
if(progressBar.isStringPainted()) {
g.setFont(c.getFont());
paintString(g, b.left, b.top, barRectWidth, barRectHeight, amountFull, b);
}
}
else { // VERTICAL
int amountFull = getAmountFull(b, barRectWidth, barRectHeight);
drawXpVertProgress(g, b.left, b.top, barRectWidth, barRectHeight, amountFull);
// Deal with possible text painting
if(progressBar.isStringPainted()) {
g.setFont(c.getFont());
paintString(g, b.left, b.top, barRectWidth, barRectHeight, amountFull, b);
}
}
}
// draw determinate
private void drawXpHorzProgress(Graphics g, int x, int y,
int w, int h, int amountFull)
{
g.translate(x, y);
// paint the track
if(!progressBar.isOpaque()) {
g.setColor(progressBar.getBackground());
g.fillRect(0, 0, w, h);
}
ProgressKey key = new ProgressKey(
progressBar.getForeground(), true, h);
Object value = cache.get(key);
if(value == null) {
// create new image
Image img = new BufferedImage(6, h, BufferedImage.TYPE_INT_ARGB);
Graphics imgGraphics = img.getGraphics();
// draw into image graphics
Color c = progressBar.getForeground();
Color c2 = ColorRoutines.lighten(c, 15);
Color c3 = ColorRoutines.lighten(c, 35);
Color c4 = ColorRoutines.lighten(c, 60);
imgGraphics.setColor(c4);
imgGraphics.drawLine(0, 0, 5, 0);
imgGraphics.drawLine(0, h - 1, 5, h - 1);
imgGraphics.setColor(c3);
imgGraphics.drawLine(0, 1, 5, 1);
imgGraphics.drawLine(0, h - 2, 5, h - 2);
imgGraphics.setColor(c2);
imgGraphics.drawLine(0, 2, 5, 2);
imgGraphics.drawLine(0, h - 3, 5, h - 3);
imgGraphics.setColor(c);
imgGraphics.fillRect(0, 3, 6, h - 6);
// dispose of image graphics
imgGraphics.dispose();
cache.put(key, img);
value = img;
if(TinyLookAndFeel.PRINT_CACHE_SIZES) {
System.out.println("TinyProgressBarUI.cache.size=" + cache.size());
}
}
int mx = 0;
while(mx < amountFull) {
if(mx + 6 > w) {
// paint partially
g.drawImage((Image)value, mx, 0, w - mx, h, progressBar);
}
else {
g.drawImage((Image)value, mx, 0, progressBar);
}
mx += 8;
}
g.translate(-x, -y);
}
// draw determinate
private void drawXpVertProgress(Graphics g, int x, int y,
int w, int h, int amountFull)
{
g.translate(x, y);
// paint the track
if(!progressBar.isOpaque()) {
g.setColor(progressBar.getBackground());
g.fillRect(0, 0, w, h);
}
ProgressKey key = new ProgressKey(
progressBar.getForeground(), false, w);
Object value = cache.get(key);
if(value == null) {
// create new image
Image img = new BufferedImage(w, 6, BufferedImage.TYPE_INT_ARGB);
Graphics imgGraphics = img.getGraphics();
// draw into image graphics
Color c = progressBar.getForeground();
Color c2 = ColorRoutines.lighten(c, 15);
Color c3 = ColorRoutines.lighten(c, 35);
Color c4 = ColorRoutines.lighten(c, 60);
imgGraphics.setColor(c4);
imgGraphics.drawLine(0, 0, 0, 5);
imgGraphics.drawLine(w - 1, 0, w - 1, 5);
imgGraphics.setColor(c3);
imgGraphics.drawLine(1, 0, 1, 5);
imgGraphics.drawLine(w - 2, 0, w - 2, 5);
imgGraphics.setColor(c2);
imgGraphics.drawLine(2, 0, 2, 5);
imgGraphics.drawLine(w - 3, 0, w - 3, 5);
imgGraphics.setColor(c);
imgGraphics.fillRect(3, 0, w - 6, 6);
// dispose of image graphics
imgGraphics.dispose();
cache.put(key, img);
value = img;
if(TinyLookAndFeel.PRINT_CACHE_SIZES) {
System.out.println("TinyProgressBarUI.cache.size=" + cache.size());
}
}
// paints bottom to top...
int my = 0;
while(my < amountFull) {
if(my + 6 > h) {
// paint partially
g.drawImage((Image)value, 0,
0, w, h - my, progressBar);
}
else {
g.drawImage((Image)value, 0, h - my - 6, progressBar);
}
my += 8;
}
g.translate(-x, -y);
}
protected void paintIndeterminate(Graphics g, JComponent c) {
Insets b = progressBar.getInsets(); // area for border
int barRectWidth = progressBar.getWidth() - (b.right + b.left);
int barRectHeight = progressBar.getHeight() - (b.top + b.bottom);
Rectangle boxRect = new Rectangle();
try {
boxRect = getBox(boxRect);
} catch (NullPointerException ignore) {}
if(progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
drawXpHorzProgress(g, b.left, b.top, barRectWidth, barRectHeight, boxRect);
}
else {
drawXpVertProgress(g, b.left, b.top, barRectWidth, barRectHeight, boxRect);
}
// Deal with possible text painting
if(progressBar.isStringPainted()) {
if(progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
// paintString(g, b.left, b.top, barRectWidth, barRectHeight, boxRect.x, boxRect.width, b);
paintString(g, b.left, b.top, barRectWidth, barRectHeight, boxRect.width, b);
}
else {
// paintString(g, b.left, b.top, barRectWidth, barRectHeight, boxRect.y, boxRect.height, b);
paintString(g, b.left, b.top, barRectWidth, barRectHeight, boxRect.height, b);
}
}
}
// private void paintString(Graphics g, int x, int y, int width, int height, int fillStart, int amountFull, Insets b) {
// if(!(g instanceof Graphics2D)) return;
//
// Graphics2D g2d = (Graphics2D)g;
// String progressString = progressBar.getString();
// g2d.setFont(progressBar.getFont());
// Point renderLocation = getStringPlacement(g2d, progressString, x, y, width, height);
// Rectangle oldClip = g2d.getClipBounds();
//
// if(progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
// g2d.setColor(getSelectionBackground());
// // New in 1.4.0: Antialiased text with 1.6 JREs
// TinyUtils.drawString(g2d, progressString, renderLocation.x, renderLocation.y);
// g2d.setColor(getSelectionForeground());
// g2d.clipRect(fillStart, y, amountFull, height);
// // New in 1.4.0: Antialiased text with 1.6 JREs
// TinyUtils.drawString(g2d, progressString, renderLocation.x, renderLocation.y);
// }
// else { // VERTICAL
// g2d.setColor(getSelectionBackground());
// AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI / 2);
// g2d.setFont(progressBar.getFont().deriveFont(rotate));
// renderLocation = getStringPlacement(g2d, progressString, x, y, width, height);
// // New in 1.4.0: Antialiased text with 1.6 JREs
// TinyUtils.drawString(g2d, progressString, renderLocation.x, renderLocation.y);
// g2d.setColor(getSelectionForeground());
// g2d.clipRect(x, fillStart, width, amountFull);
// // New in 1.4.0: Antialiased text with 1.6 JREs
// TinyUtils.drawString(g2d, progressString, renderLocation.x, renderLocation.y);
// }
//
// g2d.setClip(oldClip);
// }
/*
* Inserted this to fix a bug that came with 1.4.2_02 and caused NPE at
* javax.swing.plaf.basic.BasicProgressBarUI.updateSizes(BasicProgressBarUI.java:439).
*
* @see javax.swing.plaf.basic.BasicProgressBarUI#paintString(java.awt.Graphics, int, int, int, int, int, java.awt.Insets)
*/
// protected void paintString(Graphics g, int x, int y, int width,
// int height, int amountFull, Insets b)
// {
// Rectangle boxRect = new Rectangle(); // *
// try { // * The Fix
// boxRect = getBox(boxRect); // *
// } catch (NullPointerException ignore) {} // *
//
// if(progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
// if(progressBar.getComponentOrientation().isLeftToRight()) {
// if(progressBar.isIndeterminate()) {
// paintString(g, x, y, width, height, boxRect.x, boxRect.width, b);
// } else {
// paintString(g, x, y, width, height, x, amountFull, b);
// }
// } else {
// paintString(g, x, y, width, height, x + width - amountFull, amountFull, b);
// }
// } else {
// if(progressBar.isIndeterminate()) {
// paintString(g, x, y, width, height, boxRect.y, boxRect.height, b);
// } else {
// paintString(g, x, y, width, height, y + height - amountFull, amountFull, b);
// }
// }
// }
// draw indeterminate
private void drawXpHorzProgress(Graphics g, int x, int y,
int w, int h, Rectangle boxRect)
{
// paint the track
if(!progressBar.isOpaque()) {
g.setColor(progressBar.getBackground());
g.fillRect(x, y, w, h);
}
g.translate(boxRect.x, boxRect.y);
ProgressKey key = new ProgressKey(
progressBar.getForeground(), true, h);
Object value = cache.get(key);
if(value == null) {
// create new image
Image img = new BufferedImage(6, h, BufferedImage.TYPE_INT_ARGB);
Graphics imgGraphics = img.getGraphics();
// draw into image graphics
Color c = progressBar.getForeground();
Color c2 = ColorRoutines.lighten(c, 15);
Color c3 = ColorRoutines.lighten(c, 35);
Color c4 = ColorRoutines.lighten(c, 60);
imgGraphics.setColor(c4);
imgGraphics.drawLine(0, 0, 5, 0);
imgGraphics.drawLine(0, h - 1, 5, h - 1);
imgGraphics.setColor(c3);
imgGraphics.drawLine(0, 1, 5, 1);
imgGraphics.drawLine(0, h - 2, 5, h - 2);
imgGraphics.setColor(c2);
imgGraphics.drawLine(0, 2, 5, 2);
imgGraphics.drawLine(0, h - 3, 5, h - 3);
imgGraphics.setColor(c);
imgGraphics.fillRect(0, 3, 6, h - 6);
// dispose of image graphics
imgGraphics.dispose();
cache.put(key, img);
value = img;
if(TinyLookAndFeel.PRINT_CACHE_SIZES) {
System.out.println("TinyProgressBarUI.cache.size=" + cache.size());
}
}
int mx = 0;
while(mx + 6 < boxRect.width) {
g.drawImage((Image)value, mx, 0, progressBar);
mx += 8;
}
g.translate(-boxRect.x, -boxRect.y);
}
// draw indeterminate
private void drawXpVertProgress(Graphics g, int x, int y,
int w, int h, Rectangle boxRect)
{
// paint the track
if(!progressBar.isOpaque()) {
g.setColor(progressBar.getBackground());
g.fillRect(x, y, w, h);
}
g.translate(boxRect.x, boxRect.y);
ProgressKey key = new ProgressKey(
progressBar.getForeground(), false, w);
Object value = cache.get(key);
if(value == null) {
// create new image
Image img = new BufferedImage(w, 6, BufferedImage.TYPE_INT_ARGB);
Graphics imgGraphics = img.getGraphics();
// draw into image graphics
Color c = progressBar.getForeground();
Color c2 = ColorRoutines.lighten(c, 15);
Color c3 = ColorRoutines.lighten(c, 35);
Color c4 = ColorRoutines.lighten(c, 60);
imgGraphics.setColor(c4);
imgGraphics.drawLine(0, 0, 0, 5);
imgGraphics.drawLine(w - 1, 0, w - 1, 5);
imgGraphics.setColor(c3);
imgGraphics.drawLine(1, 0, 1, 5);
imgGraphics.drawLine(w - 2, 0, w - 2, 5);
imgGraphics.setColor(c2);
imgGraphics.drawLine(2, 0, 2, 5);
imgGraphics.drawLine(w - 3, 0, w - 3, 5);
imgGraphics.setColor(c);
imgGraphics.fillRect(3, 0, w - 6, 6);
// dispose of image graphics
imgGraphics.dispose();
cache.put(key, img);
value = img;
if(TinyLookAndFeel.PRINT_CACHE_SIZES) {
System.out.println("TinyProgressBarUI.cache.size=" + cache.size());
}
}
int my = 0;
while(my + 6 < boxRect.height) {
g.drawImage((Image)value, 0, my, progressBar);
my += 8;
}
g.translate(-boxRect.x, -boxRect.y);
}
protected Color getSelectionForeground() {
return Theme.progressSelectForeColor.getColor();
}
protected Color getSelectionBackground() {
return Theme.progressSelectBackColor.getColor();
}
protected void installDefaults() {
// Note: Omitting the following line was a bug from v1.3.01 until v1.3.04
// Note: The following method turned out to be new in 1.5. Therefore
// replaced with progressBar.setOpaque(true)
//LookAndFeel.installProperty(progressBar, "opaque", Boolean.TRUE);
// removed again in 1.3.7 (because opaque progress bar
// fills bounds with track [background] color)
//progressBar.setOpaque(true);
LookAndFeel.installBorder(progressBar, "ProgressBar.border");
LookAndFeel.installColorsAndFont(progressBar,
"ProgressBar.background", "ProgressBar.foreground", "ProgressBar.font");
}
/*
* ProgressKey is used as key in the cache HashMap.
* Overrides equals() and hashCode().
*/
private static class ProgressKey {
private Color c;
private boolean horizontal;
private int size;
ProgressKey(Color c, boolean horizontal, int size) {
this.c = c;
this.horizontal = horizontal;
this.size = size;
}
public boolean equals(Object o) {
if(o == null) return false;
if(!(o instanceof ProgressKey)) return false;
ProgressKey other = (ProgressKey)o;
return size == other.size &&
horizontal == other.horizontal &&
c.equals(other.c);
}
public int hashCode() {
return c.hashCode() * (horizontal ? 1 : 2) * size;
}
}
}
--- NEW FILE: TinyListUI.java ---
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This file is part of the Tiny Look and Feel *
* Copyright 2003 - 2008 Hans Bickel *
* *
* For licensing information and credits, please refer to the *
* comment in file de.muntjak.tinylookandfeel.TinyLookAndFeel *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
package de.muntjak.tinylookandfeel;
import java.awt.*;
import javax.swing.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;
import de.muntjak.tinylookandfeel.controlpanel.*;
/**
* TinyListUI
*
* @version 1.3
* @author Hans Bickel
*/
public class TinyListUI extends BasicListUI {
private JComponent list;
public TinyListUI() {
super();
}
public TinyListUI(JComponent list) {
super();
this.list = list;
}
public static ComponentUI createUI(JComponent list) {
return new TinyListUI(list);
}
}
--- NEW FILE: TinyRadioButtonUI.java ---
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This file is part of the Tiny Look and Feel *
* Copyright 2003 - 2008 Hans Bickel *
* *
* For licensing information and credits, please refer to the *
* comment in file de.muntjak.tinylookandfeel.TinyLookAndFeel *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
package de.muntjak.tinylookandfeel;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.event.KeyEvent;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JRadioButton;
import javax.swing.KeyStroke;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.metal.MetalRadioButtonUI;
/**
* TinyRadioButtonUI
*
* @version 1.0
* @author Hans Bickel
*/
public class TinyRadioButtonUI extends MetalRadioButtonUI {
/** the only instance of the radiobuttonUI */
private static final TinyRadioButtonUI radioButtonUI = new TinyRadioButtonUI();
/* the only instance of the stroke for the focus */
private static BasicStroke focusStroke =
new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL,
1.0f, new float[] { 1.0f, 1.0f }, 0.0f);
/* the only instance of the radiobutton icon*/
private static TinyRadioButtonIcon radioButton;
/**
* Creates the singleton for the UI
* @see javax.swing.plaf.ComponentUI#createUI(JComponent)
*/
public static ComponentUI createUI(JComponent c) {
if(c instanceof JRadioButton) {
JRadioButton jb = (JRadioButton) c;
jb.setRolloverEnabled(true);
}
return radioButtonUI;
}
/**
* Installs the icon for the UI
* @see javax.swing.plaf.ComponentUI#installUI(JComponent)
*/
public void installUI(JComponent c) {
super.installUI(c);
icon = getRadioButton();
if(!Theme.buttonEnter.getValue()) return;
if(!c.isFocusable()) return;
InputMap km = (InputMap)UIManager.get(getPropertyPrefix() + "focusInputMap");
if(km != null) {
km.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false), "pressed");
km.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, true), "released");
}
}
/**
* Returns the skinned Icon
* @return TinyRadioButtonIcon
*/
protected TinyRadioButtonIcon getRadioButton() {
if(radioButton==null) radioButton = new TinyRadioButtonIcon();
return radioButton;
}
/**
* Paints the focus for the radiobutton
* @see javax.swing.plaf.metal.MetalRadioButtonUI#paintFocus(java.awt.Graphics, java.awt.Rectangle, java.awt.Dimension)
*/
protected void paintFocus(Graphics g, Rectangle t, Dimension arg2) {
if(!Theme.buttonFocus.getValue()) return;
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(Color.black);
g2d.setStroke(focusStroke);
int x1 = t.x -1;
int y1 = t.y -1;
int x2 = x1 + t.width + 1;
int y2 = y1 + t.height + 1;
g2d.drawLine(x1, y1, x2, y1);
g2d.drawLine(x1, y1, x1, y2);
g2d.drawLine(x1, y2, x2, y2);
g2d.drawLine(x2, y1, x2, y2);
}
}
--- NEW FILE: TinyButtonUI.java ---
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This file is part of the Tiny Look and Feel *
* Copyright 2003 - 2008 Hans Bickel *
* *
* For licensing information and credits, please refer to the *
* comment in file de.muntjak.tinylookandfeel.TinyLookAndFeel *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
package de.muntjak.tinylookandfeel;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import java.util.HashMap;
import javax.swing.AbstractButton;
import javax.swing.ButtonModel;
import javax.swing.Icon;
import javax.swing.InputMap;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JToggleButton;
import javax.swing.KeyStroke;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.FileChooserUI;
import javax.swing.plaf.metal.MetalButtonUI;
import de.muntjak.tinylookandfeel.borders.TinyButtonBorder;
import de.muntjak.tinylookandfeel.borders.TinyToolButtonBorder;
import de.muntjak.tinylookandfeel.util.ColorRoutines;
import de.muntjak.tinylookandfeel.util.DrawRoutines;
/**
* TinyButtonUI. The UI delegate for JButton, JToggleButton, window buttons
* and arrow buttons of JSpinner and JComboBox.
*
* @version 1.4.0
* @author Hans Bickel
*/
public class TinyButtonUI extends MetalButtonUI {
// cache for already drawn buttons - speeds up drawing by a factor of 3
// (new in 1.4.0)
private static final HashMap cache = new HashMap();
// if a button has not the defined background, it will
// be darkened resp. lightened by BG_CHANGE amount if
// pressed or rollover
public static final int BG_CHANGE_AMOUNT = 10;
/**
* The Cached UI delegate.
*/
private static final TinyButtonUI buttonUI = new TinyButtonUI();
/* the only instance of the stroke for the focus */
private static final BasicStroke focusStroke =
new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 1.0f, new float[] { 1.0f, 1.0f }, 0.0f);
private boolean graphicsTranslated;
private boolean isToolBarButton, isFileChooserButton;
private boolean isDefaultButton;
public static void clearCache() {
cache.clear();
}
public void installUI(JComponent c) {
super.installUI(c);
if(!Theme.buttonEnter.getValue()) return;
if(!c.isFocusable()) return;
InputMap km = (InputMap)UIManager.get(getPropertyPrefix() + "focusInputMap");
if(km != null) {
// replace SPACE with ENTER (but SPACE will still work, don't know why)
km.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false), "pressed");
km.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, true), "released");
}
}
public void installDefaults(AbstractButton button) {
super.installDefaults(button);
button.setRolloverEnabled(true);
}
protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect) {
if(isFileChooserButton ||
(isToolBarButton && !Theme.toolFocus.getValue()) ||
!Theme.buttonFocus.getValue())
{
return;
}
Graphics2D g2d = (Graphics2D)g;
Rectangle focusRect = b.getBounds();
g.setColor(Color.black);
g2d.setStroke(focusStroke);
int x1 = 2;
int y1 = 2;
int x2 = x1 + focusRect.width - 5;
int y2 = y1 + focusRect.height - 5;
if(!isToolBarButton) {
x1++;
y1++;
x2--;
y2--;
}
if(graphicsTranslated) {
g.translate(-1, -1);
}
g2d.drawLine(x1, y1, x2, y1);
g2d.drawLine(x1, y1, x1, y2);
g2d.drawLine(x1, y2, x2, y2);
g2d.drawLine(x2, y1, x2, y2);
}
/**
* Creates the UI delegate for the given component.
*
* @param mainColor The component to create its UI delegate.
* @return The UI delegate for the given component.
*/
public static ComponentUI createUI(final JComponent c) {
return buttonUI;
}
protected void paintButtonPressed(Graphics g, AbstractButton button) {
if(isToolBarButton || isFileChooserButton) return;
Color col = null;
if(!(button.getBackground() instanceof ColorUIResource)) {
col = ColorRoutines.darken(button.getBackground(), BG_CHANGE_AMOUNT);
}
else if(button instanceof JToggleButton) {
col = Theme.toggleSelectedBg.getColor();
}
else {
col = Theme.buttonPressedColor.getColor();
}
g.setColor(col);
drawXpButton(g, button, col, false);
if(!(button instanceof JToggleButton)) {
// Changed in 1.3.04: If button is icon-only then don't shift
if(Theme.shiftButtonText.getValue() &&
button.getText() != null &&
!"".equals(button.getText()))
{
g.translate(1, 1);
graphicsTranslated = true;
}
}
}
public void paintToolBarButton(Graphics g, AbstractButton b) {
Color col = null;
// New in 1.3.7
boolean isRollover = b.getModel().isRollover() || b.getModel().isArmed();
Color toolButtColor = null;
if(isFileChooserButton) {
toolButtColor = b.getParent().getBackground();
}
else {
toolButtColor = Theme.toolButtColor.getColor();
}
if(b.getModel().isPressed()) {
if(isRollover) {
col = Theme.toolButtPressedColor.getColor();
}
else {
if(b.isSelected()) {
col = Theme.toolButtSelectedColor.getColor();
}
else {
col = toolButtColor;
}
}
}
else if(isRollover) {
if(b.isSelected()) {
col = Theme.toolButtSelectedColor.getColor();
}
else {
col = Theme.toolButtRolloverColor.getColor();
}
}
else if(b.isSelected()) {
col = Theme.toolButtSelectedColor.getColor();
}
else {
col = toolButtColor;
}
g.setColor(col);
drawXpToolBarButton(g, b, col, false);
}
public void paint(Graphics g, JComponent c) {
AbstractButton button = (AbstractButton)c;
if(isToolBarButton || isFileChooserButton) {
paintToolBarButton(g, button);
}
else if((button instanceof JToggleButton) && button.isSelected()) {
paintButtonPressed(g, button);
}
else {
isDefaultButton = (c instanceof JButton) && (((JButton)c).isDefaultButton());
boolean isRollover = button.getModel().isRollover();
boolean isDefinedBackground = c.getBackground().equals(
Theme.buttonNormalColor.getColor()) ||
(c.getBackground() instanceof ColorUIResource);
Color col = null;
if(!button.isEnabled()) {
col = Theme.buttonDisabledColor.getColor();
}
else if(button.getModel().isPressed()) {
if(isRollover) {
if(isDefinedBackground) {
col = Theme.buttonPressedColor.getColor();
}
else {
col = ColorRoutines.darken(c.getBackground(), BG_CHANGE_AMOUNT);
}
}
else {
// button pressed but mouse exited
col = c.getBackground();
}
}
else if(isRollover) {
if(isDefinedBackground) {
col = Theme.buttonRolloverBgColor.getColor();
}
else {
col = ColorRoutines.lighten(c.getBackground(), BG_CHANGE_AMOUNT);
}
}
else {
if(isDefinedBackground) {
col = Theme.buttonNormalColor.getColor();
}
else {
col = c.getBackground();
}
}
g.setColor(col);
if(TinyLookAndFeel.controlPanelInstantiated) {
drawXpButtonNoCache(g, button, col, isRollover);
}
else {
drawXpButton(g, button, col, isRollover);
}
}
// the base class may paint text and/or icons
super.paint(g, c);
}
// this overrides BasicButtonUI.paintIcon(...)
protected void paintIcon(Graphics g, JComponent c, Rectangle iconRect) {
if(c instanceof JToggleButton) {
paintToggleButtonIcon(g, c, iconRect);
}
else {
super.paintIcon(g, c, iconRect);
}
}
protected void paintToggleButtonIcon(Graphics g, JComponent c, Rectangle iconRect) {
AbstractButton b = (AbstractButton)c;
ButtonModel model = b.getModel();
Icon icon = null;
if(!model.isEnabled()) {
if(model.isSelected()) {
icon = (Icon)b.getDisabledSelectedIcon();
}
else {
icon = (Icon)b.getDisabledIcon();
}
}
else if(model.isPressed() && model.isArmed()) {
icon = (Icon)b.getPressedIcon();
if(icon == null) {
// Use selected icon
icon = (Icon)b.getSelectedIcon();
}
}
else if(model.isSelected()) {
if(b.isRolloverEnabled() && model.isRollover()) {
icon = (Icon)b.getRolloverSelectedIcon();
if(icon == null) {
icon = (Icon)b.getSelectedIcon();
}
}
else {
icon = (Icon)b.getSelectedIcon();
}
}
else if(model.isRollover()) {
icon = (Icon)b.getRolloverIcon();
}
if(icon == null) {
icon = (Icon)b.getIcon();
}
icon.paintIcon(b, g, iconRect.x, iconRect.y);
}
public void update(Graphics g, JComponent c) {
isToolBarButton = Boolean.TRUE.equals(
c.getClientProperty(TinyToolBarUI.IS_TOOL_BAR_BUTTON_KEY));
isFileChooserButton = Boolean.TRUE.equals(
c.getClientProperty(TinyFileChooserUI.IS_FILE_CHOOSER_BUTTON_KEY));
paint(g, c);
graphicsTranslated = false;
}
private void drawXpButton(Graphics g, AbstractButton b, Color c, boolean isRollover) {
if(!b.isContentAreaFilled()) return;
if(!b.isOpaque()) return;
int w = b.getWidth();
int h = b.getHeight();
Color bg = b.getParent().getBackground();
// With 1.4.0 added hasFocus to the key (bug only revealed with JDK 1.6)
// and added isBorderPainted to the key.
ButtonKey key = new ButtonKey(c, bg, h,
isRollover & Theme.buttonRolloverBorder.getValue(),
isDefaultButton, b.hasFocus(), b.isBorderPainted());
Object value = cache.get(key);
if(value != null) {
// image already cached - paint image and return
int width = ((Image)value).getWidth(b);
if(width == w) {
g.drawImage((Image)value, 0, 0, b);
return;
}
// left part
int sx1 = 0;
final int sy1 = 0;
int sx2 = 3;
final int sy2 = h;
int dx1 = 0;
final int dy1 = 0;
int dx2 = sx2;
final int dy2 = sy2;
g.drawImage((Image)value, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, b);
// right part
sx1 = width - 4;
sx2 = width;
dx1 = w - 4;
dx2 = w;
g.drawImage((Image)value, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, b);
// mid part - stretched
sx1 = 3;
sx2 = width - 4;
dx1 = sx1;
dx2 = w - 4;
g.drawImage((Image)value, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, b);
return;
}
Image img = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
Graphics imgGraphics = img.getGraphics();
imgGraphics.setColor(bg);
imgGraphics.drawRect(0, 0, w - 1, h - 1);
int spread1 = Theme.buttonSpreadLight.getValue();
int spread2 = Theme.buttonSpreadDark.getValue();
if(!b.isEnabled()) {
spread1 = Theme.buttonSpreadLightDisabled.getValue();
spread2 = Theme.buttonSpreadDarkDisabled.getValue();
}
float spreadStep1 = 10.0f * spread1 / (h - 3);
float spreadStep2 = 10.0f * spread2 / (h - 3);
int halfY = h / 2;
int yd;
for (int y = 1; y < h - 1; y++) {
if(y < halfY) {
yd = halfY - y;
imgGraphics.setColor(ColorRoutines.lighten(c, (int)(yd * spreadStep1)));
}
else if(y == halfY) {
imgGraphics.setColor(c);
}
else {
yd = y - halfY;
imgGraphics.setColor(ColorRoutines.darken(c, (int)(yd * spreadStep2)));
}
imgGraphics.drawLine(2, y, w - 3, y);
if(y == 1) {
// left vertical line
imgGraphics.drawLine(1, 1, 1, h - 2);
if(isRollover || isDefaultButton) {
// right vertical line
imgGraphics.drawLine(w - 2, 1, w - 2, h - 2);
}
}
else if(y == h - 2 && !(isRollover || isDefaultButton)) {
// right vertical line
imgGraphics.drawLine(w - 2, 1, w - 2, h - 2);
}
}
// paint border
if(b.isBorderPainted()) {
Border border = b.getBorder();
// Changed in 1.4.0: Moved the following block into these two if-clauses
// so additional pixels will be painted only if button has a Tiny border.
if(border != null && (border instanceof TinyButtonBorder.CompoundBorderUIResource)) {
// Draw 2 background pixels that will shine through the
// border painted above
if(isRollover && Theme.buttonRolloverBorder.getValue()) {
imgGraphics.setColor(Theme.buttonRolloverColor.getColor());
imgGraphics.drawLine(1, h - 2, 1, h - 2);
imgGraphics.drawLine(w - 2, h - 2, w - 2, h - 2);
}
else if(isDefaultButton && b.isEnabled()) {
imgGraphics.setColor(Theme.buttonDefaultColor.getColor());
imgGraphics.drawLine(1, h - 2, 1, h - 2);
imgGraphics.drawLine(w - 2, h - 2, w - 2, h - 2);
}
drawXpBorder(b, imgGraphics, 0, 0, w, h);
}
}
// dispose of image graphics
imgGraphics.dispose();
// draw the image
g.drawImage(img, 0, 0, b);
// add the image to the cache
cache.put(key, img);
if(TinyLookAndFeel.PRINT_CACHE_SIZES) {
System.out.println("TinyButtonUI.cache.size=" + cache.size());
}
}
private void drawXpBorder(AbstractButton b, Graphics g, int x, int y, int w, int h) {
boolean isComboBoxButton =
Boolean.TRUE.equals(b.getClientProperty("isComboBoxButton"));
if(isComboBoxButton) {
if(!b.isEnabled()) {
DrawRoutines.drawRoundedBorder(
g, Theme.comboBorderDisabledColor.getColor(), x, y, w, h);
}
else {
DrawRoutines.drawRoundedBorder(
g, Theme.comboBorderColor.getColor(), x, y, w, h);
if(b.getModel().isPressed()) return;
if(b.getModel().isRollover() && Theme.comboRollover.getValue()) {
DrawRoutines.drawRolloverBorder(
g, Theme.buttonRolloverColor.getColor(), x, y, w, h);
}
}
}
else { // it's a JButton or a JSpinner button
boolean isDefault = (b instanceof JButton) && (((JButton)b).isDefaultButton());
boolean isSpinnerButton =
Boolean.TRUE.equals(b.getClientProperty("isSpinnerButton"));
boolean paintRolloverBorder =
(isSpinnerButton && Theme.spinnerRollover.getValue()) ||
(!isSpinnerButton && Theme.buttonRolloverBorder.getValue());
// New in 1.4.0: If isFocusPainted is false, no focus border
// will be painted
boolean paintFocusBorder =
isDefault ||
(isSpinnerButton && Theme.buttonFocusBorder.getValue() && b.isFocusOwner()) ||
(!isSpinnerButton && Theme.buttonFocusBorder.getValue() && b.isFocusOwner() && b.isFocusPainted());
if(!b.isEnabled()) {
DrawRoutines.drawRoundedBorder(
g, Theme.buttonBorderDisabledColor.getColor(), x, y, w, h);
}
else {
DrawRoutines.drawRoundedBorder(
g, Theme.buttonBorderColor.getColor(), x, y, w, h);
if(b.getModel().isPressed()) return;
if(b.getModel().isRollover() && paintRolloverBorder) {
DrawRoutines.drawRolloverBorder(
g, Theme.buttonRolloverColor.getColor(), x, y, w, h);
}
else if(paintFocusBorder) {
DrawRoutines.drawRolloverBorder(
g, Theme.buttonDefaultColor.getColor(), x, y, w, h);
}
}
}
}
private void drawXpButtonNoCache(Graphics g, AbstractButton b, Color c, boolean isRollover) {
if(!b.isContentAreaFilled()) return;
if(!b.isOpaque()) return;
int w = b.getWidth();
int h = b.getHeight();
// paint border background
Color bg = b.getParent().getBackground();
g.setColor(bg);
g.drawRect(0, 0, w - 1, h - 1);
int spread1 = Theme.buttonSpreadLight.getValue();
int spread2 = Theme.buttonSpreadDark.getValue();
if(!b.isEnabled()) {
spread1 = Theme.buttonSpreadLightDisabled.getValue();
spread2 = Theme.buttonSpreadDarkDisabled.getValue();
}
float spreadStep1 = 10.0f * spread1 / (h - 3);
float spreadStep2 = 10.0f * spread2 / (h - 3);
int halfY = h / 2;
int yd;
for (int y = 1; y < h - 1; y++) {
if(y < halfY) {
yd = halfY - y;
g.setColor(ColorRoutines.lighten(c, (int)(yd * spreadStep1)));
}
else if(y == halfY) {
g.setColor(c);
}
else {
yd = y - halfY;
g.setColor(ColorRoutines.darken(c, (int)(yd * spreadStep2)));
}
g.drawLine(2, y, w - 3, y);
if(y == 1) {
// left vertical line
g.drawLine(1, 1, 1, h - 2);
if(isRollover || isDefaultButton) {
// right vertical line
g.drawLine(w - 2, 1, w - 2, h - 2);
}
}
else if(y == h - 2 && !isRollover && !isDefaultButton) {
// right vertical line
g.drawLine(w - 2, 1, w - 2, h - 2);
}
}
// Changed in 1.4.0: Added if-clause
if(b.isBorderPainted()) {
// Draw 2 background pixels that will shine through the
// border painted above
if(isRollover && Theme.buttonRolloverBorder.getValue()) {
g.setColor(Theme.buttonRolloverColor.getColor());
g.drawLine(1, h - 2, 1, h - 2);
g.drawLine(w - 2, h - 2, w - 2, h - 2);
}
else if(isDefaultButton && b.isEnabled()) {
g.setColor(Theme.buttonDefaultColor.getColor());
g.drawLine(1, h - 2, 1, h - 2);
g.drawLine(w - 2, h - 2, w - 2, h - 2);
}
}
}
private void drawXpToolBarButton(Graphics g,
AbstractButton b, Color c, boolean isPressed)
{
int w = b.getWidth();
int h = b.getHeight();
if(b.isContentAreaFilled()) {
g.fillRect(1, 1, w - 2, h - 2);
}
// paint border background
Color bg = b.getParent().getBackground();
// Note: Was bug before 1.4.0 - (isFileChooserButton not considered)
if((bg instanceof ColorUIResource) && !isFileChooserButton) {
g.setColor(Theme.toolBarColor.getColor());
}
else {
g.setColor(bg);
}
g.drawRect(0, 0, w - 1, h - 1);
}
private static class ButtonKey {
private Color background;
private Color parentBackground;
private int height;
private boolean rollover;
private boolean isDefault;
private boolean hasFocus;
private boolean isBorderPainted;
ButtonKey(Color background, Color parentBackground,
int height, boolean rollover, boolean isDefault,
boolean hasFocus, boolean isBorderPainted)
{
this.background = background;
this.parentBackground = parentBackground;
this.height = height;
this.rollover = rollover;
this.isDefault = isDefault;
this.hasFocus = hasFocus;
this.isBorderPainted = isBorderPainted;
}
public boolean equals(Object o) {
if(o == null) return false;
if(!(o instanceof ButtonKey)) return false;
ButtonKey other = (ButtonKey)o;
return
height == other.height &&
rollover == other.rollover &&
isDefault == other.isDefault &&
hasFocus == other.hasFocus &&
isBorderPainted == other.isBorderPainted &&
background.equals(other.background) &&
parentBackground.equals(other.parentBackground);
}
public int hashCode() {
return background.hashCode() *
parentBackground.hashCode() *
height *
(rollover ? 2 : 1) *
(isDefault ? 8 : 4) *
(hasFocus ? 16 : 8) *
(isBorderPainted ? 32 : 16);
}
}
}
--- NEW FILE: TinyDefaultTheme.java ---
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This file is part of the Tiny Look and Feel *
* Copyright 2003 - 2008 Hans Bickel *
* *
* For licensing information and credits, please refer to the *
* comment in file de.muntjak.tinylookandfeel.TinyLookAndFeel *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
package de.muntjak.tinylookandfeel;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.plaf.BorderUIResource;
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.FontUIResource;
import javax.swing.plaf.InsetsUIResource;
import javax.swing.plaf.metal.DefaultMetalTheme;
import de.muntjak.tinylookandfeel.controlpanel.*;
import de.muntjak.tinylookandfeel.util.ColorRoutines;
import de.muntjak.tinylookandfeel.util.DrawRoutines;
import de.muntjak.tinylookandfeel.util.HSBReference;
/**
* TinyDefaultTheme
*
* @version 1.1
* @author Hans Bickel
*/
public class TinyDefaultTheme extends DefaultMetalTheme {
/**
* Adds some custom values to the defaults table.
*
* @param table The UI defaults table.
*/
public void addCustomEntriesToTable(UIDefaults table) {
super.addCustomEntriesToTable(table);
table.put("Button.margin", Theme.buttonMargin);
table.put("CheckBox.margin", Theme.checkMargin);
table.put("RadioButton.margin", Theme.checkMargin);
table.put("Button.background", Theme.buttonNormalColor.getColor());
table.put("Button.font", Theme.buttonFont.getFont());
table.put("CheckBox.font", Theme.checkFont.getFont());
table.put("CheckBoxMenuItem.font", Theme.menuItemFont.getFont());
table.put("ComboBox.font", Theme.comboFont.getFont());
table.put("Label.font", Theme.labelFont.getFont());
table.put("List.font", Theme.listFont.getFont());
table.put("Menu.font", Theme.menuFont.getFont());
table.put("MenuItem.font", Theme.menuItemFont.getFont());
table.put("ProgressBar.font", Theme.progressBarFont.getFont());
table.put("RadioButton.font", Theme.radioFont.getFont());
table.put("RadioButtonMenuItem.font", Theme.menuItemFont.getFont());
table.put("Table.font", Theme.tableFont.getFont());
table.put("TableHeader.font", Theme.tableHeaderFont.getFont());
table.put("TitledBorder.font", Theme.titledBorderFont.getFont());
table.put("ToolTip.font", Theme.toolTipFont.getFont());
table.put("Tree.font", Theme.treeFont.getFont());
table.put("PasswordField.font", Theme.passwordFont.getFont());
table.put("TextArea.font", Theme.textAreaFont.getFont());
table.put("TextField.font", Theme.textFieldFont.getFont());
table.put("FormattedTextField.font", Theme.textFieldFont.getFont());
table.put("TextPane.font", Theme.textPaneFont.getFont());
table.put("EditorPane.font", Theme.editorFont.getFont());
table.put("InternalFrame.font", Theme.editorFont.getFont());
// font for internal frames and palettes
table.put("InternalFrame.normalTitleFont", Theme.internalFrameTitleFont.getFont());
table.put("InternalFrame.paletteTitleFont", Theme.internalPaletteTitleFont.getFont());
// font for (decorized) frame
table.put("Frame.titleFont", Theme.frameTitleFont.getFont());
table.put("TabbedPane.font", Theme.tabFont.getFont());
table.put("Button.foreground", Theme.buttonFontColor.getColor());
table.put("CheckBox.foreground", Theme.checkFontColor.getColor());
table.put("Menu.foreground", Theme.menuFontColor.getColor());
table.put("MenuItem.foreground", Theme.menuItemFontColor.getColor());
table.put("CheckBoxMenuItem.foreground", Theme.menuItemFontColor.getColor());
table.put("RadioButtonMenuItem.foreground", Theme.menuItemFontColor.getColor());
table.put("RadioButton.foreground", Theme.radioFontColor.getColor());
table.put("TabbedPane.foreground", Theme.tabFontColor.getColor());
table.put("TitledBorder.titleColor", Theme.titledBorderFontColor.getColor());
table.put("Label.foreground", Theme.labelFontColor.getColor());
table.put("TableHeader.foreground", Theme.tableHeaderFontColor.getColor());
table.put("TableHeader.background", Theme.tableHeaderBackColor.getColor());
table.put("Table.foreground", Theme.tableFontColor.getColor());
table.put("Table.background", Theme.tableBackColor.getColor());
table.put("Table.selectionForeground", Theme.tableSelectedForeColor.getColor());
table.put("Table.selectionBackground", Theme.tableSelectedBackColor.getColor());
table.put("Table.gridColor", Theme.tableGridColor.getColor());
// New in 1.4.0
table.put("Table.focusCellHighlightBorder", new BorderUIResource(
new LineBorder(Theme.tableFocusBorderColor.getColor())));
// New in 1.4.0
table.put("Table.alternateRowColor", Theme.tableAlternateRowColor.getColor());
table.put("ProgressBar.foreground", Theme.progressColor.getColor());
table.put("ProgressBar.background", Theme.progressTrackColor.getColor());
table.put("ProgressBar.selectionForeground", Theme.progressSelectForeColor.getColor());
table.put("ProgressBar.selectionBackground", Theme.progressSelectBackColor.getColor());
table.put("PopupMenu.background", Theme.menuPopupColor);
// Note: TabbedPane.background is the default background color of unselected tabs,
// whereas TabbedPane.unselectedBackground has no effect.
table.put("TabbedPane.background", Theme.tabNormalColor.getColor());
table.put("TabbedPane.tabAreaInsets", Theme.tabAreaInsets);
table.put("TabbedPane.tabInsets", Theme.tabInsets);
table.put("MenuBar.background", Theme.menuBarColor.getColor());
table.put("ToolBar.background", Theme.toolBarColor.getColor());
table.put("EditorPane.caretForeground", Theme.textCaretColor.getColor());
table.put("PasswordField.caretForeground", Theme.textCaretColor.getColor());
table.put("TextArea.caretForeground", Theme.textCaretColor.getColor());
table.put("TextField.caretForeground", Theme.textCaretColor.getColor());
table.put("FormattedTextField.caretForeground", Theme.textCaretColor.getColor());
table.put("List.foreground", Theme.listTextColor.getColor());
table.put("List.background", Theme.listBgColor.getColor());
table.put("ComboBox.foreground", Theme.comboTextColor.getColor());
table.put("ComboBox.background", Theme.comboBgColor.getColor());
table.put("ComboBox.disabledBackground", Theme.textDisabledBgColor.getColor());
table.put("EditorPane.background", Theme.textBgColor.getColor());
table.put("EditorPane.foreground", Theme.textTextColor.getColor());
table.put("PasswordField.background", Theme.textBgColor.getColor());
table.put("PasswordField.foreground", Theme.textTextColor.getColor());
table.put("PasswordField.inactiveBackground", Theme.textDisabledBgColor.getColor());
table.put("TextArea.background", Theme.textBgColor.getColor());
table.put("TextArea.foreground", Theme.textTextColor.getColor());
table.put("TextArea.inactiveBackground", Theme.textDisabledBgColor.getColor());
table.put("TextField.background", Theme.textBgColor.getColor());
table.put("TextField.foreground", Theme.textTextColor.getColor());
table.put("TextField.inactiveBackground", Theme.textDisabledBgColor.getColor());
table.put("FormattedTextField.background", Theme.textBgColor.getColor());
table.put("FormattedTextField.foreground", Theme.textTextColor.getColor());
table.put("FormattedTextField.inactiveBackground", Theme.textDisabledBgColor.getColor());
table.put("TextPane.background", Theme.textPaneBgColor.getColor());
table.put("EditorPane.background", Theme.editorPaneBgColor.getColor());
table.put("OptionPane.messageForeground", Theme.textTextColor.getColor());
table.put("PasswordField.selectionBackground", Theme.textSelectedBgColor.getColor());
table.put("PasswordField.selectionForeground", Theme.textSelectedTextColor.getColor());
table.put("TextField.selectionBackground", Theme.textSelectedBgColor.getColor());
table.put("TextField.selectionForeground", Theme.textSelectedTextColor.getColor());
table.put("FormattedTextField.selectionBackground", Theme.textSelectedBgColor.getColor());
table.put("FormattedTextField.selectionForeground", Theme.textSelectedTextColor.getColor());
table.put("TextArea.selectionBackground", Theme.textSelectedBgColor.getColor());
table.put("TextArea.selectionForeground", Theme.textSelectedTextColor.getColor());
table.put("TextPane.selectionBackground", Theme.textSelectedBgColor.getColor());
table.put("TextPane.selectionForeground", Theme.textSelectedTextColor.getColor());
table.put("ComboBox.selectionBackground", Theme.comboSelectedBgColor.getColor());
table.put("ComboBox.selectionForeground", Theme.comboSelectedTextColor.getColor());
table.put("ComboBox.focusBackground", Theme.comboSelectedBgColor.getColor());
table.put("List.selectionForeground", Theme.listSelectedTextColor.getColor());
table.put("List.selectionBackground", Theme.listSelectedBgColor.getColor());
// new in 1.4.0
table.put("List.focusCellHighlightBorder", new BorderUIResource(
new LineBorder(Theme.listFocusBorderColor.getColor())));
table.put("Tree.background", Theme.treeBgColor.getColor());
table.put("Tree.textBackground", Theme.treeTextBgColor.getColor());
table.put("Tree.textForeground", Theme.treeTextColor.getColor());
table.put("Tree.selectionBackground", Theme.treeSelectedBgColor.getColor());
table.put("Tree.selectionForeground", Theme.treeSelectedTextColor.getColor());
table.put("Tree.hash", Theme.treeLineColor.getColor());
table.put("Tree.line", Theme.treeLineColor.getColor());
table.put("Button.disabledText", Theme.buttonDisabledFgColor.getColor());
table.put("CheckBox.disabledText", Theme.checkDisabledFgColor.getColor());
table.put("RadioButton.disabledText", Theme.radioDisabledFgColor.getColor());
table.put("ToggleButton.disabledText", Theme.disColor.getColor());
table.put("ToggleButton.disabledSelectedText", Theme.disColor.getColor());
table.put("TextArea.inactiveForeground", Theme.disColor.getColor());
table.put("TextField.inactiveForeground", Theme.disColor.getColor());
table.put("FormattedTextField.inactiveForeground", Theme.disColor.getColor());
table.put("TextPane.inactiveForeground", Theme.disColor.getColor());
table.put("PasswordField.inactiveForeground", Theme.disColor.getColor());
table.put("ComboBox.disabledForeground", Theme.disColor.getColor());
table.put("Label.disabledForeground", Theme.disColor.getColor());
table.put("textInactiveText", Theme.disColor.getColor());
table.put("Desktop.background", Theme.desktopPaneBgColor.getColor());
table.put("Separator.background", Theme.separatorColor.getColor());
// not needed since 1.4 (XP separator has only background)
// table.put("Separator.foreground", Theme.sepLightColor.getColor());
table.put("TitledBorder.border", new LineBorder(
Theme.titledBorderColor.getColor()));
table.put("ToolTip.background", Theme.tipBgColor.getColor());
table.put("ToolTip.backgroundInactive", Theme.tipBgDis.getColor());
table.put("ToolTip.foreground", Theme.tipTextColor.getColor());
table.put("ToolTip.foregroundInactive", Theme.tipTextDis.getColor());
table.put("Panel.background", Theme.backColor.getColor());
// set default icons and colorize selected icons
Icon icon = null;
for(int i = 0; i < 20; i++) {
if(Theme.colorize[i].getValue()) {
icon = TinyLookAndFeel.getUncolorizedSystemIcon(i);
if(icon != null && (icon instanceof ImageIcon)) {
table.put(TinyLookAndFeel.getSystemIconName(i),
DrawRoutines.colorizeIcon(
((ImageIcon)icon).getImage(), Theme.colorizer[i]));
}
else {
table.put(TinyLookAndFeel.getSystemIconName(i), icon);
}
}
}
}
public String getName() {
return "TinyLaF Default Theme";
}
/**
* Returns the third secondary color. This is the panel background color.
*
* @return The third secondary color
*/
protected ColorUIResource getSecondary3() {
return Theme.backColor.getColor();
}
/**
* Returns the control text font, used for slider labels.
* @return the control text font
*/
public FontUIResource getControlTextFont() {
return Theme.labelFont.getFont();
}
}
--- NEW FILE: TinyCheckBoxMenuItemUI.java ---
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This file is part of the Tiny Look and Feel *
* Copyright 2003 - 2008 Hans Bickel *
* *
* For licensing information and credits, please refer to the *
* comment in file de.muntjak.tinylookandfeel.TinyLookAndFeel *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
package de.muntjak.tinylookandfeel;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
/**
* TinyCheckBoxMenuItemUI
*
* @version 1.0
* @author Hans Bickel
*/
public class TinyCheckBoxMenuItemUI extends TinyMenuItemUI {
public static ComponentUI createUI(JComponent c) {
return new TinyCheckBoxMenuItemUI();
}
protected String getPropertyPrefix() {
return "CheckBoxMenuItem";
}
}
--- NEW FILE: TinyPasswordFieldUI.java ---
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This file is part of the Tiny Look and Feel *
* Copyright 2003 - 2008 Hans Bickel *
* *
* For licensing information and credits, please refer to the *
* comment in file de.muntjak.tinylookandfeel.TinyLookAndFeel *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
package de.muntjak.tinylookandfeel;
import java.awt.Graphics;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicPasswordFieldUI;
import javax.swing.text.JTextComponent;
/**
* TinyPasswordFieldUI
*
* @version 1.4
* @author Hans Bickel
*/
public class TinyPasswordFieldUI extends BasicPasswordFieldUI {
public static ComponentUI createUI(JComponent c) {
return new TinyPasswordFieldUI();
}
protected void paintBackground(Graphics g) {
JTextComponent editor = getComponent();
if(editor.isEnabled()) {
// Note: Was a bug until 1.4.0 (there simply
// was no non-editable state for password fields)
if(editor.isEditable()) {
g.setColor(editor.getBackground());
}
else {
g.setColor(Theme.textNonEditableBgColor.getColor());
}
}
else {
g.setColor(Theme.textDisabledBgColor.getColor());
}
g.fillRect(0, 0, editor.getWidth(), editor.getHeight());
}
}
--- NEW FILE: TinyPopupMenuSeparatorUI.java ---
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This file is part of the Tiny Look and Feel *
* Copyright 2003 - 2008 Hans Bickel *
* *
* For licensing information and credits, please refer to the *
* comment in file de.muntjak.tinylookandfeel.TinyLookAndFeel *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
package de.muntjak.tinylookandfeel;
import java.awt.Dimension;
import java.awt.Graphics;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.metal.MetalSeparatorUI;
/**
* TinyPopupMenuSeparatorUI
*
* @version 1.0
* @author Hans Bickel
*/
public class TinyPopupMenuSeparatorUI extends MetalSeparatorUI {
private static final Dimension preferredSize = new Dimension(0, 3);
public static ComponentUI createUI( JComponent c )
{
return new TinyPopupMenuSeparatorUI();
}
public void paint(Graphics g, JComponent c ) {
drawXpSeparator(g, c.getSize());
}
private void drawXpSeparator(Graphics g, Dimension s) {
g.setColor(Theme.menuPopupColor.getColor());
g.fillRect(0, 0, s.width, s.height);
g.setColor(Theme.menuSeparatorColor.getColor());
g.drawLine(2, 1, s.width - 3, 1);
}
public Dimension getPreferredSize(JComponent c) {
return preferredSize;
}
}
--- NEW FILE: TinyInternalFrameTitlePane.java ---
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This file is part of the Tiny Look and Feel *
* Copyright 2003 - 2008 Hans Bickel *
* *
* For licensing information and credits, please refer to the *
* comment in file de.muntjak.tinylookandfeel.TinyLookAndFeel *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
package de.muntjak.tinylookandfeel;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Event;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JInternalFrame;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JSeparator;
import javax.swing.UIManager;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
import javax.swing.plaf.metal.MetalInternalFrameTitlePane;
import javax.swing.plaf.metal.MetalLookAndFeel;
import de.muntjak.tinylookandfeel.borders.TinyFrameBorder;
/**
* TinyInternalFrameTitlePane is not an UI-delegate but a JComponent.
*
* @version 1.0
* @author Hans Bickel
*/
public class TinyInternalFrameTitlePane extends BasicInternalFrameTitlePane
implements LayoutManager
{
protected boolean isPalette = false;
/**
* The buttons width, calculated at runtime.
*/
private int buttonsWidth;
protected PropertyChangeListener createPropertyChangeListener() {
return new TinyPropertyChangeHandler();
}
/**
* This constructor creates a title pane for the given internal frame
* instance.
*
* @param frame The internal frame that needs a title pane.
*/
public TinyInternalFrameTitlePane(JInternalFrame frame) {
super(frame);
}
protected JMenu createSystemMenu() {
JMenu menu = new JMenu("");
// New in 1.4.0: Don't paint rollovers on top menus
// as long as a system menu is showing
menu.addMenuListener(new MenuListener() {
public void menuSelected(MenuEvent e) {
if(frameHasMenuBar()) {
TinyMenuUI.systemMenuShowing = true;
}
}
public void menuDeselected...
[truncated message content] |