JavaFX: Bringing Rich Experiences To All the Screens Of Your Life

expand all

Profile: desktop, common

Overview

This class loads JavaFX content files--either FXD (plain text) or FXZ (a compressed archive with embedded binary assets). It can be used either synchronously (as a blocking operation) or asynchronously (as a nonblocking operation). Synchronous (blocking) load usage:

   var group:Group .... // a graphics group defined elsewhere
   var fxdGraphics = FXDLoader.load("{__DIR__}graphics.fxz"); // loads the 
       // content and blocks until all of the content is loaded
   insert fxdGraphics into group.content; // inserts the loaded FXD content
       // into the group
   

Asynchronous (non-blocking) load usage:

   var group:Group .... // a graphics group defined elsewhere
   var loader:FXDLoader = FXDLoader {
       onDone: function() { // called when loading is done
           if (loader.succeeded) {
               insert loader.content.getRoot() into group.content; // inserts loaded graphics into the group
           } else {
               println("Loading graphics from {loader.source} failed. Reason = {loader.causeOfFailure}");
           }
        }
   };
   FXDLoader.loadOnBackground("{__DIR__}graphics.fxz", loader); // starts loading,
   // but does not wait until the graphics content is loaded
   

If synchronous (blocking) loading is used, only local files (files that are packaged within the application) should be loaded to prevent the application from becoming unresponsive.

Note: When running the code on mobile devices, only FXZ files that are uncompressed to a directory or FXD files are supported for remote access, not remote FXZ files (files that are not packaged within the application). The desktop profile supports all file formats either locally or remotely.

Profile: common

Variable Summary

accessnametypeCan ReadCan InitCan WriteDefault Valuedescription
public-readcontentFXDContent

Loaded content.

Loaded content. The value is null before the loading starts.

Profile: common

 
public-read protectedsourceObjectsubclasssubclass

The source from which the content is loaded.

The source from which the content is loaded. In most cases, the value is the URL supplied by the functions FXDLoader.createLoader(url) or FXDLoader.loadOnBackground(url, loader)

Profile: common

 

Inherited Variables

javafx.async.Task

accessnametypeCan ReadCan InitCan WriteDefault Valuedescription
public-read protectedcauseOfFailureObjectsubclasssubclassnull

Indicates the cause of failure of this task.

Indicates the cause of failure of this task. If this variable's value is null, there is no known cause of failure, even if the failed variable is set to true. If this variable's value is not null, it will most likely contain an exception that describes the cause of failure.

null

See Also:
failed

Profile: common

 
public-read protecteddoneBooleansubclasssubclassfalse

Indicates if this task has completed.

Indicates if this task has completed. This is the last of the variables started, stopped, failed, succeeded and causeOfFailure to be modified. This variable is to be set to true upon completion of this task, without respect to success or failure of the task..

false

Profile: common

 
public-read protectedfailedBooleansubclasssubclassfalse

Indicates if this task has failed.

Indicates if this task has failed. This variable is set to true as a result of the task executing and failing by means of an exception. This exception could be the result of the task being stopped by the stop() function being called. causeOfFailure will contian the failure cause if the failure was caused by an exception during execution.

false

See Also:
stop(), causeOfFailure

Profile: common

 
public-read protectedmaxProgressLongsubclasssubclass-1

Indicates a maximum value for the progress variable.

Indicates a maximum value for the progress variable. If set to zero or a negative value, there is no known maximum and the percentDone variable will not change during the course of execution of this task.

-1

See Also:
progress, percentDone

Profile: common

 
publiconDonefunction():Voidnull

Callback that is invoked once to indicate that the task execution has completed (successfully, or unsuccessfully).

Callback that is invoked once to indicate that the task execution has completed (successfully, or unsuccessfully). This task's implemenation will not modify this task's variables during or after a call to this function. Once the start() function has been called, this function will eventually be called, if it is non-null.

null

See Also:
done, start(), stop()

Profile: common

 
publiconStartfunction():Voidnull

Callback that is invoked once to indicate that the task is about to start execution.

Callback that is invoked once to indicate that the task is about to start execution. This function is not called as a result of the queueing of this task for execution.

null

See Also:
started, start()

Profile: common

 
public-readpercentDoneNumber-1

Indicates the current progress of this task in terms of percent complete.

Indicates the current progress of this task in terms of percent complete. A value between zero and one indicates progress toward completion. This variable's value may or may not change from its default value depending on the specific Task implementation.

-1

See Also:
maxProgress, progress

Profile: common

 
public-read protectedprogressLongsubclasssubclass-1

Indicates the current progress toward completion of this task.

Indicates the current progress toward completion of this task. Zero or a positive value indicate progress toward completion. This variable's value may or may not change from its default value depending on the specific Task implementation.

-1

See Also:
maxProgress, percentDone

