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.*;
022:
023: import javax.swing.SwingConstants;
024: import javax.swing.plaf.*;
025:
026: import org.jdesktop.swingx.*;
027: import org.jdesktop.swingx.painter.Painter;
028: import org.jdesktop.swingx.plaf.PainterUIResource;
029: import org.jvnet.lafplugin.LafComponentPlugin;
030: import org.jvnet.substance.*;
031: import org.jvnet.substance.fonts.FontSet;
032: import org.jvnet.substance.painter.decoration.DecorationAreaType;
033: import org.jvnet.substance.theme.SubstanceTheme;
034: import org.jvnet.substance.utils.*;
035:
036: /**
037: * Substance plugin for <a href="https://swingx.dev.java.net">SwingX</a>
038: * components.
039: *
040: * @author Kirill Grouchnikov
041: */
042: public class SubstanceSwingxPlugin implements LafComponentPlugin {
043:
044: /**
045: * Creates a plugin instance.
046: */
047: public SubstanceSwingxPlugin() {
048: }
049:
050: public Object[] getDefaults(Object theme) {
051: SubstanceTheme sTheme = (SubstanceTheme) theme;
052: final Color foregroundColor = new ColorUIResource(
053: SubstanceColorUtilities.getForegroundColor(sTheme));
054: Color backgroundColor = new ColorUIResource(sTheme
055: .getBackgroundColor());
056: Color disabledForegroundColor = new ColorUIResource(sTheme
057: .getDisabledTheme().getForegroundColor());
058: Color selectionBackgroundColor = new ColorUIResource(sTheme
059: .getSelectionBackgroundColor());
060: Color selectionForegroundColor = new ColorUIResource(sTheme
061: .getSelectionForegroundColor());
062:
063: FontSet fontSet = SubstanceLookAndFeel.getFontPolicy()
064: .getFontSet("Substance", null);
065:
066: Font controlFont = fontSet.getControlFont();
067:
068: Painter titlePanelPainter = new Painter() {
069: public void paint(Graphics2D g, Object jxTitledPanel,
070: int width, int height) {
071: SubstanceFillBackgroundDelegate.GLOBAL_INSTANCE.update(
072: g, (Component) jxTitledPanel, false);
073: }
074: };
075:
076: SubstanceTheme headerDecorationTheme = sTheme
077: .getDecorationTheme(DecorationAreaType.HEADER);
078: Color titlePaneForeground = new ColorUIResource(
079: headerDecorationTheme.getForegroundColor());
080:
081: Object[] defaults = new Object[] {
082:
083: JXDatePicker.uiClassID,
084: "org.jvnet.substance.swingx.SubstanceDatePickerUI",
085:
086: JXMonthView.uiClassID,
087: "org.jvnet.substance.swingx.SubstanceMonthViewUI",
088:
089: JXTaskPaneContainer.uiClassID,
090: "org.jvnet.substance.swingx.SubstanceTaskPaneContainerUI",
091:
092: JXTaskPane.uiClassID,
093: "org.jvnet.substance.swingx.SubstanceTaskPaneUI",
094:
095: JXStatusBar.uiClassID,
096: "org.jvnet.substance.swingx.SubstanceStatusBarUI",
097:
098: JXHeader.uiClassID,
099: "org.jvnet.substance.swingx.SubstanceHeaderUI",
100:
101: JXLoginPane.uiClassID,
102: "org.jvnet.substance.swingx.SubstanceLoginPaneUI",
103:
104: JXTipOfTheDay.uiClassID,
105: "org.jvnet.substance.swingx.SubstanceTipOfTheDayUI",
106:
107: JXTitledPanel.uiClassID,
108: "org.jvnet.substance.swingx.SubstanceTitledPanelUI",
109:
110: JXErrorPane.uiClassID,
111: "org.jvnet.substance.swingx.SubstanceErrorPaneUI",
112:
113: JXHyperlink.uiClassID,
114: "org.jvnet.substance.swingx.SubstanceHyperlinkUI",
115:
116: "PanelUI",
117: "org.jvnet.substance.swingx.SubstancePanelUI",
118:
119: "ColumnHeaderRenderer.upIcon",
120: new IconUIResource(SubstanceImageCreator.getArrowIcon(
121: SubstanceSizeUtils.getControlFontSize(),
122: SwingConstants.NORTH, sTheme)),
123:
124: "ColumnHeaderRenderer.downIcon",
125: new IconUIResource(SubstanceImageCreator.getArrowIcon(
126: SubstanceSizeUtils.getControlFontSize(),
127: SwingConstants.SOUTH, sTheme)),
128:
129: "JXDatePicker.arrowIcon",
130: new IconUIResource(SubstanceImageCreator.getArrowIcon(
131: SubstanceSizeUtils.getControlFontSize(),
132: SwingConstants.SOUTH, sTheme)),
133:
134: "JXLoginPane.bannerFont",
135: new FontUIResource(controlFont
136: .deriveFont(3.0f * controlFont.getSize())),
137:
138: "JXLoginPane.bannerForeground",
139: new ColorUIResource(SubstanceColorUtilities
140: .getNegativeColor(foregroundColor)),
141:
142: "JXLoginPane.bannerLightBackground",
143: new ColorUIResource(SubstanceCoreUtilities
144: .isThemeDark(sTheme) ? sTheme.getActiveTheme()
145: .getColorScheme().getUltraLightColor() : sTheme
146: .getActiveTheme().getColorScheme()
147: .getLightColor()),
148:
149: "JXLoginPane.bannerDarkBackground",
150: new ColorUIResource(SubstanceCoreUtilities
151: .isThemeDark(sTheme) ? sTheme.getActiveTheme()
152: .getColorScheme().getLightColor() : sTheme
153: .getActiveTheme().getColorScheme()
154: .getMidColor()),
155:
156: "JXMonthView.background",
157: backgroundColor,
158:
159: "JXMonthView.foreground",
160: foregroundColor,
161:
162: "JXMonthView.monthStringBackground",
163: backgroundColor,
164:
165: "JXMonthView.monthStringForeground",
166: foregroundColor,
167:
168: "JXMonthView.daysOfTheWeekForeground",
169: foregroundColor,
170:
171: "JXMonthView.weekOfTheYearForeground",
172: foregroundColor,
173:
174: "JXMonthView.unselectableDayForeground",
175: new ColorUIResource(Color.RED),
176:
177: "JXMonthView.selectedBackground",
178: selectionBackgroundColor,
179:
180: "JXMonthView.selectedForeground",
181: selectionForegroundColor,
182:
183: "JXMonthView.flaggedDayForeground",
184: new ColorUIResource(Color.RED),
185:
186: "JXMonthView.leadingDayForeground",
187: disabledForegroundColor,
188:
189: "JXMonthView.trailingDayForeground",
190: disabledForegroundColor,
191:
192: "TaskPane.titleForeground",
193: foregroundColor,
194:
195: "TaskPane.titleOver",
196: foregroundColor,
197:
198: "TaskPane.specialTitleForeground",
199: foregroundColor,
200:
201: "TaskPane.specialTitleOver",
202: foregroundColor,
203:
204: "TaskPaneContainer.background",
205: backgroundColor,
206: // new ColorUIResource(new SubstanceComplexTheme("dummy",
207: // activeTitleTheme.getKind(), null, activeTitleTheme,
208: // null, null).getBackgroundColor()),
209:
210: "TaskPaneContainer.backgroundPainter",
211: null,
212:
213: "TaskPane.background",
214: backgroundColor,
215:
216: "TaskPane.foreground",
217: foregroundColor,
218:
219: "TaskPane.font",
220: new FontUIResource(controlFont.deriveFont(Font.BOLD)),
221:
222: "TipOfTheDay.background",
223: backgroundColor.darker(),
224:
225: "TipOfTheDay.foreground",
226: foregroundColor,
227:
228: "TipOfTheDay.font",
229: new FontUIResource(controlFont),
230:
231: "TipOfTheDay.tipFont",
232: new FontUIResource(controlFont
233: .deriveFont(4.0f + controlFont.getSize())),
234:
235: "TipOfTheDay.border", new SubstanceBorder(),
236:
237: "TitledBorder.font", new FontUIResource(controlFont),
238:
239: "TitledBorder.titleColor", foregroundColor,
240:
241: "JXTitledPanel.titleForeground", titlePaneForeground,
242:
243: "JXTitledPanel.titleFont",
244: new FontUIResource(controlFont.deriveFont(Font.BOLD)),
245:
246: "JXTitledPanel.titlePainter",
247: new PainterUIResource(titlePanelPainter),
248:
249: "JXHeader.titleForeground", titlePaneForeground,
250:
251: "JXHeader.descriptionForeground", titlePaneForeground, };
252:
253: return defaults;
254: }
255:
256: public void initialize() {
257: }
258:
259: public void uninitialize() {
260: }
261: }
|