<<

Entwicklung mit JavaFX Wolfgang Weigend Sen. Leitender Systemberater

Java1 Copyright Technologie © 2014 Oracle and/or its affiliates. und All righArchitekturts 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 © 2014 Oracle and/or its affiliates. All rights reserved. Agenda • Aktueller Status von JavaFX • JavaFX-Aufbau und Architekturkonzept • Vorteile von JavaFX bei der Entwicklung von JavaFX Anwendungen komplett in der Programmiersprache und mit Java Entwicklungswerkzeugen • JavaFX Scene Builder • Open Source Projekt OpenJFX • Kundenbeispiele • Zusammenfassung

3 Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Existierende JavaFX Produkt Releases • JavaFX 8 ist Bestandteil vom JDK 8 – General Availability for Windows, , Mac OS – Java SE Development Kit 8 Update 6 for ARM • Development Tools – NetBeans 8.0.1 – JavaFX Scene Builder 2.0 – e(fx)clipse

• major release cycle alignment with eclipse roadmap

• minor release cycle with JavaFX roadmap

4 Copyright © 2014 Oracle and/or its affiliates. All rights reserved. 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

5 Copyright © 2014 Oracle and/or its affiliates. All rights reserved. JavaFX Architektur

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

6 Copyright © 2014 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

7 Copyright © 2014 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 8 Copyright © 2014 Oracle and/or its affiliates. All rights reserved. JavaFX Architektur

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

9 Copyright © 2014 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()

10 Copyright © 2014 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(); } }

11 Copyright © 2014 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 javafx.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();

} }

}); });

} } }

12 Copyright © 2014 Oracle and/or its affiliates. All rights reserved. WebView und Swing Interoperabilität

WebView Component Swing and SWT Interop. Browser Plug-In

• Embed Web content in • Embed JavaFX content • Faster loading of JavaFX JavaFX applications into existing Swing Web applications based • HTML rendering based applications on Prism on Webkit • Extend existing Swing • Pre -loader for improved • Hardware accelerated applications with new user experience with rendering using PRISM JavaFX features such as JavaFX Web WebView and high- applications • DOM access and performance graphics manipulation • Applies to SWT* applications as well

13 Copyright © 2014 Oracle and/or its affiliates. All rights reserved. * Feature introduced since JavaFX 2.1 Design Objectives JavaFX – Moving Client Forward

Oracle’s next generation Java client solution • Built on Java in Java • Modular architecture • Migration path for Java client UI technologies • Advanced tooling • Delivering on the cross-platform promise

14 Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Java APIs und FXML

Java APIs für JavaFX FXML

• End-to-end Java development • Scriptable, XML-based markup language • Java language features - generics, for defining UI annotations, multi-threading • Convenient alternative to developing UI • Fluent API for UI construction programmatically in Java • Alternative JVM supported languages • Easy to learn and intuitive for developers (e.g. Groovy, Scala) with JavaFX familiar with web technologies or other • Leverage sophisticated Java IDEs, markup based UI technologies debuggers and profilers • Powerful scripting feature allows • Java APIs preserve convenient embedding scripts within FXML. Any JVM JavaFX Script features (e.g., bind) scripting language can be used, including JavaScript, Groovy, and Scala

15 Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Graphics und Media

New Graphics Pipeline Media

• New hardware accelerated graphics • Stable media framework based on pipeline (Prism) GStreamer • New windowing toolkit (Glass) for Prism • H.264*, VP6; MP3, AAC* playback of • Java2D Software Pipeline under Prism Web multimedia content • High-level support for making rich • Low latency audio graphics simple • Alpha Channel support for full • Shadows, Blurs, Reflections, Effects, 2D transparency to solid Pixel transforms • Performance improvements • 3D Transforms today; Full 3D objects in future • Full screen video

16 Copyright © 2014 Oracle and/or its affiliates. All rights reserved. * Feature introduced since JavaFX 2.1 New JavaFX Features in JDK 8

