Changeset 245 in tmcsimulator for trunk/src/atmsdriver/GoogleMapAnimator.java
- Timestamp:
- 02/07/2019 03:11:53 PM (7 years ago)
- File:
-
- 1 copied
-
trunk/src/atmsdriver/GoogleMapAnimator.java (copied) (copied from trunk/src/atmsdriver/TrafficEventsAnimator.java) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/atmsdriver/GoogleMapAnimator.java
r232 r245 5 5 import java.io.FileInputStream; 6 6 import java.io.FileNotFoundException; 7 import java.io.PrintWriter; 7 8 import java.rmi.RemoteException; 8 9 import java.util.ArrayList; … … 20 21 21 22 /** 22 * Read and process all Traffic Events in a file and show 23 * resulting highway network. 24 * A snapshot of the highway model after each event is saved in a buffer 25 * and a graphical display allows the user to scroll through the history. 23 * Read and process all Traffic Events in a file and output 24 * a snapshot of the highway model after each event to a json file. 25 * This file can be read by Google maps. 26 26 * This application is used by Traffic Event authors to assist 27 27 * in verifying the correctness of their data file. 28 28 * @author jdalbey 29 29 */ 30 public class TrafficEventsAnimator extends javax.swing.JPanel30 public class GoogleMapAnimator extends javax.swing.JPanel 31 31 { 32 32 /** … … 53 53 private List<String> history; 54 54 /** 55 * name of events file obtained from properties 56 */ 57 private String events_file = ""; 58 /** 55 59 * Creates the JPanel and builds the highways and events. 56 60 */ 57 public TrafficEventsAnimator() throws RemoteException, SimulationException61 public GoogleMapAnimator() throws RemoteException, SimulationException 58 62 { 59 63 initComponents(); … … 69 73 + CONFIG_FILE_NAME; 70 74 Properties props = TrafficModelManager.loadProperties(propertiesFile); 71 75 events_file = props.getProperty("Events_File"); 72 76 FileInputStream fis = null; 73 77 try 74 78 { 75 fis = new FileInputStream( props.getProperty("Events_File"));79 fis = new FileInputStream(events_file); 76 80 } catch (FileNotFoundException ex) 77 81 { 78 82 Logger.getLogger(TrafficModelManager.class.getName()).log(Level.SEVERE, null, 79 "Missing Traffic Events file " + props.getProperty("Events_File"));83 "Missing Traffic Events file " + events_file); 80 84 System.exit(-1); 81 85 } … … 87 91 public void load() 88 92 { 89 txtDisplay.setText("Loading ...");93 txtDisplay.setText("Loading traffic events from: " + events_file); 90 94 history = new ArrayList<String>(); 91 95 // If we have any events left to process … … 98 102 highways.applyColorToHighwayStretch(nextEvent.routeNumber, nextEvent.dir, 99 103 nextEvent.postmile, nextEvent.range, nextEvent.color); 100 history.add(highways.toString()+"\n"+nextEvent.eventTime); 104 //history.add(highways.toString()+"\n"+nextEvent.eventTime); 105 106 // Output the highway model 107 String geojson = highways.toJson(); 108 //System.out.println(geojson); // diagnostic 109 PrintWriter out; 110 try 111 { 112 out = new PrintWriter("highways.json"); 113 out.print(geojson); 114 out.close(); 115 } 116 catch (FileNotFoundException ex) 117 { 118 Logger.getLogger(GoogleMapAnimator.class.getName()).log(Level.SEVERE, null, ex); 119 } 120 121 // Sleep 10 sec for the javascript page to load the file 122 try 123 { 124 Thread.sleep(10000); // pause 10 seconds 125 } 126 catch (InterruptedException ex) 127 { 128 Logger.getLogger(GoogleMapAnimator.class.getName()).log(Level.SEVERE, null, ex); 129 } 101 130 // Remove this event from the queue, we're done with it. 102 131 eventQueue.remove(); … … 120 149 txtDisplay = new javax.swing.JTextArea(); 121 150 151 setPreferredSize(new java.awt.Dimension(151, 92)); 152 122 153 scrollBar.addAdjustmentListener(new java.awt.event.AdjustmentListener() 123 154 { … … 140 171 .addComponent(scrollBar, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE) 141 172 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 142 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE))173 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 421, Short.MAX_VALUE)) 143 174 ); 144 175 layout.setVerticalGroup( 145 176 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 146 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)147 177 .addComponent(scrollBar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 178 .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 148 179 ); 149 180 }// </editor-fold>//GEN-END:initComponents … … 167 198 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 168 199 frame.setSize(1050,450); 169 TrafficEventsAnimator display = new TrafficEventsAnimator();200 GoogleMapAnimator display = new GoogleMapAnimator(); 170 201 frame.add(display); 171 202 frame.setVisible(true);
Note: See TracChangeset
for help on using the changeset viewer.
