001: /*
002: * Copyright (C) 2004 NNL Technology AB
003: * Visit www.infonode.net for information about InfoNode(R)
004: * products and how to contact NNL Technology AB.
005: *
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU General Public License
008: * as published by the Free Software Foundation; either version 2
009: * of the License, or (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
019: * MA 02111-1307, USA.
020: */
021:
022: // $Id: GradientTabAreaBorder.java,v 1.16 2005/02/16 11:28:14 jesper Exp $
023: package net.infonode.tabbedpanel.border;
024:
025: import net.infonode.gui.colorprovider.ColorProvider;
026: import net.infonode.gui.colorprovider.ColorProviderUtil;
027: import net.infonode.gui.colorprovider.UIManagerColorProvider;
028: import net.infonode.gui.componentpainter.GradientComponentPainter;
029: import net.infonode.tabbedpanel.TabbedPanel;
030: import net.infonode.tabbedpanel.TabbedUtils;
031:
032: import javax.swing.border.Border;
033: import java.awt.*;
034: import java.io.Serializable;
035:
036: /**
037: * Paints a gradient background for a tab area component. The background blends from one color on the component edge
038: * opposite to the tabbed panel content panel to the another color on the component edge closest to the tabbed panel
039: * content panel.
040: *
041: * @author $Author: jesper $
042: * @version $Revision: 1.16 $
043: * @since ITP 1.1.0
044: */
045: public class GradientTabAreaBorder implements Border, Serializable {
046: private static final long serialVersionUID = 1;
047:
048: private GradientComponentPainter painter;
049:
050: /**
051: * Creates a border where the color of the component edge closest to the tabben panel content panel will be the
052: * default control color.
053: *
054: * @param topColor the color of the component edge opposite to the tabbed panel content panel
055: */
056: public GradientTabAreaBorder(Color topColor) {
057: this (topColor, null);
058: }
059:
060: /**
061: * Constructor.
062: *
063: * @param topColor the color of the component edge opposite to the tabbed panel content panel
064: * @param bottomColor the color of the component edge closest to the tabbed panel content panel
065: */
066: public GradientTabAreaBorder(Color topColor, Color bottomColor) {
067: this (ColorProviderUtil.getColorProvider(topColor,
068: UIManagerColorProvider.CONTROL_COLOR),
069: ColorProviderUtil.getColorProvider(bottomColor,
070: UIManagerColorProvider.CONTROL_COLOR));
071: }
072:
073: /**
074: * Constructor.
075: *
076: * @param topColorProvider provides the color of the component edge opposite to the tabbed panel content panel
077: * @param bottomColorProvider provides the color of the component edge closest to the tabbed panel content panel
078: */
079: public GradientTabAreaBorder(ColorProvider topColorProvider,
080: ColorProvider bottomColorProvider) {
081: painter = new GradientComponentPainter(topColorProvider,
082: topColorProvider, bottomColorProvider,
083: bottomColorProvider);
084: }
085:
086: public boolean isBorderOpaque() {
087: return true;
088: }
089:
090: public void paintBorder(Component component, Graphics g, int x,
091: int y, int width, int height) {
092: TabbedPanel tp = TabbedUtils.getParentTabbedPanel(component);
093:
094: if (tp == null)
095: return;
096:
097: painter.paint(component, g, x, y, width, height, tp
098: .getProperties().getTabAreaOrientation().getNextCW(),
099: false, false);
100: }
101:
102: public Insets getBorderInsets(Component c) {
103: return new Insets(0, 0, 0, 0);
104: }
105: }
|