SlideShare uma empresa Scribd logo
1 de 79
Baixar para ler offline
JavaFX: Building RIA
Application


Sang Shin
javapassion.com
                       1
Topics
•   Things you can build with JavaFX
•   JavaFX script overview
•   Declarative GUI building
•   Scene graph
•   Animation
•   Media
•   Deployment
•   JavaFX Mobile
•   Web services



                                       2
Things You Can Build
with JavaFX
Demo:
JavaFX Sample Apps
  from javafx.com




                     4
JavaFX Script
Overview
Features of JavaFX Script
• Declarative, statically-typed scripting language
• Facilitates rapid GUI development
• Runs on Virtual Machine for the Java™ platform
• Deployment options same as Java programs
• Fully utilizes Java class libraries behind the scenes
• Cool, interesting language features for building
  RIA apps
  > Object literal, Sequence, Data binding, Animation,
    Media, etc.

                                                     6
Class Definition

• Address class definition: The Address class
  declares street, city, state, and zip fields all
  of type String
  class Address {
     var street: String;
     var city: String;
     var state: String;
     var zip: String;
  }
                                                     7
Object Literal – Creating object
• In the JavaFX Script programming language, an
  object instance can be created with an object
  literal (like in JavaScript, unlike in Java)
• Example: The first word (Address) specifies the
  type of object, class, that you are creating.
 Address {
   street: "1 Main Street"; // separated by semi colons
   city: "Santa Clara";
   state: "CA";
   zip: "95050";
 }

                                                          8
Nesting an Object inside Another Object
• Nesting Address object inside Customer
  object
 def customer = Customer {
    firstName: "John";
    lastName: "Doe";
    phoneNum: "(408) 555-1212";
    address: Address {
        street: "1 Main Street";
        city: "Santa Clara";
        state: "CA";
        zip: "95050";
    }
 }                                         9
Binding
• Cause and effect – responding to changes
• bind operator allows dynamic content to be
  expressed declaratively
• Dependency based evaluation of any
  expression
• Automated by the JavaFX runtime rather
  than manually wired by the programmer
• Eliminates the listener pattern


                                               10
Binding to a Simple Expression
var x = 0;

// Bind variable x to variable y. Whenever the value of x
changes,
// the value of variable y automatically changes as well.
var y = bind x + 10;

x = 1;
println("----y after x is changed to 1 = {y}"); // y now
equals 11

x = 47;
println("----y after x is changed to 47 = {y}"); // y now
equals 57

                                                            11
Using Declarative Syntax
(for Creating GUI)
Example of JavaFX Application
import   javafx.scene.paint.Color;
import   javafx.scene.Scene;
import   javafx.scene.shape.Circle;
import   javafx.stage.Stage;

Stage {
  title: "My circle"
  width: 100
  height: 100
  scene: Scene {
      content: [
         Circle {
            centerX: 50,
            centerY: 50
            radius: 40
            fill: Color.RED
         }
      ]
  }
}                                     13
Why Declarative Syntax for Building
GUI?
• Because the structure of declared objects in
  the code reflects the visual structure of the
  scene graph, and this enables you to
  understand and maintain the code easily.
• The order of elements you declare in the
  code matches the order in which they
  appear in the application.



                                                  14
Demo:
          Building “HelloWorld”
           JavaFX Application
http://www.javapassion.com/handsonlabs/javafx_lang/#Exercise_1




                                                             15
Scene Graph
What is Scene Graph?
• Scene Graph enables declarative GUI programming
• The scene graph is a tree-like data structure which
  defines a hierarchy of graphical objects in a scene.
• A single element in the scene graph is called a node
• You can apply the following GUI properties to any
  node in Scene Graph tree
  > Effect
  > Animation
  > Transformation
  > User input


                                                         17
Scene Graph: Group
Group {
   transforms: Translate {                    Gro
                                              up
       x:15, y, 15
   }                                          x
   content: [                                 :
       Text {                                 1
          x: 10, y: 50                        5
                                              y:
          font: Font: {
                                              1
              size: 50                        5
          }
          content: “Hello World”
       }
       Circle {                        Text         Circle
          centerX: 100, centerY: 100
          radius: 40
          fill: Color.BLACK
       }
   ]
}
                                                         18
Effects
How Effect Works
• Any Effect instance can be applied to a scene
  graph Node by setting the Node.effect variable.
• All Effect classes extend the abstract
  javafx.scene.effect.Effect base class.
• Each Effect subclass exposes a small number of
  variables that control the visual appearance of the
  Node.




                                                        20
Effects:
DropShadow
Example: DropShadow class
• DropShadow class provides 5 variables
  > color: The shadow Color
     > default: Color.BLACK
  > offsetX: The shadow offset in the x direction, in pixels.
     > default: 0.0
  > offsetY: The shadow offset in the y direction, in pixels.
     > default: 0.0
  > radius: The radius of the shadow blur kernel.
     > default: 10.0, max: 63.0
  > spread: The spread of the shadow.
     > default: 0.0, max: 1.0, min: 0.0

                                                                22
Example: DropShadow
  Text {
     effect: DropShadow {
        offsetY: 3
        color: Color.color(0.4, 0.4, 0.4)
     };
    ...
  },
  Circle {
     effect: DropShadow {
        offsetY: 4
     },
    ...
  }

                                            23
