2
* Copyright (c) 2002 and later by MH Software-Entwicklung. All Rights Reserved.
4
* JTattoo is multiple licensed. If your are an open source developer you can use
5
* it under the terms and conditions of the GNU General Public License version 2.0
6
* or later as published by the Free Software Foundation.
10
* If you pay for a license you will become a registered user who could use the
11
* software under the terms and conditions of the GNU Lesser General Public License
12
* version 2.0 or later with classpath exception as published by the Free Software
16
* see: classpath-exception.txt
18
* Registered users could also use JTattoo under the terms and conditions of the
19
* Apache License, Version 2.0 as published by the Apache Software Foundation.
21
* see: APACHE-LICENSE-2.0.txt
24
package com.jtattoo.plaf.fast;
26
import com.jtattoo.plaf.*;
28
import javax.swing.UIDefaults;
29
import javax.swing.plaf.basic.BasicPopupMenuUI;
30
import javax.swing.plaf.basic.BasicProgressBarUI;
33
* @author Michael Hagen
35
public class FastLookAndFeel extends AbstractLookAndFeel {
37
private static final String darkBlue = "0 32 96";
38
private static final String lightBlue = "160 160 200";
39
private static final String extraLightBlue = "210 210 240";
40
private static final String superLightBlue = "230 230 255";
41
private static final String darkGreen = "0 76 57";
42
private static final String lightGreen = "172 191 186";
43
private static final String extraLightGreen = "218 226 223";
44
private static final String superLightGreen = "228 234 232";
46
private static FastDefaultTheme myTheme = null;
48
private static final ArrayList themesList = new ArrayList();
49
private static final HashMap themesMap = new HashMap();
50
private static final Properties defaultProps = new Properties();
51
private static final Properties smallFontProps = new Properties();
52
private static final Properties largeFontProps = new Properties();
53
private static final Properties giantFontProps = new Properties();
54
private static final Properties blueProps = new Properties();
55
private static final Properties blueSmallFontProps = new Properties();
56
private static final Properties blueLargeFontProps = new Properties();
57
private static final Properties blueGiantFontProps = new Properties();
58
private static final Properties greenProps = new Properties();
59
private static final Properties greenSmallFontProps = new Properties();
60
private static final Properties greenLargeFontProps = new Properties();
61
private static final Properties greenGiantFontProps = new Properties();
65
smallFontProps.setProperty("controlTextFont", "Dialog 10");
66
smallFontProps.setProperty("systemTextFont", "Dialog 10");
67
smallFontProps.setProperty("userTextFont", "Dialog 10");
68
smallFontProps.setProperty("menuTextFont", "Dialog 10");
69
smallFontProps.setProperty("windowTitleFont", "Dialog bold 10");
70
smallFontProps.setProperty("subTextFont", "Dialog 8");
72
largeFontProps.setProperty("controlTextFont", "Dialog 14");
73
largeFontProps.setProperty("systemTextFont", "Dialog 14");
74
largeFontProps.setProperty("userTextFont", "Dialog 14");
75
largeFontProps.setProperty("menuTextFont", "Dialog 14");
76
largeFontProps.setProperty("windowTitleFont", "Dialog bold 14");
77
largeFontProps.setProperty("subTextFont", "Dialog 12");
79
giantFontProps.setProperty("controlTextFont", "Dialog 18");
80
giantFontProps.setProperty("systemTextFont", "Dialog 18");
81
giantFontProps.setProperty("userTextFont", "Dialog 18");
82
giantFontProps.setProperty("menuTextFont", "Dialog 18");
83
giantFontProps.setProperty("windowTitleFont", "Dialog 18");
84
giantFontProps.setProperty("subTextFont", "Dialog 16");
86
blueProps.setProperty("selectionBackgroundColor", extraLightBlue);
87
blueProps.setProperty("focusCellColor", darkBlue);
88
blueProps.setProperty("buttonBackgroundColor", superLightBlue);
89
blueProps.setProperty("controlBackgroundColor", superLightBlue);
90
blueProps.setProperty("windowTitleBackgroundColor", lightBlue);
91
blueProps.setProperty("windowTitleColorLight", superLightBlue);
92
blueProps.setProperty("windowTitleColorDark", extraLightBlue);
93
blueProps.setProperty("windowBorderColor", lightBlue);
94
blueProps.setProperty("windowInactiveTitleBackgroundColor", extraLightBlue);
95
blueProps.setProperty("windowInactiveBorderColor", extraLightBlue);
96
blueProps.setProperty("menuBackgroundColor", superLightBlue);
97
blueProps.setProperty("menuSelectionBackgroundColor", lightBlue);
98
blueProps.setProperty("toolbarBackgroundColor", "244 244 244");
100
greenProps.setProperty("selectionBackgroundColor", lightGreen);
101
greenProps.setProperty("focusCellColor", darkGreen);
102
greenProps.setProperty("buttonBackgroundColor", lightGreen);
103
greenProps.setProperty("controlBackgroundColor", extraLightGreen);
104
greenProps.setProperty("windowTitleBackgroundColor", lightGreen);
105
greenProps.setProperty("windowTitleColorLight", extraLightGreen);
106
greenProps.setProperty("windowTitleColorDark", lightGreen);
107
greenProps.setProperty("windowBorderColor", lightGreen);
108
greenProps.setProperty("windowInactiveTitleBackgroundColor", extraLightGreen);
109
greenProps.setProperty("windowInactiveBorderColor", extraLightGreen);
110
greenProps.setProperty("menuBackgroundColor", superLightGreen);
111
greenProps.setProperty("menuSelectionBackgroundColor", lightGreen);
112
greenProps.setProperty("toolbarBackgroundColor", "244 244 244");
116
Iterator iter = smallFontProps.keySet().iterator();
117
while (iter.hasNext()) {
118
key = (String) iter.next();
119
value = smallFontProps.getProperty(key);
120
blueSmallFontProps.setProperty(key, value);
121
greenSmallFontProps.setProperty(key, value);
123
iter = largeFontProps.keySet().iterator();
124
while (iter.hasNext()) {
125
key = (String) iter.next();
126
value = largeFontProps.getProperty(key);
127
blueLargeFontProps.setProperty(key, value);
128
greenLargeFontProps.setProperty(key, value);
130
iter = giantFontProps.keySet().iterator();
131
while (iter.hasNext()) {
132
key = (String) iter.next();
133
value = giantFontProps.getProperty(key);
134
blueGiantFontProps.setProperty(key, value);
135
greenGiantFontProps.setProperty(key, value);
138
iter = blueProps.keySet().iterator();
139
while (iter.hasNext()) {
140
key = (String) iter.next();
141
value = blueProps.getProperty(key);
142
blueSmallFontProps.setProperty(key, value);
143
blueLargeFontProps.setProperty(key, value);
144
blueGiantFontProps.setProperty(key, value);
146
iter = greenProps.keySet().iterator();
147
while (iter.hasNext()) {
148
key = (String) iter.next();
149
value = greenProps.getProperty(key);
150
greenSmallFontProps.setProperty(key, value);
151
greenLargeFontProps.setProperty(key, value);
152
greenGiantFontProps.setProperty(key, value);
155
themesList.add("Default");
156
themesList.add("Small-Font");
157
themesList.add("Large-Font");
158
themesList.add("Giant-Font");
159
themesList.add("Blue");
160
themesList.add("Blue-Small-Font");
161
themesList.add("Blue-Large-Font");
162
themesList.add("Blue-Giant-Font");
163
themesList.add("Green");
164
themesList.add("Green-Small-Font");
165
themesList.add("Green-Large-Font");
166
themesList.add("Green-Giant-Font");
168
themesMap.put("Default", defaultProps);
169
themesMap.put("Small-Font", smallFontProps);
170
themesMap.put("Large-Font", largeFontProps);
171
themesMap.put("Giant-Font", giantFontProps);
172
themesMap.put("Blue", blueProps);
173
themesMap.put("Blue-Small-Font", blueSmallFontProps);
174
themesMap.put("Blue-Large-Font", blueLargeFontProps);
175
themesMap.put("Blue-Giant-Font", blueGiantFontProps);
176
themesMap.put("Green", greenProps);
177
themesMap.put("Green-Small-Font", greenSmallFontProps);
178
themesMap.put("Green-Large-Font", greenLargeFontProps);
179
themesMap.put("Green-Giant-Font", greenGiantFontProps);
182
public static java.util.List getThemes() {
186
public static Properties getThemeProperties(String name) {
187
return ((Properties) themesMap.get(name));
190
public static void setTheme(String name) {
191
setTheme((Properties) themesMap.get(name));
192
if (myTheme != null) {
193
AbstractTheme.setInternalName(name);
197
public static void setTheme(String name, String licenseKey, String logoString) {
198
Properties props = (Properties) themesMap.get(name);
200
props.put("licenseKey", licenseKey);
201
props.put("logoString", logoString);
203
if (myTheme != null) {
204
AbstractTheme.setInternalName(name);
209
public static void setTheme(Properties themesProps) {
210
currentThemeName = "fastTheme";
211
if (myTheme == null) {
212
myTheme = new FastDefaultTheme();
214
if ((myTheme != null) && (themesProps != null)) {
215
myTheme.setUpColor();
216
myTheme.setProperties(themesProps);
217
myTheme.setUpColorArrs();
218
AbstractLookAndFeel.setTheme(myTheme);
222
public static void setCurrentTheme(Properties themesProps) {
223
setTheme(themesProps);
226
public String getName() {
230
public String getID() {
234
public String getDescription() {
235
return "The Fast Look and Feel";
238
public boolean isNativeLookAndFeel() {
242
public boolean isSupportedLookAndFeel() {
246
public AbstractBorderFactory getBorderFactory() {
247
return FastBorderFactory.getInstance();
250
public AbstractIconFactory getIconFactory() {
251
return FastIconFactory.getInstance();
254
protected void createDefaultTheme() {
255
if (myTheme == null) {
256
myTheme = new FastDefaultTheme();
261
protected void initClassDefaults(UIDefaults table) {
262
if (!"fastTheme".equals(currentThemeName)) {
265
super.initClassDefaults(table);
266
Object[] uiDefaults = {
267
"PopupMenuUI", BasicPopupMenuUI.class.getName(),
268
// BaseLookAndFeel classes
269
"LabelUI", BaseLabelUI.class.getName(),
270
"SeparatorUI", BaseSeparatorUI.class.getName(),
271
"TextFieldUI", BaseTextFieldUI.class.getName(),
272
"TextAreaUI", BaseTextAreaUI.class.getName(),
273
"EditorPaneUI", BaseEditorPaneUI.class.getName(),
274
"PasswordFieldUI", BasePasswordFieldUI.class.getName(),
275
"ComboBoxUI", BaseComboBoxUI.class.getName(),
276
"CheckBoxUI", BaseCheckBoxUI.class.getName(),
277
"RadioButtonUI", BaseRadioButtonUI.class.getName(),
278
"ToolTipUI", BaseToolTipUI.class.getName(),
279
"TreeUI", BaseTreeUI.class.getName(),
280
"TableUI", BaseTableUI.class.getName(),
281
"TableHeaderUI", BaseTableHeaderUI.class.getName(),
282
"PanelUI", BasePanelUI.class.getName(),
283
"ScrollPaneUI", BaseScrollPaneUI.class.getName(),
284
"ProgressBarUI", BasicProgressBarUI.class.getName(),
285
"FileChooserUI", BaseFileChooserUI.class.getName(),
286
"MenuUI", BaseMenuUI.class.getName(),
287
"MenuItemUI", BaseMenuItemUI.class.getName(),
288
"CheckBoxMenuItemUI", BaseCheckBoxMenuItemUI.class.getName(),
289
"RadioButtonMenuItemUI", BaseRadioButtonMenuItemUI.class.getName(),
290
"PopupMenuSeparatorUI", BaseSeparatorUI.class.getName(),
291
"DesktopPaneUI", BaseDesktopPaneUI.class.getName(),
293
// FastLookAndFeel classes
294
"ButtonUI", FastButtonUI.class.getName(),
295
"ToggleButtonUI", FastToggleButtonUI.class.getName(),
296
"ScrollBarUI", FastScrollBarUI.class.getName(),
297
"SliderUI", FastSliderUI.class.getName(),
298
"TabbedPaneUI", FastTabbedPaneUI.class.getName(),
299
"SplitPaneUI", FastSplitPaneUI.class.getName(),
300
"ToolBarUI", FastToolBarUI.class.getName(),
301
"InternalFrameUI", FastInternalFrameUI.class.getName(),
302
"RootPaneUI", FastRootPaneUI.class.getName(),};
303
table.putDefaults(uiDefaults);
304
if (JTattooUtilities.getJavaVersion() >= 1.5) {
305
table.put("FormattedTextFieldUI", BaseFormattedTextFieldUI.class.getName());
306
table.put("SpinnerUI", BaseSpinnerUI.class.getName());
310
protected void initComponentDefaults(UIDefaults table) {
311
super.initComponentDefaults(table);
312
table.put("SplitPane.centerOneTouchButtons", Boolean.FALSE);