40
1 Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Entwicklung mit JavaFX Wolfgang Weigend Sen. Leitender Systemberater Java Technologie und Architektur

Development mit JavaFX - Home: DOAG e.V. · Title: Microsoft PowerPoint - Development mit JavaFX Author: wweigend Created Date: 11/10/2014 7:24:11 PM

Embed Size (px)

Citation preview

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

Entwicklung mit JavaFXWolfgang Weigend

Sen. Leitender Systemberater

Java Technologie und Architektur

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

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

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.

Agenda

• Aktueller Status von JavaFX

• JavaFX-Aufbau und Architekturkonzept

• Vorteile von JavaFX bei der Entwicklung von JavaFX Anwendungen komplett in der Java Programmiersprache

und mit Java Entwicklungswerkzeugen

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

und mit Java Entwicklungswerkzeugen

• JavaFX Scene Builder

• Open Source Projekt OpenJFX

• Kundenbeispiele

• Zusammenfassung

Existierende JavaFX Produkt Releases• JavaFX 8 ist Bestandteil vom JDK 8

– General Availability for Windows, Linux, Mac OS

– Java SE Development Kit 8 Update 6 for ARM

• Development Tools– NetBeans 8.0.1

– JavaFX Scene Builder 2.0

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

– JavaFX Scene Builder 2.0

– e(fx)clipse

• major release cycle alignment with eclipse roadmap

• minor release cycle with JavaFX roadmap

JavaFX Runtime Architektur

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

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

JavaFX Architektur

• Internal API

• Course-grained porting layer

− FX APIs isolated from

implementation details

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

implementation details

• Allows porting to completely

different systems

JavaFX Architektur

• Quantum Toolkit ties Prism and Glass

Windowing Toolkit together and makes

them available to the JavaFX layer above

in the stack

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

• Quantum Toolkit manages the threading

rules related to rendering versus events

handling

JavaFX Architektur

• Graphics API

− Converts the scene graph into

rendering calls

− Abstracts D3D, OpenGL, Java2D

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

behind a “Graphics” object

− Handles “dirty regions”, clipping, and

other optimizations

− Font support

− Rasterization• Use hardware where possible− 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

JavaFX Architektur

• Windowing API

− Windows

− Mac

− Linux

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

− Headless (not done)

• Provides basic OS services

− Drawing surface

− Input events

− Event queue

Scenegraph• Instead of remove/add:

− group.getChildren().remove(node);

− group.getChildren().add(0, node);

• node.toFront()

JavaFX Scenegraph

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

• node.toFront()

• node.toBack()

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

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();

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

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();

}

}

Class JFXPaneljava.lang.Object

java.awt.Component

java.awt.Container

private static void initFX(JFXPanel fxPanel) {

// This method is invoked on JavaFX thread

Scene scene = createScene();

fxPanel.setScene(scene);

}

JavaFX mit JFXPanel Komponente in Swing Anwendungen einbinden

public class Test {

private static void initAndShowGUI() {

// This method is invoked on Swing thread

JFrame frame = new JFrame("FX");

final JFXPanel fxPanel = new JFXPanel();

frame.add(fxPanel);

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

javax.swing.JComponentjavafx.embed.swing.JFXPanel

}

public static void main(String[] args) {

SwingUtilities.invokeLater(new Runnable() {

@Override

public void run() {

initAndShowGUI();

}

});

}

}

frame.add(fxPanel);

frame.setVisible(true);

Platform.runLater(new Runnable() {

@Override

public void run() {

initFX(fxPanel);

}

});

}

WebView und Swing Interoperabilität

• Embed Web content in JavaFX applications

• HTML rendering based on Webkit

WebView Component

• Embed JavaFX content into existing Swing applications

• Extend existing Swing

Swing and SWT Interop.

• Faster loading of JavaFX Web applications based on Prism

• Pre-loader for improved

Browser Plug-In

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

on Webkit

• Hardware accelerated rendering using PRISM

• DOM access and manipulation

• Extend existing Swing applications with new JavaFX features such as WebView and high-performance graphics

• Applies to SWT* applications as well

• Pre-loader for improved user experience with JavaFX Web applications

* Feature introduced since JavaFX 2.1

Design Objectives

Oracle’s next generation Java client solution

• Built on Java in Java

• Modular architecture

JavaFX – Moving Client Forward

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

• Modular architecture

• Migration path for Java client UI technologies

• Advanced tooling

• Delivering on the cross-platform promise

Java APIs und FXMLJava APIs für JavaFX

• End-to-end Java development

• Java language features - generics, annotations, multi-threading

• Fluent API for UI construction

FXML

• Scriptable, XML-based markup language for defining UI

