28.04.2019 Views

[JAVA][Beginning Java 8 Games Development]

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 4 ■ An Introduction to <strong>Java</strong>FX 8: Exploring the Capabilities of the <strong>Java</strong> 8 Multimedia Engine<br />

The javafx.scene.text subpackage has classes for rendering text shapes and fonts into your scenes. This includes<br />

the Font class, for employing any fonts that you may want to use that are not a <strong>Java</strong>FX system font, as well as the<br />

Text class, for creating a text node that will display the text values using this font. There is also a specialized layout<br />

container class, called TextFlow, which is used to flow text, much like you would see done on a word processor.<br />

The javafx.scene.transform subpackage offers classes for rendering 2D and 3D spatial transformations, such<br />

as the Scale, Rotate, Shear, Translate, and Affine (3D rotation) subclasses of the Transform superclass. These can<br />

be applied to any Node object in the Scene Graph. This allows anything in your scene graph (text, UI controls, shapes,<br />

meshes, images, media, and so on) to be transformed in any way that you like, which affords <strong>Java</strong>FX game developers<br />

a ton of creative power. In case you are wondering, translation is linear movement of an entire object; shear is linear<br />

movement on a 2D plane in two different directions or movement in one direction when another part of the 2D<br />

plane is fixed. Imagine moving the top of a plane, while the bottom remains fixed, such that the square becomes a<br />

parallelogram, or moving the top and bottom of the same plane (a square) in different directions.<br />

The javafx.scene.web subpackage furnishes classes for rendering web assets into a scene, using a collection of<br />

classes, including WebView, WebEvent, WebEngine, WebHistory, and HTMLEditor. The WebEngine (see, other<br />

people call things engines as well) class, as you might imagine, does the processing for showing HTML5 + CSS3 +<br />

JS in <strong>Java</strong>FX, and the WebView class creates the node for displaying the WebEngine output in the Scene Graph.<br />

The WebHistory class (object, ultimately) holds the session history (from WebEngine instantiation to removal from<br />

memory) for the web pages visited, and WebEvent bridges the <strong>Java</strong>Script web event processing with the <strong>Java</strong>FX<br />

event processing.<br />

Now that you have looked at a plethora of important and useful classes (objects) in the javafx.scene package and<br />

its related subpackages, let’s take a look at the 15 top-level <strong>Java</strong>FX packages to get a better idea of the key capabilities<br />

that <strong>Java</strong>FX offers for application development (focusing of course, on those that can be used for game development).<br />

Other <strong>Java</strong>FX Packages: The 15 Top-Level Packages<br />

There are 15 top-level packages (javafx.packagename being what I consider a top-level package), some of which<br />

have subpackage levels as well, as you have seen with the javafx.scene package and subpackages. Table 4-2 gives an<br />

overview of these packages and describes their contents.<br />

Table 4-2. <strong>Java</strong>FX Top-Level Packages, Their Primary Functions, and a Description of Their Functional Classes<br />

Package Name Functions Description of Contents<br />

javafx.animation Animation Timeline, Transition, AnimationTimer, Interpolator, KeyFrame, KeyValue<br />

javafx.application Application Application (init, start, stop methods), Preloader, Parameters, Platform<br />

javafx.beans <strong>Java</strong>FX beans <strong>Java</strong> interfaces that define the most generic form of observability<br />

javafx.collections Collections <strong>Java</strong> collections that define the most generic form of observability<br />

javafx.concurrent Threading Threading classes: Task, Service, ScheduledService, WorkerStateEvent<br />

javafx.css CSS Classes related to implementing CSS in <strong>Java</strong>FX<br />

javafx.embed Embeds Embeds deprecated <strong>Java</strong> Swing and <strong>Java</strong> AWT GUI paradigms<br />

javafx.event Event handler Event handling classes: Event, ActionEvent, EventType, WeakEventHandler<br />

javafx.fxml FXML FXML<br />

javafx.geometry 3D geometry 3D geometry classes<br />

(continued)<br />

84<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!