SlideShare une entreprise Scribd logo
1  sur  34
New and Cool: JavaFX
Eugene Bogaart
Solution Architect
Sun Microsystems

                       1
Sun Confidential: Internal Only   2
JavaFX Vision
    JavaFX is the platform for creating and
                   delivering
         Rich Internet Applications
      across all the screens of your life




   JavaFX is Powered by Java

                   Sun Confidential: Internal Only   3
A Basic Java GUI: Not Very Pretty




               Sun Confidential: Internal Only   4
Samples
• Vancouver Medal app
• Simon's Book example
• JavaFX Widget set




                    Sun Confidential: Internal Only   5
JavaFX Platform Architecture


            FX Applications

           Device                                              FXScript
   Media Specific   Core         Scene                         runtime
                                                      WebKit
   Players APIs     APIs         Graph
                                                                            Ad
                                                                 FX        Player
    Media
                       VM                                      Compiler
                                                                          Installer
   Codecs

                       Device OS

                           Sun Confidential: Internal Only                            6
JavaFX Script Basics
• Declarative, statically-typed scripting language
• Facilitates rapid GUI development
• Many cool, interesting language features
• Runs on the Java Virtual Machine
• Deployment options same as Java programs
  > Applet, Application, WebStart
• Fully utilizes Java class libraries behind the scenes
• For content designers and media engineers


                       Sun Confidential: Internal Only    7
Basic JavaFXScript Class
Syntax is Java-like with shades of JavaScript

class HelloWorldNode extends CustomNode {
    public var text:String;
    public override function create(): Node {
        return Text {
            x: 10, y: 50
            font: Font {
                size: 50
            }
            content: “Hello World”
       }
  };
}

                           Sun Confidential: Internal Only   8
Class Definition
Address class definition: The Address class declares
street, city, state, and zip instance variables all of type
String
class Address {
var street: String;
var city: String;
var state: String;
var zip: String;
}
                           Sun Confidential: Internal Only    9
Declaring an Object Literal
• In the JavaFX Script language, an object instance can
  be created with an object literal (unlike 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";
}
                      Sun Confidential: Internal Only   10
Nested Literal Declaration
• 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";
  }
}                    Sun Confidential: Internal Only   11
Sequences
• Sequences
 var time:Duration[] = [1s, 5s, 10s];
 var days = [1..31];
• Insert, delete, membership and reverse
 insert 20s into time;
 delete 31 from days;
 var revDays = Sequences.reverse(days);


• Slice via range and predicate
 var oddDays = days[n | (n mod 2) == 1];
 var firstThree = time[0..<3];


                      Sun Confidential: Internal Only   12
Binding
• Dependency-based evaluation of expressions
• Enables expression of dynamic data relationships
  var x = 10;
  var y = bind x + 100;
  x = 50;
  y == 150; // true
• Any expression can be bound
  > conditionals, loops, functions, etc...
• bind “with inverse” when 2-way is needed


                           Sun Confidential: Internal Only   13
Bound
var scale = 1.0;
// makePoint is a bound function. It will be invoked even when a value of
// non-function-arugment such as scale changes. If you remove bound
// keyword, then, the change of the value of scale does not invoke the function
bound function makePoint(xPos : Number, yPos : Number) : Point {
    Point {
       x: xPos * scale
       y: yPos * scale
       }
    }
class Point {
     var x : Number;
     var y : Number;
}                                   Sun Confidential: Internal Only               14
Bound (cont)
// Code in the previous slide
// The bind keyword, placed just before the invocation of
// makePoint, binds the newly created Point object (pt) to the outcome of the
// makePoint function.
var myX = 3.0;
var myY = 3.0;
def pt = bind makePoint(myX, myY);
println(pt.x); // 3.0
myX = 10.0;
println(pt.x); // 10.0
scale = 2.0;
println(pt.x); // 20.0


                                  Sun Confidential: Internal Only               15
Trigger
• Triggers facilitates the catching and handling of data
  modification events.
  var x : String;
  var y = bind x;
• Can be re-written using triggers in a equivalent manner:
  var x : String on replace {
             y = x;
  }
• Trigger for tracing variable changes:
  var x : String on replace {
             y = x;
             Println(“X == {x}”);
  }               Sun Confidential: Internal Only          16
Many more
Why Declarative Syntax for Building




                      Sun Confidential: Internal Only   17
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.




                      Sun Confidential: Internal Only   18
