The Wayback Machine - https://web.archive.org/web/20150801174007/http://jfxia.com/
Chapter 1
Chapter 1 is a gentle introduction to the world of rich internet
applications: a look at how the web moved from static pages to fully
functioning applications, and how Java lost out to Flash in the battle
of the applets. As well as comparing JavaFX to its main commercial rivals,
the chapter shows a couple of brief JFX code examples, including a
comparison with Java/Swing.
1.1Introducing JavaFX
1.1.1Why do we need JavaFX Script? The power of a DSL
1.1.2Back to the future: the rise of the cloud
1.1.3Form follows function: the fall and rebirth of desktop Java
1.2Minimum effort, maximum impact: a quick shot of JavaFX
1.3Comparing Java and JavaFX Script: "Hello JavaFX!"
1.4Comparing JavaFX with Adobe AIR, GWT and Silverlight
1.4.1Adobe AIR and Flex
1.4.2Google Web Toolkit
1.4.3Microsoft Silverlight
1.4.4And by comparison, JavaFX
1.5But why should I buy this book?
Chapter 2
Chapter 2 is the first part of the JavaFX Script language tutorial.
It focuses on variables and data manipulation, including: basic data
types, arithmetic, strings, durations, sequences, and binds. Full
examples are given of all the related syntax varients, with notes
explaining their purpose, mechanics, and limitations.
2.1Annotating code with comments
2.2Data types
2.2.1Static, not dynamic, types
2.2.2Value type declaration (var, Boolean, Byte, Character, Double, Duration, Float, Integer, Long, Number, Short, String)
2.2.3Initialize-only and reassignable variables (var, def)
2.2.4Arithmetic on value types (+, -, etc.)
2.2.5Logic operators (and, or, <, >, =, >=, <=, !=)
2.2.6Translating and checking types (as, instanceof)
2.3Working with text, via strings
2.3.1String literals and embedded expressions
2.3.2String formatting
2.3,3String localization
2.4Durations, using time literals
2.5Sequences: not quite arrays
2.5.1Basic sequence declaration and access (sizeof)
2.5.2Sequence creation using ranges ([..], step)
2.5.3Sequence creation using slices ( [..<] )
2.5.4Sequence creation using a predicate
2.5.5Sequence manipulation (insert, delete, reverse)
2.5.6Sequences, behind the scenes
2.6Autoupdating related data, with binds
2.6.1Binding to variables (bind)
2.6.2Binding to bound variables
2.6.3Binding to a sequence element
2.6.4Binding to an entire sequence (for)
2.6.5Binding to code
2.6.6Bidirectional binds (with inverse)
2.6.7he mechanics behind bindings
2.6.8Bound functions (bound)
2.7Working nicely with Java
2.7.1Avoiding naming conflicts, with quoted identifiers
2.7.2Handling Java native arrays (nativearray of)
2.8Summary
Chapter 3
Chapter 3 concludes the JavaFX Script language tutorial, by building on
the knowledge of variables and data from the previous chapter. This
chapter explores common code constructs. Topics covered include:
classes, objects, functions, mixin inheritance, access modifiers,
conditions and loops.
3.1Imposing order and control with packages (package, import)
3.2Developing classes
3.2.1Scripts
3.2.2Class definition (class, def, var, function, this)
3.2.3Object declaration (init, postinit, isInitialized(), new)
3.2.4Object declaration and sequences
3.2.5Class inheritance (abstract, extends, override)
3.2.6Mixin inheritance (mixin)
3.2.7Function types
3.2.8Anonymous functions
3.2.9Access modifiers (package, protected, public, public-read, public-init)
3.3Flow control, using conditions
3.3.1Basic conditions (if, else)
3.3.2Conditions as expressions
3.3.3Ternary expressions and beyond
3.4Sequence-based loops
3.4.1Basic sequence loops (for)
3.4.2For loops as expressions (indexof)
3.4.3Rolling nested loops into one expression
3.4.4Controlling flow within for loops (break, continue)
3.4.5Filtering for expressions (where)
3.5Repeating code with while loops (while, break, continue)
3.6Act on variable and sequence changes, using triggers
3.6.1Single-value triggers (on replace)
3.6.2Sequence triggers (on replace [..])
3.7Trap problems using exceptions (try, catch, any, finally)
3.8Summary
Chapter 4
Chapter 4 is the first project chapter. The main purpose of this chapter
is to experiment with the JavaFX Script language — specifically
binds and triggers. The project is a simple Sudoku game, using Swing,
carefully designed to showcase the most powerful (and unusual) features
of JavaFX Script.
The code demonstrates how JFX can make developing Model/View/Controller
applications much much easier. For experienced Java/Swing programmers
this chapter should be a real eye opener.
The bonus project shows how to auto-validate a form, using binds.
4.1Swing time: Puzzle, version 1
4.1.1Our initial puzzle data class
4.1.2Our initial GUI class
4.1.3Building the buttons
4.1.4Model/View/Controller, JavaFX Script style
4.1.5Running version 1
4.2Better informed and better looking: Puzzle, version 2
4.2.1Making the puzzle class clever, using triggers and function types
4.2.2Group checking up close: function types
4.2.3Firing the update: triggers
4.2.4Better looking GUI: playing with the underlying Swing component
4.2.5Running version 2
4.3Game on: Puzzle version 3
4.3.1Adding stats to the puzzle class
4.3.2Finishing off the puzzle grid GUI
4.3.3Adding a status line to our GUI with a Label
4.3.4Running version 3
4.4Other Swing components
4.5Bonus: using bind to validate forms
4.6Summary
Chapter 5
Chapter 5 begins the exploration of the JavaFX scene graph. The
project builds on the JavaFX Script skills of the previous chapter,
by coding some basic shape manipulation classes, within the framework
of a light show application.
The bonus project shows a home-made hypertext link, using text
nodes.
5.1What is a scene graph?
5.1.1Nodes: the building blocks of the scene graph
5.1.2Groups: graph manipulation made easy
5.2Getting animated: LightShow, version 1
5.2.1Raindrop animations
5.2.2The RainDrop class: creating graphics from geometric shapes
5.2.3Timelines and animation (Timeline, KeyFrame)
5.2.4Interpolating variables across a timeline (at, tween, =>)
5.2.5How the RainDrop class works
5.2.6The LightShow class, version 1: a stage for our scene graph
5.2.7Running version 1
5.3Total transformation: LightShow, version 2
5.3.1The swirling lines animation
5.3.2The SwirlingLines class: rectangles, rotations, and transformations
5.3.3Manipulating node rendering with transformations
5.3.4The LightShow class, version 2: color animations
5.3.5Running version 2
5.4Lost in translation? Positioning nodes in the scene graph
5.5Bonus: creating hypertext-style links
5.6Summary
Chapter 6
Chapter 6 continues the adventures in scene-graph-land. Building on the
previous chapter, it looks at how to create complex scenes, that respond
to mouse events. Specifically, it shows how to create an animated image
button, and an iPhone-style draggable list. It also examines video
playback, and node effects (like reflections).
The bonus project shows how to embed custom fonts into a JavaFX
application.
6.1Taking control: Video Player, version 1
6.1.1The Util class: creating image nodes
6.1.2The Button class: scene graph images and user input
6.1.3The GridBox class: lay out your nodes
6.1.4The Player class, version 1
6.1.5Running version 1
6.2Making the list: Video Player, version 2
6.2.1The List class: a complex multipart custom node
6.2.2The ListPane class: scrolling and clipping a scene graph
6.2.3Using media in JavaFX
6.2.4The Player class, version 2: video and linear gradients
6.2.5Creating varying color fills with LinearGradient
6.2.6Running version 2
6.3Bonus: taking control of fonts
6.4Summary
Chapter 7
Chapter 7 is aimed squarely at business application developers. The
project is a simple feedback form, that stores its results, and displays
charts and graphs based upon statistics derived from the data. It
showcases some of the standard built-in controls that ship with
JavaFX 1.2, including buttons, sliders, and radio buttons. It also
looks at persistent storage, across multiple devices (including applets
and phones). And finally, it studies in detail how to construct a 3D
bar graph and pie chart.
The bonus project shows how to write your own skinnable JFX control,
and style it using CSS.
7.1Comments welcome: Feedback, version 1
7.1.1The Record class: a bound model for our UI
7.1.2The Feedback class: controls and panel containers
7.1.3Running version 1
7.2Chart topping: Feedback, version 2
7.2.1Cross-platform persistent storage
7.2.2How Storage manages its files
7.2.3Adding pie and bar charts
7.2.4Taking control of chart axes
7.2.5Other chart controls (area, bubble, line, and scatter)
7.2.6Running version 2
7.3Bonus: creating a styled UI control in JavaFX
7.3.1What is a stylesheet?
7.3.2Creating a control: the Progress class
7.3.3Creating a skin: the ProgressSkin class
7.3.4Using our styled control with a CSS document
7.3.5Further CSS details
7.4Summary
Chapter 8
Chapter 8 continues the practical theme, this time with a project tied
to Flickr's web service. The project starts by developing classes to
make a web service call, and parse the reply. These classes are then
used to create an image viewer application: Flickr photos are
thrown onto a full screen desktop, where they can be picked up
and moved around. The code demonstrates several types of off-the-shelf
animations, as well as sophisticated interaction with the scene graph.
A bonus section gives some invaluable background detail on the different
geometries that can apply to a scene graph node as it is rendered on
screen.
8.1Our project: a Flickr image viewer
8.1.1 The Flickr web service
8.1.2 Getting registered with Flickr
8.2 Using a web service in JavaFX
8.2.1 Calling the web service with HttpRequest
8.2.2 Parsing XML with PullParser
8.2.3 A quick recap
8.2.4 Testing our web service code
8.3 Picture this: the PhotoViewer application
8.3.1 Displaying thumbnails from the web service: the GalleryView class
8.3.2 The easy way to animate: transitions
8.3.3 The main photo desktop: the PhotoViewer class
8.4 Size matters: node bounds in different contexts
8.5 Summary
Chapter 9
Chapter 9 is a bit of fun. The project builds a working Enigma machine,
of the type used in World War II to encrypt and decrypt top secret
messages. As well as demonstrating some serious data manipulation in
JavaFX Script, the project also explains the programmer/designer workflow.
The graphical elements on the Enigma interface are constructed in
Inkscape, and saved as SVG files, then imported into the Enigma
application where they are manipulated directly.
In the final part of the project the Engima application becomes an
applet, capable of being ripped from the web page, onto the desktop
(complete with modified JNLP file, to provide a custom desktop icon).
The bonus project brings an Inkscape drawing alive, turning it into
a working user interface by using carefully labelled IDs.
9.1 The Enigma project
9.1.1 The mechanics of the Enigma cipher
9.2 Programmer/designer workflow: Enigma Machine, version 1
9.2.1 Getting ready to use the JavaFX Production Suite
9.2.2 Converting SVG files to FXZ
9.2.3 The Rotor class: the heart of the encryption
9.2.4 A quick utility class
9.2.5 The Key class: input to the machine
9.2.6 The Lamp class: output from the machine
9.2.7 The Enigma class: binding the encryption engine to the interface
9.2.8 Running version 1
9.2.9 Shortcuts using NetBeans, Photoshop or Illustrator
9.3 More cryptic: Enigma Machine, version 2
9.3.1 The Rotor class, version 2: giving the cipher a visual presence
9.3.2 The Paper class: making a permanent output record
9.3.3 The Enigma class, version 2: at last our code is ready to encode
9.3.4 Running version 2
9.4 From application to applet
9.4.1 The Enigma class: from application to applet
9.4.3 Packaging up the applet
9.5 Bonus: Building the UI in an art tool
9.6 Summary
Chapter 10
Chapter 10 has two goals: it pushes the reader's scene graph skills to
the max, and it shows how to package applications up for use on a
cell phone. The project is a 3D maze game, an early prototype of
which can be viewed here.
The bonus section looks at performance tricks and tips, to help keep
your scene graphs nibble, and slick.
10.1 Amazing games: a retro 3D puzzle
10.1.1 Creating a faux 3D effect
10.1.2 Using 2D to create 3D
10.2 The Maze Game
10.2.1 The MazeDisplay class: 3D view from 2D points
10.2.2 The Map class: where are we?
10.2.3 The Radar class: this is where we are
10.2.4 The Compass class: this is where we’re facing
10.2.5 The ScoreBoard class: are we there yet?
10.2.6 The MazeGame class: our application
10.2.7 Running the MazeGame project
10.3 On the move: desktop to mobile, in a single bound
10.3.1 Packaging the game for the mobile profile
10.3.2 Running the mobile emulator
10.3.3 Emulator options
10.3.4 Running the software on a real phone
10.4 Performance tips
10.5 Summary
Chapter 11
Chapter 11, the final project, looks at how to use JavaFX from within
a Java application. The project is a simple isometric adventure game
that uses JavaFX Script code for its in-game events, and to build part
of its Swing user interface.
11.1 Different styles of linking the two languages
11.2 Adventures in JavaFX Script
11.2.1 Game engine events
11.2.2 Calling the JavaFX Script event code from Java
11.3 Adding a little FX to Java
11.3.1 The problem with mixing languages
11.3.2 The problem solved: an elegant solution to link the languages
11.3.3 Fetching the JavaFX Script object from within Java
11.4 Summary