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
ConstructorsConstructorDescriptionConstructs aGraphicalApplicationinitializing theMapobjects to keep track of scenes and controllers. -
Method Summary
Modifier and TypeMethodDescriptionvoidchangeScene(SceneName sceneName) Changes the current scene and calls theController.onChangeScene()method of the controller associated with the new scene.getControllerForPopup(PopupName popupName) Getter for theControllerassociated with a given popup scene.getControllerForScene(SceneName sceneName) Getter for theControllerassociated with a given scene.Getter for the current controller, which is theControllerassociated with the current scene returned from thegetCurrentScene()method.Getter for the currentScene.static GraphicalApplicationStatic getter for the (unique) instance of the JavaFXApplication.voidHides a popup previously opened on the screen, if present.voidThis method is called at the beginning of thestart(javafx.stage.Stage)method.static voidSets theclientstatic attribute with a reference to theClient.static voidsetShowError(Consumer<String> showError) static voidsetShowInfo(Consumer<String> showInfo) voidshowStickyPopup(PopupName popupName) Shows a popup on the screen (on top of the main scene).voidstart(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 aGraphicalApplicationinitializing theMapobjects to keep track of scenes and controllers. Saves a reference to theApplicationin 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 theFXMLLoaderfails loading
-
start
Calls theinitialize()method and then sets up the primary stage and starts the graphical application.- Specified by:
startin 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 theclientstatic attribute with a reference to theClient.- Parameters:
client- the reference to the client object
-
setShowInfo
- Parameters:
showInfo- the reference to theshowInfomethod
-
setShowError
- Parameters:
showError- the reference to theshowErrormethod
-
getCurrentScene
Getter for the currentScene.- Returns:
- a reference to the current scene
-
getCurrentController
Getter for the current controller, which is theControllerassociated with the current scene returned from thegetCurrentScene()method.- Returns:
- a reference to the current controller
-
getControllerForScene
Getter for theControllerassociated 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 theControllerassociated 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.
-