Changeset 245 in tmcsimulator for trunk


Ignore:
Timestamp:
02/07/2019 03:11:53 PM (7 years ago)
Author:
jdalbey
Message:

Added experimental utility: GoogleMapAnimator?

Location:
trunk/src/atmsdriver
Files:
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/atmsdriver/GoogleMapAnimator.form

    r232 r245  
    22 
    33<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> 
     4  <Properties> 
     5    <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> 
     6      <Dimension value="[151, 92]"/> 
     7    </Property> 
     8  </Properties> 
    49  <AuxValues> 
    510    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> 
     
    2025              <Component id="scrollBar" min="-2" pref="24" max="-2" attributes="0"/> 
    2126              <EmptySpace max="-2" attributes="0"/> 
    22               <Component id="jScrollPane1" pref="388" max="32767" attributes="0"/> 
     27              <Component id="jScrollPane1" pref="421" max="32767" attributes="0"/> 
    2328          </Group> 
    2429      </Group> 
     
    2631    <DimensionLayout dim="1"> 
    2732      <Group type="103" groupAlignment="0" attributes="0"> 
    28           <Component id="jScrollPane1" pref="300" max="32767" attributes="0"/> 
    2933          <Component id="scrollBar" alignment="0" max="32767" attributes="0"/> 
     34          <Component id="jScrollPane1" min="-2" max="-2" attributes="0"/> 
    3035      </Group> 
    3136    </DimensionLayout> 
  • trunk/src/atmsdriver/GoogleMapAnimator.java

    r232 r245  
    55import java.io.FileInputStream; 
    66import java.io.FileNotFoundException; 
     7import java.io.PrintWriter; 
    78import java.rmi.RemoteException; 
    89import java.util.ArrayList; 
     
    2021 
    2122/** 
    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.  
    2626 * This application is used by Traffic Event authors to assist 
    2727 * in verifying the correctness of their data file. 
    2828 * @author jdalbey 
    2929 */ 
    30 public class TrafficEventsAnimator extends javax.swing.JPanel 
     30public class GoogleMapAnimator extends javax.swing.JPanel 
    3131{ 
    3232    /** 
     
    5353    private List<String> history; 
    5454    /** 
     55     * name of events file obtained from properties 
     56     */ 
     57    private String events_file = "";  
     58    /** 
    5559     * Creates the JPanel and builds the highways and events.  
    5660     */ 
    57     public TrafficEventsAnimator() throws RemoteException, SimulationException 
     61    public GoogleMapAnimator() throws RemoteException, SimulationException 
    5862    { 
    5963        initComponents(); 
     
    6973                 + CONFIG_FILE_NAME; 
    7074        Properties props = TrafficModelManager.loadProperties(propertiesFile); 
    71  
     75        events_file = props.getProperty("Events_File"); 
    7276        FileInputStream fis = null; 
    7377        try 
    7478        { 
    75             fis = new FileInputStream(props.getProperty("Events_File")); 
     79            fis = new FileInputStream(events_file); 
    7680        } catch (FileNotFoundException ex) 
    7781        { 
    7882            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); 
    8084            System.exit(-1); 
    8185        } 
     
    8791    public void load() 
    8892    { 
    89         txtDisplay.setText("Loading ..."); 
     93        txtDisplay.setText("Loading traffic events from: " + events_file); 
    9094        history = new ArrayList<String>(); 
    9195        // If we have any events left to process 
     
    98102            highways.applyColorToHighwayStretch(nextEvent.routeNumber, nextEvent.dir, 
    99103                    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            } 
    101130            // Remove this event from the queue, we're done with it. 
    102131            eventQueue.remove(); 
     
    120149        txtDisplay = new javax.swing.JTextArea(); 
    121150 
     151        setPreferredSize(new java.awt.Dimension(151, 92)); 
     152 
    122153        scrollBar.addAdjustmentListener(new java.awt.event.AdjustmentListener() 
    123154        { 
     
    140171                .addComponent(scrollBar, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE) 
    141172                .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)) 
    143174        ); 
    144175        layout.setVerticalGroup( 
    145176            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
    146             .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE) 
    147177            .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) 
    148179        ); 
    149180    }// </editor-fold>//GEN-END:initComponents 
     
    167198        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
    168199        frame.setSize(1050,450); 
    169         TrafficEventsAnimator display = new TrafficEventsAnimator(); 
     200        GoogleMapAnimator display = new GoogleMapAnimator(); 
    170201        frame.add(display); 
    171202        frame.setVisible(true); 
Note: See TracChangeset for help on using the changeset viewer.