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.Font;
022: import java.awt.Graphics2D;
023:
024: import javax.swing.*;
025: import javax.swing.plaf.ComponentUI;
026:
027: import org.jdesktop.swingx.JXHeader;
028: import org.jdesktop.swingx.painter.Painter;
029: import org.jdesktop.swingx.plaf.PainterUIResource;
030: import org.jdesktop.swingx.plaf.basic.BasicHeaderUI;
031: import org.jvnet.substance.SubstanceFillBackgroundDelegate;
032: import org.jvnet.substance.painter.decoration.DecorationAreaType;
033: import org.jvnet.substance.painter.decoration.SubstanceDecorationUtilities;
034: import org.jvnet.substance.theme.SubstanceTheme;
035: import org.jvnet.substance.utils.SubstanceCoreUtilities;
036: import org.jvnet.substance.utils.SubstanceThemeUtilities;
037:
038: /**
039: * Substance-consistent UI delegate for {@link JXHeader}.
040: *
041: * @author Kirill Grouchnikov
042: */
043: public class SubstanceHeaderUI extends BasicHeaderUI {
044: public static ComponentUI createUI(JComponent c) {
045: return new SubstanceHeaderUI();
046: }
047:
048: /*
049: * (non-Javadoc)
050: *
051: * @see org.jdesktop.swingx.plaf.basic.BasicHeaderUI#installUI(javax.swing.JComponent)
052: */
053: @Override
054: public void installUI(JComponent c) {
055: super .installUI(c);
056: // this.descriptionPane.setBackgroundPainter(null);
057: // this.descriptionPane.setForegroundPainter(null);
058: this .descriptionPane.setBorder(null);
059:
060: Font font = UIManager.getFont("Label.font");
061: this .descriptionPane.setFont(font);
062: this .titleLabel.setFont(font.deriveFont(font.getSize() + 2.0f));
063: }
064:
065: /*
066: * (non-Javadoc)
067: *
068: * @see org.jdesktop.swingx.plaf.basic.BasicHeaderUI#installDefaults(org.jdesktop.swingx.JXHeader)
069: */
070: @Override
071: protected void installDefaults(JXHeader h) {
072: super .installDefaults(h);
073: // h.putClientProperty(SubstanceCoreUtilities.IS_WINDOW_DECORATION_AREA,
074: // Boolean.TRUE);
075: SubstanceDecorationUtilities.setDecorationType(h,
076: DecorationAreaType.HEADER);
077: }
078:
079: /*
080: * (non-Javadoc)
081: *
082: * @see org.jdesktop.swingx.plaf.basic.BasicHeaderUI#uninstallDefaults(org.jdesktop.swingx.JXHeader)
083: */
084: @Override
085: protected void uninstallDefaults(JXHeader h) {
086: // h.putClientProperty(SubstanceCoreUtilities.IS_WINDOW_DECORATION_AREA,
087: // null);
088: SubstanceDecorationUtilities.clearDecorationType(h);
089: super .uninstallDefaults(h);
090: }
091:
092: /*
093: * (non-Javadoc)
094: *
095: * @see org.jdesktop.swingx.plaf.basic.BasicHeaderUI#createBackgroundPainter()
096: */
097: @Override
098: protected Painter<?> createBackgroundPainter() {
099: return new PainterUIResource(new Painter<JXHeader>() {
100: public void paint(Graphics2D g, JXHeader jxHeader,
101: int width, int height) {
102: // SubstanceDecorationUtilities.paintDecorationBackground(g,
103: // jxHeader, false);
104:
105: SubstanceFillBackgroundDelegate.GLOBAL_INSTANCE.update(
106: g, jxHeader, false);
107: // g.translate(0, height - 2);
108: // SubstanceTheme decorationTheme = SubstanceThemeUtilities
109: // .getDecorationTheme(jxHeader);
110: // SubstanceCoreUtilities.paintSeparator(jxHeader, g,
111: // decorationTheme.getColorScheme(),
112: // SubstanceCoreUtilities.isThemeDark(decorationTheme),
113: // width, 1, JSeparator.HORIZONTAL);
114: // g.translate(0, 2 - height);
115: }
116: });
117: }
118:
119: }
|