Source Code Cross Referenced for FileComponentsTreeCellRenderer.java in  » IDE » Schmortopf » Schmortopf » FileComponents » View » 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 » Schmortopf » Schmortopf.FileComponents.View 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package Schmortopf.FileComponents.View;
002:
003:        import javax.swing.*;
004:        import javax.swing.tree.*;
005:        import java.awt.*;
006:
007:        import Schmortopf.FileComponents.Model.*;
008:        import Language.Language;
009:
010:        import Schmortopf.Utility.themes.*; // These themes must be used.
011:
012:        public class FileComponentsTreeCellRenderer extends
013:                DefaultTreeCellRenderer {
014:
015:            // Keys for specific icons :
016:
017:            public static final byte UseTokenLeafIcon = (byte) 0; // leafs from JavaCC parser
018:            public static final byte UseImportLeafIcon = (byte) 1;
019:            public static final byte UseExtendsLeafIcon = (byte) 2;
020:            public static final byte UseImplementsLeafIcon = (byte) 3;
021:            public static final byte UseFieldLeafIcon = (byte) 4;
022:            public static final byte UseConstructorLeafIcon = (byte) 5;
023:            public static final byte UseMethodLeafIcon = (byte) 6;
024:            public static final byte UseInitializerLeafIcon = (byte) 7;
025:            public static final byte UseClassLeafIcon = (byte) 8;
026:            public static final byte UseInterfaceLeafIcon = (byte) 9;
027:            public static final byte UseSuperClassLeafIcon = (byte) 10;
028:            public static final byte UseParserLeafIcon = (byte) 11;
029:
030:            public static final byte UseClassNodeIcon = (byte) 100;
031:            public static final byte UseInterfaceNodeIcon = (byte) 101;
032:            public static final byte UsePackageNodeIcon = (byte) 102;
033:            public static final byte UseImportNodeIcon = (byte) 103;
034:
035:            public static final byte UsePublicNodeIcon = (byte) 104;
036:            public static final byte UsePrivateNodeIcon = (byte) 105;
037:            public static final byte UseProtectedNodeIcon = (byte) 106;
038:            public static final byte UsePackageScopeNodeIcon = (byte) 107;
039:
040:            private final Icon classLeafIcon;
041:            private final Icon interfaceLeafIcon;
042:            private final Icon tokenLeafIcon;
043:            private final Icon importLeafIcon;
044:            private final Icon extendsLeafIcon;
045:            private final Icon constructorLeafIcon;
046:            private final Icon methodLeafIcon;
047:            private final Icon initializerLeafIcon;
048:            private final Icon fieldLeafIcon;
049:            private final Icon implements LeafIcon;
050:            private final Icon super ClassLeafIcon;
051:            private final Icon parserLeafIcon;
052:
053:            private final Icon packageNodeIcon;
054:            private final Icon importNodeIcon;
055:            private final Icon classNodeIcon;
056:            private final Icon interfaceNodeIcon;
057:            private final Icon publicNodeIcon;
058:            private final Icon privateNodeIcon;
059:            private final Icon protectedNodeIcon;
060:            private final Icon packageScopeNodeIcon;
061:
062:            private final Icon defaultNodeIcon;
063:
064:            private final Icon rootNodeIcon;
065:
066:            public FileComponentsTreeCellRenderer() {
067:                super ();
068:                classLeafIcon = new SelfDrawingIcon("C",
069:                        SelfDrawingIcon.ColorBlack);
070:                interfaceLeafIcon = new SelfDrawingIcon("I",
071:                        SelfDrawingIcon.ColorBlue);
072:                tokenLeafIcon = new SelfDrawingIcon("T",
073:                        SelfDrawingIcon.ColorBlack);
074:                importLeafIcon = new SelfDrawingIcon("I",
075:                        SelfDrawingIcon.ColorBlue);
076:                extendsLeafIcon = new SelfDrawingIcon("E",
077:                        SelfDrawingIcon.ColorBlue);
078:                constructorLeafIcon = new SelfDrawingIcon("C",
079:                        SelfDrawingIcon.ColorRed);
080:                methodLeafIcon = new SelfDrawingIcon("M",
081:                        SelfDrawingIcon.ColorGreen);
082:                initializerLeafIcon = new SelfDrawingIcon("In",
083:                        SelfDrawingIcon.ColorGreen);
084:                fieldLeafIcon = new SelfDrawingIcon("A",
085:                        SelfDrawingIcon.ColorBlue);
086:                implements LeafIcon = new SelfDrawingIcon(Language
087:                        .Translate("implements"), SelfDrawingIcon.ColorBlue);
088:                super ClassLeafIcon = new SelfDrawingIcon(Language
089:                        .Translate("extends"), SelfDrawingIcon.ColorBlue);
090:                parserLeafIcon = new SelfDrawingIcon(Language
091:                        .Translate("Parser"), SelfDrawingIcon.ColorBlue);
092:
093:                packageNodeIcon = new SelfDrawingIcon(Language
094:                        .Translate("Package"), SelfDrawingIcon.ColorBlue);
095:                importNodeIcon = new SelfDrawingIcon(Language
096:                        .Translate("Import"), SelfDrawingIcon.ColorBlue);
097:                classNodeIcon = new SelfDrawingIcon(
098:                        Language.Translate("Class"), SelfDrawingIcon.ColorRed);
099:                interfaceNodeIcon = new SelfDrawingIcon(Language
100:                        .Translate("Interface"), SelfDrawingIcon.ColorBlue);
101:                publicNodeIcon = new SelfDrawingIcon(Language
102:                        .Translate("Public"), SelfDrawingIcon.ColorGreen);
103:                privateNodeIcon = new SelfDrawingIcon(Language
104:                        .Translate("Private"), SelfDrawingIcon.ColorRed);
105:                protectedNodeIcon = new SelfDrawingIcon(Language
106:                        .Translate("Protected"), SelfDrawingIcon.ColorRed);
107:                packageScopeNodeIcon = new SelfDrawingIcon(Language
108:                        .Translate("Package Scope"), SelfDrawingIcon.ColorRed);
109:                defaultNodeIcon = new SelfDrawingIcon(" ",
110:                        SelfDrawingIcon.ColorBlue);
111:                rootNodeIcon = new SelfDrawingIcon(Language
112:                        .Translate("Components"), SelfDrawingIcon.ColorBlue);
113:            }
114:
115:            /**
116:             * Configures the renderer based on the passed in components.
117:             * The value is set from messaging the tree with
118:             * <code>convertValueToText</code>, which ultimately invokes
119:             * <code>toString</code> on <code>value</code>.
120:             * The foreground color is set based on the selection and the icon
121:             * is set based on on leaf and expanded.
122:             */
123:            public Component getTreeCellRendererComponent(JTree tree,
124:                    Object value, boolean sel, boolean expanded, boolean leaf,
125:                    int row, boolean hasFocus) {
126:                final String stringValue = tree.convertValueToText(value, sel,
127:                        expanded, leaf, row, hasFocus);
128:                this .hasFocus = hasFocus;
129:                setText(stringValue);
130:                this .selected = sel;
131:                if (this .selected)
132:                    setForeground(getTextSelectionColor());
133:                else
134:                    setForeground(getTextNonSelectionColor());
135:
136:                Icon leafIcon = getLeafIcon();
137:                Icon nodeOpenIcon = defaultNodeIcon;
138:                Icon nodeClosedIcon = defaultNodeIcon;
139:                // Some FileComponentsTreeUserObject's have specific node or leaf icons :
140:                if (value instanceof  DefaultMutableTreeNode) {
141:                    DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
142:                    if (node.getUserObject() instanceof  TokenTreeUserObject) {
143:                        TokenTreeUserObject userValue = (TokenTreeUserObject) node
144:                                .getUserObject();
145:
146:                        // check types :
147:                        final int iconType = userValue.getIconType();
148:                        switch (iconType) {
149:                        // leafs :
150:                        case UseTokenLeafIcon:
151:                            leafIcon = tokenLeafIcon;
152:                            break;
153:                        case UseImportLeafIcon:
154:                            leafIcon = importLeafIcon;
155:                            break;
156:                        case UseExtendsLeafIcon:
157:                            leafIcon = extendsLeafIcon;
158:                            break;
159:                        case UseImplementsLeafIcon:
160:                            leafIcon = implements LeafIcon;
161:                            break;
162:                        case UseFieldLeafIcon:
163:                            leafIcon = fieldLeafIcon;
164:                            break;
165:                        case UseConstructorLeafIcon:
166:                            leafIcon = constructorLeafIcon;
167:                            break;
168:                        case UseMethodLeafIcon:
169:                            leafIcon = methodLeafIcon;
170:                            break;
171:                        case UseInitializerLeafIcon:
172:                            leafIcon = initializerLeafIcon;
173:                            break;
174:                        case UseClassLeafIcon:
175:                            leafIcon = classLeafIcon;
176:                            break;
177:                        case UseInterfaceLeafIcon:
178:                            leafIcon = interfaceLeafIcon;
179:                            break;
180:                        case UseSuperClassLeafIcon:
181:                            leafIcon = super ClassLeafIcon;
182:                            break;
183:                        case UseParserLeafIcon:
184:                            leafIcon = parserLeafIcon;
185:                            break;
186:                        // nodes :
187:                        case UsePackageNodeIcon:
188:                            nodeOpenIcon = packageNodeIcon;
189:                            nodeClosedIcon = packageNodeIcon;
190:                            break;
191:                        case UseImportNodeIcon:
192:                            nodeOpenIcon = importNodeIcon;
193:                            nodeClosedIcon = importNodeIcon;
194:                            break;
195:                        case UseClassNodeIcon:
196:                            nodeOpenIcon = classNodeIcon;
197:                            nodeClosedIcon = classNodeIcon;
198:                            break;
199:                        case UseInterfaceNodeIcon:
200:                            nodeOpenIcon = interfaceNodeIcon;
201:                            nodeClosedIcon = interfaceNodeIcon;
202:                            break;
203:                        case UsePublicNodeIcon:
204:                            nodeOpenIcon = publicNodeIcon;
205:                            nodeClosedIcon = publicNodeIcon;
206:                            break;
207:                        case UsePrivateNodeIcon:
208:                            nodeOpenIcon = privateNodeIcon;
209:                            nodeClosedIcon = privateNodeIcon;
210:                            break;
211:                        case UseProtectedNodeIcon:
212:                            nodeOpenIcon = protectedNodeIcon;
213:                            nodeClosedIcon = protectedNodeIcon;
214:                            break;
215:                        case UsePackageScopeNodeIcon:
216:                            nodeOpenIcon = packageScopeNodeIcon;
217:                            nodeClosedIcon = packageScopeNodeIcon;
218:                            break;
219:                        }
220:                        // else use defaultUI icon(s)
221:                    } else {
222:                        // else it's the root node :
223:                        nodeOpenIcon = rootNodeIcon;
224:                        nodeClosedIcon = rootNodeIcon;
225:                    }
226:                }
227:
228:                // There needs to be a way to specify disabled icons.
229:                if (!tree.isEnabled()) {
230:                    setEnabled(false);
231:                    if (leaf) {
232:                        setDisabledIcon(leafIcon);
233:                    } else if (expanded) {
234:                        setDisabledIcon(nodeOpenIcon);
235:                    } else {
236:                        setDisabledIcon(nodeClosedIcon);
237:                    }
238:                } else {
239:                    setEnabled(true);
240:                    if (leaf) {
241:                        setIcon(leafIcon);
242:                    } else if (expanded) {
243:                        setIcon(nodeOpenIcon);
244:                    } else {
245:                        setIcon(nodeClosedIcon);
246:                    }
247:                }
248:                setComponentOrientation(tree.getComponentOrientation());
249:                // Set the selected state of the current icon :
250:                final Icon currentIcon = this .getIcon();
251:                if (currentIcon instanceof  SelfDrawingIcon) {
252:                    final SelfDrawingIcon selfDrawingIcon = (SelfDrawingIcon) currentIcon;
253:                    selfDrawingIcon.setSelected(this .selected);
254:                    selfDrawingIcon.setSelectionColor(this 
255:                            .getBackgroundSelectionColor());
256:                }
257:                return this ;
258:            } // getTreeCellRendererComponent
259:
260:            public void updateSpecialUI() {
261:                setLeafIcon(UIManager.getIcon("Tree.leafIcon"));
262:                setClosedIcon(UIManager.getIcon("Tree.closedIcon"));
263:                setOpenIcon(UIManager.getIcon("Tree.openIcon"));
264:                setTextSelectionColor(UIManager
265:                        .getColor("Tree.selectionForeground"));
266:                setTextNonSelectionColor(UIManager
267:                        .getColor("Tree.textForeground"));
268:                setBackgroundSelectionColor(UIManager
269:                        .getColor("Tree.selectionBackground"));
270:                setBackgroundNonSelectionColor(UIManager
271:                        .getColor("Tree.textBackground"));
272:                setBorderSelectionColor(UIManager
273:                        .getColor("Tree.selectionBorderColor"));
274:            }
275:
276:        } // FileComponentsTreeCellRenderer
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.