doag 2013 entwicklung mit javafx
TRANSCRIPT
DOAG 2013 Nürnberg
1 Copyright © 2013 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 © 2013 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 © 2013 Oracle and/or its affiliates. All rights reserved.
und mit Java Entwicklungswerkzeugen
• JavaFX Scene Builder
• Open Source Projekt OpenJFX
• Kundenbeispiele
• Zusammenfassung
JavaFX is the Evolution of Java as a Rich Client Platform
It is designed to provide a modern Java environment designed to provide a lightweight, hardware accelerated UI platform that meets tomorrow’s needs
4 Copyright © 2013 Oracle and/or its affiliates. All rights reserved.
Wo sich JavaFX in die Java Plattform einfügt
ServersServersServersServers DesktopDesktopDesktopDesktop EmbeddedEmbeddedEmbeddedEmbedded TVTVTVTV MobileMobileMobileMobile CardCardCardCard
BD-J
5 Copyright © 2013 Oracle and/or its affiliates. All rights reserved.
Java Card
Java EE Java TV
BD-J
JavaFX MSA
Java Language
Java SE Java ME
Key APIs
Platform
Language
Java Platform
Existierende JavaFX Produkt Releases• JavaFX 2 Platform
– General Availability for Windows (since October 2011)
– JavaFX 2.2.45 for Windows, Mac and Linux and co-bundled with JDK 7u45
– JDK 7u45 includes JavaFX SDK for Linux ARM v6/v7
• Oracle JDK 8 (with JavaFX) for ARM Early Access
• Development Tools
6 Copyright © 2013 Oracle and/or its affiliates. All rights reserved.
• Development Tools
– NetBeans 7.4
– JavaFX Scene Builder 1.1 GA
– e(fx)clipse
• major release cycle alignment with eclipse roadmap
• minor release cycle with JavaFX roadmap
JavaFX Runtime Architektur
7 Copyright © 2013 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
8 Copyright © 2013 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
9 Copyright © 2013 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
10 Copyright © 2013 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
11 Copyright © 2013 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
12 Copyright © 2013 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();
13 Copyright © 2013 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);
14 Copyright © 2013 Oracle and/or its affiliates. All rights reserved.
javax.swing.JComponent
javafx.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
15 Copyright © 2013 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
16 Copyright © 2013 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 FXML
Java 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
17 Copyright © 2013 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 Media
Media
• 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
18 Copyright © 2013 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
20 Copyright © 2013 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
21 Copyright © 2013 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
22 Copyright © 2013 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
23 Copyright © 2013 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
25 Copyright © 2013 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
26 Copyright © 2013 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)
27 Copyright © 2013 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
28 Copyright © 2013 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); }
}Note: Example is for illustration and not syntactically accurate
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
29 Copyright © 2013 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
30 Copyright © 2013 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 3 IDE and XDEV Application Framework XAPI
Funktionale Systemtests für JavaFXAutomatisiertes Testen für JavaFX UI Controls
31 Copyright © 2013 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 voraussichtlich parallel zu Java 8
32 Copyright © 2013 Oracle and/or its affiliates. All rights reserved.
• Vorabversionen auf Anfrage
Java Swing
Eclipse/SWT
Web
JavaFX Scene Builder
33 Copyright © 2013 Oracle and/or its affiliates. All rights reserved.
http://otn.oracle.com/java/javafx
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
34 Copyright © 2013 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
35 Copyright © 2013 Oracle and/or its affiliates. All rights reserved.
OpenJFX•UI Controls•Scenegraph•JemmyFX
JavaFX via Open Source auf dem Weg ins JDK 8
Open Source
�OpenJFX Project under
OpenJDK�
�
Konvergenz
�Common license with
Java SE (in place)�
�
Standardisierung
�Oracle committed to
JavaFX standardization
36 Copyright © 2013 Oracle and/or its affiliates. All rights reserved.
�First phase to focus on
UI Controls� �JavaFX to be included
in Java SE by JDK 8
�JavaFX for Java SE
Embedded (ARM)
� �JSR to be submitted
through JCP
�
OpenJFX Projekt
• OpenJFX is the open source home of JavaFX development
• Goal of OpenJFX is to build the next-generation Java client toolkit
• Project OpenJFX intends to file a JSR in Java SE 9 timeframe and be part of the JDK
• 2011 the JavaFX toolkit was completely rewritten in Java and released by Oracle as JavaFX 2.0
• Oracle announced that it would donate the JavaFX toolkit to the open source community
37 Copyright © 2013 Oracle and/or its affiliates. All rights reserved.
• Oracle announced that it would donate the JavaFX toolkit to the open source community
and by November 2011 the OpenJDK Community had agreed to take it on
• Project OpenJFX is currently focused on absorbing the existing code base from Oracle
and building a functioning community around it
• Oracle's code will be donated in phases with the initial piece being the UI Controls classes
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
38 Copyright © 2013 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
39 Copyright © 2013 Oracle and/or its affiliates. All rights reserved.
• Advanced Tooling
• Support for Modern Device Interactions
• Delivering on the Cross Platform Promise
JavaFX Update und Roadmap
Dez 2011 Jan 2013 Apr 2013 Aug 2013
Linux/ARM Dev Preview
OpenJFX Project created
Linux Developer Preview
JavaFX 2.1 fürMac OS X
JavaFX 2.2 fürLinux
Scene Builder 1.0
NetBeans 7.2 mit
2013 2014
JavaFX 8
• Included in JDK 8
• Concurrent OS support: Windows, Mac OS, Linux, ARM
40 Copyright © 2013 Oracle and/or its affiliates. All rights reserved.
Linux/ARM Dev Preview
Scene Builder Linux Developer Preview
NetBeans 7.2 mitJavaFX 2.1 und
Scene Builder Integration
NetBeans.next• Java SE 8 support
• JavaFX 8 support
• more
JavaFX Anwendungen
� HealthConnect is a Belgian company with deep expertise in integration architectures, software
development, eHealth integration and project management in the health sector. Based on the broad
experience and expertise of its people, HealthConnect provides services to healthcare practitioners,
healthcare institutions, mutual insurance organisations and governments. The health sector is our only
focus and therefore our customer’s guarantee for added value. HealthConnect has been launched in
2010. After two year, it counts 35 employees (in Belgium and India)
� Deep Analytics of Big Data
• Create highly advanced analysis fast and cost efficient
• End-User Programming in Java, Scala and R
• Access to thousands of analytical algorithms, methods and tools
42 Copyright © 2013 Oracle and/or its affiliates. All rights reserved.
• Access to thousands of analytical algorithms, methods and tools
• Oracle Java Magazine: “Java Powers Analytical Breakthroughs at QuantCell Research”
• Java Analytical Models and Big Data: End User Programming in Spreadsheets. How to use
JavaFX to build an end user environment supporting rich visualization and big data analytics
� Container Terminal Operations
• General Cargo Terminal Operations
• Intermodal Rail Operations
• Shipping Line Operations
• Yard Management
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
43 Copyright © 2013 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
44 Copyright © 2013 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
� JavaFX als strategische UI für Rich-Client-Applikationen
� Einheitliche Applikationsentwicklung für Java und Web-Lösungen• Browser Plug-in, Web Start, Native Executables
• Hardware Accelerated Graphics (DirectX, OpenGL)
• JavaFX wird mit HTML-DOM ausgestattet
− JavaFX mit WebView für HTML5 Features (Web Sockets, offline Browsing, lokale Datenbank)
− Leistungsfähige JavaScript Engine
− JavaFX als Applet eingebettet in einer Web-Seite lauffähig
Zusammenfassung
45 Copyright © 2013 Oracle and/or its affiliates. All rights reserved.
� JavaFX 2.0 Plattform Sprachwechsel
• Java als native Sprache - anstatt JavaFX Script
• JavaFX APIs in Java implementiert
• Vorteile bei Verwendung von Generics, Annotations und Multithreading für JavaFX
� JavaFX 2.2.45 verfügbar und mit NetBeans 7.4 unterstützt• Migrationspfad für Swing- und SWT-basierte Anwendungen
• JFXPanel Komponente ermöglicht das Einbinden von JavaFX Anwendungen in Swing
• Open Source mit OpenJFX und im JCP standardisiert
� JavaFX Scene Builder 1.1 GA
Vielen Dank für Ihre Aufmerksamkeit!
46 Copyright © 2013 Oracle and/or its affiliates. All rights reserved.