Source Code Cross Referenced for VPSplineInterpolatorPlugin.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/VPSplineInterpolatorPlugin.java,v 1.1 2005/04/20 21:04:46 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:
024:        import javax.media.j3d.BoundingSphere;
025:        import javax.vecmath.Point3d;
026:
027:        import org.jdesktop.j3dfly.utils.behaviors.KBSplineFromFileBG;
028:        import org.jdesktop.j3dfly.utils.loadercontrol.ExampleFileFilter;
029:
030:        /**
031:         * This is a Template for a J3dFly Plugin.
032:         *
033:         * To make it easy to generate comlex menu's for a plugin this code
034:         * 'tricks' Netbeans into thinking this is a GUI component and hence
035:         * allows the Netbeans GUI editor to be used to edit the menu.
036:         *
037:         * @author  Paul Byrne
038:         * @version $Revision: 1.1 $
039:         */
040:        public class VPSplineInterpolatorPlugin extends VPBehaviorPlugin {
041:
042:            private java.lang.ref.SoftReference panelReference = null;
043:            private KBSplineFromFileBG interp = null;
044:
045:            /** Creates new form PluginTemplate */
046:            public VPSplineInterpolatorPlugin() {
047:                super ();
048:                initComponents();
049:                menuBar.remove(pluginMenu);
050:                menuBar = null;
051:            }
052:
053:            /** This method is called from within the constructor to
054:             * initialize the form.
055:             * WARNING: Do NOT modify this code. The content of this method is
056:             * always regenerated by the Form Editor.
057:             */
058:            private void initComponents() {//GEN-BEGIN:initComponents
059:                menuBar = new javax.swing.JMenuBar();
060:                pluginMenu = new javax.swing.JMenu();
061:                loadMI = new javax.swing.JMenuItem();
062:
063:                pluginMenu.setText("KB Spline Properties");
064:                loadMI.setText("Load...");
065:                loadMI.setToolTipText("Load a new Spline");
066:                loadMI.addActionListener(new java.awt.event.ActionListener() {
067:                    public void actionPerformed(java.awt.event.ActionEvent evt) {
068:                        loadMIActionPerformed(evt);
069:                    }
070:                });
071:
072:                pluginMenu.add(loadMI);
073:                menuBar.add(pluginMenu);
074:
075:            }//GEN-END:initComponents
076:
077:            private void loadMIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadMIActionPerformed
078:                // Add your handling code here:
079:                javax.swing.JFileChooser fileChooser = pluginPref.getContext()
080:                        .getJ3dFly().getController().getFileChooser();
081:
082:                ExampleFileFilter j3dFilter = new ExampleFileFilter();
083:                j3dFilter.setDescription("KB Spline Definition");
084:                j3dFilter.addExtension("kbsp");
085:
086:                fileChooser.setFileFilter(j3dFilter);
087:
088:                int ret = fileChooser.showDialog(pluginPref.getContext()
089:                        .getJ3dFly().getController(), "Load KB Spline");
090:
091:                java.io.File file = null;
092:                if (ret == javax.swing.JFileChooser.APPROVE_OPTION) {
093:                    String filename = fileChooser.getSelectedFile()
094:                            .getAbsolutePath();
095:                    ((VPSplineInterpolatorPluginPreference) pluginPref)
096:                            .setSplineFilename(filename);
097:                    if (interp != null) {
098:                        try {
099:                            interp.loadFile(filename);
100:                        } catch (java.io.IOException e) {
101:                            javax.swing.JOptionPane.showMessageDialog(null,
102:                                    "Error Loading file " + filename);
103:                        }
104:                    }
105:                }
106:
107:            }//GEN-LAST:event_loadMIActionPerformed
108:
109:            /**
110:             * Returns the control panel for this plugin, or null if there
111:             * is no control panel
112:             */
113:            public javax.swing.JPanel getControlPanel() {
114:
115:                if (panelReference == null || panelReference.get() == null)
116:                    panelReference = new java.lang.ref.SoftReference(
117:                            new J3dFlyMouseBehaviorControlPanel(
118:                                    (J3dFlyMouseBehaviorPluginPreference) pluginPref));
119:
120:                return (javax.swing.JPanel) panelReference.get();
121:            }
122:
123:            public String getMenuString() {
124:                return "KB Spline";
125:            }
126:
127:            public String getTooltipText() {
128:                return "KB Spline Interpolator";
129:            }
130:
131:            /**
132:             * Install the plugin and add it's menu item to the menu
133:             */
134:            public void installPlugin(PluginPreference pluginPref,
135:                    J3dFlyContext j3dflyContext) {
136:                super .installPlugin(pluginPref, j3dflyContext);
137:                pluginPref.getContext().getEventProcessor().postEvent(
138:                        new VPBehaviorPluginEvent(this ,
139:                                VPBehaviorPluginEvent.INSTALLED));
140:
141:                if (pluginPref.isInstallInMenu()) {
142:                    javax.swing.JMenu menu = getMenu("Viewing Platform");
143:                    if (menu != null) {
144:                        menu.add(new javax.swing.JSeparator());
145:                        menu.add(pluginMenu);
146:                    }
147:                }
148:            }
149:
150:            /**
151:             * Uninstall this plugin
152:             */
153:            public void uninstallPlugin() {
154:                super .uninstallPlugin();
155:                pluginPref.getContext().getEventProcessor().postEvent(
156:                        new VPBehaviorPluginEvent(this ,
157:                                VPBehaviorPluginEvent.UNINSTALLED));
158:
159:                javax.swing.JMenu menu = getMenu("Viewing Platform");
160:                if (menu != null) {
161:                    menu.remove(pluginMenu);
162:                }
163:
164:            }
165:
166:            /**
167:             * Returns the class of the plugin preference.
168:             *
169:             * Plugins that require more preference information should provide a
170:             * subclass of PluginPrefernece that contains all the extra preference
171:             * data. This class must be Serializable.
172:             */
173:            public Class getPluginPreferenceClass() {
174:                return VPSplineInterpolatorPluginPreference.class;
175:            }
176:
177:            /**
178:             * Called to set this behavior to be active or inactive.
179:             * 
180:             * Only one VP Behavior can be active at a given time. This is managed
181:             * by J3dFlyController
182:             */
183:            public void setActive(boolean active) {
184:                super .setActive(active);
185:
186:                J3dFlyController control = pluginPref.getContext().getJ3dFly()
187:                        .getController();
188:
189:                if (active) {
190:                    if (((VPSplineInterpolatorPluginPreference) pluginPref)
191:                            .getSplineFilename() == null)
192:                        loadMIActionPerformed(null);
193:
194:                    interp = new KBSplineFromFileBG(pluginPref.getContext()
195:                            .getUniverse().getViewingPlatform()
196:                            .getViewPlatformTransform(),
197:                            ((VPSplineInterpolatorPluginPreference) pluginPref)
198:                                    .getSplineFilename());
199:                    interp.setEnabled(true);
200:                    j3dflyContext.getUniverse().getLocale().addBranchGraph(
201:                            interp);
202:
203:                    pluginPref.getContext().getUniverse().getViewingPlatform()
204:                            .setViewPlatformBehavior(null);
205:
206:                    pluginPref.getContext().getEventProcessor().postEvent(
207:                            new VPBehaviorPluginEvent(this ,
208:                                    VPBehaviorPluginEvent.ACTIVATED));
209:                } else {
210:                    interp.setEnabled(false);
211:                    j3dflyContext.getUniverse().getLocale().removeBranchGraph(
212:                            interp);
213:                    interp = null;
214:                    pluginPref.getContext().getEventProcessor().postEvent(
215:                            new VPBehaviorPluginEvent(this ,
216:                                    VPBehaviorPluginEvent.DEACTIVATED));
217:                    pluginPref.getContext().getUniverse().getViewingPlatform()
218:                            .setViewPlatformBehavior(null);
219:                }
220:            }
221:
222:            /**
223:             * Return the Icon for the toolbar button
224:             */
225:            public javax.swing.Icon getToolbarIcon() {
226:                return null;
227:            }
228:
229:            public static class VPSplineInterpolatorPluginPreference extends
230:                    J3dFlyMouseBehaviorPluginPreference {
231:
232:                /** Holds value of property splineFilename. */
233:                private String splineFilename = null;
234:
235:                public VPSplineInterpolatorPluginPreference() {
236:                    super ();
237:                }
238:
239:                public VPSplineInterpolatorPluginPreference(boolean enabled,
240:                        boolean installed) {
241:                    super (enabled, installed);
242:                }
243:
244:                public J3dFlyPlugin instantiatePlugin() {
245:                    return new VPSplineInterpolatorPlugin();
246:                }
247:
248:                /**
249:                 * Return a description of this plugin
250:                 */
251:                public String getDescription() {
252:                    return "A Spline based Viewing Platform interpolator";
253:                }
254:
255:                /**
256:                 * Return the name of the Plugin for this prefernece.
257:                 * This is the name that will appear in the list of plugins
258:                 */
259:                public String getName() {
260:                    return "VP Spline Interpolator";
261:                }
262:
263:                /** Getter for property splineFilename.
264:                 * @return Value of property splineFilename.
265:                 */
266:                public String getSplineFilename() {
267:                    return this .splineFilename;
268:                }
269:
270:                /** Setter for property splineFilename.
271:                 * @param splineFilename New value of property splineFilename.
272:                 */
273:                public void setSplineFilename(String splineFilename) {
274:                    this .splineFilename = splineFilename;
275:                }
276:
277:            }
278:
279:            // Variables declaration - do not modify//GEN-BEGIN:variables
280:            private javax.swing.JMenuBar menuBar;
281:            private javax.swing.JMenu pluginMenu;
282:            private javax.swing.JMenuItem loadMI;
283:            // End of variables declaration//GEN-END:variables
284:
285:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.