Package com.nnamo.view.frame
Class MainFrame
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
com.nnamo.view.frame.MainFrame
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
,RootPaneContainer
,WindowConstants
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
Nested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow, Window.Type
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
Fields inherited from class javax.swing.JFrame
accessibleContext, rootPane, rootPaneCheckingEnabled
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs the main application frame, initializing all UI panels and layout. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clears the favorites table in the prefer panel.void
close()
Hides the main frame.Returns the current route ID from the map panel.Returns the current stop icon from the map panel's stop painter.Returns the current stop ID from the map panel.org.jxmapviewer.viewer.GeoPosition
Returns the current stop position from the map panel.Returns the map panel instance.Returns the stop panel instance.void
initLeftPanelPreferPanelPreferTable
(List<StopModel> stops, List<RouteDirection> routes) Initializes the favorites table in the left panel's prefer panel.void
initPreferPanelTable
(List<StopModel> favoriteStops, List<RouteDirection> favoriteRoutes) Initializes the favorites table in the prefer panel with the provided stops and routes.void
open()
Makes the main frame visible.void
Removes the route painting from the map panel.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.void
renderSearchPanel
(List<StopModel> stops, List<RouteDirection> routes) Renders the search panel with the provided stops and routes.void
renderStops
(List<StopModel> stops) Renders the provided list of stops on the map panel.void
renderVehiclePositions
(List<com.google.transit.realtime.GtfsRealtime.VehiclePosition> realtimePositions, List<StaticVehiclePosition> staticPositions) Renders the provided vehicle positions on the map panel.void
Repaints the map panel and its overlays.void
Sets the general button panel behavior in the left panel.void
Sets the prefer button panel behavior in the left panel.void
setClickWaypointBehaviour
(WaypointBehaviour waypointBehaviour) Sets the waypoint click behavior in the map panel.void
setCurrentRouteId
(String routeId) Sets the current route ID in the map panel.void
setCurrentStop
(String stopId, org.jxmapviewer.viewer.GeoPosition position) Sets the current stop ID and position in the map panel.void
setGeneralFavBehaviour
(FavoriteBehaviour behaviour) Sets the general favorite behavior in the favorites bar.void
Sets the generic table row click behavior for the left and stop panels.void
setLocalMapCache
(File cacheDir) Sets the local cache directory for map tiles in the map panel.void
setLogoutBehaviour
(LogoutBehaviour behaviour) Sets the logout behavior in the left panel.void
setMapPanelMapPosition
(org.jxmapviewer.viewer.GeoPosition geoPosition, int zoomLevel) Sets the map panel's position and zoom level.void
setPreferPanelListener
(SearchBarListener listener) Sets the prefer panel listener in the left panel.void
setRealtimeStatus
(RealtimeStatus status) Sets the real-time status in the left panel.void
setRealtimeSwitchListener
(SwitchBarListener listener) Sets the real-time switch listener in the left panel.void
setSearchPanelListener
(SearchBarListener listener) Sets the search panel listener in the left panel.void
setupStatisticsPanel
(RealtimeGtfsService realtimeService, Map<RealtimeMetricType, List<RealtimeMetricModel>> metricsMap, MetricCollector collector) Sets up the statistics panel in the left panel with the provided services.void
updateFavRouteTable
(List<RouteDirection> route, UpdateMode updateMode) Updates the favorite routes table in the left panel.void
updateFavStopTable
(StopModel stop, UpdateMode updateMode) Updates the favorite stops table in the left panel.void
updateLeftPanelModularPanel
(JPanel panel, boolean isVisible) Updates the modular panel in the left panel.void
updateLeftPanelVisibility
(boolean visible) Sets the visibility of the favorites bar.void
updatePreferBarVisibility
(boolean visible) Sets the visibility of the favorites bar.void
updatePreferButton
(String itemId, boolean isFav, DataType dataType) Updates the favorite button in the favorites bar.void
updateStopPanelInfo
(String id, String nome) Updates the stop panel with stop information.void
updateStopPanelRoutes
(List<List<String>> uniqueRoutes) Updates the stop panel with available routes.void
updateStopPanelTimes
(List<StopTimeModel> stopTimes, List<RealtimeStopUpdate> realtimeUpdates) Updates the stop panel with stop times and real-time updates.void
updateStopPanelVisibility
(boolean visible) Sets the visibility of the stop panel.Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setTitle, setUndecorated
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, setVisible, show, toBack, toFront
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
-
Constructor Details
-
MainFrame
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
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:
-
setCurrentStop
Sets the current stop ID and position in the map panel.- Parameters:
stopId
- the stop ID to setposition
- theGeoPosition
to set- See Also:
-
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 routerealtimePositions
- the list of vehicle positionsrouteId
- the route ID to setgeoPosition
- the map position to center onzoomLevel
- the zoom level to set- See Also:
-
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 displaystaticPositions
- the list of static vehicle positions to display if no real-time data is available- See Also:
-
updateStopPanelInfo
Updates the stop panel with stop information.- Parameters:
id
- the stop IDnome
- 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 timesrealtimeUpdates
- the list of real-time updates- See Also:
-
updateStopPanelRoutes
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
Updates the modular panel in the left panel.- Parameters:
panel
- the panel to updateisVisible
- true to show, false to hide
-
updatePreferButton
Updates the favorite button in the favorites bar.- Parameters:
itemId
- the item IDisFav
- true if favorite, false otherwisedataType
- the data type (STOP or ROUTE)- See Also:
-
removeRoutePainting
public void removeRoutePainting()Removes the route painting from the map panel. -
getMapPanel
Returns the map panel instance.- Returns:
- the
MapPanel
-
getCurrentStopId
Returns the current stop ID from the map panel.- Returns:
- the current stop ID
-
getCurrentRouteId
Returns the current route ID from the map panel.- Returns:
- the current route ID
-
setCurrentRouteId
Sets the current route ID in the map panel.- Parameters:
routeId
- the route ID to set
-
getStopPanel
Returns the stop panel instance.- Returns:
- the
StopPanel
-
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 onzoomLevel
- the zoom level to set- See Also:
-
setLocalMapCache
Sets the local cache directory for map tiles in the map panel.- Parameters:
cacheDir
- the cache directory- See Also:
-
initLeftPanelPreferPanelPreferTable
Initializes the favorites table in the left panel's prefer panel.- Parameters:
stops
- the list of favorite stopsroutes
- the list of favorite routes- See Also:
-
updateFavStopTable
Updates the favorite stops table in the left panel.- Parameters:
stop
- the stop to updateupdateMode
- the update mode (ADD or REMOVE)- See Also:
-
updateFavRouteTable
Updates the favorite routes table in the left panel.- Parameters:
route
- the list of routes to updateupdateMode
- the update mode (ADD or REMOVE)- See Also:
-
setLogoutBehaviour
Sets the logout behavior in the left panel.- Parameters:
behaviour
- the logout behavior implementation- See Also:
-
setClickWaypointBehaviour
Sets the waypoint click behavior in the map panel.- Parameters:
waypointBehaviour
- the waypoint behavior implementation- See Also:
-
setRealtimeStatus
Sets the real-time status in the left panel.- Parameters:
status
- the real-time status- See Also:
-
setGenericTableRowClickBehaviour
Sets the generic table row click behavior for the left and stop panels.- Parameters:
listener
- the table row click behavior implementation- See Also:
-
setGeneralFavBehaviour
Sets the general favorite behavior in the favorites bar.- Parameters:
behaviour
- the favorite behavior implementation- See Also:
-
setButtonPanelGeneralBehaviour
Sets the general button panel behavior in the left panel.- Parameters:
listener
- the button panel behavior implementation- See Also:
-
setButtonPanelPreferBehaviour
Sets the prefer button panel behavior in the left panel.- Parameters:
listener
- the button panel behavior implementation- See Also:
-
setRealtimeSwitchListener
Sets the real-time switch listener in the left panel.- Parameters:
listener
- the switch bar listener implementation- See Also:
-
setSearchPanelListener
Sets the search panel listener in the left panel.- Parameters:
listener
- the search bar listener implementation- See Also:
-
setPreferPanelListener
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 servicemetricsMap
- the map of real-time metricscollector
- 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 stopsfavoriteRoutes
- the list of favorite routes- See Also:
-
renderSearchPanel
Renders the search panel with the provided stops and routes.- Parameters:
stops
- the list of stops to displayroutes
- the list of routes to display- See Also:
-