Source Code Cross Referenced for ConfigurableMetalTheme.java in  » Mail-Clients » pooka » net » suberic » util » swing » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Mail Clients » pooka » net.suberic.util.swing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.suberic.util.swing;
002:
003:        import net.suberic.util.*;
004:        import java.util.*;
005:        import javax.swing.*;
006:        import javax.swing.plaf.metal.*;
007:        import javax.swing.plaf.*;
008:
009:        /**
010:         * A Theme which allows you to set all of your colors for a Metal
011:         * application.
012:         */
013:        public class ConfigurableMetalTheme extends DefaultMetalTheme implements 
014:                Item, ValueChangeListener {
015:
016:            private String itemId;
017:            private String resourceString;
018:
019:            private VariableBundle bundle = null;
020:
021:            private WeakHashMap themeListenerList = new WeakHashMap();
022:
023:            protected ColorUIResource subPrimary1 = null;
024:            protected ColorUIResource subPrimary2 = null;
025:            protected ColorUIResource subPrimary3 = null;
026:
027:            protected ColorUIResource subSecondary1 = null;
028:            protected ColorUIResource subSecondary2 = null;
029:            protected ColorUIResource subSecondary3 = null;
030:
031:            protected ColorUIResource subBlack = null;
032:            protected ColorUIResource subWhite = null;
033:
034:            protected FontUIResource subControlFont = null;
035:            protected FontUIResource subSystemFont = null;
036:            protected FontUIResource subUserFont = null;
037:            protected FontUIResource subSmallFont = null;
038:            protected FontUIResource subMonospacedFont = null;
039:
040:            /**
041:             * Creates a new ConfigurableMetalTheme from the given property.
042:             */
043:            public ConfigurableMetalTheme(VariableBundle sourceBundle,
044:                    String newResourceString, String newItemId) {
045:                itemId = newItemId;
046:                resourceString = newResourceString;
047:
048:                bundle = sourceBundle;
049:
050:                loadTheme(getItemProperty(), sourceBundle);
051:
052:                sourceBundle.addValueChangeListener(this , getItemProperty()
053:                        + ".*");
054:            }
055:
056:            /**
057:             * The Item ID.  For example, if you were to have a list of users, a
058:             * given user's itemID may be "defaultUser".
059:             */
060:            public String getItemID() {
061:                return itemId;
062:            }
063:
064:            /**
065:             * The Item property.  For example, if you were to have a list of users, a
066:             * given user's itemProperty may be "Users.defaultUser".
067:             */
068:            public String getItemProperty() {
069:                return resourceString + "." + itemId;
070:            }
071:
072:            /**
073:             * Called when a ui value changes.
074:             */
075:            public void valueChanged(String changedValue) {
076:                loadTheme(getItemProperty(), bundle);
077:                fireThemeChangedEvent();
078:            }
079:
080:            /**
081:             * Adds a ThemeListener to the ListenerList.
082:             */
083:            public void addThemeListener(ThemeListener tl) {
084:                if (!themeListenerList.containsKey(tl))
085:                    themeListenerList.put(tl, null);
086:            }
087:
088:            /**
089:             * Removes a ThemeListener from the ListenerList.
090:             */
091:            public void removeThemeListener(ThemeListener tl) {
092:                themeListenerList.remove(tl);
093:            }
094:
095:            /**
096:             * Notifies all registered ThemeListeners that this Theme has changed.
097:             */
098:            public void fireThemeChangedEvent() {
099:                Iterator iter = themeListenerList.keySet().iterator();
100:                while (iter.hasNext()) {
101:                    ThemeListener current = (ThemeListener) iter.next();
102:                    current.themeChanged(this );
103:                }
104:            }
105:
106:            /**
107:             * This loads the theme from the given property and bundle.
108:             */
109:            protected void loadTheme(String property,
110:                    VariableBundle sourceBundle) {
111:                subPrimary1 = createColorUIResource(property + ".primary1",
112:                        sourceBundle);
113:                subPrimary2 = createColorUIResource(property + ".primary2",
114:                        sourceBundle);
115:                subPrimary3 = createColorUIResource(property + ".primary3",
116:                        sourceBundle);
117:
118:                subSecondary1 = createColorUIResource(property + ".secondary1",
119:                        sourceBundle);
120:                subSecondary2 = createColorUIResource(property + ".secondary2",
121:                        sourceBundle);
122:                subSecondary3 = createColorUIResource(property + ".secondary3",
123:                        sourceBundle);
124:                subWhite = createColorUIResource(property + ".white",
125:                        sourceBundle);
126:                subBlack = createColorUIResource(property + ".black",
127:                        sourceBundle);
128:
129:                subControlFont = createFontUIResource(
130:                        property + ".controlFont", sourceBundle);
131:                subSystemFont = createFontUIResource(property + ".systemFont",
132:                        sourceBundle);
133:                subUserFont = createFontUIResource(property + ".userFont",
134:                        sourceBundle);
135:                subSmallFont = createFontUIResource(property + ".smallFont",
136:                        sourceBundle);
137:                subMonospacedFont = createFontUIResource(property
138:                        + ".monospacedFont", sourceBundle);
139:
140:            }
141:
142:            protected ColorUIResource createColorUIResource(String property,
143:                    VariableBundle sourceBundle) {
144:                String enabled = sourceBundle.getProperty(property
145:                        + "._enabled", "false");
146:                if (enabled.equalsIgnoreCase("true")) {
147:                    String rgbString = sourceBundle.getProperty(property
148:                            + ".rgb", "");
149:                    if (rgbString != null && !rgbString.equals("")) {
150:                        try {
151:                            int rgbValue = Integer.parseInt(rgbString);
152:                            ColorUIResource returnValue = new ColorUIResource(
153:                                    rgbValue);
154:                            return returnValue;
155:                        } catch (Exception e) {
156:                            return null;
157:                        }
158:                    }
159:                }
160:
161:                return null;
162:            }
163:
164:            protected FontUIResource createFontUIResource(String property,
165:                    VariableBundle sourceBundle) {
166:                String enabled = sourceBundle.getProperty(property
167:                        + "._enabled", "false");
168:                if (enabled.equalsIgnoreCase("true")) {
169:                    String fontString = sourceBundle.getProperty(property, "");
170:                    if (fontString != null && !fontString.equals("")) {
171:                        try {
172:                            FontUIResource returnValue = new FontUIResource(
173:                                    java.awt.Font.decode(fontString));
174:                            return returnValue;
175:                        } catch (Exception e) {
176:                            return null;
177:                        }
178:                    }
179:                }
180:
181:                return null;
182:            }
183:
184:            public String getName() {
185:                return getItemID();
186:            }
187:
188:            protected ColorUIResource getPrimary1() {
189:                if (subPrimary1 != null)
190:                    return subPrimary1;
191:                else
192:                    return super .getPrimary1();
193:            }
194:
195:            protected ColorUIResource getPrimary2() {
196:                if (subPrimary2 != null)
197:                    return subPrimary2;
198:                else
199:                    return super .getPrimary2();
200:            }
201:
202:            protected ColorUIResource getPrimary3() {
203:                if (subPrimary3 != null)
204:                    return subPrimary3;
205:                else
206:                    return super .getPrimary3();
207:            }
208:
209:            protected ColorUIResource getSecondary1() {
210:                if (subSecondary1 != null)
211:                    return subSecondary1;
212:                else
213:                    return super .getSecondary1();
214:            }
215:
216:            protected ColorUIResource getSecondary2() {
217:                if (subSecondary2 != null)
218:                    return subSecondary2;
219:                else
220:                    return super .getSecondary2();
221:            }
222:
223:            protected ColorUIResource getSecondary3() {
224:                if (subSecondary3 != null)
225:                    return subSecondary3;
226:                else
227:                    return super .getSecondary3();
228:            }
229:
230:            protected ColorUIResource getWhite() {
231:                if (subWhite != null)
232:                    return subWhite;
233:                else
234:                    return super .getWhite();
235:            }
236:
237:            protected ColorUIResource getBlack() {
238:                if (subBlack != null) {
239:
240:                    return subBlack;
241:                } else {
242:                    return super .getBlack();
243:                }
244:            }
245:
246:            public FontUIResource getControlTextFont() {
247:                if (subControlFont != null)
248:                    return subControlFont;
249:                else
250:                    return super .getControlTextFont();
251:            }
252:
253:            public FontUIResource getSystemTextFont() {
254:                if (subSystemFont != null)
255:                    return subSystemFont;
256:                else
257:                    return super .getSystemTextFont();
258:            }
259:
260:            public FontUIResource getUserTextFont() {
261:                if (subUserFont != null)
262:                    return subUserFont;
263:                else
264:                    return super .getUserTextFont();
265:            }
266:
267:            public FontUIResource getMenuTextFont() {
268:                if (subControlFont != null)
269:                    return subControlFont;
270:                else
271:                    return super .getMenuTextFont();
272:            }
273:
274:            public FontUIResource getWindowTitleFont() {
275:                if (subControlFont != null)
276:                    return subControlFont;
277:                else
278:                    return super .getWindowTitleFont();
279:            }
280:
281:            public FontUIResource getSubTextFont() {
282:                if (subSmallFont != null)
283:                    return subSmallFont;
284:                else
285:                    return super .getSubTextFont();
286:            }
287:
288:            public FontUIResource getMonospacedFont() {
289:                return subMonospacedFont;
290:            }
291:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.