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


001:        /*
002:         *  $Header: /cvs/j3dfly/J3dEditor/src/org/jdesktop/j3dedit/scenegrapheditor/visualtools/ViewPlatformMotionMonitorVisualTool.java,v 1.1 2005/04/20 22:21:31 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.visualtools;
019:
020:        import java.util.ArrayList;
021:        import java.util.Iterator;
022:        import javax.media.j3d.TransformGroup;
023:        import javax.media.j3d.Transform3D;
024:        import javax.media.j3d.WakeupOnTransformChange;
025:        import javax.media.j3d.Behavior;
026:        import javax.media.j3d.BoundingSphere;
027:        import javax.vecmath.Vector3d;
028:        import javax.vecmath.Point3d;
029:        import javax.vecmath.Matrix3d;
030:
031:        import org.jdesktop.j3dfly.utils.vpbehaviors.ViewUtils;
032:
033:        /**
034:         * Monitor motion of the view platform and notify all listeners when
035:         * is moves.
036:         *
037:         * @author  paulby
038:         * @version 
039:         */
040:        public class ViewPlatformMotionMonitorVisualTool extends VisualTool {
041:
042:            private ArrayList listeners = null;
043:            private TransformMonitor monitor = null;
044:
045:            /** Creates new ViewPlatformMotionMonitorVisualTool */
046:            public ViewPlatformMotionMonitorVisualTool(
047:                    TransformGroup viewPlatformTG) {
048:                monitor = new TransformMonitor(viewPlatformTG);
049:                monitor.setEnable(false);
050:                this .addChild(monitor);
051:            }
052:
053:            public void addViewPlatformMotionListener(
054:                    ViewPlatformMotionListener listener) {
055:                if (listeners == null) {
056:                    listeners = new ArrayList();
057:                    listeners.add(listener);
058:                    monitor.setEnable(true);
059:                }
060:            }
061:
062:            void notifyListeners(double x, double y, double z, double roll,
063:                    double pitch, double yaw) {
064:                Iterator it = listeners.iterator();
065:                while (it.hasNext())
066:                    ((ViewPlatformMotionListener) it.next()).viewPlatformMoved(
067:                            x, y, z, roll, pitch, yaw);
068:            }
069:
070:            /**
071:             * Reset the Tool, called when user starts editing a new SceneGraph
072:             */
073:            public void reset() {
074:            }
075:
076:            /**
077:             * Listener interface for ViewPlatform motion.
078:             */
079:            public interface ViewPlatformMotionListener {
080:
081:                /**
082:                 * The new view platform position and orientation
083:                 */
084:                public void viewPlatformMoved(double x, double y, double z,
085:                        double roll, double pitch, double yaw);
086:            }
087:
088:            class TransformMonitor extends Behavior {
089:                private WakeupOnTransformChange criteria;
090:                private TransformGroup tg;
091:                private Transform3D trans = new Transform3D();
092:                private Vector3d pos = new Vector3d();
093:                private Matrix3d m3d = new Matrix3d();
094:
095:                public TransformMonitor(TransformGroup tg) {
096:                    this .tg = tg;
097:                    criteria = new WakeupOnTransformChange(tg);
098:                    this .setSchedulingBounds(new BoundingSphere(new Point3d(),
099:                            Double.POSITIVE_INFINITY));
100:                }
101:
102:                public void initialize() {
103:                    wakeupOn(criteria);
104:                }
105:
106:                public void processStimulus(java.util.Enumeration e) {
107:
108:                    tg.getTransform(trans);
109:                    trans.get(m3d, pos);
110:
111:                    Vector3d euler = new Vector3d();
112:                    ViewUtils.toEuler(m3d, euler);
113:
114:                    //System.out.println(trans);
115:
116:                    notifyListeners(pos.x, pos.y, pos.z, euler.x, euler.y,
117:                            euler.z);
118:
119:                    wakeupOn(criteria);
120:                }
121:            }
122:
123:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.