/*
 * -------------------------------------------------------------------------
 *      $Id: StatsMain.java,v 1.3 2006/02/14 22:24:03 estewart Exp $
 * -------------------------------------------------------------------------
 *      Copyright (c) 1999 Visual Numerics Inc. All Rights Reserved.
 *
 *      This software is confidential information which is proprietary to
 *      and a trade secret of Visual Numerics, Inc.  Use, duplication or
 *      disclosure is subject to the terms of an appropriate license
 *      agreement.
 *
 *      VISUAL NUMERICS MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE
 *      SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING
 *      BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY,
 *      FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. VISUAL
 *      NUMERICS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
 *      AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR
 *      ITS DERIVATIVES.
 *--------------------------------------------------------------------------
 */

/*
 * StatsMain.java
 *
 * Created on September 2, 2004, 10:20 AM
 */

package com.imsl.demo.stats;

import com.imsl.demo.gallery.Describe;

public class StatsMain extends javax.swing.JFrame {

    private javax.swing.JMenu dataMenu;
    private javax.swing.JTabbedPane jTabbedPane;

    /** Creates a new instance of StatsMain */
    public StatsMain(boolean exitOnClose) {
        if (!exitOnClose) {
            // remove the WindowListener,  installed by JFrameChart, that
            // exits the application when the window is closed.
            Object l[] = getListeners(java.awt.event.WindowListener.class);
            for (int k = 0;  k < l.length;  k++) {
                removeWindowListener((java.awt.event.WindowListener)l[k]);
            }
        }
        Describe des = new Describe(this, "/com/imsl/demo/stats/Stats.html");
        des.show();
        java.awt.Dimension ds = des.getSize();

        setTitle("Examples in Statistics");
        java.awt.Dimension ss = getToolkit().getScreenSize();
        int w = Math.min(ss.width/2, ss.height-ds.height-32);
        setSize((int)(1.5*w), w);
        setLocation(ss.width-ds.width, ds.height);

        initComponents();
    }

    public javax.swing.JMenu getDataMenu() {
        return dataMenu;
    }

    private void reset() {
        repaint();
    }

    private void initComponents() {
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                exitForm(evt);
            }
        });

        /*
        javax.swing.JMenuBar jMenu = new javax.swing.JMenuBar();
        dataMenu = new javax.swing.JMenu();
        dataMenu.setMnemonic('D');
        dataMenu.setText("Data");
        jMenu.add(dataMenu);
        setJMenuBar(jMenu);
        */

        jTabbedPane = new javax.swing.JTabbedPane();
        jTabbedPane.addTab("Random Distributions", new RDPanel(this));
        jTabbedPane.addTab("Correlation Visualization", new CVPanel(this));
        jTabbedPane.addTab("Cohen's D", new CDPanel(this));
        jTabbedPane.addTab("Radar Plot", new RAPanel(this));
        getContentPane().add(jTabbedPane, java.awt.BorderLayout.NORTH);
        jTabbedPane.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                reset();
            }
        });
    }

    /** Exit the Application */
    private void exitForm(java.awt.event.WindowEvent evt) {
        setVisible(false);
        dispose();
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        boolean exitOnClose = true;
        if (args.length > 0  && args[0].equals("-noexit"))  exitOnClose = false;
        new StatsMain(exitOnClose).show();
    }
}