Entwicklung mit JavaFX - Source Talk Tage 2006

Werbung
Source Talk Tage Göttingen
29. August 2012
Entwicklung mit JavaFX
Wolfgang Weigend
Sen. Leitender Systemberater
Java Technologie und Architektur
1
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
Java als Vorreiter für Rich Client Applications
But developers had to learn multiple technologies
2
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
JavaFX vereinfacht Applikations-Entwicklung
Developers focus on Capabilities instead of Technologies
3
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
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 © 2012 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 Java Programmiersprache
und mit Java Entwicklungswerkzeugen
• Demo
• JavaFX Scene Builder 1.0
• Open Source Projekt OpenJFX
• Zusammenfassung
5
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
Wo sich JavaFX in the Java Platform einfügt
Servers
Desktop
Embedded
TV
Mobile
Card
BD-J
Key APIs
Platform
Java EE
JavaFX
Java SE
Language
Java TV
Java ME
Java Language
Java Platform
6
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
MSA
Java Card
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
7
Copyright © 2012 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
8
Copyright © 2012 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
9
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
JavaFX Architektur
• Graphics API
− Converts the scenegraph into
rendering calls
− Abstracts D3D, OpenGL, Java2D
behind a “Graphics” object
− Handles “dirty regions”, clipping, and
other optimizations
− Font support
• 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
10
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
− Rasterization
JavaFX Architektur
• Windowing API
− Windows
− Mac
− Linux
− Headless (not done)
• Provides basic OS services
− Drawing surface
− Input events
− Event queue
11
Copyright © 2012 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()
12
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
JavaFX mit JFXPanel Komponente in
Swing Anwendungen einbinden
public class Test {
Class JFXPanel
private static void initFX(JFXPanel fxPanel) {
// This method is invoked on JavaFX thread
// This java.lang.Object
method is invoked on Swing thread
JFrame frame = new JFrame("FX");
java.awt.Component Scene scene = createScene();
fxPanel.setScene(scene);
final JFXPanel fxPanel = new JFXPanel();
java.awt.Container
}
frame.add(fxPanel);
javax.swing.JComponent
frame.setVisible(true);
public static void main(String[] args) {
javafx.embed.swing.JFXPanel
private static void initAndShowGUI() {
SwingUtilities.invokeLater(new Runnable() {
Platform.runLater(new Runnable() {
@Override
@Override
public void run() {
public void run() {
initAndShowGUI();
initFX(fxPanel);
}
}
});
});
}
}
}
13
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
WebView und Swing Interoperabilität
WebView Component
• Embed Web content in
JavaFX applications
• HTML rendering based
on Webkit
• Hardware accelerated
rendering using PRISM
• DOM access and
manipulation
14
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
Swing and SWT Interop.
Browser Plug-In
• Embed JavaFX content
into existing Swing
applications
• Extend existing Swing
applications with new
JavaFX features such as
WebView and highperformance graphics
• Applies to SWT*
applications as well
• Faster loading of JavaFX
Web applications based
on Prism
• Pre-loader for improved
user experience with
JavaFX Web
applications
* 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
15
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
Existierende JavaFX Produkt Releases
• JavaFX 2 Platform
– General Availability for Windows (since October 2011)
– JavaFX 2.2 for Windows, Mac and Linux
– JavaFX 2.2 is now co-bundled with JDK 7u6 for Windows, Mac
and Linux
• Development Tools
– NetBeans 7.2 General Availability
– JavaFX Scene Builder 1.0
16
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
Ziele für 2012
Auf der JavaOne 2011 bereits angekündigt
Open Source
Konvergenz
Standardisierung
OpenJFX Project under Common license with
Oracle committed to
JavaFX standardization
First phase to focus on JavaFX to be included
JSR to be submitted
through JCP
OpenJDK
UI Controls
Java SE (in place)
in Java SE by JDK 8
JavaFX for Java SE
Embedded (ARM)
17
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
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
• 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)
18
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
FXML
• Scriptable, XML-based markup language
for defining UI
• Convenient alternative to developing UI
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
New Graphics Pipeline
Media
• New hardware accelerated graphics
pipeline (Prism)
• New windowing toolkit (Glass) for Prism
• 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
19
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
• Stable media framework based on
GStreamer
• H.264*, VP6; MP3, AAC* playback of
Web multimedia content
• Low latency audio
• Alpha Channel support for full
transparency to solid Pixel
• Performance improvements
• Full screen video
* Feature introduced since JavaFX 2.1
JavaFX UI Controls
–
–
–
–
–
–
–
–
–
–
–
20
Accordion
Button
CheckBox
ChoiceBox
Charts
ContextMenu
Hyperlink
HTMLEditor
Label
ListView
Menu / MenuItem
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
–
–
–
–
–
–
–
–
–
–
–
MenuBar
MenuButton
PasswordField
ProgressBar
ProgressIndicator
RadioButton
ScrollBar
ScrollPane
Separator
Slider
SplitMenuButton
–
–
–
–
–
–
–
–
–
–
SplitPane
TableView
TabPane
TextArea
TextField
TitledPane
ToggleButton
Tooltip
ToolBar
TreeView
Distribution und Support
• JavaFX Distribution
– JavaFX Runtime can be distributed with third party applications*
– Applies to JavaFX 2.0.2, 2.1, 2.2 and later
• JavaFX Platform Commercial Support
– JavaFX is now part of the Java SE technologies covered through
Oracle Premier Support
– Applies to JavaFX 2.0, 2.1, 2.2 and later
* As per the terms and conditions of the Binary Code License for Java SE Platform products
21
Copyright © 2012 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);
}
}
22
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
Hello World in JavaFX
Programming in FXML und Java
FXML
<BorderPane>
<center>
<Label text=”%helloworld"/>
</center>
</BorderPane>
Java
23
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); }
}
Note: Example is for illustration
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
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
Other Java IDE’s
• Source editor with syntactic highlighting,
code completion, refactoring etc.
• Full debugger and Profiler support
24
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
JavaFX Scene Builder 1.0
http://otn.oracle.com/java/javafx
25
Copyright © 2012 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
26
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
JavaFX Scene Builder 1.0
• JavaFX Scene Builder 1.0
• Build Information Version: 1.0-b50, Change-Set:
22db15834430
Date: 2012-08-07 16:35
• JavaFX Version 2.2.0-b21
Toolkit = QuantumToolkit
Pipeline = J2DPipeline
Hardware acceleration DISABLED
• Operating System: Windows XP, x86, 5.1
• Java Version 1.7.0_03, Oracle Corporation, 1.7.0_03-b05
27
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
JavaFX und Open Source
http://openjdk.java.net/projects/openjfx
OpenJFX
28
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
• UI Controls
• Scenegraph
• JemmyFX
• Functional Tests
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
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
29
Copyright © 2012 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 2012
• 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
30
Copyright © 2012 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
31
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
Die künftige Ausrichtung von JavaFX
Oracle’s Next Generation Java Client Solution
•
•
•
•
•
•
32
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
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
JavaFX Roadmap
JavaFX 2.0
JavaFX 2.1
JavaFX 2.1
JavaFX 3.0
• Windows GA
• Linux Dev. Preview
• Windows GA
• Included in JDK 8
• Concurrent OS support
(Windows, Mac OS, Linux)
• Mac OS X Dev. Preview
2011
• Mac OS X SDK GA
2013
2012
JavaFX 2.0.2
JavaFX 2.2
• JDK 7 co-install
• Mac OS X GA
2014
• Linux GA
JavaFX
Scene Builder EA
• Windows GA
Scene Builder GA
NetBeans 7.1
• JavaFX 2 Support
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
• Java SE 8 support
• JavaFX 3 support
• more
Scene Builder
• Mac & Windows
Dev. Preview
33
NetBeans.next
GA: General Availability
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
34
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
Mit JavaFX entwickeln
35
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
Zusammenfassung
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
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 verfügbar und mit NetBeans 7.2 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.0
36
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
Vielen Dank für Ihre Aufmerksamkeit!
[email protected]
37
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
The preceding 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.
38
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
Herunterladen