tlcpowertalk - qcon london 2020...enterprise javafx for the web platform -peter pilgrim java...

48
www.devoxx.com TLCPowerTalk.com Communication for Management Professionals QCon London 2009 (c) 12 March by Peter Pilgrim 1

Upload: others

Post on 25-Apr-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

www.devoxx.com

TLCPowerTalk.com

Communication forManagement Professionals

QCon London 2009 (c) 12 March by Peter Pilgrim 1

Page 2: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

Peter PilgrimJAVAWUG.com,Sun Java Champion, Lloyds TSB Corporate Markets

QCon London 2009 (c) 12 March by Peter Pilgrim 2

Page 3: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

Enterprise JavaFX for the Web Platform -Peter Pilgrim

Java Modularity OSGi – Neil Bartlett

Groovy and Grails – Graeme Rocher

Spring Today and Tomorrow – Rod Johnson

Data Grid Design Pattern – Brian Oliver

QCon London 2009 (c) 12 March by Peter Pilgrim 3

Page 4: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

Peter PilgrimJAVAWUG.com,Sun Java Champion, Lloyds TSB Corporate Markets

QCon London 2009 (c) 12 March by Peter Pilgrim 4

Page 5: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

QCon London 2009 (c) 12 March by Peter Pilgrim 5

Page 6: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

Rich Internet Applications and JavaFX Deployment of JavaFX Clients Integration Client with Server The Way Forward

QCon London 2009 (c) 12 March by Peter Pilgrim 6

Page 7: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

Visual Metaphors

HTML Independent

Downloadable Runtime

Graphics Engine

Rich Media

QCon London 2009 (c) 12 March by Peter Pilgrim 7

Page 8: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

QCon London 2009 (c) 12 March by Peter Pilgrim 8

Page 9: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

Object oriented scripting language Stage Scene MediaView MediaPlayer Media

QCon London 2009 (c) 12 March by Peter Pilgrim 9

Page 10: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

Leverages the Java Platform Statically Compiled DSL for the JVM (SDK) Runtime for Desktop & Mobile RIA Java Media Component API Java 6 update 12 JDK / JRE

QCon London 2009 (c) 12 March by Peter Pilgrim 10

Page 11: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

Stage – container for scene (JFrame, JApplet)

Desktop profile supports translucency

Mobile profile specialised UI container

Scene – container for the UI scenegraph

QCon London 2009 (c) 12 March by Peter Pilgrim 11

Page 12: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

Group

Scene

CustomNode

Group

Circle

PolyLine

Swing Label

Image View

MediaView

QCon London 2009 (c) 12 March by Peter Pilgrim 12

Page 13: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

QCon London 2009 (c) 12 March by Peter Pilgrim 13

Page 14: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

Expression based scripting language Declarative and Object Oriented Based on Chris Oliver ideas from JavaScript,

Miranda, SQL and Lisp However, integrates with Java

QCon London 2009 (c) 12 March by Peter Pilgrim 14

Page 15: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

abstract after and as assert at attribute beforebind bound break catch class continue defdelete else exclusive extends false finally first for from function if import indexof in initinsert instanceof into inverse last lazy modnew not null on or override package postinitprivate protected public-init public public-read replace return reverse sizeof static step super then this throw trigger true try tweentypeof var where while with

QCon London 2009 (c) 12 March by Peter Pilgrim 15

Page 16: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

No primitives allowed. Wrapped Primitives. Boolean, Character, Byte, Short, Integer,

Long, Number, Float and Double

Number defaults to a Float (for performance)

String, Duration Sequences element[index] Void

QCon London 2009 (c) 12 March by Peter Pilgrim 16

Page 17: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

var red = Rectangle { fill:Color.REDx: 50; y: 50; width: 320 height: 240arcWidth: 24 arcHeight: 24}

var text = Text { x: 100 y: 100 font: Font { size: 64 }content: “The Red\nDevils” }

var stage = Stage { width: 400 height: 300scene: Scene { content: [ red, text ] }style: StageStyle.TRANSPARENT

}

QCon London 2009 (c) 12 March by Peter Pilgrim 17

Page 18: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

Live coding Example NetBeans 6.5 Transparency

QCon London 2009 (c) 12 March by Peter Pilgrim 18

