Class StageManager

java.lang.Object
no.ntnu.principes.controller.StageManager

public class StageManager extends Object
Manages JavaFX Stage instances through their StageController wrappers. Provides centralized access to named stages and coordinates their behavior. Implemented as a singleton to ensure a single point of management for all application stages.
  • Field Details

  • Constructor Details

    • StageManager

      public StageManager(double width, double height)
      Creates a new StageManager with specified window dimensions.
      Parameters:
      width - Initial default width for new stages
      height - Initial default height for new stages
  • Method Details

    • getInstance

      public static StageManager getInstance()
      Gets the singleton instance of StageManager.
      Returns:
      The StageManager instance with default dimensions
    • getController

      public StageController getController(String name)
      Gets a StageController by name, creating a new one if it doesn't exist. Uses default dimensions and a new Stage.
      Parameters:
      name - The unique name for the controller
      Returns:
      The existing or newly created StageController
    • hasController

      public boolean hasController(String name)
      Checks if a StageController with the given name exists.
      Parameters:
      name - The name to check
      Returns:
      true if a controller with that name exists, false otherwise
    • getController

      public StageController getController(String name, javafx.stage.Stage stage, double width, double height, boolean isUtility)
      Gets a StageController by name with custom parameters, creating a new one if it doesn't exist.
      Parameters:
      name - The unique name for the controller
      stage - The JavaFX Stage to use
      width - The width for the stage
      height - The height for the stage
      isUtility - Whether this is a utility stage
      Returns:
      The existing or newly created StageController
    • getController

      public StageController getController(String name, double width, double height)
      Gets a StageController by name with custom dimensions, creating a new one if it doesn't exist. Uses a new Stage.
      Parameters:
      name - The unique name for the controller
      width - The width for the stage
      height - The height for the stage
      Returns:
      The existing or newly created StageController
    • getUtilityController

      public StageController getUtilityController(String name, double width, double height)
      Gets a utility StageController by name, creating a new one if it doesn't exist. Utility stages have different behavior than regular stages.
      Parameters:
      name - The unique name for the controller
      width - The width for the stage
      height - The height for the stage
      Returns:
      The existing or newly created utility StageController
    • getMainController

      public StageController getMainController(javafx.stage.Stage stage)
      Gets the main StageController, creating it if it doesn't exist. The main stage has special handling for application-wide stage events: - It closes all other stages when closed - It hides/shows all other stages when hidden/shown
      Parameters:
      stage - The JavaFX Stage to use as the main stage
      Returns:
      The main StageController
    • removeController

      public void removeController(String name)
      Removes a StageController by name, closing its stage and cleaning up resources.
      Parameters:
      name - The name of the controller to remove