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


001:        /*
002:         *  $Header: /cvs/j3dfly/J3dFly/src/org/jdesktop/j3dfly/plugins/VPFlyBehaviorPlugin.java,v 1.1 2005/04/20 21:04:45 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.plugins;
019:
020:        import org.jdesktop.j3dfly.J3dFlyContext;
021:        import org.jdesktop.j3dfly.J3dFlyController;
022:        import org.jdesktop.j3dfly.event.VPBehaviorPluginEvent;
023:        import org.jdesktop.j3dfly.utils.vpbehaviors.VPDefaultCollision;
024:        import org.jdesktop.j3dfly.utils.vpbehaviors.VPDriveCollision;
025:
026:        import javax.media.j3d.BoundingSphere;
027:        import javax.vecmath.Point3d;
028:
029:        import org.jdesktop.j3dfly.utils.vpbehaviors.FlyBehavior;
030:
031:        /**
032:         * This is a Template for a J3dFly Plugin.
033:         *
034:         * To make it easy to generate comlex menu's for a plugin this code
035:         * 'tricks' Netbeans into thinking this is a GUI component and hence
036:         * allows the Netbeans GUI editor to be used to edit the menu.
037:         *
038:         * @author  Paul Byrne
039:         * @version $Revision: 1.1 $
040:         */
041:        public class VPFlyBehaviorPlugin extends VPBehaviorPlugin {
042:
043:            private java.lang.ref.SoftReference panelReference = null;
044:
045:            /** Creates new form PluginTemplate */
046:            public VPFlyBehaviorPlugin() {
047:                super ();
048:            }
049:
050:            /** This method is called from within the constructor to
051:             * initialize the form.
052:             * WARNING: Do NOT modify this code. The content of this method is
053:             * always regenerated by the Form Editor.
054:             */
055:            private void initComponents() {//GEN-BEGIN:initComponents
056:                menuBar = new javax.swing.JMenuBar();
057:                pluginMenu = new javax.swing.JMenu();
058:
059:                pluginMenu.setText("Menu");
060:                menuBar.add(pluginMenu);
061:
062:            }//GEN-END:initComponents
063:
064:            /**
065:             * Returns the control panel for this plugin, or null if there
066:             * is no control panel
067:             */
068:            public javax.swing.JPanel getControlPanel() {
069:
070:                if (panelReference == null || panelReference.get() == null)
071:                    panelReference = new java.lang.ref.SoftReference(
072:                            new J3dFlyMouseBehaviorControlPanel(
073:                                    (J3dFlyMouseBehaviorPluginPreference) pluginPref));
074:
075:                return (javax.swing.JPanel) panelReference.get();
076:            }
077:
078:            public String getMenuString() {
079:                return "Fly";
080:            }
081:
082:            public String getTooltipText() {
083:                return "Fly Behavior";
084:            }
085:
086:            /**
087:             * Install the plugin and add it's menu item to the menu
088:             */
089:            public void installPlugin(PluginPreference pluginPref,
090:                    J3dFlyContext j3dflyContext) {
091:                super .installPlugin(pluginPref, j3dflyContext);
092:                pluginPref.getContext().getEventProcessor().postEvent(
093:                        new VPBehaviorPluginEvent(this ,
094:                                VPBehaviorPluginEvent.INSTALLED));
095:            }
096:
097:            /**
098:             * Uninstall this plugin
099:             */
100:            public void uninstallPlugin() {
101:                super .uninstallPlugin();
102:                pluginPref.getContext().getEventProcessor().postEvent(
103:                        new VPBehaviorPluginEvent(this ,
104:                                VPBehaviorPluginEvent.UNINSTALLED));
105:            }
106:
107:            /**
108:             * Returns the class of the plugin preference.
109:             *
110:             * Plugins that require more preference information should provide a
111:             * subclass of PluginPrefernece that contains all the extra preference
112:             * data. This class must be Serializable.
113:             */
114:            public Class getPluginPreferenceClass() {
115:                return VPFlyBehaviorPluginPreference.class;
116:            }
117:
118:            /**
119:             * Called to set this behavior to be active or inactive.
120:             * 
121:             * Only one VP Behavior can be active at a given time. This is managed
122:             * by J3dFlyController
123:             */
124:            public void setActive(boolean active) {
125:                super .setActive(active);
126:
127:                J3dFlyController control = pluginPref.getContext().getJ3dFly()
128:                        .getController();
129:
130:                if (active) {
131:                    FlyBehavior fly = new FlyBehavior(pluginPref.getContext()
132:                            .getUniverse().getViewer().getView());
133:                    pluginPref.getContext().getUniverse().getViewingPlatform()
134:                            .setViewPlatformBehavior(fly);
135:                    fly.setSchedulingBounds(new BoundingSphere(new Point3d(),
136:                            Double.POSITIVE_INFINITY));
137:                    ((J3dFlyMouseBehaviorPluginPreference) pluginPref).behavior = fly;
138:
139:                    fly
140:                            .setAngleStep(((J3dFlyMouseBehaviorPluginPreference) pluginPref)
141:                                    .getAngleStep());
142:                    fly
143:                            .setForwardStep(((J3dFlyMouseBehaviorPluginPreference) pluginPref)
144:                                    .getForwardStep());
145:                    if (control.getCollisionController() != null) {
146:                        if (!(control.getCollisionController() instanceof  VPDefaultCollision))
147:                            control
148:                                    .changeCollisionController(new VPDefaultCollision());
149:                        fly.setCollisionControl(control
150:                                .getCollisionController());
151:                    }
152:
153:                    pluginPref.getContext().getEventProcessor().postEvent(
154:                            new VPBehaviorPluginEvent(this ,
155:                                    VPBehaviorPluginEvent.ACTIVATED));
156:                } else {
157:                    pluginPref.getContext().getEventProcessor().postEvent(
158:                            new VPBehaviorPluginEvent(this ,
159:                                    VPBehaviorPluginEvent.DEACTIVATED));
160:                    pluginPref.getContext().getUniverse().getViewingPlatform()
161:                            .setViewPlatformBehavior(null);
162:                    ((J3dFlyMouseBehaviorPluginPreference) pluginPref).behavior = null;
163:                }
164:            }
165:
166:            /**
167:             * Return the Icon for the toolbar button
168:             */
169:            public javax.swing.Icon getToolbarIcon() {
170:                return new javax.swing.ImageIcon(getClass().getResource(
171:                        "/org/jdesktop/j3dfly/icons/flyIcon.gif"));
172:            }
173:
174:            public static class VPFlyBehaviorPluginPreference extends
175:                    J3dFlyMouseBehaviorPluginPreference {
176:                public VPFlyBehaviorPluginPreference() {
177:                    super ();
178:                }
179:
180:                public VPFlyBehaviorPluginPreference(boolean enabled,
181:                        boolean installed) {
182:                    super (enabled, installed);
183:                }
184:
185:                public J3dFlyPlugin instantiatePlugin() {
186:                    return new VPFlyBehaviorPlugin();
187:                }
188:
189:                /**
190:                 * Return a description of this plugin
191:                 */
192:                public String getDescription() {
193:                    return "A Viewing Platform Fly behavior";
194:                }
195:
196:                /**
197:                 * Return the name of the Plugin for this prefernece.
198:                 * This is the name that will appear in the list of plugins
199:                 */
200:                public String getName() {
201:                    return "VP Fly Behavior";
202:                }
203:
204:            }
205:
206:            // Variables declaration - do not modify//GEN-BEGIN:variables
207:            private javax.swing.JMenuBar menuBar;
208:            private javax.swing.JMenu pluginMenu;
209:            // End of variables declaration//GEN-END:variables
210:
211:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.