gui_pack.MainGui.java Source code

Java tutorial

Introduction

Here is the source code for gui_pack.MainGui.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 gui_pack;

import javax.swing.JOptionPane;
import list_manager.ListGenerator;
import comparison_sort.*;
import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JProgressBar;
import javax.swing.SwingWorker;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;

/*
 * @exclude
 * This is the main gui for Sort Explorer, by David Wagner
 *
 * The gui layout was designed using NetBeans GUI Generator (formerly project matisse)
 * Netbeans is available for download at https://netbeans.org/
 *
 * The graphs were designed using jFreeChart jFreeChart is available for
 * download at http://www.jfree.org/jfreechart/
 *
 * @author David Wagner
 */
public class MainGui extends javax.swing.JFrame {

    /*
     * Creates new form PrimaryGui
     */
    ComparisonSort insertionSort = new InsertionSort();
    ComparisonSort mergeSort = new MergeSort();
    ComparisonSort quickSort = new QuickSort();
    ComparisonSort selectionSort = new SelectionSort();

    //String descriptions for the user to read in the about section
    String maximumSizeAbout = "The 'Maximum Size' field describes the largest possible size"
            + " of list to be sorted in a set of tests. For example, if maximum"
            + " size is set to 15, minimum size is set to 5 and intervals is set to "
            + "5 then lists containing 5, 10, and 15 elements will be sorted";
    String minimumSizeAbout = "The 'Minimum Size' field describes the smallest size"
            + " list that will be sorted in a set of tests. For example, if minimum"
            + " size is set to 5, maximum size is set to 15 and intervals is set to "
            + "5 then lists containing 5, 10, and 15 elements will be sorted.";
    String intervalsAbout = "The 'Intervals' field describes the distance between"
            + " various sizes of lists in tests conducted. For example, if intervals"
            + " is set to 5, minimum size is set to 5 and maximum size is set to "
            + "15 then lists containing 5, 10, and 15 elements will be sorted.";
    String includeRandomAbout = "The 'include random' checkbox, if selected, "
            + "indicates that the sort tests should be conducted on randomly ordered"
            + " lists. This may be useful for depicting about where the average case" + " of some algorithms fall.";
    String iterationsAbout = "The 'iterations' value describes how many randomly "
            + "ordered lists should be included for each interval in the set of " + "lists to be sorted. ";
    String includeAscendingAbout = "The 'Include Ascending' checkbox, if selected, "
            + "indicates that the sort tests should be conducted on already sorted"
            + " lists. This may be useful for depicting the best or worst cases of some " + "algorithms";
    String includeDescendingAbout = "The 'Include Ascending' checkbox, if selected, "
            + "indicates that the sort tests should be conducted on reverse-ordered"
            + " lists. This may be useful for depicting the worst cases of some " + "algorithms";

    public MainGui() {

        initComponents();
        iterationField.setEnabled(false);
        iterationField.setText("0");
        iterationLabel.setEnabled(false);
    }