• New Modern Theme: Modena • JavaFX 3D • Rich Text • TreeTableView • DatePicker • Public API for CSS structure • WebView Enhancements • Embedded Support

17 Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Modena Modern Theme - New in JavaFX 8

18 Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Rich Text - New in JavaFX 8 • Use Cases – text editor, code editor – mixed style Labels, buttons, cells, headings, descriptions, large textual content, etc. • Details – TextFlow, a new layout container – Text is just a node… so you can add effects, event handlers, and animations – You can also use CSS, FXML

19 Copyright © 2014 Oracle and/or its affiliates. All rights reserved. TreeTableView - New in JavaFX 8

• Goal: reuse as many API, or API concepts, as possible from the TreeView and TableView controls API

20 Copyright © 2014 Oracle and/or its affiliates. All rights reserved. DatePicker - New in JavaFX 8

21 Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Public API for CSS structure - New in JavaFX 8

• CSS styling is one of the key features for JavaFX • CSS has been implemented exclusively in private API (com.sun.javafx.css package) • Tools (e.g. Scene Builder) require a CSS public API • Developers will be able to define custom CSS styles

22 Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Embedded Support - New in JavaFX 8

• JavaFX to be included in Oracle’s implementation of – Java SE 8 (x86, x64, ARM) – Java SE Embedded 8 (ARM) • Java SE Embedded 8 will include a subset of the JavaFX features to be released in the desktop version – No WebView support – No media support

23 Copyright © 2014 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); } }

24 Copyright © 2014 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); } }

25 Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Java Entwicklungswerkzeuge

• Source editor with improved syntactic highlighting, code completion, refactoring etc. • Full debugger and profiler support • Project wizard for easy creation of JavaFX applications

Other Java IDE’s • Source editor with syntactic highlighting, code completion, refactoring etc. • Full debugger and Profiler support

26 Copyright © 2014 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 27 Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Funktionale Systemtests für JavaFX Automatisiertes Testen für JavaFX UI Controls

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

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

Java Swing Eclipse/SWT Web 29 Copyright © 2014 Oracle and/or its affiliates. All rights reserved. JavaFX Scene Builder 2.0

http://www.oracle.com/technetwork/java/javase/downloads/sb2download-2177776.

30 Copyright © 2014 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

31 Copyright © 2014 Oracle and/or its affiliates. All rights reserved. JavaFX und Open Source http://openjdk.java.net/projects/openjfx

•UI Controls OpenJFX •Scenegraph •JemmyFX

32 Copyright © 2014 Oracle and/or its affiliates. All rights reserved. JavaFX via Open Source im JDK 8

Open Source Übergang Standardisierung OpenJFX Project under Common license with Oracle committed to OpenJDK Java SE JavaFX standardization First phase to focus on JavaFX included in JSR to be submitted UI Controls Java SE with JDK 8 through JCP and JSR expected for JDK 9 JavaFX for Java SE Embedded (ARM)

33 Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Open Source und Standardisierung

• JavaFX source code being contributed as part of OpenJFX http://openjdk.java.net/projects/openjfx/ – Source code being contributed in phases – Open sourced as of March 2013 • UI Controls • Scene Graph • JemmyFX • Functional Tests • Oracle is committed to standardize JavaFX through JCP – One or more JSRs will be submitted – Expected to be become part of the Java SE specification

34 Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Die künftige Ausrichtung von JavaFX Oracle’s Next Generation Java Client Solution • Tighter Integration with Java SE • Migration Path for Java Client UI Technologies • Optimized Web Services Support • Advanced Tooling • Support for Modern Device Interactions • Delivering on the Cross Platform Promise

35 Copyright © 2014 Oracle and/or its affiliates. All rights reserved. JavaFX Kundenbeispiele

36 Copyright © 2014 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.

37 Copyright © 2014 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 © 2014 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 Plug-in, Web Start, Native Executables • Hardware Accelerated Graphics (DirectX, OpenGL) • JavaFX with HTML-DOM ‒ 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.  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 © 2014 Oracle and/or its affiliates. All rights reserved. Danke! [email protected] Twitter: @wolflook

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