001: /*
002: * $Header: /cvs/j3dfly/J3dFly/src/org/jdesktop/j3dfly/plugins/StatisticsPlugin.java,v 1.1 2005/04/20 21:04:43 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.utils.gui.StatsDialog;
022: import org.jdesktop.j3dfly.utils.developmenttools.DevelopmentLocale;
023:
024: /**
025: * @author Paul Byrne
026: * @version $Revision: 1.1 $
027: */
028: public class StatisticsPlugin extends J3dFlyPlugin {
029:
030: private java.lang.ref.SoftReference panelReference = null;
031: private StatsDialog statsDialog = null;
032:
033: /** Creates new form PluginTemplate */
034: public StatisticsPlugin() {
035: super ();
036: }
037:
038: /** This method is called from within the constructor to
039: * initialize the form.
040: * WARNING: Do NOT modify this code. The content of this method is
041: * always regenerated by the Form Editor.
042: */
043: private void initComponents() {//GEN-BEGIN:initComponents
044: menuBar = new javax.swing.JMenuBar();
045: pluginMenu = new javax.swing.JMenu();
046: statisticsMI = new javax.swing.JMenuItem();
047:
048: pluginMenu.setText("Menu");
049: statisticsMI.setText("Statistics");
050: statisticsMI
051: .addActionListener(new java.awt.event.ActionListener() {
052: public void actionPerformed(
053: java.awt.event.ActionEvent evt) {
054: statisticsMIActionPerformed(evt);
055: }
056: });
057:
058: pluginMenu.add(statisticsMI);
059: menuBar.add(pluginMenu);
060:
061: }//GEN-END:initComponents
062:
063: private void statisticsMIActionPerformed(
064: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_statisticsMIActionPerformed
065: pluginPref.getContext().getJ3dFly().getController()
066: .showStatsDialog(null);
067: }//GEN-LAST:event_statisticsMIActionPerformed
068:
069: /**
070: * Returns the control panel for this plugin, or null if there
071: * is no control panel
072: */
073: public javax.swing.JPanel getControlPanel() {
074:
075: // Uncomment this code and change XXXX to instantiate the panel for
076: // this Plugin if it has one, otherwise return null
077:
078: //if (panelReference==null || panelReference.get()==null )
079: // panelReference = new java.lang.ref.SoftReference( new XXXXX() );
080:
081: //return (javax.swing.JPanel)panelReference.get();
082:
083: return null;
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: initComponents();
093:
094: menuBar.removeAll();
095: menuBar = null;
096: pluginMenu.remove(statisticsMI);
097: pluginMenu = null;
098:
099: menu = statisticsMI;
100: if (pluginPref.isInstallInMenu())
101: getMenu("Plugins").add(statisticsMI);
102: }
103:
104: /**
105: * Uninstall this plugin
106: */
107: public void uninstallPlugin() {
108: super .uninstallPlugin();
109: if (pluginPref.isInstallInMenu())
110: getMenu("Plugins").remove(statisticsMI);
111: menu = null;
112: }
113:
114: public String getPluginTitle() {
115: return null;
116: }
117:
118: /**
119: * Returns the class of the plugin preference.
120: *
121: * Plugins that require more preference information should provide a
122: * subclass of PluginPrefernece that contains all the extra preference
123: * data. This class must be Serializable.
124: */
125: public Class getPluginPreferenceClass() {
126: return StatisticsPluginPreference.class;
127: }
128:
129: public static class StatisticsPluginPreference extends
130: PluginPreference {
131: public StatisticsPluginPreference() {
132: super ();
133: }
134:
135: public StatisticsPluginPreference(boolean enabled,
136: boolean installed) {
137: super (enabled, installed);
138: }
139:
140: public J3dFlyPlugin instantiatePlugin() {
141: plugin = new StatisticsPlugin();
142: return plugin;
143: }
144:
145: /**
146: * Return a description of this plugin
147: */
148: public String getDescription() {
149: return "Scene Graph Statistics";
150: }
151:
152: /**
153: * Return the name of the Plugin for this prefernece.
154: * This is the name that will appear in the list of plugins
155: */
156: public String getName() {
157: return "Statistics";
158: }
159:
160: }
161:
162: // Variables declaration - do not modify//GEN-BEGIN:variables
163: private javax.swing.JMenuItem statisticsMI;
164: private javax.swing.JMenuBar menuBar;
165: private javax.swing.JMenu pluginMenu;
166: // End of variables declaration//GEN-END:variables
167:
168: }
|