gt: 		measuredReverb = new XYSeries("Measured",true,false);
context: /* Renoverb is a program aimed at theater engineers that predicts the effect
     of sound absorbing materials on the reverberation of a room.
     Copyright 2008: Anthony Heathcoat, Nicholas Roth, Jim Simon, Yusuke Hasegawa
  
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation, either version 3 of the License, or
     (at your option) any later version.
  
     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
  
     You should have received a copy of the GNU General Public License
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
  
  import java.awt.BorderLayout;
  import java.awt.Color;
  import java.awt.Component;
  import java.awt.Dimension;
  import java.awt.FileDialog;
  import java.awt.Font;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.awt.event.KeyEvent;
  
  import java.sql.SQLException;
  
  import java.util.Vector;
  
  import javax.swing.BoxLayout;
  import javax.swing.JButton;
  import javax.swing.JComboBox;
  import javax.swing.JFrame;
  import javax.swing.JLabel;
  import javax.swing.JMenu;
  import javax.swing.JMenuBar;
  import javax.swing.JMenuItem;
  import javax.swing.JOptionPane;
  import javax.swing.JPanel;
  import javax.swing.JScrollPane;
  import javax.swing.JSplitPane;
  import javax.swing.JTabbedPane;
  import javax.swing.JTable;
  import javax.swing.JTextField;
  import javax.swing.SwingConstants;
  import javax.swing.border.LineBorder;
  import javax.swing.table.AbstractTableModel;
  
  import org.jfree.chart.ChartPanel;
  import org.jfree.chart.JFreeChart;
  import org.jfree.chart.axis.LogAxis;
  import org.jfree.chart.axis.NumberAxis;
  import org.jfree.chart.plot.XYPlot;
  import org.jfree.chart.renderer.xy.XYItemRenderer;
  import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
  import org.jfree.chart.renderer.xy.XYSplineRenderer;
  import org.jfree.data.Range;
  import org.jfree.data.RangeType;
  import org.jfree.data.xy.XYSeries;
  import org.jfree.data.xy.XYSeriesCollection;
  
  public class MainWindow extends JFrame implements ActionListener
  {
  	public static final long serialVersionUID = 1;
  	public static CalcSQL database = null;
  	public static DatabaseBrowser browser = null;
  	public static About about = null;
  	public static JPanel matList;		//shows all active materials
  	
  	private JButton uApply;		//universal Apply button
  	private JButton matLoad;	//load material from database
  	private JButton matNew;		//create new blank material slot to be filled in manually
  	private JComboBox chartType;//Select a renderer for the chart
  
  	private JMenuItem menuAbout;	//bring up About dialog
  	private JMenuItem dbAttach;
  	private JMenuItem dbImportDb;
  	private JMenuItem dbImportTxt;
  	private JMenuItem dbExportDb;
  
  	private JTable mrTable;		//Measured RT
  	private JTable outputTable;	//Output
  	private JTextField inSA, inVol;	//user specified room surface area and volume
  	private JTextField inRT;		//desired reverb time
  	
  	private XYSeries measuredReverb = new XYSeries("Measured",true,false);
  	private XYSeries desiredReverb = new XYSeries("Desired",true,false);
  	private XYSeries projectedReverb = new XYSeries("Projected",true,false);
  	private XYPlot chartplot;	//the combination of all the datasets that go into the chart
  
  	private XYItemRenderer[] renderers;
  	
  	public MainWindow()
  	{
  		//set basic window properties
  		super("Renoverb");
  		setDefaultCloseOperation(EXIT_ON_CLOSE);
  		setIconImage(Images.graph().getImage());
  		setResizable(true);
  		setMinimumSize(new Dimension(400,300));
  		setSize(640,480);
  
  		//find the class path of where program is running from
  		String fileSeparator = System.getProperty("file.separator");
  		String rawClasspath = System.getProperty("java.class.path");
  		String pathSeparator = System.getProperty("path.separator");
  		int firstSC = rawClasspath.indexOf(pathSeparator);
  		if(firstSC == -1) firstSC = rawClasspath.length();
  		String firstPath = rawClasspath.substring(0, firstSC);
  		int lastFS = firstPath.lastIndexOf(fileSeparator);
  		String classpath;
  		if(lastFS == -1)
  		{
  			classpath = "";
  		}else{
  			classpath = firstPath.substring(0, lastFS)+fileSeparator; //should now contain the directory of where the program is running from
  		}
  
  		/* initialize seperate windows (database browser, about box)
  		   but don't show them until the user asks for them
  		 */
  		browser = new DatabaseBrowser();
  		about = new About();
  
  		//start up material database subsystem
  		attachDatabase(classpath+"materials.db");
  		
  		//some default/common objects to use throughout the program
  		JLabel[] spacers = new JLabel[6];
  		for(int x=0;x<spacers.length;x++)
  		{
  			spacers[x] = new JLabel(" ");
  			spacers[x].setFont(new Font("Arial",Font.PLAIN,2));
  		}
  				
  		//Create contents of tabs
  		//Room
  		JPanel room = new JPanel(new BorderLayout());
  		JLabel rmTitle = new JLabel("Room",SwingConstants.CENTER);
  //		rmTitle.setFont(new Font(Font.SANS_SERIF, Font.BOLD,14));
  				
  		JLabel markSA = new JLabel("Surface Area:",SwingConstants.LEFT);
  		markSA.setFont(new Font("Arial",Font.PLAIN,14));
  		JLabel unitSA = new JLabel("square feet",SwingConstants.LEFT);
  		unitSA.setFont(new Font("Arial",Font.PLAIN,14));
  		inSA = new JTextField(15);
  		JLabel markVol = new JLabel("Volume:",SwingConstants.LEFT);
  		markVol.setFont(new Font("Arial",Font.PLAIN,14));
  		JLabel unitVol = new JLabel("cubic feet",SwingConstants.LEFT);
  		unitVol.setFont(new Font("Arial",Font.PLAIN,14));
  		inVol = new JTextField(15);
  		JLabel markRT = new JLabel("Desired RT:",SwingConstants.LEFT);
  		markRT.setFont(new Font("Arial",Font.PLAIN,14));
  		JLabel unitRT = new JLabel("seconds",SwingConstants.LEFT);
  		unitRT.setFont(new Font("Arial",Font.PLAIN,14));
  		inRT = new JTextField(15);
  		
  		JPanel fieldTitles = new JPanel();
  		fieldTitles.setLayout(new BoxLayout(fieldTitles, BoxLayout.Y_AXIS));
  		fieldTitles.add(markSA);
  		fieldTitles.add(spacers[2]);
  		fieldTitles.add(markVol);
  		fieldTitles.add(spacers[3]);
  		fieldTitles.add(markRT);
  		JPanel fieldInputs = new JPanel();
  		fieldInputs.setLayout(new BoxLayout(fieldInputs, BoxLayout.Y_AXIS));
  		fieldInputs.add(inSA);
  		fieldInputs.add(inVol);
  		fieldInputs.add(inRT);
  		JPanel fieldUnits = new JPanel();
  		fieldUnits.setLayout(new BoxLayout(fieldUnits, BoxLayout.Y_AXIS));
  		fieldUnits.add(unitSA);
  		fieldUnits.add(spacers[4]);
  		fieldUnits.add(unitVol);
  		fieldUnits.add(spacers[5]);
  		fieldUnits.add(unitRT);
  		JPanel fields = new JPanel(new BorderLayout());
  		fields.add(fieldTitles, BorderLayout.WEST);
  		fields.add(fieldInputs, BorderLayout.CENTER);
  		fields.add(fieldUnits, BorderLayout.EAST);
  		
  		JLabel mrTitle = new JLabel("Measured Reverb Times",SwingConstants.CENTER);
  //		mrTitle.setFont(new Font(Font.SANS_SERIF, Font.BOLD,14));
  		mrTable = new JTable(new MeasuredRtTable());
  		mrTable.getTableHeader().setReorderingAllowed(false);
  		
  		JPanel roomMeas = new JPanel();
  		roomMeas.setLayout(new BoxLayout(roomMeas, BoxLayout.Y_AXIS));
  		roomMeas.add(rmTitle);
  		roomMeas.add(fields);
  		roomMeas.add(spacers[0]);
  		roomMeas.add(mrTitle);
  		room.add(roomMeas,BorderLayout.NORTH);
  		room.add(new JScrollPane(mrTable),BorderLayout.CENTER);
  		
  		//Materials
  		JPanel materials = new JPanel(new BorderLayout());
  		
  		JPanel matLoadNew = new JPanel(new BorderLayout());
  		matLoad = new JButton("Browse...");
  		matNew = new JButton("New");
  		matLoadNew.add(matLoad,BorderLayout.WEST);
  		matLoadNew.add(matNew,BorderLayout.EAST);
  		matLoadNew.add(spacers[1],BorderLayout.SOUTH);
  		matLoad.addActionListener(this);
  		matNew.addActionListener(this);
  		
  		matList = new JPanel();
  		matList.setLayout(new BoxLayout(matList, BoxLayout.Y_AXIS));
  		JScrollPane matListScroller = new JScrollPane(matList);
  		
  		materials.add(matLoadNew,BorderLayout.NORTH);
  		materials.add(matListScroller,BorderLayout.CENTER);
  		
  		//Options
  		JPanel options = new JPanel();
  		options.setLayout(new BoxLayout(options, BoxLayout.Y_AXIS));
  		
  		//File the tabs together
  		JTabbedPane tabArea = new JTabbedPane();
  		tabArea.addTab("Room", null, room, "Room properties and Desired Reverb");
  		tabArea.setMnemonicAt(0, KeyEvent.VK_I);
  		tabArea.addTab("Materials", null, materials, "Absorption materials");
  		tabArea.setMnemonicAt(1, KeyEvent.VK_M);
  //		tabArea.addTab("Options", null, options, null);
  //		tabArea.setMnemonicAt(2, KeyEvent.VK_O);
  		
  		//Create Input Area (Tab area + universal Apply button)
  		JPanel inputArea = new JPanel(new BorderLayout());
  		uApply = new JButton("Apply");
  		uApply.addActionListener(this);
  		inputArea.add(tabArea, BorderLayout.CENTER);
  		inputArea.add(uApply, BorderLayout.SOUTH);
  		
  		//Create Output Table
  		JPanel opTable = new JPanel(new BorderLayout());
  		outputTable = new JTable(new OutputTable());
  		outputTable.getTableHeader().setReorderingAllowed(false);
  		opTable.add(new JScrollPane(outputTable), BorderLayout.CENTER);
  		
  		//Create Chart Area
  		JPanel chartArea = new JPanel(new BorderLayout());
  		String[] chartTypes = {"Spline Renderer","Line Renderer"};
  		renderers = new XYItemRenderer[chartTypes.length];
  		renderers[0] = new XYSplineRenderer();
  		renderers[1] = new XYLineAndShapeRenderer(true,true);
  		chartType = new JComboBox(chartTypes);
  		chartType.setEditable(false);
  		chartType.addActionListener(this);
  