Source Code Cross Referenced for UIDefaultsLookup.java in  » Swing-Library » jide-common » com » jidesoft » plaf » 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 » Swing Library » jide common » com.jidesoft.plaf 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)UIManagerLookup.java 4/5/2007
003:         *
004:         * Copyright 2002 - 2007 JIDE Software Inc. All rights reserved.
005:         */
006:
007:        package com.jidesoft.plaf;
008:
009:        import com.jidesoft.converter.ObjectConverterManager;
010:
011:        import javax.swing.*;
012:        import javax.swing.border.Border;
013:        import java.awt.*;
014:        import java.util.Locale;
015:
016:        /**
017:         * This class simply uses UIManager's get method to lookup the UIDefaults.
018:         * We used this everywhere in our code so that we have one central place
019:         * to find out which UIDefaults we are using.
020:         * Another good thing is you can use {@link #setTrace(boolean)} and {@link #setDebug(boolean)}
021:         * to turn on the trace so that it will print out which UIDefaults we are trying to get.
022:         */
023:        public class UIDefaultsLookup {
024:            private static boolean _debug = false;
025:            private static boolean _trace = false;
026:
027:            /**
028:             * Sets the debug mode. If debug mode is on, we will print out
029:             * any UIDefaults that the value is null.
030:             *
031:             * @param debug true or false.
032:             */
033:            public static void setDebug(boolean debug) {
034:                _debug = debug;
035:            }
036:
037:            /**
038:             * Sets the trace mode. If trace mode is on, we will print out
039:             * any UIDefaults we are trying to get and its current value.
040:             *
041:             * @param trace true or false.
042:             */
043:            public static void setTrace(boolean trace) {
044:                _trace = trace;
045:            }
046:
047:            public static Object get(Object key) {
048:                Object value = UIManager.get(key);
049:                log(value, key, null);
050:                return value;
051:            }
052:
053:            public static Object get(Object key, Locale l) {
054:                Object value = UIManager.get(key, l);
055:                log(value, key, l);
056:                return value;
057:            }
058:
059:            private static void log(Object value, Object key, Locale l) {
060:                if (_debug && value == null) {
061:                    System.out.println("\"" + key
062:                            + (l == null ? "" : l.toString())
063:                            + " \" ==> null ------------------------");
064:                } else if (_trace) {
065:                    if (value == null) {
066:                        System.out.println("\"" + key
067:                                + (l == null ? "" : l.toString())
068:                                + " \" ==> null ------------------------");
069:                    } else {
070:                        System.out.println("\"" + key
071:                                + (l == null ? "" : l.toString()) + " \" ==> "
072:                                + value.getClass().getName() + "("
073:                                + ObjectConverterManager.toString(value) + ")");
074:                    }
075:                }
076:            }
077:
078:            /**
079:             * If the value of <code>key</code> is a <code>Font</code> return it,
080:             * otherwise return <code>null</code>.
081:             *
082:             * @param key the desired key
083:             * @return if the value for <code>key</code> is a <code>Font</code>,
084:             *         return the <code>Font</code> object; otherwise return
085:             *         <code>null</code>
086:             */
087:            public static Font getFont(Object key) {
088:                Object value = get(key);
089:                return (value instanceof  Font) ? (Font) value : null;
090:            }
091:
092:            /**
093:             * If the value of <code>key</code> for the given <code>Locale</code>
094:             * is a <code>Font</code> return it, otherwise return <code>null</code>.
095:             *
096:             * @param key the desired key
097:             * @param l   the desired locale
098:             * @return if the value for <code>key</code> and <code>Locale</code>
099:             *         is a <code>Font</code>,
100:             *         return the <code>Font</code> object; otherwise return
101:             *         <code>null</code>
102:             * @since 1.9.5.04
103:             */
104:            public static Font getFont(Object key, Locale l) {
105:                Object value = get(key, l);
106:                return (value instanceof  Font) ? (Font) value : null;
107:            }
108:
109:            /**
110:             * If the value of <code>key</code> is a <code>Color</code> return it,
111:             * otherwise return <code>null</code>.
112:             *
113:             * @param key the desired key
114:             * @return if the value for <code>key</code> is a <code>Color</code>,
115:             *         return the <code>Color</code> object; otherwise return
116:             *         <code>null</code>
117:             */
118:            public static Color getColor(Object key) {
119:                Object value = get(key);
120:                return (value instanceof  Color) ? (Color) value : null;
121:            }
122:
123:            /**
124:             * If the value of <code>key</code> for the given <code>Locale</code>
125:             * is a <code>Color</code> return it, otherwise return <code>null</code>.
126:             *
127:             * @param key the desired key
128:             * @param l   the desired locale
129:             * @return if the value for <code>key</code> and <code>Locale</code>
130:             *         is a <code>Color</code>,
131:             *         return the <code>Color</code> object; otherwise return
132:             *         <code>null</code>
133:             * @since 1.9.5.04
134:             */
135:            public static Color getColor(Object key, Locale l) {
136:                Object value = get(key, l);
137:                return (value instanceof  Color) ? (Color) value : null;
138:            }
139:
140:            /**
141:             * If the value of <code>key</code> is an <code>Icon</code> return it,
142:             * otherwise return <code>null</code>.
143:             *
144:             * @param key the desired key
145:             * @return if the value for <code>key</code> is an <code>Icon</code>,
146:             *         return the <code>Icon</code> object; otherwise return
147:             *         <code>null</code>
148:             */
149:            public static Icon getIcon(Object key) {
150:                Object value = get(key);
151:                return (value instanceof  Icon) ? (Icon) value : null;
152:            }
153:
154:            /**
155:             * If the value of <code>key</code> for the given <code>Locale</code>
156:             * is an <code>Icon</code> return it, otherwise return <code>null</code>.
157:             *
158:             * @param key the desired key
159:             * @param l   the desired locale
160:             * @return if the value for <code>key</code> and <code>Locale</code>
161:             *         is an <code>Icon</code>,
162:             *         return the <code>Icon</code> object; otherwise return
163:             *         <code>null</code>
164:             * @since 1.9.5.04
165:             */
166:            public static Icon getIcon(Object key, Locale l) {
167:                Object value = get(key, l);
168:                return (value instanceof  Icon) ? (Icon) value : null;
169:            }
170:
171:            /**
172:             * If the value of <code>key</code> is a <code>Border</code> return it,
173:             * otherwise return <code>null</code>.
174:             *
175:             * @param key the desired key
176:             * @return if the value for <code>key</code> is a <code>Border</code>,
177:             *         return the <code>Border</code> object; otherwise return
178:             *         <code>null</code>
179:             */
180:            public static Border getBorder(Object key) {
181:                Object value = get(key);
182:                return (value instanceof  Border) ? (Border) value : null;
183:            }
184:
185:            /**
186:             * If the value of <code>key</code> for the given <code>Locale</code>
187:             * is a <code>Border</code> return it, otherwise return <code>null</code>.
188:             *
189:             * @param key the desired key
190:             * @param l   the desired locale
191:             * @return if the value for <code>key</code> and <code>Locale</code>
192:             *         is a <code>Border</code>,
193:             *         return the <code>Border</code> object; otherwise return
194:             *         <code>null</code>
195:             * @since 1.9.5.04
196:             */
197:            public static Border getBorder(Object key, Locale l) {
198:                Object value = get(key, l);
199:                return (value instanceof  Border) ? (Border) value : null;
200:            }
201:
202:            /**
203:             * If the value of <code>key</code> is a <code>String</code> return it,
204:             * otherwise return <code>null</code>.
205:             *
206:             * @param key the desired key
207:             * @return if the value for <code>key</code> is a <code>String</code>,
208:             *         return the <code>String</code> object; otherwise return
209:             *         <code>null</code>
210:             */
211:            public static String getString(Object key) {
212:                Object value = get(key);
213:                return (value instanceof  String) ? (String) value : null;
214:            }
215:
216:            /**
217:             * If the value of <code>key</code> for the given <code>Locale</code>
218:             * is a <code>String</code> return it, otherwise return <code>null</code>.
219:             *
220:             * @param key the desired key
221:             * @param l   the desired <code>Locale</code>
222:             * @return if the value for <code>key</code> for the given
223:             *         <code>Locale</code> is a <code>String</code>,
224:             *         return the <code>String</code> object; otherwise return
225:             *         <code>null</code>
226:             * @since 1.9.5.04
227:             */
228:            public static String getString(Object key, Locale l) {
229:                Object value = get(key, l);
230:                return (value instanceof  String) ? (String) value : null;
231:            }
232:
233:            /**
234:             * If the value of <code>key</code> is an <code>Integer</code> return its
235:             * integer value, otherwise return 0.
236:             *
237:             * @param key the desired key
238:             * @return if the value for <code>key</code> is an <code>Integer</code>,
239:             *         return its value, otherwise return 0
240:             */
241:            public static int getInt(Object key) {
242:                Object value = get(key);
243:                return (value instanceof  Integer) ? (Integer) value : 0;
244:            }
245:
246:            /**
247:             * If the value of <code>key</code> for the given <code>Locale</code>
248:             * is an <code>Integer</code> return its integer value, otherwise return 0.
249:             *
250:             * @param key the desired key
251:             * @param l   the desired locale
252:             * @return if the value for <code>key</code> and <code>Locale</code>
253:             *         is an <code>Integer</code>,
254:             *         return its value, otherwise return 0
255:             * @since 1.9.5.04
256:             */
257:            public static int getInt(Object key, Locale l) {
258:                Object value = get(key, l);
259:                return (value instanceof  Integer) ? (Integer) value : 0;
260:            }
261:
262:            /**
263:             * If the value of <code>key</code> is boolean, return the
264:             * boolean value, otherwise return false.
265:             *
266:             * @param key an <code>Object</code> specifying the key for the desired boolean value
267:             * @return if the value of <code>key</code> is boolean, return the
268:             *         boolean value, otherwise return false.
269:             * @since 1.9.5.04
270:             */
271:            public static boolean getBoolean(Object key) {
272:                Object value = get(key);
273:                return (value instanceof  Boolean) ? (Boolean) value : false;
274:            }
275:
276:            /**
277:             * If the value of <code>key</code> for the given <code>Locale</code>
278:             * is boolean, return the boolean value, otherwise return false.
279:             *
280:             * @param key an <code>Object</code> specifying the key for the desired boolean value
281:             * @param l   the desired locale
282:             * @return if the value for <code>key</code> and <code>Locale</code>
283:             *         is boolean, return the
284:             *         boolean value, otherwise return false.
285:             * @since 1.9.5.04
286:             */
287:            public static boolean getBoolean(Object key, Locale l) {
288:                Object value = get(key, l);
289:                return (value instanceof  Boolean) ? (Boolean) value : false;
290:            }
291:
292:            /**
293:             * If the value of <code>key</code> is an <code>Insets</code> return it,
294:             * otherwise return <code>null</code>.
295:             *
296:             * @param key the desired key
297:             * @return if the value for <code>key</code> is an <code>Insets</code>,
298:             *         return the <code>Insets</code> object; otherwise return
299:             *         <code>null</code>
300:             */
301:            public static Insets getInsets(Object key) {
302:                Object value = get(key);
303:                return (value instanceof  Insets) ? (Insets) value : null;
304:            }
305:
306:            /**
307:             * If the value of <code>key</code> for the given <code>Locale</code>
308:             * is an <code>Insets</code> return it, otherwise return <code>null</code>.
309:             *
310:             * @param key the desired key
311:             * @param l   the desired locale
312:             * @return if the value for <code>key</code> and <code>Locale</code>
313:             *         is an <code>Insets</code>,
314:             *         return the <code>Insets</code> object; otherwise return
315:             *         <code>null</code>
316:             * @since 1.9.5.04
317:             */
318:            public static Insets getInsets(Object key, Locale l) {
319:                Object value = get(key, l);
320:                return (value instanceof  Insets) ? (Insets) value : null;
321:            }
322:
323:            /**
324:             * If the value of <code>key</code> is a <code>Dimension</code> return it,
325:             * otherwise return <code>null</code>.
326:             *
327:             * @param key the desired key
328:             * @return if the value for <code>key</code> is a <code>Dimension</code>,
329:             *         return the <code>Dimension</code> object; otherwise return
330:             *         <code>null</code>
331:             */
332:            public static Dimension getDimension(Object key) {
333:                Object value = get(key);
334:                return (value instanceof  Dimension) ? (Dimension) value : null;
335:            }
336:
337:            /**
338:             * If the value of <code>key</code> for the given <code>Locale</code>
339:             * is a <code>Dimension</code> return it, otherwise return <code>null</code>.
340:             *
341:             * @param key the desired key
342:             * @param l   the desired locale
343:             * @return if the value for <code>key</code> and <code>Locale</code>
344:             *         is a <code>Dimension</code>,
345:             *         return the <code>Dimension</code> object; otherwise return
346:             *         <code>null</code>
347:             * @since 1.9.5.04
348:             */
349:            public static Dimension getDimension(Object key, Locale l) {
350:                Object value = get(key, l);
351:                return (value instanceof  Dimension) ? (Dimension) value : null;
352:            }
353:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.