28.04.2019 Views

[JAVA][Beginning Java 8 Games Development]

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

A Worker object performs processing, using a background thread, and can be either reusable (such as in the<br />

Service class) or not reusable (such as in the Task class). Worker thread states are controlled by the Worker.State<br />

class (object) and contain the life cycle stages for a Worker thread. These apply across the three primary classes in<br />

the javafx.concurrent package, as they implement the Worker interface and its related nested classes. As mentioned<br />

in the previous chapter, a nested class is accessed via dot notation, so the State class is thus nested inside the Worker<br />

interface (class). Because the states of a Worker thread are very important to understand before you use it, I am<br />

going to detail them in the form of a table so that they are crystal clear to you (see Table 4-3).<br />

Table 4-3. Worker Thread Life Cycle States, as Defined by the Worker.State Nested Class for Use with a Worker Interface<br />

Worker.State Constant<br />

READY<br />

SCHEDULED<br />

RUNNING<br />

SUCCEEDED<br />

FAILED<br />

CANCELLED<br />

Significance<br />

Worker object (thread) has been initialized (or reinitialized) and is ready to be used.<br />

Worker object (thread) has been scheduled for execution but is not currently running.<br />

Worker object (thread) is currently running and is executing the <strong>Java</strong> programming logic.<br />

Worker object (thread) has executed successfully, and a valid result is in the value property.<br />

Worker object (thread) has failed to execute successfully because of some<br />

unexpected condition.<br />

Worker object (thread) has been cancelled by invoking the Worker.cancel() method call.<br />

As with everything else in this <strong>Java</strong>FX 8 multimedia engine overview chapter, you will be getting deep into the<br />

details of how to use these packages, classes, nested classes, interfaces, methods, constants, and variables over the<br />

course of the book, as you apply these <strong>Java</strong>FX programming constructs and concepts!<br />

Summary<br />

In this fourth chapter, you took a closer look at some of the more important packages, concepts, components, classes,<br />

constructors, constants, and variables (attributes) that can be found in the <strong>Java</strong>FX 8 API, an impressive collection of<br />

36 javafx.packagename.subpackagename packages, which I outlined in tables and covered, one by one, as needed for<br />

multimedia 2D and 3D (and hybrid 2D-3D) game development. When I say, “an overview,” I mean an overview!<br />

Certainly, I cannot discuss every functional class in <strong>Java</strong>FX in one chapter, so I started with a broad overview of<br />

the <strong>Java</strong>FX engine and how it integrates with the <strong>Java</strong>FX Scene Builder tool and the <strong>Java</strong>FX Scene Graph API above<br />

it, and with the <strong>Java</strong> 8 API, NetBeans 8.0, and target OSs below it, which give <strong>Java</strong>FX expansive OS support across so<br />

many popular platforms and devices and the leading web browsers.<br />

I presented a high-level technical view of <strong>Java</strong>FX, detailing its structures, including <strong>Java</strong>FX Scene Graph, APIs,<br />

Quantum, Prism, Glass, WebKit, and Media engine. You looked at how these multithreading, rendering, windowing,<br />

media, and web engines interface with the <strong>Java</strong> 8 API and <strong>Java</strong> JDK 8 as well as with NetBeans 8.0 and the JVM<br />

bytecode that it generates, which is read by all the various OS platforms currently running across a dozen different<br />

consumer electronics device types.<br />

You also explored <strong>Java</strong>FX core concepts, such as the <strong>Java</strong>FX Scene Graph and the <strong>Java</strong>FX pulse events system,<br />

which you will be leveraging to create a <strong>Java</strong> 8 game as you work through this book, starting in the next chapter, when I<br />

explain how to use the <strong>Java</strong>FX Scene Builder visual editing tool in NetBeans.<br />

Then, you dove deep into some of the key <strong>Java</strong>FX packages and subpackages for game design, such as<br />

Application, Scene, Shape, Effect, Layout, Control, Media, Image, Stage, Animation, Geometry, Event,<br />

and Concurrent, and their package classes and subclasses and even, in some cases, their interfaces, nested classes,<br />

and constants.<br />

98<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!