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


There is a lot more in the javafx.scene package, in “subpackages” as I call them, which are packages that
are underneath the javafx.scene package that are referenced using another dot with another package
name (description). In fact, there are nine more javafx.scene packages, as you can see in Table 7-1, which
cover things such as canvas drawing, texture painting, special effects, UI layout, digital imaging, event
handling, text and fonts, shapes (2D and 3D geometry), and 2D and 3D transforms. We’ll be looking at all
of these javafx.scene subpackage classes and concepts during this chapter, as well as using many of them
during the course of this book. This section of the chapter goes over javafx.scene subpackages in greater
detail, and much of the functionality that you’ll be using for your game development will be found in these
subpackages. This is why I’m giving you an overview of what JavaFX provides so that it’s done all in one place
and we can start Pro Java 9 Games coding using JavaFX 9 APIs and use all this multimedia power to create
game experiences.


Let’s start with the packages that contain the fewest classes and get those out of the way first. Even
though the table lists subpackages alphabetically, the first one, javafx.scene.canvas, contains two classes: a
Canvas class that is used to create a Canvas object and a GraphicsContext class that is used to control calls to
draw onto that Canvas.
The next subpackage, javafx.scene.effect, contains the special effects classes. These can be very useful
for pro Java 9 games development, so this is one of the subpackages that I’m going to cover in detail during
this section.
The javafx.scene.image subpackage is used to implement digital imagery within JavaFX, and it
contains your ImageView, Image, WritableImage, PixelFormat, and WritablePixelFormat classes. The
ImageView class is what you’ll normally use to hold your digital image assets, and the more advanced
PixelFormat classes allow you to create digital imagery on a pixel-by-pixel basis if you want to do more
advanced (algorithmic) pixel-based digital image creation.


Table 7-1. The Nine Second-Level JavaFX Scene Subpackages with Primary Function and Description of the
Functional Classes


Package Name Function Package Contents and Functional Description


javafx.scene.canvas Direct drawing Provides the Canvas class (and Canvas object) for a
custom drawing surface


javafx.scene.effect Special effects Special effects classes: Glow, Blend, Bloom, Shadow,
Reflection, MotionBlur


javafx.scene.image Digital imaging Digital imaging classes: Image, ImageView,
WritableImage, PixelFormat


javafx.scene.input Event handling Provides classes related to getting input from the user
into the JavaFX app


javafx.scene.layout UI layouts User interface layout container classes: TilePane,
GridPane, FlowPane, etc.


javafx.scene.paint Texture (paint) Paint classes: Paint, Color, LinearGradient,
RadialGradient, Stop, Material, etc.


javafx.scene.shape Geometry 2D and 3D geometry classes: Mesh, Shape, Shape3D,
Circle, Line, Path, Arc, etc.


javafx.scene.text Text and fonts Provides text rendering and font rendering classes:
TextFlow, Text, Font, etc.


javafx.scene.transform Transforms Provides transform classes: Transform, Affine, Rotate,
Scale, Shear, Translate

Free download pdf