JavaFX Overview

  • View
    120

  • Download
    8

Embed Size (px)

DESCRIPTION

Short overview on JavaFX basic concepts.

Text of JavaFX Overview

  • 1. JavaFX overview Silveira Neto Sun Campus Ambassador silveira@sun.com, silveiraneto@gmail.com,2008 Presentation at CEJUG event silveiraneto.netCaf com Tapioca at Christus University

2. Agenda WhatisJavaFXDemosJavaFXFramework JavaFXScript WhereToGo Fireworks photo by Darrell Taylor at http://flickr.com/photos/d4rr3ll/300075196/ 3. What is JavaFX? Afamilyofproducts> JavaFXFramework > JavaFX Runtime > JavaFX Mobile > JavaFX Script Who> Developers> Designers What> RIA 4. JavaFX demos 5. Introduction: What is Java FX? JavaFX Script is a highly productive scripting language that enables content developers to create rich media and content for deployment on Java environments. JavaFX Script is a declarative,staticallytypedprogramminglanguage.Ithasfirst class functions, declarative syntax, listcomprehensions, and incrementaldependencybasedevaluation.Itcanmakedirect callstoJavaAPIsthatareontheplatform.https://openjfx.dev.java.net/ 6. JavaFX Overview TheJavaFXtmPlatformisarichclientplatformforcrossscreen richinternetapplications(RIA)andcontent.Itconsistsof commonelements(2Dgraphics,Animation,TextandMedia) anddevicespecificelementsfordesktop,mobileandTV.The JavaFXcommonsetofAPIsallowsourcelevelportabilityof thecommonsetoffunctionalitiesacrossallplatforms supportedbyJavaFX.TheJavaFXRuntimestargetedfor differentdeviceswillensureconsistencyandfidelityfor contentcreatedbasedontheJavaFXCommonAPIs.The JavaFXCommonAPIswillcontinuetoevolvetomatchmore powerful,commoncapabilitiesonthevariousdevicetypes. 7. JavaFX Stack 8. JavaFX Architecture 9. Scene Graph Project Example,javafx.scene.geometry> Ellipse> Polygon> Polyline > Line> Arc> Circle> Path > ArcTo> ShapeSubtract> PathElement> QuadCurve> HlineTo> DelegateShape> VlineTo> ClosePath> CurveTo> CubicCurve > QuadTo> Shape> ShapeIntersect> LineTo > MoveTo> SVGPath> Rectangle 10. Circle import javafx.scene.geometry.*; import javafx.scene.paint.*;Circle { centerX: 100 centerY: 100 radius: 50 fill: Color.BLACK } 11. Rectangle import javafx.scene.geometry.*; import javafx.scene.paint.*;Rectangle { x: 50 y: 50 width: 200 height: 100 arcWidth: 20 arcHeight: 20 fill: Color.BLACK } 12. Ellipse import javafx.scene.geometry.*; import javafx.scene.paint.*;Ellipse { centerX: 50 centerY: 50 radiusX: 50 radiusY: 25 fill: Color.BLACK } 13. ShapeIntersect import javafx.scene.geometry.*; import javafx.scene.paint.*;ShapeIntersect { fill: Color.BLACK a: Rectangle { width: 100 height: 50 } b: Ellipse { centerX: 100 centerY: 25 radiusX: 50 radiusY: 25} } 14. ShapeSubtract import javafx.scene.geometry.*; import javafx.scene.paint.*;ShapeSubtract { fill: Color.BLACK a: Rectangle { width: 100 height: 50 } b: Ellipse { centerX: 100 centerY: 25 radiusX: 50 radiusY: 25} } 15. Animation Framework javafx.animation> Interpolatable> Interpolator> KeyFrame> KeyValue> SimpleInterpolator> Timeline 16. JavaFX Script Language Declarativesyntax > GUI > Swing > Databinding > Incrementalevaluation Staticallytyped > andcodestructuring,reuse,and encapsulationfeaturesthatenablecreating andmaintainingverylargeprogramsinthe Javaprogramminglanguage. 17. Script Ascriptquot;isoneormoredeclarationsor expressions.import java.lang.System;var ten : Integer = 10; var s = quot;Twice {ten} is {2 * ten}.quot;);// s == Twice 10 is 20. Nomain,classesorfunctionsaremandatory. 18. Classclass Knight {attribute health = 100;attribute strength = 10; function isDead(){return health > 0} function hurt(amount: Integer){health -= amount}} 19. Objectsvar myKnight = Knight {} var megaKnight = Knight {health: 150;strength: 15;} myKnight.hurt(megaKnight.strength); // myKight.health = 85 20. Basic Data Types JavaFXDefault valueJava String java.lang.String Booleanfalsejava.lang.Boolean Number 0java.lang.Number Integer0.0byte,short,int,long,BigInteger Duration N/AN/A 21. String Examplesvar s1 = quot;Javaquot;;var s2 = quot;FXquot;;var s3 = quot;Java{s2}quot;; // s3 = 'Hello Joe'var s4 = quot;{s1}{s2}quot;; // s4 = quot;JavaFXquot; 22. Boolean Examplesvar cool = true;var s = quot;Java{if(cool)quot;FXquot;elsequot;Scriptquot;}quot;;//s = quot;JavaFXquot; var a = true;// a = truevar b = false; // b = falsevar c = a and b; // c = falsevar d = a or b;// d = truevar e = not a; // e = false 23. Duration Examples var t1 = 5ms; // 5 milliseconds var t2 = 10s; // 10 seconds var t3 = 30m; // 30 minutes var t4 = 1h;// 1 hourvar t5 = t1 + t2 + t3 + t4; // 1 hour 30 min 10 secs and 5 millisecs 24. Sequences Examples var x = [1,2,3]; // array initializationinsert 10 into x; // [1, 2, 3, 10]insert 12 before x[1]; // [1, 12, 2, 3, 10]delete 12 from x; // [1, 2, 3, 10]insert [1..10] into x; // [1, 2, 3, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 25. JavaFX Command Line Interface Compiling> javafxcscript.fx Running> javafxscript 26. JavaFX Tools ProjectNile NetBeansIDEJavaFXPlugin YourfavoriteIDE+JavaFXCLI Inkscape > Comingsoon(nextversion) > FileSaveAsJavaFx 27. Java FX Resources JavaFXProjectSite:http://openjfx.dev.java.net > Java.net:DownloadearlyversionsofJavaFX > IDEPlugins,Tutorials,Forums,FAQs > GettingStartedWiththeJavaFXScriptLanguage > JavaFXScript2DGraphicsTutorial > TheJavaFXScriptProgrammingLanguageReference PlanetFXWiki:http://jfx.wikia.com/wiki/Main_Page > OpensourcedocumentationsiteforJavaFX JamesWeaver'sBlog > BestblogaboutJavaFX > http://learnjavafx.typepad.com/ 28. Java FX Resources (more) Sun'sJavaFXSite: > http://www.sun.com/software/javafx/ > http://www.javafx.com > SunMicrosystemsofficialproductpage ChrisOliver'sBlog:http://blogs.sun.com/chrisoliver/ > Latestnews,otherinformalinformation > Sourcecodeforlotsofdemos(SpaceInvaders,Calculator) Myblog:) > http://silveiraneto.net 29. JavaFX Books JavaFXScript:DynamicJavaScriptingfor RichInternet/ClientsideApplication,by JamesL.Weaver,publishedbyApress. DynamischeundinteraktiveJava ApplikationenmitJavaFX,byRalph Steyer,publishedbyAddisonWesley. JavaFX !by , publishedby . 30. References BalloonsphotofromfirstandlastslidesbyJesusSolana > http://flickr.com/photos/pasotraspaso/1408057351/ FireworksphotoatagendabyDarrellTaylor > http://flickr.com/photos/d4rr3ll/300075196/ LotsofJavaOne2008JavaFX'sPresentations > http://developers.sun.com/learning/javaoneonline/ JavaFxPreview1API > http://javafx.com/releases/preview1/docs/api/ Javafx.comVideos > http://www.javafx.com MyYoutubeJavaFXChannel > http://br.youtube.com/user/NetoSilveira JavaFXNetBeansPlugin > http://javafx.netbeans.org/ 31. Open Source University Meetup OSUM > http://osum.sun.com > http://osum.sun.com/group/ufc/ > http://osum.sun.com/group/fchristus > http://osum.sun.com/group/fa7 > http://osum.sun.com/group/cefetce > http://osum.sun.com/group/uva > http://osum.sun.com/group/javafx Enterandcreateyourown 32. Java FX DownloadJavaFX&IDE PluginsforNetbeansor What to Eclipse Do JoinOpenJFXJava.net Project DoJavaFXTutorials ParticipateonJavaFX Forums Createsomethingcool!http://openjfx.dev.java.net 33. Thank you! Silveira Neto Sun Campus Ambassador mail: silveira@sun.com IM/mail: silveiraneto@gmail.comSome rights reserved blog: http://silveiraneto.net download these slides at silveiraneto.net