Source Code Cross Referenced for TVObject.java in  » 6.0-JDK-Modules » java-3d » org » jdesktop » j3dedit » scenegrapheditor » treeview » 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 » 6.0 JDK Modules » java 3d » org.jdesktop.j3dedit.scenegrapheditor.treeview 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  $Header: /cvs/j3dfly/J3dEditor/src/org/jdesktop/j3dedit/scenegrapheditor/treeview/TVObject.java,v 1.1 2005/04/20 22:21:29 paulby Exp $
003:         *
004:         *                         Sun Public License Notice
005:         *
006:         *  The contents of this file are subject to the Sun Public License Version
007:         *  1.0 (the "License"). You may not use this file except in compliance with
008:         *  the License. A copy of the License is available at http://www.sun.com/
009:         *  
010:         *  The Original Code is the Java 3D(tm) Scene Graph Editor.
011:         *  The Initial Developer of the Original Code is Paul Byrne.
012:         *  Portions created by Paul Byrne are Copyright (C) 2002.
013:         *  All Rights Reserved.
014:         *  
015:         *  Contributor(s): Paul Byrne.
016:         *  
017:         **/
018:        package org.jdesktop.j3dedit.scenegrapheditor.treeview;
019:
020:        import java.awt.Graphics;
021:        import java.awt.Graphics2D;
022:        import java.awt.Color;
023:        import java.awt.Point;
024:        import java.awt.Dimension;
025:        import java.awt.Image;
026:        import java.awt.font.GlyphVector;
027:        import java.awt.Font;
028:        import java.awt.font.FontRenderContext;
029:        import java.awt.geom.AffineTransform;
030:        import java.util.HashMap;
031:        import java.util.Properties;
032:        import java.util.Vector;
033:        import org.jdesktop.j3dedit.treelayout.DefaultTreeNode;
034:        import org.jdesktop.j3dedit.treelayout.TreeNode;
035:        import org.jdesktop.j3dedit.scenegraph.SGObject;
036:        import org.jdesktop.j3dedit.scenegraph.SGNode;
037:
038:        /**
039:         * @author Paul Byrne
040:         * @version	1.5, 01/18/02
041:         */
042:        public abstract class TVObject extends DefaultTreeNode implements 
043:                org.jdesktop.j3dedit.scenegraph.TreeViewInterface {
044:
045:            protected boolean drawAsIcon = true;
046:            protected java.awt.Image icon = null;
047:
048:            protected Color currentColor; // Temporary Storage for color
049:            protected GlyphVector nameLabel = null;
050:            protected Dimension nameLabelBounds = null;
051:            protected SGObject sgObject;
052:
053:            public TVObject(int width, int height, int spacing,
054:                    SGObject sgObject) {
055:                super (width, height, spacing);
056:                this .sgObject = sgObject;
057:            }
058:
059:            public void computeLinkPoints(Point pos) {
060:                linkExitPoint.x = pos.x + nodeSize.width / 2;
061:                linkExitPoint.y = pos.y + nodeSize.height / 2;
062:
063:                linkEntryPoint.x = pos.x + nodeSize.width / 2;
064:                linkEntryPoint.y = pos.y + nodeSize.height / 2;
065:            }
066:
067:            /**
068:             * Set the variable name for this node
069:             */
070:            public void setNodeName(String name) {
071:                createNameLabel(name);
072:            }
073:
074:            public void setIcon(Image image) {
075:                icon = image;
076:            }
077:
078:            public org.jdesktop.j3dedit.treelayout.TreeNode getChild(int index) {
079:                return null;
080:            }
081:
082:            public int numChildren() {
083:                return 0;
084:            }
085:
086:            public TreeNode getParent() {
087:                if (sgObject instanceof  SGNode) {
088:                    SGNode parent = ((SGNode) sgObject).getParent();
089:                    if (parent == null)
090:                        return null;
091:                    else
092:                        return (TreeNode) parent.getTreeViewObject();
093:                } else
094:                    return null;
095:            }
096:
097:            /**
098:             * Return the editor sgObject that this node represents
099:             */
100:            public SGObject getSGObject() {
101:                return sgObject;
102:            }
103:
104:            /**
105:             * Return the point where the behavior link should connect to this node.
106:             * behaviorLocation is provided to allow the routine to determine the
107:             * most appropriate point relative to the behavior nodes location
108:             */
109:            protected abstract Point getBehaviorLinkEntry(Point behaviorLocation);
110:
111:            /**
112:             * Highlight this node
113:             */
114:            public void setHighlight(boolean highlight) {
115:                container.repaint();
116:            }
117:
118:            private void drawHighlight(Graphics2D g) {
119:
120:                g.setColor(Color.red);
121:                g.setXORMode(g.getBackground());
122:                Point computedPosition = getComputedPosition();
123:                Dimension nodeSize = getNodeSize();
124:
125:                g.drawRect(computedPosition.x - 3, computedPosition.y - 3,
126:                        nodeSize.width + 8, nodeSize.height + 8);
127:
128:                g.setPaintMode();
129:                g.setColor(Color.black);
130:            }
131:
132:            public void paint(Graphics g) {
133:
134:                // Draw the links of this node, recurse to all children
135:                // and then draw this node.
136:                // This ordering will ensure this node is drawn last and
137:                // therefore ontop of the link lines.
138:
139:                if (numChildren() > 0) {
140:
141:                    if (getLink() != null)
142:                        getLink().paint(g);
143:                    else
144:                        System.out.println("Null Link Error " + numChildren()
145:                                + " " + sgObject);
146:
147:                    // TODO Links should not be null, the city demo was
148:                    // causing this error
149:
150:                    /*
151:                    // Draw the subtreeSize for debugging
152:                    java.awt.Rectangle subtreeSize = getSubtreeSize();
153:                    g.setColor( Color.red );
154:                    g.drawRect( subtreeSize.x, subtreeSize.y,
155:                                subtreeSize.width, subtreeSize.height );
156:                    g.setColor( Color.black );
157:                     */
158:                }
159:
160:                for (int i = 0; i < numChildren(); i++)
161:                    getChild(i).paint(g);
162:
163:                drawNode((Graphics2D) g);
164:            }
165:
166:            public void drawNode(Graphics2D g) {
167:                // Draw the highlight for this node
168:                if (sgObject.isSelected())
169:                    drawHighlight(g);
170:            }
171:
172:            /**
173:             * Create a label of the nodeName
174:             */
175:            protected void createNameLabel(String nodeName) {
176:                if (nodeName == null) {
177:                    nameLabel = null;
178:                    return;
179:                }
180:
181:                Font font = new Font("dialog", Font.PLAIN, 10);
182:                FontRenderContext context = new FontRenderContext(
183:                        new AffineTransform(), false, false);
184:                char[] chars = new char[nodeName.length()];
185:                nodeName.getChars(0, chars.length, chars, 0);
186:                nameLabel = font.createGlyphVector(context, chars);
187:
188:                nameLabelBounds = new Dimension((int) nameLabel
189:                        .getVisualBounds().getWidth(), (int) font
190:                        .getMaxCharBounds(context).getHeight());
191:            }
192:
193:            /**
194:             * Draw the name label for this node
195:             */
196:            protected void drawNameLabel(Graphics2D g) {
197:                if (nameLabel == null)
198:                    return;
199:
200:                g.setColor(Color.white);
201:                g.fillRect(computedPosition.x - 2, computedPosition.y
202:                        - nameLabelBounds.height + 3,
203:                        nameLabelBounds.width + 4, nameLabelBounds.height);
204:                g.setColor(Color.black);
205:                g.drawGlyphVector(nameLabel, (float) (computedPosition.x),
206:                        (float) (computedPosition.y));
207:            }
208:
209:            /**
210:             * Repaint this node
211:             */
212:            public void repaint() {
213:                // TODO just repaint the area of the canvas that contains
214:                // this node
215:                container.repaint();
216:            }
217:
218:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.