
/**
 * PlotterPlugin.java
 * A simple plugin for generating more custormized data plots from X.Y data
 * Created: July 4, 2005
 *
 * @author Nathan Stevens
 * @version 0.1 7/11/2005
 */
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;

public class PlotterPlugin extends JFrame implements InstruViewPlugin {
  private static final String VERSION = "0.1 (7-11-05)";
  private InstruView instruView= null;
  private String name = "Plotter";
  private SpectraData[] sda = null;
  
  // constructor isn't really used
  public PlotterPlugin() { }
  
  // the main constructor
  public PlotterPlugin(InstruView instruView) {
    super("Plotter v- " + VERSION);
    
    this.instruView = instruView;
    
    // handles clossing of this plugin
		addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent we) {
        setVisible(false);
        dispose();
      }
		});
    
    // set the layout to border layer
    getContentPane().setLayout(new BorderLayout());
    
    // some gui stuff
    JPanel panel;
    JLabel label;
    JButton button;
    
    // test code
    label = new JLabel("<html>Plotter Plugin<br>A simple test of the plugin interface");
    getContentPane().add(label, "Center");
    
    // set this visible
    setSize(300, 150);
    setVisible(true);
  }
  
  // Method to return information about this plugin
  public String[] getPluginInformation() {
    String[] information = {"Author : Nathan Stevens",
                                            "Version : " + VERSION,
                                            "",
                                            "A simple plugin for plotting data"};
    
    return information;
  }
  
  // Method to set any spectra data
  public void setSpectraData(SpectraData[] sda) {
    this.sda = sda;
  }
  
  // the static class for putting it self into the class
  static class PlotterFactory extends PluginFactory {
    public InstruViewPlugin create(InstruView instruView) {
      return (new PlotterPlugin(instruView));
    }
    
    // get the experiment type
    public String getExperimentType() {
      return "plotter";
    }
    
    // get information about this plugin
    public String[] getPluginInformation() {
      String[] information = {"Author : Nathan Stevens",
                                              "Version : " + VERSION,
                                              "",
                                              "A simple plugin for plotting data"};
      
      return information;
    }
  }// -- end inner static class PlotterFactory
  
  // add this factory to the InstruviewPluginLoader factory hashtable
  static {
    InstruViewPluginLoader.pluginFactories.put("Plotter", new PlotterFactory());
  }
} // --end class PlotterPlugin
