iad_zad3.gui.MainWindow.java Source code

Java tutorial

Introduction

Here is the source code for iad_zad3.gui.MainWindow.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package iad_zad3.gui;

import iad_zad3.algorithms.ClusteringAlgorithm;
import iad_zad3.algorithms.functions.EuclidianDistance;
import iad_zad3.algorithms.KmeansClustering;
import iad_zad3.algorithms.KohonenClustering;
import iad_zad3.algorithms.NeuralGasClustering;
import iad_zad3.gui.GUIHelper.NoFileException;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import org.jfree.chart.ChartPanel;

/**
 *
 * @author marr
 */
public class MainWindow extends javax.swing.JFrame {

    private final GUIHelper helper = new GUIHelper();
    private ClusteringAlgorithm clusteringAlgorithm;
    private ChartWorker chartWorker;
    //    private final Charts chartFactory = new Charts();

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

        jButtonLoadFile = new javax.swing.JButton();
        jButtonShowChart = new javax.swing.JButton();
        jPanelChart = new javax.swing.JPanel();
        jTextCentroids = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jButtonNextIteration = new javax.swing.JButton();
        jButtonPlay = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jTextError = new javax.swing.JTextField();
        jTabbedPane = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        jButtonChooseKmeans = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jButtonChooseKohonen = new javax.swing.JButton();
        jComboBox1 = new javax.swing.JComboBox<>();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jTextKohLambdaMax = new javax.swing.JTextField();
        jTextKohLambdaMin = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jTextKohEtaMax = new javax.swing.JTextField();
        jTextKohEtaMin = new javax.swing.JTextField();
        jPanel4 = new javax.swing.JPanel();
        jButtonChooseNeuralGas = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        jTextNeuLambdaMax = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jTextNeuLambdaMin = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jTextNeuEtaMax = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jTextNeuEtaMin = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jTextIterations = new javax.swing.JTextField();
        jButtonStop = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        jProgressBar1 = new javax.swing.JProgressBar();
        jButtonChangeData = new javax.swing.JButton();
        jCheckAnimate = new javax.swing.JCheckBox();
        jLabel13 = new javax.swing.JLabel();
        jTextFrameDuration = new javax.swing.JTextField();
        jLabelAlgorithm = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jPanelVoronoi = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Grupowanie danych");
        setPreferredSize(new java.awt.Dimension(1596, 900));
        setResizable(false);

