/*
 * SimSetupDialog.java
 *
 * Created on September 13, 2008, 10:51 PM
 */
package gui;

import java.util.ArrayList;
import java.util.HashMap;
import javax.swing.DefaultComboBoxModel;
import qsim.distributions.PseudoHyperExpDist;
import qsim.distributions.PseudoHypoExpDist;
import umontreal.iro.lecuyer.probdist.ContinuousDistribution;
import umontreal.iro.lecuyer.probdist.ErlangDist;
import umontreal.iro.lecuyer.probdist.ExponentialDist;

/**
 *
 * @author  joe
 */
public class SimSetupDialog extends javax.swing.JDialog {

    /** Creates new form SimSetupDialog */
    public SimSetupDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        this.setLocation(300, 300);
        initComponents();
        
        //paraméterlista inicializálása
        paramMap.put("Intenzitás (λ)", "7.0");
        paramMap.put("Shape (k)", "1");
        paramMap.put("Scale (λ)", "7.0");
        
        paramMap.put("Intenzitás (μ)", "10.0");
        paramMap.put("Shape (l)", "1");
        paramMap.put("Scale (μ)", "10.0");
        
        //hypoexp
        paramMap.put("λ1", "2.0");
        paramMap.put("λ2", "3.0");
        paramMap.put("Új λ...", "");
        
        paramMap.put("μ1", "2.0");
        paramMap.put("μ2", "3.0");
        paramMap.put("Új μ...", "");
        
        //hyperexp
        paramMap.put(" λ1", "2.0");
        paramMap.put(" λ2", "3.0");
        paramMap.put(" Új λ...", "");
        
