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


001:        /*
002:         *  $Header: /cvs/j3dfly/J3dEditor/src/org/jdesktop/j3dedit/scenegrapheditor/NodeEditControl.java,v 1.1 2005/04/20 22:20:47 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;
019:
020:        import javax.media.j3d.Node;
021:        import javax.media.j3d.Group;
022:        import org.jdesktop.j3dedit.scenegrapheditor.nodeeditors.EditorManager;
023:        import org.jdesktop.j3dedit.scenegraph.SGObject;
024:        import org.jdesktop.j3dedit.scenegraph.SGGroup;
025:        import org.jdesktop.j3dedit.scenegraph.SGBehavior;
026:        import org.jdesktop.j3dedit.scenegraph.SGNode;
027:        import org.jdesktop.j3dedit.scenegraph.SGLeaf;
028:        import org.jdesktop.j3dfly.utils.developmenttools.DevelopmentLocale;
029:
030:        /**
031:         *
032:         * @author Paul Byrne
033:         * @version	$Id: NodeEditControl.java,v 1.1 2005/04/20 22:20:47 paulby Exp $
034:         *
035:         * Handles all aspects of selecting a node and editing it's parameters
036:         */
037:        public class NodeEditControl extends Object {
038:
039:            private SGNode currentNode = null; // Node currently selected
040:            private SGNode pasteBuffer = null;
041:            private boolean readOnly = false;
042:            private EditorManager editorManager;
043:
044:            /** Creates new NodeEditControl */
045:            public NodeEditControl(boolean readOnly, EditorManager editorManager) {
046:                this .readOnly = readOnly;
047:                this .editorManager = editorManager;
048:            }
049:
050:            /**
051:             * Select node
052:             * Deselect Previous selected node
053:             * If the user was editing the previous node apply any changes
054:             */
055:            public void selectNode(SGObject node) {
056:                if (currentNode != null) {
057:                    currentNode.setSelected(false);
058:                    if (editorManager.editInProgress()) {
059:                        editorManager.editComplete();
060:                    }
061:                }
062:
063:                currentNode = (SGNode) node;
064:
065:                if (currentNode != null) {
066:                    currentNode.setSelected(true);
067:                } else
068:                    editorManager.clearEditorPanel();
069:            }
070:
071:            /**
072:             * Check if the currently selected node is a group
073:             * or a subclass of group
074:             */
075:            public boolean isCurrentNodeGroup() {
076:                if (currentNode != null && (currentNode instanceof  SGGroup))
077:                    return true;
078:                else
079:                    return false;
080:            }
081:
082:            /**
083:             * Check if the currently selected node is a behavior or
084:             * one of it subclasses
085:             */
086:            public boolean isCurrentNodeBehavior() {
087:                if (currentNode != null && (currentNode instanceof  SGBehavior))
088:                    return true;
089:                else
090:                    return false;
091:            }
092:
093:            /**
094:             * Check if the current node is read only
095:             */
096:            public boolean isCurrentNodeReadOnly() {
097:                if (currentNode != null)
098:                    return currentNode.getReadOnly();
099:                else
100:                    return false;
101:            }
102:
103:            public SGNode getCurrentNode() {
104:                return currentNode;
105:            }
106:
107:            /**
108:             * Start editing the currently selected node
109:             *
110:             * Does nothing if currentNode is null
111:             */
112:            public void editCurrentNode() {
113:                if (currentNode == null)
114:                    return;
115:                editorManager.editNode(currentNode);
116:            }
117:
118:            /**
119:             * Start viewing the current node. Node Editor will display in
120:             * readOnly mode
121:             */
122:            public void viewCurrentNode() {
123:                if (currentNode == null)
124:                    return;
125:
126:                throw new RuntimeException("Not Implemented");
127:            }
128:
129:            /**
130:             * Traverse the graph and remove all the names from namecontrol
131:             */
132:            private void removeNodesFromNameControl(SGNode node) {
133:                currentNode.getContext().getNameControl().removeObject(
134:                        node.getSceneName(), node.getNodeName(),
135:                        node.getJ3dNode());
136:
137:                if (node instanceof  SGGroup) {
138:                    for (int i = 0; i < ((SGGroup) node).numChildren(); i++)
139:                        removeNodesFromNameControl(((SGGroup) node).getChild(i));
140:                }
141:            }
142:
143:            public void deleteCurrentNode() {
144:                editorManager.clearEditorPanel();
145:                DevelopmentLocale locale = currentNode.getContext().getLocale();
146:                boolean wasLive = locale.getLive();
147:
148:                if (wasLive)
149:                    locale.setLive(false);
150:
151:                removeNodesFromNameControl(currentNode);
152:
153:                detachNode(currentNode.getJ3dNode());
154:                currentNode.getParent().removeChild(currentNode);
155:                currentNode.setSelected(false);
156:                currentNode = null;
157:
158:                if (wasLive)
159:                    locale.setLive(true);
160:            }
161:
162:            public boolean isPasteBufferNull() {
163:                return (pasteBuffer == null);
164:            }
165:
166:            public void cutCurrentNode() {
167:                pasteBuffer = currentNode;
168:                deleteCurrentNode();
169:            }
170:
171:            public void copyCurrentNode() {
172:                boolean wasLive = currentNode.isLive();
173:
174:                if (wasLive)
175:                    currentNode.setLive(false);
176:
177:                // TODO deal with duplicating names when this is pasted
178:
179:                try {
180:                    pasteBuffer = (SGNode) currentNode.getContext()
181:                            .getSceneGraphControl().cloneTree(currentNode);
182:                } catch (Exception e) {
183:                    WindowManager.getManager().showMessage("Internal Error",
184:                            "Can't copy node");
185:                    return;
186:                }
187:
188:                if (wasLive)
189:                    currentNode.setLive(true);
190:            }
191:
192:            public void pasteNode() {
193:                if (pasteBuffer == null)
194:                    return;
195:
196:                boolean wasLive = currentNode.isLive();
197:
198:                // TODO deal with duplicating names when this is pasted
199:
200:                if (wasLive)
201:                    currentNode.setLive(false);
202:
203:                ((Group) currentNode.getJ3dNode()).addChild(pasteBuffer
204:                        .getJ3dNode());
205:                ((SGGroup) currentNode).addChild(pasteBuffer);
206:
207:                // Make a new copy of the paste buffer incase the object is pasted
208:                // again.
209:                try {
210:                    pasteBuffer = (SGNode) pasteBuffer.getContext()
211:                            .getSceneGraphControl().cloneTree(pasteBuffer);
212:                } catch (Exception e) {
213:                    WindowManager.getManager().showMessage("Internal Error",
214:                            "Can't copy node");
215:                    return;
216:                }
217:
218:                if (wasLive)
219:                    currentNode.setLive(true);
220:            }
221:
222:            /**
223:             * Detach this Java3D from it's parent
224:             */
225:            private void detachNode(Node node) {
226:                Group parent = (Group) node.getParent();
227:                Node next;
228:
229:                if (parent == null)
230:                    return;
231:
232:                parent.removeChild(node);
233:                /*
234:                java.util.Enumeration e = parent.getAllChildren();
235:                int i=0;
236:                while(e.hasMoreElements() && i>=0 ) {
237:                  next = (Node)e.nextElement();
238:                  if (next == node) {
239:                    parent.removeChild( i );
240:                    i=-1;   // Finished
241:                  }
242:                  i++;
243:                }
244:                 */
245:            }
246:
247:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.