Java Reference
In-Depth Information
If you want to size the Image , you can specify the desired width and height , and
also specify whether the aspect ratio of the image should be preserved. The
smooth variable indicates whether to use a better quality scaling algorithm or a
faster one. When smooth is set to true, its default value, the scaling will be of
higher quality; when set to false, scaling occurs faster, but with lesser quality.
This is demonstrated in Listing 8.1.
Listing 8.1
Image Sizing
var image = Image {
url: "http://www.nasa.gov/figures/content/"
"300763main_image_1258_1600-1200.jpg"
width: 500
height: 500
preserveRatio: true
smooth: true
}
Similar geometry variables, fitWidth and fitHeight , are also available on the
ImageView , and these will be discussed a little later in this chapter. This is an
alternative way to scale the image.
Because the image may be located on a remote system—maybe it is just large or
maybe there are a lot of images to load—it may take some time to load the
image. If you do not want to wait for the image to load when you create it, you
can set the flag, backgroundLoading . When you use this option, you can also
specify a placeholder image that will be shown while the main image is down-
loading. Presumably, this placeholder image will have already been loaded and
will be ready before the primary image is loaded. This is shown in Listing 8.2.
Listing 8.2
Background Loading
var image = Image {
url: "http://www.nasa.gov/figures/content/"
"300763main_image_1258_1600-1200.jpg"
backgroundLoading: true
placeholder: Image {
url: "{__DIR__}figures/Smiley.gif"
}
}
 
Search WWH ::




Custom Search