/**
 * Frame for the Individual Incident Editor.
 *
 * @author Bryan McGuffin
 * @version 2017/08/08
 */
package scriptbuilder.gui;

import java.awt.Adjustable;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Observable;
import java.util.Observer;
import java.util.Properties;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import scriptbuilder.gui.panels.IncidentTimelinePanel;
import scriptbuilder.structures.ScriptEvent;
import scriptbuilder.structures.ScriptEvent.ScriptEventType;
import scriptbuilder.structures.ScriptIncident;
import scriptbuilder.structures.ScriptIncident.IncidentFocusedEvent;
import scriptbuilder.structures.ScriptIncident.SliceChangedEvent;
import scriptbuilder.structures.TimeSlice;
import scriptbuilder.structures.events.I_ScriptEvent;

/**
 * GUI for the script builder. Contains all panels and editor elements. Performs
 * updates to reflect script model, which it observes.
 *
 * @author Greg Eddington
 * @author Bryan McGuffin
 */
public class IncidentEditorFrame extends javax.swing.JFrame implements Observer
{

    /**
     * The script incident currently being edited.
     */
    private ScriptIncident theIncident;

    private ScriptBuilderFrame parent;

    private int savedOffset;

    /**
     * The current type of selected event.
     */
    public ScriptEventType currentEventType;
    /**
     * A list of all the event type buttons.
     */
    private ArrayList<JButton> eventButtons = null;

    /**
     * Get the script currently in use.
     *
     * @return the script model object
     */
    public ScriptIncident getIncident()
    {
        return theIncident;
    }

    /**
     * Listener for the scroll pane.
     */
    class MyAdjustmentListener implements AdjustmentListener
    {

        /**
         * If the incident timeline is scrolled horizontally, the timestamp
         * panel is updated to reflect it.
         *
         * @param evt the adjustment event
         */
        @Override
        public void adjustmentValueChanged(AdjustmentEvent evt)
        {
            if (evt.getAdjustable().getOrientation() == Adjustable.HORIZONTAL)
            {
                timeStampScrollPane.getHorizontalScrollBar()
                        .setValue(timelinesScrollPane.getHorizontalScrollBar().getValue());
                timeStampScrollPane1.getHorizontalScrollBar()
                        .setValue(timelinesScrollPane.getHorizontalScrollBar().getValue());
            }
            else
            {
                // Event from vertical scrollbar
            }

            repaint();
        }
    }

    /**
     * Listener for key presses. Used for hotkeys for different event types.
     */
    private class TimelineKeyListener implements KeyListener
    {

        /**
         * If a hotkey is pressed, select that type of event.
         *
         * @param e the key event
         */
        @Override
        public void keyPressed(KeyEvent e)
        {
            JButton lastButton = null;
            for (JButton eb : eventButtons)
            {
                eb.setFocusPainted(false);
                if (eb.isSelected())
                {
                    lastButton = eb;
                }
                eb.setSelected(false);
            }

            JButton newButton = lastButton;
            switch (e.getKeyChar())
            {
                case 'u':
                    currentEventType = ScriptEventType.AUDIO_EVENT;
                    newButton = audioButton;
                    break;
                case 'c':
                    currentEventType = ScriptEventType.CAD_EVENT;
                    newButton = cadButton;
                    break;
                case 'v':
                    currentEventType = ScriptEventType.CCTV_EVENT;
                    newButton = cctvButton;
                    break;
                case 'h':
                    currentEventType = ScriptEventType.CHP_RADIO_EVENT;
                    newButton = chpRadioButton;
                    break;
                case 'p':
                    currentEventType = ScriptEventType.PARAMICS_EVENT;
                    newButton = paramicsButton;
                    break;
                case 'o':
                    currentEventType = ScriptEventType.TOW_EVENT;
                    newButton = towButton;
                    break;
                case 'n':
                    currentEventType = ScriptEventType.UNIT_EVENT;
                    newButton = unitButton;
                    break;
                case 'w':
                    currentEventType = ScriptEventType.WITNESS_EVENT;
                    newButton = witnessButton;
                    break;
                case 'm':
                    currentEventType = ScriptEventType.MAINTENANCE_RADIO_EVENT;
                    newButton = maintenanceRadioButton;
                    break;
                case 't':
                    currentEventType = ScriptEventType.TMT_RADIO_EVENT;
                    newButton = tmtRadioButton;
                    break;
                case 'e':
                    currentEventType = ScriptEventType.TELEPHONE_EVENT;
                    newButton = telephoneButton;
                    break;
                case 'a':
                    currentEventType = ScriptEventType.ATMS_EVAL_EVENT;
                    newButton = atmsEvalButton;
                    break;
                case 'l':
                    currentEventType = ScriptEventType.ACTIVITY_LOG_EVAL_EVENT;
                    newButton = activityLogEvalButton;
                    break;
                case 'd':
                    currentEventType = ScriptEventType.CAD_EVAL_EVENT;
                    newButton = cadEvalButton;
                    break;
                case 's':
                    currentEventType = ScriptEventType.CMS_EVAL_EVENT;
                    newButton = cmsEvalButton;
                    break;
                case 'f':
                    currentEventType = ScriptEventType.FACILITATOR_EVAL_EVENT;
                    newButton = facilitatorEvalButton;
                    break;
                case 'r':
                    currentEventType = ScriptEventType.RADIO_EVAL_EVENT;
                    newButton = radioEvalButton;
                    break;
                default:
                    newButton = lastButton;
            }

            if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
            {
                currentEventType = null;
                newButton = selectButton;
            }

            if (newButton != null)
            {
                newButton.setSelected(true);
            }

            repaint();
        }

        /**
         * Take no action upon key release.
         *
         * @param e the key event
         */
        @Override
        public void keyReleased(KeyEvent e)
        {
        }

        /**
         * Take no action upon key release.
         *
         * @param e the key event
         */
        @Override
        public void keyTyped(KeyEvent e)
        {
        }
    }

