Presentation is loading. Please wait.

Presentation is loading. Please wait.

JavaFX 8: New and Noteworthy Steve Northover (Client Architect) Kevin Rushforth (Consulting Member of Technical Staff) Java Client Platform Sept, 2014.

Similar presentations


Presentation on theme: "JavaFX 8: New and Noteworthy Steve Northover (Client Architect) Kevin Rushforth (Consulting Member of Technical Staff) Java Client Platform Sept, 2014."— Presentation transcript:

1 JavaFX 8: New and Noteworthy Steve Northover (Client Architect) Kevin Rushforth (Consulting Member of Technical Staff) Java Client Platform Sept, 2014 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

2 Safe Harbor Statement 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.

3 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Program Agenda Brief History / Overview of JavaFX JavaFX 8 and 8u20: Here Today JavaFX 8u40: Coming Soon JavaFX 9: Coming Not So Soon Conclusion / Summary

4 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. History Dec 2008:JavaFX 1.0 (FX script, closed source) April 2010:JavaFX 1.3 (Controls, charts, css) Oct 2011:JavaFX 2.0 (Windows, FX reboot) Dec 2011:OpenJFX (First component open sourced) April 2012:JavaFX 2.1 (Port to Mac, co-bundled) Aug 2012:JavaFX 2.2 (Linux, canvas, new controls) Oct 2013:OpenJFX (Last component open sourced) Mar 2014:JavaFX 8.0 (Part of the Oracle JDK)

5 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Overview / Features Data Binding FXML (declarative markup) CSS Graphics Controls Drag and Drop / Clipboard Tasks Layout Media Browser Charts Swing and SWT Integration

6 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. JavaFX 8 and 8u20: Here Today 3D Support (*) Printing Complex Text (BIDI, TextFlow) (*) Component Orientation (RTL, Mirroring) (*) Modena (New theme for FX8) New Controls (DatePicker, TreeTableView) SwingNode (Embed Swing in FX) (*)

7 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. JavaFX 8 and 8u20: Here Today New Build System (based on gradle, IDE support) Native Font Rasterizer (Windows, Mac, Linux) (*) HTML5 Improvements (local storage etc.) HDPI Support (Retina displays) GPU Acceleration on Linux CSS Improvements (public API) (*) On Top Stages

8 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 3D Support in FX 8 Shape3D Lights Movable camera SubScene Scene antialiasing Sample loaders to load 3D models

9 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Shape3D Node 3D geometry – Predefined shapes Box, Cylinder, Sphere – User-defined shapes MeshView Material: – Defines rendering appearance – Texture mapping, bump mapping, etc.

10 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Shape3D: MeshView Geometry – A set of positions – A set of texture coordinates – A set of faces (triangles) that describe the topology Smoothing group – Used to group triangles that are part of same curved surface – Hard edges between triangles in different smoothing groups Sharable among multiple MeshView nodes

11 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 3D Attributes: PhongMaterial Defines the rendering appearance: – Diffuse color, diffuse map – Specular color, specular map – Specular power – Bump map (normal map) – Self-illumination map Sharable among multiple Shape3D nodes

12 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 3D Lights Defined as nodes in the scene graph Scene contains a set of active lights – Default light provided when the set is empty Each light has a set of affected nodes (scope) – If a Parent is in the set, all children are affected – Default is root node of Scene Each Shape3D affected by up to 3 lights (at present)

13 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Movable Camera Camera is now a Node – Add to scene graph to move the camera – Position and aim camera using transforms – Use “fixed eye” mode for 3D scenes – Non-moving camera need not be added to scene graph New properties for near & far clipping plane

14 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. SubScene Renders a subset of the scene with: – Different camera – Different scene attributes (depth test, antialiasing) Used to separate 2D and 3D content Overlay or “heads-up” display: – Example: UI controls in a scene with a moving camera

15 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Loading 3D Models Many 3D file formats exist, such as: – Obj, Maya, 3D Studio Max, Collada Sample code available for some of these – Included in 3DViewer sample Community can also write loaders Demo?

16 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Complex Text (BIDI, TextNode) Text node correctly renders BIDI strings – Supports the BIDI algorithm, control characters, ligatures etc. TextFlow – A subclass of Pane that positions Text and Node children – Supports text wrapping, BIDI reordering, contextual shaping – Not the same as a FlowPane (think “RichTextEditor output only”)

