/*
 * EnvironmentController.java
 *
 * Created on 05 May 2003, 17:30
 */

/**
 *
 * @author  Administrator
 */
public class EnvironmentController extends javax.swing.JFrame {
    
    /** Creates new form EnvironmentController */
    public EnvironmentController() {
        initComponents();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents
        startButton = new javax.swing.JButton();
        stopButton = new javax.swing.JButton();
        speedScrollBar = new javax.swing.JScrollBar();
        closeButton = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();

        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        setTitle("Executable Model Control");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                exitForm(evt);
            }
        });

        startButton.setMnemonic('s');
        startButton.setText("Start");
        startButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                startButtonActionPerformed(evt);
            }
        });

        getContentPane().add(startButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 50, -1, -1));

        stopButton.setMnemonic('t');
        stopButton.setText("Stop");
        stopButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stopButtonActionPerformed(evt);
            }
        });

        getContentPane().add(stopButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 50, -1, -1));

        speedScrollBar.setBlockIncrement(500);
        speedScrollBar.setMaximum(10000);
        speedScrollBar.setOrientation(javax.swing.JScrollBar.HORIZONTAL);
        speedScrollBar.setUnitIncrement(100);
        speedScrollBar.setVisibleAmount(100);
        speedScrollBar.addAdjustmentListener(new java.awt.event.AdjustmentListener() {
            public void adjustmentValueChanged(java.awt.event.AdjustmentEvent evt) {
                speedScrollBarAdjustmentValueChanged(evt);
            }
        });

        getContentPane().add(speedScrollBar, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 110, 140, 20));

        closeButton.setMnemonic('c');
        closeButton.setText("Close Model");
        getContentPane().add(closeButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 160, -1, -1));

        jLabel1.setText("Speed");
        getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 110, -1, -1));

        getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 190, -1, -1));

        pack();
    }//GEN-END:initComponents

    private void speedScrollBarAdjustmentValueChanged(java.awt.event.AdjustmentEvent evt) {//GEN-FIRST:event_speedScrollBarAdjustmentValueChanged
        DataStorer.setSleepTime(speedScrollBar.getValue());
    }//GEN-LAST:event_speedScrollBarAdjustmentValueChanged

    private void stopButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stopButtonActionPerformed
        DataStorer.setStop(true);
    }//GEN-LAST:event_stopButtonActionPerformed

    private void startButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startButtonActionPerformed
        System model = new System;
        DataStorer.setStop(false);
        DataStorer.setSleepTime(speedScrollBar.getValue());
        model.run();
    }//GEN-LAST:event_startButtonActionPerformed
    
    /** Exit the Application */
    private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
        //java.lang.System.exit(0);
        this.hide();
    }//GEN-LAST:event_exitForm
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        new EnvironmentController().show();
    }
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JButton stopButton;
    private javax.swing.JScrollBar speedScrollBar;
    private javax.swing.JButton startButton;
    private javax.swing.JButton closeButton;
    // End of variables declaration//GEN-END:variables
    
}
