2
* Copyright 2005-2010 Kirill Grouchnikov, based on work by
3
* Sun Microsystems, Inc. All rights reserved.
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.
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.
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
19
package org.pushingpixels.substance.swingx;
21
import java.awt.Color;
22
import java.awt.Component;
24
import java.awt.Graphics2D;
25
import java.awt.Rectangle;
27
import javax.swing.JComponent;
28
import javax.swing.SwingConstants;
29
import javax.swing.UIDefaults;
30
import javax.swing.plaf.ColorUIResource;
31
import javax.swing.plaf.FontUIResource;
32
import javax.swing.plaf.IconUIResource;
34
import org.jdesktop.swingx.JXDatePicker;
35
import org.jdesktop.swingx.JXErrorPane;
36
import org.jdesktop.swingx.JXHeader;
37
import org.jdesktop.swingx.JXHyperlink;
38
import org.jdesktop.swingx.JXLoginPane;
39
import org.jdesktop.swingx.JXMonthView;
40
import org.jdesktop.swingx.JXStatusBar;
41
import org.jdesktop.swingx.JXTaskPane;
42
import org.jdesktop.swingx.JXTaskPaneContainer;
43
import org.jdesktop.swingx.JXTipOfTheDay;
44
import org.jdesktop.swingx.JXTitledPanel;
45
import org.jdesktop.swingx.painter.Painter;
46
import org.jdesktop.swingx.plaf.PainterUIResource;
47
import org.pushingpixels.lafplugin.LafComponentPlugin;
48
import org.pushingpixels.substance.api.ColorSchemeAssociationKind;
49
import org.pushingpixels.substance.api.ComponentState;
50
import org.pushingpixels.substance.api.DecorationAreaType;
51
import org.pushingpixels.substance.api.SubstanceColorScheme;
52
import org.pushingpixels.substance.api.SubstanceLookAndFeel;
53
import org.pushingpixels.substance.api.SubstanceSkin;
54
import org.pushingpixels.substance.api.fonts.FontSet;
55
import org.pushingpixels.substance.internal.painter.BackgroundPaintingUtils;
56
import org.pushingpixels.substance.internal.painter.DecorationPainterUtils;
57
import org.pushingpixels.substance.internal.utils.SubstanceColorUtilities;
58
import org.pushingpixels.substance.internal.utils.SubstanceCoreUtilities;
59
import org.pushingpixels.substance.internal.utils.SubstanceImageCreator;
60
import org.pushingpixels.substance.internal.utils.SubstanceSizeUtils;
61
import org.pushingpixels.substance.internal.utils.border.SubstanceBorder;
64
* Substance plugin for <a href="https://swingx.dev.java.net">SwingX</a>
67
* @author Kirill Grouchnikov
69
public class SubstanceSwingxPlugin implements LafComponentPlugin {
72
* Creates a plugin instance.
74
public SubstanceSwingxPlugin() {
77
public Object[] getDefaults(Object mSkin) {
78
SubstanceSkin skin = (SubstanceSkin) mSkin;
79
final SubstanceColorScheme mainActiveScheme = skin
80
.getActiveColorScheme(DecorationAreaType.NONE);
81
SubstanceColorScheme mainEnabledScheme = skin
82
.getEnabledColorScheme(DecorationAreaType.NONE);
83
SubstanceColorScheme mainDisabledScheme = skin
84
.getDisabledColorScheme(DecorationAreaType.NONE);
85
Color foregroundColor = SubstanceColorUtilities
86
.getForegroundColor(mainEnabledScheme);
87
Color backgroundColor = new ColorUIResource(mainActiveScheme
88
.getBackgroundFillColor());
89
Color disabledForegroundColor = SubstanceColorUtilities
90
.getForegroundColor(mainDisabledScheme);
92
SubstanceColorScheme highlightColorScheme = skin.getColorScheme(
93
(Component) null, ColorSchemeAssociationKind.HIGHLIGHT,
94
ComponentState.SELECTED);
95
if (highlightColorScheme == null) {
96
highlightColorScheme = skin.getColorScheme(null,
97
ComponentState.ROLLOVER_SELECTED);
100
Color selectionBackgroundColor = new ColorUIResource(
101
highlightColorScheme.getSelectionBackgroundColor());
103
Color selectionForegroundColor = new ColorUIResource(
104
highlightColorScheme.getSelectionForegroundColor());
106
FontSet fontSet = SubstanceLookAndFeel.getFontPolicy().getFontSet(
109
Font controlFont = fontSet.getControlFont();
111
Painter titlePanelPainter = new Painter() {
112
public void paint(Graphics2D g, Object jxTitledPanel, int width,
114
JComponent titledPanel = (JComponent) jxTitledPanel;
115
Graphics2D g2d = (Graphics2D) g.create();
116
// g2d.translate(10, 10);
117
DecorationAreaType decorationType = SubstanceLookAndFeel
118
.getDecorationType(titledPanel);
119
if ((decorationType != null)
120
&& (SubstanceCoreUtilities.getSkin(titledPanel)
121
.isRegisteredAsDecorationArea(decorationType))) {
122
DecorationPainterUtils.paintDecorationBackground(g2d,
125
BackgroundPaintingUtils.fillAndWatermark(g2d, titledPanel,
126
SubstanceCoreUtilities.getSkin(titledPanel)
127
.getBackgroundColorScheme(decorationType)
128
.getBackgroundFillColor(), new Rectangle(0,
129
0, titledPanel.getWidth(), titledPanel
136
SubstanceColorScheme headerDecorationTheme = skin
137
.getEnabledColorScheme(DecorationAreaType.HEADER);
138
Color titlePaneForeground = new ColorUIResource(SubstanceColorUtilities
139
.getForegroundColor(headerDecorationTheme));
141
Object[] defaults = new Object[] {
143
JXDatePicker.uiClassID,
144
"org.pushingpixels.substance.swingx.SubstanceDatePickerUI",
146
JXMonthView.uiClassID,
147
"org.pushingpixels.substance.swingx.SubstanceMonthViewUI",
149
JXTaskPaneContainer.uiClassID,
150
"org.pushingpixels.substance.swingx.SubstanceTaskPaneContainerUI",
152
JXTaskPane.uiClassID,
153
"org.pushingpixels.substance.swingx.SubstanceTaskPaneUI",
155
JXStatusBar.uiClassID,
156
"org.pushingpixels.substance.swingx.SubstanceStatusBarUI",
159
"org.pushingpixels.substance.swingx.SubstanceHeaderUI",
161
JXLoginPane.uiClassID,
162
"org.pushingpixels.substance.swingx.SubstanceLoginPaneUI",
164
JXTipOfTheDay.uiClassID,
165
"org.pushingpixels.substance.swingx.SubstanceTipOfTheDayUI",
167
JXTitledPanel.uiClassID,
168
"org.pushingpixels.substance.swingx.SubstanceTitledPanelUI",
170
JXErrorPane.uiClassID,
171
"org.pushingpixels.substance.swingx.SubstanceErrorPaneUI",
173
JXHyperlink.uiClassID,
174
"org.pushingpixels.substance.swingx.SubstanceHyperlinkUI",
177
"org.pushingpixels.substance.swingx.SubstancePanelUI",
180
"org.pushingpixels.substance.swingx.SubstanceTableUI",
182
"ColumnHeaderRenderer.upIcon",
183
new UIDefaults.LazyValue() {
185
public Object createValue(UIDefaults table) {
186
return new IconUIResource(SubstanceImageCreator
187
.getArrowIcon(SubstanceSizeUtils
188
.getControlFontSize(),
189
SwingConstants.NORTH, mainActiveScheme));
193
"ColumnHeaderRenderer.downIcon",
194
new UIDefaults.LazyValue() {
196
public Object createValue(UIDefaults table) {
197
return new IconUIResource(SubstanceImageCreator
198
.getArrowIcon(SubstanceSizeUtils
199
.getControlFontSize(),
200
SwingConstants.SOUTH, mainActiveScheme));
204
"JXDatePicker.arrowIcon",
205
new UIDefaults.LazyValue() {
207
public Object createValue(UIDefaults table) {
208
return new IconUIResource(SubstanceImageCreator
209
.getArrowIcon(SubstanceSizeUtils
210
.getControlFontSize(),
211
SwingConstants.SOUTH, mainActiveScheme));
215
"JXLoginPane.bannerFont",
216
new FontUIResource(controlFont.deriveFont(3.0f * controlFont
219
"JXLoginPane.bannerForeground",
220
new ColorUIResource(SubstanceColorUtilities
221
.getNegativeColor(foregroundColor)),
223
"JXLoginPane.bannerLightBackground",
225
mainActiveScheme.isDark() ? mainActiveScheme
226
.getUltraLightColor() : mainActiveScheme
229
"JXLoginPane.bannerDarkBackground",
231
mainActiveScheme.isDark() ? mainActiveScheme
232
.getLightColor() : mainActiveScheme
235
"JXMonthView.background",
238
"JXMonthView.foreground",
241
"JXMonthView.monthStringBackground",
244
"JXMonthView.monthStringForeground",
247
"JXMonthView.daysOfTheWeekForeground",
250
"JXMonthView.weekOfTheYearForeground",
253
"JXMonthView.unselectableDayForeground",
254
new ColorUIResource(Color.RED),
256
"JXMonthView.selectedBackground",
257
selectionBackgroundColor,
259
"JXMonthView.selectedForeground",
260
selectionForegroundColor,
262
"JXMonthView.flaggedDayForeground",
263
new ColorUIResource(Color.RED),
265
"JXMonthView.leadingDayForeground",
266
disabledForegroundColor,
268
"JXMonthView.trailingDayForeground",
269
disabledForegroundColor,
271
"TaskPane.titleForeground",
274
"TaskPane.titleOver",
277
"TaskPane.specialTitleForeground",
280
"TaskPane.specialTitleOver",
283
"TaskPaneContainer.background",
285
// new ColorUIResource(new SubstanceComplexTheme("dummy",
286
// activeTitleTheme.getKind(), null, activeTitleTheme,
287
// null, null).getBackgroundColor()),
289
"TaskPaneContainer.backgroundPainter",
292
"TaskPane.background",
295
"TaskPane.foreground",
299
new FontUIResource(controlFont.deriveFont(Font.BOLD)),
301
"TipOfTheDay.background",
302
backgroundColor.darker(),
304
"TipOfTheDay.foreground",
308
new FontUIResource(controlFont),
310
"TipOfTheDay.tipFont",
311
new FontUIResource(controlFont.deriveFont(4.0f + controlFont
314
"TipOfTheDay.border", new SubstanceBorder(),
316
"TitledBorder.font", new FontUIResource(controlFont),
318
"TitledBorder.titleColor", foregroundColor,
320
"JXTitledPanel.titleForeground", titlePaneForeground,
322
"JXTitledPanel.titleFont",
323
new FontUIResource(controlFont.deriveFont(Font.BOLD)),
325
"JXTitledPanel.titlePainter",
326
new PainterUIResource(titlePanelPainter),
328
"JXHeader.titleForeground", titlePaneForeground,
330
"JXHeader.descriptionForeground", titlePaneForeground, };
335
public void initialize() {
338
public void uninitialize() {