Update of /cvsroot/squirrel-sql/mavenize/thirdparty-non-maven/tinylaf-1_4_0/src/de/muntjak/tinylookandfeel/borders
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv29130/thirdparty-non-maven/tinylaf-1_4_0/src/de/muntjak/tinylookandfeel/borders
Added Files:
TinyProgressBarBorder.java TinySpinnerBorder.java
TinyMenuBarBorder.java TinyTextFieldBorder.java
TinyPopupMenuBorder.java TinyScrollPaneBorder.java
TinyTableHeaderRolloverBorder.java TinyToolTipBorder.java
TinyButtonBorder.java TinyToolButtonBorder.java
TinyTableScrollPaneBorder.java TinyTableHeaderBorder.java
TinyFrameBorder.java TinyInternalFrameBorder.java
TinyToolBarBorder.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: TinyTableHeaderRolloverBorder.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.borders;
import java.awt.Component;
import java.awt.Graphics;
import de.muntjak.tinylookandfeel.Theme;
import de.muntjak.tinylookandfeel.util.ColorRoutines;
/**
* TinyTableHeaderRolloverBorder is the border displayed for table headers
* of sortable table models if the column in question is the rollover column.
*
* @version 1.0
* @author Hans Bickel
*/
public class TinyTableHeaderRolloverBorder extends TinyTableHeaderBorder {
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
if(color1 == null) {
color1 = Theme.tableHeaderRolloverColor.getColor();
color2 = ColorRoutines.lighten(color1, 25);
}
g.setColor(color1);
g.drawLine(x, y + h - 3, x + w - 1, y + h - 3); // top
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1); // bottom
g.setColor(color2);
g.drawLine(x, y + h - 2, x + w - 1, y + h - 2); // mid
// don't paint separator
}
}
--- NEW FILE: TinyTableHeaderBorder.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.borders;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;
import javax.swing.border.AbstractBorder;
import javax.swing.plaf.UIResource;
import de.muntjak.tinylookandfeel.Theme;
import de.muntjak.tinylookandfeel.util.ColorRoutines;
/**
* TinyTableHeaderBorder is the border displayed for table headers
* of non-sortable table models and of sortable table models if
* the column in question is not the rollover column.
*
* @version 1.0
* @author Hans Bickel
*/
public class TinyTableHeaderBorder extends AbstractBorder implements UIResource {
protected static final Insets insetsXP = new Insets(3, 0, 3, 2);
protected Color color1, color2, color3, color4, color5;
public Insets getBorderInsets(Component c) {
return insetsXP;
}
public Insets getBorderInsets(Component c, Insets insets) {
insets.left = insetsXP.left;
insets.top = insetsXP.top;
insets.right = insetsXP.right;
insets.bottom = insetsXP.bottom;
return insets;
}
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
if(color1 == null) {
color1 = ColorRoutines.darken(c.getBackground(), 5);
color2 = ColorRoutines.darken(c.getBackground(), 10);
color3 = ColorRoutines.darken(c.getBackground(), 15);
color4 = Theme.tableHeaderDarkColor.getColor();
color5 = Theme.tableHeaderLightColor.getColor();
}
// paint 3 bottom lines
g.setColor(color1);
g.drawLine(x, y + h - 3, x + w - 1, y + h - 3);
g.setColor(color2);
g.drawLine(x, y + h - 2, x + w - 1, y + h - 2);
g.setColor(color3);
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
// paint separator
g.setColor(color4);
g.drawLine(x + w - 2, y + 3, x + w - 2, y + h - 5);
g.setColor(color5);
g.drawLine(x + w - 1, y + 3, x + w - 1, y + h - 5);
}
}
--- NEW FILE: TinyFrameBorder.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.borders;
import java.awt.Color;
import java.awt.Component;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Window;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.border.AbstractBorder;
import javax.swing.plaf.UIResource;
import de.muntjak.tinylookandfeel.Theme;
import de.muntjak.tinylookandfeel.TinyLookAndFeel;
import de.muntjak.tinylookandfeel.util.ColorRoutines;
/**
* TinyFrameBorder
*
* @version 1.4.0
* @author Hans Bickel
*/
public class TinyFrameBorder extends AbstractBorder implements UIResource {
public static final int FRAME_BORDER_WIDTH = 3;
public static final int FRAME_TITLE_HEIGHT = 29;
public static final int FRAME_INTERNAL_TITLE_HEIGHT = 25;
public static final int FRAME_PALETTE_TITLE_HEIGHT = 21;
// Note: These are set at ControlPanel.DisabledFramePanel.paintComponent
public static Color buttonUpperDisabledColor, buttonLowerDisabledColor;
// Reusable rectangle for capturing screen rects
private static final Rectangle theRect = new Rectangle();
private static TinyFrameBorder onlyInstance;
private Window window;
private int titleHeight;
private boolean isActive;
public static TinyFrameBorder getInstance() {
if(onlyInstance == null) {
onlyInstance = new TinyFrameBorder();
}
return onlyInstance;
}
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
// System.out.println("paintBorder(...), c=" + c);
window = SwingUtilities.getWindowAncestor(c);
isActive = window.isActive();
if(window instanceof JFrame) {
titleHeight = FRAME_TITLE_HEIGHT;
}
else if(window instanceof JDialog) {
titleHeight = FRAME_TITLE_HEIGHT;
}
else {
titleHeight = FRAME_INTERNAL_TITLE_HEIGHT;
}
if(isActive) {
g.setColor(Theme.frameBorderColor.getColor());
}
else {
g.setColor(Theme.frameBorderDisabledColor.getColor());
}
drawXpBorder(g, x, y, w, h);
}
private void drawXpBorder(Graphics g, int x, int y, int w, int h) {
// left
g.drawLine(x, y + 6, x, y + h - 1);
g.drawLine(x + 2, y + titleHeight, x + 2, y + h - 3);
// right
g.drawLine(x + w - 1, y + 6, x + w - 1, y + h - 1);
g.drawLine(x + w - 3, y + titleHeight, x + w - 3, y + h - 3);
// bottom
g.drawLine(x + 2, y + h - 3, x + w - 3, y + h - 3);
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
if(TinyLookAndFeel.ROBOT != null) {
// Copy a 4 x 4 rect to left and right corners
int wx = window.getLocationOnScreen().x - 4;
int wy = window.getLocationOnScreen().y;
theRect.setBounds(wx, wy, 4, 4);
g.drawImage(TinyLookAndFeel.ROBOT.createScreenCapture(theRect), x, y, null);
wx = window.getLocationOnScreen().x + window.getWidth() + 1;
theRect.setBounds(wx, wy, 4, 4);
g.drawImage(TinyLookAndFeel.ROBOT.createScreenCapture(theRect), x + w - 4, y, null);
}
else {
g.setColor(Theme.backColor.getColor());
g.fillRect(0, 0, w, 3);
}
if(isActive) {
g.setColor(Theme.frameCaptionColor.getColor());
}
else {
g.setColor(Theme.frameCaptionDisabledColor.getColor());
}
// left
g.drawLine(x + 1, y + titleHeight, x + 1, y + h - 2);
// right
g.drawLine(x + w - 2, y + titleHeight, x + w - 2, y + h - 2);
// bottom
g.drawLine(x + 1, y + h - 2, x + w - 2, y + h - 2);
Color c = null;
if(isActive) {
c = Theme.frameBorderColor.getColor();
}
else {
c = Theme.frameBorderDisabledColor.getColor();
}
g.setColor(ColorRoutines.getAlphaColor(c, 82));
g.drawLine(x, y + 3, x, y + 3);
g.drawLine(x + w - 1, y + 3, x + w - 1, y + 3);
g.setColor(ColorRoutines.getAlphaColor(c, 156));
g.drawLine(x, y + 4, x, y + 4);
g.drawLine(x + w - 1, y + 4, x + w - 1, y + 4);
g.setColor(ColorRoutines.getAlphaColor(c, 215));
g.drawLine(x, y + 5, x, y + 5);
g.drawLine(x + w - 1, y + 5, x + w - 1, y + 5);
// new in 1.4.0: Paint pixels x=1 and x=2 and x=w-2 and x=w-3
if(isActive) {
c = Theme.frameCaptionColor.getColor();
}
else {
c = Theme.frameCaptionDisabledColor.getColor();
}
int spread1 = Theme.frameSpreadDarkDisabled.getValue();
int spread2 = Theme.frameSpreadLightDisabled.getValue();
Color borderColor = null;
if(isActive) {
borderColor = Theme.frameBorderColor.getColor();
spread1 = Theme.frameSpreadDark.getValue();
spread2 = Theme.frameSpreadLight.getValue();
}
int y2 = 1;
// paint semi-transparent pixels
// 2
Color c2 = ColorRoutines.darken(c, 4 * spread1);
// blend
g.setColor(ColorRoutines.getAlphaColor(c2, 139));
g.drawLine(x + 2, y2, x + 2, y2);
g.drawLine(x + w - 3, y2, x + w - 3, y2);
g.setColor(ColorRoutines.getAlphaColor(c2, 23));
g.drawLine(x + 1, y2, x + 1, y2);
g.drawLine(x + w - 2, y2, x + w - 2, y2);
y2 ++;
// 3
c2 = ColorRoutines.darken(c, 6 * spread1);
g.setColor(c2);
g.drawLine(x + 2, y2, x + 2, y2);
g.drawLine(x + w - 3, y2, x + w - 3, y2);
// blend
g.setColor(ColorRoutines.getAlphaColor(c2, 139));
g.drawLine(x + 1, y2, x + 1, y2);
g.drawLine(x + w - 2, y2, x + w - 2, y2);
y2 ++;
// 4
// darker border
g.setColor(c);
g.drawLine(x + 2, y2, x + 2, y2);
g.drawLine(x + w - 3, y2, x + w - 3, y2);
g.setColor(ColorRoutines.darken(c, 6 * spread1));
g.drawLine(x + 1, y2, x + 1, y2);
g.drawLine(x + w - 2, y2, x + w - 2, y2);
y2 ++;
// 5
// darker border
g.setColor(ColorRoutines.darken(c, 6 * spread1));
g.drawLine(x + 1, y2, x + 1, y2);
g.drawLine(x + w - 2, y2, x + w - 2, y2);
// blend from lightest color
g.setColor(ColorRoutines.lighten(c, 10 * spread2));
g.drawLine(x + 2, y2, x + 2, y2);
g.drawLine(x + w - 3, y2, x + w - 3, y2);
y2 ++;
// paint solid pixels
// 6
g.setColor(ColorRoutines.darken(c, 4 * spread1));
g.drawLine(x + 2, y2, x + 2, y2);
g.drawLine(x + w - 3, y2, x + w - 3, y2);
// lighten little
g.setColor(ColorRoutines.darken(c, 4 * spread1));
g.drawLine(x + 1, y2, x + 1, y2);
g.drawLine(x + w - 2, y2, x + w - 2, y2);
y2 ++;
// 7 - 8
g.setColor(ColorRoutines.darken(c, 4 * spread1));
g.fillRect(x + 1, y2, 2, 2);
g.fillRect(x + w - 3, y2, 2, 2);
y2 += 2;
// 9 - 12
g.setColor(ColorRoutines.darken(c, 3 * spread1));
g.fillRect(x + 1, y2, 2, 4);
g.fillRect(x + w - 3, y2, 2, 4);
y2 += 4;
// 13 - 15
g.setColor(ColorRoutines.darken(c, 2 * spread1));
g.fillRect(x + 1, y2, 2, 3);
g.fillRect(x + w - 3, y2, 2, 3);
y2 += 3;
// 16 - 17
g.setColor(ColorRoutines.darken(c, 1 * spread1));
g.fillRect(x + 1, y2, 2, 2);
g.fillRect(x + w - 3, y2, 2, 2);
y2 += 2;
// 18 - 19
g.setColor(c);
g.fillRect(x + 1, y2, 2, 2);
g.fillRect(x + w - 3, y2, 2, 2);
y2 += 2;
// 20...
g.setColor(ColorRoutines.lighten(c, 2 * spread2));
g.drawLine(x + 1, y2, x + 2, y2);
g.drawLine(x + w - 2, y2, x + w - 3, y2);
y2 ++;
g.setColor(ColorRoutines.lighten(c, 4 * spread2));
g.drawLine(x + 1, y2, x + 2, y2);
g.drawLine(x + w - 2, y2, x + w - 3, y2);
y2 ++;
g.setColor(ColorRoutines.lighten(c, 5 * spread2));
g.drawLine(x + 1, y2, x + 2, y2);
g.drawLine(x + w - 2, y2, x + w - 3, y2);
y2 ++;
g.setColor(ColorRoutines.lighten(c, 6 * spread2));
g.drawLine(x + 1, y2, x + 2, y2);
g.drawLine(x + w - 2, y2, x + w - 3, y2);
y2 ++;
g.setColor(ColorRoutines.lighten(c, 8 * spread2));
g.drawLine(x + 1, y2, x + 2, y2);
g.drawLine(x + w - 2, y2, x + w - 3, y2);
y2 ++;
g.setColor(ColorRoutines.lighten(c, 9 * spread2));
g.drawLine(x + 1, y2, x + 2, y2);
g.drawLine(x + w - 2, y2, x + w - 3, y2);
y2 ++;
g.setColor(ColorRoutines.lighten(c, 10 * spread2));
g.drawLine(x + 1, y2, x + 2, y2);
g.drawLine(x + w - 2, y2, x + w - 3, y2);
y2 ++;
// 27
g.setColor(ColorRoutines.lighten(c, 4 * spread2));
g.drawLine(x + 1, y2, x + 2, y2);
g.drawLine(x + w - 2, y2, x + w - 3, y2);
y2 ++;
// 28
g.setColor(ColorRoutines.darken(c, 2 * spread1));
g.drawLine(x + 1, y2, x + 2, y2);
g.drawLine(x + w - 2, y2, x + w - 3, y2);
y2 ++;
// 29
if(isActive) {
g.setColor(Theme.frameLightColor.getColor());
}
else {
g.setColor(Theme.frameLightDisabledColor.getColor());
}
g.drawLine(x + 1, y2, x + 2, y2);
g.drawLine(x + w - 2, y2, x + w - 3, y2);
}
/**
*
* @see javax.swing.border.Border#getBorderInsets(Component)
*/
public Insets getBorderInsets(Component c) {
Window w = SwingUtilities.getWindowAncestor(c);
if(w != null && (w instanceof Frame)) {
Frame f = (Frame)w;
// if the frame is maximized, the border should not be visible
if(f.getExtendedState() == (f.getExtendedState() | Frame.MAXIMIZED_BOTH)) {
return new Insets(0, 0, 0, 0);
}
}
return new Insets(0,
FRAME_BORDER_WIDTH,
FRAME_BORDER_WIDTH,
FRAME_BORDER_WIDTH);
}
}
--- NEW FILE: TinyProgressBarBorder.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.borders;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.AbstractBorder;
import javax.swing.plaf.UIResource;
import de.muntjak.tinylookandfeel.*;
import de.muntjak.tinylookandfeel.util.DrawRoutines;
/**
* TinyProgressBarBorder
*
* @version 1.0
* @author Hans Bickel
*/
public class TinyProgressBarBorder extends AbstractBorder implements UIResource {
protected static final Insets INSETS_YQ = new Insets(3, 3, 3, 3);
/**
* Draws the button border for the given component.
*
* @param mainColor The component to draw its border.
* @param g The graphics context.
* @param x The x coordinate of the top left corner.
* @param y The y coordinate of the top left corner.
* @param w The width.
* @param h The height.
*/
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
drawXpBorder(c, g, x, y, w, h);
}
private void drawXpBorder(Component c, Graphics g, int x, int y, int w, int h) {
DrawRoutines.drawProgressBarBorder(g,
Theme.progressBorderColor.getColor(), x, y, w, h);
DrawRoutines.drawProgressBarBorder(g,
Theme.progressDarkColor.getColor(), x + 1, y + 1, w - 2, h - 2);
w -= 4; h -= 4;
x += 2; y += 2;
g.setColor(Theme.progressLightColor.getColor());
// rect
g.drawLine(x + 1, y, x + w - 2, y);
g.drawLine(x, y + 1, x, y + h - 2);
// track
g.setColor(Theme.progressTrackColor.getColor());
g.drawLine(x + 1, y + h - 1, x + w - 2, y + h - 1);
g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 2);
}
/**
* Gets the border insets for a given component.
*
* @param c The component to get its border insets.
* @return Always returns the same insets as defined in <code>insets</code>.
*/
public Insets getBorderInsets(Component c) {
return INSETS_YQ;
}
}
--- NEW FILE: TinyTableScrollPaneBorder.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.borders;
import java.awt.*;
import javax.swing.border.AbstractBorder;
import javax.swing.plaf.UIResource;
import de.muntjak.tinylookandfeel.*;
import de.muntjak.tinylookandfeel.controlpanel.*;
/**
* TinyTableScrollPaneBorder
*
* @version 1.0
* @author Hans Bickel
*/
public class TinyTableScrollPaneBorder extends AbstractBorder implements UIResource {
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.setColor(Theme.tableBorderLightColor.getColor());
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1); // right
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1); // bottom
g.setColor(Theme.tableBorderDarkColor.getColor());
g.drawLine(x, y, x, y + h - 1); // left
g.drawLine(x, y, x + w - 1, y); // top
}
public Insets getBorderInsets(Component c) {
return insets;
}
}
--- NEW FILE: TinySpinnerBorder.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.borders;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;
import javax.swing.border.AbstractBorder;
import javax.swing.plaf.UIResource;
import de.muntjak.tinylookandfeel.Theme;
import de.muntjak.tinylookandfeel.util.DrawRoutines;
/**
* TinySpinnerBorder
* @author Hans Bickel
*
*/
public class TinySpinnerBorder extends AbstractBorder implements UIResource {
private static final Insets insets = new Insets(2, 2, 2, 2);
/**
* Gets the border insets for a given component.
*
* @param mainColor The component to get its border insets.
* @return Always returns the same insets as defined in <code>insets</code>.
*/
public Insets getBorderInsets(Component c) {
return insets;
}
/**
* Use the skin to paint the border
* @see javax.swing.border.Border#paintBorder(Component, Graphics, int, int, int, int)
*/
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
drawXpBorder(c, g, x, y, w, h);
}
private void drawXpBorder(Component c, Graphics g, int x, int y, int w, int h) {
if(!c.isEnabled()) {
DrawRoutines.drawBorder(
g, Theme.spinnerBorderDisabledColor.getColor(), x, y, w, h);
}
else {
DrawRoutines.drawBorder(
g, Theme.spinnerBorderColor.getColor(), x, y, w, h);
}
}
}
--- NEW FILE: TinyToolTipBorder.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.borders;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.Border;
import de.muntjak.tinylookandfeel.Theme;
/**
* TinyToolTipBorder
*
* @version 1.0
* @author Hans Bickel
*/
public class TinyToolTipBorder implements Border {
private static final Insets insets = new Insets(3, 3, 3, 3);
private boolean active;
public TinyToolTipBorder(boolean b) {
active = b;
}
public boolean isBorderOpaque() {
return false;
}
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
if(active) {
g.setColor(Theme.tipBorderColor.getColor());
}
else {
g.setColor(Theme.tipBorderDis.getColor());
}
g.drawRect(x, y, w - 1, h - 1);
}
public Insets getBorderInsets(Component c) {
return insets;
}
}
--- NEW FILE: TinyScrollPaneBorder.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.borders;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;
import javax.swing.border.AbstractBorder;
import javax.swing.plaf.UIResource;
import de.muntjak.tinylookandfeel.Theme;
/**
* TinyScrollPaneBorder
*
* @version 1.0
* @author Hans Bickel
*/
public class TinyScrollPaneBorder extends AbstractBorder implements UIResource {
private static final Insets defaultInsets = new Insets(1, 1, 1, 1);
public Insets getBorderInsets(Component c) {
return defaultInsets;
}
/**
* @see javax.swing.border.Border#paintBorder(Component, Graphics, int, int, int, int)
*/
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
g.setColor(Theme.scrollPaneBorderColor.getColor());
g.drawRect(x, y, w - 1, h - 1);
}
}
--- NEW FILE: TinyToolButtonBorder.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.borders;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.AbstractBorder;
import javax.swing.plaf.FileChooserUI;
import javax.swing.plaf.UIResource;
import de.muntjak.tinylookandfeel.*;
import de.muntjak.tinylookandfeel.util.DrawRoutines;
/**
* TinyToolButtonBorder is the border for JButton, JToggleButton and JSpinner buttons.
*
* @version 1.0
* @author Hans Bickel
*/
public class TinyToolButtonBorder extends AbstractBorder {
protected static final Insets insets = new Insets(1, 1, 1, 1);
/**
* Draws the button border for the given component.
*
* @param mainColor The component to draw its border.
* @param g The graphics context.
* @param x The x coordinate of the top left corner.
* @param y The y coordinate of the top left corner.
* @param w The width.
* @param h The height.
*/
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
drawXpBorder(c, g, x, y, w, h);
}
private void drawXpBorder(Component c, Graphics g, int x, int y, int w, int h) {
AbstractButton b = (AbstractButton)c;
Color col = null;
boolean isFileChooserButton = Boolean.TRUE.equals(
b.getClientProperty(TinyFileChooserUI.IS_FILE_CHOOSER_BUTTON_KEY));
// New in 1.3.7 (previously only b.getModel().isRollover() evaluated)
boolean isRollover = b.getModel().isRollover() || b.getModel().isArmed();
if(b.getModel().isPressed()) {
if(isRollover) {
col = Theme.toolBorderPressedColor.getColor();
}
else {
if(b.isSelected()) {
col = Theme.toolBorderSelectedColor.getColor();
}
else {
if(isFileChooserButton) return; // no border painted
col = Theme.toolBorderColor.getColor();
}
}
}
else if(isRollover) {
if(b.isSelected()) {
col = Theme.toolBorderSelectedColor.getColor();
}
else {
col = Theme.toolBorderRolloverColor.getColor();
}
}
else if(b.isSelected()) {
col = Theme.toolBorderSelectedColor.getColor();
}
else {
if(isFileChooserButton) return; // no border painted
col = Theme.toolBorderColor.getColor();
}
DrawRoutines.drawRoundedBorder(g, col, x, y, w, h);
}
/**
* Gets the border insets for a given component.
*
* @return some insets...
*/
public Insets getBorderInsets(Component c) {
if(!(c instanceof AbstractButton)) return insets;
AbstractButton b = (AbstractButton)c;
if(b.getMargin() == null || (b.getMargin() instanceof UIResource)) {
return Theme.toolMargin;
}
else {
Insets margin = b.getMargin();
return new Insets(
margin.top + 1,
margin.left + 1,
margin.bottom + 1,
margin.right + 1);
}
}
}
--- NEW FILE: TinyToolBarBorder.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.borders;
import java.awt.*;
import javax.swing.JToolBar;
import javax.swing.plaf.metal.MetalBorders.ToolBarBorder;
import de.muntjak.tinylookandfeel.Theme;
import de.muntjak.tinylookandfeel.TinyToolBarUI;
import de.muntjak.tinylookandfeel.util.DrawRoutines;
/**
* TinyToolBarBorder
*
* @version 1.0
* @author Hans Bickel
*/
public class TinyToolBarBorder extends ToolBarBorder {
public Insets getBorderInsets(Component c) {
return getBorderInsets(c, new Insets(0, 0, 0, 0));
}
public Insets getBorderInsets(Component c, Insets newInsets) {
newInsets.top = newInsets.left = newInsets.bottom = newInsets.right = 2;
// we cannot assume that c is a JToolBar
if(!(c instanceof JToolBar)) return newInsets;
if(((JToolBar)c).isFloatable()) {
if(((JToolBar)c).getOrientation() == HORIZONTAL) {
if(c.getComponentOrientation().isLeftToRight()) {
newInsets.left = TinyToolBarUI.FLOATABLE_GRIP_SIZE + 2;
} else {
newInsets.right = TinyToolBarUI.FLOATABLE_GRIP_SIZE + 2;
}
} else { // vertical
newInsets.top = TinyToolBarUI.FLOATABLE_GRIP_SIZE + 2;
}
}
Insets margin = ((JToolBar)c).getMargin();
if(margin != null) {
newInsets.left += margin.left;
newInsets.top += margin.top;
newInsets.right += margin.right;
newInsets.bottom += margin.bottom;
}
return newInsets;
}
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
if(!(c instanceof JToolBar)) return;
drawXPBorder(c, g, x, y, w, h);
if(((JToolBar)c).getOrientation() == HORIZONTAL) {
g.setColor(Theme.toolBarLightColor.getColor());
g.drawLine(x, y, w - 1, y); // top
g.setColor(Theme.toolBarDarkColor.getColor());
g.drawLine(x, h - 1, w - 1, h - 1); // bottom
}
else {
g.setColor(Theme.toolBarLightColor.getColor());
g.drawLine(x, y, x, h - 1); // left
g.setColor(Theme.toolBarDarkColor.getColor());
g.drawLine(w - 1, y, w - 1, h - 1); // right
}
}
protected void drawXPBorder(Component c, Graphics g, int x, int y, int w, int h) {
g.translate(x, y);
if(((JToolBar)c).isFloatable()) {
// paint grip
if(((JToolBar)c).getOrientation() == HORIZONTAL) {
int xoff = 3;
if(!c.getComponentOrientation().isLeftToRight()) {
xoff = c.getBounds().width - TinyToolBarUI.FLOATABLE_GRIP_SIZE + 3;
}
g.setColor(Theme.toolGripLightColor.getColor());
g.drawLine(xoff, 3, xoff + 1, 3);
g.drawLine(xoff, 3, xoff, h - 5);
g.setColor(Theme.toolGripDarkColor.getColor());
g.drawLine(xoff, h - 4, xoff + 1, h - 4);
g.drawLine(xoff + 2, 3, xoff + 2, h - 4);
} else { // vertical
g.setColor(Theme.toolGripLightColor.getColor());
g.drawLine(3, 3, 3, 4);
g.drawLine(3, 3, w - 4, 3);
g.setColor(Theme.toolGripDarkColor.getColor());
g.drawLine(w - 4, 4, w - 4, 5);
g.drawLine(3, 5, w - 4, 5);
}
}
g.translate(-x, -y);
}
}
--- NEW FILE: TinyButtonBorder.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.borders;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.AbstractBorder;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import javax.swing.plaf.UIResource;
import de.muntjak.tinylookandfeel.*;
import de.muntjak.tinylookandfeel.util.DrawRoutines;
/**
* TinyButtonBorder is the border for JButton, JToggleButton and JSpinner buttons.
*
* @version 1.0
* @author Hans Bickel
*/
public class TinyButtonBorder extends AbstractBorder implements UIResource {
protected final Insets borderInsets = new Insets(2, 2, 2, 2);
/**
* Draws the button border for the given component.
*
* @param c The component to draw its border.
* @param g The graphics context.
* @param x The x coordinate of the top left corner.
* @param y The y coordinate of the top left corner.
* @param w The width.
* @param h The height.
*/
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
// new in 1.4.0 - if we are not inside the control panel,
// components paint their own border, so it can be cached
if(!TinyLookAndFeel.controlPanelInstantiated) return;
AbstractButton b = (AbstractButton)c;
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 isSpinnerButton =
Boolean.TRUE.equals(b.getClientProperty("isSpinnerButton"));
boolean paintRollover =
(isSpinnerButton && Theme.spinnerRollover.getValue()) ||
(!isSpinnerButton && Theme.buttonRolloverBorder.getValue());
if(isSpinnerButton) {
// Because spinner buttons are small, we paint
// a simple and fast border
// New in 1.4.0: Instead of using button border colors
// we use spinner border colors
// paint background for edges
g.setColor(TinySpinnerButtonUI.getSpinnerParent(b).getBackground());
g.drawRect(0, 0, w - 1, h - 1);
// left/top resp. left/bottom pixel should be painted
// with spinner background
g.setColor(TinySpinnerButtonUI.getSpinner(b).getBackground());
if(Boolean.TRUE.equals(b.getClientProperty("isNextButton"))) {
// left/bottom
g.drawLine(0, h - 1, 0, h - 1);
}
else {
// left/top
g.drawLine(0, 0, 0, 0);
}
if(!b.isEnabled()) {
g.setColor(Theme.spinnerBorderDisabledColor.getColor());
}
else {
g.setColor(Theme.spinnerBorderColor.getColor());
}
g.drawLine(x + 1, y, x + w - 2, y);
g.drawLine(x + 1, y + h - 1, x + w - 2, y + h - 1);
g.drawLine(x, y + 1, x, y + h - 2);
g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 2);
if(b.getModel().isPressed()) return;
if(b.getModel().isRollover() && paintRollover) {
DrawRoutines.drawRolloverBorder(
g, Theme.buttonRolloverColor.getColor(), x, y, w, h);
}
}
else { // it's a JButton or a JToggleButton
boolean isDefault = (c instanceof JButton) && ((JButton)c).isDefaultButton();
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() && paintRollover) {
DrawRoutines.drawRolloverBorder(
g, Theme.buttonRolloverColor.getColor(), x, y, w, h);
}
// New in 1.4.0: If isFocusPainted is false, no focus border
// will be painted
else if(isDefault ||
(Theme.buttonFocusBorder.getValue() &&
b.isFocusOwner() && b.isFocusPainted()))
{
DrawRoutines.drawRolloverBorder(
g, Theme.buttonDefaultColor.getColor(), x, y, w, h);
}
}
}
}
}
/**
* Gets the border insets for a given component.
*
* @param c The component to get its border insets.
* @return Always returns the same insets as defined in <code>insets</code>.
*/
public Insets getBorderInsets(Component c) {
return borderInsets;
}
public static class CompoundBorderUIResource extends CompoundBorder implements UIResource {
public CompoundBorderUIResource(Border outsideBorder, Border insideBorder) {
super(outsideBorder, insideBorder);
}
}
}
--- NEW FILE: TinyInternalFrameBorder.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.borders;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.*;
import javax.swing.*;
import javax.swing.border.AbstractBorder;
import javax.swing.plaf.UIResource;
[...973 lines suppressed...]
CaptionKey(boolean isActive, int titleHeight) {
this.isActive = isActive;
this.titleHeight = titleHeight;
}
public boolean equals(Object o) {
if(o == null) return false;
if(!(o instanceof CaptionKey)) return false;
CaptionKey other = (CaptionKey)o;
return isActive == other.isActive &&
titleHeight == other.titleHeight;
}
public int hashCode() {
return (isActive ? 1 : 2) * titleHeight;
}
}
}
--- NEW FILE: TinyPopupMenuBorder.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.borders;
import java.awt.Component;
import java.awt.ComponentOrientation;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Insets;
import java.awt.image.BufferedImage;
import javax.swing.JComponent;
import javax.swing.JMenu;
import javax.swing.JPopupMenu;
import javax.swing.border.AbstractBorder;
import javax.swing.plaf.UIResource;
import de.muntjak.tinylookandfeel.Theme;
import de.muntjak.tinylookandfeel.TinyLookAndFeel;
import de.muntjak.tinylookandfeel.TinyPopupFactory;
/**
* TinyPopupMenuBorder
*
* @version 1.0
* @author Hans Bickel
*/
public class TinyPopupMenuBorder extends AbstractBorder implements UIResource {
public static final int SHADOW_SIZE = 5;
private static final Insets INSETS_NO_SHADOW = new Insets(2, 2, 2, 2);
private static final Insets INSETS_SHADOW_LEFT_TO_RIGHT = new Insets(2, 2, 7, 7);
private static final Insets INSETS_SHADOW_RIGHT_TO_LEFT = new Insets(2, 7, 7, 2);
public static final Image LEFT_TO_RIGHT_SHADOW_MASK =
TinyLookAndFeel.loadIcon("leftToRightShadow.png").getImage();
public static final Image RIGHT_TO_LEFT_SHADOW_MASK =
TinyLookAndFeel.loadIcon("rightToLeftShadow.png").getImage();
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
boolean hasShadow = Boolean.TRUE.equals(
((JComponent)c).getClientProperty(TinyPopupFactory.SHADOW_POPUP_KEY));
boolean isLeftToRight = isOrientationLeftToRight(c);
g.translate(x, y);
int bx = 0;
int bw = w;
int bh = h;
if(hasShadow) {
if(isLeftToRight) {
bw -= SHADOW_SIZE;
bh -= SHADOW_SIZE;
// Draw background images (unscaled)
BufferedImage img = (BufferedImage)((JComponent)c).getClientProperty(TinyPopupFactory.VERTICAL_IMAGE_KEY);
g.drawImage(img, bw, 0, c);
img = (BufferedImage)((JComponent)c).getClientProperty(TinyPopupFactory.HORIZONTAL_IMAGE_KEY);
g.drawImage(img, 0, bh, c);
}
else {
bh -= SHADOW_SIZE;
bx = SHADOW_SIZE;
// Draw background images (unscaled)
BufferedImage img = (BufferedImage)((JComponent)c).getClientProperty(TinyPopupFactory.VERTICAL_IMAGE_KEY);
if(img != null) g.drawImage(img, 0, 0, c);
img = (BufferedImage)((JComponent)c).getClientProperty(TinyPopupFactory.HORIZONTAL_IMAGE_KEY);
if(img != null) g.drawImage(img, 0, bh, c);
}
}
// Note: With right-to-left orientation, we flip
// inner highlight and inner shadow horizontally,
// BUT this works only with shadow popups (because
// else we have no information about the popup's
// orientation)
// Inner highlight
g.setColor(Theme.menuInnerHilightColor.getColor());
g.drawLine(bx + 1, 1, bw - 3, 1);
if(isLeftToRight) {
g.drawLine(bx + 1, 1, bx + 1, bh - 3);
}
else {
g.drawLine(bw - 2, 1, bw - 2, bh - 2);
}
// Inner shadow
g.setColor(Theme.menuInnerShadowColor.getColor());
if(isLeftToRight) {
g.drawLine(bw - 2, 1, bw - 2, bh - 2);
}
else {
g.drawLine(bx + 1, 1, bx + 1, bh - 2);
}
g.drawLine(bx + 1, bh - 2, bw - 2, bh - 2);
// Outer highlight
g.setColor(Theme.menuOuterHilightColor.getColor());
g.drawLine(bx, 0, bw - 2, 0);
g.drawLine(bx, 0, bx, bh - 1);
// Outer shadow
g.setColor(Theme.menuOuterShadowColor.getColor());
g.drawLine(bw - 1, 0, bw - 1, bh - 1);
g.drawLine(bx, bh - 1, bw - 1, bh - 1);
if(hasShadow) {
// paint shadows
if(isLeftToRight) {
// non-scaled
g.drawImage(LEFT_TO_RIGHT_SHADOW_MASK,
bw, 4, bw + SHADOW_SIZE, 8,
6, 0, 11, 4, c);
g.drawImage(LEFT_TO_RIGHT_SHADOW_MASK,
4, bh, 8, bh + SHADOW_SIZE,
0, 6, 4, 11, c);
g.drawImage(LEFT_TO_RIGHT_SHADOW_MASK,
bw, bh, bw + SHADOW_SIZE, bh + SHADOW_SIZE,
6, 6, 11, 11, c);
// scaled
g.drawImage(LEFT_TO_RIGHT_SHADOW_MASK,
bw, 8, bw + SHADOW_SIZE, bh,
6, 4, 11, 5, c);
g.drawImage(LEFT_TO_RIGHT_SHADOW_MASK,
8, bh, bw, bh + SHADOW_SIZE,
4, 6, 5, 11, c);
}
else {
// non-scaled
g.drawImage(RIGHT_TO_LEFT_SHADOW_MASK,
0, 4, SHADOW_SIZE, 8,
0, 0, 5, 4, c);
g.drawImage(RIGHT_TO_LEFT_SHADOW_MASK,
bw - 8, bh, bw - 4, bh + SHADOW_SIZE,
7, 6, 11, 11, c);
g.drawImage(RIGHT_TO_LEFT_SHADOW_MASK,
0, bh, SHADOW_SIZE, bh + SHADOW_SIZE,
0, 6, 6, 11, c);
// // scaled
g.drawImage(RIGHT_TO_LEFT_SHADOW_MASK,
0, 8, SHADOW_SIZE, bh,
0, 4, 5, 5, c);
g.drawImage(RIGHT_TO_LEFT_SHADOW_MASK,
SHADOW_SIZE, bh, bw - 8, bh + SHADOW_SIZE,
5, 6, 6, 11, c);
}
}
g.translate(-x, -y);
}
/**
* Gets the border insets for a given component.
*
* @param c The component to get its border insets.
* @return different insets for shadow and non-shadow popups
*/
public Insets getBorderInsets(Component c) {
if(TinyPopupFactory.isPopupShadowEnabled()) {
if(isOrientationLeftToRight(c)) {
return INSETS_SHADOW_LEFT_TO_RIGHT;
}
return INSETS_SHADOW_RIGHT_TO_LEFT;
}
return INSETS_NO_SHADOW;
}
private boolean isOrientationLeftToRight(Component c) {
if(!(c instanceof JComponent)) {
return true;
}
Object co = ((JComponent)c).getClientProperty(TinyPopupFactory.COMPONENT_ORIENTATION_KEY);
if(co == null && (c instanceof JPopupMenu)) {
Component invoker = ((JPopupMenu)c).getInvoker();
if(invoker != null) {
co = invoker.getComponentOrientation();
}
}
return (co == null ? true : ((ComponentOrientation)co).isLeftToRight());
}
public static String componentOrientationToString(ComponentOrientation co) {
if(co == null) return "<null>";
return (co.isLeftToRight() ? "left-to-right" : "right-to-left");
}
}
--- NEW FILE: TinyMenuBarBorder.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.borders;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;
import javax.swing.JMenuBar;
import javax.swing.UIManager;
import javax.swing.border.AbstractBorder;
import javax.swing.plaf.UIResource;
import javax.swing.plaf.metal.MetalLookAndFeel;
import javax.swing.plaf.metal.MetalToolBarUI;
import de.muntjak.tinylookandfeel.Theme;
import de.muntjak.tinylookandfeel.TinyToolBarUI;
/**
* The border for menu bars.
*
* @author Hans Bickel
* @version 1.4.0
*/
public class TinyMenuBarBorder extends AbstractBorder implements UIResource {
static final Insets borderInsets = new Insets(1, 1, 2, 1);
public Insets getBorderInsets(Component c) {
return borderInsets;
}
public Insets getBorderInsets(Component c, Insets newInsets) {
newInsets.top = borderInsets.top;
newInsets.left = borderInsets.left;
newInsets.bottom = borderInsets.bottom;
newInsets.right = borderInsets.right;
return newInsets;
}
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
// Only paint a border if we're not next to a horizontal toolbar
if(!TinyToolBarUI.doesMenuBarBorderToolBar((JMenuBar)c)) {
g.translate(x, y);
g.setColor(Theme.toolBarDarkColor.getColor());
g.drawLine(0, h - 1, w, h - 1);
g.translate(-x, -y);
}
}
}
--- NEW FILE: TinyTextFieldBorder.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.borders;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;
import javax.swing.border.AbstractBorder;
import javax.swing.plaf.UIResource;
import de.muntjak.tinylookandfeel.Theme;
import de.muntjak.tinylookandfeel.util.DrawRoutines;
/**
* TinyTextFieldBorder
*
* @version 1.0
* @author Hans Bickel
*/
public class TinyTextFieldBorder extends AbstractBorder implements UIResource {
/**
* Gets the border insets for a given component.
*
* @param c The component to get its border insets.
* @return Always returns the same insets as defined in <code>insets</code>.
*/
public Insets getBorderInsets(Component c) {
return Theme.textInsets;
}
/**
* Use the skin to paint the border
* @see javax.swing.border.Border#paintBorder(Component, Graphics, int, int, int, int)
*/
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
drawXpBorder(c, g, x, y, w, h);
}
private void drawXpBorder(Component c, Graphics g, int x, int y, int w, int h) {
if(!c.isEnabled()) {
DrawRoutines.drawBorder(
g, Theme.textBorderDisabledColor.getColor(), x, y, w, h);
}
else {
DrawRoutines.drawBorder(
g, Theme.textBorderColor.getColor(), x, y, w, h);
}
}
}
|