gerrit grunwald
play

Gerrit Grunwald canoo Engineering AG blog: harmonic-code.org - PowerPoint PPT Presentation

Gerrit Grunwald canoo Engineering AG blog: harmonic-code.org Twitter: @hansolo_ A genda history controls New plugin css scene graph WebView Java API JFXPanel properties charts


  1. Gerrit Grunwald canoo ¡Engineering ¡AG blog: harmonic-code.org Twitter: @hansolo_

  2. A genda history controls ✴ ✴ New plugin css ✴ ✴ scene graph WebView ✴ ✴ Java API JFXPanel ✴ ✴ properties charts ✴ ✴ Bindings fxml ✴ ✴

  3. S ome History

  4. R oadmap

  5. W hat Java FX r eally is ...

  6. I t is the successo r to Java Swing

  7. and it ' s still not finished

  8. Av aila b le f o r ✴ Windows ✴ Mac os x ✴ Linux ✴ ARM (preview)

  9. V e r sions ✴ JavaFX 2.2 Bundled with jdk >Java 7u6 ✴ Standalone for Java6

  10. Te a r chitectu r e

  11. Te a r chitectu r e Prism processes the rendering jobs.

  12. Te a r chitectu r e OpenGL on Mac, Linux, Embedded

  13. Te a r chitectu r e DirectX 9 on Windows XP , Vista DirectX 11 on Windows 7

  14. Te a r chitectu r e Java2D when hardware acceleration is not possible

  15. Te a r chitectu r e Provides low level native operating system services

  16. Te a r chitectu r e Ties Prism and Glass Windowing Toolkit together and makes them available to the JavaFX layer above

  17. Te a r chitectu r e

  18. O pen S ou r ce ✴ JavaFX source code is part of the Open JFX project http:/ /openjdk.java.net/projects/openjfx/ n e p o y l e 3 t 1 e 0 l p 2 m / 2 o 0 c d n u o r a e c r u o s

  19. A gain a ne w plugin

  20. Br o w se r P lugin ✴ Faster loading of JavaFX web apps based on prism ✴ pre-loader for improved user experience

  21. Te scene graph

  22. S cene Gr aph root branch leaf

  23. S cene Gr aph ✴ Handles the UI ✴ tree structure ✴ one root node ✴ Branch + leaf nodes

  24. R oot N ode ✴ The Only node without a parent node

  25. Br anch N odes ✴ are derived from javafx.scene.Parent ✴ can contain other nodes

  26. L ea f N odes ✴ Shapes ✴ Media ✴ Images ✴ Controls ✴ Text ✴ Charts ✴ WebView

  27. L ea f N odes ✴ Have no getChildren()

  28. S cene Gr aph ✴ root node is a stackpane ✴ stage is container for root ✴ alive...no dead bitmaps

  29. A tyical app public class SceneGraphStructure extends Application { @Override public void start(Stage stage) { stage.setTitle(„Hello World“); Button button = new Button("Say 'Hello World‘“); button.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent evt) { System.out.println("Hello World"); } }); StackPane root = new StackPane(); root.getChildren().add(button); stage.setScene(new Scene(root, 300, 250)); stage.show(); S cene Gr aph } public static void main(String[] args) { sta r t J a v a F x application launch (args); } }

  30. L ayout classes Node (abstract) Parent (abstract) Group Region Control (abstract) non- resizable resizable + CSS stylable resizable, skinnable + CSS stylable Pane TabPane TitledPane SplitPane Accordian ToolBar StackPane HBox VBox TilePane FlowPane AnchorPane BorderPane GridPane

  31. Te Java A pi

  32. J a v a F x S c r ipt is not DEAD

  33. I t li v es on as Visage

  34. N o w w e ha v e pure Java

  35. S ome examples

  36. C ode eamples // Java FX 1.x // Java FX 2.x public def timer = Timeline { private Timeline timer = repeatCount: Timeline.INDEFINITE TimelineBuilder.create() keyframes: KeyFrame { .cycleCount(Timeline.INDEFINITE) time: 1s .keyFrames( action: function() {...} new KeyFrame(Duration.seconds(1), }} new EventHandler() {...} )) .build();

  37. C ode eamples // Java FX 1.x // Java FX 2.x view = ImageView { view = new ImageView(image); image:image view.translateXProperty().bind( translateX:bind x + (view.scaleX - 1) x.add(view.getScaleX() - 1)); translateY:bind y + (view.scaleY - 1) view.translateYProperty().bind( }; y.add(view.getScaleY() - 1));

  38. Pr ope r ties and bindings

  39. Pr ope r ties // Property string private static final String VALUE_PROPERTY = "value"; J a v a Sw ing // A double property double value; // The getter method public double getValue() { return value; } // The setter method public void setValue(double newValue) { double oldValue = value; value = newValue; firePropertyChange(VALUE_PROPERTY, oldValue, value); }

  40. Pr ope r ties // A double property DoubleProperty value; J a v a F x // The getter method public double getValue() { return value.get(); } // The setter method public void setValue(double newValue) { value.set(newValue); } // The property method public DoubleProperty valueProperty() { return value; }

  41. B indings ✴ High-level binding ✴ fluent api ✴ bindings class ✴ low-level binding

  42. B indings ✴ unidirectional binding bind(); ✴ bidirectional binding bindBidirectional();

  43. H igh -L e v el IntegerProperty number1 = new SimpleIntegerProperty(1); IntegerProperty number2 = new SimpleIntegerProperty(2); DoubleProperty number3 = new SimpleDoubleProperty(0.5); // High-Level Binding (Fluent API) NumberBinding sum = number1.add(number2); NumberBinding result = number1.add(number2).multiply(number3); // High-Level Binding (Binding class) NumberBinding result = Bindings. add (number1, number2); NumberBinding result = Bindings. add (number1, multiply(number2, number3));

  44. H igh -L e v el ✴ Fluent api is selfexplaining ✴ more readable code ✴ might be a bit slower

  45. L o w-L e v el IntegerProperty number1 = new SimpleIntegerProperty(1); IntegerProperty number2 = new SimpleIntegerProperty(2); DoubleProperty number3 = new SimpleDoubleProperty(0.5); // Low-Level Binding DoubleBinding db = new DoubleBinding() { { super.bind(number1, number2, number3); } @Override protected double computeValue() { return (number1.get() + number2.get() * number3.get()); } }

  46. L o w-L e v el ✴ Overrides a binding class ✴ is more flexible ✴ could be faster

  47. J a v a F x controls

  48. S ome examples

  49. C ont r ol st r uctu r e ✴ Control ✴ Skin ✴ Behavior ✴ css

  50. C ont r ol B eha v io r CSS S kin

  51. S tyling w ith css

  52. R emem b e r Look + Feels in Sw ing ?

  53. F o r get them ...

  54. U sing CSS ✴ One default css caspian.css for root and controls ✴ JavaFX css is based on w3C CSS 2.1 + some additions

  55. U sing CSS ✴ either override the defaults to style your app ✴ or apply your own css file

  56. Te C aspian . css .root { -fx-base : #d0d0d0; -fx-background : #f4f4f4; -fx-color : -fx-base; -fx-hover-base : ladder(-fx-base, derive(-fx-base, 20%) 20%, derive(-fx-base, 30%) 35%, derive(-fx-base, 40%) 50%); -fx-pressed-base: derive(-fx-base, -20%); -fx-focused-base: -fx-base; -fx-body-color : linear-gradient(to bottom, derive(-fx-color, 34%) 0%, derive(-fx-color, -18%) 100%); ...

  57. Te de f ault CSS .button { -fx-skin : "com.sun.javafx.scene.control.skin.ButtonSkin"; -fx-background-color : -fx-shadow-highlight-color, -fx-outer-border, -fx-inner-border, -fx-body-color; -fx-background-insets: 0 0 -1 0, 0, 1, 2; -fx-background-radius: 5, 5, 4, 3; -fx-padding : 0.166667em 0.833333em 0.25em 0.833333em; -fx-text-fill : -fx-text-base-color; -fx-alignment : CENTER; -fx-content-display : LEFT; }

  58. Te custom CSS .root { -fx-base: #252525; /* scene.getRoot().setStyle("-fx-base: #252525"); */ } .button { -fx-font-family : "Verdana"; -fx-font-size : 16px; -fx-background-radius: 9, 9, 8, 7; -fx-padding : 9px 16px 9px 16px; }

  59. A simple app

  60. C aspian S tyle r

  61. A pply some CSS Scene scene = new Scene(pane, Color. rgb (75, 75, 75)); scene.getStylesheets().add("file:///customStylesheet.css");

  62. .root { -fx-font-family : "Verdana"; -fx-font-size : 13.0px; -fx-base : #363636; -fx-background : #5C5C5C; -fx-focus-color : #FF001B; -fx-control-inner-background: #DCDCDC; -fx-inner-border : linear-gradient(to bottom, derive(-fx-color, 90.23825953613186%) 0%, derive(-fx-color, 17.136566353587632%) 100%); -fx-body-color : linear-gradient(to bottom, derive(-fx-color, 45.81081081081081%) 0%, derive(-fx-color, -9.603603603603602%) 100%); } .button { -fx-background-radius : 30, 30, 29, 28; -fx-padding : 7px 14px 7px 14px; } .label { -fx-padding : 7px 22px 7px 14px; } .label { -fx-padding : 7px 8px 7px 10px; } .text-field { -fx-padding : 7px 10px 7px 10px; } .label { -fx-text-fill : -fx-text-background-color; } .button { -fx-background-insets : 0 0 -1 0, 0, 3, 4; } .button:focused { -fx-background-insets : -1.4, 0, 3, 4; } .separator:horizontal .line { -fx-border-color : derive(-fx-background, -80%) transparent transparent transparent; }

  63. A simple app

  64. W e bV ie w and webengine

  65. Scene Group NODE NODE

  66. Scene webview WEBENGINE

  67. W e bV ie w ✴ extension of node ✴ encapsulates webengine ✴ incorporates html into the scene

  68. W e bE ngine ✴ provides webpage function ✴ supports user interaction ✴ enables dom access and js

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend