Java Reference
In-Depth Information
Getting ready
In this recipe, we are going to reach back to some of the concepts learned in previous
chapters to extend the image browser example presented in the previous recipe. We will make
use of JavaFX GUI controls and node effects. If you are not familiar with either of these topics,
please review the recipes from Chapter 3 , Transformations, Animations, and Effects , and
Chapter 4 , Components and Skinning .
The example presented here extends the image browser from the previous recipe to add
image manipulation capabilities. The new version adds GUI controls to scale, rotate, add
effects, and animate the loaded image.
How to do it...
The code snippet presented next has been abbreviated to concentrate on the more interesting
aspects of the code. You can access the full code listing from ch05/source-code/src/
image/ImageBrowserExtendedDemo.fx .
def w = 800;
def h = 600;
def maxW = w * 0.7;
def maxH = h * 0.7;
var scene:Scene;
def slider = Slider {min:1 max:1.5 value:1}
def imgView:ImageView = ImageView{
preserveRatio:true
fitWidth:bind if((slider.value*maxW) < w)
maxW * slider.value else w
fitHeight:bind if((slider.value*maxH) < h)
maxH * slider.value else h
};
var anim = TranslateTransition {
fromX:0 toX:w - maxW
node: imgView repeatCount:TranslateTransition.INDEFINITE
autoReverse:true
}
var rotateAngle = 0;
... //Address Bar Group and loadImg() function not shown
 
Search WWH ::




Custom Search