Entwicklung mit JavaFX Die UI-Technologie im JDK 8

Wolfgang Weigend Sen. Leitender Systemberater Java Technologie und Architektur

1 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.

2 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Agenda

• Aktueller Status von JavaFX • Entwicklungsressourcen beim Engineering und in der Java Community • on ARM Port • JavaFXAufbau und Architekturkonzept • Migration von Komponenten • Barrierefreiheit • Vorteile bei der Entwicklung von JavaFX Anwendungen • SceneBuilder GUI Editor • Automatisiertes Testen von JavaFX GUI Komponenten • Open Source Projekt OpenJFX • Kundenbeispiele, Projekte und relevante Partnerlösungen • Zusammenfassung 3 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Aktueller Status von JavaFX • JavaFX 8 ist fester Bestandteil der Java SE 8 – General Availability for Windows, Linux, Mac OS – Java SE 8 Roadmap until 2025 and expected JDK 9 until 2028 – Java SE Development Kit 8 Update 6 for ARM

• Starting with JDK 8u33, JavaFX Embedded is removed from the ARM bundle and is not supported

– http://www.oracle.com/technetwork/java/javase/jdk8u33armrelnotes2406696.

– http://mail.openjdk.java.net/pipermail/openjfxdev/2015January/016570.html • Development Tools – NetBeans 8.2 – JavaFX Scene Builder 2.0 und Version 8.2.0 – e(fx)clipse

• major release cycle alignment with eclipse roadmap

• minor release cycle with JavaFX roadmap 4 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Entwicklungsressourcen beim Engineering und in der Java Community • Development Team – Kevin Rushforth – Senior Engineering Manager – openjfx[email protected] – Technical Writer and Documentation – Oracle Java Support • Java Community – Gluon – MicroDoc Systems – BestSolution.at EDV Systemhaus GmbH – Saxonia Systems AG, Canoo Engineering AG, open knowledge GmbH – Dirk Lemmermann 5 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Die Community beteiligt sich The third party developer community has shown interest in JavaFX. Here are a few projects: • e(fx)clipse: plugins for Eclipse and for OSGi • DataFX: data source and cell factories for JavaFX UI controls • ScalaFX , GroovyFX: Scala and Groovy bindings for JavaFX • JFX Flow, eFX, JRebirth: application development frameworks • FXForms2: automatic form generation • JFXtras: UI controls and extensions for JavaFX • XDEV IDE and XDEV Application Framework XAPI

6 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Gluon Ignite library Dependency Injection Frameworks in JavaFX applications • With the Gluon Ignite library, developers can use popular dependency injection frameworks in their JavaFX applications, including inside their FXML controllers • Gluon Ignite creates a common abstraction over several popular dependency injection frameworks: – currently Guice, Spring, and Dagger, and plan to add more as the demand becomes obvious • With full support of JSR330 Gluon Ignite makes using dependency injection in JavaFX applications trivial • Example of creating an application using the Guice framework and Gluon Ignite:

Source: http://gluonhq.com/ open-source/ignite/

7 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. JavaFX Linux on ARM Port created by MicroDoc • Agreement by Oracle and MicroDoc • MicroDoc has started to create and deploy embedded runtimes in 1999 – MicroDoc worked with customers from a large variety of industries including Automotive, Telematics, Telecommunication, GSM Network Infrastructure, Building Automation, Smart Home, Smart Grid / Smart Metering, Mobile , Airline Traffic Management, Security Systems, Laser Technology, Education • MicroDoc creates Linux on ARM Port for JavaFX on their own – Source code and testing included – As well for higher versions of Java, i.e. Java SE 9 • MicroDoc leds own projects • MicroDoc Linux on ARM Port created and shipped – OpenJFX 8 source with MultiTouch JavaFX build for manufacturing customer in Austria – Debian Linux

10 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Source: https://www.microdoc.com/ JavaFX Runtime Architektur

JavaFX Architektur Komponenten • Glass Windowing Toolkit : Provides native operating services, such as managing the windows, timers, and surfaces • Prism : Graphics pipeline that can run on hardware and software renderers • UI Toolkit : Ties Prism and Glass together and makes them available to the JavaFX APIs

11 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. JavaFX Architektur

• Internal API • Coursegrained porting layer − FX APIs isolated from implementation details • Allows porting to completely different systems

12 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. JavaFX Architektur

• Quantum Toolkit ties Prism and Glass Windowing Toolkit together and makes them available to the JavaFX layer above in the stack

• Quantum Toolkit manages the threading rules related to rendering versus events handling

13 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. JavaFX Architektur

• Graphics API − Converts the scene graph into rendering calls − Abstracts D3D, OpenGL*, Java2D behind a “Graphics” object − Handles “dirty regions”, clipping, and other optimizations − Font support

• Use hardware where possible − Rasterization − Fast paths using shaders for ellipses, rectangles, etc. • Reduce context switches − Looking towards possible state sorting optimizations in the future • Fallback to software rendering when necessary − Bad drivers are the main reason for doing so 14 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. * No direct OpenGL support JavaFX Architektur

