Java Reference
In-Depth Information
separation of pixels. When the image is scaled up, these partially drawn pixels at the edge of the circle
are scaled as well, which produces the fuzziness around the circle.
Now if we know our application is going to be scaling an image with a circle on it, we can write it in
such a way as to just store the fact that we want a circle drawn. Our application can then be smart
enough to always draw the circle after any scaling is performed on the pixels, guaranteeing a nice, crisp
circle. This is basically what a vector graphics library like JavaFX does; it provides a way to describe the
content of the scene, which is called a scene graph. The scene can then be drawn to any size without a
loss in fidelity.
The quality of the finished rendering is very important and makes having a scene graph worthwhile,
but there is another advantage as well. Since the scene graph allows you to describe the image on the
screen in a non-destructive way, it allows you to make changes to the graph during runtime to create
high-quality animations. With a raster library, it is up the developer to figure out how to draw each frame
of the animation. This is hard, error-prone work. It is much nicer for the developer to simply say, here is
a rectangle at this point, and in 5 seconds it needs to be over here. Since the developer is able to program
an animation in much the same way as a designer describes one, the quality of the animation produced
by the developer is much better. It is really very nice to be able to spend my development time getting an
animation just right, versus getting to work at all. This is the advantage of a domain-specific language.
Designer Tools
There has always been friction between the tools a designer uses and the tools a developer uses. In the
worst case, the designer e-mails a static image to the developer and says, “I want the application to look
like this.” This puts a lot of design decisions on the developer and makes it hard to make iterative
changes. JavaFX helps solve this issue by allowing designers to create content in Adobe Illustrator and
export their work as a JavaFX resource (as shown in Figure 1-9). This allows the developer to
programmatically import the work of designers directly into the code base of the application. This
feature is added to Adobe Illustrator through a plug-in available at Simply download and
install the JavaFX Production Suite.
Search WWH ::

Custom Search