Lines 18-136
Link Here
|
18 |
import javax.swing.plaf.*; |
18 |
import javax.swing.plaf.*; |
19 |
import javax.swing.plaf.metal.*; |
19 |
import javax.swing.plaf.metal.*; |
20 |
import org.openide.*; |
20 |
import org.openide.*; |
|
|
21 |
import java.util.*; |
22 |
/** An extension of javax.swing.plaf.metal.DefaultMetalTheme which can read a an xml |
23 |
* file named <code>themes.xml</code> and apply the theme defined in XML. NbTheme |
24 |
* stores its data in the <code>UIDefaults</code> instance available from the |
25 |
* look-and-feel manager (<code>UiManager.getLookAndFeel.getDefaults()</code>). |
26 |
* These means that theme files may also override per-component-type settings |
27 |
* stored there, so changes to look and feel deeper than those afforded by the |
28 |
* <code>MetalTheme</code> parent class are possible. |
29 |
* <P> |
30 |
* <code>NbTheme</code> supports five kinds of data: Colors, Fonts, Integers, |
31 |
* Strings, and Booleans, which are the major interesting data types typical |
32 |
* stored in <code>UIDefaults</code>. */ |
21 |
public class NbTheme extends MetalTheme implements org.xml.sax.DocumentHandler { |
33 |
public class NbTheme extends MetalTheme implements org.xml.sax.DocumentHandler { |
22 |
|
34 |
|
23 |
public static final String THEMEFILE_NAME = "Themes.xml"; // NOI18N |
35 |
public static final String THEMEFILE_NAME = "themes.xml"; // NOI18N |
24 |
|
36 |
// legal xml tags for theme files |
25 |
private static final String MAIN_TAG = "MetalTheme"; // NOI18N |
37 |
private static final String THEMESET_TAG = "themeset"; // NOI18N |
26 |
private static final String MAIN_ACTIVATE_TAG = "activate"; // NOI18N |
38 |
private static final String ACTIVE_ATTR = "active"; // NOI18N |
27 |
private static final String THEME_TAG = "Theme"; // NOI18N |
39 |
private static final String THEME_TAG = "theme"; // NOI18N |
28 |
private static final String THEME_NAME_TAG = "name"; // NOI18N |
40 |
private static final String BOOL_TAG = "boolean"; // NOI18N |
29 |
|
41 |
private static final String DIM_TAG = "dimension"; // NOI18N |
30 |
private static final String R_TAG = "R"; // NOI18N |
42 |
private static final String FONT_TAG = "font"; // NOI18N |
31 |
private static final String G_TAG = "G"; // NOI18N |
43 |
private static final String INSETS_TAG = "insets"; // NOI18N |
32 |
private static final String B_TAG = "B"; // NOI18N |
44 |
// attributes recognized in various tags |
33 |
private static final String PRIMARY1_TAG = "primary1"; // NOI18N |
45 |
private static final String COLOR_ATTR = "color"; // NOI18N |
34 |
private static final String PRIMARY2_TAG = "primary2"; // NOI18N |
46 |
private static final String KEY_ATTR = "key"; // NOI18N |
35 |
private static final String PRIMARY3_TAG = "primary3"; // NOI18N |
47 |
private static final String METRIC_TAG = "metric"; // NOI18N |
36 |
private static final String SECONDARY1_TAG = "secondary1"; // NOI18N |
48 |
private static final String STRING_TAG = "string"; // NOI18N |
37 |
private static final String SECONDARY2_TAG = "secondary2"; // NOI18N |
49 |
private static final String NAME_ATTR = "name"; // NOI18N |
38 |
private static final String SECONDARY3_TAG = "secondary3"; // NOI18N |
50 |
private static final String FONTSTYLE_ATTR = "style"; // NOI18N |
39 |
|
51 |
private static final String FONTSIZE_ATTR = "size"; // NOI18N |
40 |
private static final String FONTNAME_TAG = "name"; // NOI18N |
52 |
private static final String VALUE_ATTR = "value"; |
41 |
private static final String FONTSTYLE_TAG = "style"; // NOI18N |
53 |
private static final String WIDTH_ATTR = "width"; |
42 |
private static final String FONTSTYLE_PLAIN = "Plain"; // NOI18N |
54 |
private static final String HEIGHT_ATTR = "height"; |
43 |
private static final String FONTSTYLE_BOLD = "Bold"; // NOI18N |
55 |
private static final String RED_ATTR = "r"; // NOI18N |
44 |
private static final String FONTSTYLE_ITALIC = "Italic"; // NOI18N |
56 |
private static final String GREEN_ATTR = "g"; // NOI18N |
45 |
private static final String FONTSIZE_TAG = "size"; // NOI18N |
57 |
private static final String BLUE_ATTR = "b"; // NOI18N |
46 |
private static final String CONTROLFONT_TAG = "controlFont"; // NOI18N |
58 |
private static final String LEFT_ATTR = "left"; // NOI18N |
47 |
private static final String SYSTEMFONT_TAG = "systemFont"; // NOI18N |
59 |
private static final String TOP_ATTR = "top"; // NOI18N |
48 |
private static final String USERFONT_TAG = "userFont"; // NOI18N |
60 |
private static final String RIGHT_ATTR = "right"; // NOI18N |
49 |
private static final String SUBFONT_TAG = "subFont"; // NOI18N |
61 |
private static final String BOTTOM_ATTR = "bottom"; // NOI18N |
50 |
private static final String MENUFONT_TAG = "menuFont"; // NOI18N |
62 |
// font styles |
51 |
private static final String WINDOWTITLEFONT_TAG = "windowTitleFont"; // NOI18N |
63 |
private static final String FONTSTYLE_PLAIN = "plain"; // NOI18N |
52 |
|
64 |
private static final String FONTSTYLE_BOLD = "bold"; // NOI18N |
53 |
|
65 |
private static final String FONTSTYLE_ITALIC = "italic"; // NOI18N |
54 |
// default Theme |
66 |
// keys used to store theme values in UIDefaults |
55 |
private ColorUIResource primary1 = new ColorUIResource(102, 102, 153); |
67 |
private static final String CONTROLFONT = "controlFont"; // NOI18N |
56 |
private ColorUIResource primary2 = new ColorUIResource(153, 153, 204); |
68 |
private static final String SYSTEMFONT = "systemFont"; // NOI18N |
57 |
private ColorUIResource primary3 = new ColorUIResource(204, 204, 255); |
69 |
private static final String USERFONT = "userFont"; // NOI18N |
58 |
|
70 |
private static final String MENUFONT = "menuFont"; // NOI18N |
59 |
private ColorUIResource secondary1 = new ColorUIResource(102, 102, 102); |
71 |
private static final String WINDOWTITLEFONT = "windowTitleFont"; // NOI18N |
60 |
private ColorUIResource secondary2 = new ColorUIResource(153, 153, 153); |
72 |
private static final String SUBFONT = "subFont"; // NOI18N |
61 |
private ColorUIResource secondary3 = new ColorUIResource(204, 204, 204); |
73 |
private static final String PRIMARY1 = "primary1"; // NOI18N |
62 |
|
74 |
private static final String PRIMARY2 = "primary2"; // NOI18N |
63 |
private FontUIResource controlFont; |
75 |
private static final String PRIMARY3 = "primary3"; // NOI18N |
64 |
private FontUIResource systemFont; |
76 |
private static final String SECONDARY1 = "secondary1"; // NOI18N |
65 |
private FontUIResource userFont; |
77 |
private static final String SECONDARY2 = "secondary2"; // NOI18N |
66 |
private FontUIResource subFont; |
78 |
private static final String SECONDARY3 = "secondary3"; // NOI18N |
67 |
private FontUIResource menuFont; |
79 |
private static final String WHITE = "white"; // NOI18N |
68 |
private FontUIResource windowTitleFont; |
80 |
private static final String BLACK = "black"; // NOI18N |
69 |
|
81 |
|
70 |
private String activeTag=""; // NOI18N |
82 |
private HashSet activeThemes=null; |
71 |
private boolean activeTagFlag=false; |
83 |
private boolean inActiveTheme=false; |
72 |
|
84 |
|
73 |
public String getName(){ return "NetBeans"; } // NOI18N |
85 |
private UIDefaults defaults; |
74 |
|
86 |
public String getName(){ return "NetBeans XML Theme"; } // NOI18N |
75 |
/** Creates new NBTheme */ |
87 |
/** Create a new instance of NBTheme */ |
76 |
public NbTheme() { |
88 |
public NbTheme() { |
77 |
try{ |
89 |
defaults = UIManager.getDefaults(); //cache to avoid overhead |
78 |
controlFont = new FontUIResource(new Font("Dialog", Font.PLAIN, 11)); // NOI18N |
90 |
addCustomDefaults (); |
79 |
systemFont = new FontUIResource(new Font("Dialog", Font.PLAIN, 11)); // NOI18N |
|
|
80 |
userFont = new FontUIResource(new Font("Dialog", Font.PLAIN, 11)); // NOI18N |
81 |
menuFont = new FontUIResource(new Font("Dialog", Font.PLAIN, 11)); // NOI18N |
82 |
windowTitleFont = new FontUIResource(new Font("Dialog", Font.PLAIN, 11)); // NOI18N |
83 |
subFont = new FontUIResource(new Font("Dialog", Font.PLAIN, 10)); // NOI18N |
84 |
UIManager.getDefaults ().put ("List.font", controlFont); // NOI18N |
85 |
UIManager.getDefaults ().put ("Tree.font", controlFont); // NOI18N |
86 |
UIManager.getDefaults ().put ("Panel.font", controlFont); // NOI18N |
87 |
} catch (Exception e){ |
88 |
ErrorManager.getDefault().notify(org.openide.ErrorManager.INFORMATIONAL, e); |
89 |
} |
90 |
parseTheme(); |
91 |
parseTheme(); |
91 |
} |
92 |
} |
92 |
|
93 |
|
93 |
protected ColorUIResource getPrimary1() { return primary1; } |
94 |
private void addCustomDefaults () { |
94 |
protected ColorUIResource getPrimary2() { return primary2; } |
95 |
//Note, all of this could be removed, and the themes file used |
95 |
protected ColorUIResource getPrimary3() { return primary3; } |
96 |
//for this job, but it does mean NetBeans would never start if |
96 |
|
97 |
//the themes file was missing - primary1, etc. would produce an NPE |
97 |
protected ColorUIResource getSecondary1() { return secondary1; } |
98 |
//when the UI calls them - Tim |
98 |
protected ColorUIResource getSecondary2() { return secondary2; } |
99 |
defaults.put(PRIMARY1, new ColorUIResource(102, 102, 153)); // NOI18N |
99 |
protected ColorUIResource getSecondary3() { return secondary3; } |
100 |
defaults.put(PRIMARY2, new ColorUIResource(153, 153, 204)); // NOI18N |
100 |
|
101 |
defaults.put(PRIMARY3, new ColorUIResource(204, 204, 255)); // NOI18N |
101 |
public FontUIResource getControlTextFont() { return controlFont; } |
102 |
|
102 |
public FontUIResource getSystemTextFont() { return systemFont; } |
103 |
defaults.put(SECONDARY1, new ColorUIResource(102, 102, 102)); // NOI18N |
103 |
public FontUIResource getUserTextFont() { return userFont; } |
104 |
defaults.put(SECONDARY2, new ColorUIResource(153, 153, 153)); // NOI18N |
104 |
public FontUIResource getMenuTextFont() { return menuFont; } |
105 |
defaults.put(SECONDARY3, new ColorUIResource(204, 204, 204)); // NOI18N |
105 |
public FontUIResource getWindowTitleFont() { return windowTitleFont; } |
106 |
|
106 |
public FontUIResource getSubTextFont() { return subFont; } |
107 |
defaults.put(WHITE, new ColorUIResource(255,255,255)); // NOI18N |
|
|
108 |
defaults.put(BLACK, new ColorUIResource(0,0,0)); // NOI18N |
109 |
|
110 |
FontUIResource controlFont = new FontUIResource(new Font("Dialog", Font.PLAIN, 11)); |
111 |
defaults.put(CONTROLFONT, controlFont); // NOI18N |
112 |
defaults.put(SYSTEMFONT, controlFont); // NOI18N |
113 |
defaults.put(USERFONT, controlFont); // NOI18N |
114 |
defaults.put(MENUFONT, controlFont); // NOI18N |
115 |
defaults.put(WINDOWTITLEFONT, controlFont); // NOI18N |
116 |
UIManager.getDefaults ().put ("List.font", controlFont); // NOI18N |
117 |
UIManager.getDefaults ().put ("Tree.font", controlFont); // NOI18N |
118 |
UIManager.getDefaults ().put ("Panel.font", controlFont); // NOI18N |
119 |
|
120 |
defaults.put(SUBFONT, new FontUIResource(new Font("Dialog", Font.PLAIN, 10))); // NOI18N |
121 |
} |
107 |
|
122 |
|
108 |
private void parseTheme(){ |
123 |
private void parseTheme(){ |
109 |
|
|
|
110 |
org.xml.sax.Parser p = org.openide.loaders.XMLDataObject.createParser(); |
124 |
org.xml.sax.Parser p = org.openide.loaders.XMLDataObject.createParser(); |
111 |
p.setDocumentHandler(this); |
125 |
p.setDocumentHandler(this); |
112 |
java.io.File f = new java.io.File(NonGui.getSystemDir() + java.io.File.separator + THEMEFILE_NAME); |
126 |
java.io.File f = new java.io.File(NonGui.getSystemDir() + java.io.File.separator + THEMEFILE_NAME); |
113 |
java.io.Reader cs = null; |
127 |
if (!f.exists()) { |
114 |
boolean useDefaults = false; |
128 |
return; |
115 |
try{ |
129 |
} |
116 |
cs = new java.io.FileReader(f); |
130 |
java.io.Reader fr = null; |
|
|
131 |
try { |
132 |
fr = new java.io.FileReader(f); |
117 |
} |
133 |
} |
118 |
catch(java.io.FileNotFoundException e){ |
134 |
catch(java.io.FileNotFoundException e){ |
119 |
useDefaults = true; |
135 |
//should never happen |
|
|
136 |
ErrorManager.getDefault().notify(org.openide.ErrorManager.INFORMATIONAL, e); |
120 |
} |
137 |
} |
121 |
|
138 |
|
122 |
if(!useDefaults){ |
139 |
org.xml.sax.InputSource is = new org.xml.sax.InputSource(fr); |
123 |
org.xml.sax.InputSource is = new org.xml.sax.InputSource(cs); |
140 |
try{ |
124 |
|
141 |
p.parse(is); |
125 |
try{ |
142 |
activeThemes=null; //dispose of now useless hashtable |
126 |
p.parse(is); |
143 |
} |
127 |
} |
144 |
catch(java.io.IOException ie){ |
128 |
catch(java.io.IOException ie){ |
145 |
ErrorManager.getDefault().notify(org.openide.ErrorManager.INFORMATIONAL, ie); |
129 |
ErrorManager.getDefault().notify(org.openide.ErrorManager.INFORMATIONAL, ie); |
146 |
} |
130 |
} |
147 |
catch(org.xml.sax.SAXException se){ |
131 |
catch(org.xml.sax.SAXException se){ |
148 |
ErrorManager.getDefault().annotate(se, "Error parsing theme file"); //NOI18N |
132 |
ErrorManager.getDefault().notify(org.openide.ErrorManager.INFORMATIONAL, se); |
149 |
ErrorManager.getDefault().notify(org.openide.ErrorManager.INFORMATIONAL, se); |
133 |
} |
|
|
134 |
} |
150 |
} |
135 |
} |
151 |
} |
136 |
|
152 |
|
Lines 141-229
Link Here
|
141 |
} |
157 |
} |
142 |
|
158 |
|
143 |
public void startElement(java.lang.String p1,org.xml.sax.AttributeList atts) throws org.xml.sax.SAXException { |
159 |
public void startElement(java.lang.String p1,org.xml.sax.AttributeList atts) throws org.xml.sax.SAXException { |
144 |
int r = 0; |
160 |
//found the themeset? |
145 |
int g = 0; |
161 |
if (p1.equals(THEMESET_TAG)) { |
146 |
int b = 0; |
162 |
//break out the comma delimited list of active themes |
147 |
String fontname = null; |
163 |
//and stores them in activeThemes hashset |
148 |
int fontstyle = 0; |
164 |
String themes = atts.getValue (ACTIVE_ATTR); |
149 |
int fontsize = 0; |
165 |
if (themes != null) { |
150 |
|
166 |
StringTokenizer tok = new StringTokenizer (themes, ","); //NOI18N |
151 |
if(p1.equals(MAIN_TAG) && atts.getLength()==1 && atts.getName(0).equals(MAIN_ACTIVATE_TAG)) { |
167 |
activeThemes = new HashSet (tok.countTokens() + 1); |
152 |
activeTag = atts.getValue(0); |
168 |
while (tok.hasMoreTokens()) { |
|
|
169 |
activeThemes.add(tok.nextToken()); |
170 |
} |
171 |
} |
153 |
} |
172 |
} |
154 |
else{ |
173 |
else{ |
155 |
if(p1.equals(THEME_TAG) && atts.getLength()==1 && atts.getName(0).equals(THEME_NAME_TAG) && atts.getValue(0).equals(activeTag)){ |
174 |
if (p1.equals(THEME_TAG) && (activeThemes != null)) { |
156 |
activeTagFlag=true; |
175 |
//see if the current theme is one of the active ones |
157 |
} |
176 |
String themeName = atts.getValue (NAME_ATTR); |
158 |
|
177 |
inActiveTheme = activeThemes.contains(themeName); |
159 |
if(activeTagFlag){ |
178 |
} else { |
160 |
for (int i = 0; i < atts.getLength(); i++) { |
179 |
if (inActiveTheme) { |
161 |
if(atts.getName(i).equals(R_TAG)){ |
180 |
if (p1.equals (COLOR_ATTR)) { |
162 |
r = Integer.valueOf(atts.getValue(i)).intValue(); |
181 |
handleColor (atts); |
163 |
} |
182 |
return; |
164 |
if(atts.getName(i).equals(G_TAG)){ |
|
|
165 |
g = Integer.valueOf(atts.getValue(i)).intValue(); |
166 |
} |
167 |
if(atts.getName(i).equals(B_TAG)){ |
168 |
b = Integer.valueOf(atts.getValue(i)).intValue(); |
169 |
} |
170 |
if(atts.getName(i).equals(FONTNAME_TAG)){ |
171 |
fontname = atts.getValue(i); |
172 |
} |
173 |
if(atts.getName(i).equals(FONTSTYLE_TAG)){ |
174 |
if(atts.getValue(i).equals(FONTSTYLE_PLAIN)) fontstyle = Font.PLAIN; |
175 |
if(atts.getValue(i).equals(FONTSTYLE_BOLD)) fontstyle = Font.BOLD; |
176 |
if(atts.getValue(i).equals(FONTSTYLE_ITALIC)) fontstyle = Font.ITALIC; |
177 |
} |
183 |
} |
178 |
if(atts.getName(i).equals(FONTSIZE_TAG)){ |
184 |
if (p1.equals (FONT_TAG)) { |
179 |
fontsize = Integer.valueOf(atts.getValue(i)).intValue(); |
185 |
handleFont (atts); |
|
|
186 |
return; |
187 |
} |
188 |
if (p1.equals (METRIC_TAG)) { |
189 |
handleMetric (atts); |
190 |
return; |
191 |
} |
192 |
if (p1.equals (STRING_TAG)) { |
193 |
handleString (atts); |
194 |
return; |
195 |
} |
196 |
if (p1.equals (INSETS_TAG)) { |
197 |
handleInsets (atts); |
198 |
return; |
199 |
} |
200 |
if (p1.equals (BOOL_TAG)) { |
201 |
handleBool (atts); |
202 |
return; |
203 |
} |
204 |
if (p1.equals (DIM_TAG)) { |
205 |
handleDim (atts); |
180 |
} |
206 |
} |
181 |
} |
|
|
182 |
|
183 |
if(p1.equals(PRIMARY1_TAG)){ |
184 |
primary1 = new ColorUIResource(r, g, b); |
185 |
} |
186 |
if(p1.equals(PRIMARY2_TAG)){ |
187 |
primary2 = new ColorUIResource(r, g, b); |
188 |
} |
189 |
if(p1.equals(PRIMARY3_TAG)){ |
190 |
primary3 = new ColorUIResource(r, g, b); |
191 |
} |
192 |
|
193 |
if(p1.equals(SECONDARY1_TAG)){ |
194 |
secondary1 = new ColorUIResource(r, g, b); |
195 |
} |
196 |
if(p1.equals(SECONDARY2_TAG)){ |
197 |
secondary2 = new ColorUIResource(r, g, b); |
198 |
} |
199 |
if(p1.equals(SECONDARY3_TAG)){ |
200 |
secondary3 = new ColorUIResource(r, g, b); |
201 |
} |
202 |
if(p1.equals(CONTROLFONT_TAG)){ |
203 |
controlFont = new FontUIResource(new Font(fontname, fontstyle, fontsize)); |
204 |
UIManager.getDefaults ().put ("List.font", controlFont); // NOI18N |
205 |
UIManager.getDefaults ().put ("Tree.font", controlFont); // NOI18N |
206 |
UIManager.getDefaults ().put ("Panel.font", controlFont); // NOI18N |
207 |
} |
208 |
if(p1.equals(SYSTEMFONT_TAG)){ |
209 |
systemFont = new FontUIResource(new Font(fontname, fontstyle, fontsize)); |
210 |
} |
211 |
if(p1.equals(USERFONT_TAG)){ |
212 |
userFont = new FontUIResource(new Font(fontname, fontstyle, fontsize)); |
213 |
} |
214 |
if(p1.equals(SUBFONT_TAG)){ |
215 |
subFont = new FontUIResource(new Font(fontname, fontstyle, fontsize)); |
216 |
} |
217 |
if(p1.equals(MENUFONT_TAG)){ |
218 |
menuFont = new FontUIResource(new Font(fontname, fontstyle, fontsize)); |
219 |
} |
220 |
if(p1.equals(WINDOWTITLEFONT_TAG)){ |
221 |
windowTitleFont = new FontUIResource(new Font(fontname, fontstyle, fontsize)); |
222 |
} |
207 |
} |
223 |
} |
208 |
} |
224 |
} |
209 |
} |
225 |
} |
210 |
} |
226 |
|
211 |
|
|
|
212 |
private final void handleFont (org.xml.sax.AttributeList atts) { |
213 |
String key = atts.getValue (KEY_ATTR); |
214 |
String fontname = atts.getValue (NAME_ATTR); |
215 |
String fontstylename = atts.getValue (FONTSTYLE_ATTR); |
216 |
int fontsize = intFromAttr (atts, FONTSIZE_ATTR); |
217 |
int fontstyle = Font.PLAIN; |
218 |
if(fontstylename.equals(FONTSTYLE_BOLD)) { |
219 |
fontstyle = Font.BOLD; |
220 |
} else { |
221 |
if(fontstylename.equals(FONTSTYLE_ITALIC)) fontstyle = Font.ITALIC; |
222 |
} |
223 |
FontUIResource resource = new FontUIResource (fontname, fontstyle, fontsize); |
224 |
defaults.put (key, resource); |
225 |
} |
226 |
|
227 |
private final void handleColor (org.xml.sax.AttributeList atts) { |
228 |
int r = intFromAttr (atts, RED_ATTR); |
229 |
int g = intFromAttr (atts, GREEN_ATTR); |
230 |
int b = intFromAttr (atts, BLUE_ATTR); |
231 |
String key = atts.getValue(KEY_ATTR); |
232 |
ColorUIResource resource = new ColorUIResource (r,g,b); |
233 |
defaults.put (key, resource); |
234 |
} |
235 |
|
236 |
private final void handleMetric (org.xml.sax.AttributeList atts) { |
237 |
String key = atts.getValue(KEY_ATTR); |
238 |
Integer resource = Integer.valueOf (atts.getValue(VALUE_ATTR)); |
239 |
defaults.put (key, resource); |
240 |
} |
241 |
|
242 |
private final void handleString (org.xml.sax.AttributeList atts) { |
243 |
String key = atts.getValue (KEY_ATTR); |
244 |
String resource = atts.getValue (VALUE_ATTR); |
245 |
defaults.put (key, resource); |
246 |
} |
247 |
|
248 |
private final void handleBool (org.xml.sax.AttributeList atts) { |
249 |
String key = atts.getValue (KEY_ATTR); |
250 |
Boolean resource = Boolean.valueOf (key); |
251 |
defaults.put (key, resource); |
252 |
} |
253 |
|
254 |
private final void handleDim (org.xml.sax.AttributeList atts) { |
255 |
String key = atts.getValue (KEY_ATTR); |
256 |
int width = intFromAttr (atts, WIDTH_ATTR); |
257 |
int height = intFromAttr (atts, HEIGHT_ATTR); |
258 |
DimensionUIResource resource = new DimensionUIResource (width, height); |
259 |
defaults.put (key, resource); |
260 |
} |
261 |
|
262 |
private final void handleInsets (org.xml.sax.AttributeList atts) { |
263 |
String key = atts.getValue (KEY_ATTR); |
264 |
int top = intFromAttr (atts, TOP_ATTR); |
265 |
int left = intFromAttr (atts, LEFT_ATTR); |
266 |
int bottom = intFromAttr (atts, RIGHT_ATTR); |
267 |
int right = intFromAttr (atts, RIGHT_ATTR); |
268 |
InsetsUIResource resource = new InsetsUIResource (top, left, bottom, |
269 |
right); |
270 |
defaults.put (key, resource); |
271 |
} |
272 |
|
273 |
|
274 |
private final int intFromAttr (final org.xml.sax.AttributeList atts, final String key) { |
275 |
try { |
276 |
return Integer.valueOf (atts.getValue (key)).intValue(); |
277 |
} catch (NumberFormatException nfe) { |
278 |
ErrorManager.getDefault().notify(org.openide.ErrorManager.INFORMATIONAL, nfe); |
279 |
return 0; |
280 |
} |
281 |
} |
282 |
|
227 |
public void characters(char[] p1,int p2,int p3) throws org.xml.sax.SAXException { |
283 |
public void characters(char[] p1,int p2,int p3) throws org.xml.sax.SAXException { |
228 |
} |
284 |
} |
229 |
|
285 |
|
Lines 232-240
Link Here
|
232 |
|
288 |
|
233 |
public void endElement(java.lang.String p1) throws org.xml.sax.SAXException { |
289 |
public void endElement(java.lang.String p1) throws org.xml.sax.SAXException { |
234 |
if(p1.equals(THEME_TAG)){ |
290 |
if(p1.equals(THEME_TAG)){ |
235 |
activeTagFlag=false; |
291 |
inActiveTheme=false; |
236 |
} |
292 |
} |
237 |
|
|
|
238 |
} |
293 |
} |
239 |
|
294 |
|
240 |
public void ignorableWhitespace(char[] p1,int p2,int p3) throws org.xml.sax.SAXException { |
295 |
public void ignorableWhitespace(char[] p1,int p2,int p3) throws org.xml.sax.SAXException { |
Lines 242-255
Link Here
|
242 |
|
297 |
|
243 |
public void processingInstruction(java.lang.String p1,java.lang.String p2) throws org.xml.sax.SAXException { |
298 |
public void processingInstruction(java.lang.String p1,java.lang.String p2) throws org.xml.sax.SAXException { |
244 |
} |
299 |
} |
|
|
300 |
|
301 |
private final ColorUIResource getColor(String key) { |
302 |
return (ColorUIResource) defaults.get (key); |
303 |
} |
304 |
|
305 |
private final FontUIResource getFont(String key) { |
306 |
return (FontUIResource) defaults.get (key); |
307 |
} |
308 |
|
309 |
public FontUIResource getControlTextFont() { return getFont (CONTROLFONT); } |
310 |
public FontUIResource getSystemTextFont() { return getFont (SYSTEMFONT); } |
311 |
public FontUIResource getUserTextFont() { return getFont (USERFONT); } |
312 |
public FontUIResource getMenuTextFont() { return getFont (MENUFONT); } |
313 |
public FontUIResource getWindowTitleFont() { return getFont (WINDOWTITLEFONT); } |
314 |
public FontUIResource getSubTextFont() { return getFont (SUBFONT); } |
315 |
protected ColorUIResource getPrimary1() { return getColor (PRIMARY1); } |
316 |
protected ColorUIResource getPrimary2() { return getColor (PRIMARY2); } |
317 |
protected ColorUIResource getPrimary3() { return getColor (PRIMARY3); } |
318 |
protected ColorUIResource getSecondary1() { return getColor (SECONDARY1); } |
319 |
protected ColorUIResource getSecondary2() { return getColor (SECONDARY2); } |
320 |
protected ColorUIResource getSecondary3() { return getColor (SECONDARY3); } |
321 |
protected ColorUIResource getWhite() { return getColor (WHITE); } |
322 |
protected ColorUIResource getBlack() { return getColor (BLACK); } |
245 |
|
323 |
|
246 |
/* |
|
|
247 |
public ColorUIResource getSystemTextColor(){ return primary1; } |
248 |
public ColorUIResource getControlTextColor(){ return primary1; } |
249 |
public ColorUIResource getInactiveControlTextColor(){ return primary1; } |
250 |
public ColorUIResource getInactiveSystemTextColor(){ return primary1; } |
251 |
public ColorUIResource getUserTextColor(){ return primary1; } |
252 |
public ColorUIResource getTextHighlightColor(){ return primary1; } |
253 |
public ColorUIResource getHighlightedTextColor(){ return primary1; } |
254 |
*/ |
255 |
} |
324 |
} |