/*
 * -------------------------------------------------------------------------
 *      $Id: ClusterMain.java,v 1.1 2006/01/30 18:54:59 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.
 *--------------------------------------------------------------------------
 */

/*
 * ClusterMain.java
 *
 * Created on December 14, 2005, 3:24 AM
 * Modified version of StatsMain.java
 */

package com.imsl.demo.cluster;

import com.imsl.demo.gallery.Describe;

public class ClusterMain extends javax.swing.JFrame {

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

    /** Creates a new instance of ClusterMain */
    public ClusterMain(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/cluster/StarCluster.html");
        des.show();
        java.awt.Dimension ds = des.getSize();

        setTitle("Examples in Cluster Analysis");
        java.awt.Dimension ss = getToolkit().getScreenSize();
        int w = Math.min(ss.width/2, ss.height-ds.height-32);
        setSize(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);
            }
        });

        jTabbedPane = new javax.swing.JTabbedPane();
        jTabbedPane.addTab("K-Means", new StarCluster(this));
        jTabbedPane.addTab("Hierarchical", new HCluster(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 ClusterMain(exitOnClose).show();
    }
}


/*

path=c:\prog\j2sdk1.4.2_05\bin;%path%
set CLASSPATH=C:\prog\cvs\jmsl\Release_2005_12_12_02PM\Internal\jmsl_unlicensed.jar;%CLASSPATH%;c:\prog\java\test

*/