Package com.nnamo.controllers
Class MapController
java.lang.Object
com.nnamo.controllers.MapController
Controller responsible for managing map-related functionalities,
including waypoint interactions, route rendering, and vehicle position updates.
It interacts with the DatabaseService, MainFrame, and RealtimeGtfsService
to provide a seamless user experience on the map interface.
- Author:
- Samuele Lombardi, Riccardo Finocchiaro
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionMapController
(DatabaseService db, MainFrame mainFrame, RealtimeGtfsService realtimeService) -
Method Summary
Modifier and TypeMethodDescriptionstatic org.jxmapviewer.viewer.GeoPosition
calculateBarycenter
(List<StopModel> stopList) Calculate the geographical barycenter of a list of stops.static int
calculateZoomLevel
(List<StopModel> stopList) Calculate an appropriate zoom level based on the geographical spread of a list of stops.static void
renderRoutesVehicles
(List<StopModel> stopModels, RealtimeGtfsService realtimeService, MainFrame mainFrame, DatabaseService db, String routeId, Direction direction) void
run()
void
setSessionUser
(UserModel sessionUser) void
static void
updateVehiclePositions
(String routeId, MainFrame mainFrame, RealtimeGtfsService realtimeService, DatabaseService db)
-
Constructor Details
-
MapController
- Parameters:
db
- the database service for data accessmainFrame
- the main application frame for UI interactionsrealtimeService
- the real-time GTFS service for fetching live data- See Also:
-
-
Method Details
-
run
public void run() -
setSessionUser
-
setupWaypointBehavior
public void setupWaypointBehavior() -
calculateBarycenter
Calculate the geographical barycenter of a list of stops.- Parameters:
stopList
- List of StopModel objects representing the stops.- Returns:
- GeoPosition representing the calculated barycenter.
- Throws:
ArithmeticException
- if the stopList is empty.
-
calculateZoomLevel
Calculate an appropriate zoom level based on the geographical spread of a list of stops.- Parameters:
stopList
- List of StopModel objects representing the stops.- Returns:
- An integer representing the calculated zoom level.
-
renderRoutesVehicles
public static void renderRoutesVehicles(List<StopModel> stopModels, RealtimeGtfsService realtimeService, MainFrame mainFrame, DatabaseService db, String routeId, Direction direction) throws SQLException - Throws:
SQLException
-
updateVehiclePositions
public static void updateVehiclePositions(String routeId, MainFrame mainFrame, RealtimeGtfsService realtimeService, DatabaseService db) throws SQLException - Throws:
SQLException
-