Source Code Cross Referenced for PMDLookAndFeel.java in  » UML » jrefactory » org » acm » seguin » pmd » swingui » 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 » UML » jrefactory » org.acm.seguin.pmd.swingui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.acm.seguin.pmd.swingui;
002:
003:        import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
004:
005:        import javax.swing.ImageIcon;
006:        import javax.swing.LookAndFeel;
007:        import javax.swing.UIDefaults;
008:        import java.awt.Color;
009:        import java.awt.Font;
010:        import java.io.BufferedInputStream;
011:        import java.io.ByteArrayOutputStream;
012:        import java.io.IOException;
013:        import java.io.InputStream;
014:        import java.util.Properties;
015:
016:        /**
017:         *
018:         * @author Donald A. Leckie
019:         * @since August 27, 2002
020:         * @version $Revision: 1.4 $, $Date: 2003/09/21 20:51:41 $
021:         */
022:        public class PMDLookAndFeel extends WindowsLookAndFeel {
023:
024:            /**
025:             ****************************************************************************
026:             *
027:             * @return
028:             */
029:            public String getDescription() {
030:                return "Source Forge PMD look and feel";
031:            }
032:
033:            /**
034:             ****************************************************************************
035:             *
036:             * @return
037:             */
038:            public String getID() {
039:                return "SourceForgePMD";
040:            }
041:
042:            /**
043:             ****************************************************************************
044:             *
045:             * @return
046:             */
047:            public String getName() {
048:                return "SourceForgePMD";
049:            }
050:
051:            /**
052:             ****************************************************************************
053:             *
054:             * @return
055:             */
056:            public boolean isNativeLookAndFeel() {
057:                return false;
058:            }
059:
060:            /**
061:             ****************************************************************************
062:             *
063:             * @return
064:             */
065:            public boolean isSupportedLookAndFeel() {
066:                return true;
067:            }
068:
069:            /**
070:             ****************************************************************************
071:             *
072:             * @param table
073:             */
074:            protected void initClassDefaults(UIDefaults table) {
075:                super .initClassDefaults(table);
076:            }
077:
078:            /**
079:             ****************************************************************************
080:             *
081:             * @param table
082:             */
083:            protected void initSystemColorDefaults(UIDefaults table) {
084:                super .initSystemColorDefaults(table);
085:
086:                Color darkBlue = Color.blue.darker();
087:
088:                String[] defaultSystemColors = { "pmdBlue",
089:                        String.valueOf(darkBlue.getRGB()), "pmdRed",
090:                        String.valueOf(Color.red.getRGB()), "pmdGreen",
091:                        "#336666", "pmdGray", "#F0F0F0", "pmdTreeBackground",
092:                        "#F0F0F0", "pmdTableBackground", "#F0F0F0",
093:                        "pmdMessageAreaBackground", "#F0F0F0",
094:                        "pmdStatusAreaBackground", "#F0F0F0", "mediumGray",
095:                        "#686868", "mediumDarkGray", "#434343", "paleGray",
096:                        "#AAAAAA", "standardButtonBackground", "#686868",
097:                        "standardButtonForeground", "#FFFFFF",
098:                        "pmdTableHeaderBackground", "#686868",
099:                        "pmdTableHeaderForeground", "#FFFFFF",
100:                        "pmdEditingPanelBackground",
101:                        String.valueOf(Color.lightGray.getRGB()),
102:                        "disabledTextBackground", "#AAAAAA", };
103:
104:                loadSystemColors(table, defaultSystemColors,
105:                        isNativeLookAndFeel());
106:            }
107:
108:            /**
109:             ****************************************************************************
110:             *
111:             * @param table
112:             */
113:            protected void initComponentDefaults(UIDefaults table) {
114:                super .initComponentDefaults(table);
115:
116:                Class wlafClass = WindowsLookAndFeel.class;
117:                Class plafClass = PMDLookAndFeel.class;
118:                Object[] defaults = {
119:                        "document",
120:                        LookAndFeel.makeIcon(plafClass, "icons/Document.gif"),
121:                        "cancel",
122:                        LookAndFeel.makeIcon(plafClass, "icons/cancel.gif"),
123:                        "save",
124:                        LookAndFeel.makeIcon(plafClass, "icons/Save.gif"),
125:                        "saveAs",
126:                        LookAndFeel.makeIcon(plafClass, "icons/SaveAs.gif"),
127:                        "print",
128:                        LookAndFeel.makeIcon(plafClass, "icons/Print.gif"),
129:                        "copy",
130:                        LookAndFeel.makeIcon(plafClass, "icons/Copy.gif"),
131:                        "edit",
132:                        LookAndFeel.makeIcon(plafClass, "icons/edit.gif"),
133:                        "view",
134:                        LookAndFeel.makeIcon(plafClass, "icons/View.gif"),
135:                        "help",
136:                        LookAndFeel.makeIcon(plafClass, "icons/help.gif"),
137:                        "pmdLogo",
138:                        LookAndFeel.makeIcon(plafClass, "icons/pmdLogo.gif"),
139:                        "pmdLogoImage",
140:                        getImageIcon("icons/pmdLogo.jpg"),
141:                        "labelFont",
142:                        new Font("Dialog", Font.BOLD, 12),
143:                        "label14Font",
144:                        new Font("Dialog", Font.BOLD, 14),
145:                        "label16Font",
146:                        new Font("Dialog", Font.BOLD, 16),
147:                        "dataFont",
148:                        new Font("Dialog", Font.PLAIN, 12),
149:                        "codeFont",
150:                        new Font("Monospaced", Font.PLAIN, 12),
151:                        "tabFont",
152:                        new Font("SansSerif", Font.BOLD, 12),
153:                        "titleFont",
154:                        new Font("SansSerif", Font.BOLD, 14),
155:                        "buttonFont",
156:                        new Font("SansSerif", Font.BOLD, 12),
157:                        "messageFont",
158:                        new Font("Dialog", Font.PLAIN, 12),
159:                        "serif12Font",
160:                        new Font("Serif", Font.PLAIN, 12),
161:                        "serif14Font",
162:                        new Font("Serif", Font.PLAIN, 14),
163:                        "viewerProperties",
164:                        loadViewerProperties(),
165:
166:                        // These are all the icons defined in the WindowsLookAndFeel.  We redefine them
167:                        // here because of the way they are defined in that class: in terms of the return
168:                        // value of getClass().  I.e., getClass() just returns the handle to the invoking
169:                        // class, which now is PMDLookAndFeel.  That means that the icons are searched
170:                        // for in the PMD look and feel package, which is not where they really are.
171:                        // Since we've just called the superclass method, the icons have been installed
172:                        // incorrectly in the table.  Reinstall them using the correct class.
173:
174:                        "Tree.openIcon",
175:                        LookAndFeel.makeIcon(wlafClass, "icons/TreeOpen.gif"),
176:                        "Tree.closedIcon",
177:                        LookAndFeel.makeIcon(wlafClass, "icons/TreeClosed.gif"),
178:                        "Tree.leafIcon",
179:                        LookAndFeel.makeIcon(wlafClass, "icons/TreeLeaf.gif"),
180:
181:                        "FileChooser.newFolderIcon",
182:                        LookAndFeel.makeIcon(wlafClass, "icons/NewFolder.gif"),
183:                        "FileChooser.upFolderIcon",
184:                        LookAndFeel.makeIcon(wlafClass, "icons/UpFolder.gif"),
185:                        "FileChooser.homeFolderIcon",
186:                        LookAndFeel.makeIcon(wlafClass, "icons/HomeFolder.gif"),
187:                        "FileChooser.detailsViewIcon",
188:                        LookAndFeel
189:                                .makeIcon(wlafClass, "icons/DetailsView.gif"),
190:                        "FileChooser.listViewIcon",
191:                        LookAndFeel.makeIcon(wlafClass, "icons/ListView.gif"),
192:
193:                        "FileView.directoryIcon",
194:                        LookAndFeel.makeIcon(wlafClass, "icons/Directory.gif"),
195:                        "FileView.fileIcon",
196:                        LookAndFeel.makeIcon(wlafClass, "icons/File.gif"),
197:                        "FileView.computerIcon",
198:                        LookAndFeel.makeIcon(wlafClass, "icons/Computer.gif"),
199:                        "FileView.hardDriveIcon",
200:                        LookAndFeel.makeIcon(wlafClass, "icons/HardDrive.gif"),
201:                        "FileView.floppyDriveIcon",
202:                        LookAndFeel
203:                                .makeIcon(wlafClass, "icons/FloppyDrive.gif"), };
204:
205:                table.putDefaults(defaults);
206:            }
207:
208:            /**
209:             ****************************************************************************
210:             *
211:             * @return
212:             */
213:            private Properties loadViewerProperties() {
214:                Properties properties = new Properties();
215:
216:                try {
217:                    InputStream inputStream = getClass().getResourceAsStream(
218:                            "pmdViewer.properties");
219:
220:                    if (inputStream != null) {
221:                        properties.load(inputStream);
222:                    }
223:                } catch (IOException exception) {
224:                    exception.printStackTrace();
225:                }
226:
227:                return properties;
228:            }
229:
230:            /**
231:             *******************************************************************************
232:             *
233:             * @param fileName
234:             *
235:             * @return
236:             */
237:            protected static final ImageIcon getImageIcon(String fileName) {
238:                final byte[][] buffer = new byte[1][];
239:
240:                try {
241:                    InputStream resource = PMDLookAndFeel.class
242:                            .getResourceAsStream(fileName);
243:
244:                    if (resource == null) {
245:                        return null;
246:                    }
247:
248:                    BufferedInputStream in;
249:                    ByteArrayOutputStream out;
250:                    int n;
251:
252:                    in = new BufferedInputStream(resource);
253:                    out = new ByteArrayOutputStream(1024);
254:                    buffer[0] = new byte[1024];
255:
256:                    while ((n = in.read(buffer[0])) >= 0) {
257:                        out.write(buffer[0], 0, n);
258:                    }
259:
260:                    in.close();
261:                    out.flush();
262:                    buffer[0] = out.toByteArray();
263:                } catch (IOException ioe) {
264:                    return null;
265:                }
266:
267:                if (buffer[0] == null) {
268:                    return null;
269:                }
270:
271:                if (buffer[0].length == 0) {
272:                    return null;
273:                }
274:
275:                return new ImageIcon(buffer[0]);
276:            }
277:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.