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

expand all

Profile: desktop, common

Overview

A class representing content loaded from an FXD content file or FXZ archive, together with ID strings used to identify individual graphic objects. For example:

 var fxdContent = FXDLoader.loadContent(URL);
 insert fxdContent.getRoot() into myScene.content;
 var myNode = fxdContent.getNode("myNode");
 var myShape = fxdContent.getShape("myShape");
 myNode.translateX = 40;
 myShape.fill = Color.WHITE;
 TranslateTransition{ node: myNode byY: 80 duration: 500ms}.play();
 
In the code above, first the content is loaded into the fxdContent variable. The root of the loaded content is inserted into the existing scene graph, which is already visible on the screen. At this point, manipulation of the loaded content begins. The myNode and myShape variables are declared, and values are assigned to them. TranslateTransition adds a little animation to the myNode object. Since the root element of fxdContent has already been inserted into the existing scene graph, all changes to the variables and animations should immediately be visible.

Profile: common

Inherited Variables

Function Summary

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

 

Inherited Functions




Spec-Zone.ru - all specs in one place