• Windowing API − Windows − Mac − Linux − Headless (not done) • Provides basic OS services − Drawing surface − Input events − Event queue

15 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. JavaFX Scenegraph

Scenegraph • Instead of remove/add: − group.getChildren().remove(node); − group.getChildren().add(0, node); • node.toFront() • node.toBack()

Scenegraph −node.toFront() −node.toBack()

16 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Displaying HTML in JavaFX

public class WebViewDemo extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage stage) { WebView webView = new WebView(); webView.getEngine().load("http://java.oracle.com"); Scene scene = new Scene(webView); stage.setScene(scene); stage.setTitle("Web View Demo"); stage.show(); } }

17 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. JavaFX mit JFXPanel Komponente in Swing Anwendungen einbinden public class Test {

private staticClass void initAndShowGUI() JFXPanel { private static void initFX(JFXPanel fxPanel) { // This methodjava.lang.Object is invoked on Swing thread // This method is invoked on JavaFX thread JFrame frame =java.awt.Component new JFrame("FX"); Scene scene = createScene(); final JFXPanel fxPanel = new JFXPanel(); fxPanel.setScene(scene);

frame.add(fxPanel); java.awt.Container} frame.setVisible(true); javax.swing.JComponent .embed.swing.JFXPanelpublic static void main(String[] args) { Platform.runLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {

@Override @Override

public void run() { public void run() {

initFX(fxPanel); initAndShowGUI();

} }

}); });

} } }

18 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Hello World in JavaFX Programming in Java public class JavaFXExample extends Application { @Override public void start(Stage stage){ Scene scene = new Scene( LabelBuilder.create() .text(" Hello World! ") .layoutX(25) .build()); stage.setTitle(" Welcome to JavaFX! "); stage.setScene(scene); stage.show(); } public static void main(String[] args) { launch(args); } }

19 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Hello World in JavaFX Programming in FXML und Java FXML

Java public class FXMLExample extends Application { @Override public void start(Stage stage) throws Exception { stage.setTitle(" FXML Example "); Parent root = FXMLLoader.load(getClass().getResource (“ example.fxml "), ResourceBundle.getBundle(“ r.fxml_example ")); stage.setScene( new Scene(root)); stage.show(); } public static void main(String[] args) { launch(args); } }

20 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. JavaFX Scene Builder 2.0

http://www.oracle.com/technetwork/java/javase/downloads/sb2download2177776.html

21 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. JavaFX Scene Builder

• UI layout tool for JavaFX • FXML visual editor • Can be used standalone or with all major Java IDEs – Tighter integration with NetBeans IDE • Preview mode • CSS support • Supported on Windows and Mac OS X

22 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Gluon supports Scene Builder • Scene Builder only as source code within the OpenJFX project • Gluon provides Scene Builder builds – Actively work on improvements to Scene Builder, in a public repo, to further drive the functionality of Scene Builder forward – These builds will be the Oracle bits, with additional improvements based on community involvement and our desires to better support third party projects such as ControlsFX , FXyz , DataFX , others • Downloads: • Scene Builder is open source and licensed under the BSD license

• Scene Builder 8.2.0 released on 18 th of May 2016

23 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Source: http://gluonhq.com/open-source/scene-builder/ Funktionale Systemtests für JavaFX Automatisiertes Testen für JavaFX UI Controls

•Functional Testing QF-Test •UI Controls Firma Quality First Software Professionelles GUITesten für •Scenegraph Java & Web www.qfs.de

24 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. QF-Test und JavaFX 8 • JavaFX ist eine pure JavaAnbindung analog Swing • Erfahrungsschatz erlaubt schnelle Erweiterung auf JavaFX • Technischer Durchstich bereits erfolgreich vollzogen • Offizielle Unterstützung für Java 8 • QFTest Version 4.1 freigegeben

Java Swing Eclipse/SWT Web 25 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. QF-Test & JavaFX 8 – GUI Testautomatisierung

26 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. JavaFX in the Browser http://www.jpro.io/

jpro is a new technology which brings Java back into the browser without Java Plugin. To achieve that, jpro runs JavaFX on the server and maps its scenegraph directly into the browser

The client side rendering is highly optimized with browser side approximations and browser side rendering to get a smooth user experience free of lags

27 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. © 2016 jpro technologies AG jpro architecture - JavaFX in the browser Thin client model

28 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. © 2016 jpro technologies AG JavaFX und Open Source http://openjdk.java.net/projects/openjfx

•UI Controls OpenJFX •Scenegraph •JemmyFX

29 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Java SE Roadmap JDK 7u21/25 JDK 7u40/45/51/55/60 JDK 8 GA18 th of March 2014 JDK 8u40/8u45/8u51 JDK 9 .. • Java Client • Lambda • Performance • Modularity - Jigsaw JDK7u65/67/71/75/79/80 Improvements Security • JSR 310: New Date & Time API • HTTP 2.0 Enhancements • Java Flight Recorder • Density and Resource • Complete JVM Convergence • Lightweight JSON in JDK Management • Nashorn: JavaScript Interoperability • Cloud optimized JVM • Native Memory • Multi-Language Tracking • JavaFX 8 Improvements • Continued Java SE Advanced Features • Java Discovery − Public UI Control API • Accessibility Protocol − Java SE Embedded support Enhancements • Ahead of Time Compilation • App Store Packaging − Enhanced HTML5 support • Continued Java SE Tools Advanced Features

