Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

Chapter 10 ■ User InterfaCe DesIgn InteraCtIvIty: event hanDlIng anD ImagIng effeCts


Special Effects: The javafx.scene.effects Package


The javafx.scene.effect package contains a foundational superclass for all the JavaFX special effects. Not
surprisingly, this is called the Effect class. The Effect class has 17 known direct subclasses for 2D digital
image compositing effects, such as you would find in GIMP 2.10, which are also contained in this package.
These include Blend, Bloom, BoxBlur, ColorAdjust, ColorInput, DisplacementMap, DropShadow, FloatMap,
GaussianBlur, Glow, ImageInput, InnerShadow, Lighting, MotionBlur, PerspectiveTransform, Reflection,
SepiaTone, and Shadow classes. For 2D, this package also contains the Light superclass and the Light.
Distant, Light.Point, and Light.Spot subclasses, which we’ll use later, during the 3D part of this book.
Let’s cover the JavaFX Effect superclass first. This class is a public abstract class, extending a java.
lang.Object master class. This means that it was created, from scratch, by the JavaFX development team,
specifically for providing image-based (pixel-based) special effects in JavaFX and to provide lighting support,
usable for 2D and 3D. The effects provided are much like those that GIMP 3 or Photoshop provide in their
respective digital imaging software packages.
The JavaFX Effect Java class hierarchy would therefore look like the following:


java.lang.Object



javafx.scene.effect.Effect



The Effect class provides an abstract or “base” class for the creation of all special effects
implementations in JavaFX. An Effect object (and subclass) in JavaFX will always contain a pixel graphics
algorithm that produces an Image object. This will be an algorithmic modification of the pixels in your
source Image object and works in both 2D and 3D.


Figure 10-8. Implement the code in the handle() method to reconfigure the creditButton UI compositing layer
objects

Free download pdf