    /**
     * Constructor. Prep new script model, initialize the GUI, and add listeners
     * for all buttons.
     *
     * @param inc the Script Incident which this window will edit.
     */
    public IncidentEditorFrame(ScriptIncident inc, ScriptBuilderFrame topFrame)
    {
        this.theIncident = inc;
        this.savedOffset = this.theIncident.offset;
        this.theIncident.setOffset(0);
        this.parent = topFrame;
        initComponents();

        absoluteTimeStampPanel.setOffset(savedOffset);
        absoluteTimeStampPanel.setAbsolute(true);
        timelineTickPanel.update(theIncident, incidentTimelinePanel1);
        absoluteTimeStampPanel.update(theIncident, incidentTimelinePanel1);
        relativeTimeStampPanel.update(theIncident, incidentTimelinePanel1);
        incidentTimelinePanel1.timelinePanelUpdate(theIncident);

        incidentNumberPanel1.update(theIncident);
        selectButton.addKeyListener(new TimelineKeyListener());
        cadButton.addKeyListener(new TimelineKeyListener());
        cctvButton.addKeyListener(new TimelineKeyListener());
        chpRadioButton.addKeyListener(new TimelineKeyListener());
        paramicsButton.addKeyListener(new TimelineKeyListener());
        towButton.addKeyListener(new TimelineKeyListener());
        unitButton.addKeyListener(new TimelineKeyListener());
        witnessButton.addKeyListener(new TimelineKeyListener());
        maintenanceRadioButton.addKeyListener(new TimelineKeyListener());
        tmtRadioButton.addKeyListener(new TimelineKeyListener());
        telephoneButton.addKeyListener(new TimelineKeyListener());
        atmsEvalButton.addKeyListener(new TimelineKeyListener());
        activityLogEvalButton.addKeyListener(new TimelineKeyListener());
        cadEvalButton.addKeyListener(new TimelineKeyListener());
        cmsEvalButton.addKeyListener(new TimelineKeyListener());
        facilitatorEvalButton.addKeyListener(new TimelineKeyListener());
        radioEvalButton.addKeyListener(new TimelineKeyListener());

//        // Hack to refresh the zoom
//        zoomSlider.setValue(zoomSlider.getValue() - 1);
//        zoomSlider.setValue(zoomSlider.getValue() + 1);
        // Set listener for scroll pane
        AdjustmentListener listener = new MyAdjustmentListener();
        timelinesScrollPane.getHorizontalScrollBar().addAdjustmentListener(listener);
        timelinesScrollPane.getVerticalScrollBar().addAdjustmentListener(listener);

        // Button list
        eventButtons = new ArrayList<JButton>();
        eventButtons.add(maintenanceRadioButton);
        eventButtons.add(tmtRadioButton);
        eventButtons.add(telephoneButton);
        eventButtons.add(paramicsButton);
        eventButtons.add(towButton);
        eventButtons.add(witnessButton);
        eventButtons.add(unitButton);
        eventButtons.add(audioButton);
        eventButtons.add(cadButton);
        eventButtons.add(cctvButton);
        eventButtons.add(chpRadioButton);
        eventButtons.add(selectButton);
        eventButtons.add(cmsEvalButton);
        eventButtons.add(atmsEvalButton);
        eventButtons.add(cadEvalButton);
        eventButtons.add(activityLogEvalButton);
        eventButtons.add(facilitatorEvalButton);
        eventButtons.add(radioEvalButton);

        this.addWindowListener(new WindowAdapter()
        {
            @Override
            public void windowClosing(WindowEvent e)
            {
                //Add previous offset back in
                //If we didn't adjust the offset, this will just set it to the old value
                //If we deleted the first event(s), this will add the offsets,
                //to ensure that events stay at the correct times
                theIncident.setOffset(theIncident.offset + savedOffset);
                parent.returnFocus();
            }
        });

        incidentNumber.setText("" + this.theIncident.number);
        incidentName.setText("" + this.theIncident.name);
        incidentDescription.setText("" + this.theIncident.description);
        zoomSlider.setValue(zoomSlider.getMinimum());
        this.update(null, this.theIncident);
    }

    /**
     * Update the GUI to reflect the model. If the script changed, update all
     * the incident panels. If a timeslice changed, add any new events to the
     * model. If an incident gained focus, update the incident info screen to
     * display its details.
     *
     * @param o The observed object
     * @param arg Either the script model or an incident event, depending on who
     * called this update
     */
    @Override
    public void update(Observable o, Object arg)
    {
        //Three possibilities: This is a general script update, or it's one of
        //two different focus updates
        if (arg instanceof ScriptIncident)
        {
            theIncident = (ScriptIncident) arg;

            //Update the appropriate panels
            timelineTickPanel.update(theIncident, incidentTimelinePanel1);
            absoluteTimeStampPanel.update(theIncident, incidentTimelinePanel1);
            relativeTimeStampPanel.update(theIncident, incidentTimelinePanel1);

            incidentTimelinePanel1.timelinePanelUpdate(theIncident);

            incidentNumberPanel1.update(theIncident);

            /**
             * DefaultComboBoxModel model = new DefaultComboBoxModel(); for
             * (ScriptIncident i : script.incidents) { if (i != null)
             * model.addElement(i); } gotoIncident.setModel(model);*
             */
            this.setPreferredSize(this.getSize());
            pack();
        }
        //A new timeslice has gained focus
        else if (arg instanceof SliceChangedEvent)
        {
            TimeSlice slice = ((SliceChangedEvent) arg).slice;

            //Put the relevant slice's events into a list
            DefaultListModel model = new DefaultListModel();
            for (I_ScriptEvent e : slice.events)
            {
                model.addElement(e);
            }
            scriptEventsList.setModel(model);
        }
        //A new incident has gained focus
        //This really should only be called upon instantiaton of the window 
        else if (arg instanceof IncidentFocusedEvent)
        {
            ScriptIncident i = ((IncidentFocusedEvent) arg).incident;

            //Put the incident's data in the incident description area
            incidentNumber.setText(Integer.toString(i.number));
            incidentName.setText(i.name);
            incidentDescription.setText(i.description);

            //gotoIncident.setSelectedItem(i);
        }

        //Regardless of update type, do these things to refresh the window
        //Resize the zoom slider scale so that the most zoomed-out state displays
        //the entire incident on the window
        zoomSlider.setMinimum(((timelineTickPanel.getVisibleRect().width - 20)
                * ScriptBuilderGuiConstants.HORIZONTAL_TICK_RESOLUTION)
                / Math.max(theIncident.length, ScriptBuilderGuiConstants.TICK_TIMELINE_SMALLEST_LENGTH));
        zoomSlider.setMaximum(zoomSlider.getMinimum() + 20);
    }

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

        eventPopupMenu = new javax.swing.JPopupMenu();
        cadEvent = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        radioEvent = new javax.swing.JMenuItem();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenuItem6 = new javax.swing.JMenuItem();
        cadEventFrame = new javax.swing.JFrame();
        jLabel5 = new javax.swing.JLabel();
        radioEventFrame = new javax.swing.JFrame();
        radioTypeLabel = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        radioTypeComboBox = new javax.swing.JComboBox();
        radioMessageScrollPane = new javax.swing.JScrollPane();
        radioMessage = new javax.swing.JTextArea();
        okButton = new javax.swing.JButton();
        cancelButton = new javax.swing.JButton();
        eventListPopupMenu = new javax.swing.JPopupMenu();
        editEventList = new javax.swing.JMenuItem();
        deleteEventList = new javax.swing.JMenuItem();
        addNoiseFrame = new javax.swing.JFrame();
        labelRadioChatter = new javax.swing.JLabel();
        sliderRadioChatter = new javax.swing.JSlider();
        sliderLaneClosures = new javax.swing.JSlider();
        labelLaneClosures = new javax.swing.JLabel();
        sliderTMCAL = new javax.swing.JSlider();
        labelTMCAL = new javax.swing.JLabel();
        labelNoiseDescription = new javax.swing.JTextArea();
        sliderBackgroundNoise = new javax.swing.JSlider();
        labelBackgroundNoise = new javax.swing.JLabel();
        sliderMinorEvents = new javax.swing.JSlider();
        labelMinorEvents = new javax.swing.JLabel();
        btnCancelNoise = new javax.swing.JButton();
        btnGenerateNoise = new javax.swing.JButton();
        labelLeastFreq = new javax.swing.JLabel();
        labelMostFreq = new javax.swing.JLabel();
        timelinesScrollPane = new javax.swing.JScrollPane();
        timelineTickPanel = new scriptbuilder.gui.panels.TimelineTickPanel();
        incidentTimelinePanel1 = new scriptbuilder.gui.panels.IncidentTimelinePanel(false);
        incidentNumberPanel1 = new scriptbuilder.gui.panels.IncidentNumberPanel();
        scriptEventsPanel = new javax.swing.JPanel();
        scriptEventsPane = new javax.swing.JScrollPane();
        scriptEventsList = new javax.swing.JList();
        zoomSlider = new javax.swing.JSlider();
        scriptEventsPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        incidentName = new javax.swing.JTextField();
        incidentDescriptionPane = new javax.swing.JScrollPane();
        incidentDescription = new javax.swing.JTextArea();
        incidentNumber = new javax.swing.JTextField();
        selectButton = new javax.swing.JButton();
        incidentEventsPanel = new javax.swing.JPanel();
        maintenanceRadioButton = new javax.swing.JButton();
        tmtRadioButton = new javax.swing.JButton();
        telephoneButton = new javax.swing.JButton();
        unitButton = new javax.swing.JButton();
        witnessButton = new javax.swing.JButton();
        paramicsButton = new javax.swing.JButton();
        towButton = new javax.swing.JButton();
        audioButton = new javax.swing.JButton();
        cctvButton = new javax.swing.JButton();
        cadButton = new javax.swing.JButton();
        chpRadioButton = new javax.swing.JButton();
        evaluationEventsPanel = new javax.swing.JPanel();
        atmsEvalButton = new javax.swing.JButton();
        cmsEvalButton = new javax.swing.JButton();
        cadEvalButton = new javax.swing.JButton();
        facilitatorEvalButton = new javax.swing.JButton();
        activityLogEvalButton = new javax.swing.JButton();
        radioEvalButton = new javax.swing.JButton();
        zoomInIcon = new javax.swing.JLabel();
        zoomOutIcon = new javax.swing.JLabel();
        timeStampScrollPane = new javax.swing.JScrollPane();
        absoluteTimeStampPanel = new scriptbuilder.gui.panels.TimeStampPanel();
        btnAddTime = new javax.swing.JButton();
        timeStampScrollPane1 = new javax.swing.JScrollPane();
        relativeTimeStampPanel = new scriptbuilder.gui.panels.TimeStampPanel();