• Convenient alternative to developing UI programmatically in Java

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

• Fluent API for UI construction

• Alternative JVM supported languages (e.g. Groovy, Scala) with JavaFX

• Leverage sophisticated Java IDEs, debuggers and profilers

• Java APIs preserve convenient JavaFX Script features (e.g., bind)

programmatically in Java

• Easy to learn and intuitive for developers familiar with web technologies or other markup based UI technologies

• Powerful scripting feature allows embedding scripts within FXML. Any JVM scripting language can be used, including JavaScript, Groovy, and Scala

Graphics und MediaMedia

• Stable media framework based on GStreamer

• H.264*, VP6; MP3, AAC* playback of Web multimedia content

• New hardware accelerated graphics pipeline (Prism)

• New windowing toolkit (Glass) for Prism

• Java2D Software Pipeline under Prism

New Graphics Pipeline

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

Web multimedia content

• Low latency audio

• Alpha Channel support for full

transparency to solid Pixel

• Performance improvements

• Full screen video

• Java2D Software Pipeline under Prism

• High-level support for making rich graphics simple

• Shadows, Blurs, Reflections, Effects, 2D

transforms

• 3D Transforms today; Full 3D objects in

future

* Feature introduced since JavaFX 2.1

New JavaFX Features in JDK 8

• New Modern Theme: Modena

• JavaFX 3D

• Rich Text

• TreeTableView

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

• TreeTableView

• DatePicker

• Public API for CSS structure

• WebView Enhancements

• Embedded Support

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

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

• 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

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

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

• Tools (e.g. Scene Builder) require a CSS public API

• Developers will be able to define custom CSS styles

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

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

features to be released in the desktop version– No WebView support

– No media support

Hello World in JavaFXProgramming in Javapublic class JavaFXExample extends Application {

@Override public void start(Stage stage){

Scene scene = new Scene(

LabelBuilder.create()

.text("Hello World!")

.layoutX(25)

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

.build());

stage.setTitle("Welcome to JavaFX!");

stage.setScene(scene);

stage.show();

}

public static void main(String[] args) {

launch(args);

}

}

Hello World in JavaFXProgramming in FXML und JavaFXML<BorderPane>

<center>

<Label text=”%helloworld"/>

</center>

</BorderPane>

Java

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

Javapublic 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); }

}

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

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

applications

Other Java IDE’s

• Source editor with syntactic highlighting,

code completion, refactoring etc.

• Full debugger and Profiler support

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

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

• 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

Funktionale Systemtests für JavaFXAutomatisiertes Testen für JavaFX UI Controls

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

QF-TestFirma Quality First Software

Professionelles GUI-Testen für

Java & Web www.qfs.de

•Functional Testing•UI Controls•Scenegraph

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

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

• QF-Test Version 4.0.2 freigegeben

Java Swing

Eclipse/SWT

Web

JavaFX Scene Builder 2.0

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

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

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

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

– Tighter integration with NetBeans IDE

• Preview mode

• CSS support

• Supported on Windows and Mac OS X

JavaFX und Open Sourcehttp://openjdk.java.net/projects/openjfx

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

OpenJFX •UI Controls•Scenegraph•JemmyFX

JavaFX via Open Source im JDK 8

Open Source

�OpenJFX Project under

OpenJDK�

Übergang

�Common license with

Java SE�

Standardisierung

�Oracle committed to

JavaFX standardization�

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

OpenJDK

�First phase to focus on

UI Controls

Java SE

�JavaFX included in

Java SE with JDK 8

�JavaFX for Java SE

Embedded (ARM)

JavaFX standardization

�JSR to be submitted

through JCP and JSR

expected for JDK 9�

Open Source und Standardisierung

• JavaFX source code being contributed as part of OpenJFXhttp://openjdk.java.net/projects/openjfx/

– Source code being contributed in phases

– Open sourced as of March 2013

• UI Controls

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

• 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

Die künftige Ausrichtung von JavaFX

• Tighter Integration with Java SE

• Migration Path for Java Client UI Technologies

• Optimized Web Services Support

• Advanced Tooling

Oracle’s Next Generation Java Client Solution

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

• Advanced Tooling

• Support for Modern Device Interactions

• Delivering on the Cross Platform Promise

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

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

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.

Ressourcen

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

• OpenJFX: http://openjdk.java.net/projects/openjfx/

• Oracle Premier Supporthttp://www.oracle.com/us/support/software/premier/

• Blogs

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

• Blogs– http://blogs.oracle.com/javafx

– http://fxexperience.com

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

• Twitter: @javafx4you

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

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

‒ 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

Danke!

[email protected]

Twitter: @wolflook

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