jazoon fx talk v1 1

machinebrainySoftware and s/w Development

Jun 8, 2012 (6 years and 4 months ago)


The Condemned Live Longer
Andreas Fürer and David Sauter
AdNovum Informatik AG
Submission ID: 97Introduction
> Speakers
– Andreas Fürer, AdNovum Informatik AG
– David Sauter, AdNovum Informatik AG
> About this talk
– Give experience report to people planning to use JavaFX
– Pros and cons of using JavaFX in a desktop application
> Introduction
> The Problem to Solve
> Technology Evaluation
> JavaFX in Practice: our experience
– The good
– The bad
– …, and the ugly?
> Conclusion
3About AdNovum Informatik AG
> Founded in 1988 as a small software project company
> Currently ~200 employees (70% engineers) ‏
> Core competence: High-end business applications and security software for
– Finance
– Insurance companies
– Government
– Telecommunications
> About the project …
– “Intelligent T-Shirt”: Health data visualization software in Eclipse RCP
– Visualization of health data for sports, written in JavaFX
4The Problem to Solve
“Develop a desktop application for monitoring real-time health data”
> Strong graphical requirements
– Customer has clear ideas about the design and the look & feel
– Chart integration with real-time streaming
– Complex and large GUI with lots of functionality
> Technical constraints on our side
– Project is follow-up: reuse as much as possible
– External hardware integration
– Must match the existing tools we are using
We need a UI technology that can cope with all aspects involved
5The Problem to Solve (2) ‏
> Problem: Users are accustomed to modern looking, interactive web pages
– Puts increased pressure on desktop applications to keep up
> Customer requirements
– Modern and fancy UI (similar to web pages) ‏
– No standard window decorations
– Smooth round window edges
– Many custom-made widgets (buttons, lists, navigation, …) ‏
– Nice look, but still intuitive to use
Solution 1: Develop web applications explicitly
Solution 2: Use existing GUI technologies for the desktop (Swing, SWT) ‏
Solution 3: Use RIA technologies that deploy to the desktop
6The Problem to Solve (3) ‏
Criteria Priority
Java Integration
Runtime Environment
Build Process
Learning Curve
7Technology Evaluation
> We came up with four UI technologies that are up to the task
> Two of them were dropped
– Eclipse RCP 3.5 does not meet the high graphical demands
– Microsoft Silverlight does neither fit into our stack nor does it go hand in
hand with our philosophy
Adobe AIR/Flex and JavaFX are evaluated in detail
8Technology Evaluation (2): Adobe AIR/Flex
“Flex is a highly productive, free, open source framework for building expressive web
applications that deploy consistently across browsers, desktops, and operating systems by
leveraging the Adobe Flash Player and Adobe AIR runtimes.”
> First released in March 2004 mature technology
> Develop RIAs based on Adobe Flash that deploy to the desktop
> Build visually rich applications, GUI builder: FlexBuilder
v1.0 v2.0 v3.0 v4.0
‘04 ‘05 ‘06 ‘07 ‘08 ‘09 ’10
9Technology Evaluation (3): JavaFX
“JavaFX is the best way to create expressive, feature-rich content. Building on the Java
Platform, JavaFX delivers a compelling mix of ubiquity, capability, expressiveness and
> First released in December 2008
> RIA for the desktop
> Production Suite: Plugins for Photoshop and Illustrator export graphics to
JavaFX Script
v1.0 v1.2 v1.3
‘04 ‘05 ‘06 ‘07 ‘08 ‘09 ’10
10Technology Evaluation (4): Comparison
Criteria Priority AIR/Flex JavaFX
Java Integration
Runtime Environment
Build Process
Learning Curve
11Technology Evaluation (5): Decision
> Both JavaFX and Adobe AIR/Flex seem to fill a space where desktop apps
should look like modern web pages
> JavaFX wins the evaluation because of …
– Java and external hardware integration
– runtime environment
– learning curve
> despite …
– being less mature
– having less components and no UI builder
> Project is being developed since February 2010
– On Linux with NetBeans 6.8 and Eclipse 3.5
– Used JavaFX 1.2, recently upgraded to JavaFX 1.3
12Our Experience
> The good
– Powerful graphic and animations
– Seamless integration with Java
– Mature runtime
– Powerful language feature
> The bad
– Missing controls
– Missing layout managers
– Styling and Skinning in JavaFX 1.2
– Missing QA aspects
> …, and the ugly?
13 13Powerful graphic and animation capabilities
> JavaFX Scene Graph (retained mode
rendering) is very powerful
– Effects and animations can easily
be applied to nodes and groups
– Developers don’t need graphic
programming knowledge
Node Group
– Scene Graph builds your object-
oriented view model
The Scene Graph allows us to
implement a fully customized user
Button Text
interface without struggling with Java
2D or SWT 2D API
14 14Production Suite
create graphics (FXD/FXZ)‏
business logic
Designer Developer
> Absolute layouts of nodes (no dynamic layouts) ‏
> Missing I18N support
> Trial-and-error: How to arrange layers in Illustrator so that I get the expected
FXD structure time-consuming and error-prone iterations
> Fonts are included in each FXZ huge FXZ files
> Issues with fonts (character sets, issues with different OS) ‏
Designer/Developer workflow does not fit all use-cases.
15 15
Works for simple widgets, but not for complex controls and layouts.Example
> Lines of Code:
– Handwritten: 20 LoC
– Generated: 300 LoC (gradients, SVG path)‏
Image how many LoC needed to do the same with Java2D?
16 16
>Seamless Integration with Java
> Java classes can directly be used
var logDebugEnabled: Boolean =
if (logDebugEnabled) {
LOG.entering(this, "contentLoaded");
> Direct usage of JPA classes
– No separate DTO classes in FX needed
> Integration of 3 -party libraries
– Integration of JFreeChart with swing.ext
> Run an embedded DB
– H2 is used as relational database
17 17
> Integration of external hardware with JNIMature Runtime Environment
“We also know first hand that Flash is the
number one reason Macs crash.” (S. Jobs) ‏
> Java Runtime is a stable runtime environment
> We know the tools
– Profiling (JProbe) ‏
– Monitoring and troubleshooting (JVisualVM)‏
– Remote debugging (-Xdebug –Xrundwp options) ‏
– Memory management tuning (-Xmx –Xms options) ‏
> Reverse-engineering possible (jad) ‏
18 18Powerful Language Feature: Databinding
Databinding is a very powerful language feature of JavaFX
> Avoids writing lots of boilerplate code
> Avoids writing observer/listener patterns
var area = bind x * y;
> Developers immediately start using those features everywhere
> We ran into performance problems soon
> Performance of bind in JavaFX 1.2 is still not good
– Profiling Example: 70% of the handler time used for listener notifications
19 19Bind in JavaFX 1.2
> Variables are implemented by object graph (so-called “Location”) ‏
– Maintain dependencies between related variables
– Track changes of values
– Fire update and notify listeners
var area = bind x * y;
> Location graphs quickly get huge and updates slow!
20 20Bind in JavaFX 1.3
> Compile bind directly into generated bytecode
– In-lining of expressions in getters/setters
– Lazy evaluation using invalidation
– Locations and other supporting structures (BindingExpression,
ChangeListeners) no longer used
> Less memory footprint, no GC of location graphs
> Less execution time to build and update location graphs
public static int get$area() {
if (/* check invalidation */) {
Binding.Script.VFLG$area = (short)(Binding.Script.VFLG$area | 0x400);
} else if ((Binding.Script.VFLG$area & 0x104) == 260) {
// ...
int varNewValue$ = get$x() * get$y();
$area = varNewValue$;
return $area;
21 21
}Missing Controls
> JavaFX 1.2 controls were pretty poor and buggy
> New controls introduced in JavaFX 1.3
– ChoiceBox, TreeView (preview), PasswordBox, Menu, …
> JFXtras tries to close the gap
> Still missing:
– Dropdown/Combobox (ChoiceBox in 1.3 is not a substitute) ‏
– Spinner
– TableView (incl. sorters, in-cell editing) ‏
– CheckBoxTreeView
– Groups
– TabFolders
22 22Missing Controls (2) ‏
> MessageBox (InfoMessageBox, WarningMessageBox, ErrorMessageBox)‏
> Dialogs (ColorDialog, FileDialog, FontDialog, PrintDialog) ‏
Swing dialogs can be used, but are not skinnable
Not essential, but nice to have:
> Expandable groups (aka ExpandBar in SWT) ‏
> Calendar
> HTML/WebView
23 23Missing Layout Managers
> GridLayout missing in JavaFX 1.2
– Most important layout manager
> BorderLayout missing
> We use MigLayout (port from JFXtras) ‏
– Powerful table layouts with dynamic cell sizes possible
– Integration details sometimes hard to solve
> JavaFX 1.3 introduces GridLayout as preview (API changes possible) ‏
24 24Styling and Skinning in JavaFX 1.2
CSS Styling with JavaFX 1.2
> Very buggy (e.g. styles only applied when loading scene) ‏
> Not documented, only few examples
> Did not cover all controls (e.g. ListView)‏
> Not generic enough, tailor-made for Caspian
We had to solve the styling of the application by overriding the
Caspian Skins classes
– Performance issues due to bindings
– Trial-and-error (missing Caspian documentation) ‏
25 25CSS Improvements in JavaFX 1.3
> Huge improvements of CSS support in
JavaFX 1.3
> Changing not just color schemes,
but also their shapes! (Region API)‏
> CSS syntax changed from 1.2 1.3
> Region API not considered finished
> JavaFX CSS specification (1.3) still not
.triangle {
-fx-shape: "M 0,1 L 1,1 .5,0 Z";
-fx-background-color: darkgray,
-fx-background-insets: 0, 2 2 2 2;
26 26
}Missing QA Aspects
> Lack of stable tools for automated GUI testing
– Jemmy: V3 in development; stability issues with JavaFX 1.2 (GUI deadlocks) ‏
– FEST-JavaFX: Promising, but not yet ready
> Unit testing
– No direct support from JavaFX platform and IDEs
– Integration of JUnit as test harness possible
– Declarative unit tests with org.jfxtras.test
Stable QA frameworks and tooling for production use missing
27 27Conclusion: JavaFX for Desktop Applications
What do we need to build our applications?
JavaFX Platform:
> All (standard) controls (Dropdown, Table, Tree, Spinner, DateField, …) ‏
> Validators (e.g. with annotations) and visual indications
> Better tooling support (e.g. scene graph browser, Eclipse support) ‏
> Splash Screen during startup (nobody wants to see Java Webstart) ‏
> Rich application components like:
– Wizard
– Job Scheduling (aka Jobs API and the ProgressView in Eclipse RCP) ‏
– Online help integration
28 28
> QA frameworks and better tooling integrationConclusion: … and the ugly?
> JavaFX is on the right track (see improvements between 1.1 and 1.3) ‏
> Strong commitment from Oracle to further invest in JavaFX
> Not only focus on the competition with Flash/Silverlight, convince Java devs
> Invest in enterprise application features and tools
> Complete documentation
> Frameworks have to evolve first (e.g. QAE tooling / application platforms) ‏
Java 1.0 was also bleeding edge, Java 1.4 was usable, Java 7 is mature J
1.2 1.3
1.0 1.1
Frameworks 100%
30 30Screenshot (2) ‏
31 31Andreas Fürer
AdNovum Informatik AG andreas.fuerer@adnovum.ch
David Sauter
AdNovum Informatik AG david.sauter@adnovum.ch