Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

Chapter 7 ■ IntroduCtIon to JavaFX 9: overvIew oF the JavaFX new MedIa engIne


The javafx.graphics Module: 18 Multimedia Packages


There are 18 top-level javafx.graphics module packages that are the most often used packages (besides the
core javafx.base module packages). These follow a javafx.packagename name format (not javafx.graphics.
packagename). Some of these, such as scene and css, have subpackage levels as well. We saw this with the
nine javafx.scene package and its subpackages, which we looked at previously, so we won’t look at these
here. The javafx.graphics module is one of three key modules to include for creating Pro Java 9 Games, with
the others being javafx.base and javafx.media. Since nine javafx.graphics module packages are included
in Table 7-2, this essentially means that from a JavaFX API module perspective, the javafx.graphics module
has a total of 18 package categories, as nine are listed in Table 7-1. These module packages have been
reorganized since JavaFX 8 by the JavaFX 9 development team at Oracle to allow better modularization
(function optimization). For instance, if you don’t need audio or video in your 3D game, you could just use
the base and graphics modules. Since we want audio, we will use base, graphics, and media modules, or
three of the seven JavaFX API modules (a 57 percent JavaFX API package code reduction right off the bat).
I wanted to give you an overview of these 18 functional areas in the javafx.graphics module’s packages,
as shown in Table 7-1 and 7-2, and take a closer look at what each of the graphics areas (vector, raster,
animation, CSS) will do.


Some of these we have covered already, such as the javafx.application package, which we learned
about in Chapter 6 , and the javafx.scene package and its subpackages, which we covered in the previous
section.
The first package in Table 7-2 is the javafx.animation package. Since animation is important for Java
games, let’s cover that in the next section of the chapter. I’ll also cover javafx.geometry and javafx.stage,
as the core packages from Table 7-2 that are needed for a Java 9 game are animation, application, geometry,
scene, and stage.


Table 7-2. javafx.graphics Module Top-Level (Nonscene) Packages, with Primary Functions and Description
of Function


Package Name Functions Package Contents Description


javafx.animation Animation Classes: AnimationTimer, Timeline, Transition,
Interpolator, KeyFrame, KeyValue


javafx.application Application Provides Application (init, start, stop methods),
Preloader, Parameters, Platform


javafx.concurrent Threading Provides threading classes: Task, Service,
ScheduledService, WorkerStateEvent


javafx.css CSS Provides classes related to implementing Cascading
Style Sheets (CSS) in JavaFX


javafx.css.converter CSS Provides classes related to implementing CSS in JavaFX


javafx.geometry 3D geometry Provides 3D geometry


javafx.print Printing Provides printing


javafx.scene Scene control Classes related to scene creation, organization, and
control (see Table 7-1)


javafx.stage Stage creation Provides Stage creation

Free download pdf