17 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Create Text Nodes: Use a TextFlow … Text text1 = new Text("JavaFX"); text1.getStyleClass().add("bold"); Text text2 = new Text(" is a "); Text text3 = new Text("software platform"); text3.getStyleClass().add("link"); text3.addEventFilter(MouseEvent.MOUSE_CLICKED, this); Text text4 = new Text(" for creating and delivering "); Text text5 = new Text("rich internet applications (RIAs)"); text5.getStyleClass().add("link"); text5.addEventFilter(MouseEvent.MOUSE_CLICKED, this); Text text6 = new Text(" that can run across a wide variety of devices."); TextFlow textFlow = new TextFlow(text1, text2, text3, text4, text5, text6); textFlow.getStyleClass().add("textFlow"); …

18 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Use CSS to Style Text: Bold or Links.bold { -fx-font-weight: bold; }.link { -fx-fill: royalblue; -fx-underline: true; -fx-cursor: hand; }.textFlow { -fx-font-family: "Helvetica"; -fx-font-size: 18px; -fx-padding: 6px; -fx-border-color: royalblue; -fx-border-radius: 4px; -fx-border-insets: 6px; }

19 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. TextFlow versus FlowPane Text nodes are positioned and wrapped correctly in the TextFlow

20 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Component Orientation (RTL, Mirroring) Every Node has an orientation – (LTR) Left-to-right, (RTL) Right-to-left, (INHERIT) inherit – The default orientation for Scene and most Nodes is INHERT – Applications set node orientation to change the layout Every Node has an effective orientation – The effective orientation of a node is computed based on INHERIT – The effective orientation is either LRT or RTL (never INHERIT) – Applications cannot set the effective orientation – Nodes draw using this orientation

21 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Node Orientation public enum NodeOrientation { /** Indicates that the node draws from left-to-right */ LEFT_TO_RIGHT, /** Indicates that the node draws from right-to-left */ RIGHT_TO_LEFT, /** Indicates that the node inherits orientation from the parent */ INHERIT }

22 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Node Orientation API Node.setNodeOrientation() Node.getNodeOrientation() Node.nodeOrienationProperty() Node.getEffectiveNodeOrientation() Node.effectiveNodeOrientationProperty() Scene.setNodeOrientation() Scene.getNodeOrientation() Scene.nodeOrienationProperty() Scene.getEffectiveNodeOrientation() Scene.effectiveNodeOrientationProperty() -Djavafx.scene.nodeOrientation.RTL=true

23 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. A Simple Application: Default Orientation

24 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. The Same Application: RIGHT_TO_LEFT

