java.lang.Object
no.ntnu.principes.controller.screen.ScreenController
Controls the navigation and display of screens and modals in the application.
Manages screen transitions, modal dialogs, and maintains navigation history.
-
Constructor Summary
ConstructorsConstructorDescriptionScreenController(StageController stageController) Manages the initialization and hierarchical layout of the graphical user interface, including the setup of containers for main screens, modals, and the title bar. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddScreen(String name, BaseScreen screen) Adds a screen to the collection, associating it with a unique name.booleanChecks if the navigation stack has more than one screen, indicating that the user can navigate back to a previous screen.voidclose()Cleans up resources used by the current instance.getContext(String screenId) Eases the process of obtaining aScreenContextfor a given screen ID.Retrieves the current modal ID from the modal stack.Retrieves the current modal instance if it is of typeBaseModal.javafx.scene.ParentRetrieves the currently active screen in the screen container.javafx.beans.value.ObservableStringValueRetrieves the current screen ID as an observable string value.inthashCode()booleanChecks if there are any open modals in the modal stack.voidremoveScreen(String name) Removes a screen and its associated context.voidutility(javafx.scene.Node node) Sets the main container to display a utility node.
-
Constructor Details
-
ScreenController
Manages the initialization and hierarchical layout of the graphical user interface, including the setup of containers for main screens, modals, and the title bar. also links its operations to a specifiedStageController.- Parameters:
stageController- TheStageControllerfor which this ScreenController is managing screens and modals for.
-
-
Method Details
-
addScreen
Adds a screen to the collection, associating it with a unique name. The screen can later be retrieved or manipulated by its name.- Parameters:
name- A unique identifier for the screen. Must not be null or empty. If a screen with the same name already exists, it will be replaced.screen- The screen instance to add. Must not be null.
-
removeScreen
Removes a screen and its associated context. This includes removing the screen from the screen registry, clearing its context, and removing any references from navigation and modal stacks.- Parameters:
name- The unique identifier of the screen to be removed. Must not be null or empty. If the screen does not exist, no action will be performed.
-
getContext
Eases the process of obtaining aScreenContextfor a given screen ID. -
getCurrentScreen
public javafx.scene.Parent getCurrentScreen()Retrieves the currently active screen in the screen container.- Returns:
- The currently active
Parentscreen, ornullif no screens are present in the container.
-
getCurrentModalInstance
Retrieves the current modal instance if it is of typeBaseModal. -
canGoBack
public boolean canGoBack()Checks if the navigation stack has more than one screen, indicating that the user can navigate back to a previous screen.- Returns:
trueif there is a previous screen to navigate back to;falseotherwise.
-
hasOpenModals
public boolean hasOpenModals()Checks if there are any open modals in the modal stack.- Returns:
trueif there are open modals;falseotherwise.
-
getCurrentScreenId
public javafx.beans.value.ObservableStringValue getCurrentScreenId()Retrieves the current screen ID as an observable string value.- Returns:
- The current screen ID as an
ObservableStringValue.
-
getCurrentModalId
Retrieves the current modal ID from the modal stack.- Returns:
- The current modal ID as a string, or
nullif no modals are open.
-
utility
public void utility(javafx.scene.Node node) Sets the main container to display a utility node.This method is used to display a utility node in the main container, for utility stages, like the sidebar and debug windows.
- Parameters:
node- The node to be displayed in the main container.
-
close
public void close()Cleans up resources used by the current instance.This method removes any listeners and clears stored data to ensure the instance is properly reset and does not hold onto unnecessary references.
- Calls
tearDownListeners()to deregister any attached listeners. - Invokes
clear()to remove any internal state or data.
- Calls
-
hashCode
public int hashCode()
-