Game Development Reference
In-Depth Information
tent and scenes. For this reason, many of you may be familiar (and comfortable) with
this design paradigm.
JavaFX Scene Graph data structure allows you not only to architect, organize, and
design your JavaFX scene and its content, but also to apply opacity , states , event
handlers , transformations , and special effects to entire logical branches of the Scene
Graph hierarchy if you set up the Scene Graph correctly. Figure 4-3 shows the basic
Scene Graph tree, with the root node at the top and branch and leaf nodes below it.
Figure 4-3 . JavaFX Scene Graph hierarchy, starting with the root node and progressing to branch and leaf nodes
The root node is the topmost node, which is why it is called the root, even though it
is at the top, not the bottom, like a root would be in the plant world. A root node has no
parent , that is, nothing above it in the Scene Graph hierarchy. A root node is itself a
parent to the branch nodes and leaf nodes below it.
The next most powerful (and complex) construct in the Scene Graph tree is the
branch node, which uses the javafx.scene.Parent class as its superclass and which can
contain children (this is logical, as it extends a class aptly named Parent ). A branch
node can contain other branch nodes, as well as leaf nodes, so it can be used to create
some very complicated and powerful Scene Graph hierarchy (or Scene Graph architec-
ture) constructs.
The last level in the hierarchy is the leaf node. A leaf node is the end of the branch
and, as such, cannot have children. It is important to note that leaf nodes can come dir-
ectly off the root node, as you can see in Figure 4-3 . Branch nodes can be created by
using the Parent , Group , or SubScene classes (see Figure 4-2 ) or any of their sub-
classes, such as the WebView , PopupControl , Region , Pane , or StackPane class.
Examples of leaf nodes include JavaFX classes (as objects), which can be con-
figured using parameters, such as shapes, text, or an ImageView, but which are design
or content components, in and of themselves, and have not been designed to have chil-
dren (child objects).
 
 
Search WWH ::




Custom Search