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.-
Nested Class Summary
Nested classes/interfaces inherited from class javafx.application.Application
javafx.application.Application.Parameters
-
Field Summary
Fields inherited from class javafx.application.Application
STYLESHEET_CASPIAN, STYLESHEET_MODENA
-
Constructor Summary
ConstructorDescriptionConstructs aGraphicalApplication
initializing theMap
objects to keep track of scenes and controllers. -
Method Summary
Modifier and TypeMethodDescriptionvoid
changeScene
(SceneName sceneName) Changes the current scene and calls theController.onChangeScene()
method of the controller associated with the new scene.getControllerForPopup
(PopupName popupName) Getter for theController
associated with a given popup scene.getControllerForScene
(SceneName sceneName) Getter for theController
associated with a given scene.Getter for the current controller, which is theController
associated with the current scene returned from thegetCurrentScene()
method.Getter for the currentScene
.static GraphicalApplication
Static getter for the (unique) instance of the JavaFXApplication
.void
Hides a popup previously opened on the screen, if present.void
This method is called at the beginning of thestart(javafx.stage.Stage)
method.static void
Sets theclient
static attribute with a reference to theClient
.static void
setShowError
(Consumer<String> showError) static void
setShowInfo
(Consumer<String> showInfo) void
showStickyPopup
(PopupName popupName) Shows a popup on the screen (on top of the main scene).void
start
(javafx.stage.Stage primaryStage) Calls theinitialize()
method and then sets up the primary stage and starts the graphical application.Methods inherited from class javafx.application.Application
getHostServices, getParameters, getUserAgentStylesheet, init, launch, launch, notifyPreloader, setUserAgentStylesheet, stop
-
Constructor Details
-
GraphicalApplication
public GraphicalApplication()Constructs aGraphicalApplication
initializing theMap
objects to keep track of scenes and controllers. Saves a reference to theApplication
in a static attribute.
-
-
Method Details
-
getInstance
Static getter for the (unique) instance of the JavaFXApplication
.- Returns:
- a reference to the instance of the application
-
initialize
This method is called at the beginning of thestart(javafx.stage.Stage)
method. Initializes all the scenes and controllers and sets the initial scene.- Throws:
IOException
- if theFXMLLoader
fails loading
-
start
Calls theinitialize()
method and then sets up the primary stage and starts the graphical application.- Specified by:
start
in classjavafx.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
Changes the current scene and calls theController.onChangeScene()
method of the controller associated with the new scene.- Parameters:
sceneName
- the name of the scene to change to
-
setClient
Sets theclient
static attribute with a reference to theClient
.- Parameters:
client
- the reference to the client object
-
setShowInfo
- Parameters:
showInfo
- the reference to theshowInfo
method
-
setShowError
- Parameters:
showError
- the reference to theshowError
method
-
getCurrentScene
Getter for the currentScene
.- Returns:
- a reference to the current scene
-
getCurrentController
Getter for the current controller, which is theController
associated with the current scene returned from thegetCurrentScene()
method.- Returns:
- a reference to the current controller
-
getControllerForScene
Getter for theController
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
Getter for theController
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
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.
-