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


001:        /*
002:         *  $Header: /cvs/j3dfly/J3dEditor/src/org/jdesktop/j3dedit/scenegraph/SGObject.java,v 1.1 2005/04/20 22:20:41 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.scenegraph;
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 javax.media.j3d.SceneGraphObject;
035:        import javax.media.j3d.Locale;
036:        import org.jdesktop.j3dedit.scenegrapheditor.nodeeditors.SGObjectExtraData;
037:        import org.jdesktop.j3dedit.scenegrapheditor.CapabilityPersistance;
038:        import org.jdesktop.j3dedit.scenegrapheditor.NodePersistance;
039:        import org.jdesktop.j3dedit.scenegrapheditor.ConfigLoader;
040:        import org.jdesktop.j3dedit.J3dEditContext;
041:
042:        /**
043:         * The superclass for all the SceneGraphEditor nodes that mirror the
044:         * Java3D Scene graph objects.
045:         *
046:         * @author Paul Byrne
047:         * @version $Id: SGObject.java,v 1.1 2005/04/20 22:20:41 paulby Exp $
048:         */
049:        public abstract class SGObject {
050:
051:            /**
052:             *  Java3D Node represented by this object
053:             */
054:            protected SceneGraphObject j3dNode;
055:
056:            private String toolTipText; // Text to display when user rests mouse
057:            // over this node
058:            private String nodeName = null; // The name of the node
059:            private String sceneName = ""; // The name of the scene containing this node
060:
061:            private boolean selected = false;
062:            private boolean boundsVisible = false;
063:            private boolean readOnly = false;
064:            private SGObjectExtraData nodeExtraData = null; // Extra information for EditorPanels
065:
066:            /**
067:             * The capabilities required to exectute the scenegraph
068:             * Not including those required for the editor
069:             */
070:            protected CapabilityPersistance capabilities;
071:
072:            /**
073:             * The Editor Context for this node
074:             */
075:            protected J3dEditContext context = null;
076:
077:            /**
078:             * Status of capabilities required by editor for this node
079:             */
080:            private int editorCapabilitiesStatus = CAPABILITIES_NONE;
081:
082:            /**
083:             * Indicates that no editor capabilities have been set
084:             */
085:            public static final int CAPABILITIES_NONE = 1;
086:
087:            /**
088:             * Indicates that read only editor capabilities have been set
089:             */
090:            public static final int CAPABILITIES_READ = 2;
091:
092:            /** 
093:             * Indicates that read/write editor capabilities have been set
094:             */
095:            public static final int CAPABILITIES_READ_WRITE = 3;
096:
097:            protected TreeViewInterface treeViewObject;
098:
099:            public SGObject(org.jdesktop.j3dedit.J3dEditContext editContext) {
100:                capabilities = new CapabilityPersistance();
101:                context = editContext;
102:            }
103:
104:            /**
105:             * Get the editor context for this node
106:             */
107:            public J3dEditContext getContext() {
108:                return context;
109:            }
110:
111:            /**
112:             * The node type is the information which will be displayed as a tooltip
113:             * in the scene graph editor
114:             *
115:             * @param nodeType Type of node
116:             */
117:            public void setNodeType(String nodeType) {
118:                setNodeType(nodeType, null);
119:            }
120:
121:            /**
122:             * The node type is the information which will be displayed as a tooltip
123:             * in the scene graph editor.
124:             *
125:             * @param nodeType Type of node
126:             */
127:            public void setNodeType(String nodeType, Image image) {
128:                toolTipText = nodeType;
129:                treeViewObject.setIcon(image);
130:            }
131:
132:            /**
133:             * Return the scenegraph object represented by this node.
134:             *
135:             * @See getJ3dNode is SGNode and SGNodeComponent which return
136:             *      a more constrained type
137:             */
138:            public SceneGraphObject getJ3dSceneGraphObject() {
139:                return j3dNode;
140:            }
141:
142:            /**
143:             * Set the variable name for this node. The node name will also be
144:             * pre-pended to the tooltip.
145:             */
146:            public void setNodeName(String name) {
147:                nodeName = name;
148:                toolTipText = name + " " + toolTipText;
149:                treeViewObject.setNodeName(name);
150:            }
151:
152:            /**
153:             * Returns the variable name for this node
154:             */
155:            public String getNodeName() {
156:                return nodeName;
157:            }
158:
159:            /**
160:             * Set the name of the scene that contains this node
161:             */
162:            public void setSceneName(String name) {
163:                sceneName = name;
164:            }
165:
166:            /**
167:             * Return the name of the scene that contains this node
168:             */
169:            public String getSceneName() {
170:                return sceneName;
171:            }
172:
173:            public String getToolTipText() {
174:                return toolTipText;
175:            }
176:
177:            public void setReadOnly(boolean readOnly) {
178:                this .readOnly = readOnly;
179:            }
180:
181:            public boolean getReadOnly() {
182:                return readOnly;
183:            }
184:
185:            /**
186:             * Repaint the tree representation of this node
187:             *
188:             * This should be called whenever data is changed that is
189:             * displayed.
190:             */
191:            public void repaint() {
192:                treeViewObject.repaint();
193:            }
194:
195:            /**
196:             * Add the capability name to the list of capabilities required
197:             * for this node.
198:             */
199:            public void setCapability(String name) {
200:                if (j3dNode == null)
201:                    throw new RuntimeException("Java3D Node is null");
202:
203:                capabilities.addCapability(j3dNode, name);
204:            }
205:
206:            /**
207:             * Remove the capability name from the list of capabilities required
208:             * for this node
209:             */
210:            public void clearCapability(String name) {
211:                if (j3dNode == null)
212:                    throw new RuntimeException("Java3D Node is null");
213:
214:                capabilities.removeCapability(j3dNode, name);
215:            }
216:
217:            /**
218:             * Restore the capabilities of the node
219:             */
220:            public void restoreCapabilities() {
221:                if (j3dNode == null)
222:                    throw new RuntimeException("Node is null");
223:
224:                capabilities.restoreCapabilities(j3dNode);
225:            }
226:
227:            /**
228:             * Store the capabilities of this node
229:             */
230:            public void storeCapabilities() {
231:                if (j3dNode == null)
232:                    throw new RuntimeException("Node is null");
233:
234:                capabilities.storeCapabilities(j3dNode);
235:            }
236:
237:            /**
238:             * Return an array of Strings representing the capabilities of
239:             * this node
240:             */
241:            public String[] getCapabilitiesAsStrings() {
242:                return capabilities.getCapabilitiesAsStrings(j3dNode);
243:            }
244:
245:            /**
246:             * TODO Change method name to setSelected
247:             */
248:            public void setSelected(boolean selected) {
249:                this .selected = selected;
250:                treeViewObject.setHighlight(selected);
251:            }
252:
253:            /**
254:             * Return the selection state of this object
255:             */
256:            public boolean isSelected() {
257:                return selected;
258:            }
259:
260:            public TreeViewInterface getTreeViewObject() {
261:                return treeViewObject;
262:            }
263:
264:            public void setTreeViewObject(TreeViewInterface tvObject) {
265:                treeViewObject = tvObject;
266:            }
267:
268:            public void setBoundsVisible(boolean boundsVisible) {
269:                this .boundsVisible = boundsVisible;
270:            }
271:
272:            public boolean getBoundsVisible() {
273:                return boundsVisible;
274:            }
275:
276:            /**
277:             * Get EditorPanel information
278:             */
279:            public SGObjectExtraData getSGObjectExtraData() {
280:                return nodeExtraData;
281:            }
282:
283:            /**
284:             * Store EditorPanel information
285:             */
286:            public void setSGObjectExtraData(SGObjectExtraData state) {
287:                nodeExtraData = state;
288:            }
289:
290:            /**
291:             * Create the correct node persistance object for this node
292:             */
293:            public NodePersistance createPersistanceObject() {
294:                return new NodePersistance();
295:            }
296:
297:            /**
298:             * Set the persitant information in the data object provided
299:             */
300:            public void createPersistanceData(NodePersistance data) {
301:                if (boundsVisible)
302:                    data.setData("BoundsVis", "T");
303:
304:                if (nodeExtraData != null)
305:                    nodeExtraData.writePersistanceData(data);
306:            }
307:
308:            /**
309:             * Set the internal state of this node to represent the data
310:             * passed
311:             */
312:            public void applyPersistanceData(NodePersistance data) {
313:
314:                String str;
315:
316:                str = data.getData("BoundsVis");
317:                if (str != null && str.equals("T"))
318:                    boundsVisible = true;
319:
320:                nodeExtraData = context.getConfigLoader().getEditorManager()
321:                        .createSGObjectExtraData(j3dNode, data);
322:
323:            }
324:
325:            /**
326:             * Set the status of the capabilities in respect to the editor. This call does
327:             * not actually change any capabilities, it's just an indicator of the current
328:             * state.
329:             *
330:             * @param status must be one of CAPABILITIES_NONE, CAPABILITIES_READ, CAPABILITIES_READ_WRITE
331:             */
332:            public void setEditorCapabilitiesStatus(int status) {
333:                editorCapabilitiesStatus = status;
334:            }
335:
336:            /**
337:             * Return the status of the capabilties
338:             */
339:            public int getEditorCapabilitiesStatus() {
340:                return editorCapabilitiesStatus;
341:            }
342:
343:            /**
344:             * Return the Locale to which this node is connected.
345:             *
346:             * It the current implementation NodeComponents cannot be shared
347:             * between Locales
348:             */
349:            public abstract javax.media.j3d.Locale getLocale();
350:
351:            /**
352:             * Change the live state of this node, this may change the live
353:             * state of other nodes in the graph, but in general the minimum
354:             * change will be made
355:             */
356:            public abstract void setLive(boolean live);
357:
358:            /**
359:             * Is this node live
360:             */
361:            public abstract boolean isLive();
362:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.