001: /*
002: * $Header: /cvs/j3dfly/J3dFly/src/org/jdesktop/j3dfly/plugins/StereoControlPlugin.java,v 1.1 2005/04/20 21:04:44 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:
022: /**
023: * Controls for 3D Stereo
024: *
025: * @author Paul Byrne
026: * @version $Revision: 1.1 $
027: */
028: public class StereoControlPlugin extends J3dFlyPlugin {
029:
030: private java.lang.ref.SoftReference panelReference = null;
031:
032: /** Creates new form PluginTemplate */
033: public StereoControlPlugin() {
034: super ();
035: }
036:
037: /** This method is called from within the constructor to
038: * initialize the form.
039: * WARNING: Do NOT modify this code. The content of this method is
040: * always regenerated by the Form Editor.
041: */
042: private void initComponents() {//GEN-BEGIN:initComponents
043: menuBar = new javax.swing.JMenuBar();
044: pluginMenu = new javax.swing.JMenu();
045: stereoMI = new javax.swing.JMenuItem();
046:
047: pluginMenu.setText("Menu");
048: stereoMI.setText("Stereo Controls...");
049: stereoMI.addActionListener(new java.awt.event.ActionListener() {
050: public void actionPerformed(java.awt.event.ActionEvent evt) {
051: stereoMIActionPerformed(evt);
052: }
053: });
054:
055: pluginMenu.add(stereoMI);
056: menuBar.add(pluginMenu);
057:
058: }//GEN-END:initComponents
059:
060: private void stereoMIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stereoMIActionPerformed
061: // Add your handling code here:
062: showControls();
063: }//GEN-LAST:event_stereoMIActionPerformed
064:
065: /**
066: * Get the title of the plugin
067: */
068: public String getPluginTitle() {
069: // Change this to return the name of the plugin
070: return "Stereo Controls";
071: }
072:
073: /**
074: * Returns the control panel for this plugin, or null if there
075: * is no control panel
076: */
077: public javax.swing.JPanel getControlPanel() {
078: if (panelReference == null || panelReference.get() == null)
079: panelReference = new java.lang.ref.SoftReference(
080: new StereoControlPanel(j3dflyContext));
081:
082: return (javax.swing.JPanel) panelReference.get();
083: }
084:
085: /**
086: * Install the plugin and add it's menu item to the menu
087: */
088: public void installPlugin(PluginPreference pluginPref,
089: J3dFlyContext j3dflyContext) {
090: super .installPlugin(pluginPref, j3dflyContext);
091: initComponents();
092:
093: menuBar.removeAll();
094: menuBar = null;
095: pluginMenu.removeAll();
096: pluginMenu = null;
097: menu = stereoMI;
098:
099: if (pluginPref.isInstallInMenu())
100: getMenu("Plugins").add(menu);
101: if (!j3dflyContext.getUniverse().getViewer().getCanvas3Ds()[0]
102: .getStereoAvailable())
103: menu.setEnabled(false);
104: }
105:
106: /**
107: * Uninstall this plugin
108: */
109: public void uninstallPlugin() {
110: super .uninstallPlugin();
111: if (pluginPref.isInstallInMenu())
112: getMenu("Plugins").remove(menu);
113: menu = null;
114: }
115:
116: /**
117: * Returns the class of the plugin preference.
118: *
119: * Plugins that require more preference information should provide a
120: * subclass of PluginPrefernece that contains all the extra preference
121: * data. This class must be Serializable.
122: */
123: public Class getPluginPreferenceClass() {
124: return StereoControlPluginPreference.class;
125: }
126:
127: public static class StereoControlPluginPreference extends
128: PluginPreference {
129: public StereoControlPluginPreference() {
130: super ();
131: }
132:
133: public StereoControlPluginPreference(boolean enabled,
134: boolean installed) {
135: super (enabled, installed);
136: }
137:
138: public J3dFlyPlugin instantiatePlugin() {
139: return new StereoControlPlugin();
140: }
141:
142: /**
143: * Return a description of this plugin
144: */
145: public String getDescription() {
146: return "Controls for adjusting stereo features";
147: }
148:
149: /**
150: * Return the name of the Plugin for this prefernece.
151: * This is the name that will appear in the list of plugins
152: */
153: public String getName() {
154: return "Stereo Controls";
155: }
156:
157: }
158:
159: // Variables declaration - do not modify//GEN-BEGIN:variables
160: private javax.swing.JMenuBar menuBar;
161: private javax.swing.JMenu pluginMenu;
162: private javax.swing.JMenuItem stereoMI;
163: // End of variables declaration//GEN-END:variables
164:
165: }
|