2013 2014 2015 2017

JDK 8u20/25/31 JDK 8u60 .. 8u111 • G1 Performance Improvements • Bug Fixes • JVM Performance Improvements • Continued Java SE • Java Mission Control 5.4 Advanced Features • Advanced Management Console 1.0 • MSI Enterprise Installer 30 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. JavaFX Kundenbeispiele

31 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. JavaFX Anwendungen

 Celer is a trading management platform for every asset class, the true multi asset modular trading platform. Built by traders for traders.

• The Celer Trading module is built on top of the Celer framework and combines an execution and order management system in one, giving all the control needed in one easy to use platform. Quick order entry and combination depth deal tickets are just some of the features that the platform can offer customer trading.

• Software Development Kit (SDK) The Celer Framework SDK allows to build the next feature to keep customer business ahead of the competition and to adapt to customer needs in the future.

32 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. JavaFX Real-World Applications Area of use Hospitals / Surgery • CuratorOR Caliop, entwickelt von der EIZO GMBH in Deutschland, ist eine Anwendung, die in OPSälen von Krankenhäusern installiert werden soll. Sie ist ausgelegt auf Konsolen, die an der Wand montiert werden und mit einem Windows PC verbunden sind, auf dem Java 8 läuft. Die Konsolen sind außerdem mit zusätzlicher Hardware ausgestattet, um VideoInputSignale an diverse Monitore / Displays zu verteilen und VideoSignale aufzuzeichnen (Video und Screenshots). Das OPPersonal nutzt Caliop dann, um auf Patientendaten zuzugreifen, OPs zu dokumentieren und die produzierten Dokumente in der zentralen Datenbank des Krankenhauses abzulegen. Von Dirk Lemmermann and Alexander Casall

33 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Source: https://jaxenter.de/javafx-anwendungen-aus-der-praxis-so-schoen-kann-ein-java-ui-sein-34877 Source: https://jaxenter.com/20-javafx-real-world-applications-123653.html? Volkswagen Group Research - Reactive Modeling of Automotive User Interfaces with JavaFX

• UI series development at Volkswagen Group • UI prototyping at Volkswagen Group Research • The UI framework Tappas • Reactive UI modeling • Implementation of reactive models with JavaFX • JavaFX on automotive target hardware

34 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. UI series development at Volkswagen Group

• User interfaces for automotive infotainment systems are developed for various models, brands and markets at Volkswagen Group • A high number of variants and skins are required • The development is based on state chart models • Java 1.4 code is generated • Rendering is hardware accelerated using OpenGL ES

35 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. UI prototyping at Volkswagen Group Research

• UI prototypes require fast and flexible development • JavaFX is our technology of choice, replacing Flash

36 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. JavaFX - UI prototyping at Volkswagen Group Research - Tappas UI framework • UI prototypes require fast and flexible development • JavaFX is our technology of choice, replacing Flash • Tappas UI framework – Highly modular and flexible with OSGi – Different JavaFX center console applications for different hardware and operating concepts • Single screen, split screen or dual screen applications • Hardware keys, direct touch or indirect touch operation – Various JavaFX apps as OSGi bundles, running within the different center console applications • Tuner, media, telephone, contacts, climate, navigation with a 3D map written in JavaFX, etc. – Reactive modeling of screen changes – Quelle: Volkswagen AG, Jens Ehrke & Simon Gerlach, JavaOne 2014, vom 1. Oktober 2014 • Reactive Modeling of Automotive User Interfaces with JavaFX 37 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Ressourcen

• Downloads: http://otn.oracle.com/javafx

• OpenJFX: http://openjdk.java.net/projects/openjfx/ • Oracle Premier Support http://www.oracle.com/us/support/software/premier/ • Blogs – http://blogs.oracle.com/javafx – http://fxexperience.com

• OTN Forum: https://forums.oracle.com/forums/forum.jspa?forumID=1385 • Twitter: @javafx4you

38 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Zusammenfassung

 JavaFX is the strategic Java UI technology for rich client applications  Unified development of Java and Web applications • Browser Plugin, Web Start, Native Executables • Hardware Accelerated Graphics (DirectX, ..) • JavaFX Web View based on WebKit ‒ JavaFX with WebView for HTML5 features ‒ Improved JavaScript Engine ‒ JavaFX as applet integrated to run in a web page • IDE support for Eclipse e(fx)clipse, IntelliJ, IDEA, NetBeans, etc. • Private vs. JavaFX Public API with JDK 9 (TBD)  Wanted JavaFX for mobile operating systems iOS & Android - desirable  Developer community could make use of the JavaFX Open Source process • Get hands-on porting for iOS and Android

39 Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Danke! [email protected] Twitter: wolflook

40 Copyright © 2016 Oracle and/or its affiliates. All rights reserved.