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: * STheme represents a neutral way of expressing Themes for Look and Feels.
015: *
016: * @author Robin Sharp
017: */
018:
019: public abstract class STheme {
020: //Background 1X1 Transparent Image
021: public final static String BACKGROUND_ICON = "1X1";
022:
023: //Tree
024: public final static String TREE_OPEN_ICON = "TREE_OPEN";
025: public final static String TREE_LEAF_ICON = "TREE_LEAF";
026: public final static String TREE_CLOSED_ICON = "TREE_CLOSED";
027:
028: //Tabs
029: public final static String TAB_TL_ICON = "TAB_TL";
030: public final static String TAB_BL_ICON = "TAB_BL";
031: public final static String TAB_TM_ICON = "TAB_TM";
032: public final static String TAB_TR_ICON = "TAB_TR";
033: public final static String TAB_BR_ICON = "TAB_BR";
034:
035: //FRAME
036: public final static String FRAME_ICON = "FRAMEICO";
037: public final static String FRAME_DESKTOP = "FRAMEDSK";
038: public final static String FRAME_MIN = "FRAMEMIN";
039: public final static String FRAME_MAX = "FRAMEMAX";
040: public final static String FRAME_RESTORE = "FRAMERES";
041: public final static String FRAME_CLOSE = "FRAMECLO";
042: public final static String FRAME_BAR = "FRAMEBAR";
043:
044: //SPLIT PANE - default size = 8
045: public final static String VERTICAL_DIV = "VER_DIV";
046: public final static String HORIZONTAL_DIV = "HOR_DIV";
047:
048: // STATIC METHODS ////////////////////////////////////////////
049:
050: /**
051: * Put a Theme into the hashtable.
052: */
053: public static synchronized void putTheme(STheme theme) {
054: themes.put(theme.getName().toLowerCase(), theme);
055: }
056:
057: /**
058: * Get a Theme by path to a properties file.
059: */
060: public static synchronized STheme getTheme(String name) {
061: STheme theme = (STheme) themes.get(name.toLowerCase());
062:
063: if (theme == null) {
064: throw new IllegalArgumentException("Cannot find the theme "
065: + name);
066: }
067:
068: return theme;
069: }
070:
071: /**
072: * Get the enumeration of Themes.
073: */
074: public static Enumeration getThemes() {
075: return themes.elements();
076: }
077:
078: // NAME //////////////////////////////////////////////////////////////
079:
080: public abstract String getName();
081:
082: // FONT //////////////////////////////////////////////////////////////
083:
084: public abstract SFont getControlTextFont();
085:
086: public abstract SFont getSystemTextFont();
087:
088: public abstract SFont getUserTextFont();
089:
090: public abstract SFont getMenuTextFont();
091:
092: public abstract SFont getWindowTitleFont();
093:
094: public abstract SFont getSubTextFont();
095:
096: // ICONS /////////////////////////////////////////////////////////////
097:
098: /**
099: * Get the path for the icons. This is relative to the
100: * SwingletManager. ImagePath.
101: */
102: public String getPath() {
103: return path;
104: }
105:
106: /**
107: * Set the path for the icons.
108: */
109: public void setPath(String path) {
110: this .path = path;
111: }
112:
113: /**
114: * Get an icons for the given key. This list of manditory keys
115: * is listed at the top of this class.
116: */
117: public abstract SIcon getIcon(String key);
118:
119: // COLORS ////////////////////////////////////////////////////////////
120:
121: public SColor getFocusColor() {
122: return getPrimary2();
123: }
124:
125: public SColor getDesktopColor() {
126: return getPrimary2();
127: }
128:
129: public SColor getControl() {
130: return getSecondary3();
131: }
132:
133: public SColor getControlShadow() {
134: return getSecondary2();
135: }
136:
137: public SColor getControlDarkShadow() {
138: return getSecondary1();
139: }
140:
141: public SColor getControlInfo() {
142: return getContrast3();
143: }
144:
145: public SColor getControlHighlight() {
146: return getContrast1();
147: }
148:
149: public SColor getControlDisabled() {
150: return getSecondary2();
151: }
152:
153: public SColor getPrimaryControl() {
154: return getPrimary3();
155: }
156:
157: public SColor getPrimaryControlShadow() {
158: return getPrimary2();
159: }
160:
161: public SColor getPrimaryControlDarkShadow() {
162: return getPrimary1();
163: }
164:
165: public SColor getPrimaryControlInfo() {
166: return getContrast3();
167: }
168:
169: public SColor getPrimaryControlHighlight() {
170: return getContrast1();
171: }
172:
173: public SColor getSystemTextColor() {
174: return getPrimary1();
175: }
176:
177: public SColor getControlTextColor() {
178: return getControlInfo();
179: }
180:
181: public SColor getInactiveControlTextColor() {
182: return getControlDisabled();
183: }
184:
185: public SColor getInactiveSystemTextColor() {
186: return getSecondary2();
187: }
188:
189: public SColor getUserTextColor() {
190: return getContrast3();
191: }
192:
193: public SColor getTextHighlightColor() {
194: return getPrimary3();
195: }
196:
197: public SColor getHighlightedTextColor() {
198: return getControlTextColor();
199: }
200:
201: public SColor getWindowBackground() {
202: return getWhite();
203: }
204:
205: public SColor getWindowTitleBackground() {
206: return getPrimary3();
207: }
208:
209: public SColor getWindowTitleForeground() {
210: return getContrast2();
211: }
212:
213: public SColor getWindowTitleInactiveBackground() {
214: return getSecondary3();
215: }
216:
217: public SColor getWindowTitleInactiveForeground() {
218: return getContrast2();
219: }
220:
221: public SColor getMenuBackground() {
222: return getSecondary3();
223: }
224:
225: public SColor getMenuForeground() {
226: return getContrast3();
227: }
228:
229: public SColor getMenuSelectedBackground() {
230: return getPrimary2();
231: }
232:
233: public SColor getMenuSelectedForeground() {
234: return getContrast3();
235: }
236:
237: public SColor getMenuDisabledForeground() {
238: return getSecondary2();
239: }
240:
241: public SColor getSeparatorBackground() {
242: return getContrast3();
243: }
244:
245: public SColor getSeparatorForeground() {
246: return getPrimary1();
247: }
248:
249: public SColor getAcceleratorForeground() {
250: return getPrimary1();
251: }
252:
253: public SColor getAcceleratorSelectedForeground() {
254: return getContrast1();
255: }
256:
257: // OBJECT /////////////////////////////////////////////////////////////
258:
259: /**
260: * Return the name.
261: */
262: public String toString() {
263: return getName();
264: }
265:
266: // PROTECTED //////////////////////////////////////////////////////////
267:
268: protected String path;
269:
270: //Colors - used for color highlights
271: protected abstract SColor getPrimary1();
272:
273: protected abstract SColor getPrimary2();
274:
275: protected abstract SColor getPrimary3();
276:
277: //Colors - used for contrast to primary
278: protected abstract SColor getContrast1();
279:
280: protected abstract SColor getContrast2();
281:
282: protected abstract SColor getContrast3();
283:
284: //Gray Colors - used for backgrounds
285: protected abstract SColor getSecondary1();
286:
287: protected abstract SColor getSecondary2();
288:
289: protected abstract SColor getSecondary3();
290:
291: protected SColor getWhite() {
292: return white;
293: }
294:
295: protected SColor getBlack() {
296: return black;
297: }
298:
299: private final static SColor white = SColor.white;
300: private final static SColor black = SColor.black;
301:
302: protected static Hashtable themes = new Hashtable();
303:
304: }
|