        jButtonLoadFile.setFont(new java.awt.Font("Corbel", 1, 14)); // NOI18N
        jButtonLoadFile.setText("Wczytaj plik");
        jButtonLoadFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonLoadFileActionPerformed(evt);
            }
        });

        jButtonShowChart.setFont(new java.awt.Font("Corbel", 1, 14)); // NOI18N
        jButtonShowChart.setText("Resetuj Sie");
        jButtonShowChart.setEnabled(false);
        jButtonShowChart.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonShowChartActionPerformed(evt);
            }
        });

        jPanelChart.setPreferredSize(new java.awt.Dimension(700, 700));

        javax.swing.GroupLayout jPanelChartLayout = new javax.swing.GroupLayout(jPanelChart);
        jPanelChart.setLayout(jPanelChartLayout);
        jPanelChartLayout.setHorizontalGroup(jPanelChartLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 700, Short.MAX_VALUE));
        jPanelChartLayout.setVerticalGroup(jPanelChartLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 675, Short.MAX_VALUE));

        jTextCentroids.setFont(new java.awt.Font("Arial Black", 0, 14)); // NOI18N
        jTextCentroids.setText("30");
        jTextCentroids.setToolTipText("");

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel1.setText("Liczba iteracji");

        jButtonNextIteration.setFont(new java.awt.Font("Corbel", 1, 14)); // NOI18N
        jButtonNextIteration.setText("Nastpna iteracja");
        jButtonNextIteration.setEnabled(false);
        jButtonNextIteration.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonNextIterationActionPerformed(evt);
            }
        });

        jButtonPlay.setFont(new java.awt.Font("Corbel", 1, 14)); // NOI18N
        jButtonPlay.setText("PLAY");
        jButtonPlay.setEnabled(false);
        jButtonPlay.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonPlayActionPerformed(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Corbel", 1, 18)); // NOI18N
        jLabel2.setText("redni bd kwantyzacji");

        jTextError.setEditable(false);
        jTextError.setFont(new java.awt.Font("Arial Black", 0, 24)); // NOI18N

        jTabbedPane.setFont(new java.awt.Font("Candara", 1, 12)); // NOI18N

        jButtonChooseKmeans.setFont(new java.awt.Font("Corbel", 1, 14)); // NOI18N
        jButtonChooseKmeans.setText("Wybierz algorytm");
        jButtonChooseKmeans.setEnabled(false);
        jButtonChooseKmeans.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonChooseKmeansActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout
                .setHorizontalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel2Layout
                                .createSequentialGroup().addContainerGap().addComponent(jButtonChooseKmeans,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE)
                                .addGap(261, 261, 261)));
        jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout
                        .createSequentialGroup().addContainerGap().addComponent(jButtonChooseKmeans,
                                javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(76, Short.MAX_VALUE)));

        jTabbedPane.addTab("algorytm k-rednich", jPanel2);

        jButtonChooseKohonen.setFont(new java.awt.Font("Corbel", 1, 14)); // NOI18N
        jButtonChooseKohonen.setText("Wybierz algorytm");
        jButtonChooseKohonen.setActionCommand("kohonen");
        jButtonChooseKohonen.setEnabled(false);
        jButtonChooseKohonen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonChooseKohonenActionPerformed(evt);
            }
        });

        jComboBox1.setFont(new java.awt.Font("Corbel", 1, 14)); // NOI18N
        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(
                new String[] { "ssiedztwo prostoktne", "ssiedztwo gaussowskie" }));

        jLabel5.setFont(new java.awt.Font("Corbel", 1, 14)); // NOI18N
        jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel5.setText("\u03BB max");

        jLabel6.setFont(new java.awt.Font("Corbel", 1, 14)); // NOI18N
        jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel6.setText("\u03B7 min");

        jTextKohLambdaMax.setFont(new java.awt.Font("Arial Black", 0, 14)); // NOI18N
        jTextKohLambdaMax.setText("0.5");
        jTextKohLambdaMax.setToolTipText("");

        jTextKohLambdaMin.setFont(new java.awt.Font("Arial Black", 0, 14)); // NOI18N
        jTextKohLambdaMin.setText("0.05");
        jTextKohLambdaMin.setToolTipText("");

        jLabel7.setFont(new java.awt.Font("Corbel", 1, 14)); // NOI18N
        jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel7.setText("\u03B7 max");

        jLabel8.setFont(new java.awt.Font("Corbel", 1, 14)); // NOI18N
        jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel8.setText("\u03BB min");

        jTextKohEtaMax.setFont(new java.awt.Font("Arial Black", 0, 14)); // NOI18N
        jTextKohEtaMax.setText("0.1");
        jTextKohEtaMax.setToolTipText("");

        jTextKohEtaMin.setFont(new java.awt.Font("Arial Black", 0, 14)); // NOI18N
        jTextKohEtaMin.setText("0.01");
        jTextKohEtaMin.setToolTipText("");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout
                .setHorizontalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                jPanel3Layout.createSequentialGroup().addContainerGap().addGroup(jPanel3Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(jPanel3Layout.createSequentialGroup()
                                                .addComponent(jButtonChooseKohonen,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE)
                                                .addGap(28, 28, 28)
                                                .addComponent(
                                                        jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 195,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(38, 38, 38))
                                        .addGroup(jPanel3Layout
                                                .createSequentialGroup()
                                                .addGroup(jPanel3Layout
                                                        .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment.LEADING, false)
                                                        .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                103, Short.MAX_VALUE)
                                                        .addComponent(
                                                                jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                Short.MAX_VALUE))
                                                .addPreferredGap(
                                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                .addGroup(jPanel3Layout
                                                        .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                        .addGroup(jPanel3Layout
                                                                .createSequentialGroup()
                                                                .addComponent(jTextKohLambdaMax,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 60,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addPreferredGap(
                                                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                .addComponent(jLabel7,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 84,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addPreferredGap(
                                                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                                .addComponent(
                                                                        jTextKohEtaMax,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 60,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                                        .addGroup(jPanel3Layout.createSequentialGroup()
                                                                .addComponent(jTextKohLambdaMin,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 60,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addPreferredGap(
                                                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                .addComponent(jLabel6,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 84,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addPreferredGap(
                                                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                                .addComponent(jTextKohEtaMin,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 60,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        Short.MAX_VALUE)))));
        jPanel3Layout
                .setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap()
                                .addGroup(jPanel3Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(jButtonChooseKohonen, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                40, Short.MAX_VALUE)
                                        .addComponent(jComboBox1))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel3Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 22,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jTextKohLambdaMax, javax.swing.GroupLayout.PREFERRED_SIZE, 27,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 22,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jTextKohEtaMax, javax.swing.GroupLayout.PREFERRED_SIZE, 27,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(jPanel3Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 22,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jTextKohLambdaMin, javax.swing.GroupLayout.PREFERRED_SIZE, 27,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 22,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jTextKohEtaMin, javax.swing.GroupLayout.PREFERRED_SIZE, 27,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addContainerGap()));

        jTabbedPane.addTab("algorytm Kohonena", jPanel3);

        jButtonChooseNeuralGas.setFont(new java.awt.Font("Corbel", 1, 14)); // NOI18N
        jButtonChooseNeuralGas.setText("Wybierz algorytm");
        jButtonChooseNeuralGas.setActionCommand("neuralgas");
        jButtonChooseNeuralGas.setEnabled(false);
        jButtonChooseNeuralGas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonChooseNeuralGasActionPerformed(evt);
            }
        });

        jLabel9.setFont(new java.awt.Font("Corbel", 1, 14)); // NOI18N
        jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel9.setText("\u03BB max");

        jTextNeuLambdaMax.setFont(new java.awt.Font("Arial Black", 0, 14)); // NOI18N
        jTextNeuLambdaMax.setText("0.8");
        jTextNeuLambdaMax.setToolTipText("");
        jTextNeuLambdaMax.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextNeuLambdaMaxActionPerformed(evt);
            }
        });

        jLabel10.setFont(new java.awt.Font("Corbel", 1, 14)); // NOI18N
        jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel10.setText("\u03BB min");

        jTextNeuLambdaMin.setFont(new java.awt.Font("Arial Black", 0, 14)); // NOI18N
        jTextNeuLambdaMin.setText("0.001");
        jTextNeuLambdaMin.setToolTipText("");

        jLabel11.setFont(new java.awt.Font("Corbel", 1, 14)); // NOI18N
        jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel11.setText("\u03B7 max");

        jTextNeuEtaMax.setFont(new java.awt.Font("Arial Black", 0, 14)); // NOI18N
        jTextNeuEtaMax.setText("0.2");
        jTextNeuEtaMax.setToolTipText("");
        jTextNeuEtaMax.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextNeuEtaMaxActionPerformed(evt);
            }
        });

        jLabel12.setFont(new java.awt.Font("Corbel", 1, 14)); // NOI18N
        jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel12.setText("\u03B7 min");

        jTextNeuEtaMin.setFont(new java.awt.Font("Arial Black", 0, 14)); // NOI18N
        jTextNeuEtaMin.setText("0.01");
        jTextNeuEtaMin.setToolTipText("");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(jPanel4Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel4Layout.createSequentialGroup().addContainerGap().addGroup(jPanel4Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(jButtonChooseNeuralGas, javax.swing.GroupLayout.DEFAULT_SIZE, 148,
                                        Short.MAX_VALUE)
                                .addGap(261, 261, 261))
                        .addGroup(jPanel4Layout.createSequentialGroup().addGroup(
                                jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 103,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel4Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(jPanel4Layout.createSequentialGroup()
                                                .addComponent(jTextNeuLambdaMax,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 60,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 84,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(
                                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                .addComponent(jTextNeuEtaMax,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 60,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(jPanel4Layout.createSequentialGroup()
                                                .addComponent(jTextNeuLambdaMin,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 60,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 84,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(
                                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                .addComponent(jTextNeuEtaMin,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 60,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))));
        jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel4Layout.createSequentialGroup().addContainerGap()
                        .addComponent(jButtonChooseNeuralGas, javax.swing.GroupLayout.PREFERRED_SIZE, 40,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 22,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextNeuLambdaMax, javax.swing.GroupLayout.PREFERRED_SIZE, 27,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 22,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextNeuEtaMax, javax.swing.GroupLayout.PREFERRED_SIZE, 27,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 22,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextNeuLambdaMin, javax.swing.GroupLayout.PREFERRED_SIZE, 27,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 22,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextNeuEtaMin, javax.swing.GroupLayout.PREFERRED_SIZE, 27,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(29, 29, 29)));

        jTabbedPane.addTab("algorytm gazu neuronowego", jPanel4);

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel3.setText("Liczba centroid/neuronw");

        jTextIterations.setFont(new java.awt.Font("Arial Black", 0, 14)); // NOI18N
        jTextIterations.setText("50");
        jTextIterations.setToolTipText("");

        jButtonStop.setFont(new java.awt.Font("Corbel", 1, 14)); // NOI18N
        jButtonStop.setText("STOP");
        jButtonStop.setEnabled(false);
        jButtonStop.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonStopActionPerformed(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel4.setText("postp");

        jButtonChangeData.setFont(new java.awt.Font("Corbel", 1, 14)); // NOI18N
        jButtonChangeData.setText("Zastp dane");
        jButtonChangeData
                .setToolTipText("Zastpuje dane wejciowe centroidami/neuronami z poprzedniego dowiadczenia");
        jButtonChangeData.setEnabled(false);
        jButtonChangeData.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonChangeDataActionPerformed(evt);
            }
        });

        jCheckAnimate.setFont(new java.awt.Font("Corbel", 1, 14)); // NOI18N
        jCheckAnimate.setSelected(true);
        jCheckAnimate.setText("animuj");

        jLabel13.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel13.setText("czas trwania klatki [ms]");

        jTextFrameDuration.setFont(new java.awt.Font("Arial Black", 0, 14)); // NOI18N
        jTextFrameDuration.setText("100");
        jTextFrameDuration.setToolTipText("");

        jLabelAlgorithm.setFont(new java.awt.Font("Corbel", 1, 18)); // NOI18N
        jLabelAlgorithm.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabelAlgorithm.setText("nie wybrano");

        jLabel15.setFont(new java.awt.Font("Corbel", 1, 18)); // NOI18N
        jLabel15.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel15.setText("algorytm:");

        jPanelVoronoi.setPreferredSize(new java.awt.Dimension(700, 700));

        javax.swing.GroupLayout jPanelVoronoiLayout = new javax.swing.GroupLayout(jPanelVoronoi);
        jPanelVoronoi.setLayout(jPanelVoronoiLayout);
        jPanelVoronoiLayout.setHorizontalGroup(jPanelVoronoiLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 600, Short.MAX_VALUE));
        jPanelVoronoiLayout.setVerticalGroup(jPanelVoronoiLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 600, Short.MAX_VALUE));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jButtonStop, javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButtonShowChart, javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButtonNextIteration, javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButtonPlay, javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE)
                        .addComponent(jProgressBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE)
                        .addComponent(jCheckAnimate)
                        .addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE)
                        .addComponent(jTextFrameDuration, javax.swing.GroupLayout.PREFERRED_SIZE, 60,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabelAlgorithm, javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel15, javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanelChart, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(59, 59, 59)
                        .addComponent(jPanelVoronoi, javax.swing.GroupLayout.PREFERRED_SIZE, 600,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(69, Short.MAX_VALUE))
                .addGroup(layout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jButtonLoadFile, javax.swing.GroupLayout.Alignment.TRAILING,
                                        javax.swing.GroupLayout.PREFERRED_SIZE, 148,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jButtonChangeData, javax.swing.GroupLayout.Alignment.TRAILING,
                                        javax.swing.GroupLayout.PREFERRED_SIZE, 148,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jTabbedPane, javax.swing.GroupLayout.PREFERRED_SIZE, 424,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addGroup(layout.createSequentialGroup().addComponent(jLabel3)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 148,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                                layout.createSequentialGroup()
                                                        .addComponent(jTextCentroids,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE, 148,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addGap(39, 39, 39).addComponent(jTextIterations,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE, 148,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(153, 153, 153)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel2).addComponent(jTextError,
                                        javax.swing.GroupLayout.PREFERRED_SIZE, 182,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(473, Short.MAX_VALUE)));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addGroup(layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(layout.createSequentialGroup().addGroup(layout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jTabbedPane, javax.swing.GroupLayout.PREFERRED_SIZE, 156,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                        .addContainerGap()
                                        .addComponent(jButtonLoadFile, javax.swing.GroupLayout.PREFERRED_SIZE, 43,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jButtonChangeData, javax.swing.GroupLayout.PREFERRED_SIZE, 43,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 22,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 22,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jTextCentroids, javax.swing.GroupLayout.PREFERRED_SIZE, 27,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jTextIterations, javax.swing.GroupLayout.PREFERRED_SIZE, 27,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(7, 7, 7))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                layout.createSequentialGroup().addGap(56, 56, 56)
                                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 23,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(
                                                jTextError, javax.swing.GroupLayout.PREFERRED_SIZE, 49,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup().addGap(27, 27, 27)
                                        .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 25,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jLabelAlgorithm, javax.swing.GroupLayout.PREFERRED_SIZE, 34,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(jButtonShowChart, javax.swing.GroupLayout.DEFAULT_SIZE, 54,
                                                Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jButtonNextIteration, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                54, Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jButtonPlay, javax.swing.GroupLayout.DEFAULT_SIZE, 54,
                                                Short.MAX_VALUE)
                                        .addGap(4, 4, 4)
                                        .addComponent(jButtonStop, javax.swing.GroupLayout.DEFAULT_SIZE, 51,
                                                Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 22,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 27,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jCheckAnimate)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 22,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jTextFrameDuration, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                27, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(222, 222, 222))
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                        layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE)
                                                .addComponent(jPanelVoronoi, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        600, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(98, 98, 98))
                                .addGroup(layout.createSequentialGroup()
                                        .addComponent(jPanelChart, javax.swing.GroupLayout.PREFERRED_SIZE, 675,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))));

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

    private void jButtonLoadFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonLoadFileActionPerformed
        try {
            helper.openFile(this);
            switchChoiceButtons(true);
        } catch (NoFileException ex) {
            switchChoiceButtons(false);
            switchRunButtons(false);
            Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            switchChoiceButtons(false);
            switchRunButtons(false);
            Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            switchChoiceButtons(false);
            switchRunButtons(false);
            Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButtonLoadFileActionPerformed

    private void jButtonShowChartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonShowChartActionPerformed
        if (chartWorker != null) {
            chartWorker.cancel(true);
        }
        clusteringAlgorithm.setUpNewCentroids(Integer.parseInt(jTextCentroids.getText()));
        showKMeansChart();
        jTextError.setText(String.valueOf(clusteringAlgorithm.getError()));
    }//GEN-LAST:event_jButtonShowChartActionPerformed

    private void jButtonNextIterationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonNextIterationActionPerformed
        clusteringAlgorithm.moveCentroids();
        showKMeansChart();
        jTextError.setText(ChartWorker.df.format(clusteringAlgorithm.getError()));
    }//GEN-LAST:event_jButtonNextIterationActionPerformed

    private void jButtonPlayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPlayActionPerformed
        if (chartWorker != null) {
            chartWorker.cancel(true);
        }
        chartWorker = new ChartWorker(jPanelChart, jPanelVoronoi, jTextError, jProgressBar1, clusteringAlgorithm,
                jCheckAnimate.isSelected(), Integer.parseInt(jTextFrameDuration.getText()));
        chartWorker.execute();
    }//GEN-LAST:event_jButtonPlayActionPerformed

    private void jButtonStopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonStopActionPerformed
        if (chartWorker != null) {
            chartWorker.cancel(true);
        }
    }//GEN-LAST:event_jButtonStopActionPerformed

    private void jButtonChooseKmeansActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonChooseKmeansActionPerformed
        try {
            clusteringAlgorithm = new KmeansClustering(new EuclidianDistance(), helper.getData(),
                    Integer.parseInt(jTextCentroids.getText()), Integer.parseInt(jTextIterations.getText()));
            jProgressBar1.setMaximum(Integer.parseInt(jTextIterations.getText()));
            jLabelAlgorithm.setText("k-rednich");
            switchRunButtons(true);
        } catch (NoFileException ex) {
            switchChoiceButtons(false);
            switchRunButtons(false);
        }
    }//GEN-LAST:event_jButtonChooseKmeansActionPerformed

    private void jButtonChooseNeuralGasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonChooseNeuralGasActionPerformed
        try {
            gatherParameters(evt.getActionCommand());
            clusteringAlgorithm = new NeuralGasClustering(new EuclidianDistance(), helper.getData(),
                    Integer.parseInt(jTextCentroids.getText()), Integer.parseInt(jTextIterations.getText()),
                    helper.getSOMParameters());
            jProgressBar1.setMaximum(Integer.parseInt(jTextIterations.getText()));
            jLabelAlgorithm.setText("gazu neuronowego");
            switchRunButtons(true);
        } catch (NoFileException ex) {
            switchChoiceButtons(false);
            switchRunButtons(false);
        } catch (GUIHelper.NoParamsException ex) {
            switchRunButtons(false);
            Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButtonChooseNeuralGasActionPerformed

    private void jButtonChangeDataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonChangeDataActionPerformed
        helper.insertData(clusteringAlgorithm.getCentroids());
    }//GEN-LAST:event_jButtonChangeDataActionPerformed

    private void jButtonChooseKohonenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonChooseKohonenActionPerformed
        try {
            gatherParameters(evt.getActionCommand());
            clusteringAlgorithm = new KohonenClustering(new EuclidianDistance(), helper.getData(),
                    Integer.parseInt(jTextCentroids.getText()), Integer.parseInt(jTextIterations.getText()),
                    helper.getSOMParameters(), ((jComboBox1.getSelectedIndex()) != 1));
            jProgressBar1.setMaximum(Integer.parseInt(jTextIterations.getText()));
            jLabelAlgorithm.setText("Kohonena");
            switchRunButtons(true);
        } catch (NoFileException ex) {
            switchChoiceButtons(false);
            switchRunButtons(false);
        } catch (GUIHelper.NoParamsException ex) {
            switchRunButtons(false);
            Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButtonChooseKohonenActionPerformed

    private void jTextNeuLambdaMaxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextNeuLambdaMaxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextNeuLambdaMaxActionPerformed

    private void jTextNeuEtaMaxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextNeuEtaMaxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextNeuEtaMaxActionPerformed

    private void showKMeansChart() {
        jPanelChart.removeAll();
        ChartPanel chartPanel = new ChartPanel(
                Charts.getKmeansChart(clusteringAlgorithm.getData(), clusteringAlgorithm.getCentroids()));
        chartPanel.setPreferredSize(new Dimension(600, 600));
        chartPanel.setDomainZoomable(true);
        jPanelChart.setLayout(new java.awt.BorderLayout());
        jPanelChart.add(chartPanel, BorderLayout.CENTER);
        jPanelChart.validate();
    }

    private void switchChoiceButtons(boolean b) {
        jButtonChooseKmeans.setEnabled(b);
        jButtonChooseKohonen.setEnabled(b);
        jButtonChooseNeuralGas.setEnabled(b);
    }

    private void switchRunButtons(boolean b) {
        jButtonShowChart.setEnabled(b);
        jButtonNextIteration.setEnabled(b);
        jButtonPlay.setEnabled(b);
        jButtonStop.setEnabled(b);
        jButtonChangeData.setEnabled(b);
    }

    private void gatherParameters(String algorithm) {
        switch (algorithm) {
        case "kohonen":
            helper.setSOMParameters(Double.parseDouble(jTextKohLambdaMax.getText()),
                    Double.parseDouble(jTextKohLambdaMin.getText()), Double.parseDouble(jTextKohEtaMax.getText()),
                    Double.parseDouble(jTextKohEtaMin.getText()));
            break;
        case "neuralgas":
            helper.setSOMParameters(Double.parseDouble(jTextNeuLambdaMax.getText()),
                    Double.parseDouble(jTextNeuLambdaMin.getText()), Double.parseDouble(jTextNeuEtaMax.getText()),
                    Double.parseDouble(jTextNeuEtaMin.getText()));
            break;
        }
    }

    private static void initLookAndFeel() {
        String lookAndFeel = null;
        lookAndFeel = UIManager.getSystemLookAndFeelClassName();
        try {
            UIManager.setLookAndFeel(lookAndFeel);
        } catch (ClassNotFoundException | UnsupportedLookAndFeelException e) {
        } catch (Exception e) {
            //TODO :)
        }
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonChangeData;
    private javax.swing.JButton jButtonChooseKmeans;
    private javax.swing.JButton jButtonChooseKohonen;
    private javax.swing.JButton jButtonChooseNeuralGas;
    private javax.swing.JButton jButtonLoadFile;
    private javax.swing.JButton jButtonNextIteration;
    private javax.swing.JButton jButtonPlay;
    private javax.swing.JButton jButtonShowChart;
    private javax.swing.JButton jButtonStop;
    private javax.swing.JCheckBox jCheckAnimate;
    private javax.swing.JComboBox<String> jComboBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLabelAlgorithm;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanelChart;
    private javax.swing.JPanel jPanelVoronoi;
    private javax.swing.JProgressBar jProgressBar1;
    private javax.swing.JTabbedPane jTabbedPane;
    private javax.swing.JTextField jTextCentroids;
    private javax.swing.JTextField jTextError;
    private javax.swing.JTextField jTextFrameDuration;
    private javax.swing.JTextField jTextIterations;
    private javax.swing.JTextField jTextKohEtaMax;
    private javax.swing.JTextField jTextKohEtaMin;
    private javax.swing.JTextField jTextKohLambdaMax;
    private javax.swing.JTextField jTextKohLambdaMin;
    private javax.swing.JTextField jTextNeuEtaMax;
    private javax.swing.JTextField jTextNeuEtaMin;
    private javax.swing.JTextField jTextNeuLambdaMax;
    private javax.swing.JTextField jTextNeuLambdaMin;
    // End of variables declaration//GEN-END:variables

}