Class GraphicalApplication

java.lang.Object
javafx.application.Application
it.polimi.ingsw.eriantys.client.gui.GraphicalApplication

public class GraphicalApplication extends javafx.application.Application
This class represents the JavaFX Application and handles stages, scenes and controllers.
  • Constructor Details

    • GraphicalApplication

      public GraphicalApplication()
      Constructs a GraphicalApplication initializing the Map objects to keep track of scenes and controllers. Saves a reference to the Application in a static attribute.
  • Method Details

    • getInstance

      public static GraphicalApplication getInstance()
      Static getter for the (unique) instance of the JavaFX Application.
      Returns:
      a reference to the instance of the application
    • initialize

      public void initialize() throws IOException
      This method is called at the beginning of the start(javafx.stage.Stage) method. Initializes all the scenes and controllers and sets the initial scene.
      Throws:
      IOException - if the FXMLLoader fails loading
    • start

      public void start(javafx.stage.Stage primaryStage) throws IOException
      Calls the initialize() method and then sets up the primary stage and starts the graphical application.
      Specified by:
      start in class javafx.application.Application
      Parameters:
      primaryStage - The primary stage for this application, onto which the application scene can be set
      Throws:
      IOException - if the initialization fails
    • changeScene

      public void changeScene(SceneName sceneName)
      Changes the current scene and calls the Controller.onChangeScene() method of the controller associated with the new scene.
      Parameters:
      sceneName - the name of the scene to change to
    • setClient

      public static void setClient(Client client)
      Sets the client static attribute with a reference to the Client.
      Parameters:
      client - the reference to the client object
    • setShowInfo

      public static void setShowInfo(Consumer<String> showInfo)
      Sets a reference to the UserInterface.showInfo(String) method as a Consumer of String.
      Parameters:
      showInfo - the reference to the showInfo method
    • setShowError

      public static void setShowError(Consumer<String> showError)
      Sets a reference to the UserInterface.showError(String) method as a Consumer of String.
      Parameters:
      showError - the reference to the showError method
    • getCurrentScene

      public SceneName getCurrentScene()
      Getter for the current Scene.
      Returns:
      a reference to the current scene
    • getCurrentController

      public Controller getCurrentController()
      Getter for the current controller, which is the Controller associated with the current scene returned from the getCurrentScene() method.
      Returns:
      a reference to the current controller
    • getControllerForScene

      public Controller getControllerForScene(SceneName sceneName)
      Getter for the Controller associated with a given scene.
      Parameters:
      sceneName - the name of the scene to which the controller is associated
      Returns:
      the controller associated with the given scene
    • getControllerForPopup

      public Controller getControllerForPopup(PopupName popupName)
      Getter for the Controller associated with a given popup scene.
      Parameters:
      popupName - the name of the popup scene to which the controller is associated
      Returns:
      the controller associated with the given popup scene
    • showStickyPopup

      public void showStickyPopup(PopupName popupName)
      Shows a popup on the screen (on top of the main scene).
      Parameters:
      popupName - the name of the popup scene to show
    • hideStickyPopup

      public void hideStickyPopup()
      Hides a popup previously opened on the screen, if present.