Class MainFrame

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants

public class MainFrame extends JFrame
Custom JFrame that composes and manages the primary UI panels, including the map, stop details, favorites bar, and navigation panels.
Author:
Riccardo Finocchiaro, Samuele Lombardi, Davide Galilei
See Also:
  • Constructor Details

    • MainFrame

      public MainFrame() throws IOException
      Constructs the main application frame, initializing all UI panels and layout. Sets up split panes for navigation and content, and configures the application icon.
      Throws:
      IOException - if an error occurs during map panel initialization
      See Also:
  • Method Details

    • open

      public void open()
      Makes the main frame visible.
    • close

      public void close()
      Hides the main frame.
    • renderStops

      public void renderStops(List<StopModel> stops)
      Renders the provided list of stops on the map panel.
      Parameters:
      stops - the list of stops to display
      See Also:
    • getCurrentStopPosition

      public org.jxmapviewer.viewer.GeoPosition getCurrentStopPosition()
      Returns the current stop position from the map panel.
      Returns:
      the current stop GeoPosition
      See Also:
      • GeoPosition
    • setCurrentStop

      public void setCurrentStop(String stopId, org.jxmapviewer.viewer.GeoPosition position)
      Sets the current stop ID and position in the map panel.
      Parameters:
      stopId - the stop ID to set
      position - the GeoPosition to set
      See Also:
      • GeoPosition
    • repaintMap

      public void repaintMap()
      Repaints the map panel and its overlays.
    • renderRouteLines

      public void renderRouteLines(List<StopModel> stopModels, List<com.google.transit.realtime.GtfsRealtime.VehiclePosition> realtimePositions, List<StaticVehiclePosition> staticPositions, String routeId, org.jxmapviewer.viewer.GeoPosition geoPosition, int zoomLevel)
      Renders route lines and vehicle positions on the map panel, and updates the current route and map position.
      Parameters:
      stopModels - the list of stops representing the route
      realtimePositions - the list of vehicle positions
      routeId - the route ID to set
      geoPosition - the map position to center on
      zoomLevel - the zoom level to set
      See Also:
      • StopModel
      • GtfsRealtime.VehiclePosition
      • GeoPosition
    • renderVehiclePositions

      public void renderVehiclePositions(List<com.google.transit.realtime.GtfsRealtime.VehiclePosition> realtimePositions, List<StaticVehiclePosition> staticPositions)
      Renders the provided vehicle positions on the map panel.
      Parameters:
      realtimePositions - the list of real-time vehicle positions to display
      staticPositions - the list of static vehicle positions to display if no real-time data is available
      See Also:
      • GtfsRealtime.VehiclePosition
    • updateStopPanelInfo

      public void updateStopPanelInfo(String id, String nome)
      Updates the stop panel with stop information.
      Parameters:
      id - the stop ID
      nome - the stop name
    • updateStopPanelTimes

      public void updateStopPanelTimes(List<StopTimeModel> stopTimes, List<RealtimeStopUpdate> realtimeUpdates)
      Updates the stop panel with stop times and real-time updates.
      Parameters:
      stopTimes - the list of stop times
      realtimeUpdates - the list of real-time updates
      See Also:
    • updateStopPanelRoutes

      public void updateStopPanelRoutes(List<List<String>> uniqueRoutes)
      Updates the stop panel with available routes.
      Parameters:
      uniqueRoutes - the list of unique routes
    • updateStopPanelVisibility

      public void updateStopPanelVisibility(boolean visible)
      Sets the visibility of the stop panel.
      Parameters:
      visible - true to show, false to hide
    • updatePreferBarVisibility

      public void updatePreferBarVisibility(boolean visible)
      Sets the visibility of the favorites bar.
      Parameters:
      visible - true to show, false to hide
    • updateLeftPanelVisibility

      public void updateLeftPanelVisibility(boolean visible)
      Sets the visibility of the favorites bar.
      Parameters:
      visible - true to show, false to hide
    • updateLeftPanelModularPanel

      public void updateLeftPanelModularPanel(JPanel panel, boolean isVisible)
      Updates the modular panel in the left panel.
      Parameters:
      panel - the panel to update
      isVisible - true to show, false to hide
    • updatePreferButton

      public void updatePreferButton(String itemId, boolean isFav, DataType dataType)
      Updates the favorite button in the favorites bar.
      Parameters:
      itemId - the item ID
      isFav - true if favorite, false otherwise
      dataType - the data type (STOP or ROUTE)
      See Also:
    • removeRoutePainting

      public void removeRoutePainting()
      Removes the route painting from the map panel.
    • getMapPanel

      public MapPanel getMapPanel()
      Returns the map panel instance.
      Returns:
      the MapPanel
    • getCurrentStopId

      public String getCurrentStopId()
      Returns the current stop ID from the map panel.
      Returns:
      the current stop ID
    • getCurrentRouteId

      public String getCurrentRouteId()
      Returns the current route ID from the map panel.
      Returns:
      the current route ID
    • setCurrentRouteId

      public void setCurrentRouteId(String routeId)
      Sets the current route ID in the map panel.
      Parameters:
      routeId - the route ID to set
    • getStopPanel

      public StopPanel getStopPanel()
      Returns the stop panel instance.
      Returns:
      the StopPanel
    • getCurrentStopIcon

      public BufferedImage getCurrentStopIcon()
      Returns the current stop icon from the map panel's stop painter.
      Returns:
      the current stop BufferedImage icon
    • setMapPanelMapPosition

      public void setMapPanelMapPosition(org.jxmapviewer.viewer.GeoPosition geoPosition, int zoomLevel)
      Sets the map panel's position and zoom level.
      Parameters:
      geoPosition - the position to center the map on
      zoomLevel - the zoom level to set
      See Also:
      • GeoPosition
    • setLocalMapCache

      public void setLocalMapCache(File cacheDir)
      Sets the local cache directory for map tiles in the map panel.
      Parameters:
      cacheDir - the cache directory
      See Also:
    • initLeftPanelPreferPanelPreferTable

      public void initLeftPanelPreferPanelPreferTable(List<StopModel> stops, List<RouteDirection> routes)
      Initializes the favorites table in the left panel's prefer panel.
      Parameters:
      stops - the list of favorite stops
      routes - the list of favorite routes
      See Also:
    • updateFavStopTable

      public void updateFavStopTable(StopModel stop, UpdateMode updateMode)
      Updates the favorite stops table in the left panel.
      Parameters:
      stop - the stop to update
      updateMode - the update mode (ADD or REMOVE)
      See Also:
    • updateFavRouteTable

      public void updateFavRouteTable(List<RouteDirection> route, UpdateMode updateMode)
      Updates the favorite routes table in the left panel.
      Parameters:
      route - the list of routes to update
      updateMode - the update mode (ADD or REMOVE)
      See Also:
    • setLogoutBehaviour

      public void setLogoutBehaviour(LogoutBehaviour behaviour)
      Sets the logout behavior in the left panel.
      Parameters:
      behaviour - the logout behavior implementation
      See Also:
    • setClickWaypointBehaviour

      public void setClickWaypointBehaviour(WaypointBehaviour waypointBehaviour)
      Sets the waypoint click behavior in the map panel.
      Parameters:
      waypointBehaviour - the waypoint behavior implementation
      See Also:
    • setRealtimeStatus

      public void setRealtimeStatus(RealtimeStatus status)
      Sets the real-time status in the left panel.
      Parameters:
      status - the real-time status
      See Also:
    • setGenericTableRowClickBehaviour

      public void setGenericTableRowClickBehaviour(TableRowClickBehaviour listener)
      Sets the generic table row click behavior for the left and stop panels.
      Parameters:
      listener - the table row click behavior implementation
      See Also:
    • setGeneralFavBehaviour

      public void setGeneralFavBehaviour(FavoriteBehaviour behaviour)
      Sets the general favorite behavior in the favorites bar.
      Parameters:
      behaviour - the favorite behavior implementation
      See Also:
    • setButtonPanelGeneralBehaviour

      public void setButtonPanelGeneralBehaviour(ButtonPanelBehaviour listener)
      Sets the general button panel behavior in the left panel.
      Parameters:
      listener - the button panel behavior implementation
      See Also:
    • setButtonPanelPreferBehaviour

      public void setButtonPanelPreferBehaviour(ButtonPanelBehaviour listener)
      Sets the prefer button panel behavior in the left panel.
      Parameters:
      listener - the button panel behavior implementation
      See Also:
    • setRealtimeSwitchListener

      public void setRealtimeSwitchListener(SwitchBarListener listener)
      Sets the real-time switch listener in the left panel.
      Parameters:
      listener - the switch bar listener implementation
      See Also:
    • setSearchPanelListener

      public void setSearchPanelListener(SearchBarListener listener)
      Sets the search panel listener in the left panel.
      Parameters:
      listener - the search bar listener implementation
      See Also:
    • setPreferPanelListener

      public void setPreferPanelListener(SearchBarListener listener)
      Sets the prefer panel listener in the left panel.
      Parameters:
      listener - the search bar listener implementation
      See Also:
    • setupStatisticsPanel

      public void setupStatisticsPanel(RealtimeGtfsService realtimeService, Map<RealtimeMetricType,List<RealtimeMetricModel>> metricsMap, MetricCollector collector)
      Sets up the statistics panel in the left panel with the provided services.
      Parameters:
      realtimeService - the real-time GTFS service
      metricsMap - the map of real-time metrics
      collector - the metrics collector
      See Also:
    • clearPreferPanelTable

      public void clearPreferPanelTable()
      Clears the favorites table in the prefer panel.
    • initPreferPanelTable

      public void initPreferPanelTable(List<StopModel> favoriteStops, List<RouteDirection> favoriteRoutes)
      Initializes the favorites table in the prefer panel with the provided stops and routes.
      Parameters:
      favoriteStops - the list of favorite stops
      favoriteRoutes - the list of favorite routes
      See Also:
    • renderSearchPanel

      public void renderSearchPanel(List<StopModel> stops, List<RouteDirection> routes)
      Renders the search panel with the provided stops and routes.
      Parameters:
      stops - the list of stops to display
      routes - the list of routes to display
      See Also: