Source Code Cross Referenced for HTMLTreeUI.java in  » Swing-Library » Swinglets » com » javelin » swinglets » plaf » html » 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 » Swinglets » com.javelin.swinglets.plaf.html 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright Javelin Software, All rights reserved.
003:         */
004:
005:        package com.javelin.swinglets.plaf.html;
006:
007:        import java.awt.*;
008:        import java.util.*;
009:        import java.io.*;
010:
011:        import javax.swing.tree.*;
012:
013:        import com.javelin.swinglets.*;
014:        import com.javelin.swinglets.tree.*;
015:        import com.javelin.swinglets.plaf.*;
016:        import com.javelin.swinglets.theme.*;
017:
018:        /**
019:         * HTMLTreeUI defines a look and feel for default HTML. 
020:         * 
021:         * @author Robin Sharp
022:         */
023:
024:        public class HTMLTreeUI extends HTMLComponentUI {
025:            /**
026:             * Render the UI on the PrintWriter
027:             */
028:            public void update(PrintWriter out, SComponent c) {
029:                if (!c.isVisible())
030:                    return;
031:
032:                STree tree = (STree) c;
033:
034:                if (tree.getModel() == null)
035:                    return;
036:
037:                TreePath path = new TreePath(tree.getModel().getRoot());
038:                row = 0;
039:
040:                treeCellRenderer = tree.getTreeCellRenderer(getLookAndFeel()
041:                        .getClass().getName());
042:
043:                //Write the table
044:                out.print("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0");
045:
046:                Object cssClass = c.getClientProperty(CSS_CLASS);
047:                if (cssClass != null) {
048:                    out.print(" class=\"");
049:                    out.print(cssClass);
050:                }
051:
052:                if (tree.getBackgroundIcon() != null) {
053:                    out.print(" BACKGROUND=\"");
054:                    out.print(tree.getBackgroundIcon().getUrl());
055:                    out.print("\"");
056:                } else if (!tree.isOpaque()) {
057:                    //Dont do anything
058:                } else if (tree.getBackground() != null) {
059:                    out.print(" BGCOLOR=\"#");
060:                    out.print(SColor.toHexString(tree.getBackground()));
061:                    out.print("\"");
062:                } else {
063:                    out.print(" BGCOLOR=\"#");
064:                    out.print(SColor.toHexString(getTheme()
065:                            .getWindowBackground()));
066:                    out.print("\"");
067:                }
068:
069:                out.println(" >");
070:
071:                /*
072:                //WRITE THE FORM INSIDE THE TABLE
073:                out.println();
074:                out.print( "<FORM" );
075:                out.print( " METHOD=\"GET\" " );
076:                HTMLUtility.setName( out, tree );
077:                out.println( ">" );
078:
079:                //WRITE OUT THE FRAME AND COMPONENT AS HIDDEN FIELDS
080:                HTMLUtility.setFrameName( out, tree );
081:                HTMLUtility.setComponentName( out, tree );
082:                 */
083:                update(out, tree, path);
084:
085:                //out.println( "</FORM>" );
086:                out.println("</TABLE>");
087:            }
088:
089:            /**
090:             * Depth first update of all expanded nodes and their descendents.
091:             */
092:            public void update(PrintWriter out, STree tree, TreePath path) {
093:                boolean expanded = tree.isExpanded(path);
094:
095:                //System.out.println( "VALUE=" + path.getLastPathComponent() + ",expanded=" + expanded + ",row=" + row );
096:
097:                if (tree.getModel().getRoot() == path.getLastPathComponent()) {
098:                    //May be display the root
099:                    if (tree.isRootVisible()) {
100:                        updateNode(out, tree, path, expanded);
101:                    }
102:                } else {
103:                    //else display the node
104:                    updateNode(out, tree, path, expanded);
105:                }
106:
107:                if (row > tree.getRowCount())
108:                    return;
109:                ;
110:
111:                //Display all the children
112:                if (expanded) {
113:                    depth++;
114:                    TreeNode node = (TreeNode) path.getLastPathComponent();
115:                    for (int index = 0; index < node.getChildCount(); index++) {
116:                        //Recursively display the children
117:                        update(out, tree, path.pathByAddingChild(node
118:                                .getChildAt(index)));
119:                    }
120:                    depth--;
121:                }
122:            }
123:
124:            /**
125:             * Render a node in HTML as a TABLE;
126:             */
127:            public void updateNode(PrintWriter out, STree tree, TreePath path,
128:                    boolean expanded) {
129:                TreeNode node = (TreeNode) path.getLastPathComponent();
130:                out.println("<TR><TD>");
131:
132:                for (int index = 0; index < depth; index++) {
133:                    out.print(HTMLCharacterUI
134:                            .getSpecialCharacter(SCharacter.SPACE));
135:                    out.print(HTMLCharacterUI
136:                            .getSpecialCharacter(SCharacter.SPACE));
137:                    out.print(HTMLCharacterUI
138:                            .getSpecialCharacter(SCharacter.SPACE));
139:                    out.print(HTMLCharacterUI
140:                            .getSpecialCharacter(SCharacter.SPACE));
141:                    out.print(HTMLCharacterUI
142:                            .getSpecialCharacter(SCharacter.SPACE));
143:                }
144:
145:                if (treeCellRenderer != null) {
146:                    SComponent component = treeCellRenderer
147:                            .getTreeCellRendererComponent(tree, node, expanded,
148:                                    node.isLeaf(), row, tree
149:                                            .isPathSelected(path));
150:
151:                    if (component != null) {
152:                        //Change the look and feel to that of the tree.
153:                        component.setLookAndFeel(tree.getLookAndFeel());
154:
155:                        if (component.getFont() == null) {
156:                            if (tree.getFont() != null) {
157:                                component.setFont(tree.getFont());
158:                            } else {
159:                                component.setFont(getTheme()
160:                                        .getSystemTextFont());
161:                            }
162:                        }
163:
164:                        component.paint(out);
165:                    }
166:                } else {
167:                    out.println(node.toString());
168:                }
169:
170:                out.println("</TD></TR>");
171:
172:                row++;
173:
174:            }
175:
176:            // PRIVATE //////////////////////////////////////////////////////////////////////////
177:
178:            protected int row;
179:            protected int depth;
180:
181:            private STreeCellRenderer treeCellRenderer;
182:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.