Debian Codegraph @

substance-swingx/src/main/java/org/pushingpixels/substance/swingx/SubstanceHeaderUI.java

raw symbols SCIP
1 /*
2 * Copyright 2005-2010 Kirill Grouchnikov, based on work by
3 * Sun Microsystems, Inc. All rights reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 package org.pushingpixels.substance.swingx;
20
21 import java.awt.Font;
22 import java.awt.Graphics2D;
23
24 import javax.swing.JComponent;
25 import javax.swing.UIManager;
26 import javax.swing.plaf.ComponentUI;
27
28 import org.jdesktop.swingx.JXHeader;
29 import org.jdesktop.swingx.painter.Painter;
30 import org.jdesktop.swingx.plaf.PainterUIResource;
31 import org.jdesktop.swingx.plaf.basic.BasicHeaderUI;
32 import org.pushingpixels.substance.api.DecorationAreaType;
33 import org.pushingpixels.substance.api.SubstanceLookAndFeel;
34 import org.pushingpixels.substance.internal.painter.BackgroundPaintingUtils;
35 import org.pushingpixels.substance.internal.painter.DecorationPainterUtils;
36 import org.pushingpixels.substance.internal.utils.SubstanceCoreUtilities;
37
38 /**
39 * Substance-consistent UI delegate for {@link JXHeader}.
40 *
41 * @author Kirill Grouchnikov
42 */
43 public class SubstanceHeaderUI extends BasicHeaderUI {
44 public static ComponentUI createUI(JComponent comp) {
45 SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp);
46 return new SubstanceHeaderUI();
47 }
48
49 // protected class SubstanceDescriptionPane extends DescriptionPane {
50 // @Override
51 // protected void paintComponent(Graphics g) {
52 // Graphics2D g2d = (Graphics2D)g.create();
53 // RenderingUtils.installDesktopHints(g2d, this);
54 // super.paintComponent(g2d);
55 // g2d.dispose();
56 // }
57 // }
58
59 /*
60 * (non-Javadoc)
61 *
62 * @see
63 * org.jdesktop.swingx.plaf.basic.BasicHeaderUI#installUI(javax.swing.JComponent
64 * )
65 */
66 @Override
67 public void installUI(JComponent c) {
68 super.installUI(c);
69
70 Font font = UIManager.getFont("Label.font");
71 this.descriptionPane.setFont(font);
72 this.titleLabel.setFont(font.deriveFont(font.getSize() + 2.0f));
73 }
74
75 /*
76 * (non-Javadoc)
77 *
78 * @see
79 * org.jdesktop.swingx.plaf.basic.BasicHeaderUI#installDefaults(org.jdesktop
80 * .swingx.JXHeader)
81 */
82 @Override
83 protected void installDefaults(JXHeader h) {
84 // this.descriptionPane = new SubstanceDescriptionPane();
85 // this.descriptionPane.setLineWrap(true);
86 // this.descriptionPane.setOpaque(false);
87
88 super.installDefaults(h);
89 SubstanceLookAndFeel.setDecorationType(h, DecorationAreaType.HEADER);
90 }
91
92 /*
93 * (non-Javadoc)
94 *
95 * @see
96 * org.jdesktop.swingx.plaf.basic.BasicHeaderUI#uninstallDefaults(org.jdesktop
97 * .swingx.JXHeader)
98 */
99 @Override
100 protected void uninstallDefaults(JXHeader h) {
101 DecorationPainterUtils.clearDecorationType(h);
102 super.uninstallDefaults(h);
103 }
104
105 /*
106 * (non-Javadoc)
107 *
108 * @see
109 * org.jdesktop.swingx.plaf.basic.BasicHeaderUI#createBackgroundPainter()
110 */
111 @Override
112 protected Painter<?> createBackgroundPainter() {
113 return new PainterUIResource(new Painter<JXHeader>() {
114 public void paint(Graphics2D g, JXHeader jxHeader, int width,
115 int height) {
116 // SubstanceDecorationUtilities.paintDecorationBackground(g,
117 // jxHeader, false);
118
119 BackgroundPaintingUtils.update(g, jxHeader, false);
120 // g.translate(0, height - 2);
121 // SubstanceTheme decorationTheme = SubstanceThemeUtilities
122 // .getDecorationTheme(jxHeader);
123 // SubstanceCoreUtilities.paintSeparator(jxHeader, g,
124 // decorationTheme.getColorScheme(),
125 // SubstanceCoreUtilities.isThemeDark(decorationTheme),
126 // width, 1, JSeparator.HORIZONTAL);
127 // g.translate(0, 2 - height);
128 }
129 });
130 }
131
132 }