001: /*
002: * Copyright Javelin Software, All rights reserved.
003: */
004:
005: package com.javelin.swinglets.theme;
006:
007: import java.awt.*;
008: import java.util.*;
009: import java.io.*;
010:
011: import com.javelin.swinglets.*;
012:
013: /**
014: * SDefaultTheme represents a concrete implementation of a default theme.
015: *
016: * @author Robin Sharp
017: */
018:
019: public class SDefaultTheme extends STheme {
020: /**
021: * Path relative to
022: */
023: public SDefaultTheme() {
024: }
025:
026: /**
027: * Get a Theme by path to a properties file.
028: */
029: public static synchronized STheme getDefaultTheme() {
030: return STheme.getTheme("metal");
031: }
032:
033: /**
034: * Get the name.
035: */
036: public String getName() {
037: return name;
038: }
039:
040: /**
041: * Set the name.
042: */
043: public void setName(String name) {
044: this .name = name;
045: }
046:
047: /**
048: * Get the icon ny name.
049: */
050: public SIcon getIcon(String key) {
051: SIcon icon = (SIcon) icons.get(key);
052:
053: if (icon == null) {
054: icon = newIcon(key);
055: icons.put(icon, key);
056: }
057:
058: return icon;
059: }
060:
061: /**
062: * Load an Icon from the respective theme directory
063: * <P>
064: * "com/javelin/swinglets/theme/" + name + ".gif"
065: */
066: protected SIcon newIcon(String key) {
067: return new SIcon(getPath() + "/" + key + ".gif");
068: }
069:
070: /**
071: * Get Text Color.
072: */
073: protected SColor getPrimary1() {
074: return primary1;
075: }
076:
077: /**
078: * Set the Text Color.
079: */
080: public void setPrimary1(String color) {
081: primary1 = SColor.getColor(color);
082: }
083:
084: /**
085: * Get Focus, Desktop.
086: */
087: protected SColor getPrimary2() {
088: return primary2;
089: }
090:
091: /**
092: * Set the Focus, Desktop..
093: */
094: public void setPrimary2(String color) {
095: primary2 = SColor.getColor(color);
096: }
097:
098: /**
099: * Get Menu Background.
100: */
101: protected SColor getPrimary3() {
102: return primary3;
103: }
104:
105: /**
106: * Set the Menu Background..
107: */
108: public void setPrimary3(String color) {
109: primary3 = SColor.getColor(color);
110: }
111:
112: /**
113: * Get Text Color.
114: */
115: protected SColor getContrast1() {
116: return contrast1;
117: }
118:
119: /**
120: * Set the Text Color.
121: */
122: public void setContrast1(String color) {
123: contrast1 = SColor.getColor(color);
124: }
125:
126: /**
127: * Get Focus, Desktop.
128: */
129: protected SColor getContrast2() {
130: return contrast2;
131: }
132:
133: /**
134: * Set the Focus, Desktop..
135: */
136: public void setContrast2(String color) {
137: contrast2 = SColor.getColor(color);
138: }
139:
140: /**
141: * Get Menu Background.
142: */
143: protected SColor getContrast3() {
144: return contrast3;
145: }
146:
147: /**
148: * Set the Menu Background..
149: */
150: public void setContrast3(String color) {
151: contrast3 = SColor.getColor(color);
152: }
153:
154: /**
155: * Get Text Color - disabled.
156: */
157: protected SColor getSecondary1() {
158: return secondary1;
159: }
160:
161: /**
162: * Set the Text Color - disabled.
163: */
164: public void setSecondary1(String color) {
165: secondary1 = SColor.getColor(color);
166: }
167:
168: /**
169: * Get Focus, Desktop - disabled.
170: */
171: protected SColor getSecondary2() {
172: return secondary2;
173: }
174:
175: /**
176: * Set the Focus, Desktop - disabled.
177: */
178: public void setSecondary2(String color) {
179: secondary2 = SColor.getColor(color);
180: }
181:
182: /**
183: * Get Menu Background - disabled.
184: */
185: protected SColor getSecondary3() {
186: return secondary3;
187: }
188:
189: /**
190: * Set Menu Background - disabled.
191: */
192: public void setSecondary3(String color) {
193: secondary3 = SColor.getColor(color);
194: }
195:
196: /**
197: * Get Control Text sFont.
198: */
199: public SFont getControlTextFont() {
200: return controlFont;
201: }
202:
203: /**
204: * Set Control Text SFont.
205: */
206: public void setControlTextFont(String font) {
207: controlFont = SFont.getFont(font);
208: }
209:
210: /**
211: * Get System Text SFont.
212: */
213: public SFont getSystemTextFont() {
214: return systemFont;
215: }
216:
217: /**
218: * Set Control Text SFont.
219: */
220: public void setSystemTextFont(String font) {
221: systemFont = SFont.getFont(font);
222: }
223:
224: /**
225: * Get User Text SFont.
226: */
227: public SFont getUserTextFont() {
228: return userFont;
229: }
230:
231: /**
232: * Set Control Text SFont.
233: */
234: public void setUserTextFont(String font) {
235: userFont = SFont.getFont(font);
236: }
237:
238: /**
239: * Get Menu Text SFont.
240: */
241: public SFont getMenuTextFont() {
242: return menuFont;
243: }
244:
245: /**
246: * Set Menu Text SFont.
247: */
248: public void setMenuTextFont(String font) {
249: menuFont = SFont.getFont(font);
250: }
251:
252: /**
253: * Get Window Title SFont.
254: */
255: public SFont getWindowTitleFont() {
256: return getControlTextFont();
257: }
258:
259: /**
260: * Set Window Title SFont.
261: */
262: public void setWindowTitleFont(String font) {
263: windowTitleFont = SFont.getFont(font);
264: }
265:
266: /**
267: * Get Sub Text SFont.
268: */
269: public SFont getSubTextFont() {
270: return subFont;
271: }
272:
273: /**
274: * Get Sub Text SFont.
275: */
276: public void setSubTextFont(String font) {
277: subFont = SFont.getFont(font);
278: }
279:
280: // PRIVATE //////////////////////////////////////////////////////////////////////////
281:
282: private SColor primary1;
283: private SColor primary2;
284: private SColor primary3;
285:
286: private SColor contrast1;
287: private SColor contrast2;
288: private SColor contrast3;
289:
290: private SColor secondary1;
291: private SColor secondary2;
292: private SColor secondary3;
293:
294: private SFont controlFont;
295: private SFont systemFont;
296: private SFont userFont;
297: private SFont menuFont;
298: private SFont windowTitleFont;
299: private SFont subFont;
300:
301: private String name;
302: private Hashtable icons = new Hashtable();
303:
304: static {
305: try {
306: STheme
307: .putTheme((STheme) SComponentLoader
308: .loadProperties(STheme.class
309: .getResourceAsStream("metal/metal.properties")));
310:
311: STheme
312: .putTheme((STheme) SComponentLoader
313: .loadProperties(STheme.class
314: .getResourceAsStream("metal/emerald.properties")));
315:
316: STheme
317: .putTheme((STheme) SComponentLoader
318: .loadProperties(STheme.class
319: .getResourceAsStream("metal/aqua.properties")));
320:
321: STheme
322: .putTheme((STheme) SComponentLoader
323: .loadProperties(STheme.class
324: .getResourceAsStream("windows/windows.properties")));
325: } catch (Exception e) {
326: e.printStackTrace();
327: }
328: }
329:
330: }
|