Page 19: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

// A sequence of Strings

[ “red”, “green”, “gold” ]

// A sequence of Integer

[ 21, 31, 44, 65, 95 ]

// Range of Integers from 0, 1, 2 to 100

[0 .. 100]

// Range of Integers from 0, 1, 2 to 99

[0 .. <100]

QCon London 2009 (c) 12 March by Peter Pilgrim 19

Page 20: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

var fruits[] = { “Apple”, “Pear”, “Orange” };

// Prints “First element is AppleFX.println( “First element is {fruits[0]}” );

// Prints 3FX.println( sizeof fruits )

var empty[];// Prints 0FX.println( sizeof empty );

QCon London 2009 (c) 12 March by Peter Pilgrim 20

Page 21: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

Nested sequences are automatically flattened

var seq = [ [ 1,2,3, [4,5,6] ], [7, 8, 9] ];

for ( e in seq ) {

FX.println( “{indexof e}-{e}” );

}

// Prints 0-1 1-2 2-3 3-4 4-5 5-6 6-7 7-8 8-9

QCon London 2009 (c) 12 March by Peter Pilgrim 21

Page 22: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

var names=[ ”Khan”, ”Bush Jr”];

insert “Obama” into names;

// [ “Khan”, “Bush Jr”, “Obama” ]

insert [ “Reagan”, “Bush Sr” ] before names[0];

// [ “Reagan”, “Bush Sr”, “Khan”, “Bush Jr”, “Obama” ]

delete names[2]; delete “Khan” from names;

// [ “Reagan”, “Bush Sr”, “Bush Jr”, “Obama” ]

insert “Clinton” after names[1];

QCon London 2009 (c) 12 March by Peter Pilgrim 22

Page 23: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

QCon London 2009 (c) 12 March by Peter Pilgrim 23

foo : Float bar: String

var foo: Float = 3.14596527;

var bar: String = bind “bar={foo}”;

FX.println(bar); // bar=3.141596527

foo = 27.471;

FX.println(bar); // bar=27.471

Page 24: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

var x = 7 on replace oldValue {

FX.println("x was {oldValue} and is now: {x}")

};

// Prints x was 7 and is now: 12

x = 12;

QCon London 2009 (c) 12 March by Peter Pilgrim 24

Page 25: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

var data: Float[] = {10.2, 74.4, 82.7 } on replace oldValue[firstIdx .. lastIdx] = newElements {

println("replaced {oldValue}[{firstIdx}..{lastIdx}] by {newElements} yielding {data}")

};

// Prints “replaced [10.2, 74.4, 82.7]{4..3} by 3.14 yielding [10.2, 74.4, 82.7, 3.14 ]

insert 3.14 into data; // Prints “replaced [10.2, 74.4, 82.7, 3.14]{2..2} by null

yielding [10.2, 74.4, 3.14 ]delete data[2];

QCon London 2009 (c) 12 March by Peter Pilgrim 25

Page 26: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

public class Dimension2D {

public var width: Float; public var height: Float;

public function override toString() {

return "Dimension2D( width={width},

height={height} )";

}

// Object literal syntax

var prefSize = Dimension2D{ width: 640 height: 480 };

prefSize.width = 1920;

prefSize.height = 1200;

QCon London 2009 (c) 12 March by Peter Pilgrim 26

Page 27: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

Live Coding Example RGB Color Mixer

QCon London 2009 (c) 12 March by Peter Pilgrim 27

Page 28: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

HBox – Horizontal layout container

VBox – Vertical layout container

Custom layouts

Write your own

See JFXtras Project for Grid and MigLayout

QCon London 2009 (c) 12 March by Peter Pilgrim 28

VBox

1

2

3

HB

ox

1 2 3

Page 29: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

My Personal Layouts

Perspective Tabbed Pane

Animated Tabbed Pane

MigLayout Example

QCon London 2009 (c) 12 March by Peter Pilgrim 29

Page 30: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

QCon London 2009 (c) 12 March by Peter Pilgrim 30

Timeline

Key Frame (0s)

Key Value

Interpolator

Key Frame (1s)

Key Value

Interpolator

0..*0..*

1..*1..*

Page 31: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

