Source Code Cross Referenced for SGBehavior.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/SGBehavior.java,v 1.1 2005/04/20 22:20:39 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.lang.reflect.*;
021:
022:        import javax.media.j3d.Behavior;
023:        import javax.media.j3d.Node;
024:        import javax.media.j3d.TransformGroup;
025:
026:        import org.jdesktop.j3dedit.scenegrapheditor.PropertiesDialog;
027:        import org.jdesktop.j3dedit.scenegrapheditor.WindowManager;
028:
029:        /**
030:         * @author Paul Byrne
031:         * @version $id$
032:         */
033:        public class SGBehavior extends SGLeaf {
034:
035:            private SGObject actionNode; // Node on which this behavior acts
036:
037:            /** Creates new BehaviorTreeNode */
038:            public SGBehavior(javax.media.j3d.Node node,
039:                    org.jdesktop.j3dedit.J3dEditContext editContext) {
040:                super (node, editContext);
041:                actionNode = null;
042:            }
043:
044:            /**
045:             * Set the node on which this behavior acts
046:             * If this is set then a line is drawn between the behavior and
047:             * node on which it acts.
048:             */
049:            public void setActionNode(SGObject actionNode) {
050:                this .actionNode = actionNode;
051:            }
052:
053:            /**
054:             * Return the node this behavior acts on
055:             */
056:            public SGObject getActionNode() {
057:                return actionNode;
058:            }
059:
060:            /**
061:             * Return true if node is a valid target for this behavior
062:             */
063:            public boolean isValidTarget(SGObject node) {
064:
065:                Behavior behavior = (Behavior) getJ3dNode();
066:                if (behavior instanceof  javax.media.j3d.PathInterpolator
067:                        || behavior instanceof  javax.media.j3d.PositionInterpolator
068:                        || behavior instanceof  javax.media.j3d.PositionPathInterpolator
069:                        || behavior instanceof  javax.media.j3d.RotationInterpolator
070:                        || behavior instanceof  javax.media.j3d.ScaleInterpolator
071:                        || behavior instanceof  com.sun.j3d.utils.behaviors.mouse.MouseRotate
072:                        || behavior instanceof  com.sun.j3d.utils.behaviors.mouse.MouseTranslate
073:                        || behavior instanceof  com.sun.j3d.utils.behaviors.mouse.MouseZoom
074:                        || behavior instanceof  com.sun.j3d.utils.behaviors.interpolators.KBRotPosScaleSplinePathInterpolator
075:                        || behavior instanceof  com.sun.j3d.utils.behaviors.interpolators.TCBSplinePathInterpolator)
076:                    if (node.getJ3dSceneGraphObject() instanceof  javax.media.j3d.TransformGroup)
077:                        return true;
078:
079:                return false;
080:            }
081:
082:            /**
083:             * Set the target of this behavior to be node, updates both the view
084:             * (using setActionNode) and the scene graph.
085:             */
086:            public void setTarget(SGObject node) {
087:                setActionNode(node);
088:
089:                // Update scenegraph
090:
091:                // Call setTarget method in the Interpolator
092:                Node target = (Node) node.getJ3dSceneGraphObject();
093:                if (target == null)
094:                    target = new javax.media.j3d.TransformGroup();
095:                Behavior behavior = (Behavior) getJ3dNode();
096:                Method setTarget;
097:                try {
098:                    if (behavior instanceof  com.sun.j3d.utils.behaviors.mouse.MouseRotate
099:                            || behavior instanceof  com.sun.j3d.utils.behaviors.mouse.MouseZoom
100:                            || behavior instanceof  com.sun.j3d.utils.behaviors.mouse.MouseTranslate)
101:                        setTarget = behavior
102:                                .getClass()
103:                                .getMethod(
104:                                        "setTransformGroup",
105:                                        new Class[] { javax.media.j3d.TransformGroup.class });
106:                    else
107:                        setTarget = behavior
108:                                .getClass()
109:                                .getMethod(
110:                                        "setTarget",
111:                                        new Class[] { javax.media.j3d.TransformGroup.class });
112:
113:                    if (PropertiesDialog.performanceLevel != PropertiesDialog.READ_WRITE_ALLOWED) {
114:                        context.getLocale().setLive(false);
115:                        target
116:                                .setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
117:                        target
118:                                .setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
119:                    }
120:
121:                    node.setCapability("ALLOW_TRANSFORM_READ");
122:                    node.setCapability("ALLOW_TRANSFORM_WRITE");
123:
124:                    setTarget.invoke(behavior, new Object[] { target });
125:
126:                    if (PropertiesDialog.performanceLevel != PropertiesDialog.READ_WRITE_ALLOWED)
127:                        context.getLocale().setLive(true);
128:
129:                } catch (Exception e) {
130:                    e.printStackTrace();
131:                }
132:            }
133:
134:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.