Exemplo n.º 1
0
  /**
   * Retrieves a list of all the RouteConfigs for specified Agency and stores the result in a
   * MainModel variable
   */
  public void processAllRouteConfigs() {
    mainView.updateStatus("Address search disabled until Route Configs loaded...");
    try {
      long current = System.currentTimeMillis();
      RouteList routeList = mainModel.getRouteList();
      Map<String, RouteConfig> allRouteConfigs =
          new HashMap<String, RouteConfig>(routeList.getRoutes().size());

      mainView.setupProgressBar(routeList.getRoutes().size());
      int progressLength = 1;

      for (Route route : routeList.getRoutes()) {
        RouteConfig routeConfig = mainModel.getRouteConfig(route);
        allRouteConfigs.put(route.getTag(), routeConfig);
        mainView.updateProgressBar(progressLength++);
        Thread.sleep(1);
      }

      mainModel.setAllRouteConfigs(allRouteConfigs);
      mainView.updateStatus(
          "It took " + (System.currentTimeMillis() - current) + " ms to get all routeConfigs.");
      Thread.sleep(5000);
      mainView.updateStatus(MainView.DEFAULT_STATUS);

    } catch (InterruptedException | ServiceUnavailableException e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 2
0
  /**
   * Accepts Route Tag value to retrieve Route object. Gets list of GeoPosition points using Route
   * object. Draws route on map based on retrieved GeoPosition points.
   *
   * @param routeTag - Route Object Tag value (String)
   */
  private void drawMapRoute(String routeTag) {
    try {
      Route route = mainModel.getRoute(routeTag);
      RouteConfig routeConfig = mainModel.getRouteConfig(route);
      ArrayList<Path> ttfPaths = mainModel.getPathList(route);

      mapControl = mainView.getMapControl();
      mapControl.drawRoute(routeConfig, ttfPaths);
      mapControl.getAllOverlays();

      mainView.updateMapViewer();
    } catch (ServiceUnavailableException e) {
      mainView.notifyAndExit(MainView.NEXTBUS_SERVICE_UNAVAILABLE);
    }
  }