Spec-Zone .ru
спецификации, руководства, описания, API

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

expand all

Profile: desktop, common

Overview

A visual node representing FXD/FXZ graphics. Typical usage:

 Scene {
     content: FXDNode {
         url: "{__DIR__}mygraphics.fxz"
         backgroundLoading: true
         placeholder: Text { x: 10 y: 10 content: "Loading graphics ..."}
     }
 }
 

Profile: common

Variable Summary

accessnametypeCan ReadCan InitCan WriteDefault Valuedescription
public-initbackgroundLoadingBooleanfalse

If true, content will be loaded asychronousy (in the background).

public-init protectedloaderFXDLoadersubclass

Used to listen on events such as onStarted, onDone.

Used to listen on events such as onStarted, onDone. Typical usage:

     var loader:FXDLoader;
     FXDNode {
         url: "{__DIR__}graphics.fxz}
         backroundLoading: true
         placeholder: Text { x: 10 y: 10 content: "Loading graphics ..."}
         loader: loader = FXDLoader {
             onStart: function() {
                 println("Started loading graphics from {loader.source}");
             }
             onDone: function() {
                 if (loader.succeeded) {
                     println("Graphics successfully loaded.");
                 } else if (loader.stopped) {
                    println("Loading graphics canceled.");
                 } else if (loader.failed) {
                    println("Loading graphics failes. Reason: {loader.causeOfFailure}");
                 }
             }
         }
     }
     

Profile: common

 
publicplaceholderNode

Placeholder displayed while the graphics content is being loaded.

Placeholder displayed while the graphics content is being loaded. Used only when loading occurs in the background.

Profile: common

 
publicurlString

The URL from which the JavaFX content (FXD or FXZ file) will be loaded.

The URL from which the JavaFX content (FXD or FXZ file) will be loaded.

