/** Starts route generation after the calculate button has been pressed. */
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == calcButton) {
     OsmMap map = frame.getMap();
     List<Position> positions =
         routeCalculator.calculateRoute(map.getMarkers(), map, waySelection.getSelectedIndex());
     frame.getMap().createTrack(ROUTE_TRACK_NAME, positions);
   }
 }
  public RoutePlannerApp(String[] args) {
    frame = new MapViewFrame(args);
    frame.setTitle("OSM Route Planner");
    routeCalculator = createRouteCalculator();
    JToolBar toolbar = frame.getToolbar();
    toolbar.addSeparator();
    waySelection = new JComboBox(routeCalculator.getWaySelectionOptions());
    toolbar.add(waySelection);
    toolbar.addSeparator();
    calcButton = new JButton("Calculate Route");
    calcButton.setEnabled(frame.getMap().getMarkers().size() >= 2);
    calcButton.addActionListener(this);
    toolbar.add(calcButton);

    frame.getMap().addMapDataEventListener(new MapDataEventHandler());
  }
 /**
  * Loads the default map if necessary and returns the frame (useful for integration into an AIMA
  * demo application).
  */
 public MapViewFrame constructApplicationFrame() {
   if (frame.getMap().isEmpty()) frame.readMap(DataResource.getULMFileResource());
   return frame;
 }
 public void showFrame() {
   frame.setSize(800, 600);
   frame.setVisible(true);
 }