Helsinki Scala Club 25.4.2013 Punavuoren Ahven S c a l a F X - - PowerPoint PPT Presentation

helsinki scala club 25 4 2013
SMART_READER_LITE
LIVE PREVIEW

Helsinki Scala Club 25.4.2013 Punavuoren Ahven S c a l a F X - - PowerPoint PPT Presentation

Helsinki Scala Club 25.4.2013 Punavuoren Ahven S c a l a F X HelloStage.scala getting the development system up is a h*ll of a work - well skip that! :D c l u d e s . i n e s o f i n c k i n g 1 0 l L a S c


slide-1
SLIDE 1

Helsinki Scala Club 25.4.2013

Punavuoren Ahven

slide-2
SLIDE 2

S c a l a F X

HelloStage.scala

getting the development system up is a h*ll of a work - we’ll skip that! :D

L a c k i n g 1 l i n e s

  • f

i n c l u d e s .

slide-3
SLIDE 3

S c a l a F X

Getting started

Unfortunately ScalaFX is not yet available as i.e. ‘sbt’ dependency. $ hg clone https://code.google.com/p/scalafx/ ... $ export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/ Contents/Home/ $ cd scalafx ... $ sbt clean compile scalafx-demos/run

T h i s i s h

  • w

t

  • g

e t a d e m

  • r

u n n i n g

  • n

O S X w i t h

s c a l a

,

h g

a n d

s b t

f r

  • m

H

  • m

e b r e w a n d O r a c l e J R E 7 i n s t a l l e d . B a s e d

  • n

s t a t e

  • f

S c a l a F X r e p

  • s

i t

  • r

y

  • n

2 5 A p r 2 1 3 .

slide-4
SLIDE 4

S c a l a F X

DEMO

Note: the ‘colorful circles’ demo is pretty intensive of GPU usage. Windows platforms seem to have a way better graphics pipeline than i.e. OS X (or maybe Linux). For other samples, the difference is not as great.

slide-5
SLIDE 5

S c a l a F X

  • New! > Fireworks
  • Animation > Timelines > Interpolator
  • Advanced > Adv Area Audio Chart
  • Advanced > Area Chart
  • Bar > Advanced Bar Chart (show adding points)
  • Pie > Advanced Pie Chart
  • Graphics > Digital Clock
  • Graphics 3D > Xylophone (try hitting some chords!)
  • Media > Advanced media (try full screen)
  • Web > Web view
  • Web > HTML editor
slide-6
SLIDE 6

S c a l a F X

Unfortunately ScalaFX is not yet available as i.e. ‘sbt’ dependency. $ hg clone https://code.google.com/p/scalafx/ ... $ export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/ Contents/Home/ $ cd scalafx $ sbt clean compile run $ sbt package $ ls -al scalafx/target/scala-2.9.3/

  • rw-r--r-- 1 asko staff 1925012 25 Huh 16:56 ./scalafx/target/scala-2.9.3/

scalafx_2.9.3-1.0.0-M4-SNAPSHOT.jar $ cp scalafx/target/scala-2.9.3/scalafx_*.jar <myproject>/lib

N

  • w

h

  • w

t

  • g

e t t h

  • s

e S c a l a v e r s i

  • n

s t

  • m

a t c h ? W h

  • .

. . . ( w

  • r

t h a f u l l w e e k c a m p )

Getting started

slide-7
SLIDE 7

S c a l a F X

Scene graph

The ‘live’ UI are those components that are found within a ‘scene graph’.

scalafx.stage.Stage scalafx.scene.Scene scalafx.scene.Group scalafx.scene.Node

G

  • t

h r

  • u

g h t h e c l a s s e s a t : s c a l a f x / s c a l a f x / s r c / m a i n / s c a l a / s c a l a f x

Yes, what a path!?

slide-8
SLIDE 8

S c a l a F X

Scene graph...

  • Mouse clicks etc. events travel through the scene graph.

=> only objects on the scene graph are ‘live’

Other ScalaFX features...

  • Theming via CSS (just as if the scene graph were HTML)
  • Binding by ’<==’ syntax sugar (which may be unhealthy!)

