Javafx Overview
Total Page:16
File Type:pdf, Size:1020Kb
JavaFX Overview Peter Doschkinow Software Architekt Sun Microsystems 1 1 Agenda • What is and Why JavaFX • Key features • Things you can build with JavaFX • JavaFX platform architecture • JavaFX script • Content of JavaFX 1.1 2 RIA Market Trends • Browser based applications reach their limits regarding complexity and performance • Many vendors and content providers are looking for independence on browser and search engines > their default settings could be a competitive disadvantage > not willing to pay to contact their customers, direct contact is needed • Client applications are becoming more expressive and visually rich • Client applications are being designed in addition to being programmed 3 > cooperation of graphic designer + application developer RIA today omnipresent but fragmented 4 Java Omnipresence Java Everywhere > 6 Billion Java-Enabled Devices 2.5 Billion Java-Enabled Phones 3.5 Billion Java Card 20 Million Java Set-top Boxes 800 Million Java Desktops 180 Operators Deploying Java Content 6 Million Developers 5 RIA Platform Requirements • accessible for any Internet user > on desktops, mobile phones and new devices • high performance, easy-to-use and accessible for design professionals • reuse of available know-how and IT-infrastructure • free and open development environment 6 JavaFX Vision JavaFX is THE platform for creating and delivering Rich Internet Applications (RIA) across all the screens of your life JavaFX is Powered by Java 7 JavaFX Key Features •One-stop expressive RIA platform for all screens: > Build engaging visual experiences across desktop, browser and mobile with a unified development and deployment model. •Broadest market reach: > Distribute RIAs easily across billions of devices with the power of Java. •Powerful runtime and API: > Leverage the extreme ubiquity, power, performance and security of the Java runtime. 8 Key Features (Continued) • Designer-developer workflow: > Dramatically shorten your production cycle for design and development. • Break free from the browser: > Drag-and drop a JavaFX application from the browser to deploy to the desktop. • Java technology compatibility: > Preserve your investment by enabling the use of any Java library within a JavaFX application. 9 Demo • WORA in action • Running a JavaFX application on the desktop and on the mobile without changing a single line of code 10 Things you can build with JavaFX •Cross-Browser Video playback •Interactive and immersive business applications •Mash-ups with REST based web services •Applications that run across the browser, desktop, mobile and more! 11 Simple Video Player •Incorporating video in your application is as simple as creating an instance of this component, setting a few variables and including a link to your video source. • 12 3-D Display Shelf With the PerspectiveTransform •The PerspectiveTransform built into JavaFX can be used to easily create 3-D effects 13 Flying Saucer •The new out-of-process Java applet plugin in Java SE 6 update 10 enables you to make applets which can run outside of the browser. 14 JavaFX Platform Architecture Applications and Services Application Framework Authoring Tools Desktop TV Mobile Developer Runtime Runtime Runtime Tools Mobile Desktop TV Extensions Extensions Extensions Designer Tools Common Platform Java Platform: Java SE, JavaME 15 JavaFX Components • JavaFX Script – the language • JavaFX Runtimes: Desktop/Web, Mobile, TV > 1.5 MB jar (700 KB packed), dynamically downloaded, cached, and updated as necessary (i.e. “no-hassle deployment”) • JavaFX applications > In jar file(s), loaded via class loader > Standalone, via Java Web Start, as Applet, or mobile app • JavaFX Tools > FX Script compiler and runtime tools, IDE plug-in, designer tools, and graphics-, media-, web services-, and rich text libraries 16 Java SE 6u10 – Consumer JRE • Features for better performance & experience > better support for applets (“New Plugin”) > simpler installation (“Deployment Toolkit”) > significantly reduced download size (“Java Kernel” - modularized JRE) > quicker start-up(“Java Quickstarter”) > new windows rendering pipeline (“DirectX v9”) > new Look & Feel (“Nimbus”) > better support for JavaFX > Support für Translucent/Shaped Windows, V-Synced Double Buffering • current version is JRE 1.6.0_12 > 17 many performance improvements JavaFX Mobile • Available now: NetBeans 6.5 with JavaFX 1.1 Plugin > Includes final version of JavaFX Mobile and emulator • Unified development > Create cross-platform applications: Use JavaFX Common Platform > Leverage mobile-specific features: Use JavaFX Mobile Elements and/or mobile-specific JSR APIs • Commitment from vendors > Sony-Ericsson, LG Electronics 18• Commitment from carriers: Orange, Sprint JavaFX Mobile Application Architecture Java FX Mobile Application bile Mo JavaFX Language Runtime CLDC + MIDP + MSA • Application deployed as Midlets • Full access to all FX and device features • Language runtime is common to all platforms 19 Mobile vs. Desktop p n le skto i De ommo ob • Common profile C M • Platform specific APIs > Performance > Capabilities • Mobile specific APIs include e.g.: > SMS send and receive > Embedded camera access > Persistent data storage > Contact list access 20 Why Separation of Roles between Designers and Developers • Combining graphics directly with code is great for small projects and encapsulated components • However - for large applications (complex graphics, many screens, bigger teams) separation of graphics and code is required • Designers and developers need to work on graphics and code as separate parts in independent iterations • The tooling needs to assure a seamless integration of the both parts at any time 21 JavaFX Workflow Visual Designer Content developer Java FX Mobile App Binary JavaFX Mobile g in g cka Java FX TV Pa J App Binary Visual ava ng F gi X Scr ka JavaFX TV A Pac sse i t pt s cod n o Pa lati ck e mpi ag in Co g Java FX Source Application Java FX Desktop App Binary JavaFX Tools JavaFX Desktop / Consumer JRE 22 JavaFX Tool Chain Media Assets Assets Integrated Emulated By Created By Transformed By Into IDEs (If Required) Adobe Illustrator JavaFX Plug-in for IDEs Adobe Photoshop JavaFX JavaFX Production Mobile Suite JavaFX Emulator On2 Flix Compiler Encoders (JavaFX File Format, VP6 and MP3) Adobe CS3 rd (Flash and 3 Party Flash Video, JavaFX 1.5) RAD Tool (Open Source) 23 JavaFX Deployment Options Desktop • using 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). • for desktop applications > provisioning through the browser: just drag&drop on the desktop > possible through new Java Plugin architecture since JDK 1.6u10 > JavaFX runtime is a chached JNLP extension 24 JavaFX Deployment Options Mobile • OTA (Over-The-Air) > Possible to prototype on in-the-market phones > Lower performance > Bigger storage footprint (bigger downloads) > Demonstration purposes only • Embedded > Better platform integration possibilities > Ability to leverage all target device capabilities (i.e. hardware acceleration) > Better performance > Smaller storage footprint 25 > Better developer experience JavaFX Script • Declarative, statically-typed scripting language • Facilitates rapid GUI development • Supports multimedia and visual effects • Runs on the JVM • Deployment options same as Java programs • Full access to Java class libraries • Also for content designers and Media engineers 26 Variables, Constants • Java String str = “hello”; // Type name = init_value final double PI = 3.14; // “final” keyword => unmodifiable • JavaScript var str = “hello”; // “var” is a keyword const PI = 3.14; // “const” is a keyword • JavaFX var str = “hello”; // “var” is a keyword var str : String = “hello”; // optionally specify type def PI = 3.14; // “def” keyword => unmodifiable 27 Primitive Types • Java > char, byte, short, int, long, float, double, boolean > void (as return type) • JavaScript > Number, boolean, string, null, undefined • JavaFX > Value types – non-null default value, immutable types > String, Number, Integer, Boolean, Duration > Void (as return type) 28 String Literals • Java > “This is a String” • JavaScript > 'single-quoted string' > “double-quoted string” • JavaFX > “double quoted like Java” > 'single quoted too works like JavaScript!' > “x is {x}” // string with embedded expressions 29 Expressions • JavaFX is an expression rich language • Block are expressions // block is evaluated and last expression “33” is assigned to “v” var v = { println(“hello”); 33 } • “if” is expression var str = if (x mod 2 == 0) then “even” else “odd” • while expression • break, continue, return expression • try .. catch .. finally, throw expression 30 Functions • Java No free standing functions, use static methods • JavaScript function Hello() { alert(“hello“); // alert is built-in } • JavaFX function Hello(str) { println(“hello”); // println is built-in } 31 Functions - contd. • JavaScript – anonymous functions, function values // function valued variable var func = function (x) { alert (“x = “ + x); } func(10); • JavaFX // function valued variable var func = function (x) { println(“x = {x}”); } func(10); 32 Classes • JavaFX class Person { // instance variables are variables inside classes var name: String; var likes: String; // methods are functions with classes public function hello() { println(“Hello, I'm {name}”); } 33 } JavaFX Object Creatation