When background loading is not used (

backgroundLoading = false
, default value), only local files (files packaged with 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

 

Inherited Variables

Function Summary

protected contentLoaded() : Void

Called when the content has been successfully loaded.

Called when the content has been successfully loaded.

Profile: common

 
protected create() : Node

Creates the FXD node.

Creates the FXD node.

Returns
Node
Node

Profile: common

 
protected customCreate(id: java.lang.String, fxdObj: com.sun.javafx.tools.fxd.FXDObjectElement) : java.lang.Object
Parameters
id
fxdObj
Returns
Object
 

Inherited Functions

javafx.scene.CustomNode

protected create() : Node

Returns the root of the hierarchy that defines this CustomNode.

Returns the root of the hierarchy that defines this CustomNode. This is an optional function that may be overridden by a subclass of CustomNode to define its content.

The create function is called once, from the postinit block of the CustomNode base class, when the CustomNode is constructed. Applications that extend CustomNode should be aware that the subclass' create function is called after its init block, but before its postinit block.

The create function is called only if the children sequence of the subclass is empty when the postinit block is run. In the case where it is called, the returned node is added to the children sequence as the sole child, and may not be added to any other Group or CustomNode.

See the class documentation for Node for scene graph structure restrictions on nodes returned from the create function. If the returned node violates these restrictions, IllegalArgumentException is thrown during initialization.

Returns
Node

Profile: common

 
protected doLayout() : Void

Invoked during the layout pass to layout the children in this CustomNode.

Invoked during the layout pass to layout the children in this CustomNode. By default it will set the size of managed javafx.scene.layout.Resizable content to their preferred sizes.

Subclasses should override this function to layout children as needed.

 

javafx.fxd.FXDContent

public getGroup(id: java.lang.String) : Group

Gets a group with the given ID, or null if there is no such group.

Gets a group with the given ID, or null if there is no such group.

Parameters
id
The ID of the group to be looked for
Returns
Group
Group The group that was found, or null if there is no such group with given ID

Profile: common

 
public getMetaData(fxObj: java.lang.Object) : java.util.Map

Returns metadata associated with given FX object.

Returns metadata associated with given FX object. Metadata properties can be defined within any FXD element which is later used to construct FX object. The name of metadata property is always enclosed in quotation marks. The metadata is not processed by FXD loader and must be understood and handled by an application logic. FXDLoader just parses and provides it to the application logic when required. For example:

      Rectangle {
          id: "barrel"
          x: 10
          y: 11
          width: 40
          height: 40
          fill: Color.RED
          "can.explode": true
          "explosion.range": 15
          "explosion.sound": "bang.mp3"
      }
     
In the FXD fragment above three metadata properties - "can.explode", "explosion.range" and "explosion.sound" are defined for Rectangle element with id "barrel". Below is code example that uses them in application layer:
      /// load fxd content
      var fxdContent = FXDLoader.loadContent( "...");
      // get all meta data for element with id "rect"
      var meta = fxdContent.getMetaData( fxdContent.getObject("barrel"));
      // get meta property #1
      var canExplode = meta.get( "can.explode") as Boolean;
      // get meta property #2
      var explosionRange = meta.get("explosion.range") as Integer;
      // get meta property #3
      var explosionSound = meta.get("explosion.sound") as String;
     

Parameters
fxObj
The JavaFX object whose metadata properties should be obtained
Returns
Map
Map The map containing all metadata properties defined for particular JavaFX object or null if no metadata are defined.

Profile: common

 
public getNode(id: java.lang.String) : Node

Gets a node with the given ID, or returns null if there is no such node.

Gets a node with the given ID, or returns null if there is no such node.

Parameters
id
The ID of the node to be looked for
Returns
Node
Node The node that was found, or null if there is no such node with given ID

Profile: common

 
public getObject(id: java.lang.String) : java.lang.Object

Gets an object for the given ID, or null if there is no such object.

Gets an object for the given ID, or null if there is no such object.

Parameters
id
The ID of the object to be looked for
Returns
Object
Object The object that was found, or null if there is no object with given ID

Profile: common

 
public bound getRoot() : Group

Gets the topmost node of the loaded graphics (root node).

Gets the topmost node of the loaded graphics (root node).

Returns
Group
the topmost group of the loaded graphics. In previous versions of JavaFX (1.0 and 1.1), the topmost node was exposed by the read-only variable <pre>_root</pre>.

Profile: common

 
public getShape(id: java.lang.String) : Shape

Gets a shape with the given ID, or null if there is no such shape.

Gets a shape with the given ID, or null if there is no such shape.

Parameters
id
The ID of the shape to be looked for
Returns
Shape
Shape The shape that was found, or null if there is no shape with the given ID

Profile: common

 
public select(query: java.lang.String) : java.lang.Object

Gets an object or property selected by the given query.

Gets an object or property selected by the given query. In case there are several objects only the first one is returned. The query syntax has been inspired by XPath syntax and uses element identifiers and property names to select what will be returned. The element identifiers are separated with forward slash characters ('/') and the dot (.) is used to denote a property.The insignificant elements (i.e. those without any id defined) are skipped completely during query resolution. For example this code

      ...
      // load fxd content
      var fxdContent = FXDLoader.loadContent("...");

      // select the rectangle with id  "rect" which is direct child
      // of the group with id "group1"
      var rect = fxdContent.select( "/group1/rect") as Rectangle;

      // select the fill property of the rectangle with id "rect" which
      // is indirect child of the group with id "group2"
      var color = fxdContent.select( "/group2/rect.fill") as Color;
      ...
      
can be used to select elements in the following FXD file:
      FXD {
          content: [
              Group {
                  id: "group1"
                  content: [
                      Rectangle {
                          id: "rect"
                          fill: Color.RED
                      }
                  ]
              },
              Group {
                  id: "group2"
                  content: [
                      Group {
                         content: [
                              Rectangle {
                                  id: "rect"
                                  fill: Color.GREEN
                              }
                         }
                      }
                  ]
              }
          ]
      }
     

Parameters
query
The query used to select some JavaFX object or property
Returns
Object
Object The FXObject or property described by the given query.

Profile: common