/** * Method called when the user inputs an address on the user interface and they want to see the * closes bus stops. * * @param address the user entered address */ public void searchPressedAction(String address) { mainView.enableRefresh(false); this.lastAddress = address; try { if (address != null && address.length() > 0) { // Get closest stops to address ArrayList<RouteStopGeoPositionDTO> closestStops = mainModel.getStopsForDisplay(address); // Get stops with next bus times added ArrayList<Stop> stopsList = mainModel.addNextBusTimes(closestStops); // Clear out Route and Stop Information resetAll(); // Update Stops Table with Closest Stops String[][] closestStopsArray = StopsToArray.convert(closestStops); mainView.enableRefresh(stopsExist(closestStopsArray.length)); mainView.updateStopsTable(closestStopsArray); // Draw Closest Stops on Map drawClosestMapStops(stopsList, address); // Update Status mainView.updateStatus(MainView.DEFAULT_STATUS); } } catch (ServiceUnavailableException e) { mainView.notifyAndExit(MainView.NEXTBUS_SERVICE_UNAVAILABLE); } catch (InvalidAddressException e) { mainView.updateStatus(MainView.INVALID_ADDRESS); } }