001: /*
002: * Copyright 2005-2008 Kirill Grouchnikov, based on work by
003: * Sun Microsystems, Inc. All rights reserved.
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2.1 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
018: */
019: package org.jvnet.substance.swingx;
020:
021: import java.awt.Graphics2D;
022:
023: import javax.swing.JComponent;
024: import javax.swing.JSeparator;
025:
026: import org.jvnet.substance.SubstanceFillBackgroundDelegate;
027: import org.jvnet.substance.theme.SubstanceTheme;
028: import org.jvnet.substance.utils.SubstanceCoreUtilities;
029: import org.jvnet.substance.utils.SubstanceThemeUtilities;
030:
031: public class SubstanceSwingxFillBackgroundDelegate {
032: /**
033: * Background delegate.
034: */
035: private SubstanceFillBackgroundDelegate bgDelegate;
036:
037: public SubstanceSwingxFillBackgroundDelegate() {
038: bgDelegate = new SubstanceFillBackgroundDelegate();
039: }
040:
041: public void paint(JComponent component, Graphics2D graphics,
042: boolean paintSeparator) {
043: bgDelegate.updateIfOpaque(graphics, component);
044: if (paintSeparator) {
045: // paint the separator on top.
046: SubstanceTheme componentTheme = SubstanceThemeUtilities
047: .getTheme(component);
048: SubstanceCoreUtilities.paintSeparator(component, graphics,
049: componentTheme.getColorScheme(),
050: SubstanceCoreUtilities.isThemeDark(componentTheme),
051: component.getWidth(), 0, JSeparator.HORIZONTAL,
052: false, 0);
053: }
054: //
055: // int width = component.getWidth();
056: // SubstanceTitlePainter titlePainter = SubstanceLookAndFeel
057: // .getCurrentTitlePainter();
058: // boolean useHeaderPainter = (titlePainter instanceof
059: // SubstanceHeaderPainter);
060: // SubstanceTheme headerTheme = SubstanceLookAndFeel.getTheme()
061: // .getActiveTitlePaneTheme();
062: // if (useHeaderPainter) {
063: // SubstanceHeaderPainter headerPainter = (SubstanceHeaderPainter)
064: // titlePainter;
065: // if (headerPainter.isPaintingContainer(component)) {
066: // // special case for skins such as BusinessBlackSteel, which use
067: // // dark theme for header (title pane + menus) - using such a
068: // // dark
069: // // theme on a status bar is not good, since all the status bar
070: // // controls are assuming a non-dark theme (they use black
071: // // foreground
072: // // color).
073: // if (SubstanceCoreUtilities.isThemeDark(headerTheme) !=
074: // SubstanceCoreUtilities
075: // .isThemeDark(SubstanceLookAndFeel.getTheme())) {
076: // headerTheme = SubstanceLookAndFeel.getTheme();
077: // }
078: //
079: // int height = component.getHeight() + 1;
080: // headerPainter.paintExtraBackground(graphics, component
081: // .getParent(), component, width, height, headerTheme,
082: // false);
083: // if (SubstanceCoreUtilities.toDrawWatermark(component)) {
084: // SubstanceLookAndFeel.getCurrentWatermark()
085: // .drawWatermarkImage(graphics, component, 0, 0,
086: // width, height);
087: //
088: // // paint the background second time with 50%
089: // // translucency, making the watermark 'bleed' through.
090: // Graphics2D tempGraphics = (Graphics2D) graphics.create();
091: // tempGraphics.setComposite(TransitionLayout
092: // .getAlphaComposite(component, 0.5f, graphics));
093: // headerPainter.paintExtraBackground(tempGraphics, component
094: // .getParent(), component, width, height,
095: // headerTheme, false);
096: // tempGraphics.dispose();
097: // }
098: // if (paintSeparator) {
099: // // paint the separator on top.
100: // SubstanceCoreUtilities.paintSeparator(component, graphics,
101: // headerTheme.getColorScheme(),
102: // SubstanceCoreUtilities.isThemeDark(headerTheme),
103: // width, 0, JSeparator.HORIZONTAL, false, 0);
104: // }
105: // } else {
106: // bgDelegate.updateIfOpaque(graphics, component);
107: // if (paintSeparator) {
108: // // paint the separator on top.
109: // SubstanceCoreUtilities.paintSeparator(component, graphics,
110: // headerTheme.getColorScheme(),
111: // SubstanceCoreUtilities.isThemeDark(headerTheme),
112: // width, 0, JSeparator.HORIZONTAL, false, 0);
113: // }
114: // }
115: // } else {
116: // bgDelegate.updateIfOpaque(graphics, component);
117: // }
118: //
119: }
120: }
|