        paramMap.put(" μ1", "2.0");
        paramMap.put(" μ2", "3.0");
        paramMap.put(" Új μ...", "");
    }

    /** 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.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        StartjButton = new javax.swing.JButton();
        CanceljButton = new javax.swing.JButton();
        arrjLabel = new javax.swing.JLabel();
        servjLabel = new javax.swing.JLabel();
        numberOfServersjLabel = new javax.swing.JLabel();
        policyjLabel = new javax.swing.JLabel();
        simTimejLabel = new javax.swing.JLabel();
        arrDistjComboBox = new javax.swing.JComboBox();
        servDistjComboBox = new javax.swing.JComboBox();
        numberOfServersjTextField = new javax.swing.JTextField();
        titlejLabel = new javax.swing.JLabel();
        policyjComboBox = new javax.swing.JComboBox();
        simTimejTextField = new javax.swing.JTextField();
        arrParamjTextField = new javax.swing.JTextField();
        servParamjTextField = new javax.swing.JTextField();
        arrParamjComboBox = new javax.swing.JComboBox();
        servParamjComboBox = new javax.swing.JComboBox();
        capacityjLabel = new javax.swing.JLabel();
        capacityjTextField = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Szimuláció beállítása");
        setName("simSetupDialog"); // NOI18N
        setResizable(false);

        StartjButton.setText("Szimuláció indítása");
        StartjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                StartjButtonActionPerformed(evt);
            }
        });

        CanceljButton.setText("Mégse");
        CanceljButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CanceljButtonActionPerformed(evt);
            }
        });

        arrjLabel.setText("Beérkezési időközök eloszlása");

        servjLabel.setText("Kiszolgálási idők eloszlása");

        numberOfServersjLabel.setText("Kiszolgálók száma");

        policyjLabel.setText("Kiszolgálási elv");

        simTimejLabel.setText("Szimuláció hossza (időegység)");

        arrDistjComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Exponenciális", "Erlang", "HypoExp", "HyperExp" }));
        arrDistjComboBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                arrDistjComboBoxItemStateChanged(evt);
            }
        });

        servDistjComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Exponenciális", "Erlang", "HypoExp", "HyperExp" }));
        servDistjComboBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                servDistjComboBoxItemStateChanged(evt);
            }
        });

        numberOfServersjTextField.setText("1");
        numberOfServersjTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                numberOfServersjTextFieldKeyReleased(evt);
            }
        });

        titlejLabel.setFont(new java.awt.Font("Albany AMT", 0, 18));
        titlejLabel.setText("Szimuláció beállítása");

        policyjComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "FIFO", "LIFO" }));

        simTimejTextField.setText("100");
        simTimejTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                simTimejTextFieldKeyReleased(evt);
            }
        });

        arrParamjTextField.setText("7");
        arrParamjTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                arrParamjTextFieldKeyReleased(evt);
            }
        });

        servParamjTextField.setText("10");
        servParamjTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                servParamjTextFieldKeyReleased(evt);
            }
        });

        arrParamjComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Intenzitás (λ)" }));
        arrParamjComboBox.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                arrParamjComboBoxMousePressed(evt);
            }
        });
        arrParamjComboBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                arrParamjComboBoxItemStateChanged(evt);
            }
        });
        arrParamjComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                arrParamjComboBoxActionPerformed(evt);
            }
        });

        servParamjComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Intenzitás (μ)" }));
        servParamjComboBox.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                servParamjComboBoxMousePressed(evt);
            }
        });
        servParamjComboBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                servParamjComboBoxItemStateChanged(evt);
            }
        });
        servParamjComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                servParamjComboBoxActionPerformed(evt);
            }
        });

        capacityjLabel.setText("Kapacitás");

        capacityjTextField.setText("-1");
        capacityjTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                capacityjTextFieldKeyReleased(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(titlejLabel))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(arrjLabel)
                                    .addComponent(servjLabel))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(arrDistjComboBox, javax.swing.GroupLayout.Alignment.LEADING, 0, 128, Short.MAX_VALUE)
                                    .addComponent(servDistjComboBox, javax.swing.GroupLayout.Alignment.LEADING, 0, 128, Short.MAX_VALUE)
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addComponent(capacityjTextField, javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(numberOfServersjTextField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 37, Short.MAX_VALUE))))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(simTimejLabel)
                                    .addComponent(policyjLabel))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(simTimejTextField)
                                    .addComponent(policyjComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 63, Short.MAX_VALUE)))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(servParamjComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(arrParamjComboBox, 0, 110, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(servParamjTextField)
                            .addComponent(arrParamjTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 43, Short.MAX_VALUE))
                        .addGap(54, 54, 54))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(numberOfServersjLabel))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(capacityjLabel))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(166, 166, 166)
                        .addComponent(StartjButton)
                        .addGap(18, 18, 18)
                        .addComponent(CanceljButton)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(titlejLabel)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(arrjLabel)
                    .addComponent(arrDistjComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(arrParamjTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(arrParamjComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(servjLabel)
                    .addComponent(servDistjComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(servParamjTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(servParamjComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(numberOfServersjLabel)
                    .addComponent(numberOfServersjTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(capacityjLabel)
                    .addComponent(capacityjTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(simTimejLabel)
                    .addComponent(simTimejTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(policyjLabel)
                    .addComponent(policyjComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 39, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(CanceljButton)
                    .addComponent(StartjButton))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void CanceljButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CanceljButtonActionPerformed
// TODO add your handling code here:
    this.dispose();
}//GEN-LAST:event_CanceljButtonActionPerformed

private void StartjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_StartjButtonActionPerformed
// TODO add your handling code here:
    
    //ez arra kell, hogy akkor is frissüljenek az adatok, ha egyből a Startra kattintunk
    paramMap.put(this.arrParamjComboBox.getSelectedItem().toString(), 
            this.arrParamjTextField.getText());
    
    paramMap.put(this.servParamjComboBox.getSelectedItem().toString(), 
            this.servParamjTextField.getText());
    
    try {
        ContinuousDistribution arrDist = null;
        ContinuousDistribution servDist = null;
        
        //beérkező időközök eloszlása
        if(this.arrDistjComboBox.getSelectedItem().toString().equals("Exponenciális")){
            arrDist = new ExponentialDist(Double.parseDouble(this.paramMap.get("Intenzitás (λ)")));          
        }
        else if (this.arrDistjComboBox.getSelectedItem().toString().equals("Erlang")){
            arrDist = new ErlangDist(Integer.parseInt(this.paramMap.get("Shape (k)")), Double.parseDouble(this.paramMap.get("Scale (λ)")));
        }
        else if (this.arrDistjComboBox.getSelectedItem().toString().equals("HypoExp")){
            ArrayList<ExponentialDist> dists = new ArrayList<ExponentialDist>();
            for(String param: this.paramMap.keySet()){
                if(param.charAt(0) == 'λ'){
                    dists.add(new ExponentialDist(new Double(this.paramMap.get(param))));
                }
            }
            arrDist = new PseudoHypoExpDist(dists);
        }
        else if (this.arrDistjComboBox.getSelectedItem().toString().equals("HyperExp")){
            ArrayList<ExponentialDist> dists = new ArrayList<ExponentialDist>();
            for(String param: this.paramMap.keySet()){
                if(param.charAt(0) == ' ' && param.charAt(1) == 'λ'){
                    dists.add(new ExponentialDist(new Double(this.paramMap.get(param))));
                }
            }
            arrDist = new PseudoHyperExpDist(dists);
        }
        
        //kiszolgálási idők eloszlása
        if(this.servDistjComboBox.getSelectedItem().toString().equals("Exponenciális")){
            servDist = new ExponentialDist(Double.parseDouble(this.paramMap.get("Intenzitás (μ)")));          
        }
        else if (this.servDistjComboBox.getSelectedItem().toString().equals("Erlang")){
            servDist = new ErlangDist(Integer.parseInt(this.paramMap.get("Shape (l)")), Double.parseDouble(this.paramMap.get("Scale (μ)")));
        }
        else if (this.servDistjComboBox.getSelectedItem().toString().equals("HypoExp")){
            ArrayList<ExponentialDist> dists = new ArrayList<ExponentialDist>();
            for(String param: this.paramMap.keySet()){
                if(param.charAt(0) == 'μ'){
                    dists.add(new ExponentialDist(new Double(this.paramMap.get(param))));
                }
            }
            servDist = new PseudoHypoExpDist(dists);
        }
        else if (this.servDistjComboBox.getSelectedItem().toString().equals("HyperExp")){
            ArrayList<ExponentialDist> dists = new ArrayList<ExponentialDist>();
            for(String param: this.paramMap.keySet()){
                if(param.charAt(0) == ' ' && param.charAt(1) == 'μ'){
                    dists.add(new ExponentialDist(new Double(this.paramMap.get(param))));
                }
            }
            servDist = new PseudoHyperExpDist(dists);
        }
        
        new SimResultInTable(arrDist, servDist, Integer.parseInt(this.numberOfServersjTextField.getText()),
                Integer.parseInt(this.capacityjTextField.getText()),
                this.policyjComboBox.getSelectedItem().toString(), 
                Integer.parseInt(this.simTimejTextField.getText())).setVisible(true);
        
        this.dispose();
    
    } catch (NumberFormatException nFe){
        new ErrorDialog(null, true, "Hibás beviteli adatok!").setVisible(true);
    } catch (Exception e) {
        new ErrorDialog(null, true, e.getClass().toString()).setVisible(true);
    }
}//GEN-LAST:event_StartjButtonActionPerformed

private void arrDistjComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_arrDistjComboBoxItemStateChanged
// TODO add your handling code here:
    paramMap.put(this.arrParamjComboBox.getSelectedItem().toString(), 
            this.arrParamjTextField.getText());
    
    if (this.arrDistjComboBox.getSelectedItem().toString().equals("Exponenciális")) {
        this.arrParamjComboBox.setModel(arrExpModel);
    } else if (this.arrDistjComboBox.getSelectedItem().toString().equals("Erlang")) {
        this.arrParamjComboBox.setModel(arrErlangModel);
    } else if (this.arrDistjComboBox.getSelectedItem().toString().equals("HypoExp")) {
        this.arrParamjComboBox.setModel(arrHypoExpModel);
    } else if (this.arrDistjComboBox.getSelectedItem().toString().equals("HyperExp")) {
        this.arrParamjComboBox.setModel(arrHyperExpModel);
    }
    
    this.arrParamjTextField.setText(paramMap.get(arrParamjComboBox.getSelectedItem().toString()));

}//GEN-LAST:event_arrDistjComboBoxItemStateChanged

private void arrParamjTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_arrParamjTextFieldKeyReleased
// TODO add your handling code here:
    try {
        if (this.arrParamjTextField.getText().trim().equals("")) return;
        new Double(this.arrParamjTextField.getText());
    } catch (Exception e) {
        this.arrParamjTextField.setText("1");
    }
}//GEN-LAST:event_arrParamjTextFieldKeyReleased

private void numberOfServersjTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_numberOfServersjTextFieldKeyReleased
// TODO add your handling code here:
    try {
        if (this.numberOfServersjTextField.getText().trim().equals("")) return;
        Integer iK = new Integer(this.capacityjTextField.getText());
        Integer iN = new Integer(this.numberOfServersjTextField.getText());
        
        if (iK != -1 && iK < iN){
            this.capacityjTextField.setText(iN.toString());
        }
    } catch (Exception e) {
        this.numberOfServersjTextField.setText("1");
    }
}//GEN-LAST:event_numberOfServersjTextFieldKeyReleased

private void servParamjTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_servParamjTextFieldKeyReleased
// TODO add your handling code here:
    try {
        if (this.servParamjTextField.getText().trim().equals("")) return;
        new Double(this.servParamjTextField.getText());
    } catch (Exception e) {
        this.servParamjTextField.setText("1");
    }
    
}//GEN-LAST:event_servParamjTextFieldKeyReleased

private void simTimejTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_simTimejTextFieldKeyReleased
// TODO add your handling code here:
    try {
        if (this.simTimejTextField.getText().trim().equals("")) return;
        new Integer(this.simTimejTextField.getText());
    } catch (Exception e) {
        this.simTimejTextField.setText("100");
    }
}//GEN-LAST:event_simTimejTextFieldKeyReleased

private void servDistjComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_servDistjComboBoxItemStateChanged
// TODO add your handling code here:
    paramMap.put(this.servParamjComboBox.getSelectedItem().toString(), 
            this.servParamjTextField.getText());
    
    if (this.servDistjComboBox.getSelectedItem().toString().equals("Exponenciális")) {
        this.servParamjComboBox.setModel(servExpModel);
    } else if (this.servDistjComboBox.getSelectedItem().toString().equals("Erlang")) {
        this.servParamjComboBox.setModel(servErlangModel);
    } else if (this.servDistjComboBox.getSelectedItem().toString().equals("HypoExp")) {
        this.servParamjComboBox.setModel(servHypoExpModel);
    } else if (this.servDistjComboBox.getSelectedItem().toString().equals("HyperExp")) {
        this.servParamjComboBox.setModel(servHyperExpModel);
    }
    
    this.servParamjTextField.setText(paramMap.get(servParamjComboBox.getSelectedItem().toString()));
}//GEN-LAST:event_servDistjComboBoxItemStateChanged

private void arrParamjComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_arrParamjComboBoxItemStateChanged
// TODO add your handling code here:
    this.arrParamjTextField.setText(paramMap.get(arrParamjComboBox.getSelectedItem().toString()));
}//GEN-LAST:event_arrParamjComboBoxItemStateChanged

private void servParamjComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_servParamjComboBoxItemStateChanged
// TODO add your handling code here:
    this.servParamjTextField.setText(paramMap.get(servParamjComboBox.getSelectedItem().toString()));
}//GEN-LAST:event_servParamjComboBoxItemStateChanged

private void arrParamjComboBoxMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_arrParamjComboBoxMousePressed
// TODO add your handling code here:
    paramMap.put(this.arrParamjComboBox.getSelectedItem().toString(), 
            this.arrParamjTextField.getText());
}//GEN-LAST:event_arrParamjComboBoxMousePressed

private void servParamjComboBoxMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_servParamjComboBoxMousePressed
// TODO add your handling code here:
    paramMap.put(this.servParamjComboBox.getSelectedItem().toString(), 
            this.servParamjTextField.getText());
}//GEN-LAST:event_servParamjComboBoxMousePressed

private void capacityjTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_capacityjTextFieldKeyReleased
// TODO add your handling code here:
    try {
        if (this.capacityjTextField.getText().trim().equals("")) return;
        if (this.capacityjTextField.getText().trim().equals("-1")) return;
        Integer iK = new Integer(this.capacityjTextField.getText());
        Integer iN = new Integer(this.numberOfServersjTextField.getText());
        
        if (iK < iN){
            this.capacityjTextField.setText(iN.toString());
        }
    } catch (Exception e) {
        this.capacityjTextField.setText("-1");
    }
}//GEN-LAST:event_capacityjTextFieldKeyReleased

private void arrParamjComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_arrParamjComboBoxActionPerformed
// TODO add your handling code here
    //System.out.println(this.arrParamjComboBox.getSelectedItem());
    if (this.arrParamjComboBox.getSelectedItem().toString().equals("Új λ...")){
        this.arrHypoExpModel.insertElementAt("λ" + (this.arrHypoExpModel.getSize()), this.arrHypoExpModel.getSize()-1);
        this.arrParamjComboBox.setSelectedIndex(this.arrHypoExpModel.getSize()-2);
    } else if (this.arrParamjComboBox.getSelectedItem().toString().equals(" Új λ...")){
        this.arrHyperExpModel.insertElementAt(" λ" + (this.arrHyperExpModel.getSize()), this.arrHyperExpModel.getSize()-1);
        this.arrParamjComboBox.setSelectedIndex(this.arrHyperExpModel.getSize()-2);
    }
}//GEN-LAST:event_arrParamjComboBoxActionPerformed

private void servParamjComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_servParamjComboBoxActionPerformed
// TODO add your handling code here:
    if (this.servParamjComboBox.getSelectedItem().toString().equals("Új μ...")){
        this.servHypoExpModel.insertElementAt("μ" + (this.servHypoExpModel.getSize()), this.servHypoExpModel.getSize()-1);
        this.servParamjComboBox.setSelectedIndex(this.servHypoExpModel.getSize()-2);
    } else if (this.servParamjComboBox.getSelectedItem().toString().equals(" Új μ...")){
        this.servHyperExpModel.insertElementAt(" μ" + (this.servHyperExpModel.getSize()), this.servHyperExpModel.getSize()-1);
        this.servParamjComboBox.setSelectedIndex(this.servHyperExpModel.getSize()-2);
    }
}//GEN-LAST:event_servParamjComboBoxActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton CanceljButton;
    private javax.swing.JButton StartjButton;
    private javax.swing.JComboBox arrDistjComboBox;
    private javax.swing.JComboBox arrParamjComboBox;
    private javax.swing.JTextField arrParamjTextField;
    private javax.swing.JLabel arrjLabel;
    private javax.swing.JLabel capacityjLabel;
    private javax.swing.JTextField capacityjTextField;
    private javax.swing.JLabel numberOfServersjLabel;
    private javax.swing.JTextField numberOfServersjTextField;
    private javax.swing.JComboBox policyjComboBox;
    private javax.swing.JLabel policyjLabel;
    private javax.swing.JComboBox servDistjComboBox;
    private javax.swing.JComboBox servParamjComboBox;
    private javax.swing.JTextField servParamjTextField;
    private javax.swing.JLabel servjLabel;
    private javax.swing.JLabel simTimejLabel;
    private javax.swing.JTextField simTimejTextField;
    private javax.swing.JLabel titlejLabel;
    // End of variables declaration//GEN-END:variables
    
    public DefaultComboBoxModel arrExpModel = new DefaultComboBoxModel(new String[]{"Intenzitás (λ)"});
    public DefaultComboBoxModel arrErlangModel = new DefaultComboBoxModel(new String[]{"Shape (k)", "Scale (λ)"});
    public DefaultComboBoxModel servExpModel = new DefaultComboBoxModel(new String[]{"Intenzitás (μ)"});
    public DefaultComboBoxModel servErlangModel = new DefaultComboBoxModel(new String[]{"Shape (l)", "Scale (μ)"});
    public DefaultComboBoxModel arrHypoExpModel = new DefaultComboBoxModel(new String[]{"λ1", "λ2", "Új λ..."});
    public DefaultComboBoxModel servHypoExpModel = new DefaultComboBoxModel(new String[]{"μ1", "μ2", "Új μ..."});
    public DefaultComboBoxModel arrHyperExpModel = new DefaultComboBoxModel(new String[]{" λ1", " λ2", " Új λ..."});
    public DefaultComboBoxModel servHyperExpModel = new DefaultComboBoxModel(new String[]{" μ1", " μ2", " Új μ..."});
    
    
    private HashMap<String, String> paramMap = new HashMap<String, String>();
}
