Java Reference
In-Depth Information
var scene:Scene;
var text:Text;
var stage:Stage = Stage {
title: "Stage and Scene Geometry"
x: 250
y: 150
width: 800
height: 100
scene: scene = Scene{
fill: Color.NAVY
content: text = Text {
translateX: bind
(scene.width-text.layoutBounds.width) / 2 -
text.layoutBounds.minX
translateY: 24
fill: Color.YELLOW
textOrigin: TextOrigin.TOP
font: Font { size: 24 }
content: bind
"Stage: [{stage.x},{stage.y}] , "
"[{stage.width}, {stage.height}]"
"Scene: [{scene.x},{scene.y}] , "
"[{scene.width}, {scene.height}]"
}
}
}
Figure 5.4
Stage and Scene Geometry
To accomplish the repositioning, we first assigned the Scene instance to the
script variable scene . Then we used the instance variable, scene.width , to cal-
culate the start position for the Text . We had to use a bind , because the scene's
geometry will change, at least initially, from zero width and height to the width
and height based on the stage's geometry.
Notice that the stage's position, [250,150], is relative to the desktop coordinate
space, whereas the scene's position, [5, 23], is relative to the stage's coordinate
space. Also, the scene's width, (790), and height, (72), is less than the stage's
width, (800), and height, (100). This takes into account the border space taken up
by the stage that is not available to the scene for rendering graphical nodes.
Search WWH ::




Custom Search