source: liacs/se/RouteGUI/src/routegui/MainJFrame.java@ 89

Last change on this file since 89 was 2, checked in by Rick van der Zwet, 15 years ago

Initial import of data of old repository ('data') worth keeping (e.g. tracking
means of URL access statistics)

File size: 24.6 KB
Line 
1/*
2 * MainJFrame.java
3 *
4 * Created on 10 april 2008, 17:
5 * @todo: Eliminate dirty hacking intruduced to het Compass displayed properly
6 */
7package routegui;
8
9import java.text.DateFormat;
10import java.util.Calendar;
11import java.util.Date;
12import java.util.logging.Level;
13import java.util.logging.Logger;
14import org.jdesktop.swingx.mapviewer.GeoPosition;
15import java.util.TimerTask;
16import java.util.Random;
17import java.awt.Color;
18import java.awt.Graphics2D;
19import java.util.HashSet;
20import java.util.Set;
21import javax.swing.JFileChooser;
22import org.jdesktop.swingx.JXMapViewer;
23import org.jdesktop.swingx.mapviewer.Waypoint;
24import org.jdesktop.swingx.mapviewer.WaypointPainter;
25/*
26 * @author evert
27 */
28import org.jdesktop.swingx.mapviewer.WaypointRenderer;
29import org.jdesktop.swingx.painter.CompoundPainter;
30import org.jdesktop.swingx.painter.Painter;
31
32public class MainJFrame extends javax.swing.JFrame {
33
34 /** Creates new form MainJFrame */
35 private boolean powerState = false;
36 private java.util.Timer clockTimer = new java.util.Timer();
37 private Random generator = new Random();
38 private SimulateDrive simulateDrive;
39
40 /**
41 * Revert state of PND, either ON -> OFF or OFF -> ON
42 */
43 private void powerDevice() {
44 powerState = ! powerState;
45
46 if (powerState) {
47 jTogglePower.setText("Turn OFF");
48 } else {
49 jTogglePower.setText("Turn ON");
50 }
51
52 jControl.setVisible(powerState);
53 jLabelSnelheid.setVisible(powerState);
54 jCompass.setVisible(powerState);
55 jButtonEndSimulation.setVisible(powerState);
56 }
57
58 private void updateSpeed(double snelheid) {
59 jLabelSnelheid.setText(String.valueOf(snelheid).concat(" KM"));
60 if (snelheid < 50) {
61 jLabelSnelheid.setForeground(Color.green);
62 } else if (snelheid < 100) {
63 jLabelSnelheid.setForeground(Color.yellow);
64 } else {
65 jLabelSnelheid.setForeground(Color.red);
66 }
67 jLabelSnelheid.repaint();
68 }
69
70 public MainJFrame() {
71 initComponents();
72 clockTimer.scheduleAtFixedRate(new TickTimerTask(), 0, 1000);
73
74 /* Hack to allow init of components of OFF */
75 powerState = true;
76 powerDevice();
77
78 jXMapKit1.setZoom(3);
79 }
80
81 /** tack to update clock one a second */
82 class TickTimerTask extends TimerTask {
83
84 @Override
85 public void run() {
86 Date rightNow = Calendar.getInstance().getTime();
87 jLabelTime.setText(DateFormat.getTimeInstance().format(rightNow));
88 }
89 }
90
91 class SimulateDrive implements Runnable {
92
93 private boolean killMe = false;
94 private GPS route = new GPS();
95
96 public void terminate() {
97 killMe = true;
98 }
99
100 private SimulateDrive(String routeFile) {
101 route.init(routeFile);
102 }
103
104 @Override
105 @SuppressWarnings("unchecked") //@todo: warnings Painter mapping
106 public void run() {
107 /**
108 * @todo: Find a proper way to display both the route and current location at the same time
109 * Guru help site at http://today.java.net/pub/a/today/2007/11/13/mapping-mashups-with-jxmapviewer.html
110 */
111 Painter<JXMapViewer> defaultOverlay = jXMapKit1.getMainMap().getOverlayPainter();
112 Painter<JXMapViewer> textOverlay = new Painter<JXMapViewer>() {
113
114 @Override
115 public void paint(Graphics2D g, JXMapViewer map, int w, int h) {
116 g.setPaint(new Color(0, 0, 0, 150));
117 g.fillRoundRect(5, 5, 280, 30, 10, 10);
118 g.setPaint(Color.WHITE);
119 g.drawString("Images provided by OpenStreetMap.org", 20, 20);
120 }
121 };
122 CompoundPainter cp = new CompoundPainter();
123 cp.setPainters(textOverlay, defaultOverlay);
124 cp.setCacheable(false);
125 jXMapKit1.getMainMap().setOverlayPainter(cp);
126
127 Set<Waypoint> waypoints = new HashSet<Waypoint>();
128 WaypointPainter painter = new WaypointPainter();
129 //painter.setWaypoints(waypoints);
130 painter.setRenderer(new WaypointRenderer() {
131
132 @Override
133 public boolean paintWaypoint(Graphics2D g, JXMapViewer map, Waypoint wp) {
134 g.setColor(Color.RED);
135 g.drawLine(0, 0, 0, 0);
136 return true;
137 }
138 });
139
140 /* Initial fetch data */
141 route.next();
142 long prevTime = route.data.calendar.getTime().getTime();
143 Date curTime;
144 int i = 0;
145 /* Center map at starting point */
146 jXMapKit1.setAddressLocation(route.data.position);
147 do {
148 try {
149 waypoints.add(new Waypoint(route.data.position));
150 jXMapKit1.setAddressLocation(route.data.position);
151 updateSpeed(route.data.speed);
152 if (route.data.bearing != null) {
153 Compass foo = (Compass) jCompass;
154 foo.setAngle(route.data.bearing.intValue());
155 }
156 /* Specify amount of sleep time needed */
157 curTime = route.data.calendar.getTime();
158 jLabelTime.setText(DateFormat.getTimeInstance().format(curTime));
159 Thread.sleep(Math.max(0, (curTime.getTime() - prevTime) / jSliderSimulationSpeed.getValue()));
160 prevTime = curTime.getTime();
161 } catch (InterruptedException ex) {
162 Logger.getLogger(MainJFrame.class.getName()).log(Level.SEVERE, null, ex);
163 }
164 } while (route.next() && !killMe);
165 painter.setWaypoints(waypoints);
166 jXMapKit1.getMainMap().setOverlayPainter(painter);
167 }
168 }
169
170 /** This method is called from within the constructor to
171 * initialize the form.
172 * WARNING: Do NOT modify this code. The content of this method is
173 * always regenerated by the Form Editor.
174 */
175 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
176 private void initComponents() {
177
178 jTogglePower = new javax.swing.JToggleButton();
179 jControl = new javax.swing.JTabbedPane();
180 jPanel1 = new javax.swing.JPanel();
181 jXMapKit1 = new org.jdesktop.swingx.JXMapKit();
182 jPanel2 = new javax.swing.JPanel();
183 jLabel1 = new javax.swing.JLabel();
184 jButtonQ = new javax.swing.JButton();
185 jButtonOK = new javax.swing.JButton();
186 jTextFieldDestination = new javax.swing.JTextField();
187 jButtonBcsp = new javax.swing.JButton();
188 jPanel3 = new javax.swing.JPanel();
189 jTextFieldFileSimulation = new javax.swing.JTextField();
190 jButtonFileSimulationBrowse = new javax.swing.JButton();
191 jLabelFileSimulation = new javax.swing.JLabel();
192 jSliderSimulationSpeed = new javax.swing.JSlider();
193 jButtonSimulationStatus = new javax.swing.JButton();
194 jLabelSimulationSpeed = new javax.swing.JLabel();
195 jLabelNames = new javax.swing.JLabel();
196 jLabelTime = new javax.swing.JLabel();
197 jLabelSnelheid = new javax.swing.JLabel();
198 jButtonEndSimulation = new javax.swing.JButton();
199 jCompass = new Compass();
200
201 setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
202
203 jTogglePower.setText("Turn OFF");
204 jTogglePower.addActionListener(new java.awt.event.ActionListener() {
205 public void actionPerformed(java.awt.event.ActionEvent evt) {
206 jTogglePowerActionPerformed(evt);
207 }
208 });
209
210 jControl.setTabPlacement(javax.swing.JTabbedPane.LEFT);
211 jControl.setFont(jControl.getFont().deriveFont((jControl.getFont().getStyle() | java.awt.Font.ITALIC) | java.awt.Font.BOLD, jControl.getFont().getSize()+11));
212
213 jXMapKit1.setDefaultProvider(org.jdesktop.swingx.JXMapKit.DefaultProviders.OpenStreetMaps);
214 jXMapKit1.setScrollableTracksViewportWidth(true);
215 jXMapKit1.setZoom(1);
216
217 javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
218 jPanel1.setLayout(jPanel1Layout);
219 jPanel1Layout.setHorizontalGroup(
220 jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
221 .addComponent(jXMapKit1, javax.swing.GroupLayout.DEFAULT_SIZE, 595, Short.MAX_VALUE)
222 );
223 jPanel1Layout.setVerticalGroup(
224 jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
225 .addGroup(jPanel1Layout.createSequentialGroup()
226 .addComponent(jXMapKit1, javax.swing.GroupLayout.DEFAULT_SIZE, 311, Short.MAX_VALUE)
227 .addContainerGap())
228 );
229
230 jControl.addTab("Map", jPanel1);
231
232 jLabel1.setText("Destination :");
233
234 jButtonQ.setText("q");
235 jButtonQ.addActionListener(new java.awt.event.ActionListener() {
236 public void actionPerformed(java.awt.event.ActionEvent evt) {
237 jButtonQActionPerformed(evt);
238 }
239 });
240
241 jButtonOK.setText("OK currently hardcoded to 52.161087, 4.490153");
242 jButtonOK.addActionListener(new java.awt.event.ActionListener() {
243 public void actionPerformed(java.awt.event.ActionEvent evt) {
244 jButtonOKActionPerformed(evt);
245 }
246 });
247
248 jTextFieldDestination.setText("<select your destination>");
249
250 jButtonBcsp.setText("<-");
251 jButtonBcsp.addActionListener(new java.awt.event.ActionListener() {
252 public void actionPerformed(java.awt.event.ActionEvent evt) {
253 jButtonBcspActionPerformed(evt);
254 }
255 });
256
257 javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
258 jPanel2.setLayout(jPanel2Layout);
259 jPanel2Layout.setHorizontalGroup(
260 jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
261 .addGroup(jPanel2Layout.createSequentialGroup()
262 .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
263 .addGroup(jPanel2Layout.createSequentialGroup()
264 .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
265 .addGroup(jPanel2Layout.createSequentialGroup()
266 .addGap(48, 48, 48)
267 .addComponent(jLabel1)
268 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
269 .addComponent(jTextFieldDestination, javax.swing.GroupLayout.DEFAULT_SIZE, 355, Short.MAX_VALUE))
270 .addGroup(jPanel2Layout.createSequentialGroup()
271 .addGap(35, 35, 35)
272 .addComponent(jButtonQ, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)))
273 .addGap(23, 23, 23)
274 .addComponent(jButtonBcsp, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE))
275 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
276 .addContainerGap(233, Short.MAX_VALUE)
277 .addComponent(jButtonOK)))
278 .addContainerGap())
279 );
280 jPanel2Layout.setVerticalGroup(
281 jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
282 .addGroup(jPanel2Layout.createSequentialGroup()
283 .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
284 .addComponent(jLabel1)
285 .addComponent(jTextFieldDestination, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
286 .addGap(18, 18, 18)
287 .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
288 .addComponent(jButtonBcsp)
289 .addComponent(jButtonQ, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
290 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 227, Short.MAX_VALUE)
291 .addComponent(jButtonOK))
292 );
293
294 jControl.addTab("Route", jPanel2);
295
296 jTextFieldFileSimulation.setText("/Users/rick/svn/data/liacs/se/gps-data/101/characteroutput-20080312-090741.txt");
297
298 jButtonFileSimulationBrowse.setText("Browse");
299 jButtonFileSimulationBrowse.addActionListener(new java.awt.event.ActionListener() {
300 public void actionPerformed(java.awt.event.ActionEvent evt) {
301 jButtonFileSimulationBrowseActionPerformed(evt);
302 }
303 });
304
305 jLabelFileSimulation.setText("Filename:");
306
307 jSliderSimulationSpeed.setMajorTickSpacing(10);
308 jSliderSimulationSpeed.setPaintLabels(true);
309 jSliderSimulationSpeed.setPaintTicks(true);
310 jSliderSimulationSpeed.setValue(100);
311
312 jButtonSimulationStatus.setText("GO");
313 jButtonSimulationStatus.addActionListener(new java.awt.event.ActionListener() {
314 public void actionPerformed(java.awt.event.ActionEvent evt) {
315 jButtonSimulationStatusActionPerformed(evt);
316 }
317 });
318
319 jLabelSimulationSpeed.setText("Sim Speed:");
320
321 javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
322 jPanel3.setLayout(jPanel3Layout);
323 jPanel3Layout.setHorizontalGroup(
324 jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
325 .addGroup(jPanel3Layout.createSequentialGroup()
326 .addContainerGap()
327 .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
328 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
329 .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
330 .addComponent(jLabelSimulationSpeed, javax.swing.GroupLayout.DEFAULT_SIZE, 211, Short.MAX_VALUE)
331 .addComponent(jLabelFileSimulation))
332 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
333 .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
334 .addComponent(jSliderSimulationSpeed, javax.swing.GroupLayout.DEFAULT_SIZE, 261, Short.MAX_VALUE)
335 .addComponent(jTextFieldFileSimulation, javax.swing.GroupLayout.DEFAULT_SIZE, 261, Short.MAX_VALUE))
336 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
337 .addComponent(jButtonFileSimulationBrowse))
338 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
339 .addComponent(jButtonSimulationStatus)
340 .addContainerGap())))
341 );
342 jPanel3Layout.setVerticalGroup(
343 jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
344 .addGroup(jPanel3Layout.createSequentialGroup()
345 .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
346 .addComponent(jLabelFileSimulation, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
347 .addComponent(jButtonFileSimulationBrowse)
348 .addComponent(jTextFieldFileSimulation, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
349 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
350 .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
351 .addComponent(jSliderSimulationSpeed, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
352 .addComponent(jLabelSimulationSpeed, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
353 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 192, Short.MAX_VALUE)
354 .addComponent(jButtonSimulationStatus)
355 .addContainerGap())
356 );
357
358 jControl.addTab("Simulate", jPanel3);
359
360 jLabelNames.setText("Software Engineering - Evert Mouw, Hugo Meiland, Rick van der Zwet");
361
362 jLabelTime.setText("00:00:00");
363 jLabelTime.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));
364
365 jLabelSnelheid.setFont(new java.awt.Font("Lucida Grande", 0, 18)); // NOI18N
366 jLabelSnelheid.setText("Snelheid");
367
368 jButtonEndSimulation.setForeground(new java.awt.Color(255, 0, 0));
369 jButtonEndSimulation.setText("END Simulation");
370 jButtonEndSimulation.addActionListener(new java.awt.event.ActionListener() {
371 public void actionPerformed(java.awt.event.ActionEvent evt) {
372 jButtonEndSimulationActionPerformed(evt);
373 }
374 });
375
376 jCompass.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
377
378 javax.swing.GroupLayout jCompassLayout = new javax.swing.GroupLayout(jCompass);
379 jCompass.setLayout(jCompassLayout);
380 jCompassLayout.setHorizontalGroup(
381 jCompassLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
382 .addGap(0, 87, Short.MAX_VALUE)
383 );
384 jCompassLayout.setVerticalGroup(
385 jCompassLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
386 .addGap(0, 90, Short.MAX_VALUE)
387 );
388
389 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
390 getContentPane().setLayout(layout);
391 layout.setHorizontalGroup(
392 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
393 .addGroup(layout.createSequentialGroup()
394 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
395 .addGroup(layout.createSequentialGroup()
396 .addComponent(jLabelTime)
397 .addGap(14, 14, 14)
398 .addComponent(jLabelNames, javax.swing.GroupLayout.DEFAULT_SIZE, 477, Short.MAX_VALUE)
399 .addGap(8, 8, 8)
400 .addComponent(jTogglePower))
401 .addGroup(layout.createSequentialGroup()
402 .addComponent(jButtonEndSimulation, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)
403 .addGap(100, 100, 100)
404 .addComponent(jLabelSnelheid, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE)
405 .addGap(151, 151, 151)
406 .addComponent(jCompass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
407 .addGroup(layout.createSequentialGroup()
408 .addGap(13, 13, 13)
409 .addComponent(jControl, javax.swing.GroupLayout.DEFAULT_SIZE, 641, Short.MAX_VALUE)))
410 .addContainerGap())
411 );
412 layout.setVerticalGroup(
413 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
414 .addGroup(layout.createSequentialGroup()
415 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
416 .addComponent(jLabelNames)
417 .addComponent(jLabelTime)
418 .addComponent(jTogglePower))
419 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
420 .addComponent(jControl, javax.swing.GroupLayout.DEFAULT_SIZE, 352, Short.MAX_VALUE)
421 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
422 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
423 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
424 .addComponent(jLabelSnelheid, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
425 .addComponent(jButtonEndSimulation, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE))
426 .addComponent(jCompass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
427 .addContainerGap())
428 );
429
430 pack();
431 }// </editor-fold>//GEN-END:initComponents
432
433 private void jTogglePowerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTogglePowerActionPerformed
434 powerDevice();
435}//GEN-LAST:event_jTogglePowerActionPerformed
436
437 private void jButtonQActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonQActionPerformed
438 /**
439 * @todo: Find a way to generate all buttons on the fly or hardcode them
440 */
441 jTextFieldDestination.setText(jTextFieldDestination.getText().concat("q"));
442}//GEN-LAST:event_jButtonQActionPerformed
443
444 private void jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOKActionPerformed
445 jXMapKit1.setAddressLocation(new GeoPosition(52.161087, 4.490153));
446 jControl.setSelectedIndex(0);
447}//GEN-LAST:event_jButtonOKActionPerformed
448
449 private void jButtonBcspActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBcspActionPerformed
450 String tmpString = jTextFieldDestination.getText();
451 jTextFieldDestination.setText(tmpString.substring(0, tmpString.length() - 1));
452}//GEN-LAST:event_jButtonBcspActionPerformed
453
454 private void jButtonFileSimulationBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonFileSimulationBrowseActionPerformed
455 final JFileChooser fc = new JFileChooser();
456 int returnVal = fc.showOpenDialog(null);
457 if (returnVal == JFileChooser.APPROVE_OPTION) {
458 jTextFieldFileSimulation.setText(fc.getSelectedFile().getAbsolutePath());
459 }
460}//GEN-LAST:event_jButtonFileSimulationBrowseActionPerformed
461
462 private void jButtonSimulationStatusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSimulationStatusActionPerformed
463
464 jButtonEndSimulation.setVisible(true);
465 jControl.setSelectedIndex(0);
466 simulateDrive = new SimulateDrive(jTextFieldFileSimulation.getText());
467 new Thread(simulateDrive).start();
468 clockTimer.cancel();//GEN-LAST:event_jButtonSimulationStatusActionPerformed
469
470
471 }
472
473 private void jButtonEndSimulationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonEndSimulationActionPerformed
474 simulateDrive.terminate();
475 /** @todo how to fix clock start/start signaling or seperate tread? */
476 //clockTimer.notify();
477 jButtonEndSimulation.setVisible(false);
478 }//GEN-LAST:event_jButtonEndSimulationActionPerformed
479
480 /**
481 * @param args the command line arguments
482 */
483 public static void main(String args[]) {
484 java.awt.EventQueue.invokeLater(new Runnable() {
485 @Override
486 public void run() {
487 new MainJFrame().setVisible(true);
488 }
489 });
490 }
491 public void close() {
492 clockTimer.cancel();
493 }
494
495 // Variables declaration - do not modify//GEN-BEGIN:variables
496 private javax.swing.JButton jButtonBcsp;
497 private javax.swing.JButton jButtonEndSimulation;
498 private javax.swing.JButton jButtonFileSimulationBrowse;
499 private javax.swing.JButton jButtonOK;
500 private javax.swing.JButton jButtonQ;
501 private javax.swing.JButton jButtonSimulationStatus;
502 private javax.swing.JPanel jCompass;
503 private javax.swing.JTabbedPane jControl;
504 private javax.swing.JLabel jLabel1;
505 private javax.swing.JLabel jLabelFileSimulation;
506 private javax.swing.JLabel jLabelNames;
507 private javax.swing.JLabel jLabelSimulationSpeed;
508 private javax.swing.JLabel jLabelSnelheid;
509 private javax.swing.JLabel jLabelTime;
510 private javax.swing.JPanel jPanel1;
511 private javax.swing.JPanel jPanel2;
512 private javax.swing.JPanel jPanel3;
513 private javax.swing.JSlider jSliderSimulationSpeed;
514 private javax.swing.JTextField jTextFieldDestination;
515 private javax.swing.JTextField jTextFieldFileSimulation;
516 private javax.swing.JToggleButton jTogglePower;
517 private org.jdesktop.swingx.JXMapKit jXMapKit1;
518 // End of variables declaration//GEN-END:variables
519
520}
Note: See TracBrowser for help on using the repository browser.