Java Reference
In-Depth Information
JavaFX
JavaFX provides a number of features that makes it an excellent environment for developing complex
graphical applications. It can be considered a domain-specific language for the creation of animated
graphics. A domain-specific language is simply a language that focuses on solving a particular task. For
example, SQL is a domain-specific language for working with data in a database. The following sections
explore some of the features in JavaFX and how they help mitigate the concerns of designers mentioned
earlier in this chapter.
Scene Graph
There are basically two types of graphics libraries, raster and vector. Raster graphics libraries typically
just provide a set of utility functions, like drawCircle or drawImage, for setting the values of pixels. A
function like drawCircle probably just takes an array of values (pixels) and changes just the right ones to
make a circular pattern when the values are drawn to the screen. An application using this library does
not necessarily maintain a record that a circle was drawn; the intent of a circle is lost. For example,
consider two scenarios, in the first an image has a circle drawn on it and then the image is scaled up. In
the second scenario, an image is scaled up and then a circle is drawn on it. Figure 1-8 shows the result of
these two scenarios.
Figure 1-8. Fuzzy circle, crisp circle
In Figure 1-8, the circle on the left is the result of the first scenario; the circle on the right is the result
of the second scenario. As you can see, the circle from scenario one is fuzzy. This is because when a
circle is drawn to a rectangular grid of pixels, the edge of the circle is anti-aliased—there is not a clean
Search WWH ::




Custom Search