MATSIM
RunEventsHandlingExample.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * EventsReader
4  * *
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2009 by the members listed in the COPYING, *
8  * LICENSE and WARRANTY file. *
9  * email : info at matsim dot org *
10  * *
11  * *********************************************************************** *
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * See also COPYING, LICENSE and WARRANTY file *
18  * *
19  * *********************************************************************** */
20 package tutorial.programming.example06EventsHandling;
21 
25 
26 
27 
28 
36 
37 
38 
39  public static void main(String[] args) {
40 
41  //path to events file
42  String inputFile = "output/example5/ITERS/it.10/10.events.xml.gz";
43 
44  //create an event object
46 
47  //create the handler and add it
48  MyEventHandler1 handler1 = new MyEventHandler1();
49  MyEventHandler2 handler2 = new MyEventHandler2();
50  MyEventHandler3 handler3 = new MyEventHandler3();
51  events.addHandler(handler1);
52  events.addHandler(handler2);
53  events.addHandler(handler3);
54 
55  //create the reader and read the file
56  MatsimEventsReader reader = new MatsimEventsReader(events);
57  reader.readFile(inputFile);
58 
59  System.out.println("average travel time: " + handler2.getTotalTravelTime());
60  handler3.writeChart("output/departuresPerHour.png");
61 
62  System.out.println("Events file read!");
63  }
64 
65 }
void addHandler(final EventHandler handler)
static EventsManager createEventsManager()