Scene Graph Nodes: javafx.gui.*
                         Node


ComponentView*          Group                             Shape
  ImageView               HBox                              Arc
                           HBox
  MediaView               VBox                            Circle
                           VBox
                                                       CubicCurve
                                                         Ellipse
         Transform                                         Line
           Affine                                          Path
           Rotate                                        Polygon
            Scale                                       Polyline
            Shear                                      QuadCurve
         Translate                                     Rectangle
                                                           Text
                     Sun Confidential: Internal Only                19
Effects: javafx.gui.effects.*
              Effect
              DisplacementMap
   Blend
           PerspectiveTransform                          Light
   Bloom
                  InvertMask
    Glow
                 ColorAdjust                          DistanceLight
  Lighting
                   SepiaTone                            PointLight
   Flood
 Reflection                                              SpotLight
                GaussianBlur
   Shadow
                  MotionBlur
InnerShadow
 DropShadow



                    Sun Confidential: Internal Only                   20
Effects
• Effects On Images Demo




                    Sun Confidential: Internal Only   21
Some Effects Supported In JavaFX
effect: SepiaTone { level: 0.5 }



effect: Glow { level: 0.7 }
                                                           Original image

effect: GaussianBlur {
   input: SepiaTone {
       level: 0.5 }
   radius: 10.0
}

effect: Reflection {
   fraction: 0.7
}


                         Sun Confidential: Internal Only                    22
Lighting Effect
 effect: Lighting{
    surfaceScale: 7
    light: DistantLight {
       azimuth: 90
       elevation: 30
    }
 }
 effect: Lighting{
    surfaceScale: 7
    light: SpotLight {
       x: 0 y :0 z: 50
       pointsAtX: 10
       pointsAtY: 10
       pointsAtZ: 0
    }
 }

                     Sun Confidential: Internal Only   23
Animation
• Timelines handles the animation in JavaFX
• Timelines are first-class citizen in the language
  along with the duration time constants (1s, 10s)
• They can have one or more KeyFrames
• Functions: start(), stop(), pause(),
 resume()
• Properties: autoReverse, repeatCount,
 toggle


                       Sun Confidential: Internal Only   24
Example – Defining Key Frames
Timeline {
   keyFrames: [
       KeyFrame {
           time: 0s
           values: [ radius => 30 ]
         }
       KeyFrame {
           time: 5s
           values: [
              radius => 300 tween Interpolator.LINEAR
           ]
       }     Key value     How the value changes over time
   ]
}
             radius = 30                          radius = 300


                0s            1s              2s              3s   4s   5s   6s
                  Keyframes Sun Confidential: Internal Only                       25
Animation
• Animating TimeLines Sample




                    Sun Confidential: Internal Only   26
JavaFX Media Design Goals
• Media Playback is of primary importance
• Simple API: only a few lines of coded needed
• Cross platform A/V format required
• Native support also desirable
  > “Mash ups”
  > Viewing local media
• Zero Configuration plug in support
  > Drop in format support
• Going beyond rectangular video
  > Lightweight rendering
                      Sun Confidential: Internal Only   27
Streaming Media
• Simple Stream Media Sample




                   Sun Confidential: Internal Only   28
JavaFX Media Example
var media = Media{source: ”movie.mov”};
var player = MediaPlayer{media: media, autoPlay:true};

