25. Example of JavaFX Application Stage { title: "circle" width: 240 height: 200 scene : { content : [ Circle { centerX: 50 centerY: 50 radius: 50 fill: Color.RED } ] } } Stage Scene content Circle Stage class defines the container window, size and title Scene class defines the content to be displayed in the window
37. Declaring Classes // This class extends a Java interface public class FooModel extends TableModel { ... } // This class defines two variables and a function public class Location { public var x:Number; public var y:Number; public function move(newX:Number, newY:Number):Void { x = newX; y = newY; } }
38. Basic JavaFXScript Class class HelloWorldNode extends CustomNode { public var text:String; public override function create() : Node { return Text { x: 10 , y: 50 font: Font { size: 50 } content: bind text } }; } Syntax is Java-like with shades of JavaScript
45. When the value of the variable changes , the code is executed
46. Similar to PropertyChangeListener //oldValue is optional var text on replace oldValue { println(“Old value = '{oldValue}'”); println(“New value = '{text}'”); } text = “Hello” //prints Old value = '' //prints New value = 'Hello'
48. JavaFX Stage Scene Stage is the top level container window Scene is a drawing surface container that holds the scene graph nodes. content holds JavaFX graphical elements which define the graphical content of the application.
49. JavaFX Scene Graph Programming Model (cont.) top level container window container that holds the scene graph nodes
110. Example – expanding Circle var cRadius; var circle: Circle = Circle { centerX: 300, centerY: 300 radius: bind cRadius fill: Color.LIGHTBLUE onMousePressed: function( e: MouseEvent ):Void { tRadius.playFromStart(); } } Stage { scene: Scene { content: [circle] } }
111. Example – Defining Key Frames var tRadius : Timeline = Timeline { keyFrames: [ KeyFrame { //start point time: 0s values: [ cRadius => 30 ] } KeyFrame { //end point time: 5s values: [ cRadius => 300 tween Inter polator.LINEAR ] } ] } movement from the beginning to the end states Interpolator calculates the states that occur between animation frames 0s 1s 2s 3s 4s 5s 6s Key value radius = 30 radius = 300 Keyframes How the value changes over time
113. Example – expanding Circle var cRadius:Number = 30; var tRadius :Timeline = Timeline { keyFrames: [ at(3s) { cRadius => 200 tween Interpolator.LINEAR} ] }; var circle: Circle = Circle { centerX: 300, centerY: 300 radius: bind cRadius fill: Color.LIGHTBLUE onMousePressed: function( e: MouseEvent ):Void { tRadius.playFromStart(); } }
114. Example – Animating an Object var x : Number=0; Timeline { keyFrames: [ at (7s) { x => 387.0 tween Interpolator.LINEAR} ] }.play(); Path{ ... translateX: bind x ...}
115. Demo: Building “Picture Display” Step by Step http://www.javapassion.com/handsonlabs/javafx_customnode/index.html
117. RESTful Catalog Service JavaFX client JAX-RS, JAXB, JPA DB Registration Application JAX-RS class JavaFX client JAXB class Entity Class ItemsConverter Item ItemsResource
119. RESTful Pet Catalog Web Service http://petstore/catalog/resources/items/ HTTP GET Response XML items <item> <imageurl>http://host/catalog/images/anthony.jpg</imageurl> <name>Friendly Cat</name> <price>307.10</price> <productid>feline01</productid> </item> Server Client Addressable Resources Web Container
134. Example of Creating a Media Player var video :Media = Media { source: "http://..." }; var player :MediaPlayer = MediaPlayer { media: video rate: 1.0 volume: 0.4 }; var view :MediaView = MediaView { mediaPlayer: player x:200 y:200 }; Stage { title: "Media Player" width: 700 height: 700 scene: Scene { content: [view] } } controls for playing media Display for MediaPlayer Media source
escribe and present your product(s)/product line/service(s), technology, solution at a mid to high-level. Avoid low-level technical details (reserve to Systems Engineering training if needed) What are the business/technology value propositions? What is your BU vision and strategy? What OEM specific programs / resources do you have? How does your product/solution fit into an overall Sun open source /solution/story? JavaFX is the, Java-based, rich client platform for building RIA applications and content across multiple platforms Messages Designed to enable consistent user experiences, from desktop to mobile device to set-top box to Blu-ray Disc _________________________________________________ Zoom in on the FX portion of the Markecture diagram with a cool visual effect As Rich talks about a portion of Java FX, the component name is the only thing on the screen, high contrast, big font If there are cool visuals for the component, sprinkle them in
Now here it is in JavaFX Script: Notice how both the frame's stage and the circle class use the same name for the background: fill. And if you want to get rid of the window's background you just set fill to null. It's consistent and easy. *that's* the value of creating a new API.
The public-read Access Modifier The public-read access modifier defines a variable that is publicly readable, but (by default) is writeable only from within the current script. To widen its write access, prepend either the package or protected modifier (i.e. package public-read or protected public-read). Doing so will set its write access to the package or protected level. The public-init Access Modifier The public-init access modifier defines a variable that can be publicly initialized by object literals in any package. Subsequent write access, however, is controlled in the same manner as public-read (the default is write access at the script-level, but prepending package or protected will widen the access accordingly). The value of this variable is always readable from any package.
Function An executable body of code that performs a particular task Function does not execute until it is invoked There are two levels of function: script level and object level Function can be a variable
Classes extend classes or interfaces Scope modifiers: public, protected, package Implicitly “script private” init { } and postinit { } blocks take place of Constructors Functions and variables declared outside a class are static Multiple classes may be defined in a single Script
Classes extend classes or interfaces Scope modifiers: public, protected, package Implicitly “script private” init { } and postinit { } blocks take place of Constructors Functions and variables declared outside a class are static Multiple classes may be defined in a single Script
A Sequence represents an ordered list of objects; the objects of a sequence are called items. JavaFX has “Sequences”, not arrays A Sequence is an immutable ordered list of non-null elements JavaFX supports sequence comprehensions Sequences can be “sliced” Sequences can optimize memory usage
bind is a way to tie the value of one variable to the value of an expression binding must be defined when the variable is initialized bindings are statically compiled bound variables cannot be set manually use bind with inverse for bidirectional binding
The MoveTo class indicates the start point for the shape, and the ArcTo class creates an arc segment. All segments are combined into a shape using the Path class which represents a simple shape, and enables basic construction of a geometric path. The Path class is helpful when you need to create your own shape that is different from the primitive graphic shapes available in the javafx.scene.shape package. The Path class extends the Node class and inherits all of its instance variables and functions. Note: The sweepFlag instance variable is set to true so that the arc be drawn clockwise, in a &quot;positive&quot; angle. If the arcs are drawn counterclockwise, they will not curve correctly.
The movement from the beginning to the end states, commonly called &quot;tweening,&quot; is specified with the tween operator. The Interpolator.LINEAR value means that movement will progress at a steady rate from the beginning position to the end position.