- 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 Scene
getScene()
Stage
getStage()
void
init()
protected void
initApplication()
The application initialization method.This method is called immediately after theXAOSApplication
class is loaded and constructed.void
start(Stage stage)
protected void
startApplication(BorderPane sceneRoot)
The main entry point for a XAOS application.protected void
step()
Tells thePreloader
the application startup process is about to start the next step of progress.protected void
step(int subSteps)
Tells thePreloader
the application startup process is about to start the next step of progress, which is itself split in the given number of sub-steps.protected void
stepsBegin(int steps)
Tells thePreloader
the application startup process is about to begin.protected void
stepsComplete()
Tells thePreloader
the application startup process is completed and the application's UI is about to be displayed.protected void
stepsIndeterminate()
Tells thePreloader
the application startup progress is indeterminate.void
stop()
protected void
stopApplication()
This method is called when the application should stop, and provides a convenient place to prepare for application exit and destroy resources.protected void
subStep()
Tells thePreloader
the 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
Scene
ornull
if the application is not yet started.
-
getStage
public Stage getStage()
- Returns:
- This application's
Stage
ornull
if the application is not yet started.
-
init
public final void init() throws Exception
- Overrides:
init
in classApplication
- Throws:
Exception
-
start
public final void start(Stage stage) throws Exception
- Specified by:
start
in classApplication
- Throws:
Exception
-
stop
public final void stop() throws Exception
- Overrides:
stop
in classApplication
- Throws:
Exception
-
initApplication
protected void initApplication() throws Exception
The application initialization method.This method is called immediately after theXAOSApplication
class 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
XAOSApplication
class does nothing.Note: This method is not called on the JavaFX
Application
Thread. An application must not construct aScene
or aStage
in 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. ThestartApplication
method 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 thePreloader
of the current startup progress:notifyPreloader(new ProgressNotification(progress));
where
progress
is a number between 0 (started) to 1 (completed).The implementation of this method provided by the
XAOSApplication
class does nothing.Note: Contrarily to the
Application.start(Stage)
method, this one is not called on the JavaFX Application Thread.- Parameters:
sceneRoot
- TheBorderPane
root container pre-installed in the application'sScene
.- Throws:
Exception
- If something goes wrong.
-
step
protected void step() throws IllegalStateException
Tells thePreloader
the 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, IllegalStateException
Tells thePreloader
the 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
- IfsubSteps
is 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, IllegalStateException
Tells thePreloader
the application startup process is about to begin. The total number ofsteps
is 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
- Ifsteps
is not a positive number.IllegalStateException
- If this method is called more than once.
-
stepsComplete
protected void stepsComplete()
Tells thePreloader
the 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 thePreloader
the 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 Exception
This 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
XAOSApplication
class does nothing.Note: This method is called on the JavaFX
Application
Thread.- Throws:
Exception
- If something goes wrong.
-
subStep
protected void subStep() throws IllegalStateException
Tells thePreloader
the 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)
.
-
-