var mediaView = MediaView{
  // To enable audio only, don't create MediaView
  MediaView{
    mediaPlayer: player,
    onMouseClicked: function(e) { // Play/pause control
      if (player.paused) {
        player.play();
      } else {
        player.pause();
      }
    }
    rotate: 90; // Rotate
}

                      Sun Confidential: Internal Only     29
JavaFX NetBeans IDE Plugin
• Available for NetBeans 6.1 and later
  > Current NB=6.8
• Supports conventional development cycle
  > edit, compile, run, test
  > Also has preview mode (avoid compile/run)
• Specific project type for JavaFX
• Automatic installation of JavaFX SDK
• Editor supports code completion, drag and drop of
 components

                       Sun Confidential: Internal Only   30
Further Information
•   openjdk.java.net
•   www.javafx.com
•   www.sun.com/javafx
•   openjfx.org
•   learnjavafx.typepad.com




                       Sun Confidential: Internal Only   31
More info




            Sun Confidential: Internal Only   32
Summary
•   Java continues to evolve
•   JDK7 driving changes in the platform
•   JavaFX providing a RIA platform built on Java
•   More to come...




                        Sun Confidential: Internal Only   33
Q&A
Presenter’s Name
first.last@sun.com


                     34

Contenu connexe

Similaire à 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 RitterJAX London
 
JavaFX - Next Generation Java UI
JavaFX - Next Generation Java UIJavaFX - Next Generation Java UI
JavaFX - Next Generation Java UIYoav Aharoni
 
Tools and practices for rapid application development
Tools and practices for rapid application developmentTools and practices for rapid application development
Tools and practices for rapid application developmentZoltán Váradi
 
Hinkmond's JavaFX Mobile Dojo
Hinkmond's JavaFX Mobile DojoHinkmond's JavaFX Mobile Dojo
Hinkmond's JavaFX Mobile DojoStephen Chin
 
JavaFX goes Scala
JavaFX goes ScalaJavaFX goes Scala
JavaFX goes ScalaCofinpro AG
 
Java Fx Ajaxworld Rags V1
Java Fx Ajaxworld Rags V1Java Fx Ajaxworld Rags V1
Java Fx Ajaxworld Rags V1rajivmordani
 
Ionic Framework - get up and running to build hybrid mobile apps
Ionic Framework - get up and running to build hybrid mobile appsIonic Framework - get up and running to build hybrid mobile apps
Ionic Framework - get up and running to build hybrid mobile appsAndreas Sahle
 
Java keynote preso
Java keynote presoJava keynote preso
Java keynote presoArtur Alves
 
JavaFX Enterprise (JavaOne 2014)
JavaFX Enterprise (JavaOne 2014)JavaFX Enterprise (JavaOne 2014)
JavaFX Enterprise (JavaOne 2014)Hendrik Ebbers
 
Presentation - Course about JavaFX
Presentation - Course about JavaFXPresentation - Course about JavaFX
Presentation - Course about JavaFXTom Mix Petreca
 
Java 8 selected updates
Java 8 selected updatesJava 8 selected updates
Java 8 selected updatesVinay H G
 
JDD2015: Java Everywhere Again—with DukeScript - Jaroslav Tulach
JDD2015: Java Everywhere Again—with DukeScript - Jaroslav TulachJDD2015: Java Everywhere Again—with DukeScript - Jaroslav Tulach
JDD2015: Java Everywhere Again—with DukeScript - Jaroslav TulachPROIDEA
 
Java Fx Overview Tech Tour
Java Fx Overview Tech TourJava Fx Overview Tech Tour
Java Fx Overview Tech TourCarol McDonald
 
blueMarine photographic workflow with Java
blueMarine photographic workflow with JavablueMarine photographic workflow with Java
blueMarine photographic workflow with JavaFabrizio Giudici
 
Spring in the Cloud - using Spring with Cloud Foundry
Spring in the Cloud - using Spring with Cloud FoundrySpring in the Cloud - using Spring with Cloud Foundry
Spring in the Cloud - using Spring with Cloud FoundryJoshua Long
 
Google io bootcamp_2010
Google io bootcamp_2010Google io bootcamp_2010
Google io bootcamp_2010Chris Ramsdale
 
How I learned to stop worrying and love embedding JavaScript
How I learned to stop worrying and love embedding JavaScriptHow I learned to stop worrying and love embedding JavaScript
How I learned to stop worrying and love embedding JavaScriptKevin Read
 

Similaire à Introduction into JavaFX (20)

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 Overview 90minutes
Javafx Overview 90minutesJavafx Overview 90minutes
Javafx Overview 90minutes
 
Javafx Overview 90minutes
Javafx Overview 90minutesJavafx Overview 90minutes
Javafx Overview 90minutes
 
Javafx Overview 90minutes
Javafx Overview 90minutesJavafx Overview 90minutes
Javafx Overview 90minutes
 
JavaFX - Next Generation Java UI
JavaFX - Next Generation Java UIJavaFX - Next Generation Java UI
JavaFX - Next Generation Java UI
 
Tools and practices for rapid application development
Tools and practices for rapid application developmentTools and practices for rapid application development
Tools and practices for rapid application development
 
Hinkmond's JavaFX Mobile Dojo
Hinkmond's JavaFX Mobile DojoHinkmond's JavaFX Mobile Dojo
Hinkmond's JavaFX Mobile Dojo
 
JavaFX goes Scala
JavaFX goes ScalaJavaFX goes Scala
JavaFX goes Scala
 
Java Fx Ajaxworld Rags V1
Java Fx Ajaxworld Rags V1Java Fx Ajaxworld Rags V1
Java Fx Ajaxworld Rags V1
 
Ionic Framework - get up and running to build hybrid mobile apps
Ionic Framework - get up and running to build hybrid mobile appsIonic Framework - get up and running to build hybrid mobile apps
Ionic Framework - get up and running to build hybrid mobile apps
 
Java keynote preso
Java keynote presoJava keynote preso
Java keynote preso
 
JavaFX Enterprise (JavaOne 2014)
JavaFX Enterprise (JavaOne 2014)JavaFX Enterprise (JavaOne 2014)
JavaFX Enterprise (JavaOne 2014)
 
Presentation - Course about JavaFX
Presentation - Course about JavaFXPresentation - Course about JavaFX
Presentation - Course about JavaFX
 
Java 8 selected updates
Java 8 selected updatesJava 8 selected updates
Java 8 selected updates
 
JDD2015: Java Everywhere Again—with DukeScript - Jaroslav Tulach
JDD2015: Java Everywhere Again—with DukeScript - Jaroslav TulachJDD2015: Java Everywhere Again—with DukeScript - Jaroslav Tulach
JDD2015: Java Everywhere Again—with DukeScript - Jaroslav Tulach
 
Java Fx Overview Tech Tour
Java Fx Overview Tech TourJava Fx Overview Tech Tour
Java Fx Overview Tech Tour
 
blueMarine photographic workflow with Java
blueMarine photographic workflow with JavablueMarine photographic workflow with Java
blueMarine photographic workflow with Java
 
Spring in the Cloud - using Spring with Cloud Foundry
Spring in the Cloud - using Spring with Cloud FoundrySpring in the Cloud - using Spring with Cloud Foundry
Spring in the Cloud - using Spring with Cloud Foundry
 
Google io bootcamp_2010
Google io bootcamp_2010Google io bootcamp_2010
Google io bootcamp_2010
 
How I learned to stop worrying and love embedding JavaScript
How I learned to stop worrying and love embedding JavaScriptHow I learned to stop worrying and love embedding JavaScript
How I learned to stop worrying and love embedding JavaScript
 

Plus de Eugene Bogaart

What is new and cool j2se & java
What is new and cool j2se & javaWhat is new and cool j2se & java
What is new and cool j2se & javaEugene Bogaart
 
Java Enterprise Edition 6 Overview
Java Enterprise Edition 6 OverviewJava Enterprise Edition 6 Overview
Java Enterprise Edition 6 OverviewEugene Bogaart
 
EDA With Glassfish ESB Jfall IEP Intelligent Event Processing
EDA With Glassfish ESB Jfall IEP Intelligent Event ProcessingEDA With Glassfish ESB Jfall IEP Intelligent Event Processing
EDA With Glassfish ESB Jfall IEP Intelligent Event ProcessingEugene Bogaart
 
Glassfish Overview 29 Oktober 2009
Glassfish Overview 29 Oktober 2009Glassfish Overview 29 Oktober 2009
Glassfish Overview 29 Oktober 2009Eugene Bogaart
 
Gf University 27may09 Amersfoort
Gf University 27may09 AmersfoortGf University 27may09 Amersfoort
Gf University 27may09 AmersfoortEugene Bogaart
 
Glass Fish V3 University Amers May2009
Glass Fish V3  University Amers May2009Glass Fish V3  University Amers May2009
Glass Fish V3 University Amers May2009Eugene Bogaart
 
Glassfish Overview Fontys 20090520
Glassfish Overview Fontys 20090520Glassfish Overview Fontys 20090520
Glassfish Overview Fontys 20090520Eugene Bogaart
 
Glassfish Overview for Sogeti 20090225
Glassfish Overview for Sogeti 20090225Glassfish Overview for Sogeti 20090225
Glassfish Overview for Sogeti 20090225Eugene Bogaart
 

Plus de Eugene Bogaart (8)

What is new and cool j2se & java
What is new and cool j2se & javaWhat is new and cool j2se & java
What is new and cool j2se & java
 
Java Enterprise Edition 6 Overview
Java Enterprise Edition 6 OverviewJava Enterprise Edition 6 Overview
Java Enterprise Edition 6 Overview
 
EDA With Glassfish ESB Jfall IEP Intelligent Event Processing
EDA With Glassfish ESB Jfall IEP Intelligent Event ProcessingEDA With Glassfish ESB Jfall IEP Intelligent Event Processing
EDA With Glassfish ESB Jfall IEP Intelligent Event Processing
 
Glassfish Overview 29 Oktober 2009
Glassfish Overview 29 Oktober 2009Glassfish Overview 29 Oktober 2009
Glassfish Overview 29 Oktober 2009
 
Gf University 27may09 Amersfoort
Gf University 27may09 AmersfoortGf University 27may09 Amersfoort
Gf University 27may09 Amersfoort
 
Glass Fish V3 University Amers May2009
Glass Fish V3  University Amers May2009Glass Fish V3  University Amers May2009
Glass Fish V3 University Amers May2009
 
Glassfish Overview Fontys 20090520
Glassfish Overview Fontys 20090520Glassfish Overview Fontys 20090520
Glassfish Overview Fontys 20090520
 
Glassfish Overview for Sogeti 20090225
Glassfish Overview for Sogeti 20090225Glassfish Overview for Sogeti 20090225
Glassfish Overview for Sogeti 20090225
 

Dernier

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 

Dernier (20)

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 

Introduction into JavaFX

  • 1. New and Cool: JavaFX Eugene Bogaart Solution Architect Sun Microsystems 1
  • 3. JavaFX Vision JavaFX is the platform for creating and delivering Rich Internet Applications across all the screens of your life JavaFX is Powered by Java Sun Confidential: Internal Only 3
  • 4. A Basic Java GUI: Not Very Pretty Sun Confidential: Internal Only 4
  • 5. Samples • Vancouver Medal app • Simon's Book example • JavaFX Widget set Sun Confidential: Internal Only 5
  • 6. JavaFX Platform Architecture FX Applications Device FXScript Media Specific Core Scene runtime WebKit Players APIs APIs Graph Ad FX Player Media VM Compiler Installer Codecs Device OS Sun Confidential: Internal Only 6
  • 7. JavaFX Script Basics • Declarative, statically-typed scripting language • Facilitates rapid GUI development • Many cool, interesting language features • Runs on the Java Virtual Machine • Deployment options same as Java programs > Applet, Application, WebStart • Fully utilizes Java class libraries behind the scenes • For content designers and media engineers Sun Confidential: Internal Only 7
  • 8. Basic JavaFXScript Class Syntax is Java-like with shades of JavaScript class HelloWorldNode extends CustomNode { public var text:String; public override function create(): Node { return Text { x: 10, y: 50 font: Font { size: 50 } content: “Hello World” } }; } Sun Confidential: Internal Only 8
  • 9. Class Definition Address class definition: The Address class declares street, city, state, and zip instance variables all of type String class Address { var street: String; var city: String; var state: String; var zip: String; } Sun Confidential: Internal Only 9
  • 10. Declaring an Object Literal • In the JavaFX Script language, an object instance can be created with an object literal (unlike 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"; } Sun Confidential: Internal Only 10
  • 11. Nested Literal Declaration • 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"; } } Sun Confidential: Internal Only 11
  • 12. Sequences • Sequences var time:Duration[] = [1s, 5s, 10s]; var days = [1..31]; • Insert, delete, membership and reverse insert 20s into time; delete 31 from days; var revDays = Sequences.reverse(days); • Slice via range and predicate var oddDays = days[n | (n mod 2) == 1]; var firstThree = time[0..<3]; Sun Confidential: Internal Only 12
  • 13. Binding • Dependency-based evaluation of expressions • Enables expression of dynamic data relationships var x = 10; var y = bind x + 100; x = 50; y == 150; // true • Any expression can be bound > conditionals, loops, functions, etc... • bind “with inverse” when 2-way is needed Sun Confidential: Internal Only 13
  • 14. Bound var scale = 1.0; // makePoint is a bound function. It will be invoked even when a value of // non-function-arugment such as scale changes. If you remove bound // keyword, then, the change of the value of scale does not invoke the function bound function makePoint(xPos : Number, yPos : Number) : Point { Point { x: xPos * scale y: yPos * scale } } class Point { var x : Number; var y : Number; } Sun Confidential: Internal Only 14
  • 15. Bound (cont) // Code in the previous slide // The bind keyword, placed just before the invocation of // makePoint, binds the newly created Point object (pt) to the outcome of the // makePoint function. var myX = 3.0; var myY = 3.0; def pt = bind makePoint(myX, myY); println(pt.x); // 3.0 myX = 10.0; println(pt.x); // 10.0 scale = 2.0; println(pt.x); // 20.0 Sun Confidential: Internal Only 15
  • 16. Trigger • Triggers facilitates the catching and handling of data modification events. var x : String; var y = bind x; • Can be re-written using triggers in a equivalent manner: var x : String on replace { y = x; } • Trigger for tracing variable changes: var x : String on replace { y = x; Println(“X == {x}”); } Sun Confidential: Internal Only 16
  • 17. Many more Why Declarative Syntax for Building Sun Confidential: Internal Only 17
  • 18. 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. Sun Confidential: Internal Only 18
  • 19. Scene Graph Nodes: javafx.gui.* Node ComponentView* Group Shape ImageView HBox Arc HBox MediaView VBox Circle VBox CubicCurve Ellipse Transform Line Affine Path Rotate Polygon Scale Polyline Shear QuadCurve Translate Rectangle Text Sun Confidential: Internal Only 19
  • 20. Effects: javafx.gui.effects.* Effect DisplacementMap Blend PerspectiveTransform Light Bloom InvertMask Glow ColorAdjust DistanceLight Lighting SepiaTone PointLight Flood Reflection SpotLight GaussianBlur Shadow MotionBlur InnerShadow DropShadow Sun Confidential: Internal Only 20
  • 21. Effects • Effects On Images Demo Sun Confidential: Internal Only 21
  • 22. Some Effects Supported In JavaFX effect: SepiaTone { level: 0.5 } effect: Glow { level: 0.7 } Original image effect: GaussianBlur { input: SepiaTone { level: 0.5 } radius: 10.0 } effect: Reflection { fraction: 0.7 } Sun Confidential: Internal Only 22
  • 23. Lighting Effect effect: Lighting{ surfaceScale: 7 light: DistantLight { azimuth: 90 elevation: 30 } } effect: Lighting{ surfaceScale: 7 light: SpotLight { x: 0 y :0 z: 50 pointsAtX: 10 pointsAtY: 10 pointsAtZ: 0 } } Sun Confidential: Internal Only 23
  • 24. Animation • Timelines handles the animation in JavaFX • Timelines are first-class citizen in the language along with the duration time constants (1s, 10s) • They can have one or more KeyFrames • Functions: start(), stop(), pause(), resume() • Properties: autoReverse, repeatCount, toggle Sun Confidential: Internal Only 24
  • 25. Example – Defining Key Frames Timeline { keyFrames: [ KeyFrame { time: 0s values: [ radius => 30 ] } KeyFrame { time: 5s values: [ radius => 300 tween Interpolator.LINEAR ] } Key value How the value changes over time ] } radius = 30 radius = 300 0s 1s 2s 3s 4s 5s 6s Keyframes Sun Confidential: Internal Only 25
  • 26. Animation • Animating TimeLines Sample Sun Confidential: Internal Only 26
  • 27. JavaFX Media Design Goals • Media Playback is of primary importance • Simple API: only a few lines of coded needed • Cross platform A/V format required • Native support also desirable > “Mash ups” > Viewing local media • Zero Configuration plug in support > Drop in format support • Going beyond rectangular video > Lightweight rendering Sun Confidential: Internal Only 27
  • 28. Streaming Media • Simple Stream Media Sample Sun Confidential: Internal Only 28
  • 29. JavaFX Media Example var media = Media{source: ”movie.mov”}; var player = MediaPlayer{media: media, autoPlay:true}; var mediaView = MediaView{ // To enable audio only, don't create MediaView MediaView{ mediaPlayer: player, onMouseClicked: function(e) { // Play/pause control if (player.paused) { player.play(); } else { player.pause(); } } rotate: 90; // Rotate } Sun Confidential: Internal Only 29
  • 30. JavaFX NetBeans IDE Plugin • Available for NetBeans 6.1 and later > Current NB=6.8 • Supports conventional development cycle > edit, compile, run, test > Also has preview mode (avoid compile/run) • Specific project type for JavaFX • Automatic installation of JavaFX SDK • Editor supports code completion, drag and drop of components Sun Confidential: Internal Only 30
  • 31. Further Information • openjdk.java.net • www.javafx.com • www.sun.com/javafx • openjfx.org • learnjavafx.typepad.com Sun Confidential: Internal Only 31
  • 32. More info Sun Confidential: Internal Only 32
  • 33. Summary • Java continues to evolve • JDK7 driving changes in the platform • JavaFX providing a RIA platform built on Java • More to come... Sun Confidential: Internal Only 33