    /**
     * 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() {

        Header = new javax.swing.JLabel();
        insertionCheckBox = new javax.swing.JCheckBox();
        mergeCheckBox = new javax.swing.JCheckBox();
        quickCheckBox = new javax.swing.JCheckBox();
        selectionCheckBox = new javax.swing.JCheckBox();
        iterationLabel = new javax.swing.JLabel();
        rangeMinLabel = new javax.swing.JLabel();
        rangeMaxLabel = new javax.swing.JLabel();
        spacingLabel = new javax.swing.JLabel();
        ascendingCheckBox = new javax.swing.JCheckBox();
        descendingCheckBox = new javax.swing.JCheckBox();
        iterationField = new javax.swing.JTextField();
        rangeMinField = new javax.swing.JTextField();
        rangeMaxField = new javax.swing.JTextField();
        spacingField = new javax.swing.JTextField();
        exitButton = new javax.swing.JButton();
        runTestsButton = new javax.swing.JButton();
        insertionAboutButton = new javax.swing.JButton();
        mergeAboutButton = new javax.swing.JButton();
        quickAboutButton = new javax.swing.JButton();
        selectionAboutButton = new javax.swing.JButton();
        iterationAboutButton = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        rangeMinAboutButton = new javax.swing.JButton();
        jSeparator2 = new javax.swing.JSeparator();
        rangeMaxAboutButton = new javax.swing.JButton();
        intervalsAboutButton = new javax.swing.JButton();
        ascendingAboutButton = new javax.swing.JButton();
        descendingAboutButton = new javax.swing.JButton();
        authorLabel = new javax.swing.JLabel();
        randomCheckBox = new javax.swing.JCheckBox();
        randomAboutButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        Header.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        Header.setText("Sort Explorer");

        insertionCheckBox.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        insertionCheckBox.setText("Insertion Sort");
        insertionCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                insertionCheckBoxActionPerformed(evt);
            }
        });

        mergeCheckBox.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        mergeCheckBox.setText("Merge Sort");
        mergeCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mergeCheckBoxActionPerformed(evt);
            }
        });

        quickCheckBox.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        quickCheckBox.setText("Quick Sort");

        selectionCheckBox.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        selectionCheckBox.setText("Selection Sort");

        iterationLabel.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        iterationLabel.setText("Iterations");

        rangeMinLabel.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        rangeMinLabel.setText("Minimum size");

        rangeMaxLabel.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        rangeMaxLabel.setText("Maximum size");

        spacingLabel.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        spacingLabel.setText("Intervals");

        ascendingCheckBox.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        ascendingCheckBox.setText("Include Ascending Order");
        ascendingCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ascendingCheckBoxActionPerformed(evt);
            }
        });

        descendingCheckBox.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        descendingCheckBox.setText("Include Descending Order");
        descendingCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                descendingCheckBoxActionPerformed(evt);
            }
        });

        iterationField.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        iterationField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                iterationFieldActionPerformed(evt);
            }
        });

        rangeMinField.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        rangeMinField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rangeMinFieldActionPerformed(evt);
            }
        });

        rangeMaxField.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        rangeMaxField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rangeMaxFieldActionPerformed(evt);
            }
        });

        spacingField.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        spacingField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                spacingFieldActionPerformed(evt);
            }
        });

        exitButton.setText("Exit");
        exitButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitButtonActionPerformed(evt);
            }
        });

        runTestsButton.setText("Run Tests");
        runTestsButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                runTestsButtonActionPerformed(evt);
            }
        });

        insertionAboutButton.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        insertionAboutButton.setText("About");
        insertionAboutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                insertionAboutButtonActionPerformed(evt);
            }
        });

        mergeAboutButton.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        mergeAboutButton.setText("About");
        mergeAboutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mergeAboutButtonActionPerformed(evt);
            }
        });

        quickAboutButton.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        quickAboutButton.setText("About");
        quickAboutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                quickAboutButtonActionPerformed(evt);
            }
        });

        selectionAboutButton.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        selectionAboutButton.setText("About");
        selectionAboutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                selectionAboutButtonActionPerformed(evt);
            }
        });

        iterationAboutButton.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        iterationAboutButton.setText("About");
        iterationAboutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                iterationAboutButtonActionPerformed(evt);
            }
        });

        rangeMinAboutButton.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        rangeMinAboutButton.setText("About");
        rangeMinAboutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rangeMinAboutButtonActionPerformed(evt);
            }
        });

        rangeMaxAboutButton.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        rangeMaxAboutButton.setText("About");
        rangeMaxAboutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rangeMaxAboutButtonActionPerformed(evt);
            }
        });

        intervalsAboutButton.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        intervalsAboutButton.setText("About");
        intervalsAboutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                intervalsAboutButtonActionPerformed(evt);
            }
        });

        ascendingAboutButton.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        ascendingAboutButton.setText("About");
        ascendingAboutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ascendingAboutButtonActionPerformed(evt);
            }
        });

        descendingAboutButton.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        descendingAboutButton.setText("About");
        descendingAboutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                descendingAboutButtonActionPerformed(evt);
            }
        });

        authorLabel.setText("By Dave Wagner");

        randomCheckBox.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        randomCheckBox.setText("Include Random Order");
        randomCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                randomCheckBoxActionPerformed(evt);
            }
        });

        randomAboutButton.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        randomAboutButton.setText("About");
        randomAboutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                randomAboutButtonActionPerformed(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().addGap(20, 20, 20).addComponent(Header)
                                .addGap(18, 18, 18).addComponent(authorLabel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGroup(layout.createSequentialGroup().addGap(10, 10, 10).addComponent(jSeparator1,
                                javax.swing.GroupLayout.PREFERRED_SIZE, 269,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createSequentialGroup().addContainerGap()
                                .addComponent(exitButton, javax.swing.GroupLayout.PREFERRED_SIZE, 133,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(runTestsButton, javax.swing.GroupLayout.PREFERRED_SIZE, 129,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createSequentialGroup().addGap(10, 10, 10).addGroup(layout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup().addGroup(layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(quickCheckBox).addComponent(mergeCheckBox)
                                        .addComponent(insertionCheckBox).addComponent(selectionCheckBox)
                                        .addGroup(layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                                        false)
                                                .addGroup(layout.createSequentialGroup().addGroup(layout
                                                        .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                        .addGroup(layout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.TRAILING,
                                                                        false)
                                                                .addComponent(rangeMinLabel,
                                                                        javax.swing.GroupLayout.Alignment.LEADING,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        Short.MAX_VALUE)
                                                                .addComponent(rangeMaxLabel,
                                                                        javax.swing.GroupLayout.Alignment.LEADING))
                                                        .addComponent(spacingLabel,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE, 80,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addComponent(iterationLabel,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE, 80,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                        .addGroup(layout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                                .addComponent(rangeMinField,
                                                                        javax.swing.GroupLayout.Alignment.TRAILING)
                                                                .addComponent(rangeMaxField,
                                                                        javax.swing.GroupLayout.Alignment.TRAILING)
                                                                .addComponent(spacingField,
                                                                        javax.swing.GroupLayout.Alignment.TRAILING)
                                                                .addComponent(iterationField,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE, 117,
                                                                        Short.MAX_VALUE)))
                                                .addComponent(descendingCheckBox))
                                        .addComponent(ascendingCheckBox).addComponent(randomCheckBox,
                                                javax.swing.GroupLayout.PREFERRED_SIZE, 166,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addGroup(layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                                        false)
                                                .addComponent(selectionAboutButton,
                                                        javax.swing.GroupLayout.Alignment.TRAILING,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(quickAboutButton,
                                                        javax.swing.GroupLayout.Alignment.TRAILING,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(mergeAboutButton,
                                                        javax.swing.GroupLayout.Alignment.TRAILING,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(insertionAboutButton,
                                                        javax.swing.GroupLayout.Alignment.TRAILING,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(intervalsAboutButton,
                                                        javax.swing.GroupLayout.Alignment.TRAILING,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(rangeMaxAboutButton,
                                                        javax.swing.GroupLayout.Alignment.TRAILING,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(rangeMinAboutButton,
                                                        javax.swing.GroupLayout.Alignment.TRAILING,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(ascendingAboutButton,
                                                        javax.swing.GroupLayout.Alignment.TRAILING,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(iterationAboutButton,
                                                        javax.swing.GroupLayout.Alignment.TRAILING,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(randomAboutButton,
                                                        javax.swing.GroupLayout.Alignment.TRAILING,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(descendingAboutButton,
                                                        javax.swing.GroupLayout.Alignment.TRAILING,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 262,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addContainerGap()));

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
                new java.awt.Component[] { exitButton, runTestsButton });

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
                new java.awt.Component[] { jSeparator1, jSeparator2 });

        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                javax.swing.GroupLayout.Alignment.TRAILING,
                layout.createSequentialGroup().addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(Header).addComponent(authorLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(insertionCheckBox).addComponent(insertionAboutButton))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(mergeCheckBox).addComponent(mergeAboutButton))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(quickCheckBox).addComponent(quickAboutButton))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(selectionCheckBox).addComponent(selectionAboutButton))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(2, 2, 2)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(rangeMinLabel)
                                .addComponent(rangeMinField, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(rangeMinAboutButton))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(rangeMaxLabel)
                                        .addComponent(rangeMaxField, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(rangeMaxAboutButton))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(spacingField, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(spacingLabel))
                                .addComponent(intervalsAboutButton))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(randomAboutButton).addComponent(randomCheckBox))
                        .addGap(6, 6, 6)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(iterationAboutButton)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(iterationField, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(iterationLabel)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(ascendingAboutButton).addComponent(ascendingCheckBox))
                        .addGap(4, 4, 4)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(descendingAboutButton).addComponent(descendingCheckBox))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(exitButton, javax.swing.GroupLayout.PREFERRED_SIZE, 32,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(runTestsButton))
                        .addContainerGap(15, Short.MAX_VALUE)));

        layout.linkSize(javax.swing.SwingConstants.VERTICAL,
                new java.awt.Component[] { iterationField, rangeMaxField, rangeMinField, spacingField });

        layout.linkSize(javax.swing.SwingConstants.VERTICAL,
                new java.awt.Component[] { exitButton, runTestsButton });

        layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] { jSeparator1, jSeparator2 });

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

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

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

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

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

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

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

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

    private void exitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitButtonActionPerformed
        // TODO add your handling code here:
        System.exit(0);
    }//GEN-LAST:event_exitButtonActionPerformed

    private void iterationAboutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_iterationAboutButtonActionPerformed
        AboutFrame abouter = new AboutFrame();
        abouter.SetText(iterationsAbout);
        abouter.setTitle("About 'Iterations' Field");
        abouter.setVisible(true);
    }//GEN-LAST:event_iterationAboutButtonActionPerformed

    private void insertionAboutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_insertionAboutButtonActionPerformed
        AboutFrame abouter = new AboutFrame();
        abouter.SetText(insertionSort.about());
        abouter.setTitle("About 'Insertion Sort'");
        abouter.setVisible(true);
    }//GEN-LAST:event_insertionAboutButtonActionPerformed

    private void rangeMaxAboutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rangeMaxAboutButtonActionPerformed
        AboutFrame abouter = new AboutFrame();
        abouter.SetText(maximumSizeAbout);
        abouter.setTitle("About 'Maximum Size' Field");
        abouter.setVisible(true);
    }//GEN-LAST:event_rangeMaxAboutButtonActionPerformed

    private void ascendingAboutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ascendingAboutButtonActionPerformed
        AboutFrame abouter = new AboutFrame();
        abouter.SetText(includeAscendingAbout);
        abouter.setTitle("About 'Include Ascending Order' Checkbox");
        abouter.setVisible(true);
    }//GEN-LAST:event_ascendingAboutButtonActionPerformed

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

    private void descendingAboutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_descendingAboutButtonActionPerformed
        AboutFrame abouter = new AboutFrame();
        abouter.SetText(includeDescendingAbout);
        abouter.setTitle("About 'Include Descending Order' Checkbox");
        abouter.setVisible(true);
    }//GEN-LAST:event_descendingAboutButtonActionPerformed

    private void runTestsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_runTestsButtonActionPerformed
        int rangeMin, rangeMax, spacing;
        int passing = 0;

        {//  Beginning of input validation
            String errorTitle, errorMessage;

            //make sure at least one sort algorithm is selected
            if (!(insertionCheckBox.isSelected() || mergeCheckBox.isSelected() || quickCheckBox.isSelected()
                    || selectionCheckBox.isSelected())) {
                errorTitle = "Selection Error";
                errorMessage = "At least one sort algorithm (Insertion Sort, "
                        + "Merge Sort, Quick Sort, or Selection Sort) must be selected.";
                JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.WARNING_MESSAGE);
                return;
            }

            //make sure at least one order is selected
            if (!(ascendingCheckBox.isSelected() || descendingCheckBox.isSelected()
                    || randomCheckBox.isSelected())) {
                errorTitle = "Selection Error";
                errorMessage = "At least one order (Ascending Order, Descending Order, or Random Order) "
                        + "must be selected.";
                JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.WARNING_MESSAGE);
                return;
            }

            //make sure all the proper fields contain data
            try {
                rangeMin = Integer.parseInt(rangeMinField.getText());
                rangeMax = Integer.parseInt(rangeMaxField.getText());
                spacing = Integer.parseInt(spacingField.getText());
                //for the multithreaded version of this program "iterations" cannot be a variable
                //this was left in to catch if the iteration field is left blank or has no value
                if (iterationField.isEnabled()) {
                    Integer.parseInt(iterationField.getText());
                }
            } catch (NumberFormatException arbitraryName) {
                errorTitle = "Input Error";
                if (iterationField.isEnabled()) {
                    errorMessage = "The size, intervals, and iterations fields must contain "
                            + "integer values and only integer values.";
                } else {
                    errorMessage = "The size and intervals fields must contain "
                            + "integer values and only integer values.";
                }
                JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.WARNING_MESSAGE);
                return;
            }

            //make sure field data is appropriate
            if (rangeMin > rangeMax) {
                errorTitle = "Range Error";
                errorMessage = "Minimum Size must be less than or equal to Maximum Size.";
                JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.WARNING_MESSAGE);
                return;
            }

            if (spacing < 1 || rangeMin < 1 || rangeMax < 1
                    || (iterationField.isEnabled() && Integer.parseInt(iterationField.getText()) < 1)) {
                errorTitle = "Value Error";
                if (iterationField.isEnabled()) {
                    errorMessage = "Intervals, sizes, and iterations must be in the positive domain. "
                            + "Spacing, Range(min), Range(max), and Iterations must be greater than or"
                            + " equal to one.";
                } else {
                    errorMessage = "Intervals and sizes must be in the positive domain. "
                            + "Spacing, Range(min) and Range(max) be greater than or" + " equal to one.";
                }
                JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.WARNING_MESSAGE);
                return;
            }

            if (!iterationField.isEnabled()) {
                passing = 0;
            }

        } // End of input validation

        //here's where we set up a loading bar in case the tests take a while
        JProgressBar loadBar = new JProgressBar();
        JFrame loadFrame = new JFrame();
        JLabel displayLabel1 = new JLabel();
        loadBar.setIndeterminate(true);
        loadBar.setVisible(true);
        displayLabel1.setText("Running large tests, or many tests, using inefficient algorithms \n"
                + "may take a while. Please be patient.");
        loadFrame.setLayout(new FlowLayout());
        loadFrame.add(loadBar);
        loadFrame.add(displayLabel1);
        loadFrame.setSize(600, 100);
        loadFrame.setTitle("Loading");
        loadFrame.setVisible(true);

        //now we will leave this open until the tests are completed
        //now we can conduct the actual tests
        SwingWorker worker = new SwingWorker<XYSeriesCollection, Void>() {
            XYSeriesCollection results = new XYSeriesCollection();

            @Override
            protected XYSeriesCollection doInBackground() {
                XYSeries insertSeries = new XYSeries("Insertion Sort");
                XYSeries mergeSeries = new XYSeries("Merge Sort");
                XYSeries quickSeries = new XYSeries("Quick Sort");
                XYSeries selectSeries = new XYSeries("Selection Sort");

                final boolean ascending = ascendingCheckBox.isSelected();
                final boolean descending = descendingCheckBox.isSelected();
                final boolean insertion = insertionCheckBox.isSelected();
                final boolean merge = mergeCheckBox.isSelected();
                final boolean quick = quickCheckBox.isSelected();
                final boolean selection = selectionCheckBox.isSelected();

                final int iterations = Integer.parseInt(iterationField.getText());

                ListGenerator generator = new ListGenerator();
                int[] list;
                for (int count = rangeMin; count <= rangeMax; count = count + spacing) {

                    if (ascending) {

                        list = generator.ascending(count);
                        if (insertion) {
                            insertSeries.add(count, insertionSort.sort(list));
                        }
                        if (merge) {
                            mergeSeries.add(count, mergeSort.sort(list));
                        }
                        if (quick) {
                            quickSeries.add(count, quickSort.sort(list));
                        }
                        if (selection) {
                            selectSeries.add(count, selectionSort.sort(list));
                        }
                    }
                    if (descending) {

                        list = generator.descending(count);
                        if (insertion) {
                            insertSeries.add(count, insertionSort.sort(list));
                        }
                        if (merge) {
                            mergeSeries.add(count, mergeSort.sort(list));
                        }
                        if (quick) {
                            quickSeries.add(count, quickSort.sort(list));
                        }
                        if (selection) {
                            selectSeries.add(count, selectionSort.sort(list));
                        }
                    }

                    for (int iteration = 0; iteration < iterations; iteration++) {
                        list = generator.random(count);

                        if (insertion) {
                            insertSeries.add(count, insertionSort.sort(list));
                        }
                        if (merge) {
                            mergeSeries.add(count, mergeSort.sort(list));
                        }
                        if (quick) {
                            quickSeries.add(count, quickSort.sort(list));
                        }
                        if (selection) {
                            selectSeries.add(count, selectionSort.sort(list));
                        }
                    }

                }

                //now we aggregate the results
                if (insertion) {
                    results.addSeries(insertSeries);
                }
                if (merge) {
                    results.addSeries(mergeSeries);
                }
                if (quick) {
                    results.addSeries(quickSeries);
                }
                if (selection) {
                    results.addSeries(selectSeries);
                }
                return results;
            }

            @Override
            protected void done() {
                //finally, we display the results
                JFreeChart chart = ChartFactory.createScatterPlot("SortExplorer", // chart title
                        "List Size", // x axis label
                        "Number of Comparisons", // y axis label
                        results, // data  
                        PlotOrientation.VERTICAL, true, // include legend
                        true, // tooltips
                        false // urls
                );
                ChartFrame frame = new ChartFrame("First", chart);
                frame.pack();
                frame.setVisible(true);
                loadFrame.setVisible(false);
            }
        };

        //having set up the multithreading 'worker' we can finally conduct the 
        //test
        worker.execute();

    }//GEN-LAST:event_runTestsButtonActionPerformed

    private void randomCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_randomCheckBoxActionPerformed
        //we want to toggle the iteration gui objects such that they are only
        //be useable when the user is testing randomly ordered lists
        iterationField.setEnabled(!iterationField.isEnabled());
        iterationLabel.setEnabled(!iterationLabel.isEnabled());
        if (!iterationField.isEnabled()) {
            iterationField.setText("0");
        } else {
            iterationField.setText("");
        }
    }//GEN-LAST:event_randomCheckBoxActionPerformed

    private void selectionAboutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectionAboutButtonActionPerformed
        AboutFrame abouter = new AboutFrame();
        abouter.SetText(selectionSort.about());
        abouter.setTitle("About 'Selection Sort'");
        abouter.setVisible(true);
    }//GEN-LAST:event_selectionAboutButtonActionPerformed

    private void intervalsAboutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_intervalsAboutButtonActionPerformed
        AboutFrame abouter = new AboutFrame();
        abouter.SetText(intervalsAbout);
        abouter.setTitle("About 'Intervals' Field");
        abouter.setVisible(true);
    }//GEN-LAST:event_intervalsAboutButtonActionPerformed

    private void rangeMinAboutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rangeMinAboutButtonActionPerformed
        AboutFrame abouter = new AboutFrame();
        abouter.SetText(minimumSizeAbout);
        abouter.setTitle("About 'Minimum Size' Field");
        abouter.setVisible(true);
    }//GEN-LAST:event_rangeMinAboutButtonActionPerformed

    private void randomAboutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_randomAboutButtonActionPerformed
        AboutFrame abouter = new AboutFrame();
        abouter.SetText(includeRandomAbout);
        abouter.setTitle("About 'Include Random Order' Checkbox");
        abouter.setVisible(true);
    }//GEN-LAST:event_randomAboutButtonActionPerformed

    private void mergeAboutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mergeAboutButtonActionPerformed
        AboutFrame abouter = new AboutFrame();
        abouter.SetText(mergeSort.about());
        abouter.setTitle("About 'Merge Sort'");
        abouter.setVisible(true);
    }//GEN-LAST:event_mergeAboutButtonActionPerformed

    private void quickAboutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_quickAboutButtonActionPerformed
        AboutFrame abouter = new AboutFrame();
        abouter.SetText(quickSort.about());
        abouter.setTitle("About 'Quick Sort'");
        abouter.setVisible(true);
    }//GEN-LAST:event_quickAboutButtonActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
                | javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MainGui.class.getName()).log(java.util.logging.Level.SEVERE, null,
                    ex);
        }
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>

        //</editor-fold>
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MainGui().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel Header;
    private javax.swing.JButton ascendingAboutButton;
    private javax.swing.JCheckBox ascendingCheckBox;
    private javax.swing.JLabel authorLabel;
    private javax.swing.JButton descendingAboutButton;
    private javax.swing.JCheckBox descendingCheckBox;
    private javax.swing.JButton exitButton;
    private javax.swing.JButton insertionAboutButton;
    private javax.swing.JCheckBox insertionCheckBox;
    private javax.swing.JButton intervalsAboutButton;
    private javax.swing.JButton iterationAboutButton;
    private javax.swing.JTextField iterationField;
    private javax.swing.JLabel iterationLabel;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JButton mergeAboutButton;
    private javax.swing.JCheckBox mergeCheckBox;
    private javax.swing.JButton quickAboutButton;
    private javax.swing.JCheckBox quickCheckBox;
    private javax.swing.JButton randomAboutButton;
    private javax.swing.JCheckBox randomCheckBox;
    private javax.swing.JButton rangeMaxAboutButton;
    private javax.swing.JTextField rangeMaxField;
    private javax.swing.JLabel rangeMaxLabel;
    private javax.swing.JButton rangeMinAboutButton;
    private javax.swing.JTextField rangeMinField;
    private javax.swing.JLabel rangeMinLabel;
    private javax.swing.JButton runTestsButton;
    private javax.swing.JButton selectionAboutButton;
    private javax.swing.JCheckBox selectionCheckBox;
    private javax.swing.JTextField spacingField;
    private javax.swing.JLabel spacingLabel;
    // End of variables declaration//GEN-END:variables
}