Problems?

  • ScalaFX API heavily derives from JavaFX objects. Sometimes this shines

through!

  • To study the API one needs to see both the Book / web (Java) and the ScalaFX

headers. = a unified, documented Scala ONLY API would imho be welcome.

Good walk through at: http://code.google.com/p/scalafx/

slide-9
SLIDE 9

S c a l a F X

GUI paradigms

Desktop Web Mobile / touch Games consoles

  • windowed (stretchable) / full screen;

scaled by the user

  • mouse pointer -> hovering -> tooltips
  • full screen only
  • transparencies (alpha blending)
  • visual transitions

Cross pollutation of ideas across paradigms.

slide-10
SLIDE 10

S c a l a F X

GUI paradigms

Desktop Web Mobile / touch Games consoles

  • windowed (stretchable) / full screen;

scaled by the user

  • mouse pointer -> hovering -> tooltips
  • full screen only
  • transparencies (alpha blending)
  • visual transitions

native HTML Qt ScalaFX Fastest speed (but code and test x N) Fastest development (but test and tune x N²) Pretty good (but compile x N and test x N) Awesome! (still test x N)

slide-11
SLIDE 11

S c a l a F X

GUI paradigms

Desktop Web Mobile / touch Games consoles

  • windowed (stretchable) / full screen;

scaled by the user

  • mouse pointer -> hovering -> tooltips
  • full screen only
  • transparencies (alpha blending)
  • visual transitions

native HTML Qt ScalaFX Fastest speed (but code and test x N) Fastest development (but test and tune x N²) Pretty good (but compile x N and test x N) Awesome! (still test x N)

slide-12
SLIDE 12

S c a l a F X

GUI paradigms

Desktop Web Mobile / touch Games consoles

  • windowed (stretchable) / full screen;

scaled by the user

  • mouse pointer -> hovering -> tooltips
  • full screen only
  • transparencies (alpha blending)
  • visual transitions

native HTML Qt ScalaFX Fastest speed (but code and test x N) Fastest development (but test and tune x N²) Pretty good (but compile x N and test x N) Awesome! (still test x N)

slide-13
SLIDE 13

S c a l a F X

GUI paradigms

Desktop Web Mobile / touch Games consoles

  • windowed (stretchable) / full screen;

scaled by the user

  • mouse pointer -> hovering -> tooltips
  • full screen only
  • transparencies (alpha blending)
  • visual transitions

native HTML Qt ScalaFX Fastest speed (but code and test x N) Fastest development (but test and tune x N²) Pretty good (but compile x N and test x N) Awesome! (still test x N)

slide-14
SLIDE 14

S c a l a F X

OpenJDK on ARM platforms

ARM Linux preview of JavaFX available since late 2012.

  • Raspberry Pi
  • Pandaboard (ES)
  • FreeScale i.MX6
  • etc.

https://jdk8.java.net/fxarmpreview/

slide-15
SLIDE 15

S c a l a F X

OpenJDK on ARM platforms

Android and iOS support coming up via OpenJDK in 2013:

  • JVM will be packaged within the application
  • Modularity in JVM 8 reduces the footprint (< 10MB?)
  • JavaFX libraries are included in the JVM runtime (since JVM 7)

= hardware accelerated graphics pipeline for Desktop, Android, iOS

slide-16
SLIDE 16

S c a l a F X

So Why Not Just Do HTML?

Sure. Please do. Then if it hurts, it’s nice to know there’s another way.

productivity testability maintainability your metrics?

(+ JavaScript + libraries + CSS) 100 50

slide-17
SLIDE 17

Summary

  • A more natural way to construct JavaFX apps than

the Java API.

  • JavaFX a built-in part of Java runtime since JRE 7.
  • Linux ARM support coming up.
  • Modern, GPU accelerated API
  • Good media (i.e. H264) and sound support, too.
  • Touch support
  • CSS themeable
  • Worth a try?

http://code.google.com/p/scalafx/

slide-18
SLIDE 18

Next?

  • Unit testing I actually started to use
  • Pretty much the standard of Scala testing (but not

the only one)

  • Can also test Java code of course