Profile: common

 
public-read protectedstartedBooleansubclasssubclassfalse

Indicates if this task has started.

Indicates if this task has started. Once this task's start() function has been called, the task may or may not be queued before it executes. This variable is set to true just before the task starts executing.

false

See Also:
onStart

Profile: common

 
public-read protectedstoppedBooleansubclasssubclassfalse

Indicates if this task has been stopped.

Indicates if this task has been stopped. This variable is set to true as a result of the stop() function being called. A value of true means that the task did not execute to completion, and possibly not at all if the task was queued for execution by stop() and stopped by stop() before execution.

false

See Also:
stop()

Profile: common

 
public-read protectedsucceededBooleansubclasssubclassfalse

Indicates if this task has successfully completed.

Indicates if this task has successfully completed. This variable is to be set to true upon successful completion of this task, but before the done variable is set to to true.

false

See Also:
done

Profile: common

 

Script Function Summary

public createLoader(url: java.lang.String) : FXDLoader

Creates a loader for a content file with a given URL.

Creates a loader for a content file with a given URL. This loader executes loading asynchronously in the background. The loader is started by calling the start() function. When loading is done, the onDone() function is called.

Usage:

   var loader:FXDLoader = FXDLoader.createLoader("{__DIR__}content.fxz");
   loader.onDone = function() {
       if (loader.succeeded) {
          scene.content = loader.content.getRoot();
       } else {
           println("Loading graphics from {loader.source} failed. Reason = {loader.causeOfFailure});
       }
   };
   loader.start();
   

Parameters
url
The URL from which the content should be loaded
Returns
FXDLoader
FXDLoader

Profile: common

 
public load(url: java.lang.String) : Node

Loads a JavaFX content file from a given URL and returns the top root node.

Loads a JavaFX content file from a given URL and returns the top root node.

Note: Because this loading function is a synchronous (blocking) operation, only local files (files packaged with the application) should be loaded to prevent the application from becoming unresponsive.

Parameters
url
The URL from which the file should be loaded
Returns
Node
Node The top root node of the loaded content

Profile: common

 
public loadContent(url: java.lang.String) : FXDContent

Loads a JavaFX content file from a given URL and returns a javafx.fxd.FXDContent object, which can be used to access named elements (elements with the id variable specified).

Loads a JavaFX content file from a given URL and returns a javafx.fxd.FXDContent object, which can be used to access named elements (elements with the id variable specified).

Note: Since this function is a synchronous (blocking) operation, only local files should be loaded to prevent the application from becoming unresponsive.

Parameters
url
The URL from which the content file should be loaded
Returns
FXDContent
FXDContent

Profile: common

 
public loadOnBackground(url: java.lang.String, loader: FXDLoader) : FXDLoader

Starts loading content from a given URL using the supplied loader.

Starts loading content from a given URL using the supplied loader. If the loader argument is null, a new loader is created. This function returns the loader used to load the content, either the supplied one or the one created. The loading starts automatically.

Usage:

   var loader:FXDLoader = FXDLoader {
     onStart: function() { println("loading started ..."); }
     onDone: function() { scene.content = loader.content.getRoot(); }
   };
   FXDLoader.loadOnBackground("{__DIR__}content.fxz", loader); // starts loading
 

Parameters
url
The URL from which the content should be loaded
loader
The loader to be used to load the content. The value can be null.
Returns
FXDLoader
FXDLoader The loader used to load the content

Profile: common

 

Function Summary

protected createLoadContext() : com.sun.javafx.tools.fxd.LoadContext
Returns
LoadContext
 
protected getContainerEntry(ctx: com.sun.javafx.tools.fxd.LoadContext) : com.sun.javafx.tools.fxd.container.ContainerEntry
Parameters
ctx
Returns
ContainerEntry
 
public start() : Void

Starts loading the content.

Starts loading the content.

Profile: common

 
public stop() : Void

Stops (cancels) loading the content.

Stops (cancels) loading the content.

Profile: common

 

Inherited Functions

javafx.async.Task

public abstract start() : Void

Initiates execution of this task.

Initiates execution of this task. Calling this function will either queue this task for future execution or start execution. The execution of the task happens on a thread other than the JavaFX event dispatch thread. The onStart function may not be called before this function returns. This function is expected to be called a maximum of once per instance of Task.

See Also:
onStart

Profile: common

 
public abstract stop() : Void

Terminates execution of this task.

Terminates execution of this task. Calling this function will either remove this task from the execution queue or stop execution. Subsequent calls to this function have no effect. The onDone function will be called as a result of calling this function, if it is non-null. The onDone function may not be called before this function returns. This function is expected to be called a maximum of once per instance of Task.

See Also:
stopped, onDone

Profile: common

 



Spec-Zone.ru - all specs in one place