source: tmcsimulator/trunk/src/atmsdriver/trafficeventseditor/TrafficEventsEditor.java @ 253

Revision 253, 58.4 KB checked in by jdalbey, 7 years ago (diff)

TrafficEventEditor?: Added file chooser to save button. TODO: Save the script to the selected file.

Line 
1/*
2 * To change this license header, choose License Headers in Project Properties.
3 * To change this template file, choose Tools | Templates
4 * and open the template in the editor.
5 */
6package atmsdriver.trafficeventseditor;
7
8import atmsdriver.model.Highway;
9import atmsdriver.model.LoopDetector;
10import atmsdriver.model.LoopDetector.DOTCOLOR;
11import atmsdriver.model.Station;
12import java.io.File;
13import java.util.ArrayList;
14import java.util.Enumeration;
15import java.util.Observable;
16import java.util.Observer;
17import javax.swing.AbstractButton;
18import javax.swing.AbstractListModel;
19import javax.swing.ButtonGroup;
20import javax.swing.DefaultListSelectionModel;
21import javax.swing.JComboBox;
22import javax.swing.JFileChooser;
23import javax.swing.JList;
24import javax.swing.JOptionPane;
25import javax.swing.JTable;
26import javax.swing.JTextField;
27import javax.swing.ListSelectionModel;
28import javax.swing.event.ListSelectionEvent;
29import javax.swing.event.ListSelectionListener;
30import javax.swing.table.AbstractTableModel;
31
32/**
33 *
34 * @author jtorres
35 */
36public class TrafficEventsEditor extends javax.swing.JFrame implements Observer
37{
38   
39    TimeFrames timeFrames;
40   
41    /**
42     * Creates new form BatchBuilderGUI
43     */
44    public TrafficEventsEditor(TimeFrames timeFrames)
45    {
46        initComponents();
47        this.timeFrames = timeFrames;
48       
49        HighwayList.setModel(new HighwaysListModel());
50        HighwayList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
51        HighwayList.addListSelectionListener(new HighwaysListSelectionListener());
52       
53        StationTable.setModel(new StationTableModel());
54        StationTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
55        StationTable.getSelectionModel().addListSelectionListener(
56                new StationTableListSelectionListener());
57       
58        TimeFrameList.setModel(new TimeFrameListModel());
59        TimeFrameList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
60        TimeFrameList.addListSelectionListener(new TimeFrameListSelectionListener());
61       
62        LoopDetectorTable.setModel(new LoopDetectorTableModel());
63        LoopDetectorTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
64        LoopDetectorTable.getSelectionModel().addListSelectionListener(
65                new LoopDetectorTableListSelectionListener());
66       
67        TrafficLaneEventsTable.setModel(new TrafficLaneEventsTableModel());
68        TrafficLaneEventsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
69        TrafficLaneEventsTable.getSelectionModel().addListSelectionListener(
70                new TrafficLaneEventsTableSelectionListener());
71       
72        GreenButton.setSelected(true);
73    }
74   
75    private class TrafficLaneEventsTableModel extends AbstractTableModel
76    {
77        String[] columnNames = {"Route", "StationID", "Postmile", "LoopID", "LoopType", 
78            "LoopDesc", "Color"};
79        int rows;
80        int cols;
81        String[][] data;
82        TimeFrame currFrame;
83        public TrafficLaneEventsTableModel()
84        {           
85            currFrame = timeFrames.currentTimeFrame;
86            rows = currFrame != null ? currFrame.events.size() : 0;
87            cols = columnNames.length;
88            data = new String[rows][cols];
89            for(int i = 0; i < rows; i++)
90            {
91                TrafficLaneEvent currEvent = currFrame.events.get(i);
92                data[i][0] = Integer.toString(currEvent.routeNum);
93                data[i][1] = Integer.toString(currEvent.station.ldsID);
94                data[i][2] = Double.toString(currEvent.station.postmile);
95                data[i][3] = Integer.toString(currEvent.loopDetector.loopID);
96                data[i][4] = currEvent.loopDetector.loopLocationID;
97                data[i][5] = currEvent.loopDetector.loopLocation;
98                data[i][6] = currEvent.color.getLetter();
99            }
100        }
101       
102        @Override
103        public String getColumnName(int col)
104        {
105            return columnNames[col];
106        }
107       
108        @Override
109        public int getRowCount()
110        {
111            return rows;
112        }
113
114        @Override
115        public int getColumnCount()
116        {
117            return cols;
118        }
119
120        @Override
121        public Object getValueAt(int rowIndex, int columnIndex)
122        {
123            return data[rowIndex][columnIndex];
124        }
125       
126    }
127   
128    private class LoopDetectorTableModel extends AbstractTableModel
129    {
130        String[] columnnames = {"Loop_ID", "Loop_Type", "Loop_Desc"};
131        int rows;
132        int cols;
133        String[][] data;
134        Station currStn;
135       
136        public LoopDetectorTableModel()
137        {
138            currStn = timeFrames.currentStation;
139            rows = currStn != null ? currStn.loops.size() : 0;
140            cols = columnnames.length;
141            data = new String[rows][cols];
142            for(int i = 0; i < rows; i++)
143            {
144                data[i][0] = Integer.toString(currStn.loops.get(i).loopID);
145                data[i][1] = currStn.loops.get(i).loopLocationID;
146                data[i][2] = currStn.loops.get(i).loopLocation;
147            }
148        }
149       
150        @Override
151        public String getColumnName(int col)
152        {
153            return columnnames[col];
154        }
155       
156        @Override
157        public int getRowCount()
158        {
159            return rows;
160        }
161
162        @Override
163        public int getColumnCount()
164        {
165            return cols;
166        }
167
168        @Override
169        public Object getValueAt(int rowIndex, int columnIndex)
170        {
171            return data[rowIndex][columnIndex];
172        }
173       
174    }
175   
176    private class TimeFrameListModel extends AbstractListModel
177    {
178        ArrayList<TimeFrame> frames;
179       
180        public TimeFrameListModel()
181        {
182            frames = (ArrayList<TimeFrame>) timeFrames.frames;
183        }
184
185        @Override
186        public int getSize()
187        {
188            return frames.size();
189        }
190
191        @Override
192        public Object getElementAt(int index)
193        {
194            return frames.get(index);
195        }
196       
197    }
198
199    private class TrafficLaneEventsTableSelectionListener implements ListSelectionListener
200    {
201        @Override
202        public void valueChanged(ListSelectionEvent e)
203        {
204            if(e.getValueIsAdjusting())
205                return;
206            DefaultListSelectionModel mod = (DefaultListSelectionModel) e.getSource();
207            int index = mod.getMaxSelectionIndex();
208            if(index >= 0)
209                timeFrames.setCurrentTrafficLaneEvent(index);
210        }
211    }
212   
213    private class HighwaysListSelectionListener implements ListSelectionListener
214    {
215        @Override
216        public void valueChanged(ListSelectionEvent e)
217        {
218            if(e.getValueIsAdjusting())
219                return;
220            JList source = (JList) e.getSource();
221            timeFrames.setCurrentHighway(source.getSelectedIndex());
222        }
223    }
224   
225    private class TimeFrameListSelectionListener implements ListSelectionListener
226    {
227        @Override
228        public void valueChanged(ListSelectionEvent e)
229        {
230            if(e.getValueIsAdjusting())
231                return;
232            JList source = (JList) e.getSource();
233            int index = source.getSelectedIndex();
234            if(index >= 0)
235            {
236                timeFrames.setCurrentTimeFrame(index);
237            }
238        }
239    }
240   
241    private class StationTableListSelectionListener implements ListSelectionListener
242    {
243
244        @Override
245        public void valueChanged(ListSelectionEvent e)
246        {
247            if(e.getValueIsAdjusting())
248                return;
249            DefaultListSelectionModel mod = (DefaultListSelectionModel) e.getSource();
250            int index = mod.getMaxSelectionIndex();
251            if(index >= 0)
252                timeFrames.setCurrentStation(index);
253        }
254    }
255   
256    private class LoopDetectorTableListSelectionListener implements ListSelectionListener
257    {
258
259        @Override
260        public void valueChanged(ListSelectionEvent e)
261        {
262            if(e.getValueIsAdjusting())
263                return;
264            DefaultListSelectionModel mod = (DefaultListSelectionModel) e.getSource();
265            int index = mod.getMaxSelectionIndex();
266            if(index >= 0)
267                timeFrames.setCurrentLoopDetector(index);
268        }
269       
270    }
271   
272    private class StationTableModel extends AbstractTableModel
273    {
274        String[] columnNames = {"lds_id", "direction", "postmile", "location"};
275        String[][] data;
276        Highway hwy;
277        int rows;
278        int cols;
279       
280        public StationTableModel()
281        {
282            hwy = TrafficEventsEditor.this.timeFrames.currentHighway;
283            cols = columnNames.length;
284            rows = hwy != null ? hwy.stations.size() : 0;
285            data = new String[rows][cols];
286            for(int i = 0; i < rows; i++)
287            {
288                data[i][0] = Integer.toString(hwy.stations.get(i).ldsID);
289                data[i][1] = hwy.stations.get(i).direction.getLetter();
290                data[i][2] = Double.toString(hwy.stations.get(i).postmile);
291                data[i][3] = hwy.stations.get(i).location;
292            }
293        }
294       
295        @Override
296        public String getColumnName(int col)
297        {
298            return columnNames[col];
299        }
300
301        @Override
302        public int getRowCount()
303        {
304            return rows;
305        }
306
307        @Override
308        public int getColumnCount()
309        {
310            return cols;
311        }
312
313        @Override
314        public Object getValueAt(int rowIndex, int columnIndex)
315        {
316            return data[rowIndex][columnIndex];
317        }
318    }
319   
320    private class HighwaysListModel extends AbstractListModel
321    {
322       
323        @Override
324        public int getSize()
325        {
326            return TrafficEventsEditor.this.timeFrames.highways.highways.size();
327        }
328
329        @Override
330        public Object getElementAt(int index)
331        {
332            return TrafficEventsEditor.this.timeFrames.highways.highways.get(index);
333        }
334    }
335
336    /**
337     * This method is called from within the constructor to initialize the form.
338     * WARNING: Do NOT modify this code. The content of this method is always
339     * regenerated by the Form Editor.
340     */
341    @SuppressWarnings("unchecked")
342    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
343    private void initComponents()
344    {
345
346        colorRadioButtons = new javax.swing.ButtonGroup();
347        jPanel6 = new javax.swing.JPanel();
348        jPanel2 = new javax.swing.JPanel();
349        HighwayScrollPane = new javax.swing.JScrollPane();
350        HighwayList = new javax.swing.JList();
351        jPanel4 = new javax.swing.JPanel();
352        StationScrollPane = new javax.swing.JScrollPane();
353        StationTable = new javax.swing.JTable();
354        jPanel5 = new javax.swing.JPanel();
355        LoopDetectorScrollPane = new javax.swing.JScrollPane();
356        LoopDetectorTable = new javax.swing.JTable();
357        jPanel1 = new javax.swing.JPanel();
358        jPanel9 = new javax.swing.JPanel();
359        jLabel1 = new javax.swing.JLabel();
360        CurrentTimeFrameLabel = new javax.swing.JLabel();
361        CurrentHighwayLabel = new javax.swing.JLabel();
362        jLabel2 = new javax.swing.JLabel();
363        jLabel3 = new javax.swing.JLabel();
364        CurrentStationLabel = new javax.swing.JLabel();
365        CurrentStationPostmileLabel = new javax.swing.JLabel();
366        jLabel4 = new javax.swing.JLabel();
367        jLabel5 = new javax.swing.JLabel();
368        CurrentStationLocationLabel = new javax.swing.JLabel();
369        CurrentLoopDetectorLabel = new javax.swing.JLabel();
370        jLabel6 = new javax.swing.JLabel();
371        jLabel7 = new javax.swing.JLabel();
372        CurrentLoopDetectorTypeLabel = new javax.swing.JLabel();
373        CurrentLoopDetectorDescLabel = new javax.swing.JLabel();
374        jLabel8 = new javax.swing.JLabel();
375        jLabel9 = new javax.swing.JLabel();
376        CurrentStationDirectionLabel = new javax.swing.JLabel();
377        jPanel7 = new javax.swing.JPanel();
378        GreenButton = new javax.swing.JRadioButton();
379        YellowButton = new javax.swing.JRadioButton();
380        RedButton = new javax.swing.JRadioButton();
381        AddNewEventButton = new javax.swing.JButton();
382        DeleteEventButton = new javax.swing.JButton();
383        jPanel11 = new javax.swing.JPanel();
384        jPanel12 = new javax.swing.JPanel();
385        SinglePreviewStationButton = new javax.swing.JButton();
386        SinglePreviewHighwaysButton = new javax.swing.JButton();
387        jPanel13 = new javax.swing.JPanel();
388        CumulativePreviewStationButton = new javax.swing.JButton();
389        CumulativePreviewHighwaysButton = new javax.swing.JButton();
390        jPanel15 = new javax.swing.JPanel();
391        jPanel3 = new javax.swing.JPanel();
392        TimeFrameScrollPane = new javax.swing.JScrollPane();
393        TimeFrameList = new javax.swing.JList();
394        jPanel10 = new javax.swing.JPanel();
395        AddNewTimeFrameButton = new javax.swing.JButton();
396        DeleteTimeFrameButton = new javax.swing.JButton();
397        jPanel8 = new javax.swing.JPanel();
398        jScrollPane1 = new javax.swing.JScrollPane();
399        TrafficLaneEventsTable = new javax.swing.JTable();
400        jPanel14 = new javax.swing.JPanel();
401        jButton1 = new javax.swing.JButton();
402        btnSave = new javax.swing.JButton();
403        jButton3 = new javax.swing.JButton();
404
405        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
406        setTitle("Traffic Events Editor");
407
408        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)), "Lane Selection Panel"));
409
410        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1), "Highway"));
411
412        HighwayList.setModel(new javax.swing.AbstractListModel()
413        {
414            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
415            public int getSize() { return strings.length; }
416            public Object getElementAt(int i) { return strings[i]; }
417        });
418        HighwayScrollPane.setViewportView(HighwayList);
419
420        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
421        jPanel2.setLayout(jPanel2Layout);
422        jPanel2Layout.setHorizontalGroup(
423            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
424            .addComponent(HighwayScrollPane, javax.swing.GroupLayout.Alignment.TRAILING)
425        );
426        jPanel2Layout.setVerticalGroup(
427            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
428            .addComponent(HighwayScrollPane)
429        );
430
431        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1), "Station"));
432
433        StationTable.setModel(new javax.swing.table.DefaultTableModel(
434            new Object [][]
435            {
436                {null, null, null, null},
437                {null, null, null, null},
438                {null, null, null, null},
439                {null, null, null, null}
440            },
441            new String []
442            {
443                "Title 1", "Title 2", "Title 3", "Title 4"
444            }
445        ));
446        StationScrollPane.setViewportView(StationTable);
447
448        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
449        jPanel4.setLayout(jPanel4Layout);
450        jPanel4Layout.setHorizontalGroup(
451            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
452            .addComponent(StationScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 546, Short.MAX_VALUE)
453        );
454        jPanel4Layout.setVerticalGroup(
455            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
456            .addComponent(StationScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
457        );
458
459        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1), "Loop Detector"));
460
461        LoopDetectorTable.setModel(new javax.swing.table.DefaultTableModel(
462            new Object [][]
463            {
464                {null, null, null, null},
465                {null, null, null, null},
466                {null, null, null, null},
467                {null, null, null, null}
468            },
469            new String []
470            {
471                "Title 1", "Title 2", "Title 3", "Title 4"
472            }
473        ));
474        LoopDetectorScrollPane.setViewportView(LoopDetectorTable);
475
476        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
477        jPanel5.setLayout(jPanel5Layout);
478        jPanel5Layout.setHorizontalGroup(
479            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
480            .addComponent(LoopDetectorScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 479, Short.MAX_VALUE)
481        );
482        jPanel5Layout.setVerticalGroup(
483            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
484            .addComponent(LoopDetectorScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
485        );
486
487        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
488        jPanel6.setLayout(jPanel6Layout);
489        jPanel6Layout.setHorizontalGroup(
490            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
491            .addGroup(jPanel6Layout.createSequentialGroup()
492                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
493                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
494                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
495                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
496                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
497        );
498        jPanel6Layout.setVerticalGroup(
499            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
500            .addGroup(jPanel6Layout.createSequentialGroup()
501                .addGap(6, 6, 6)
502                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
503                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
504                    .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
505                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
506        );
507
508        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)), "Current Selection"));
509        jPanel1.setLayout(new java.awt.GridLayout(1, 0));
510
511        jLabel1.setText("TimeFrame:");
512
513        CurrentTimeFrameLabel.setText("null");
514
515        CurrentHighwayLabel.setText("null");
516
517        jLabel2.setText("Highway:");
518
519        jLabel3.setText("Station:");
520
521        CurrentStationLabel.setText("null");
522
523        CurrentStationPostmileLabel.setText("null");
524
525        jLabel4.setText("Postmile:");
526
527        jLabel5.setText("Location:");
528
529        CurrentStationLocationLabel.setText("null");
530
531        CurrentLoopDetectorLabel.setText("null");
532
533        jLabel6.setText("Loop:");
534
535        jLabel7.setText("Type:");
536
537        CurrentLoopDetectorTypeLabel.setText("null");
538
539        CurrentLoopDetectorDescLabel.setText("null");
540
541        jLabel8.setText("Desc:");
542
543        jLabel9.setText("Direction:");
544
545        CurrentStationDirectionLabel.setText("null");
546
547        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
548        jPanel9.setLayout(jPanel9Layout);
549        jPanel9Layout.setHorizontalGroup(
550            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
551            .addGroup(jPanel9Layout.createSequentialGroup()
552                .addContainerGap()
553                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
554                    .addComponent(jLabel1)
555                    .addComponent(jLabel2)
556                    .addComponent(jLabel3)
557                    .addComponent(jLabel6)
558                    .addGroup(jPanel9Layout.createSequentialGroup()
559                        .addGap(6, 6, 6)
560                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
561                            .addComponent(jLabel9)
562                            .addComponent(jLabel5)
563                            .addComponent(jLabel4)
564                            .addComponent(jLabel7)
565                            .addComponent(jLabel8))))
566                .addGap(18, 18, 18)
567                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
568                    .addComponent(CurrentLoopDetectorTypeLabel)
569                    .addComponent(CurrentLoopDetectorLabel)
570                    .addComponent(CurrentStationLocationLabel)
571                    .addComponent(CurrentStationDirectionLabel)
572                    .addComponent(CurrentStationLabel)
573                    .addComponent(CurrentHighwayLabel)
574                    .addComponent(CurrentTimeFrameLabel)
575                    .addComponent(CurrentStationPostmileLabel)
576                    .addComponent(CurrentLoopDetectorDescLabel))
577                .addContainerGap(239, Short.MAX_VALUE))
578        );
579        jPanel9Layout.setVerticalGroup(
580            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
581            .addGroup(jPanel9Layout.createSequentialGroup()
582                .addContainerGap()
583                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
584                    .addComponent(jLabel1)
585                    .addComponent(CurrentTimeFrameLabel))
586                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
587                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
588                    .addComponent(jLabel2)
589                    .addComponent(CurrentHighwayLabel))
590                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
591                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
592                    .addComponent(jLabel3)
593                    .addComponent(CurrentStationLabel))
594                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
595                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
596                    .addComponent(jLabel9)
597                    .addComponent(CurrentStationDirectionLabel))
598                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
599                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
600                    .addComponent(jLabel4)
601                    .addComponent(CurrentStationPostmileLabel))
602                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
603                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
604                    .addComponent(jLabel5)
605                    .addComponent(CurrentStationLocationLabel))
606                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
607                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
608                    .addComponent(jLabel6)
609                    .addComponent(CurrentLoopDetectorLabel))
610                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
611                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
612                    .addComponent(jLabel7)
613                    .addComponent(CurrentLoopDetectorTypeLabel))
614                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
615                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
616                    .addComponent(jLabel8)
617                    .addComponent(CurrentLoopDetectorDescLabel))
618                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
619        );
620
621        jPanel1.add(jPanel9);
622
623        jPanel7.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
624
625        colorRadioButtons.add(GreenButton);
626        GreenButton.setText("Green");
627
628        colorRadioButtons.add(YellowButton);
629        YellowButton.setText("Yellow");
630
631        colorRadioButtons.add(RedButton);
632        RedButton.setText("Red");
633
634        AddNewEventButton.setText("Add New Event");
635        AddNewEventButton.addActionListener(new java.awt.event.ActionListener()
636        {
637            public void actionPerformed(java.awt.event.ActionEvent evt)
638            {
639                AddLaneEventButtonActionPerformed(evt);
640            }
641        });
642
643        DeleteEventButton.setText("Delete Selected Event");
644        DeleteEventButton.addActionListener(new java.awt.event.ActionListener()
645        {
646            public void actionPerformed(java.awt.event.ActionEvent evt)
647            {
648                DeleteEventButtonActonPerformed(evt);
649            }
650        });
651
652        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
653        jPanel7.setLayout(jPanel7Layout);
654        jPanel7Layout.setHorizontalGroup(
655            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
656            .addGroup(jPanel7Layout.createSequentialGroup()
657                .addContainerGap()
658                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
659                    .addComponent(DeleteEventButton, javax.swing.GroupLayout.DEFAULT_SIZE, 344, Short.MAX_VALUE)
660                    .addGroup(jPanel7Layout.createSequentialGroup()
661                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
662                            .addComponent(RedButton)
663                            .addComponent(YellowButton)
664                            .addComponent(GreenButton))
665                        .addGap(0, 0, Short.MAX_VALUE))
666                    .addComponent(AddNewEventButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
667                .addContainerGap())
668        );
669        jPanel7Layout.setVerticalGroup(
670            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
671            .addGroup(jPanel7Layout.createSequentialGroup()
672                .addContainerGap()
673                .addComponent(GreenButton)
674                .addGap(12, 12, 12)
675                .addComponent(YellowButton)
676                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
677                .addComponent(RedButton)
678                .addGap(18, 18, 18)
679                .addComponent(AddNewEventButton)
680                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
681                .addComponent(DeleteEventButton)
682                .addContainerGap(25, Short.MAX_VALUE))
683        );
684
685        jPanel1.add(jPanel7);
686
687        jPanel11.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)), "Preview Lane Events on ATMS"));
688        jPanel11.setLayout(new java.awt.BorderLayout());
689
690        jPanel12.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED), "Selected Time Frame Preview"));
691
692        SinglePreviewStationButton.setText("Send Selected Station Events");
693        SinglePreviewStationButton.addActionListener(new java.awt.event.ActionListener()
694        {
695            public void actionPerformed(java.awt.event.ActionEvent evt)
696            {
697                SinglePreviewStationButtonActionPerformed(evt);
698            }
699        });
700
701        SinglePreviewHighwaysButton.setText("Send All Events");
702        SinglePreviewHighwaysButton.addActionListener(new java.awt.event.ActionListener()
703        {
704            public void actionPerformed(java.awt.event.ActionEvent evt)
705            {
706                SinglePreviewHighwaysButtonActionPerformed(evt);
707            }
708        });
709
710        javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
711        jPanel12.setLayout(jPanel12Layout);
712        jPanel12Layout.setHorizontalGroup(
713            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
714            .addGroup(jPanel12Layout.createSequentialGroup()
715                .addContainerGap()
716                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
717                    .addComponent(SinglePreviewHighwaysButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
718                    .addComponent(SinglePreviewStationButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
719                .addContainerGap(10, Short.MAX_VALUE))
720        );
721        jPanel12Layout.setVerticalGroup(
722            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
723            .addGroup(jPanel12Layout.createSequentialGroup()
724                .addContainerGap()
725                .addComponent(SinglePreviewStationButton)
726                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
727                .addComponent(SinglePreviewHighwaysButton)
728                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
729        );
730
731        jPanel11.add(jPanel12, java.awt.BorderLayout.CENTER);
732
733        jPanel13.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED), "Cumulative Preview"));
734
735        CumulativePreviewStationButton.setText("Send Selected Station Events");
736        CumulativePreviewStationButton.addActionListener(new java.awt.event.ActionListener()
737        {
738            public void actionPerformed(java.awt.event.ActionEvent evt)
739            {
740                CumulativeStationPreviewButtonActionPerformed(evt);
741            }
742        });
743
744        CumulativePreviewHighwaysButton.setText("Send All Events");
745        CumulativePreviewHighwaysButton.addActionListener(new java.awt.event.ActionListener()
746        {
747            public void actionPerformed(java.awt.event.ActionEvent evt)
748            {
749                CumulativeHighwaysPreviewButtonActionPerformed(evt);
750            }
751        });
752
753        javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13);
754        jPanel13.setLayout(jPanel13Layout);
755        jPanel13Layout.setHorizontalGroup(
756            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
757            .addGroup(jPanel13Layout.createSequentialGroup()
758                .addContainerGap()
759                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
760                    .addComponent(CumulativePreviewHighwaysButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
761                    .addComponent(CumulativePreviewStationButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
762                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
763        );
764        jPanel13Layout.setVerticalGroup(
765            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
766            .addGroup(jPanel13Layout.createSequentialGroup()
767                .addContainerGap()
768                .addComponent(CumulativePreviewStationButton)
769                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
770                .addComponent(CumulativePreviewHighwaysButton)
771                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
772        );
773
774        jPanel11.add(jPanel13, java.awt.BorderLayout.PAGE_START);
775
776        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)), "Time Frame"));
777
778        TimeFrameList.setModel(new javax.swing.AbstractListModel()
779        {
780            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
781            public int getSize() { return strings.length; }
782            public Object getElementAt(int i) { return strings[i]; }
783        });
784        TimeFrameScrollPane.setViewportView(TimeFrameList);
785
786        jPanel10.setBorder(javax.swing.BorderFactory.createEtchedBorder());
787
788        AddNewTimeFrameButton.setText("New");
789        AddNewTimeFrameButton.setActionCommand("addTimeFrame");
790        AddNewTimeFrameButton.addActionListener(new java.awt.event.ActionListener()
791        {
792            public void actionPerformed(java.awt.event.ActionEvent evt)
793            {
794                addNewTimeFrameButtonClicked(evt);
795            }
796        });
797
798        DeleteTimeFrameButton.setText("Delete");
799        DeleteTimeFrameButton.addActionListener(new java.awt.event.ActionListener()
800        {
801            public void actionPerformed(java.awt.event.ActionEvent evt)
802            {
803                DeleteTimeFrameButtonActionPerformed(evt);
804            }
805        });
806
807        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
808        jPanel10.setLayout(jPanel10Layout);
809        jPanel10Layout.setHorizontalGroup(
810            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
811            .addGroup(jPanel10Layout.createSequentialGroup()
812                .addContainerGap()
813                .addComponent(AddNewTimeFrameButton, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
814                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 40, Short.MAX_VALUE)
815                .addComponent(DeleteTimeFrameButton, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
816                .addContainerGap())
817        );
818        jPanel10Layout.setVerticalGroup(
819            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
820            .addGroup(jPanel10Layout.createSequentialGroup()
821                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
822                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
823                    .addComponent(AddNewTimeFrameButton)
824                    .addComponent(DeleteTimeFrameButton))
825                .addContainerGap())
826        );
827
828        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
829        jPanel3.setLayout(jPanel3Layout);
830        jPanel3Layout.setHorizontalGroup(
831            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
832            .addComponent(TimeFrameScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE)
833            .addComponent(jPanel10, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
834        );
835        jPanel3Layout.setVerticalGroup(
836            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
837            .addGroup(jPanel3Layout.createSequentialGroup()
838                .addComponent(TimeFrameScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)
839                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
840                .addComponent(jPanel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
841                .addGap(76, 76, 76))
842        );
843
844        jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)), "Traffic Lane Events"));
845
846        TrafficLaneEventsTable.setModel(new javax.swing.table.DefaultTableModel(
847            new Object [][]
848            {
849                {null, null, null, null},
850                {null, null, null, null},
851                {null, null, null, null},
852                {null, null, null, null}
853            },
854            new String []
855            {
856                "Title 1", "Title 2", "Title 3", "Title 4"
857            }
858        ));
859        jScrollPane1.setViewportView(TrafficLaneEventsTable);
860
861        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
862        jPanel8.setLayout(jPanel8Layout);
863        jPanel8Layout.setHorizontalGroup(
864            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
865            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING)
866        );
867        jPanel8Layout.setVerticalGroup(
868            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
869            .addGroup(jPanel8Layout.createSequentialGroup()
870                .addContainerGap()
871                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
872                .addContainerGap())
873        );
874
875        javax.swing.GroupLayout jPanel15Layout = new javax.swing.GroupLayout(jPanel15);
876        jPanel15.setLayout(jPanel15Layout);
877        jPanel15Layout.setHorizontalGroup(
878            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
879            .addGroup(jPanel15Layout.createSequentialGroup()
880                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
881                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
882                .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
883                .addContainerGap())
884        );
885        jPanel15Layout.setVerticalGroup(
886            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
887            .addGroup(jPanel15Layout.createSequentialGroup()
888                .addContainerGap()
889                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
890                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
891                    .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
892                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
893        );
894
895        jPanel14.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)), "Export/Import Scripts"));
896
897        jButton1.setText("Load Script");
898
899        btnSave.setText("Save Script");
900        btnSave.addActionListener(new java.awt.event.ActionListener()
901        {
902            public void actionPerformed(java.awt.event.ActionEvent evt)
903            {
904                btnSaveActionPerformed(evt);
905            }
906        });
907
908        jButton3.setText("Save Script As");
909
910        javax.swing.GroupLayout jPanel14Layout = new javax.swing.GroupLayout(jPanel14);
911        jPanel14.setLayout(jPanel14Layout);
912        jPanel14Layout.setHorizontalGroup(
913            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
914            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel14Layout.createSequentialGroup()
915                .addContainerGap(28, Short.MAX_VALUE)
916                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
917                    .addComponent(btnSave, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
918                    .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
919                    .addComponent(jButton3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
920                .addGap(27, 27, 27))
921        );
922        jPanel14Layout.setVerticalGroup(
923            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
924            .addGroup(jPanel14Layout.createSequentialGroup()
925                .addContainerGap()
926                .addComponent(jButton1)
927                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
928                .addComponent(btnSave)
929                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
930                .addComponent(jButton3)
931                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
932        );
933
934        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
935        getContentPane().setLayout(layout);
936        layout.setHorizontalGroup(
937            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
938            .addGroup(layout.createSequentialGroup()
939                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
940                    .addGroup(layout.createSequentialGroup()
941                        .addGap(12, 12, 12)
942                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
943                            .addComponent(jPanel15, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
944                            .addGroup(layout.createSequentialGroup()
945                                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 730, javax.swing.GroupLayout.PREFERRED_SIZE)
946                                .addGap(18, 18, 18)
947                                .addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE)
948                                .addGap(18, 18, 18)
949                                .addComponent(jPanel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
950                    .addGroup(layout.createSequentialGroup()
951                        .addContainerGap()
952                        .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
953                .addContainerGap())
954        );
955        layout.setVerticalGroup(
956            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
957            .addGroup(layout.createSequentialGroup()
958                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
959                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
960                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
961                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
962                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
963                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
964                        .addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
965                    .addComponent(jPanel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
966                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
967                .addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
968        );
969
970        pack();
971    }// </editor-fold>//GEN-END:initComponents
972
973    private void AddLaneEventButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_AddLaneEventButtonActionPerformed
974    {//GEN-HEADEREND:event_AddLaneEventButtonActionPerformed
975        int rows[] = LoopDetectorTable.getSelectedRows();
976        timeFrames.addEventsToTimeFrame(rows, getDotColorFromText(
977                getSelectedButtonText(colorRadioButtons)));
978    }//GEN-LAST:event_AddLaneEventButtonActionPerformed
979
980    private void DeleteTimeFrameButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_DeleteTimeFrameButtonActionPerformed
981    {//GEN-HEADEREND:event_DeleteTimeFrameButtonActionPerformed
982        timeFrames.deleteTimeFrame(TimeFrameList.getSelectedIndex());
983    }//GEN-LAST:event_DeleteTimeFrameButtonActionPerformed
984
985    private String[] getTimeChoices()
986    {
987        String[] choices = new String[60];
988        for(int i = 0; i < 60; i++)
989        {
990            choices[i] = String.format("%02d", i);
991        }
992        return choices;
993    }
994   
995    private void addNewTimeFrameButtonClicked(java.awt.event.ActionEvent evt)//GEN-FIRST:event_addNewTimeFrameButtonClicked
996    {//GEN-HEADEREND:event_addNewTimeFrameButtonClicked
997        // String name = JOptionPane.showInputDialog(this, "Enter a time frame (HH:MM:SS)");
998        String[] hourChoices = getTimeChoices();
999        String[] minChoices = getTimeChoices();
1000        String[] secChoices = {"00", "30"};
1001       
1002        JComboBox hourCombo = new JComboBox(hourChoices);
1003        JComboBox minCombo = new JComboBox(minChoices);
1004        JComboBox secCombo = new JComboBox(secChoices);
1005       
1006        Object[] message = {
1007            "Hour:", hourCombo,
1008            "Minute:", minCombo,
1009            "Second:", secCombo
1010        };
1011        int option = JOptionPane.showConfirmDialog(this, message, "Enter a time frame:", JOptionPane.OK_CANCEL_OPTION);
1012        if(option == JOptionPane.OK_OPTION)
1013        {
1014            String h = hourCombo.getSelectedItem().toString();
1015            String m = minCombo.getSelectedItem().toString();
1016            String s = secCombo.getSelectedItem().toString();
1017            String cum = h + ":" + m + ":" + s;
1018            timeFrames.addTimeFrame(cum);
1019        }
1020        /*if(name != null)
1021        {
1022            timeFrames.addTimeFrame(name);
1023        }*/
1024    }//GEN-LAST:event_addNewTimeFrameButtonClicked
1025
1026    private void DeleteEventButtonActonPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_DeleteEventButtonActonPerformed
1027    {//GEN-HEADEREND:event_DeleteEventButtonActonPerformed
1028        timeFrames.deleteTrafficLaneEvent(TrafficLaneEventsTable
1029                .getSelectionModel().getMaxSelectionIndex());
1030    }//GEN-LAST:event_DeleteEventButtonActonPerformed
1031
1032    private void SinglePreviewStationButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_SinglePreviewStationButtonActionPerformed
1033    {//GEN-HEADEREND:event_SinglePreviewStationButtonActionPerformed
1034        timeFrames.singlePreviewStation();
1035    }//GEN-LAST:event_SinglePreviewStationButtonActionPerformed
1036
1037    private void SinglePreviewHighwaysButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_SinglePreviewHighwaysButtonActionPerformed
1038    {//GEN-HEADEREND:event_SinglePreviewHighwaysButtonActionPerformed
1039        timeFrames.singlePreviewHighways();
1040    }//GEN-LAST:event_SinglePreviewHighwaysButtonActionPerformed
1041
1042    private void CumulativeStationPreviewButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_CumulativeStationPreviewButtonActionPerformed
1043    {//GEN-HEADEREND:event_CumulativeStationPreviewButtonActionPerformed
1044        timeFrames.cumulativePreviewStation();
1045    }//GEN-LAST:event_CumulativeStationPreviewButtonActionPerformed
1046
1047    private void CumulativeHighwaysPreviewButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_CumulativeHighwaysPreviewButtonActionPerformed
1048    {//GEN-HEADEREND:event_CumulativeHighwaysPreviewButtonActionPerformed
1049        timeFrames.cumulativePreviewHighways();
1050    }//GEN-LAST:event_CumulativeHighwaysPreviewButtonActionPerformed
1051
1052     /**
1053     * Shows the dialog for choosing a file to save the script data to.
1054     * @author jdalbey
1055     */
1056    private void btnSaveActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnSaveActionPerformed
1057    {//GEN-HEADEREND:event_btnSaveActionPerformed
1058        boolean saved = false;
1059        JFileChooser chooser = new JFileChooser(".");
1060        int choice = chooser.showSaveDialog(chooser);
1061        if (choice == JFileChooser.APPROVE_OPTION)
1062        {
1063            File selectedFile = chooser.getSelectedFile();
1064            //TODO: Save the script to the selected file
1065            JOptionPane.showMessageDialog(null, "Saving Not Implemented Yet");
1066        }
1067//        return choice == JFileChooser.APPROVE_OPTION && saved;
1068    }//GEN-LAST:event_btnSaveActionPerformed
1069
1070    private DOTCOLOR getDotColorFromText(String text)
1071    {
1072        return DOTCOLOR.toDotColor(text);
1073    }
1074   
1075    private String getSelectedButtonText(ButtonGroup buttonGroup)
1076    {
1077        for(Enumeration<AbstractButton> buttons = buttonGroup.getElements(); buttons.hasMoreElements();)
1078        {
1079            AbstractButton button = buttons.nextElement();
1080            if(button.isSelected())
1081            {
1082                return button.getText();
1083            }
1084        }
1085        return null;
1086    }
1087   
1088    /**
1089     * @param args the command line arguments
1090     */
1091    public static void main(String args[])
1092    {
1093        /* Set the Nimbus look and feel */
1094        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
1095        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
1096         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
1097         */
1098        try
1099        {
1100            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels())
1101            {
1102                if ("Nimbus".equals(info.getName()))
1103                {
1104                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
1105                    break;
1106                }
1107            }
1108        } catch (ClassNotFoundException ex)
1109        {
1110            java.util.logging.Logger.getLogger(TrafficEventsEditor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
1111        } catch (InstantiationException ex)
1112        {
1113            java.util.logging.Logger.getLogger(TrafficEventsEditor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
1114        } catch (IllegalAccessException ex)
1115        {
1116            java.util.logging.Logger.getLogger(TrafficEventsEditor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
1117        } catch (javax.swing.UnsupportedLookAndFeelException ex)
1118        {
1119            java.util.logging.Logger.getLogger(TrafficEventsEditor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
1120        }
1121        //</editor-fold>
1122        //</editor-fold>
1123        //</editor-fold>
1124        //</editor-fold>
1125       
1126        TimeFrames timeFrames = new TimeFrames();
1127        final TrafficEventsEditor gui = new TrafficEventsEditor(timeFrames);
1128        timeFrames.addObserver(gui);
1129       
1130        /* Create and display the form */
1131        java.awt.EventQueue.invokeLater(new Runnable()
1132        {
1133            public void run()
1134            {
1135                gui.update(null, null);
1136                gui.setVisible(true);
1137            }
1138        });
1139    }
1140
1141    // Variables declaration - do not modify//GEN-BEGIN:variables
1142    private javax.swing.JButton AddNewEventButton;
1143    private javax.swing.JButton AddNewTimeFrameButton;
1144    private javax.swing.JButton CumulativePreviewHighwaysButton;
1145    private javax.swing.JButton CumulativePreviewStationButton;
1146    private javax.swing.JLabel CurrentHighwayLabel;
1147    private javax.swing.JLabel CurrentLoopDetectorDescLabel;
1148    private javax.swing.JLabel CurrentLoopDetectorLabel;
1149    private javax.swing.JLabel CurrentLoopDetectorTypeLabel;
1150    private javax.swing.JLabel CurrentStationDirectionLabel;
1151    private javax.swing.JLabel CurrentStationLabel;
1152    private javax.swing.JLabel CurrentStationLocationLabel;
1153    private javax.swing.JLabel CurrentStationPostmileLabel;
1154    private javax.swing.JLabel CurrentTimeFrameLabel;
1155    private javax.swing.JButton DeleteEventButton;
1156    private javax.swing.JButton DeleteTimeFrameButton;
1157    private javax.swing.JRadioButton GreenButton;
1158    private javax.swing.JList HighwayList;
1159    private javax.swing.JScrollPane HighwayScrollPane;
1160    private javax.swing.JScrollPane LoopDetectorScrollPane;
1161    private javax.swing.JTable LoopDetectorTable;
1162    private javax.swing.JRadioButton RedButton;
1163    private javax.swing.JButton SinglePreviewHighwaysButton;
1164    private javax.swing.JButton SinglePreviewStationButton;
1165    private javax.swing.JScrollPane StationScrollPane;
1166    private javax.swing.JTable StationTable;
1167    private javax.swing.JList TimeFrameList;
1168    private javax.swing.JScrollPane TimeFrameScrollPane;
1169    private javax.swing.JTable TrafficLaneEventsTable;
1170    private javax.swing.JRadioButton YellowButton;
1171    private javax.swing.JButton btnSave;
1172    private javax.swing.ButtonGroup colorRadioButtons;
1173    private javax.swing.JButton jButton1;
1174    private javax.swing.JButton jButton3;
1175    private javax.swing.JLabel jLabel1;
1176    private javax.swing.JLabel jLabel2;
1177    private javax.swing.JLabel jLabel3;
1178    private javax.swing.JLabel jLabel4;
1179    private javax.swing.JLabel jLabel5;
1180    private javax.swing.JLabel jLabel6;
1181    private javax.swing.JLabel jLabel7;
1182    private javax.swing.JLabel jLabel8;
1183    private javax.swing.JLabel jLabel9;
1184    private javax.swing.JPanel jPanel1;
1185    private javax.swing.JPanel jPanel10;
1186    private javax.swing.JPanel jPanel11;
1187    private javax.swing.JPanel jPanel12;
1188    private javax.swing.JPanel jPanel13;
1189    private javax.swing.JPanel jPanel14;
1190    private javax.swing.JPanel jPanel15;
1191    private javax.swing.JPanel jPanel2;
1192    private javax.swing.JPanel jPanel3;
1193    private javax.swing.JPanel jPanel4;
1194    private javax.swing.JPanel jPanel5;
1195    private javax.swing.JPanel jPanel6;
1196    private javax.swing.JPanel jPanel7;
1197    private javax.swing.JPanel jPanel8;
1198    private javax.swing.JPanel jPanel9;
1199    private javax.swing.JScrollPane jScrollPane1;
1200    // End of variables declaration//GEN-END:variables
1201   
1202    private void updateStatusLabels()
1203    {
1204        CurrentTimeFrameLabel.setText(timeFrames.currentTimeFrame != null
1205                ? timeFrames.currentTimeFrame.toString()
1206                : "");
1207       
1208        CurrentStationLabel.setText(timeFrames.currentStation != null
1209                ? timeFrames.currentStation.toString()
1210                : "");
1211       
1212        CurrentHighwayLabel.setText(timeFrames.currentHighway != null
1213                ? timeFrames.currentHighway.toString()
1214                : "");
1215        CurrentStationPostmileLabel.setText(timeFrames.currentStation != null
1216                ? Double.toString(timeFrames.currentStation.postmile)
1217                : "");
1218        CurrentStationDirectionLabel.setText(timeFrames.currentStation != null
1219                ? timeFrames.currentStation.direction.getLetter()
1220                : "");
1221        CurrentStationLocationLabel.setText(timeFrames.currentStation != null
1222                ? timeFrames.currentStation.location
1223                : "");
1224       
1225        CurrentLoopDetectorLabel.setText(timeFrames.currentLoopDetector != null
1226                ? Integer.toString(timeFrames.currentLoopDetector.loopID)
1227                : "");
1228        CurrentLoopDetectorTypeLabel.setText(timeFrames.currentLoopDetector != null
1229                ? timeFrames.currentLoopDetector.loopLocationID
1230                : "");
1231        CurrentLoopDetectorDescLabel.setText(timeFrames.currentLoopDetector != null
1232                ? timeFrames.currentLoopDetector.loopLocation
1233                : "");
1234    }
1235   
1236    private void updateButtonEnabled()
1237    {
1238        // add event button
1239        this.AddNewEventButton.setEnabled(
1240                timeFrames.currentTimeFrame != null 
1241                && timeFrames.currentHighway != null
1242                && timeFrames.currentStation != null 
1243                && timeFrames.currentLoopDetector != null
1244        );
1245       
1246        // delete event button
1247        DeleteEventButton.setEnabled(
1248                !TrafficLaneEventsTable.getSelectionModel().isSelectionEmpty());
1249       
1250        // delete time frame button
1251        DeleteTimeFrameButton.setEnabled(!TimeFrameList.isSelectionEmpty());
1252       
1253        // single preview buttons
1254        SinglePreviewStationButton.setEnabled(
1255                timeFrames.currentStation != null
1256                && timeFrames.currentTimeFrame != null
1257        );
1258       
1259        SinglePreviewHighwaysButton.setEnabled(
1260                timeFrames.currentTimeFrame != null
1261        );
1262       
1263        // cumulative preview buttons
1264        CumulativePreviewHighwaysButton.setEnabled(
1265                timeFrames.currentTimeFrame != null
1266        );
1267       
1268        CumulativePreviewStationButton.setEnabled(
1269                timeFrames.currentTimeFrame != null
1270                && timeFrames.currentStation != null
1271        );
1272    }
1273   
1274    @Override
1275    public void update(Observable o, Object arg)
1276    {
1277        String updateArg = (String) arg;
1278        updateStatusLabels();
1279        if(updateArg != null)
1280        {
1281            if(updateArg.equals("add frame") || updateArg.equals("delete frame"))
1282            {
1283                TimeFrameList.setModel(new TimeFrameListModel());
1284                TimeFrameList.setSelectedIndex(
1285                        timeFrames.getCurrentTimeFrameIndex());
1286                TrafficLaneEventsTable.setModel(new TrafficLaneEventsTableModel());
1287            }
1288            else if(updateArg.equals("select hwy"))
1289            {
1290                StationTable.setModel(new StationTableModel());
1291                LoopDetectorTable.setModel(new LoopDetectorTableModel());
1292            }
1293            else if(updateArg.equals("select station"))
1294            {
1295                LoopDetectorTable.setModel(new LoopDetectorTableModel());
1296            }
1297            else if(updateArg.equals("select frame"))
1298            {
1299                TrafficLaneEventsTable.setModel(
1300                        new TrafficLaneEventsTableModel());
1301            }
1302            else if(updateArg.equals("add event") 
1303                    || updateArg.equals("delete event"))
1304            {
1305                TrafficLaneEventsTable.setModel(
1306                        new TrafficLaneEventsTableModel());
1307                TrafficLaneEventsTable.getSelectionModel()
1308                        .setSelectionInterval(
1309                                timeFrames.getCurrentTrafficEventIndex(), 
1310                                timeFrames.getCurrentTrafficEventIndex());
1311            }
1312        }
1313        updateButtonEnabled();
1314    }
1315}
Note: See TracBrowser for help on using the repository browser.