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


001:        /*
002:         *  $Header: /cvs/j3dfly/J3dFly/src/org/jdesktop/j3dfly/utils/vpbehaviors/J3dFlyMouseBehavior.java,v 1.1 2005/04/20 21:05:13 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 Java 3D(tm) Fly Through.
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.j3dfly.utils.vpbehaviors;
019:
020:        import java.awt.Component;
021:        import java.awt.Cursor;
022:        import java.awt.event.MouseEvent;
023:        import javax.media.j3d.Transform3D;
024:        import javax.media.j3d.Canvas3D;
025:        import javax.vecmath.Point3d;
026:
027:        /**
028:         *
029:         * @author  paulby
030:         * @version 
031:         */
032:        public abstract class J3dFlyMouseBehavior extends VPCollisionBehavior {
033:
034:            protected java.awt.Rectangle canvasBounds;
035:            protected java.awt.geom.Point2D.Float canvasCenter;
036:
037:            protected Transform3D targetTransform;
038:
039:            protected float MAX_ANGLE = (float) Math.toRadians(3);
040:            protected float MAX_VELOCITY = 10f;
041:
042:            protected boolean ignoreMouseMotion = false;
043:            protected float deadXSize;
044:            protected float deadYSize;
045:            protected FlyControlDialog flyControlDialog = null;
046:            protected boolean doingDrag = false;
047:
048:            //protected Transform3D currentImagePlateToCoexistance;
049:
050:            /**
051:             * Flag indicating that the View has been initialized
052:             */
053:            //protected boolean viewInitialized = false;
054:            /** Creates new J3dFlyMouseBehavior 
055:             * @deprecated use J3dFlyMouseBehavior()
056:             */
057:            public J3dFlyMouseBehavior(Canvas3D c) {
058:                this ();
059:            }
060:
061:            public J3dFlyMouseBehavior() {
062:                super ();
063:                canvasCenter = new java.awt.geom.Point2D.Float();
064:                targetTransform = new Transform3D();
065:            }
066:
067:            /*
068:            public void processStimulus( java.util.Enumeration enum ) {
069:                if (!viewInitialized) {
070:                    canvasBounds = getCoexistanceBounds( vp.getViewers()[0] );
071:                    viewInitialized = true;
072:                    canvasCenter.x = canvasBounds.width/2;
073:                    canvasCenter.y = canvasBounds.height/2;
074:                    deadXSize = 15.0 / canvasCenter.x;
075:                    deadYSize = 15.0 / canvasCenter.y;  
076:                }
077:                super.processStimulus( enum );
078:            }
079:             */
080:
081:            protected void queueAWTEvent(java.awt.AWTEvent evt) {
082:                super .queueAWTEvent(evt);
083:            }
084:
085:            /**
086:             * Process any events the subclass did not handle
087:             */
088:            protected void processUnusedEvent(java.awt.AWTEvent evt) {
089:                if (evt instanceof  MouseEvent) {
090:                    if (((MouseEvent) evt).getID() == MouseEvent.MOUSE_ENTERED)
091:                        processMouseEntered((MouseEvent) evt);
092:                    else if (((MouseEvent) evt).getID() == MouseEvent.MOUSE_EXITED)
093:                        processMouseExited((MouseEvent) evt);
094:                }
095:            }
096:
097:            protected void processMouseEntered(java.awt.event.MouseEvent evt) {
098:                Component component = evt.getComponent();
099:                if (component instanceof  javax.media.j3d.Canvas3D) {
100:                    canvasBounds = component.getBounds();
101:                    canvasCenter.x = canvasBounds.width / 2;
102:                    canvasCenter.y = canvasBounds.height / 2;
103:                    deadXSize = 15f / canvasCenter.x;
104:                    deadYSize = 15f / canvasCenter.y;
105:                    if (!ignoreMouseMotion) {
106:                        component.setCursor(Cursor
107:                                .getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
108:                    }
109:                }
110:                /*
111:                System.out.println(evt);
112:                Component component = evt.getComponent();
113:                if (component instanceof javax.media.j3d.Canvas3D) {
114:                    currentImagePlateToCoexistance = getImagePlateToCoexistance( (Canvas3D)component, vp.getViewers()[0] );
115:                    if (!ignoreMouseMotion) {
116:                        component.setCursor( Cursor.getPredefinedCursor( Cursor.CROSSHAIR_CURSOR ));
117:                    }
118:
119:                }
120:                 */
121:            }
122:
123:            public void processMouseExited(java.awt.event.MouseEvent evt) {
124:                Component component = evt.getComponent();
125:                if (component instanceof  javax.media.j3d.Canvas3D) {
126:                    component.setCursor(Cursor.getDefaultCursor());
127:                }
128:            }
129:
130:            /**
131:             * Compute the Bounds of Coexistance for all canvases in the view
132:             */
133:            /*
134:            private java.awt.geom.Rectangle2D.Double getCoexistanceBounds( com.sun.j3d.utils.universe.Viewer viewer ) {
135:                java.awt.geom.Rectangle2D.Double rect = 
136:                        new java.awt.geom.Rectangle2D.Double( Double.POSITIVE_INFINITY, 
137:                                                              Double.POSITIVE_INFINITY, 
138:                                                              Double.NEGATIVE_INFINITY,
139:                                                              Double.NEGATIVE_INFINITY );
140:                javax.vecmath.Point3d p3d = new javax.vecmath.Point3d();
141:
142:                Canvas3D[] canvases = viewer.getCanvas3Ds();
143:                
144:                for(int i=0; i<canvases.length; i++) {
145:                    System.out.println( canvases[i] );
146:                    Transform3D trans = getImagePlateToCoexistance( canvases[i], viewer );
147:
148:                    canvases[i].getPixelLocationInImagePlate( 0, 0, p3d );
149:                    trans.transform( p3d );
150:                    rect.x = Math.min( rect.x, p3d.x );
151:                    rect.y = Math.min( rect.y, p3d.y );
152:                    
153:                    canvases[i].getPixelLocationInImagePlate( canvases[i].getWidth(),
154:                                                              canvases[i].getHeight(), p3d );
155:                    
156:                    
157:                    trans.transform( p3d );            
158:                    rect.width = Math.max( rect.width, p3d.x );
159:                    rect.height = Math.max( rect.height, p3d.y );
160:                }
161:                
162:                return rect;
163:            }
164:            
165:            private Transform3D getImagePlateToCoexistance( Canvas3D canvas, com.sun.j3d.utils.universe.Viewer viewer ) {
166:                Transform3D imagePlateToTrackerBase = new Transform3D();
167:                canvas.getScreen3D().getTrackerBaseToImagePlate( imagePlateToTrackerBase );
168:                imagePlateToTrackerBase.invert();
169:                
170:                Transform3D trackerBaseToCoexistance = new Transform3D();
171:                
172:                viewer.getPhysicalEnvironment().getCoexistenceToTrackerBase( trackerBaseToCoexistance );
173:                trackerBaseToCoexistance.invert();
174:                
175:                
176:                imagePlateToTrackerBase.mul( trackerBaseToCoexistance );
177:                
178:                return imagePlateToTrackerBase;
179:            }
180:             */
181:
182:            /*
183:            protected void getPixelInCoexistance( Canvas3D canvas, int pixelX, int pixelY, Point3d result ) {
184:                canvas.getPixelLocationInImagePlate( pixelX, pixelY, result );
185:                currentImagePlateToCoexistance.transform( result );
186:            }
187:             */
188:
189:            /**
190:             * Called when the user wants to change the parameters of the
191:             * behavior.
192:             * 
193:             * This method may be called from the AWT event thread
194:             */
195:            public void editParameters(java.awt.Frame parent) {
196:                if (flyControlDialog == null) {
197:                    flyControlDialog = new FlyControlDialog(parent, true);
198:                }
199:
200:                flyControlDialog.setStep(MAX_VELOCITY);
201:                flyControlDialog.setAngle((float) Math.toDegrees(MAX_ANGLE));
202:                flyControlDialog.setVisible(true);
203:
204:                if (!flyControlDialog.userCancelled()) {
205:                    MAX_ANGLE = (float) Math.toRadians(flyControlDialog
206:                            .getAngle());
207:                    MAX_VELOCITY = flyControlDialog.getStep();
208:                }
209:            }
210:
211:            /**
212:             * Set the maximum angle moved per frame
213:             *
214:             * @param angle The angle in radians
215:             */
216:            public void setAngleStep(float angle) {
217:                MAX_ANGLE = angle;
218:            }
219:
220:            /**
221:             * Set the largest forward step per frame
222:             */
223:            public void setForwardStep(float forward) {
224:                MAX_VELOCITY = forward;
225:            }
226:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.