package org.mbari.seepsearch.ui;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import org.mbari.awt.layout.*;
import javax.swing.border.*;

/**
 * <p><!--Insert summary here--></p>
 *
 * <p>The Seep Search project is a sub-project of the Continental
 * Margin Fluids and Gases project (200010). It involves the analysis of
 * archived ROV data to obtain understanding of seep distritution in Monterey
 * Bay.</p>
 *
 * <p>The Purpose of this Java package is to intercompare ROV Navigation files,
 * VIMS data on seep community observations and the EM-300 bathymetry. We are
 * looking for locations where the ROV navigation files and the EM-300 data
 * have similar depths between the 2 data sets, which implies that the ROV is
 * observing the sea floor.</p><hr><br>
 *
 * <p>MBARI provides this documentation and code &quot;as is&quot;, with no
 * warranty, express or implied, of its quality or consistency. It is provided
 * without support and without obligation on the part of the Monterey Bay
 * Aquarium Research Institute to assist in its use, correction, modification,
 * or enhancement. This information should not be published or distributed to
 * third parties without specific written permission from MBARI.</p><br>
 *
 * Copyright 2002 MBARI.<br>
 * MBARI Proprietary Information. All rights reserved.<br><hr><br>
 *
 * $Log: StartFrame.java,v $
 * Revision 1.2  2002/04/22 18:56:37  brian
 * Modified to include VarsGridGeneratorFrame
 *
 * Revision 1.1  2002/01/30 00:23:56  brian
 * Added comments to all classes and methods. Tested the accuracy of AsciiRasterGridReader and AsciiRasterGridWriter. Also checked the the GridUtil was populating the spatial grids correctly and accurately. The data files generated matched up perfectly with the orginal text files. Also implemented an RovAltitudeFilter class to encapsulate different filtering methods.
 *<br><hr><br>
 *
 * @author  : $Author: brian $
 * @version : $Revision: 1.2 $
 */
public class StartFrame extends JFrame {
    JPanel contentPane;
    final JPanel jPanel1 = new JPanel();
    final GridLayout gridLayout1 = new GridLayout();
    final VerticalFlowLayout verticalFlowLayout1 = new VerticalFlowLayout();
    Border border1;
    TitledBorder titledBorder1;
    final JButton btnFromQuery = new JButton();
    final JButton btnFromNav = new JButton();
    final JButton btnExit = new JButton();
    JFrame rovGridGeneratorFrame;
    JFrame varsGridGeneratorFrame;

    /**Construct the frame*/
    public StartFrame() {
        enableEvents(AWTEvent.WINDOW_EVENT_MASK);
        try {
            jbInit();
        }
        catch(Exception e) {
            e.printStackTrace();
        }
    }
    /**Component initialization*/
    private void jbInit() throws Exception  {
        btnExit.setText("Exit");
        btnExit.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                btnExit_mouseClicked(e);
            }
        });
        //setIconImage(Toolkit.getDefaultToolkit().createImage(StartFrame.class.getResource("[Your Icon]")));
        contentPane = (JPanel) this.getContentPane();
        border1 = BorderFactory.createEtchedBorder(Color.white,new Color(142, 142, 142));
        titledBorder1 = new TitledBorder(border1,"Generate Grid From:");
        contentPane.setLayout(gridLayout1);
        this.setSize(new Dimension(250, 250));
        this.setTitle("Geogaphic Raster Grid Generator");
        jPanel1.setLayout(verticalFlowLayout1);
        jPanel1.setBorder(titledBorder1);
        btnFromQuery.setToolTipText("");
        btnFromQuery.setText("From VARS Query");
        btnFromQuery.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
                btnFromQuery_actionPerformed(e);
            }
        });
        btnFromNav.setText("From Navigation Files");
        btnFromNav.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
                btnFromNav_actionPerformed(e);
            }
        });
        contentPane.add(jPanel1, null);
        jPanel1.add(btnFromQuery, null);
        jPanel1.add(btnFromNav, null);
        jPanel1.add(btnExit, null);
    }
    /**Overridden so we can exit when window is closed*/
    protected void processWindowEvent(WindowEvent e) {
        super.processWindowEvent(e);
        if (e.getID() == WindowEvent.WINDOW_CLOSING) {
            System.exit(0);
        }
    }

    void btnExit_mouseClicked(MouseEvent e) {
        System.exit(1);
    }

    void btnFromNav_actionPerformed(ActionEvent e) {
        if (rovGridGeneratorFrame == null) {
            rovGridGeneratorFrame = new RovGridGeneratorFrame();
        }
        rovGridGeneratorFrame.pack();
        rovGridGeneratorFrame.setVisible(true);
    }

    void btnFromQuery_actionPerformed(ActionEvent ev) {
        if (varsGridGeneratorFrame == null) {
            varsGridGeneratorFrame = new VarsGridGeneratorFrame();
        }
        varsGridGeneratorFrame.pack();
        varsGridGeneratorFrame.setVisible(true);

    }


}