Source Code Cross Referenced for CustomOceanTheme.java in  » IDE » tIDE » snow » lookandfeel » 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 » IDE » tIDE » snow.lookandfeel 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package snow.lookandfeel;
002:
003:        import snow.utils.storage.AppProperties;
004:        import java.io.*;
005:        import javax.swing.*;
006:        import javax.swing.event.*;
007:        import javax.swing.plaf.metal.*;
008:        import javax.swing.plaf.*;
009:        import javax.swing.plaf.InsetsUIResource;
010:        import java.awt.Color;
011:        import java.awt.Font;
012:        import java.awt.event.*;
013:        import java.util.*;
014:
015:        public class CustomOceanTheme extends OceanTheme {
016:            final private String customName;
017:
018:            // the properties, maybe customized by the user, keys always starting with customName
019:            final private AppProperties props;
020:
021:            // each subclass may defins its own defaults (efcn => dark, cloud => bright)
022:            final private AppProperties themeDefaults = new AppProperties();
023:
024:            public final static String COLOR_BLACK = "Black";
025:            public final static String COLOR_White = "White";
026:
027:            public final static String COLOR_Green = "Green";
028:            public final static String COLOR_Red = "Red";
029:
030:            public final static String COLOR_Primary1 = "Primary 1";
031:            public final static String COLOR_Primary2 = "Primary 2";
032:            public final static String COLOR_Primary3 = "Primary 3";
033:
034:            public final static String COLOR_Secondary1 = "Secondary 1";
035:            public final static String COLOR_Secondary2 = "Secondary 2";
036:            public final static String COLOR_Secondary3 = "Secondary 3";
037:
038:            public final static String COLOR_tide_Comments = "tIDE Comments";
039:            public final static String COLOR_tide_Keywords = "tIDE Keywords";
040:            public final static String COLOR_tide_Text = "tIDE Text";
041:            public final static String COLOR_tide_Litterals = "tIDE Litteral";
042:
043:            public final static String COLOR_ControlText = "ControlTextColor";
044:            public final static String COLOR_DesktopColor = "DesktopColor";
045:            public final static String COLOR_InactiveControlText = "InactiveControlTextColor";
046:            public final static String COLOR_MenuDisabledForeground = "MenuDisabledForegroundColor";
047:
048:            public final static String COLOR_TextHighlight = "TextHighlightColor";
049:            public final static String COLOR_UserText = "UserTextColor";
050:
051:            public static final String FONT_SubText = "SubTextFont";
052:            public static final String FONT_System = "SystemFont";
053:            public static final String FONT_UserText = "UserTextFont";
054:            public static final String FONT_WindowTitle = "WindowTitleFont";
055:            public static final String FONT_ControlText = "ControlTextFont";
056:            public static final String FONT_MenuText = "MenuTextFont";
057:            public static final String FONT_CodeEditor = "CodeEditorFont";
058:
059:            private ImageIcon backgroundImage;
060:
061:            public CustomOceanTheme(final String customName,
062:                    final AppProperties props, final ImageIcon backgroundImage) {
063:                super ();
064:                this .customName = customName;
065:                this .props = props;
066:                this .backgroundImage = backgroundImage;
067:
068:                this .setDefaultColor(this .COLOR_Green, new ColorUIResource(180,
069:                        250, 180));
070:                this .setDefaultColor(this .COLOR_Red, new ColorUIResource(250,
071:                        100, 100)); // [Nov2007]: 180 => 100
072:
073:                this .setDefaultColor(this .COLOR_tide_Comments,
074:                        new ColorUIResource(30, 30, 160));
075:                this .setDefaultColor(this .COLOR_tide_Text, new ColorUIResource(
076:                        0, 0, 0));
077:                this .setDefaultColor(this .COLOR_tide_Keywords,
078:                        new ColorUIResource(160, 30, 30));
079:                this .setDefaultColor(this .COLOR_tide_Litterals,
080:                        new ColorUIResource(30, 160, 30));
081:
082:                this .setDefaultFont(FONT_CodeEditor, new Font(
083:                        "Lucida Sans Typewriter", Font.PLAIN, 12));
084:            }
085:
086:            /** Overwrite this if you change something to the theme.
087:             */
088:            public void writeDefaults() {
089:            }
090:
091:            @Override
092:            public String getName() {
093:                return customName;
094:            }
095:
096:            /**
097:             *  Returns the background image for this theme if it exists,
098:             *  and null otherwise.
099:             */
100:            public ImageIcon getBackgroundImage() {
101:                return this .backgroundImage;
102:            }
103:
104:            @Override
105:            public void addCustomEntriesToTable(UIDefaults table) {
106:                super .addCustomEntriesToTable(table);
107:                UIManager.put("ScrollBar.width", 12); // instead 17
108:                UIManager.put("SplitPane.dividerSize", 8); // instead 10
109:                UIManager.put("TabbedPane.contentBorderInsets",
110:                        new InsetsUIResource(4, 0, 0, 0));
111:                UIManager.put("Tree.leftChildIndent", 4); // instead 7
112:                UIManager.put("Tree.rightChildIndent", 9); // instead 13
113:
114:                UIManager.put(FONT_CodeEditor, new Font(
115:                        "Lucida Sans Typewriter", Font.PLAIN, 12));
116:            }
117:
118:            //
119:            // COLORS
120:            //
121:            @Override
122:            public final ColorUIResource getBlack() {
123:                return getColor(COLOR_BLACK);
124:            }
125:
126:            @Override
127:            public ColorUIResource getWhite() {
128:                return getColor(COLOR_White);
129:            }
130:
131:            public ColorUIResource getGreen() {
132:                return getColor(COLOR_Green);
133:            }
134:
135:            //NO @Override
136:            public ColorUIResource getRed() {
137:                return getColor(COLOR_Red);
138:            }
139:
140:            @Override
141:            protected ColorUIResource getPrimary1() {
142:                return getColor(COLOR_Primary1);
143:            }
144:
145:            @Override
146:            protected ColorUIResource getPrimary2() {
147:                return getColor(COLOR_Primary2);
148:            }
149:
150:            @Override
151:            protected ColorUIResource getPrimary3() {
152:                return getColor(COLOR_Primary3);
153:            }
154:
155:            @Override
156:            protected ColorUIResource getSecondary1() {
157:                return getColor(COLOR_Secondary1);
158:            }
159:
160:            @Override
161:            protected ColorUIResource getSecondary2() {
162:                return getColor(COLOR_Secondary2);
163:            }
164:
165:            @Override
166:            protected ColorUIResource getSecondary3() {
167:                return getColor(COLOR_Secondary3);
168:            }
169:
170:            /** table text
171:             */
172:            @Override
173:            public ColorUIResource getControlTextColor() {
174:                return getColor(this .COLOR_ControlText);
175:            }
176:
177:            @Override
178:            public ColorUIResource getDesktopColor() {
179:                return getColor(this .COLOR_DesktopColor);
180:            }
181:
182:            @Override
183:            public ColorUIResource getInactiveControlTextColor() {
184:                return getColor(this .COLOR_InactiveControlText);
185:            }
186:
187:            @Override
188:            public ColorUIResource getMenuDisabledForeground() {
189:                return getColor(this .COLOR_MenuDisabledForeground);
190:            }
191:
192:            @Override
193:            public ColorUIResource getTextHighlightColor() {
194:                return getColor(this .COLOR_TextHighlight);
195:            }
196:
197:            @Override
198:            public ColorUIResource getUserTextColor() {
199:                return getColor(this .COLOR_UserText);
200:            }
201:
202:            // TIDE specific
203:            public ColorUIResource get_tideEditor_commentColor() {
204:                return getColor(this .COLOR_tide_Comments);
205:            }
206:
207:            public ColorUIResource get_tideEditor_keywordColor() {
208:                return getColor(this .COLOR_tide_Keywords);
209:            }
210:
211:            public ColorUIResource get_tideEditor_textColor() {
212:                return getColor(this .COLOR_tide_Text);
213:            }
214:
215:            public ColorUIResource get_tideEditor_litteralsColor() {
216:                return getColor(this .COLOR_tide_Litterals);
217:            }
218:
219:            //return new ColorUIResource(30,30,160);   }  // blue
220:
221:            /** retrieves a color for this theme
222:             */
223:            public ColorUIResource getColor(String key) {
224:                // first look in the user props
225:                Color found = props.getColor(customName + key, null);
226:                if (found != null)
227:                    return new ColorUIResource(found);
228:
229:                // if not found, look in the defaults
230:                found = themeDefaults.getColor(customName + key, null);
231:                if (found != null)
232:                    return new ColorUIResource(found);
233:
234:                // Not found => look in the default ocean
235:                if (key.equals(COLOR_BLACK))
236:                    return super .getBlack();
237:                if (key.equals(COLOR_White))
238:                    return super .getWhite();
239:                if (key.equals(COLOR_Primary1))
240:                    return super .getPrimary1();
241:                if (key.equals(COLOR_Primary2))
242:                    return super .getPrimary2();
243:                if (key.equals(COLOR_Primary3))
244:                    return super .getPrimary3();
245:                if (key.equals(COLOR_Secondary1))
246:                    return super .getSecondary1();
247:                if (key.equals(COLOR_Secondary2))
248:                    return super .getSecondary2();
249:                if (key.equals(COLOR_Secondary3))
250:                    return super .getSecondary3();
251:
252:                if (key.equals(COLOR_ControlText))
253:                    return super .getControlTextColor();
254:                if (key.equals(COLOR_DesktopColor))
255:                    return super .getDesktopColor();
256:                if (key.equals(COLOR_InactiveControlText))
257:                    return super .getInactiveControlTextColor();
258:                if (key.equals(COLOR_MenuDisabledForeground))
259:                    return super .getMenuDisabledForeground();
260:                if (key.equals(this .COLOR_TextHighlight))
261:                    return super .getTextHighlightColor();
262:                if (key.equals(COLOR_UserText))
263:                    return super .getUserTextColor();
264:
265:                return new ColorUIResource(Color.cyan); // default
266:            }
267:
268:            /** if null, is removed
269:             */
270:            public void setDefaultColor(String key, Color c) {
271:                if (c == null) {
272:                    themeDefaults.remove(customName + key);
273:                } else {
274:                    themeDefaults.setColor(customName + key, c);
275:                }
276:            }
277:
278:            //
279:            // Fonts
280:            //
281:
282:            @Override
283:            public FontUIResource getSubTextFont() {
284:                return getFont(FONT_SubText);
285:            }
286:
287:            @Override
288:            public FontUIResource getSystemTextFont() {
289:                return getFont(FONT_System);
290:            }
291:
292:            @Override
293:            public FontUIResource getUserTextFont() {
294:                return getFont(FONT_UserText);
295:            }
296:
297:            @Override
298:            public FontUIResource getWindowTitleFont() {
299:                return getFont(FONT_WindowTitle);
300:            }
301:
302:            @Override
303:            public FontUIResource getControlTextFont() {
304:                return getFont(FONT_ControlText);
305:            }
306:
307:            @Override
308:            public FontUIResource getMenuTextFont() {
309:                return getFont(FONT_MenuText);
310:            }
311:
312:            //no
313:            //@Override
314:            public FontUIResource getFont(String key) {
315:                Font found = props.getFont(customName + key, null);
316:                if (found != null)
317:                    return new FontUIResource(found);
318:
319:                found = this .themeDefaults.getFont(customName + key, null);
320:                if (found != null)
321:                    return new FontUIResource(found);
322:
323:                // Maps defaults with parent
324:                if (key.equals(FONT_SubText))
325:                    return super .getSubTextFont();
326:                if (key.equals(FONT_System))
327:                    return super .getSystemTextFont();
328:                if (key.equals(FONT_UserText))
329:                    return super .getUserTextFont();
330:                if (key.equals(FONT_WindowTitle))
331:                    return super .getWindowTitleFont();
332:                if (key.equals(FONT_ControlText))
333:                    return super .getControlTextFont();
334:                if (key.equals(FONT_MenuText))
335:                    return super .getMenuTextFont();
336:                //if(key.equals(FONT_CodeEditor))
337:
338:                return null;
339:            }
340:
341:            public void setDefaultFont(String key, Font f) {
342:                if (f == null) {
343:                    themeDefaults.remove(customName + key);
344:                } else {
345:                    themeDefaults.setFont(customName + key, f);
346:                }
347:            }
348:
349:            //
350:            // Edition
351:            //
352:
353:            public List<String> getKeysForEdition() {
354:                List<String> keys = new Vector<String>();
355:                keys.add(COLOR_BLACK);
356:                keys.add(COLOR_White);
357:
358:                keys.add(COLOR_Green);
359:                keys.add(COLOR_Red);
360:
361:                keys.add(COLOR_Primary1);
362:                keys.add(COLOR_Primary2);
363:                keys.add(COLOR_Primary3);
364:                keys.add(COLOR_Secondary1);
365:                keys.add(COLOR_Secondary2);
366:                keys.add(COLOR_Secondary3);
367:
368:                keys.add(COLOR_ControlText);
369:                keys.add(COLOR_UserText);
370:                keys.add(COLOR_TextHighlight);
371:                keys.add(COLOR_DesktopColor);
372:                keys.add(COLOR_InactiveControlText);
373:                keys.add(COLOR_MenuDisabledForeground);
374:
375:                keys.add(FONT_SubText);
376:                keys.add(FONT_System);
377:                keys.add(FONT_UserText);
378:                keys.add(FONT_WindowTitle);
379:                keys.add(FONT_ControlText);
380:                keys.add(FONT_MenuText);
381:                keys.add(FONT_CodeEditor);
382:
383:                keys.add(this .COLOR_tide_Comments);
384:                keys.add(this .COLOR_tide_Keywords);
385:                keys.add(this .COLOR_tide_Text);
386:
387:                return keys;
388:            }
389:
390:            public Object getResource(String key) {
391:                FontUIResource f = this .getFont(key);
392:                if (f != null)
393:                    return f;
394:                ColorUIResource c = this .getColor(key);
395:                return c;
396:            }
397:
398:            /** used to set fonts of colors
399:             */
400:            public void setResource(String key, Object res) {
401:                if (res instanceof  Font) {
402:                    this .props.setFont(customName + key, (Font) res);
403:                } else if (res instanceof  Color) {
404:                    this .props.setColor(customName + key, (Color) res);
405:                }
406:
407:            }
408:
409:            public void clearUserSettings() {
410:                for (String s : getKeysForEdition()) {
411:                    props.setColor(customName + s, null);
412:                    props.setFont(customName + s, null);
413:                }
414:                writeDefaults();
415:            }
416:
417:            public static void main(String[] aaa) {
418:                ThemesManager.main(aaa);
419:            }
420:
421:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.