25 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. The Node Orientation set with a Property static { String lang = Locale.getDefault().getLanguage(); if (lang == "ar" || lang == "iw" || lang == "fa" || lang == "ur") { System.setProperty("javafx.scene.nodeOrientation.RTL", "true"); System.out.println("Application set to RTL"); } Different strings are loaded from a resource bundle but there are no other code changes.

26 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Mirroring: An Implementation of Node Orientation (0,0) 0... N (0,0) N … 0 Left to RightRight to Left

27 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Advantages of Mirroring Applications are written for the default orientation (LTR) Almost no code changes required to work in RTL orientation – Need to handle a few “hard left” and “hard right” concepts – For example, left arrow must traverse always traverse to the left – Traversal is handled correctly by FX (but the application look for arrow keys) No special API concepts such as LEAD or TRAILING required

28 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. SwingNode SwingNode is a regular JavaFX node Multiple SwingNode supported in a single application Overrides event handlers and forwards to AWT/Swing Performance is comparable to stand alone AWT/Swing Supports accelerated painting, drag and drop, etc.

29 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. SwingNode: A Complete Example public void start(Stage stage) { SwingNode swingNode = new SwingNode(); SwingUtilities.invokeLater(() -> { swingNode.setContent(new JButton("Click me!")); }); StackPane pane = new StackPane(); pane.getChildren().add(swingNode); stage.setScene(new Scene(pane, 100, 50)); stage.show(); } Oracle Confidential – Internal/Restricted/Highly Restricted29

30 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. CSS Improvements CSS Public API – javafx.css package – Create styleable properties – Manage pseudo-class support (load a support (to import another style sheet) setUserAgentStylesheet on Scene and SubScene

31 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Native Font Rasterizer FX 2.x used custom T2K font rasterizer – Same rasterizer that is used in the JDK FX 8.0 uses native font rasterizer on: – Windows: DirectWrite – Mac: Core Text FX 8u20 uses native font rasterizer on: – Linux: Freetype + Pango

32 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Native Font Rasterizer T2KMac (CoreText)

33 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. JavaFX 8u40: Coming Soon

34 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. JavaFX 8u40: Coming Soon Accessibility (Windows and Mac) New Controls – Spinner – Filtered Text – Dialogs (Alerts, TextInputDialog, ChoiceDialog) LCD Text on Canvas (highly requested) 3D User-Defined Normals Early Access builds are available at https://jdk8.java.net/download.html

35 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 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

36 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. The Fundamental Accessibility API A simple set of properties to solve the most common cases Node#accessibleRoleProperty() Node#accessibleRoleDescriptionProperty() Node#accessibleTextProperty() Node#accessibleHelpProperty() Label#labelForProperty() (not a new property)

37 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Making a Bouncing Ball Accessible … ball.setAccessibleRole(AccessibleRole.BUTTON); ball.setAccessibleRoleDescription("Bouncing Ball"); ball.setAccessibleText(text); ball.setAccessibleHelp("This is bouncing ball, use the primary action to start animation"); …

38 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. VoiceOver on a TableView

39 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. New Controls Spinner control has been missing for a long time Applications need the ability to filter and format text fields Applications need to use standard dialogs to interact with the user – Alert – TextInputDialog – ChoiceDialog Applications need to create their own dialogs

40 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Spinner Single line text field with up/down arrows Values are one of: – Range of numbers (int or double) – Observable list of items Select value or list item from a sequence Field can be editable or not

41 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Filtered Text TextInputControl has new TextFormatter property – Restricts and format the text that can be displayed and typed TextFormatter has one or both of: – Filter -- intercepts and can modify or reject text changes – ValueConverter -- A StringConverter that converts between the values and text – Several predefined converters in javafx.util.converter package

42 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Using a Filter to Limit Text Length A text filter is a lambda that returns the Change argument (or null) API on Change is used to get and set the new edit state (text, caret etc.) // Simple filter to limit text to 4 characters or less TextFormatter formatter1 = new TextFormatter<>(c -> c.getControlNewText().length() > 4 ? null : c); textField1.setTextFormatter(formatter1);

43 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Using a Value Converter to Convert to a Number A value converter is a standard JavaFX Converter Use TextFormatter.getValue() to get the converted value // Simple number converter NumberStringConverter valConv = new NumberStringConverter(); TextFormatter formatter2 = new TextFormatter<>(valConv); textField2.setTextFormatter(formatter2);

44 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Dialogs Framework for modal and non-modal dialogs Base Dialog class provides common dialog capability – Three preconfigured Dialog subclasses – Define your own custom dialog if needed Properties – DialogPane (content) – Modality (used to disable other windows) – Owner window – Blocking (showAndWait) and non-blocking (show) methods

45 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Predefined Dialogs Alert – Standard information and confirmation dialogs – Specify list of ButtonTypes (optional) Example: Alert alert = new Alert(AlertType.CONFIRMATION); ButtonType result = alert.showAndWait().get(); if (result == ButtonType.OK) { // Do something... }

46 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Predefined Dialogs ChoiceDialog – Item selection via a combo-box – Confirm with OK/Cancel buttons Example: ArrayList list = … ChoiceDialog dlg = new ChoiceDialog<>(list.get(0), list); dlg.showAndWait().ifPresent(val -> { System.out.println("Selected: " + val); });

47 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Predefined Dialogs TextInputDialog – Enter data in a TextField – Confirm with OK/Cancel buttons Example: TextInputDialog dlg = new TextInputDialog("Jonathan"); dlg.showAndWait().ifPresent(name -> { System.out.println("Your name is: " + name); });

48 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. LCD Text on Canvas Canvas has immediate-mode drawString API 8u40 adds “LCD” font-smoothing mode – setFontSmoothingType(FontSmoothingType.LCD); Only takes effect on opaque background – Use fillRect(0, 0, w, h) with an opaque color

49 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 3D User-Defined Normals TriangleMesh now has per-vertex surface normals Can be used as an alternative to smoothing group – More efficient in most cases – More convenient if you already have vertex normals – Many loaders include vertex normals

50 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. JavaFX 9: Coming Not So Soon

51 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. JavaFX 9: Coming Not So Soon JDK9 Modularity (Jigsaw) RichTextEditor (?) Image Writing (?) … But we need help. The focus for 9 is bug fixing and performance.

52 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Conclusion / Summary

53 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Conclusion / Summary JavaFX is a full featured UI toolkit Significant functionality has been added in each release – 3D support, printing, BIDI, accessibility, … Comprehensive and complete applications are possible – Significant functionality over AWT/Swing is built into the toolkit Very few gaps remain between FX and AWT/Swing

54 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Safe Harbor Statement 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.

55


Download ppt "JavaFX 8: New and Noteworthy Steve Northover (Client Architect) Kevin Rushforth (Consulting Member of Technical Staff) Java Client Platform Sept, 2014."

Similar presentations


Ads by Google