Example: DropShadow
  Text {
     effect: DropShadow {
        offsetY: 3
        color: Color.GREEN
        radius: 20.0
     };
    ...
  },
  Circle {
     effect: DropShadow {
        offsetX: 10
        offsetY: 20
        color: Color.BLUE
        radius: 30.0
     }
    ...
                             24
Example: DropShadow with Binding
• Apply a DropShadow effect to a rounded
  Rectangle and control its appearance
  through the magic of the bind operator.
Rectangle {
   effect: DropShadow {
             radius: bind radius
   }
   x: 50 y: 30 width: 150 height: 100
   arcWidth: 40 arcHeight: 40
   fill: Color.RED
}

                                            25
Demo:
                    DropShadow,
javapassion.com/handsonlabs/javafx_guibasics/index.html#7.1

           DropShadow with Binding,
     javapassion.com/handsonlabs/javafx_customnode

                EffectsPlayground
   http://javafx.com/samples/EffectsPlayground/index.html



                                                            26
JavaFX
GUI Basics II:
Interaction,
Transformation,
Binding,
Drag and drop,
Swing components

                   27
Topics
•   Interaction
•   Transformation
•   Binding
•   Drag and drop
•   Swing components




                       28
Interactions
Handling Events
• All nodes have either mouse or keyboard
  events
  > Override the appropriate method
• Mouse events – onMouseXXXX()
  > XXXX = Entered, Exited, Pressed, Dragged,
    Moved, Clicked, Released, WheelMoved
• Keyboard events – onKeyboardXXXX()
  > XXXX = Pressed, Released, Typed
• Indicate interactivity by changing cursor
  > Set the cursor attribute
                                                30
Example: Handling Events
• Mouse events change the color of an
  rectangle
var rectangle:Rectangle = Rectangle {
    x: 20, y: 10
    width: 150, height: 70
    arcWidth: 50, arcHeight: 50
    fill: Color.LIGHTBLUE
    stroke: Color.ROYALBLUE
    strokeWidth: 3
    onMouseEntered: function( e: MouseEvent ):Void {
        rectangle.fill = Color.WHITESMOKE;
    }
    onMouseExited: function( e: MouseEvent ):Void {
        rectangle.fill = Color.LIGHTBLUE;
    }
}
                                                       31
Demo:
                 Simple Sketch
             gui2_interaction_Sketch_basic_3steps
http://www.javapassion.com/handsonlabs/javafx_guibasics2/#1.3




                                                                32
Transformation
Transformation class
• Provides functions to perform
  > Rotating
  > Scaling
  > Shearing
  > Translation




                                  34
Rotate Transformation
• Rotates coordinates around an anchor point
Stage {
    title: "Welcome to JavaFX!"
    scene: Scene {
        width: 200
        height: 200
        content: [
            Rectangle {
                transforms: Rotate {
                    angle: bind angle
                    pivotX: 10
                    pivotY: 10
                }
                ...
            }
        ]
    }
}                                              35
Translation Transformation
• Translates coordinates by the specified
  factors
Stage {
    title: "Transformation - Translate"
    width: 100 height: 100
    scene: Scene {
        content: [
            Rectangle {
                transforms: Translate {
                    x: bind translateX
                    y: bind translateY
                }
                x: 10
                y: 10
                width: 20
                height: 20
                fill: Color.GREEN
                onMouseEntered: function( e: MouseEvent ):Void {
                    translateX = 20;
                    translateY = 30
                }
                onMouseExited: function( e: MouseEvent ):Void {
                    translateX = 0.0;
                    translateY = 0.0;                              36
Demo:
                Transformation
www.javapassion.com/handsonlabs/javafx_guibasics2/#Exercise_2




                                                            37
Bindings with
GUI Objects
Binding with GUI objects
• The power of binding really shows when it is
  used with GUI objects
  > GUI objects can automatically change their
   shape, characteristics, and behavior




                                                 39
Demo:
                Transformation
              gui2_binding_DropShadow_Mouse
www.javapassion.com/handsonlabs/javafx_guibasics2/#Exercise_3




                                                            40
Animation Support in
JavaFX
Animation Support in JavaFX
• Built in the language syntax
  > Can animate any variable
• Native support for time
  > Duration class
  > Time literals – 1ms, 1s, 1m, 1h
  > Eg. var runFor = 500ms




                                      42
Two Types of Animation in JavaFX
• Transition
  > “Precanned” animation
  > Single purpose
• Animation
  > More flexible but more code




                                   43
Transitions
Transitions
• Predefined animations to perform a specific
  task
  > Position, rotation, opacity, etc.
• Out of the box transitions
  > RotateTranstion – rotation
  > FadeTransition – opacity
  > TranslateTransition – move a node along a
    straight line
  > PathTransition – move an object along a defined
    path
  > ScaleTranstion – grows or shrinks a node
                                                      45
Using Transitions
• Need to specify which node the transition is
  performed on
  > Nodes – geometric shapes, images, text, Swing
    components
• Other attributes
  > Duration – how long to perform the animation
  > Rate – the speed and direction
  > Interpolator – the acceleration and deceleration of the
    animation
• Can execute a function at the end of the animation
  > Assign a function to action attribute
                                                         46
RotationTransition
var rotTransition = RotateTransition {
    duration: 3s
    node: node
    byAngle: 180
    repeatCount:4
    autoReverse: true
}

var princess:ImageView = ImageView {
    image: Image {
        url: "{__DIR__}princess.png"
    }
    onMouseClicked: function( e: MouseEvent ):Void {
        rotTransition.play();
    }
}
                                                       47
Path Transition
var earth:ImageView = ImageView {
    x: sx y: sy
    image: Image { url: "{__DIR__}earth.png” }
}
def path = [
   MoveTo { x: sx y: sy}
   ArcTo { x: 0 y: 200
       radiusX: 50 radiusY: 50 sweepFlag: true
   }
];
var aniPath:PathTransition = PathTransition {
    node: earth
    path: AnimationPath.createFromPath(
                Path {elements: path })
    duration: 1500ms
}

aniPath.playFromStart();
                                                 48
Demo:
                    Transitions
http://www.javapassion.com/handsonlabs/javafx_animation/#Exercise_1
http://www.javapassion.com/handsonlabs/javafx_animation/#Exercise_2




                                                                      49
KeyFrame based
Animation
Key Frame based Animation
• What is Key Frame based animation?
  > A declarative model in which programmer describes
    the animated state transitions of each "scene" by
    declaring "snapshots" (key frames) of state at
    certain points in time
• Two basic varieties of key frame animation
  > Discrete - Set of discrete key frames
  > Interpolated - Special interpolation functions
    calculate the states that occur between animation
    frames
• Animation controls
  > Start, stop, pause, and resume
                                                        51
Programming Model of Key Frame
Animation
• Animations occur along a timeline, represented
  by a javafx.animation.Timeline object.
• Each timeline contains two or more key frames,
  represented by javafx.animation.KeyFrame
  objects.
• Each timeline supports
  > Animation attributes
     > autoReverse, repeatCount, toggle, etc.
  > Playback controls
     > start(), stop(), pause(), and resume()
                                                   52
Example: Interpolator Based
// The value of tx changes from 0 to 700
// in 10 second period in linear fashion
var t = Timeline {
    keyFrames : [
        KeyFrame {
            time: 0s
            values: [ tx => 0 ]
            action: function() { … }
        },
        KeyFrame {
            time: 10s
            values: [
                tx => 700 tween Interpolator.LINEAR
            ]
        } ]
}
t.start();
                                                      53
Example – Defining Key Frames
Timeline {
   keyFrames: [
       KeyFrame {
           time: 0s
           values: [ radius => 30 ]
         }
       KeyFrame {
           time: 5s
           values: [
               radius => 300 tween Interpolator.LINEAR
           ]
       }                   How the value changes over time
             Key value
   ]
}            radius = 30                      radius = 300



               0s      1s      2s     3s     4s      5s      6s

                Keyframes
                                                                  54
at() (Shorthand notation)
var t = Timeline {
   ...
   keyFrames: [
       KeyFrame {
          time: 0ms
          values: [ radius => 30 ]
       },
       KeyFrame {
          time: 500ms
          values: [
              radius => 300 tween Interpolator.LINEAR
          ]
       }
   ]              keyFrames: [
};                    at(0ms) { radius => 30 }
                      at(500ms) {
                         radius => 300 Interpolator.LINEAR
                      }
                  ]

                                                             55
Animation through Binding
var opa = 0.0;
var street1:ImageView = ImageView {
    image: Image { url: "{__DIR__}street1.jpg" }
    opacity: bind opa
    onMouseClicked: function( e: MouseEvent ):Void {
        timeline.play();
    }
}
var timeline:Timeline = Timeline {
    keyFrames: [
        KeyFrame {
            time: 0s
            values: [ opa => 0.0,]
        },
        KeyFrame {
            time: 1s
            values: [ opa => 1.0 tween Interpolator.LINEAR,]
        }
    ]
}                                                         56
Custom Node
Custom Node
• Primary means of Scene Graph
  encapsulation
• Use it when extending existing GUI class is
  not enough for your task
• Simply override the create() method, which
  returns a Node object




                                                58
Simple CustomNode
 • Extend CustomNode class and override
   create()
class Bars extends CustomNode {
   override function create():Node {
      return Group {
         content: for(x in [0..4]) {
           Rectangle {
             y: indexof x * 20
             width: 100
             height: 10
             fill:Color.RED
           }
         }
      };
   }
}
// Bars object literal
Bars { }
                                          59
Demo:
     Building “Under the Sea”
           Step by Step
http://www.javapassion.com/handsonlabs/javafx_animation/index.html#4.1




                                                                         60
Media
FX Media API Overview
                          Media
     MediaView is      MediaPlayer
       UI that
      extended       MediaView
      from the
        Node        SceneGraph Node




• Simple model-view-controller design
• All classes in javafx.scene.media package.
• MediaView takes all cool features of SceneGraph
  node, such as effects, transforming, clip, opacity,
  etc...                                                62
Example of Creating a Media Player
var video:Media = Media {
    source: "http://..."
};
var player:MediaPlayer = MediaPlayer {
    media: video
    rate: 1.0
    volume: 0.4                 Stage {
};                                  title: "Media Player"
var view:MediaView = MediaView {
                                    width: 700
    mediaPlayer: player
                                    height: 700
    x:200
    y:200                           scene: Scene {
};                                      content: [view]
                                 }
                            }
                                                     63
Demo:
                   Media
http://javafx.com/samples/SimpleVideoPlayer/index.html




                                                         64
Deployment
Deployment Options
• JavaFX 1.0 applications can be deployed using
  the two standard Java deployment technologies
  > Java Plugin: A tool used for deploying Java applets
    that run inside a web browser
  > Java Web Start: A tool used for deploying stand-alone
    Java applications on the desktop, using JNLP (Java
    Network Launching Protocol).
• Or using mobile emulation
  > JavaFX Mobile Emulator: A tool provided with the
    JavaFX SDK, which displays your applications as they
    would look on a typical mobile device.

                                                           66
Execution Models
• Standard, Web Start, Applet, Mobile emulator




                                                 67
Demo:
Draggable Applet




                   68
JavaFX Mobile
Demo:
            JavaFX Mobile
http://javafx.com/samples/SimpleVideoPlayerMobile/index.html




                                                               70
Java Store
What is Java Store?

• Online store for Java and JavaFX applications
  > Distribution channel delivering Java and JavaFX
    applications to 1Billion Java enabled desktop and
    devices
• Provide an easy means for developers and
  ISVs to monetize their Java and JavaFX
  applications



                                                      72
Java Store is Written in JavaFX




                                  73
Java Store End-to-End Architecture


               •Developer           Java Store
               Registration          Desktop

               •Publishing
               •Testing            Mobile Store
  DEVELOPERS
                                  SP/OEM Branded
               •Content
               Management
               •Payment              TV Store
               Settlement

    WEB        WAREHOUSE            STORES
 DEVELOPERS
                          MARKETPLACE              END USER

                                                              74
How People Get Java Store?


>store.java.com

>Java auto-update
>JRE/JDK downloads

>Java.sun.com




                             75
Demo: Java Store




                   76
WidgetFX
Demo:
WidgetFx




           78
JavaFX Technology
Overview




                    79

Mais conteúdo relacionado

Destaque (19)

Iasi code camp 12 october 2013 responsive images in the wild-vlad zelinschi
Iasi code camp 12 october 2013 responsive images in the wild-vlad zelinschiIasi code camp 12 october 2013 responsive images in the wild-vlad zelinschi
Iasi code camp 12 october 2013 responsive images in the wild-vlad zelinschi
 
Dan Vulpe - JavaFX 2 - Developing RIA with Java
Dan Vulpe - JavaFX 2 - Developing RIA with JavaDan Vulpe - JavaFX 2 - Developing RIA with Java
Dan Vulpe - JavaFX 2 - Developing RIA with Java
 
Windows 7
Windows 7Windows 7
Windows 7
 
Develop Your Skills With Osum
Develop Your Skills With OsumDevelop Your Skills With Osum
Develop Your Skills With Osum
 
Introduction To Programming (2009 2010)
Introduction To Programming (2009 2010)Introduction To Programming (2009 2010)
Introduction To Programming (2009 2010)
 
Javanowandfuture Chihuahua
Javanowandfuture ChihuahuaJavanowandfuture Chihuahua
Javanowandfuture Chihuahua
 
Google Summer of Code
Google Summer of CodeGoogle Summer of Code
Google Summer of Code
 
Javafx Overview 90minutes
Javafx Overview 90minutesJavafx Overview 90minutes
Javafx Overview 90minutes
 
Msp
MspMsp
Msp
 
How To Get Your First Job
How To Get Your First  JobHow To Get Your First  Job
How To Get Your First Job
 
I Phone Session Mufix
I Phone Session MufixI Phone Session Mufix
I Phone Session Mufix
 
Javafx Overview 90minutes
Javafx Overview 90minutesJavafx Overview 90minutes
Javafx Overview 90minutes
 
Linux Presentation
Linux PresentationLinux Presentation
Linux Presentation
 
Game Programming By J2me
Game Programming By J2meGame Programming By J2me
Game Programming By J2me
 
Linux Administration
Linux AdministrationLinux Administration
Linux Administration
 
Web Fundamental
Web FundamentalWeb Fundamental
Web Fundamental
 
Mufix Network Programming Lecture
Mufix Network Programming LectureMufix Network Programming Lecture
Mufix Network Programming Lecture
 
Networks Basics
Networks BasicsNetworks Basics
Networks Basics
 
Joomla Presentations
Joomla PresentationsJoomla Presentations
Joomla Presentations
 

Semelhante a Javafx Overview 90minutes

Introduction into JavaFX
Introduction into JavaFXIntroduction into JavaFX
Introduction into JavaFXEugene Bogaart
 
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon RitterJava Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon RitterJAX London
 
JavaFX 2.0 With Alternative Languages [Portuguese]
JavaFX 2.0 With Alternative Languages [Portuguese]JavaFX 2.0 With Alternative Languages [Portuguese]
JavaFX 2.0 With Alternative Languages [Portuguese]Stephen Chin
 
JFXtras - JavaFX Controls, Layout, Services, and More
JFXtras - JavaFX Controls, Layout, Services, and MoreJFXtras - JavaFX Controls, Layout, Services, and More
JFXtras - JavaFX Controls, Layout, Services, and MoreStephen Chin
 
JavaFX - Next Generation Java UI
JavaFX - Next Generation Java UIJavaFX - Next Generation Java UI
JavaFX - Next Generation Java UIYoav Aharoni
 
Scripting with Java FX - Cédric Tabin - December 2007
Scripting with Java FX - Cédric Tabin - December 2007Scripting with Java FX - Cédric Tabin - December 2007
Scripting with Java FX - Cédric Tabin - December 2007JUG Lausanne
 
用 OPENRNDR 將 Chatbot 訊息視覺化
用 OPENRNDR 將 Chatbot 訊息視覺化用 OPENRNDR 將 Chatbot 訊息視覺化
用 OPENRNDR 將 Chatbot 訊息視覺化Shengyou Fan
 
Enhancing UI/UX using Java animations
Enhancing UI/UX using Java animationsEnhancing UI/UX using Java animations
Enhancing UI/UX using Java animationsNaman Dwivedi
 
JavaFX 2.0 and Alternative Languages
JavaFX 2.0 and Alternative LanguagesJavaFX 2.0 and Alternative Languages
JavaFX 2.0 and Alternative LanguagesStephen Chin
 
JavaFX Your Way: Building JavaFX Applications with Alternative Languages
JavaFX Your Way: Building JavaFX Applications with Alternative LanguagesJavaFX Your Way: Building JavaFX Applications with Alternative Languages
JavaFX Your Way: Building JavaFX Applications with Alternative LanguagesStephen Chin
 
SwiftUI Animation - The basic overview
SwiftUI Animation - The basic overviewSwiftUI Animation - The basic overview
SwiftUI Animation - The basic overviewWannitaTolaema
 
Java FX 2.0 - A Developer's Guide
Java FX 2.0 - A Developer's GuideJava FX 2.0 - A Developer's Guide
Java FX 2.0 - A Developer's GuideStephen Chin
 
Getting Visual with Ruby Processing
Getting Visual with Ruby ProcessingGetting Visual with Ruby Processing
Getting Visual with Ruby ProcessingRichard LeBer
 
Interactive Graphics
Interactive GraphicsInteractive Graphics
Interactive GraphicsBlazing Cloud
 
U5 JAVA.pptx
U5 JAVA.pptxU5 JAVA.pptx
U5 JAVA.pptxmadan r
 
I Can't Believe It's Not Flash
I Can't Believe It's Not FlashI Can't Believe It's Not Flash
I Can't Believe It's Not FlashThomas Fuchs
 

Semelhante a Javafx Overview 90minutes (20)

Introduction into JavaFX
Introduction into JavaFXIntroduction into JavaFX
Introduction into JavaFX
 
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon RitterJava Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
 
JavaFX
JavaFXJavaFX
JavaFX
 
JavaFX 2.0 With Alternative Languages [Portuguese]
JavaFX 2.0 With Alternative Languages [Portuguese]JavaFX 2.0 With Alternative Languages [Portuguese]
JavaFX 2.0 With Alternative Languages [Portuguese]
 
Groovy's Builder
Groovy's BuilderGroovy's Builder
Groovy's Builder
 
Mini-curso JavaFX Aula1
Mini-curso JavaFX Aula1Mini-curso JavaFX Aula1
Mini-curso JavaFX Aula1
 
JFXtras - JavaFX Controls, Layout, Services, and More
JFXtras - JavaFX Controls, Layout, Services, and MoreJFXtras - JavaFX Controls, Layout, Services, and More
JFXtras - JavaFX Controls, Layout, Services, and More
 
JavaFX - Next Generation Java UI
JavaFX - Next Generation Java UIJavaFX - Next Generation Java UI
JavaFX - Next Generation Java UI
 
Scripting with Java FX - Cédric Tabin - December 2007
Scripting with Java FX - Cédric Tabin - December 2007Scripting with Java FX - Cédric Tabin - December 2007
Scripting with Java FX - Cédric Tabin - December 2007
 
用 OPENRNDR 將 Chatbot 訊息視覺化
用 OPENRNDR 將 Chatbot 訊息視覺化用 OPENRNDR 將 Chatbot 訊息視覺化
用 OPENRNDR 將 Chatbot 訊息視覺化
 
Java Fx
Java FxJava Fx
Java Fx
 
Enhancing UI/UX using Java animations
Enhancing UI/UX using Java animationsEnhancing UI/UX using Java animations
Enhancing UI/UX using Java animations
 
JavaFX 2.0 and Alternative Languages
JavaFX 2.0 and Alternative LanguagesJavaFX 2.0 and Alternative Languages
JavaFX 2.0 and Alternative Languages
 
JavaFX Your Way: Building JavaFX Applications with Alternative Languages
JavaFX Your Way: Building JavaFX Applications with Alternative LanguagesJavaFX Your Way: Building JavaFX Applications with Alternative Languages
JavaFX Your Way: Building JavaFX Applications with Alternative Languages
 
SwiftUI Animation - The basic overview
SwiftUI Animation - The basic overviewSwiftUI Animation - The basic overview
SwiftUI Animation - The basic overview
 
Java FX 2.0 - A Developer's Guide
Java FX 2.0 - A Developer's GuideJava FX 2.0 - A Developer's Guide
Java FX 2.0 - A Developer's Guide
 
Getting Visual with Ruby Processing
Getting Visual with Ruby ProcessingGetting Visual with Ruby Processing
Getting Visual with Ruby Processing
 
Interactive Graphics
Interactive GraphicsInteractive Graphics
Interactive Graphics
 
U5 JAVA.pptx
U5 JAVA.pptxU5 JAVA.pptx
U5 JAVA.pptx
 
I Can't Believe It's Not Flash
I Can't Believe It's Not FlashI Can't Believe It's Not Flash
I Can't Believe It's Not Flash
 

Mais de SiliconExpert Technologies (13)

Joining Osum Community And ..
Joining Osum Community And ..Joining Osum Community And ..
Joining Osum Community And ..
 
Sfd Post Event Report
Sfd Post Event ReportSfd Post Event Report
Sfd Post Event Report
 
Linux
LinuxLinux
Linux
 
Web Intro
Web IntroWeb Intro
Web Intro
 
Desktop Intro
Desktop IntroDesktop Intro
Desktop Intro
 
Fedora Fs Menoufiya Release 10
Fedora Fs Menoufiya Release 10Fedora Fs Menoufiya Release 10
Fedora Fs Menoufiya Release 10
 
Database Session
Database SessionDatabase Session
Database Session
 
Eclipse Vs Netbeans
Eclipse Vs NetbeansEclipse Vs Netbeans
Eclipse Vs Netbeans
 
Introduction to Programming
Introduction to ProgrammingIntroduction to Programming
Introduction to Programming
 
Linux
LinuxLinux
Linux
 
How To Write A Cv That Talks For You
How To Write A Cv That Talks For YouHow To Write A Cv That Talks For You
How To Write A Cv That Talks For You
 
Web Fundamentals
Web FundamentalsWeb Fundamentals
Web Fundamentals
 
ugmented Reality BY Dr.Hatem Mohammed
ugmented Reality BY Dr.Hatem Mohammedugmented Reality BY Dr.Hatem Mohammed
ugmented Reality BY Dr.Hatem Mohammed
 

Último

Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 

Último (20)

Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 

Javafx Overview 90minutes

  • 1. JavaFX: Building RIA Application Sang Shin javapassion.com 1
  • 2. Topics • Things you can build with JavaFX • JavaFX script overview • Declarative GUI building • Scene graph • Animation • Media • Deployment • JavaFX Mobile • Web services 2
  • 3. Things You Can Build with JavaFX
  • 4. Demo: JavaFX Sample Apps from javafx.com 4
  • 6. Features of JavaFX Script • Declarative, statically-typed scripting language • Facilitates rapid GUI development • Runs on Virtual Machine for the Java™ platform • Deployment options same as Java programs • Fully utilizes Java class libraries behind the scenes • Cool, interesting language features for building RIA apps > Object literal, Sequence, Data binding, Animation, Media, etc. 6
  • 7. Class Definition • Address class definition: The Address class declares street, city, state, and zip fields all of type String class Address { var street: String; var city: String; var state: String; var zip: String; } 7
  • 8. Object Literal – Creating object • In the JavaFX Script programming language, an object instance can be created with an object literal (like in JavaScript, unlike in Java) • Example: The first word (Address) specifies the type of object, class, that you are creating. Address { street: "1 Main Street"; // separated by semi colons city: "Santa Clara"; state: "CA"; zip: "95050"; } 8
  • 9. Nesting an Object inside Another Object • Nesting Address object inside Customer object def customer = Customer { firstName: "John"; lastName: "Doe"; phoneNum: "(408) 555-1212"; address: Address { street: "1 Main Street"; city: "Santa Clara"; state: "CA"; zip: "95050"; } } 9
  • 10. Binding • Cause and effect – responding to changes • bind operator allows dynamic content to be expressed declaratively • Dependency based evaluation of any expression • Automated by the JavaFX runtime rather than manually wired by the programmer • Eliminates the listener pattern 10
  • 11. Binding to a Simple Expression var x = 0; // Bind variable x to variable y. Whenever the value of x changes, // the value of variable y automatically changes as well. var y = bind x + 10; x = 1; println("----y after x is changed to 1 = {y}"); // y now equals 11 x = 47; println("----y after x is changed to 47 = {y}"); // y now equals 57 11
  • 13. Example of JavaFX Application import javafx.scene.paint.Color; import javafx.scene.Scene; import javafx.scene.shape.Circle; import javafx.stage.Stage; Stage { title: "My circle" width: 100 height: 100 scene: Scene { content: [ Circle { centerX: 50, centerY: 50 radius: 40 fill: Color.RED } ] } } 13
  • 14. Why Declarative Syntax for Building GUI? • Because the structure of declared objects in the code reflects the visual structure of the scene graph, and this enables you to understand and maintain the code easily. • The order of elements you declare in the code matches the order in which they appear in the application. 14
  • 15. Demo: Building “HelloWorld” JavaFX Application http://www.javapassion.com/handsonlabs/javafx_lang/#Exercise_1 15
  • 17. What is Scene Graph? • Scene Graph enables declarative GUI programming • The scene graph is a tree-like data structure which defines a hierarchy of graphical objects in a scene. • A single element in the scene graph is called a node • You can apply the following GUI properties to any node in Scene Graph tree > Effect > Animation > Transformation > User input 17
  • 18. Scene Graph: Group Group { transforms: Translate { Gro up x:15, y, 15 } x content: [ : Text { 1 x: 10, y: 50 5 y: font: Font: { 1 size: 50 5 } content: “Hello World” } Circle { Text Circle centerX: 100, centerY: 100 radius: 40 fill: Color.BLACK } ] } 18
  • 20. How Effect Works • Any Effect instance can be applied to a scene graph Node by setting the Node.effect variable. • All Effect classes extend the abstract javafx.scene.effect.Effect base class. • Each Effect subclass exposes a small number of variables that control the visual appearance of the Node. 20
  • 22. Example: DropShadow class • DropShadow class provides 5 variables > color: The shadow Color > default: Color.BLACK > offsetX: The shadow offset in the x direction, in pixels. > default: 0.0 > offsetY: The shadow offset in the y direction, in pixels. > default: 0.0 > radius: The radius of the shadow blur kernel. > default: 10.0, max: 63.0 > spread: The spread of the shadow. > default: 0.0, max: 1.0, min: 0.0 22
  • 23. Example: DropShadow Text { effect: DropShadow { offsetY: 3 color: Color.color(0.4, 0.4, 0.4) }; ... }, Circle { effect: DropShadow { offsetY: 4 }, ... } 23
  • 24. Example: DropShadow Text { effect: DropShadow { offsetY: 3 color: Color.GREEN radius: 20.0 }; ... }, Circle { effect: DropShadow { offsetX: 10 offsetY: 20 color: Color.BLUE radius: 30.0 } ... 24
  • 25. Example: DropShadow with Binding • Apply a DropShadow effect to a rounded Rectangle and control its appearance through the magic of the bind operator. Rectangle { effect: DropShadow { radius: bind radius } x: 50 y: 30 width: 150 height: 100 arcWidth: 40 arcHeight: 40 fill: Color.RED } 25
  • 26. Demo: DropShadow, javapassion.com/handsonlabs/javafx_guibasics/index.html#7.1 DropShadow with Binding, javapassion.com/handsonlabs/javafx_customnode EffectsPlayground http://javafx.com/samples/EffectsPlayground/index.html 26
  • 28. Topics • Interaction • Transformation • Binding • Drag and drop • Swing components 28
  • 30. Handling Events • All nodes have either mouse or keyboard events > Override the appropriate method • Mouse events – onMouseXXXX() > XXXX = Entered, Exited, Pressed, Dragged, Moved, Clicked, Released, WheelMoved • Keyboard events – onKeyboardXXXX() > XXXX = Pressed, Released, Typed • Indicate interactivity by changing cursor > Set the cursor attribute 30
  • 31. Example: Handling Events • Mouse events change the color of an rectangle var rectangle:Rectangle = Rectangle { x: 20, y: 10 width: 150, height: 70 arcWidth: 50, arcHeight: 50 fill: Color.LIGHTBLUE stroke: Color.ROYALBLUE strokeWidth: 3 onMouseEntered: function( e: MouseEvent ):Void { rectangle.fill = Color.WHITESMOKE; } onMouseExited: function( e: MouseEvent ):Void { rectangle.fill = Color.LIGHTBLUE; } } 31
  • 32. Demo: Simple Sketch gui2_interaction_Sketch_basic_3steps http://www.javapassion.com/handsonlabs/javafx_guibasics2/#1.3 32
  • 34. Transformation class • Provides functions to perform > Rotating > Scaling > Shearing > Translation 34
  • 35. Rotate Transformation • Rotates coordinates around an anchor point Stage { title: "Welcome to JavaFX!" scene: Scene { width: 200 height: 200 content: [ Rectangle { transforms: Rotate { angle: bind angle pivotX: 10 pivotY: 10 } ... } ] } } 35
  • 36. Translation Transformation • Translates coordinates by the specified factors Stage { title: "Transformation - Translate" width: 100 height: 100 scene: Scene { content: [ Rectangle { transforms: Translate { x: bind translateX y: bind translateY } x: 10 y: 10 width: 20 height: 20 fill: Color.GREEN onMouseEntered: function( e: MouseEvent ):Void { translateX = 20; translateY = 30 } onMouseExited: function( e: MouseEvent ):Void { translateX = 0.0; translateY = 0.0; 36
  • 37. Demo: Transformation www.javapassion.com/handsonlabs/javafx_guibasics2/#Exercise_2 37
  • 39. Binding with GUI objects • The power of binding really shows when it is used with GUI objects > GUI objects can automatically change their shape, characteristics, and behavior 39
  • 40. Demo: Transformation gui2_binding_DropShadow_Mouse www.javapassion.com/handsonlabs/javafx_guibasics2/#Exercise_3 40
  • 42. Animation Support in JavaFX • Built in the language syntax > Can animate any variable • Native support for time > Duration class > Time literals – 1ms, 1s, 1m, 1h > Eg. var runFor = 500ms 42
  • 43. Two Types of Animation in JavaFX • Transition > “Precanned” animation > Single purpose • Animation > More flexible but more code 43
  • 45. Transitions • Predefined animations to perform a specific task > Position, rotation, opacity, etc. • Out of the box transitions > RotateTranstion – rotation > FadeTransition – opacity > TranslateTransition – move a node along a straight line > PathTransition – move an object along a defined path > ScaleTranstion – grows or shrinks a node 45
  • 46. Using Transitions • Need to specify which node the transition is performed on > Nodes – geometric shapes, images, text, Swing components • Other attributes > Duration – how long to perform the animation > Rate – the speed and direction > Interpolator – the acceleration and deceleration of the animation • Can execute a function at the end of the animation > Assign a function to action attribute 46
  • 47. RotationTransition var rotTransition = RotateTransition { duration: 3s node: node byAngle: 180 repeatCount:4 autoReverse: true } var princess:ImageView = ImageView { image: Image { url: "{__DIR__}princess.png" } onMouseClicked: function( e: MouseEvent ):Void { rotTransition.play(); } } 47
  • 48. Path Transition var earth:ImageView = ImageView { x: sx y: sy image: Image { url: "{__DIR__}earth.png” } } def path = [ MoveTo { x: sx y: sy} ArcTo { x: 0 y: 200 radiusX: 50 radiusY: 50 sweepFlag: true } ]; var aniPath:PathTransition = PathTransition { node: earth path: AnimationPath.createFromPath( Path {elements: path }) duration: 1500ms } aniPath.playFromStart(); 48
  • 49. Demo: Transitions http://www.javapassion.com/handsonlabs/javafx_animation/#Exercise_1 http://www.javapassion.com/handsonlabs/javafx_animation/#Exercise_2 49
  • 51. Key Frame based Animation • What is Key Frame based animation? > A declarative model in which programmer describes the animated state transitions of each "scene" by declaring "snapshots" (key frames) of state at certain points in time • Two basic varieties of key frame animation > Discrete - Set of discrete key frames > Interpolated - Special interpolation functions calculate the states that occur between animation frames • Animation controls > Start, stop, pause, and resume 51
  • 52. Programming Model of Key Frame Animation • Animations occur along a timeline, represented by a javafx.animation.Timeline object. • Each timeline contains two or more key frames, represented by javafx.animation.KeyFrame objects. • Each timeline supports > Animation attributes > autoReverse, repeatCount, toggle, etc. > Playback controls > start(), stop(), pause(), and resume() 52
  • 53. Example: Interpolator Based // The value of tx changes from 0 to 700 // in 10 second period in linear fashion var t = Timeline { keyFrames : [ KeyFrame { time: 0s values: [ tx => 0 ] action: function() { … } }, KeyFrame { time: 10s values: [ tx => 700 tween Interpolator.LINEAR ] } ] } t.start(); 53
  • 54. Example – Defining Key Frames Timeline { keyFrames: [ KeyFrame { time: 0s values: [ radius => 30 ] } KeyFrame { time: 5s values: [ radius => 300 tween Interpolator.LINEAR ] } How the value changes over time Key value ] } radius = 30 radius = 300 0s 1s 2s 3s 4s 5s 6s Keyframes 54
  • 55. at() (Shorthand notation) var t = Timeline { ... keyFrames: [ KeyFrame { time: 0ms values: [ radius => 30 ] }, KeyFrame { time: 500ms values: [ radius => 300 tween Interpolator.LINEAR ] } ] keyFrames: [ }; at(0ms) { radius => 30 } at(500ms) { radius => 300 Interpolator.LINEAR } ] 55
  • 56. Animation through Binding var opa = 0.0; var street1:ImageView = ImageView { image: Image { url: "{__DIR__}street1.jpg" } opacity: bind opa onMouseClicked: function( e: MouseEvent ):Void { timeline.play(); } } var timeline:Timeline = Timeline { keyFrames: [ KeyFrame { time: 0s values: [ opa => 0.0,] }, KeyFrame { time: 1s values: [ opa => 1.0 tween Interpolator.LINEAR,] } ] } 56
  • 58. Custom Node • Primary means of Scene Graph encapsulation • Use it when extending existing GUI class is not enough for your task • Simply override the create() method, which returns a Node object 58
  • 59. Simple CustomNode • Extend CustomNode class and override create() class Bars extends CustomNode { override function create():Node { return Group { content: for(x in [0..4]) { Rectangle { y: indexof x * 20 width: 100 height: 10 fill:Color.RED } } }; } } // Bars object literal Bars { } 59
  • 60. Demo: Building “Under the Sea” Step by Step http://www.javapassion.com/handsonlabs/javafx_animation/index.html#4.1 60
  • 61. Media
  • 62. FX Media API Overview Media MediaView is MediaPlayer UI that extended MediaView from the Node SceneGraph Node • Simple model-view-controller design • All classes in javafx.scene.media package. • MediaView takes all cool features of SceneGraph node, such as effects, transforming, clip, opacity, etc... 62
  • 63. Example of Creating a Media Player var video:Media = Media { source: "http://..." }; var player:MediaPlayer = MediaPlayer { media: video rate: 1.0 volume: 0.4 Stage { }; title: "Media Player" var view:MediaView = MediaView { width: 700 mediaPlayer: player height: 700 x:200 y:200 scene: Scene { }; content: [view] } } 63
  • 64. Demo: Media http://javafx.com/samples/SimpleVideoPlayer/index.html 64
  • 66. Deployment Options • JavaFX 1.0 applications can be deployed using the two standard Java deployment technologies > Java Plugin: A tool used for deploying Java applets that run inside a web browser > Java Web Start: A tool used for deploying stand-alone Java applications on the desktop, using JNLP (Java Network Launching Protocol). • Or using mobile emulation > JavaFX Mobile Emulator: A tool provided with the JavaFX SDK, which displays your applications as they would look on a typical mobile device. 66
  • 67. Execution Models • Standard, Web Start, Applet, Mobile emulator 67
  • 70. Demo: JavaFX Mobile http://javafx.com/samples/SimpleVideoPlayerMobile/index.html 70
  • 72. What is Java Store? • Online store for Java and JavaFX applications > Distribution channel delivering Java and JavaFX applications to 1Billion Java enabled desktop and devices • Provide an easy means for developers and ISVs to monetize their Java and JavaFX applications 72
  • 73. Java Store is Written in JavaFX 73
  • 74. Java Store End-to-End Architecture •Developer Java Store Registration Desktop •Publishing •Testing Mobile Store DEVELOPERS SP/OEM Branded •Content Management •Payment TV Store Settlement WEB WAREHOUSE STORES DEVELOPERS MARKETPLACE END USER 74
  • 75. How People Get Java Store? >store.java.com >Java auto-update >JRE/JDK downloads >Java.sun.com 75