Game Development Reference
In-Depth Information
One of the important methods in the JavaFX Scene Graph Node class is the public fi-
nal Bounds .getBoundsInLocal() method. This method is the getter method that re-
trieves the value of the boundsInLocal property. The boundsInLocal property is “read-
only” and holds a rectangular Bounds object for the Node it is contained in. The data
that it contains represents untransformed (original) local coordinate space for a Node.
Untransformed means the Node coordinates prior to their being rotated , translated , or
scaled , which represents the Node object's original (default) coordinates.
For a Node class (object) that extends the Shape class (which our ImageView Node
does not), the local Bounds will also include the space required to implement a non-
zero Shape (or Path) stroke , as this might extend “outside” of the Shape geometry,
which is being defined by these position and size attributes. A local Bounds object also
includes any clipping path areas that you may have set, as well as the extents of any
special effects that you may have set.
The boundsInLocal property will always have a non-null value, and it is import-
ant to note that this method does not take the Node object's visibility into account, so
the computation is based on the geometry of the Node only. The boundsInLocal prop-
erty is automatically computed whenever the geometry of a Node object changes.
We will be using the .getBoundsInLocal() method on an intersection of our Invin-
ciBagel SVGPath Shape data with our other Scene Actor Prop SVGPath collision
Shape data, in order to ascertain if the width of the intersection is negative one, as -1 in
a Bounds object, as we have learned, is empty, or no intersection , which signifies no
collision . Next, let's take a look at the boundsInParent property, which contains the
boundsInLocal data plus transformations.
Using Node Parent Bounds: The .getBoundsInParent()
Method
Another one of those important methods to understand in the JavaFX Scene Graph
Node class is the public final Bounds .getBoundsInParent() method. This method is
the getter method that retrieves the value of the boundsInParent property. The bound-
sInParent property is a “read-only” property that holds the rectangular Bounds object
for the Node it is contained in. The data that it contains represents the transformed
(modified) coordinate space for a Node. Transformed means the Node coordinates plus
any transforms that have taken place since the Node object's default, initial or original
state. It is named “boundsInParent” because the Bounds object rectangle data will need
to be relative to the Parent Node object's coordinate system. This represents the 'visu-
Search WWH ::




Custom Search