
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 Java 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, Linux, 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 <BorderPane> <center> <Label text=”%helloworld"/>
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages40 Page
-
File Size-