javafx on desktop, mobile, and embedded - oracle · javafx on desktop, mobile, and embedded stephen...
TRANSCRIPT
JavaFX on Desktop, Mobile, and EmbeddedStephen Chin (@steveonjava)Lead Java Community ManagerJavaOne Community Chair
Java Community Management
314 Java User Groups 9M+ Java
Developers
150+ 150+ Java Champions
50+ JUG groups contributing to JCP
2
Community
• Cross-platform Animation, Video, Charting
• Integrate Java, JavaScript, and HTML5 in the same application
• New graphics stack takes advantage of hardware acceleration for 2D and 3D applications
• Bidirectional integration with Swing applications using JFXPanel and SwingNode
Immersive Application Experience
JavaFX Platform
Architecture of JavaFX
Java Virtual Machine
Java2D Open GL D3D
Prism GlassWinTk
MediaEngine
WebEngine
JavaFX Public API
Quantum Toolkit
New Features in JavaFX 8
DatePicker
• Allows selection of dates and ranges
• Can use custom formats and calendars
• Supports Cascading Style Sheets
TreeTableView
• Combines a TreeView and a TableView
• Optional menu for hiding and showing columns
• Root can be hidden• Supports multiple selection• Supports CSS
New Modena UI Theme
HTML5 Features
• Canvas and SVG• Media playback• Form controls• History maintenance• Interactive element tags• DOM• Web workers*• Web sockets*• Web fonts*
* = new in HTML5
Build Applications VisuallyGluon Scene Builder 8
JAVAFX 3D
Mesh Geometry (3D Shapes)
■ Predefined shapes■ Box■ Cylinder■ Sphere
■ User-defined shapes■ Using TriangleMesh / MeshView
13
https://wikis.oracle.com/display/OpenJDK/SphereAndBox.java
UV Mapping Textures to Shapes
14
Tip: A texture is a 2D image to be mapped on a 3D surface
Source: http://en.wikipedia.org/wiki/File:UVMapping.png
3D Lights
■ Lights are nodes in the scene graph■ PointLight■ AmbientLight
■ Default light provided if no active lights
15
https://wikis.oracle.com/display/OpenJDK/3D+Features
JDK 8 Update Releases
16
JDK 8u40• Released in March 2015• Added a number of important missing features:
– Accessibility (Windows and Mac)– New Controls
• Spinner• Filtered Text• Dialogs (Alerts, TextInputDialog, ChoiceDialog)
– LCD Text on Canvas– 3D User-Defined Normals
• Several bugs fixed in controls, charts, layout, etc.
17
Accessibility• A full-featured minimal API and implementation• Supports native accessibility (VoiceOver, Narrator)• All built-in controls and charts are accessible• Developers can make their own controls accessible
18
Dialogs• Finally built-in to JavaFX!• Simple Alert API for prompting users• More advanced Dialog / DialogPane for
total customization• OS-specific button ordering
19
JDK 8u60• Released in August 2015• Focus was on bug fixing and stabilization of the platform• Small number of new features:
– Updated to newer version of WebKit– Added minimal High-DPI support on Windows
• Enabled by default when Windows UI scale is >= 150%• No API added to provide application control (stay tuned)
20
Coming up in JavaFX for JDK 9
21
Jigsaw Modularity• Jigsaw Modularity is the primary feature for JDK 9
– JEP 200: The Modular JDK (Umbrella)• JEP 201: Modular Source Code• JEP 220: Modular Run-Time Images• JEP 260: Encapsulate Most Internal APIs• JEP 261: Module System
• Modularizing JavaFX is our main goal for JDK 9!– JDK-8092093: Modularization support for JavaFX (Umbrella)
Jigsaw Modularity: JavaFX Modules• JavaFX module graph for runtime (JRE) modules:
23
javafx.graphics
javafx.controls
javafx.base
javafx.mediajavafx.fxml javafx.swing
javafx.web
JEP 253• JDK 9 with Jigsaw modularity is a big game changer:
– Up until JDK 9, developers could (ab)use API in com.sun.* packages.– JDK 9 enforces boundaries - com.sun.* becomes unavailable at compile time
• Many (if not most) JavaFX apps and libraries will fail to compile / execute under JDK 9.
• We asked the community for JDeps output• In summary:
– Almost all open source apps and most customer apps break!
JEP 253 :: Current Split
Control
Behavior
Skin
Private Implementation(com.sun.javafx.scene.control.*)
Public API(javafx.scene.control)
JEP 253 :: Future Split
Control
Behavior
Skin
Public API(javafx.scene.control) Private Implementation
(com.sun.javafx.scene.control.*)
JEP 253 :: Summary• Free side-effect of JEP 253:
– Move closer to providing a full API for third-party UI controls– This has been a feature we’ve been wanting for a very long time– We now have all controls and skins available as public API
– Next target is to make behaviors public API too• Outside scope of JDK 9
High DPI• In JDK 9 we will add:
– High-DPI support for Linux– API to set the render scale and the threshold for
enabling High-DPI– Support for “snap to pixel” even when using non-integer
render scale
Nested Event Loop• Sometimes an application wants to process events without returning from
the current flow of control• JavaFX internally uses nested event loops in some cases:
– Calling showAndWait on Stage or Dialog– For displaying printer dialogs
• New API on Platform:– public static Object enterNestedEventLoop(Object key);– public static void exitNestedEventLoop(Object key, Object rval);– public static boolean isNestedLoopRunning();
Pulse Listener• Some applications want a callback during the pulse for each frame
– Using AnimationTimer provides a similar capability, but runs before CSS and layout (and forces a continuous pulse)
• New API on Scene:– public final void addScenePulseListener(Runnable r);
• This will add a listener (Runnable) that is called every frame– Called after CSS and layout have been done– Called before rendering– Any changes to the scene graph will be rendered this frame, but will not have CSS or
layout applied until next frame
Platform Startup• New API on Platform:
– public static void startup(Runnable);
• Starts the JavaFX runtime and then calls the run method of the Runnable on the JavaFX Application Thread– The startup method returns before the Runnable is run
• Must not be called if the JavaFX runtime has already been started– Cannot be used to restart the JavaFX runtime after it has terminated
Other JDK 9 Enhancements• JEP 257: Update to Newer Version of GStreamer
– Requires newer version of GLIB so some older Linux distroswill no longer work
• Updated Version of WebKit– We will do this at least one time in JDK 9, and maybe twice– Goal: pick up bug fixes and performance improvements in a more timely fashion
JavaFX on Mobile and Embedded
JavaFX on iOS/Androidhttp://gluonhq.com
Gluon: Technology Stack
35
Gluon Mobile
Gluon Cloud
Open Source Efforthttps://bitbucket.org/javafxports/android/wiki/Home
2048 Game in the Play Storehttp://jperedadnr.blogspot.com.es/2015/03/javafx-on-mobile-dream-come-true.html
=
Have Java With Your DessertRaspberry Pi
http://elinux.org/File:Raspi-Model-AB-Mono-2-699x1024.png
Embedded Controls Theme
Virtual Keyboard
42
Raspberry Pi with Java
43
raspberrypiwithjava.com
Stephen Chintweet: @steveonjavablog: http://steveonjava.com
nighthacking.com
Real GeeksLive Hacking
NightHacking Tour
Safe Harbor StatementThe 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.
45