        cadEvent.setText("CAD Event");
        cadEvent.addMouseListener(new java.awt.event.MouseAdapter()
        {
            public void mousePressed(java.awt.event.MouseEvent evt)
            {
                cadEventMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt)
            {
                cadEventMouseReleased(evt);
            }
        });
        eventPopupMenu.add(cadEvent);

        jMenuItem2.setText("Paramics Event");
        eventPopupMenu.add(jMenuItem2);

        radioEvent.setText("Radio Event");
        radioEvent.addMouseListener(new java.awt.event.MouseAdapter()
        {
            public void mousePressed(java.awt.event.MouseEvent evt)
            {
                radioEventMousePressed(evt);
            }
        });
        eventPopupMenu.add(radioEvent);

        jMenuItem4.setText("Telephone Event");
        eventPopupMenu.add(jMenuItem4);

        jMenuItem5.setText("Video Event");
        eventPopupMenu.add(jMenuItem5);

        jMenuItem6.setText("Evaluation Event");
        eventPopupMenu.add(jMenuItem6);

        cadEventFrame.setMinimumSize(new java.awt.Dimension(400, 300));

        jLabel5.setText("CAD Entry");

        javax.swing.GroupLayout cadEventFrameLayout = new javax.swing.GroupLayout(cadEventFrame.getContentPane());
        cadEventFrame.getContentPane().setLayout(cadEventFrameLayout);
        cadEventFrameLayout.setHorizontalGroup(
            cadEventFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(cadEventFrameLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        cadEventFrameLayout.setVerticalGroup(
            cadEventFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(cadEventFrameLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel5)
                .addContainerGap(1357, Short.MAX_VALUE))
        );

        radioEventFrame.setTitle("Add Radio Event");
        radioEventFrame.setMinimumSize(new java.awt.Dimension(400, 300));

        radioTypeLabel.setText("Radio Type:");

        jLabel7.setText("Radio Message:");

        radioTypeComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "TMT", "Maintanence" }));

        radioMessageScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

        radioMessage.setColumns(20);
        radioMessage.setLineWrap(true);
        radioMessage.setRows(5);
        radioMessage.setWrapStyleWord(true);
        radioMessageScrollPane.setViewportView(radioMessage);

        okButton.setText("OK");
        okButton.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                okButtonActionPerformed(evt);
            }
        });

        cancelButton.setText("Cancel");
        cancelButton.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                cancelButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout radioEventFrameLayout = new javax.swing.GroupLayout(radioEventFrame.getContentPane());
        radioEventFrame.getContentPane().setLayout(radioEventFrameLayout);
        radioEventFrameLayout.setHorizontalGroup(
            radioEventFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, radioEventFrameLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(radioEventFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(radioMessageScrollPane, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, radioEventFrameLayout.createSequentialGroup()
                        .addComponent(radioTypeLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(radioTypeComboBox, 0, 312, Short.MAX_VALUE))
                    .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, radioEventFrameLayout.createSequentialGroup()
                        .addComponent(cancelButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 246, Short.MAX_VALUE)
                        .addComponent(okButton, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        radioEventFrameLayout.setVerticalGroup(
            radioEventFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(radioEventFrameLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(radioEventFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(radioTypeLabel)
                    .addComponent(radioTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(radioMessageScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 198, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(radioEventFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(okButton)
                    .addComponent(cancelButton))
                .addContainerGap())
        );

        editEventList.setText("Edit...");
        editEventList.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                editEventListActionPerformed(evt);
            }
        });
        eventListPopupMenu.add(editEventList);

        deleteEventList.setText("Delete...");
        eventListPopupMenu.add(deleteEventList);

        addNoiseFrame.setTitle("Generate Noise");
        addNoiseFrame.setMinimumSize(new java.awt.Dimension(395, 315));
        addNoiseFrame.setResizable(false);

        labelRadioChatter.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        labelRadioChatter.setText("Radio Chatter: ");

        labelLaneClosures.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        labelLaneClosures.setText("Lane Closures:");

        labelTMCAL.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        labelTMCAL.setText("TMCAL Logs:");

        labelNoiseDescription.setEditable(false);
        labelNoiseDescription.setColumns(20);
        labelNoiseDescription.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        labelNoiseDescription.setLineWrap(true);
        labelNoiseDescription.setRows(5);
        labelNoiseDescription.setText("Noise events will be randomly generated for the simulation with frequencies based on the control selections made below");
        labelNoiseDescription.setWrapStyleWord(true);
        labelNoiseDescription.setAutoscrolls(false);
        labelNoiseDescription.setBorder(null);
        labelNoiseDescription.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        labelNoiseDescription.setFocusable(false);
        labelNoiseDescription.setOpaque(false);

        labelBackgroundNoise.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        labelBackgroundNoise.setText("Background Noise: ");

        labelMinorEvents.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        labelMinorEvents.setText("Minor Events:");

        btnCancelNoise.setText("Cancel");
        btnCancelNoise.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                btnCancelNoiseActionPerformed(evt);
            }
        });

        btnGenerateNoise.setText("Generate");
        btnGenerateNoise.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                btnGenerateNoiseActionPerformed(evt);
            }
        });

        labelLeastFreq.setText("Least Frequent");

        labelMostFreq.setText("Most Frequent");

        javax.swing.GroupLayout addNoiseFrameLayout = new javax.swing.GroupLayout(addNoiseFrame.getContentPane());
        addNoiseFrame.getContentPane().setLayout(addNoiseFrameLayout);
        addNoiseFrameLayout.setHorizontalGroup(
            addNoiseFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, addNoiseFrameLayout.createSequentialGroup()
                .addContainerGap(21, Short.MAX_VALUE)
                .addGroup(addNoiseFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(labelNoiseDescription, javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(addNoiseFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, addNoiseFrameLayout.createSequentialGroup()
                            .addComponent(btnCancelNoise)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(btnGenerateNoise))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, addNoiseFrameLayout.createSequentialGroup()
                            .addGroup(addNoiseFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(addNoiseFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(labelBackgroundNoise)
                                    .addComponent(labelLaneClosures, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(labelTMCAL, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(labelRadioChatter, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(labelMinorEvents, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(4, 4, 4)
                            .addGroup(addNoiseFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(sliderRadioChatter, javax.swing.GroupLayout.PREFERRED_SIZE, 245, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(sliderLaneClosures, javax.swing.GroupLayout.PREFERRED_SIZE, 245, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(sliderTMCAL, javax.swing.GroupLayout.PREFERRED_SIZE, 245, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(sliderMinorEvents, javax.swing.GroupLayout.PREFERRED_SIZE, 245, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(sliderBackgroundNoise, javax.swing.GroupLayout.PREFERRED_SIZE, 245, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, addNoiseFrameLayout.createSequentialGroup()
                                    .addComponent(labelLeastFreq)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(labelMostFreq))))))
                .addGap(20, 20, 20))
        );
        addNoiseFrameLayout.setVerticalGroup(
            addNoiseFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, addNoiseFrameLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(labelNoiseDescription, javax.swing.GroupLayout.DEFAULT_SIZE, 39, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(addNoiseFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(labelMostFreq)
                    .addComponent(labelLeastFreq))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(addNoiseFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(labelRadioChatter, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(sliderRadioChatter, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(addNoiseFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(labelLaneClosures, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(sliderLaneClosures, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(addNoiseFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(labelTMCAL)
                    .addComponent(sliderTMCAL, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(addNoiseFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(sliderBackgroundNoise, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelBackgroundNoise, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(addNoiseFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(sliderMinorEvents, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelMinorEvents))
                .addGap(18, 18, 18)
                .addGroup(addNoiseFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnCancelNoise)
                    .addComponent(btnGenerateNoise))
                .addContainerGap())
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Incident Editor");
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setMinimumSize(new java.awt.Dimension(800, 700));

        timelinesScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        timelinesScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        timelinesScrollPane.setFocusCycleRoot(true);
        timelinesScrollPane.setFocusTraversalPolicyProvider(true);
        timelinesScrollPane.setPreferredSize(new java.awt.Dimension(72000, 1341));

        timelineTickPanel.setMaximumSize(new java.awt.Dimension(7200, 32767));
        timelineTickPanel.setMinimumSize(new java.awt.Dimension(7200, 0));
        timelineTickPanel.setPreferredSize(new java.awt.Dimension(7200, 1317));

        incidentTimelinePanel1.setMaximumSize(new java.awt.Dimension(32767, 100));
        incidentTimelinePanel1.setOpaque(false);
        incidentTimelinePanel1.setPreferredSize(new java.awt.Dimension(691, 100));

        javax.swing.GroupLayout incidentTimelinePanel1Layout = new javax.swing.GroupLayout(incidentTimelinePanel1);
        incidentTimelinePanel1.setLayout(incidentTimelinePanel1Layout);
        incidentTimelinePanel1Layout.setHorizontalGroup(
            incidentTimelinePanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 6776, Short.MAX_VALUE)
        );
        incidentTimelinePanel1Layout.setVerticalGroup(
            incidentTimelinePanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 334, Short.MAX_VALUE)
        );

        incidentNumberPanel1.setOpaque(false);

        javax.swing.GroupLayout incidentNumberPanel1Layout = new javax.swing.GroupLayout(incidentNumberPanel1);
        incidentNumberPanel1.setLayout(incidentNumberPanel1Layout);
        incidentNumberPanel1Layout.setHorizontalGroup(
            incidentNumberPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 106, Short.MAX_VALUE)
        );
        incidentNumberPanel1Layout.setVerticalGroup(
            incidentNumberPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout timelineTickPanelLayout = new javax.swing.GroupLayout(timelineTickPanel);
        timelineTickPanel.setLayout(timelineTickPanelLayout);
        timelineTickPanelLayout.setHorizontalGroup(
            timelineTickPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(timelineTickPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(incidentNumberPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(incidentTimelinePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 6776, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(300, Short.MAX_VALUE))
        );
        timelineTickPanelLayout.setVerticalGroup(
            timelineTickPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(timelineTickPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(timelineTickPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(incidentTimelinePanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 334, Short.MAX_VALUE)
                    .addComponent(incidentNumberPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(977, Short.MAX_VALUE))
        );

        timelinesScrollPane.setViewportView(timelineTickPanel);

        scriptEventsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Script Events"));

        scriptEventsPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

        scriptEventsList.setModel(new DefaultListModel());
        scriptEventsList.setComponentPopupMenu(eventListPopupMenu);
        scriptEventsPane.setViewportView(scriptEventsList);

        javax.swing.GroupLayout scriptEventsPanelLayout = new javax.swing.GroupLayout(scriptEventsPanel);
        scriptEventsPanel.setLayout(scriptEventsPanelLayout);
        scriptEventsPanelLayout.setHorizontalGroup(
            scriptEventsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(scriptEventsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(scriptEventsPane)
                .addContainerGap())
        );
        scriptEventsPanelLayout.setVerticalGroup(
            scriptEventsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(scriptEventsPanelLayout.createSequentialGroup()
                .addComponent(scriptEventsPane, javax.swing.GroupLayout.DEFAULT_SIZE, 215, Short.MAX_VALUE)
                .addContainerGap())
        );

        zoomSlider.setMaximum(22);
        zoomSlider.setMinimum(4);
        zoomSlider.setOrientation(javax.swing.JSlider.VERTICAL);
        zoomSlider.setValue(4);
        zoomSlider.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        zoomSlider.setFocusable(false);
        zoomSlider.addChangeListener(new javax.swing.event.ChangeListener()
        {
            public void stateChanged(javax.swing.event.ChangeEvent evt)
            {
                zoomSliderStateChanged(evt);
            }
        });

        scriptEventsPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Incident Information"));

        jLabel2.setText("Incident Number:");

        jLabel3.setText("Incident Name:");

        jLabel4.setText("Incident Description:");

        incidentName.setEditable(false);
        incidentName.setText("Media");

        incidentDescriptionPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

        incidentDescription.setEditable(false);
        incidentDescription.setColumns(20);
        incidentDescription.setLineWrap(true);
        incidentDescription.setRows(5);
        incidentDescription.setText("All media message events are found in this incident.");
        incidentDescription.setWrapStyleWord(true);
        incidentDescriptionPane.setViewportView(incidentDescription);

        incidentNumber.setEditable(false);
        incidentNumber.setText("100");

        javax.swing.GroupLayout scriptEventsPanel1Layout = new javax.swing.GroupLayout(scriptEventsPanel1);
        scriptEventsPanel1.setLayout(scriptEventsPanel1Layout);
        scriptEventsPanel1Layout.setHorizontalGroup(
            scriptEventsPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(scriptEventsPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(scriptEventsPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(incidentDescriptionPane, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel4)
                    .addGroup(scriptEventsPanel1Layout.createSequentialGroup()
                        .addGroup(scriptEventsPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(jLabel3))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(scriptEventsPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(incidentName)
                            .addComponent(incidentNumber))))
                .addContainerGap())
        );
        scriptEventsPanel1Layout.setVerticalGroup(
            scriptEventsPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(scriptEventsPanel1Layout.createSequentialGroup()
                .addGroup(scriptEventsPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(incidentNumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(scriptEventsPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(incidentName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(incidentDescriptionPane, javax.swing.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE)
                .addContainerGap())
        );

        selectButton.setToolTipText("Select");
        selectButton.setFocusPainted(false);
        selectButton.setIconTextGap(0);
        selectButton.setMargin(new java.awt.Insets(2, 10, 2, 10));
        selectButton.setPreferredSize(new java.awt.Dimension(30, 25));
        selectButton.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                selectButtonActionPerformed(evt);
            }
        });

        incidentEventsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Incident Events"));

        maintenanceRadioButton.setText("Maintenance Radio");
        maintenanceRadioButton.setToolTipText("");
        maintenanceRadioButton.setFocusPainted(false);
        maintenanceRadioButton.setIconTextGap(0);
        maintenanceRadioButton.setMargin(new java.awt.Insets(2, 10, 2, 10));
        maintenanceRadioButton.setPreferredSize(new java.awt.Dimension(30, 25));
        maintenanceRadioButton.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                maintenanceRadioButtonActionPerformed(evt);
            }
        });

        tmtRadioButton.setText("TMT Radio");
        tmtRadioButton.setToolTipText("");
        tmtRadioButton.setFocusPainted(false);
        tmtRadioButton.setIconTextGap(0);
        tmtRadioButton.setMargin(new java.awt.Insets(2, 10, 2, 10));
        tmtRadioButton.setPreferredSize(new java.awt.Dimension(30, 25));
        tmtRadioButton.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                tmtRadioButtonActionPerformed(evt);
            }
        });

        telephoneButton.setText("Telephone");
        telephoneButton.setToolTipText("");
        telephoneButton.setFocusPainted(false);
        telephoneButton.setIconTextGap(0);
        telephoneButton.setMargin(new java.awt.Insets(2, 10, 2, 10));
        telephoneButton.setPreferredSize(new java.awt.Dimension(30, 25));
        telephoneButton.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                telephoneButtonActionPerformed(evt);
            }
        });

        unitButton.setText("Unit");
        unitButton.setToolTipText("");
        unitButton.setFocusPainted(false);
        unitButton.setIconTextGap(0);
        unitButton.setMargin(new java.awt.Insets(2, 10, 2, 10));
        unitButton.setPreferredSize(new java.awt.Dimension(30, 25));
        unitButton.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                unitButtonActionPerformed(evt);
            }
        });

        witnessButton.setText("Witness");
        witnessButton.setToolTipText("");
        witnessButton.setFocusPainted(false);
        witnessButton.setIconTextGap(0);
        witnessButton.setMargin(new java.awt.Insets(2, 10, 2, 10));
        witnessButton.setPreferredSize(new java.awt.Dimension(30, 25));
        witnessButton.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                witnessButtonActionPerformed(evt);
            }
        });

        paramicsButton.setText("Paramics");
        paramicsButton.setToolTipText("");
        paramicsButton.setFocusPainted(false);
        paramicsButton.setIconTextGap(0);
        paramicsButton.setMargin(new java.awt.Insets(2, 10, 2, 10));
        paramicsButton.setPreferredSize(new java.awt.Dimension(30, 25));
        paramicsButton.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                paramicsButtonActionPerformed(evt);
            }
        });

        towButton.setText("Tow");
        towButton.setToolTipText("");
        towButton.setFocusPainted(false);
        towButton.setIconTextGap(0);
        towButton.setMargin(new java.awt.Insets(2, 10, 2, 10));
        towButton.setPreferredSize(new java.awt.Dimension(30, 25));
        towButton.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                towButtonActionPerformed(evt);
            }
        });

        audioButton.setText("Audio");
        audioButton.setToolTipText("");
        audioButton.setFocusPainted(false);
        audioButton.setIconTextGap(0);
        audioButton.setMargin(new java.awt.Insets(2, 10, 2, 10));
        audioButton.setPreferredSize(new java.awt.Dimension(30, 25));
        audioButton.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                audioButtonActionPerformed(evt);
            }
        });

        cctvButton.setText("CCTV");
        cctvButton.setToolTipText("");
        cctvButton.setFocusPainted(false);
        cctvButton.setIconTextGap(0);
        cctvButton.setMargin(new java.awt.Insets(2, 10, 2, 10));
        cctvButton.setPreferredSize(new java.awt.Dimension(30, 25));
        cctvButton.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                cctvButtonActionPerformed(evt);
            }
        });

        cadButton.setText("CAD");
        cadButton.setToolTipText("");
        cadButton.setFocusPainted(false);
        cadButton.setIconTextGap(0);
        cadButton.setMargin(new java.awt.Insets(2, 10, 2, 10));
        cadButton.setPreferredSize(new java.awt.Dimension(30, 25));
        cadButton.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                cadButtonActionPerformed(evt);
            }
        });

        chpRadioButton.setText("CHP Radio");
        chpRadioButton.setToolTipText("");
        chpRadioButton.setFocusPainted(false);
        chpRadioButton.setIconTextGap(0);
        chpRadioButton.setMargin(new java.awt.Insets(2, 10, 2, 10));
        chpRadioButton.setPreferredSize(new java.awt.Dimension(30, 25));
        chpRadioButton.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                chpRadioButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout incidentEventsPanelLayout = new javax.swing.GroupLayout(incidentEventsPanel);
        incidentEventsPanel.setLayout(incidentEventsPanelLayout);
        incidentEventsPanelLayout.setHorizontalGroup(
            incidentEventsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(incidentEventsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(incidentEventsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(incidentEventsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, incidentEventsPanelLayout.createSequentialGroup()
                            .addComponent(maintenanceRadioButton, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(tmtRadioButton, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(telephoneButton, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(paramicsButton, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(incidentEventsPanelLayout.createSequentialGroup()
                            .addComponent(towButton, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(unitButton, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(witnessButton, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(audioButton, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(incidentEventsPanelLayout.createSequentialGroup()
                        .addComponent(cadButton, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cctvButton, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(chpRadioButton, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        incidentEventsPanelLayout.setVerticalGroup(
            incidentEventsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(incidentEventsPanelLayout.createSequentialGroup()
                .addGroup(incidentEventsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(incidentEventsPanelLayout.createSequentialGroup()
                        .addGroup(incidentEventsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(maintenanceRadioButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(tmtRadioButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(telephoneButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(incidentEventsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(towButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(unitButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(witnessButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(audioButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(paramicsButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(incidentEventsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(incidentEventsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(cctvButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(chpRadioButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(cadButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        evaluationEventsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Evaluation Events"));

        atmsEvalButton.setText("ATMS Evaluation");
        atmsEvalButton.setToolTipText("");
        atmsEvalButton.setFocusPainted(false);
        atmsEvalButton.setIconTextGap(0);
        atmsEvalButton.setMargin(new java.awt.Insets(2, 10, 2, 10));
        atmsEvalButton.setPreferredSize(new java.awt.Dimension(30, 25));
        atmsEvalButton.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                atmsEvalButtonActionPerformed(evt);
            }
        });

        cmsEvalButton.setText("CMS Evaluation");
        cmsEvalButton.setToolTipText("");
        cmsEvalButton.setFocusPainted(false);
        cmsEvalButton.setIconTextGap(0);
        cmsEvalButton.setMargin(new java.awt.Insets(2, 10, 2, 10));
        cmsEvalButton.setPreferredSize(new java.awt.Dimension(30, 25));
        cmsEvalButton.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                cmsEvalButtonActionPerformed(evt);
            }
        });

        cadEvalButton.setText("CAD Evaluation");
        cadEvalButton.setToolTipText("");
        cadEvalButton.setFocusPainted(false);
        cadEvalButton.setIconTextGap(0);
        cadEvalButton.setMargin(new java.awt.Insets(2, 10, 2, 10));
        cadEvalButton.setPreferredSize(new java.awt.Dimension(30, 25));
        cadEvalButton.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                cadEvalButtonActionPerformed(evt);
            }
        });

        facilitatorEvalButton.setText("Facilitator Evaluation");
        facilitatorEvalButton.setToolTipText("");
        facilitatorEvalButton.setFocusPainted(false);
        facilitatorEvalButton.setIconTextGap(0);
        facilitatorEvalButton.setMargin(new java.awt.Insets(2, 10, 2, 10));
        facilitatorEvalButton.setPreferredSize(new java.awt.Dimension(30, 25));
        facilitatorEvalButton.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                facilitatorEvalButtonActionPerformed(evt);
            }
        });

        activityLogEvalButton.setText("Activity Log Evaluation");
        activityLogEvalButton.setToolTipText("");
        activityLogEvalButton.setFocusPainted(false);
        activityLogEvalButton.setIconTextGap(0);
        activityLogEvalButton.setMargin(new java.awt.Insets(2, 10, 2, 10));
        activityLogEvalButton.setPreferredSize(new java.awt.Dimension(30, 25));
        activityLogEvalButton.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                activityLogEvalButtonActionPerformed(evt);
            }
        });

        radioEvalButton.setText("Radio Evaluation");
        radioEvalButton.setToolTipText("");
        radioEvalButton.setFocusPainted(false);
        radioEvalButton.setIconTextGap(0);
        radioEvalButton.setMargin(new java.awt.Insets(2, 10, 2, 10));
        radioEvalButton.setPreferredSize(new java.awt.Dimension(30, 25));
        radioEvalButton.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                radioEvalButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout evaluationEventsPanelLayout = new javax.swing.GroupLayout(evaluationEventsPanel);
        evaluationEventsPanel.setLayout(evaluationEventsPanelLayout);
        evaluationEventsPanelLayout.setHorizontalGroup(
            evaluationEventsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(evaluationEventsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(evaluationEventsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(evaluationEventsPanelLayout.createSequentialGroup()
                        .addComponent(atmsEvalButton, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(activityLogEvalButton, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(evaluationEventsPanelLayout.createSequentialGroup()
                        .addComponent(cmsEvalButton, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(facilitatorEvalButton, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(evaluationEventsPanelLayout.createSequentialGroup()
                        .addComponent(cadEvalButton, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(radioEvalButton, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        evaluationEventsPanelLayout.setVerticalGroup(
            evaluationEventsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(evaluationEventsPanelLayout.createSequentialGroup()
                .addGroup(evaluationEventsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cmsEvalButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(facilitatorEvalButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(evaluationEventsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(atmsEvalButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(activityLogEvalButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(evaluationEventsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cadEvalButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(radioEvalButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        zoomInIcon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/ZoomIn.png"))); // NOI18N
        zoomInIcon.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        zoomInIcon.addMouseListener(new java.awt.event.MouseAdapter()
        {
            public void mouseClicked(java.awt.event.MouseEvent evt)
            {
                zoomInIconMouseClicked(evt);
            }
        });

        zoomOutIcon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/ZoomOut.png"))); // NOI18N
        zoomOutIcon.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        zoomOutIcon.addMouseListener(new java.awt.event.MouseAdapter()
        {
            public void mouseClicked(java.awt.event.MouseEvent evt)
            {
                zoomOutIconMouseClicked(evt);
            }
        });

        timeStampScrollPane.setBorder(null);
        timeStampScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        timeStampScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);

        javax.swing.GroupLayout absoluteTimeStampPanelLayout = new javax.swing.GroupLayout(absoluteTimeStampPanel);
        absoluteTimeStampPanel.setLayout(absoluteTimeStampPanelLayout);
        absoluteTimeStampPanelLayout.setHorizontalGroup(
            absoluteTimeStampPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 1036, Short.MAX_VALUE)
        );
        absoluteTimeStampPanelLayout.setVerticalGroup(
            absoluteTimeStampPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        timeStampScrollPane.setViewportView(absoluteTimeStampPanel);

        btnAddTime.setText("+15:00");
        btnAddTime.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                btnAddTimeActionPerformed(evt);
            }
        });

        timeStampScrollPane1.setBorder(null);
        timeStampScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        timeStampScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);

        javax.swing.GroupLayout relativeTimeStampPanelLayout = new javax.swing.GroupLayout(relativeTimeStampPanel);
        relativeTimeStampPanel.setLayout(relativeTimeStampPanelLayout);
        relativeTimeStampPanelLayout.setHorizontalGroup(
            relativeTimeStampPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 1036, Short.MAX_VALUE)
        );
        relativeTimeStampPanelLayout.setVerticalGroup(
            relativeTimeStampPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        timeStampScrollPane1.setViewportView(relativeTimeStampPanel);

        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)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(selectButton, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(incidentEventsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(evaluationEventsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(zoomSlider, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnAddTime, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(zoomInIcon)
                                    .addComponent(zoomOutIcon))
                                .addGap(0, 0, Short.MAX_VALUE))))
                    .addComponent(timelinesScrollPane, 0, 0, Short.MAX_VALUE)
                    .addComponent(timeStampScrollPane)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(scriptEventsPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(scriptEventsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(timeStampScrollPane1))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(evaluationEventsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(incidentEventsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(47, 47, 47)
                                .addComponent(selectButton, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(9, 9, 9)
                                .addComponent(zoomInIcon)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(zoomSlider, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(61, 61, 61)
                                .addComponent(btnAddTime, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(zoomOutIcon)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(timeStampScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(timeStampScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(timelinesScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(scriptEventsPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(scriptEventsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

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

    /**
     * Scale the timeline width based on zoom slider position.
     *
     * @param evt the state change event
     */
    private void zoomSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_zoomSliderStateChanged
        //Moving the zoom slider always refreshes the window
        ScriptBuilderGuiConstants.PIXEL_WIDTH_PER_HORIZONTAL_TICK = zoomSlider.getValue();
        this.update(null, theIncident);
        pack();
        repaint();
    }//GEN-LAST:event_zoomSliderStateChanged

    private void cadEventMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cadEventMousePressed
    }//GEN-LAST:event_cadEventMousePressed

    private void radioEventMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_radioEventMousePressed
    }//GEN-LAST:event_radioEventMousePressed

    private void cadEventMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cadEventMouseReleased
    }//GEN-LAST:event_cadEventMouseReleased

    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
    }//GEN-LAST:event_okButtonActionPerformed

    /**
     * If cancel button is pressed, close radio event editor
     *
     * @param evt the button press event
     */
    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
        radioMessage.setText("");
        radioTypeComboBox.setSelectedIndex(0);
        radioEventFrame.setVisible(false);
    }//GEN-LAST:event_cancelButtonActionPerformed

    private void editEventListActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editEventListActionPerformed
    }//GEN-LAST:event_editEventListActionPerformed

    /**
     * Deselects new event type upon click of blank "select" button.
     *
     * @param evt the button press event
     */
    private void selectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectButtonActionPerformed
        currentEventType = null;
        for (JButton eb : eventButtons)
        {
            eb.setSelected(false);
        }
        selectButton.setSelected(true);
    }//GEN-LAST:event_selectButtonActionPerformed

    /**
     * Selects CAD_EVENT as the current type of new event, upon click of "CAD
     * Event" button.
     *
     * @param evt the button press event
     */
    private void cadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cadButtonActionPerformed
        currentEventType = ScriptEventType.CAD_EVENT;
        for (JButton eb : eventButtons)
        {
            eb.setSelected(false);
        }
        cadButton.setSelected(true);
    }//GEN-LAST:event_cadButtonActionPerformed

    /**
     * Selects CCTV_EVENT as the current type of new event, upon click of "CCTV
     * Event" button.
     *
     * @param evt the button press event
     */
    private void cctvButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cctvButtonActionPerformed
        currentEventType = ScriptEventType.CCTV_EVENT;
        for (JButton eb : eventButtons)
        {
            eb.setSelected(false);
        }
        cctvButton.setSelected(true);
    }//GEN-LAST:event_cctvButtonActionPerformed

    /**
     * Selects CHP_RADIO_EVENT as the current type of new event, upon click of
     * "CHP Radio Event" button.
     *
     * @param evt the button press event
     */
    private void chpRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chpRadioButtonActionPerformed
        currentEventType = ScriptEventType.CHP_RADIO_EVENT;
        for (JButton eb : eventButtons)
        {
            eb.setSelected(false);
        }
        chpRadioButton.setSelected(true);
    }//GEN-LAST:event_chpRadioButtonActionPerformed

    /**
     * Hides the noise generation screen upon click of the "Cancel" button.
     *
     * @param evt the button press event
     */
    private void btnCancelNoiseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelNoiseActionPerformed
        addNoiseFrame.setVisible(false);
    }//GEN-LAST:event_btnCancelNoiseActionPerformed

    /**
     * Generates random noise upon click of the "OK" button, then hides the
     * noise generation screen.
     *
     * @param evt the button press event
     */
    private void btnGenerateNoiseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGenerateNoiseActionPerformed
        Random rng = new Random();
        ScriptEventType[] eventTypes = ScriptEventType.values();

        /* For prototyping purpose, ignore the sliders and average their values */
        int total = sliderRadioChatter.getValue() + sliderLaneClosures.getValue() + sliderTMCAL.getValue() + sliderMinorEvents.getValue() + sliderBackgroundNoise.getValue();
        total /= 5;

        for (int i = 0; i < theIncident.slices.size(); i++)
        {
            theIncident.slices.get(i).events.clear();
        }

        for (int i = 0; i < total; i++)
        {
            int n = rng.nextInt();
            int s = rng.nextInt();
            int e = rng.nextInt();
            if (n < 0)
            {
                n *= -1;
            }
            if (s < 0)
            {
                s *= -1;
            }
            if (e < 0)
            {
                e *= -1;
            }

            theIncident.slices.get(s % (theIncident.slices.size())).addEvent(ScriptEvent.factoryByType(eventTypes[e % eventTypes.length]));
        }

        addNoiseFrame.setVisible(false);

        this.update(null, theIncident);
}//GEN-LAST:event_btnGenerateNoiseActionPerformed

    /**
     * Selects WITNESS_EVENT as the current type of new event, upon click of
     * "Witness Event" button.
     *
     * @param evt the button press event
     */
    private void witnessButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_witnessButtonActionPerformed
        currentEventType = ScriptEventType.WITNESS_EVENT;
        for (JButton eb : eventButtons)
        {
            eb.setSelected(false);
        }
        witnessButton.setSelected(true);
    }//GEN-LAST:event_witnessButtonActionPerformed

    /**
     * Selects UNIT_EVENT as the current type of new event, upon click of "Unit
     * Event" button.
     *
     * @param evt the button press event
     */
    private void unitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_unitButtonActionPerformed
        currentEventType = ScriptEventType.UNIT_EVENT;
        for (JButton eb : eventButtons)
        {
            eb.setSelected(false);
        }
        unitButton.setSelected(true);
    }//GEN-LAST:event_unitButtonActionPerformed

    /**
     * Selects TOW_EVENT as the current type of new event, upon click of "TOW
     * Event" button.
     *
     * @param evt the button press event
     */
    private void towButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_towButtonActionPerformed
        currentEventType = ScriptEventType.TOW_EVENT;
        for (JButton eb : eventButtons)
        {
            eb.setSelected(false);
        }
        towButton.setSelected(true);
    }//GEN-LAST:event_towButtonActionPerformed

    /**
     * Selects PARAMICS_EVENT as the current type of new event, upon click of
     * "Paramics Event" button.
     *
     * @param evt the button press event
     */
    private void paramicsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_paramicsButtonActionPerformed
        currentEventType = ScriptEventType.PARAMICS_EVENT;
        for (JButton eb : eventButtons)
        {
            eb.setSelected(false);
        }
        paramicsButton.setSelected(true);
    }//GEN-LAST:event_paramicsButtonActionPerformed

    /**
     * Selects MAINTENANCE_RADIO_EVENT as the current type of new event, upon
     * click of "Maintenance Radio Event" button.
     *
     * @param evt the button press event
     */
    private void maintenanceRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_maintenanceRadioButtonActionPerformed
        currentEventType = ScriptEventType.MAINTENANCE_RADIO_EVENT;
        for (JButton eb : eventButtons)
        {
            eb.setSelected(false);
        }
        maintenanceRadioButton.setSelected(true);
    }//GEN-LAST:event_maintenanceRadioButtonActionPerformed

    /**
     * Selects ATMS_EVAL_EVENT as the current type of new event, upon click of
     * "ATMS Evaluation Event" button.
     *
     * @param evt the button press event
     */
    private void atmsEvalButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_atmsEvalButtonActionPerformed
        currentEventType = ScriptEventType.ATMS_EVAL_EVENT;
        for (JButton eb : eventButtons)
        {
            eb.setSelected(false);
        }
        atmsEvalButton.setSelected(true);
    }//GEN-LAST:event_atmsEvalButtonActionPerformed

    /**
     * Selects TELEPHONE_EVENT as the current type of new event, upon click of
     * "Telephone Event" button.
     *
     * @param evt the button press event
     */
    private void telephoneButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_telephoneButtonActionPerformed
        currentEventType = ScriptEventType.TELEPHONE_EVENT;
        for (JButton eb : eventButtons)
        {
            eb.setSelected(false);
        }
        telephoneButton.setSelected(true);
    }//GEN-LAST:event_telephoneButtonActionPerformed

    /**
     * Selects TMT_RADIO_EVENT as the current type of new event, upon click of
     * "TMT Radio Event" button.
     *
     * @param evt the button press event
     */
    private void tmtRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tmtRadioButtonActionPerformed
        currentEventType = ScriptEventType.TMT_RADIO_EVENT;
        for (JButton eb : eventButtons)
        {
            eb.setSelected(false);
        }
        tmtRadioButton.setSelected(true);
    }//GEN-LAST:event_tmtRadioButtonActionPerformed

    /**
     * Selects CMS_EVAL_EVENT as the current type of new event, upon click of
     * "CMS Evaluation Event" button.
     *
     * @param evt the button press event
     */
    private void cmsEvalButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmsEvalButtonActionPerformed
        currentEventType = ScriptEventType.CMS_EVAL_EVENT;
        for (JButton eb : eventButtons)
        {
            eb.setSelected(false);
        }
        cmsEvalButton.setSelected(true);
    }//GEN-LAST:event_cmsEvalButtonActionPerformed

    /**
     * Selects CAD_EVAL_EVENT as the current type of new event, upon click of
     * "CAD Evaluation Event" button.
     *
     * @param evt the button press event
     */
    private void cadEvalButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cadEvalButtonActionPerformed
        currentEventType = ScriptEventType.CAD_EVAL_EVENT;
        for (JButton eb : eventButtons)
        {
            eb.setSelected(false);
        }
        cadEvalButton.setSelected(true);
    }//GEN-LAST:event_cadEvalButtonActionPerformed

    /**
     * Selects ACTIVITY_LOG_EVAL_EVENT as the current type of new event, upon
     * click of "Activity Log Evaluation Event" button.
     *
     * @param evt the button press event
     */
    private void activityLogEvalButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_activityLogEvalButtonActionPerformed
        currentEventType = ScriptEventType.ACTIVITY_LOG_EVAL_EVENT;
        for (JButton eb : eventButtons)
        {
            eb.setSelected(false);
        }
        activityLogEvalButton.setSelected(true);
    }//GEN-LAST:event_activityLogEvalButtonActionPerformed

    /**
     * Selects RADIO_EVAL_EVENT as the current type of new event, upon click of
     * "Radio Evaluation Event" button.
     *
     * @param evt the button press event
     */
    private void radioEvalButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioEvalButtonActionPerformed
        currentEventType = ScriptEventType.RADIO_EVAL_EVENT;
        for (JButton eb : eventButtons)
        {
            eb.setSelected(false);
        }
        radioEvalButton.setSelected(true);
    }//GEN-LAST:event_radioEvalButtonActionPerformed

    /**
     * Selects FACILITATOR_EVAL_EVENT as the current type of new event, upon
     * click of "Facilitator Evaluation Event" button.
     *
     * @param evt the button press event
     */
    private void facilitatorEvalButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_facilitatorEvalButtonActionPerformed
        currentEventType = ScriptEventType.FACILITATOR_EVAL_EVENT;
        for (JButton eb : eventButtons)
        {
            eb.setSelected(false);
        }
        facilitatorEvalButton.setSelected(true);
    }//GEN-LAST:event_facilitatorEvalButtonActionPerformed

    /**
     * Selects AUDIO_EVENT as the current type of new event, upon click of
     * "Audio Event" button.
     *
     * @param evt the button press event
     */
    private void audioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_audioButtonActionPerformed
        currentEventType = ScriptEventType.AUDIO_EVENT;
        for (JButton eb : eventButtons)
        {
            eb.setSelected(false);
        }
        audioButton.setSelected(true);
    }//GEN-LAST:event_audioButtonActionPerformed

    /**
     * Increases zoom level upon click of the "Zoom in" icon.
     *
     * @param evt the mouse event
     */
    private void zoomInIconMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_zoomInIconMouseClicked
        zoomSlider.setValue(zoomSlider.getValue() >= 21 ? 21 : zoomSlider.getValue() + 1);
    }//GEN-LAST:event_zoomInIconMouseClicked

    /**
     * Decreases zoom level upon click of the "Zoom out" icon.
     *
     * @param evt the mouse event
     */
    private void zoomOutIconMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_zoomOutIconMouseClicked
        zoomSlider.setValue(zoomSlider.getValue() <= 5 ? 5 : zoomSlider.getValue() - 1);
    }//GEN-LAST:event_zoomOutIconMouseClicked

    /**
     * Add 15 minutes to the end of the timeline. This allows the user to add
     * new events past the current end of the incident
     *
     * @param evt the button press event
     */
    private void btnAddTimeActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnAddTimeActionPerformed
    {//GEN-HEADEREND:event_btnAddTimeActionPerformed
        incidentTimelinePanel1.requestedEditorFillerTime += IncidentTimelinePanel.FILLER_INTERVAL_SECONDS;
        this.update(null, theIncident);
    }//GEN-LAST:event_btnAddTimeActionPerformed

    /**
     * Read the version number from the application properties. The file
     * 'application.properties' is generated by build.xml.
     *
     * @return a version string obtained from application.properties file, or
     * "Version: unknown" if an IOerror prevents us from reading the file.
     */
    private String getAppVersion()
    {
        String propfilename = "/scriptbuilder/gui/application.properties";
        String propKey = "Application.revision";
        String version = "unknown";
        // Load the application properties (created by build.xml)
        try
        {
            Properties props = new Properties();
            props.load(this.getClass().getResourceAsStream(propfilename));
            version = (String) props.get(propKey);
        }
        catch (IOException ex)
        {
            Logger.getLogger("scriptbuilder.gui").log(Level.SEVERE,
                    "ScriptBuilderFrame.getAppVersion()."
                    + " IOError reading " + propfilename);
        }
        catch (NullPointerException npe)
        {
            Logger.getLogger("scriptbuilder.gui").log(Level.SEVERE,
                    "ScriptBuilderFrame.getAppVersion().load."
                    + " Missing file: " + propfilename);
        }
        return version;
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private scriptbuilder.gui.panels.TimeStampPanel absoluteTimeStampPanel;
    private javax.swing.JButton activityLogEvalButton;
    private javax.swing.JFrame addNoiseFrame;
    private javax.swing.JButton atmsEvalButton;
    private javax.swing.JButton audioButton;
    private javax.swing.JButton btnAddTime;
    private javax.swing.JButton btnCancelNoise;
    private javax.swing.JButton btnGenerateNoise;
    private javax.swing.JButton cadButton;
    private javax.swing.JButton cadEvalButton;
    private javax.swing.JMenuItem cadEvent;
    private javax.swing.JFrame cadEventFrame;
    private javax.swing.JButton cancelButton;
    private javax.swing.JButton cctvButton;
    private javax.swing.JButton chpRadioButton;
    private javax.swing.JButton cmsEvalButton;
    private javax.swing.JMenuItem deleteEventList;
    private javax.swing.JMenuItem editEventList;
    private javax.swing.JPanel evaluationEventsPanel;
    private javax.swing.JPopupMenu eventListPopupMenu;
    private javax.swing.JPopupMenu eventPopupMenu;
    private javax.swing.JButton facilitatorEvalButton;
    private javax.swing.JTextArea incidentDescription;
    private javax.swing.JScrollPane incidentDescriptionPane;
    private javax.swing.JPanel incidentEventsPanel;
    private javax.swing.JTextField incidentName;
    private javax.swing.JTextField incidentNumber;
    private scriptbuilder.gui.panels.IncidentNumberPanel incidentNumberPanel1;
    private scriptbuilder.gui.panels.IncidentTimelinePanel incidentTimelinePanel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItem6;
    private javax.swing.JLabel labelBackgroundNoise;
    private javax.swing.JLabel labelLaneClosures;
    private javax.swing.JLabel labelLeastFreq;
    private javax.swing.JLabel labelMinorEvents;
    private javax.swing.JLabel labelMostFreq;
    private javax.swing.JTextArea labelNoiseDescription;
    private javax.swing.JLabel labelRadioChatter;
    private javax.swing.JLabel labelTMCAL;
    private javax.swing.JButton maintenanceRadioButton;
    private javax.swing.JButton okButton;
    private javax.swing.JButton paramicsButton;
    private javax.swing.JButton radioEvalButton;
    private javax.swing.JMenuItem radioEvent;
    private javax.swing.JFrame radioEventFrame;
    private javax.swing.JTextArea radioMessage;
    private javax.swing.JScrollPane radioMessageScrollPane;
    private javax.swing.JComboBox radioTypeComboBox;
    private javax.swing.JLabel radioTypeLabel;
    private scriptbuilder.gui.panels.TimeStampPanel relativeTimeStampPanel;
    private javax.swing.JList scriptEventsList;
    private javax.swing.JScrollPane scriptEventsPane;
    private javax.swing.JPanel scriptEventsPanel;
    private javax.swing.JPanel scriptEventsPanel1;
    private javax.swing.JButton selectButton;
    private javax.swing.JSlider sliderBackgroundNoise;
    private javax.swing.JSlider sliderLaneClosures;
    private javax.swing.JSlider sliderMinorEvents;
    private javax.swing.JSlider sliderRadioChatter;
    private javax.swing.JSlider sliderTMCAL;
    private javax.swing.JButton telephoneButton;
    private javax.swing.JScrollPane timeStampScrollPane;
    private javax.swing.JScrollPane timeStampScrollPane1;
    private scriptbuilder.gui.panels.TimelineTickPanel timelineTickPanel;
    private javax.swing.JScrollPane timelinesScrollPane;
    private javax.swing.JButton tmtRadioButton;
    private javax.swing.JButton towButton;
    private javax.swing.JButton unitButton;
    private javax.swing.JButton witnessButton;
    private javax.swing.JLabel zoomInIcon;
    private javax.swing.JLabel zoomOutIcon;
    private javax.swing.JSlider zoomSlider;
    // End of variables declaration//GEN-END:variables
}