var t1 = Timeline {

repeatCount: Timeline.INDEFINITE

keyFrames: [

KeyFrame {

time: 0s

values: [ angle => 180, xpos => 0 ]

},

KeyFrame {

time: 4s

values: [ angle => -180, xpos => 400

tween Interpolator.EASEBOTH ]

}

]

};

t1.play();

QCon London 2009 (c) 12 March by Peter Pilgrim 31

Page 32: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

Here is one I partially prepared earlier.

JavaFX Timeline

QCon London 2009 (c) 12 March by Peter Pilgrim 32

Page 33: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

Animations for a single purpose

Translation/Scale/Rotation/Fade

Animation along a path

Containers for complex animation

▪ SequentialTransition

▪ ParallelTransition

▪ PauseTransition

QCon London 2009 (c) 12 March by Peter Pilgrim 33

Page 34: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

TransitionsFadeTranslateRotateScaleParallelSequence

QCon London 2009 (c) 12 March by Peter Pilgrim 34

Page 35: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

QCon London 2009 (c) 12 March by Peter Pilgrim 35

Page 36: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

Javafxpackager to generate a JAR Write a Java Network Launching Protocol (JNLP) file Upload the JARS and JNLP file On the client side, theJavaFX Runtime will

download the appropriate JRE runtime e.g. “Consumer JRE”

QCon London 2009 (c) 12 March by Peter Pilgrim 36

Page 37: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

Java Kernel

Sun Microsystems modularised JRE

Java Quickstarter Deployment Kit Accelerated Graphics Draggable Applets

QCon London 2009 (c) 12 March by Peter Pilgrim 37

Page 38: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

QCon London 2009 (c) 12 March by Peter Pilgrim 38

Page 39: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

FX Libraries support XML / JSON Parsers Asynchronous HTTP requests Invoke RESTful Web Services

QCon London 2009 (c) 12 March by Peter Pilgrim 39

Page 40: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

def request = HttpRequest {location: “http://api.flick.com/.../rest/?method=...” method: HttpRequest.GET

onInput: function( is: InputStream ) {try {

// parse the content} finally {

is.close();}

}}

// Start the request, executes on the EDTrequest.enqueue();

QCon London 2009 (c) 12 March by Peter Pilgrim 40

Page 41: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

Use the javafx.data.PullParser to parse XML into data objects

Or how about using Codehaus XStream in JavaFX? Yes we can!

QCon London 2009 (c) 12 March by Peter Pilgrim 41

Page 42: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

QCon London 2009 (c) 12 March by Peter Pilgrim 42

Page 43: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

HTML Web Pages Applets JavaScript / DOM

QCon London 2009 (c) 12 March by Peter Pilgrim 43

Page 44: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

Corporate packagement of RIA (JavaFX) application

See WidgetFX (BSD license)

QCon London 2009 (c) 12 March by Peter Pilgrim 44

Page 45: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

Lack of traction on the JSR 186 and 286 portal servers

Lack of successful models may drive RIA portals based on Flex and/or JavaFX

QCon London 2009 (c) 12 March by Peter Pilgrim 45

Page 46: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

QCon London 2009 (c) 12 March by Peter Pilgrim 46

Page 47: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

Easy and Accessible Rich Media Bindings, Triggers and Sequences Write YOUR JavaFX applications today!

Deploy to desktop, target mobile phones In the Summer 2009 expect JavaFX 1.5

QCon London 2009 (c) 12 March by Peter Pilgrim 47

Page 48: TLCPowerTalk - QCon London 2020...Enterprise JavaFX for the Web Platform -Peter Pilgrim Java Modularity OSGi –Neil Bartlett Groovy and Grails –Graeme Rocher Spring Today and Tomorrow

My Email peter.pilgrim at gmail dot com My Blog roll http://jroller.com/peter_pilgrim JavaFX main site http://javafx.com/ NetBeans 6.5 IDE

http://www.netbeans.org/features/javafx/index.html JFXtras Project http://code.google.com/p/jfxtras/ JavaFX Language Reference Docs

http://openjfx.java.sun.com/current-build/doc/reference/JavaFXReference.html

JAVAWUG http://jroller.com/javawug

QCon London 2009 (c) 12 March by Peter Pilgrim 48