JavaFX Advanced

45
JavaFX Paul Bakker

description

Presentation about the features of JavaFX. See how to use video, different deployment types, JavaScript integration, annimations and more. Demo's not included.

Transcript of JavaFX Advanced

Page 1: JavaFX Advanced

JavaFXPaul Bakker

Page 2: JavaFX Advanced

About me

Paul Bakker Trainer Info Support NLJUG speaker Java Magazine author

EJB 3JSFSeamJavaFXSpringHibernateFlex

Page 3: JavaFX Advanced

Outline

Video

Deployment

Mobile

Production Suite

Web Services API

Page 4: JavaFX Advanced

One minute introJavaFX is Sun’s RIA platform

Competes with Flex, Flash and Silverlight

A new language

JavaFX Script

Declarative UI programming

Page 5: JavaFX Advanced

Platform SupportMacOSWindowsLinux / Solaris on the way

Page 6: JavaFX Advanced

Runtimes

JRE 6 update 11 recommended

Performance

Drag-able applets

Stability

Download size

Runs on JRE 5

Page 7: JavaFX Advanced

Video

Native codec supportCross platform FLV

Page 8: JavaFX Advanced

Native codecsCore Video

Video: H.261, H.263, and H.264 codecs

MPEG-1, MPEG-2, and MPEG-4 Video file formats and associated codecs (such as AVC)Sorenson Video 2 and 3 codecs Audio: AIFF, MP3, WAV,MPEG-4 AAC Audio (.m4a, .m4b, .m4p), MIDI

Page 9: JavaFX Advanced

Native CodecsDirectShow

Video: Windows Media Video,H264 (as an update)

Audio: MPEG-1, MP3, Windows Media Audio, MIDI

Page 10: JavaFX Advanced

FXM

Video: On2 VP6 Audio: MP3

Page 11: JavaFX Advanced

Using Video

MediaMediaPlayer

MediaView

Page 12: JavaFX Advanced

varmedia=Media{source:"file:///Users/paul/21.avi"}

varplayer=MediaPlayer{media:mediaautoPlay:true}

Media

MediaPlayer

Page 13: JavaFX Advanced

Stage{title:"Videodemo"width:bindmedia.widthheight:bindmedia.heightscene:Scene{content:MediaView{mediaPlayer:player}}}

MediaView

Page 14: JavaFX Advanced

MediaSimpleVideoVideoPerformance

Page 15: JavaFX Advanced

CSS

Skins

Styling components using external style sheets

Page 16: JavaFX Advanced

CSS

Skins

Styling components using external style sheets

Not a standard feature yet!

Page 17: JavaFX Advanced

A skinnable button

publicclassButtonextendsControl{publicvarlabel:String;init{skin=ButtonSkin{}}}

Page 18: JavaFX Advanced

The SkinpublicclassButtonSkinextendsSkin{publicvarbackgroundColor:Color=Color.BLACK;publicvarcolor:Color=Color.WHITE;publicvararcHeight:Number=20;publicvararcWidth:Number=20;

varbutton:Button=bindcontrolasButton;

init{scene={....//Drawthecontrol’sUI

Page 19: JavaFX Advanced

The CSS

Button{backgroundColor:green;color:black;arcHeight:0;arcWidth:0;}

Button.rounded{arcHeight:20;arcWidth:20;}

Page 20: JavaFX Advanced

DeploymentDesktop, Browser and Mobile

No code changes

Device specific hooks

Page 21: JavaFX Advanced

Oneroot object

Stage{title:"Applicationtitle"width:250height:80scene:Scene{content:[]}}

Page 22: JavaFX Advanced

Applet<scriptsrc="http://dl.javafx.com/dtfx.js"></script><script>javafx({archive:"JavaFXDemo.jar",draggable:true,width:800,height:600,code:"awsdemo.AmazonBrowser",name:"JavaFXDemo"});</script>

Page 23: JavaFX Advanced

Applet hooks

extensions:[AppletStageExtension{onDragStarted:function(){}}]

Specify drag behavior

Page 24: JavaFX Advanced

JavaScript integration

Call JavaScript from Java

varapplet=FX.getArgument("javafx.applet")asjava.applet.Applet;

varwindow:JSObject=JSObject.getWindow(applet);

window.call("showProduct",[product.name,product.description]);

Page 25: JavaFX Advanced

<script>function showProduct(name, description) {

var titleElement = document.getElementById('productTitle'); titleElement.innerHTML = name;

var detailsElement = document.getElementById('productDetails'); detailsElement.innerHTML = description; }</script>

<h1 id="productTitle"></h1><div id="productDetails"></div>

Page 26: JavaFX Advanced

Frame styles

Decorated (standard)

Undecorated

Transparent

Page 27: JavaFX Advanced

Applets WindowStylesJavaScriptDemo

Page 28: JavaFX Advanced

Animation

Timeline

Set of frames

Controls playing

KeyFrame

A moment in time

Page 29: JavaFX Advanced

Defining KeyFramesKeyFrame { time: 1s values: [ imageView.x => 100 tween Interpolator.EASEBOTH imageView.y => 100 tween Interpolator.EASEBOTH ]

action: function() { println(“Action executed”); }}

Page 30: JavaFX Advanced

Transitions

Predefined animations

FadeTransition

ParallelTransition

PathTransition

PauseTransition

RotateTransition

ScaleTransition

Page 31: JavaFX Advanced

Animation

Page 32: JavaFX Advanced

MobileFebruary 2009

Write Once, Run Everywhere

Page 33: JavaFX Advanced

Not supported

Effects (reflection etc.)

Opacity

Video

Page 34: JavaFX Advanced

Mobile

Page 35: JavaFX Advanced

Production Suite

Designer => Developer

Workflow

Page 36: JavaFX Advanced

Web Services

HTTPRequest

REST style services

PullParser

JSON & XML

Page 37: JavaFX Advanced

Web Service call

Enqueue HTTP Request

Handle input

Parse input

Handle ‘events’

Page 38: JavaFX Advanced

XML PullParserif(event.qname.name=="Item"andevent.type==PullParser.START_ELEMENT){product=newProduct();}

elseif(event.qname.name=="Title"){product.title=event.text;}

elseif(event.qname.name=="Item"andevent.type==PullParser.END_ELEMENT){insertproductintoproducts;}

Page 39: JavaFX Advanced

Web ServicesAmazon Demo

Page 40: JavaFX Advanced

Effects

Effect property at any Node

Including text, video, and images

Lots of standard effects

e.g. DropShadow, Blur, InnerShadow, Reflection, SepiaTone

Page 41: JavaFX Advanced

Current problems

No components!

No layout managers

No selectable text

Page 42: JavaFX Advanced

Road Map

Februari 2009 => JavaFX Mobile 1.0

JavaOne 2009 => Announcing JavaFX 2.0

Winter 2009 => JavaFX 2.0

Complete new component suite

Swing end-of-life?

Page 43: JavaFX Advanced

JavaFX.com

Page 44: JavaFX Advanced

The RIA war

Page 45: JavaFX Advanced

Shameless plug ;-)

2 day JavaFX course now available

Full JavaFX Script language coverage

Video

Web Services

Animations

Custom components

Production Suite