- java.lang.Object
-
- javafx.application.Application
-
- eu.ess.xaos.app.XAOSApplication
-
- Direct Known Subclasses:
SimpleApplication
public class XAOSApplication extends Application
This is the basic class from which any JavaFX applications based on the XAOS framework should inherit from.Note:
init(),start(javafx.stage.Stage), andstop()should never be overridden!- Author:
- claudio.rosati@esss.se
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javafx.application.Application
Application.Parameters
-
-
Field Summary
-
Fields inherited from class javafx.application.Application
STYLESHEET_CASPIAN, STYLESHEET_MODENA
-
-
Constructor Summary
Constructors Constructor Description XAOSApplication()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ScenegetScene()StagegetStage()voidinit()protected voidinitApplication()The application initialization method.This method is called immediately after theXAOSApplicationclass is loaded and constructed.voidstart(Stage stage)protected voidstartApplication(BorderPane sceneRoot)The main entry point for a XAOS application.protected voidstep()Tells thePreloaderthe application startup process is about to start the next step of progress.protected voidstep(int subSteps)Tells thePreloaderthe application startup process is about to start the next step of progress, which is itself split in the given number of sub-steps.protected voidstepsBegin(int steps)Tells thePreloaderthe application startup process is about to begin.protected voidstepsComplete()Tells thePreloaderthe application startup process is completed and the application's UI is about to be displayed.protected voidstepsIndeterminate()Tells thePreloaderthe application startup progress is indeterminate.voidstop()protected voidstopApplication()This method is called when the application should stop, and provides a convenient place to prepare for application exit and destroy resources.protected voidsubStep()Tells thePreloaderthe application startup process is about to start the next sub-step of progress.-
Methods inherited from class javafx.application.Application
getHostServices, getParameters, getUserAgentStylesheet, launch, launch, notifyPreloader, setUserAgentStylesheet
-
-
-
-
Method Detail
-
getScene
public Scene getScene()
- Returns:
- This application's
Sceneornullif the application is not yet started.
-
getStage
public Stage getStage()
- Returns:
- This application's
Stageornullif the application is not yet started.
-
init
public final void init() throws Exception- Overrides:
initin classApplication- Throws:
Exception
-
start
public final void start(Stage stage) throws Exception
- Specified by:
startin classApplication- Throws:
Exception
-
stop
public final void stop() throws Exception- Overrides:
stopin classApplication- Throws:
Exception
-
initApplication
protected void initApplication() throws ExceptionThe application initialization method.This method is called immediately after theXAOSApplicationclass is loaded and constructed. An application may override this method to perform initialization prior to the actual starting of the application.The implementation of this method provided by the
XAOSApplicationclass does nothing.Note: This method is not called on the JavaFX
ApplicationThread. An application must not construct aSceneor aStagein this method. An application may construct other JavaFX objects in this method.- Throws:
Exception- If something goes wrong.
-
startApplication
protected void startApplication(BorderPane sceneRoot) throws Exception
The main entry point for a XAOS application. ThestartApplicationmethod is called after theinitApplication()method has returned, and after the system is ready for the application to begin running.Inside this methods
Application.notifyPreloader(PreloaderNotification)can be invoked to inform thePreloaderof the current startup progress:notifyPreloader(new ProgressNotification(progress));
where
progressis a number between 0 (started) to 1 (completed).The implementation of this method provided by the
XAOSApplicationclass does nothing.Note: Contrarily to the
Application.start(Stage)method, this one is not called on the JavaFX Application Thread.- Parameters:
sceneRoot- TheBorderPaneroot container pre-installed in the application'sScene.- Throws:
Exception- If something goes wrong.
-
step
protected void step() throws IllegalStateExceptionTells thePreloaderthe application startup process is about to start the next step of progress. It must be call at the beginning of the step to be performed.For example:
stepsBegin(10); for ( int i = 0; i < 10; i++ ) { step(); ... } stepsComplete();- Throws:
IllegalStateException- If this method is called before thestepsBegin(int)one, or afterstepsComplete(), or more than the number of steps stated instepsBegin(int).
-
step
protected void step(int subSteps) throws IllegalArgumentException, IllegalStateExceptionTells thePreloaderthe application startup process is about to start the next step of progress, which is itself split in the given number of sub-steps. It must be call at the beginning of the step to be performed.For example:
stepsBegin(10); for ( int i = 0; i < 10; i++ ) { step(5); for ( int j = 0; j < 5; j++ ) { subStep() ... } } stepsComplete();- Parameters:
subSteps- The number of sub-steps to be performed. It must be greater than or equal to 2. If no sub-steps must be performed then callstep()instead.- Throws:
IllegalArgumentException- IfsubStepsis not greater than or equal to 2.IllegalStateException- If this method is called before thestepsBegin(int)one, or afterstepsComplete().
-
stepsBegin
protected void stepsBegin(int steps) throws IllegalArgumentException, IllegalStateExceptionTells thePreloaderthe application startup process is about to begin. The total number ofstepsis given, and the first one is about to start.For example:
stepsBegin(10); for ( int i = 0; i < 10; i++ ) { step(); ... } stepsComplete();- Parameters:
steps- The number of steps to be performed. Cannot be 0. If no steps must be performed then callstepsIndeterminate()instead, and thenstepsComplete()after the startup is completed.- Throws:
IllegalArgumentException- Ifstepsis not a positive number.IllegalStateException- If this method is called more than once.
-
stepsComplete
protected void stepsComplete()
Tells thePreloaderthe application startup process is completed and the application's UI is about to be displayed.For example:
stepsBegin(10); for ( int i = 0; i < 10; i++ ) { step(); ... } stepsComplete();
-
stepsIndeterminate
protected void stepsIndeterminate()
Tells thePreloaderthe application startup progress is indeterminate.It could be called instead of
stepsBegin(int)if the whole startup process cannot be decomposed into a determinate number of steps:stepsIndeterminate(); ... stepsComplete();
Otherwise can be intermixed with
step()when some steps require an indeterminate amount of time to be completed:stepsBegin(10); for ( int i = 0; i < 10; i++ ) { step(); ... if ( longTimeRequired ) { stepsIndeterminate(); } ... } stepsComplete();
-
stopApplication
protected void stopApplication() throws ExceptionThis method is called when the application should stop, and provides a convenient place to prepare for application exit and destroy resources.The implementation of this method provided by the
XAOSApplicationclass does nothing.Note: This method is called on the JavaFX
ApplicationThread.- Throws:
Exception- If something goes wrong.
-
subStep
protected void subStep() throws IllegalStateExceptionTells thePreloaderthe application startup process is about to start the next sub-step of progress. It must be call at the beginning of the sub-step to be performed.For example:
stepsBegin(10); for ( int i = 0; i < 10; i++ ) { step(5); for ( int j = 0; j < 5; j++ ) { subStep() ... } } stepsComplete();- Throws:
IllegalStateException- If this method is called before thestep(int)one, or afterstepsComplete(), or more than the number of sub-steps stated instep(int).
-
-