Java Reference
In-Depth Information
The
boundsInParent
reflects the Group's coordinate system and also reflects
the
translateX
and
translateY
transform from the
Rectangle
node. Notice
the dimensions are still 84 by 70 but the
minX
and
minY
and
maxX
and
maxY
val-
ues have changed to reflect the
translateX
and
translateY
transformation.
The
boundsInScene
reflects the Group's rotation, and now the bounding area is
a square that encloses the rotated rectangle. This reflects the Group's rotation.
Table 5.1 summarizes the differences between these four bounds.
Ta b l e 5 . 1
Bounds
Coordinate
Space
Bounds
Contribution
boundsInLocal
Untransformed local coordinates, including shape
stroke, clip, and effect
Node
BoundsInLocal
plus
transforms[]
sequence
Node
layoutBounds
LayoutBounds
plus
translateX
/
translateY
,
scaleX
/
scaleY
,
rotate
Parent
boundsInParent
boundsInScene
BoundsInParent
plus accumulated transforms of all
ancestor nodes
Scene
To position a node, you need to use the Nodes
layoutBounds
to determine its
basic size. If you need to incorporate transformations into this calculation, you
should use the
transforms[]
sequence rather than the standalone transform
instance variables,
translateX/Y
,
scaleX/Y
, and
rotate
. Listing 5.18 provides
an example to center a node in a scene.
Listing 5.18
Centering a Node in a Scene
var rect:Rectangle;
Stage {
var scene:Scene;
width: 200
height: 200
scene: scene = Scene {
content: rect = Rectangle {
translateX: bind (scene.width -
rect.layoutBounds.width)/2.0 -
rect.layoutBounds.minX
Search WWH ::
Custom Search