SlideShare ist ein Scribd-Unternehmen logo
1 von 36
Downloaden Sie, um offline zu lesen
JavaFX
Scala
Como fazer em casa algo
que custa mais de U$15 mil?
Gastando apenas R$20mil?
Stage {
title: "Hello World"
width: 400
height: 250
scene: Scene {
fill: Color.ALICEBLUE
content: Text {
font: Font {
name: "Envy Code R"
size: 20
}
x: 105, y: 120
content: "Hello World!"
}
}
}
JavaFX Script 1.3
Stage {
title: "Hello World"
width: 400
height: 250
scene: Scene {
fill: Color.ALICEBLUE
content: Text {
font: Font {
name: "Envy Code R"
size: 20
}
x: 105, y: 120
content: "Hello World!"
}
}
}
public class HelloWorld extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Hello World");
Group root = new Group();
Scene scene = new Scene(root, 400, 250,
Color.ALICEBLUE);
Text text = new Text();
text.setX(105);
text.setY(120);
text.setFont(Font.font("Envy Code R", 20));
text.setText("Hello World!");
root.getChildren().add(text);
primaryStage.setScene(scene);
primaryStage.show();
}
}
Stage {
title: "Hello World"
width: 400
height: 250
scene: Scene {
fill: Color.ALICEBLUE
content: Text {
font: Font {
name: "Envy Code R"
size: 20
}
x: 105, y: 120
content: "Hello World!"
}
}
}
Stage {
Scene {
Text {
"Hello World!"
x: 105, y: 120
font: Font {
name: "Envy Code R"
size: 20pt
}
}
fill: ALICEBLUE
}
title: "Hello World"
width: 400
height: 250
}
Stage {
title: "Hello World"
width: 400
height: 250
scene: Scene {
fill: Color.ALICEBLUE
content: Text {
font: Font {
name: "Envy Code R"
size: 20
}
x: 105, y: 120
content: "Hello World!"
}
}
}
public void start(Stage primaryStage) {
primaryStage.setTitle("Hello World");
primaryStage.setScene(
SceneBuilder.create()
.width(400)
.height(250)
.fill(Color.ALICEBLUE)
.root(
GroupBuilder.create().children(
TextBuilder.create()
.x(105)
.y(120)
.text("Hello World!")
.font(Font.font("Envy Code R", 20))
.build()
).build()
)
.build());
primaryStage.show();
}
¿ ?
¿ ?
¿ ?
¿ ?
scene graph
CSS styling
animations & transitions
event management
.dmg
.msi
.exe
.rpm
.deb
Stage {
title: "Hello World"
width: 400
height: 250
scene: Scene {
fill: Color.ALICEBLUE
content: Text {
font: Font {
name: "Envy Code R"
size: 20
}
x: 105, y: 120
content: "Hello World!"
}
}
}
GroovyFX.start { primaryStage ->
def sg = new SceneGraphBuilder()
sg.stage(
title: 'Hello World',
show: true) {
scene(
fill: aliceblue,
width: 400,
height: 250) {
text(
x: 105, y: 120,
text: "Hello World!"
font: '20pt "Envy Code R"')
}
}
}
Stage {
title: "Hello World"
width: 400
height: 250
scene: Scene {
fill: Color.ALICEBLUE
content: Text {
font: Font {
name: "Envy Code R"
size: 20
}
x: 105, y: 120
content: "Hello World!"
}
}
}
object HelloWorld extends JFXApp {
stage = new JFXApp.PrimaryStage {
title = "Hello World"
scene = new Scene(400, 250) {
fill = Color.ALICEBLUE
content = new Text {
font = Font("Envy Code R", 20)
x = 105; y = 120
text = "Hello World!"
}
}
}
}
I can honestly say if
someone had shown me the
Programming in Scala book
by Martin Odersky, Lex
Spoon & Bill Venners back in
2003, I'd probably have
never created Groovy.
James Strachan
James Strachan
Scala is statically typed and compiles
down to the same fast bytecode as
Java so it's usually about as fast as
Java.
Scala is statically typed and compiles
down to the same fast bytecode as
Java so it's usually about as fast as
Java.
Scala has type inference - so it's
typically as concise as Ruby/Groovy
but that everything has static types.
Scala is statically typed and compiles
down to the same fast bytecode as
Java so it's usually about as fast as
Java.
Scala has type inference - so it's
typically as concise as Ruby/Groovy
but that everything has static types.
Scala has high order functions and
closure support along with sequence
comprehensions so you can write
beautifully concise code.
Scala is statically typed and compiles
down to the same fast bytecode as
Java so it's usually about as fast as
Java.
Scala has type inference - so it's
typically as concise as Ruby/Groovy
but that everything has static types.
Scala does take a little bit of getting
used to - I confess the first few times
I looked at Scala it wasn't that
pleasing on the eye.
Scala has high order functions and
closure support along with sequence
comprehensions so you can write
beautifully concise code.
Statically typed
JVM bytecode
Type inference
High order functions
Closures
Sequence comprehension
Notthatpleasingontheeye
Beautifully concise code
Por que Scala?
> Compartilha muitas funcionalidades do JavaFX Script que tornam
a programação de interfaces mais fácil:
Checagem estática de tipos – Encontre seus erros em tempo de
compilação
Closures / traits – Misture os comportamentos e passe-os como
referência
Declarativa – Expresse a interface como ela deve aparecer
> Scala também permite implementar suas DSLs!
Conversões implícitas – extensão de classes typesafe
Sobrecarga de operadores – com regras de precedência
DelayedInit / @specialized – funcionalides avançadas da
linguagem
object VanishingCircles extends JFXApp {
stage = new JFXApp.PrimaryStage {
title = "Vanishing Circles"
width = 800
height = 600
scene = new Scene {
fill = BLACK
content = for (i <- 0 until 50) yield new Circle {
centerX = random * 800
centerY = random * 600
radius = 150
fill = color(random, random, random, 0.2)
effect = new BoxBlur(10, 10, 3)
}
}
}
}
Classe base para aplicações
ScalaFX
object VanishingCircles extends JFXApp {
stage = new JFXApp.PrimaryStage {
title = "Vanishing Circles"
width = 800
height = 600
scene = new Scene {
fill = BLACK
content = for (i <- 0 until 50) yield new Circle {
centerX = random * 800
centerY = random * 600
radius = 150
fill = color(random, random, random, 0.2)
effect = new BoxBlur(10, 10, 3)
}
}
}
}
Definição Declarativa do
Stage
object VanishingCircles extends JFXApp {
stage = new JFXApp.PrimaryStage {
title = "Vanishing Circles"
width = 800
height = 600
scene = new Scene {
fill = BLACK
content = for (i <- 0 until 50) yield new Circle {
centerX = random * 800
centerY = random * 600
radius = 150
fill = color(random, random, random, 0.2)
effect = new BoxBlur(10, 10, 3)
}
}
}
}
Definições das
propriedades no corpo
object VanishingCircles extends JFXApp {
stage = new JFXApp.PrimaryStage {
title = "Vanishing Circles"
width = 800
height = 600
scene = new Scene {
fill = BLACK
content = for (i <- 0 until 50) yield new Circle {
centerX = random * 800
centerY = random * 600
radius = 150
fill = color(random, random, random, 0.2)
effect = new BoxBlur(10, 10, 3)
}
}
}
}
Criação de Sequência via
Comprehension
Animação em ScalaFX
val timeline = new Timeline {
cycleCount = INDEFINITE
autoReverse = true
keyFrames = for (circle <- circles) yield
at (40 s) {
Set(
circle.centerX -> random * stage.width.get,
circle.centerY -> random * stage.height.get
)
}
}
timeline.play
Sintaxe de animação como
no JavaFX Script:
at (duração) {keyframes}
Animação em ScalaFX
val timeline = new Timeline {
cycleCount = INDEFINITE
autoReverse = true
keyFrames = for (circle <- circles) yield
at (40 s) {
Set(
circle.centerX -> random * stage.width.get,
circle.centerY -> random * stage.height.get
)
}
}
timeline.play Sobrecarga de operador para
sintaxe de animação
Animação em ScalaFX
val timeline = new Timeline {
cycleCount = INDEFINITE
autoReverse = true
keyFrames = for (circle <- circles) yield
at (40 s) {
Set(
circle.centerX -> random * stage.width tween EASE_BOTH,
circle.centerY -> random * stage.height tween EASE_IN
)
}
}
timeline.play Sintaxe tween
opcional
Event Listeners em ScalaFX
> Suportado usando sintaxe Closure embutida
> Argumentos opcionais para tratamento de eventos
> 100% tipagem forte
Sintaxe compacta
{body}
onMouseClicked = {
Timeline(at(3 s){radius->0}).play
}
Event Listeners em ScalaFX
> Suportado usando sintaxe Closure embutida
> Argumentos opcionais para tratamento de eventos
> 100% tipagem forte
onMouseClicked = { (e: MouseEvent) =>
Timeline(at(3 s){radius->0}).play
}
Evento = parametro opcional
{(event) => body}
Binding em ScalaFX
Adição/Subtração/Multiplicação/Divisão Infixas:
height <== rect1.height + rect2.height
Operadores de Agregação:
width <== max(rect1.width, rect2.width, rect3.width)
Expressões Condicionais:
strokeWidth <== when (hover) choose 4 otherwise 0
Expressões Compostas:
text <== when (rect.hover || circle.hover && !disabled)
choose textField.text + " is enabled" otherwise "disabled"
2001
Scala começou
2003/2004
Scala v1.0
2006
Scala v2.0
2013
Scala 2.10.1
(última)
Alain Béarez
« francês »
(* ~10×106 ms Unix Epoch)

Weitere ähnliche Inhalte

Was ist angesagt?

ES2015 (ES6) Overview
ES2015 (ES6) OverviewES2015 (ES6) Overview
ES2015 (ES6) Overviewhesher
 
Deep Dive: AWS Command Line Interface
Deep Dive: AWS Command Line InterfaceDeep Dive: AWS Command Line Interface
Deep Dive: AWS Command Line InterfaceAmazon Web Services
 
ES6 PPT FOR 2016
ES6 PPT FOR 2016ES6 PPT FOR 2016
ES6 PPT FOR 2016Manoj Kumar
 
TLS305 Using DynamoDB with the AWS SDK for PHP - AWS re: Invent 2012
TLS305 Using DynamoDB with the AWS SDK for PHP - AWS re: Invent 2012TLS305 Using DynamoDB with the AWS SDK for PHP - AWS re: Invent 2012
TLS305 Using DynamoDB with the AWS SDK for PHP - AWS re: Invent 2012Amazon Web Services
 
Python and EM CLI: The Enterprise Management Super Tools
Python and EM CLI: The Enterprise Management Super ToolsPython and EM CLI: The Enterprise Management Super Tools
Python and EM CLI: The Enterprise Management Super ToolsSeth Miller
 
Deep Dive: AWS Command Line Interface
Deep Dive: AWS Command Line InterfaceDeep Dive: AWS Command Line Interface
Deep Dive: AWS Command Line InterfaceAmazon Web Services
 
Masterclass Advanced Usage of the AWS CLI
Masterclass Advanced Usage of the AWS CLIMasterclass Advanced Usage of the AWS CLI
Masterclass Advanced Usage of the AWS CLIDanilo Poccia
 
P6 OO vs Moose (&Moo)
P6 OO vs Moose (&Moo)P6 OO vs Moose (&Moo)
P6 OO vs Moose (&Moo)lichtkind
 
Deep Dive into AWS CLI - the command line interface
Deep Dive into AWS CLI - the command line interfaceDeep Dive into AWS CLI - the command line interface
Deep Dive into AWS CLI - the command line interfaceJohn Varghese
 
Tame cloud complexity with F# powered DSLs (build stuff)
Tame cloud complexity with F# powered DSLs (build stuff)Tame cloud complexity with F# powered DSLs (build stuff)
Tame cloud complexity with F# powered DSLs (build stuff)Yan Cui
 
All I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkAll I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkBen Scofield
 
Deep Dive - Advanced Usage of the AWS CLI
Deep Dive - Advanced Usage of the AWS CLIDeep Dive - Advanced Usage of the AWS CLI
Deep Dive - Advanced Usage of the AWS CLIAmazon Web Services
 
Scala - just good for Java shops?
Scala - just good for Java shops?Scala - just good for Java shops?
Scala - just good for Java shops?Sarah Mount
 
Ruby on Rails 中級者を目指して - 大場寧子
Ruby on Rails 中級者を目指して - 大場寧子Ruby on Rails 中級者を目指して - 大場寧子
Ruby on Rails 中級者を目指して - 大場寧子Yasuko Ohba
 

Was ist angesagt? (20)

ES2015 (ES6) Overview
ES2015 (ES6) OverviewES2015 (ES6) Overview
ES2015 (ES6) Overview
 
XQuery Rocks
XQuery RocksXQuery Rocks
XQuery Rocks
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
Deep Dive: AWS Command Line Interface
Deep Dive: AWS Command Line InterfaceDeep Dive: AWS Command Line Interface
Deep Dive: AWS Command Line Interface
 
ES6 PPT FOR 2016
ES6 PPT FOR 2016ES6 PPT FOR 2016
ES6 PPT FOR 2016
 
TLS305 Using DynamoDB with the AWS SDK for PHP - AWS re: Invent 2012
TLS305 Using DynamoDB with the AWS SDK for PHP - AWS re: Invent 2012TLS305 Using DynamoDB with the AWS SDK for PHP - AWS re: Invent 2012
TLS305 Using DynamoDB with the AWS SDK for PHP - AWS re: Invent 2012
 
Python and EM CLI: The Enterprise Management Super Tools
Python and EM CLI: The Enterprise Management Super ToolsPython and EM CLI: The Enterprise Management Super Tools
Python and EM CLI: The Enterprise Management Super Tools
 
Deep Dive: AWS Command Line Interface
Deep Dive: AWS Command Line InterfaceDeep Dive: AWS Command Line Interface
Deep Dive: AWS Command Line Interface
 
Masterclass Advanced Usage of the AWS CLI
Masterclass Advanced Usage of the AWS CLIMasterclass Advanced Usage of the AWS CLI
Masterclass Advanced Usage of the AWS CLI
 
P6 OO vs Moose (&Moo)
P6 OO vs Moose (&Moo)P6 OO vs Moose (&Moo)
P6 OO vs Moose (&Moo)
 
Es.next
Es.nextEs.next
Es.next
 
Deep Dive into AWS CLI - the command line interface
Deep Dive into AWS CLI - the command line interfaceDeep Dive into AWS CLI - the command line interface
Deep Dive into AWS CLI - the command line interface
 
Tame cloud complexity with F# powered DSLs (build stuff)
Tame cloud complexity with F# powered DSLs (build stuff)Tame cloud complexity with F# powered DSLs (build stuff)
Tame cloud complexity with F# powered DSLs (build stuff)
 
All I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkAll I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web Framework
 
Ruby
RubyRuby
Ruby
 
Deep Dive - Advanced Usage of the AWS CLI
Deep Dive - Advanced Usage of the AWS CLIDeep Dive - Advanced Usage of the AWS CLI
Deep Dive - Advanced Usage of the AWS CLI
 
XQuery in the Cloud
XQuery in the CloudXQuery in the Cloud
XQuery in the Cloud
 
Scala - just good for Java shops?
Scala - just good for Java shops?Scala - just good for Java shops?
Scala - just good for Java shops?
 
Ruby on Rails 中級者を目指して - 大場寧子
Ruby on Rails 中級者を目指して - 大場寧子Ruby on Rails 中級者を目指して - 大場寧子
Ruby on Rails 中級者を目指して - 大場寧子
 
ES6: The Awesome Parts
ES6: The Awesome PartsES6: The Awesome Parts
ES6: The Awesome Parts
 

Andere mochten auch

Mashups in the_classroom
Mashups in the_classroomMashups in the_classroom
Mashups in the_classroomcarmelladoty
 
Mashups in the_classroomx
Mashups in the_classroomxMashups in the_classroomx
Mashups in the_classroomxcarmelladoty
 
Middle School Science Nov 2011
Middle School Science Nov 2011Middle School Science Nov 2011
Middle School Science Nov 2011carmelladoty
 
Mset i connect presenter
Mset i connect presenterMset i connect presenter
Mset i connect presentercarmelladoty
 
BPO en cloud: HR uit de kraan?
BPO en cloud: HR uit de kraan?BPO en cloud: HR uit de kraan?
BPO en cloud: HR uit de kraan?Anita Lettink
 
HR Trends in Nederland
HR Trends in NederlandHR Trends in Nederland
HR Trends in NederlandAnita Lettink
 
HR Outsourcing is not all or nothing
HR Outsourcing is not all or nothingHR Outsourcing is not all or nothing
HR Outsourcing is not all or nothingAnita Lettink
 

Andere mochten auch (7)

Mashups in the_classroom
Mashups in the_classroomMashups in the_classroom
Mashups in the_classroom
 
Mashups in the_classroomx
Mashups in the_classroomxMashups in the_classroomx
Mashups in the_classroomx
 
Middle School Science Nov 2011
Middle School Science Nov 2011Middle School Science Nov 2011
Middle School Science Nov 2011
 
Mset i connect presenter
Mset i connect presenterMset i connect presenter
Mset i connect presenter
 
BPO en cloud: HR uit de kraan?
BPO en cloud: HR uit de kraan?BPO en cloud: HR uit de kraan?
BPO en cloud: HR uit de kraan?
 
HR Trends in Nederland
HR Trends in NederlandHR Trends in Nederland
HR Trends in Nederland
 
HR Outsourcing is not all or nothing
HR Outsourcing is not all or nothingHR Outsourcing is not all or nothing
HR Outsourcing is not all or nothing
 

Ähnlich wie Don't panic in Fortaleza - ScalaFX

JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)Stephen Chin
 
JavaFX 2.0 With Alternative Languages [Portuguese]
JavaFX 2.0 With Alternative Languages [Portuguese]JavaFX 2.0 With Alternative Languages [Portuguese]
JavaFX 2.0 With Alternative Languages [Portuguese]Stephen Chin
 
JavaFX Your Way: Building JavaFX Applications with Alternative Languages
JavaFX Your Way: Building JavaFX Applications with Alternative LanguagesJavaFX Your Way: Building JavaFX Applications with Alternative Languages
JavaFX Your Way: Building JavaFX Applications with Alternative LanguagesStephen Chin
 
JavaFX 2.0 and Alternative Languages
JavaFX 2.0 and Alternative LanguagesJavaFX 2.0 and Alternative Languages
JavaFX 2.0 and Alternative LanguagesStephen Chin
 
JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...
JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...
JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...Stephen Chin
 
Hacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen Chin
Hacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen ChinHacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen Chin
Hacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen Chinjaxconf
 
JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...
JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...
JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...Stephen Chin
 
Gatling @ Scala.Io 2013
Gatling @ Scala.Io 2013Gatling @ Scala.Io 2013
Gatling @ Scala.Io 2013slandelle
 
Gatling - Paris Perf User Group
Gatling - Paris Perf User GroupGatling - Paris Perf User Group
Gatling - Paris Perf User Groupslandelle
 
Intro to Scala.js - Scala UG Cologne
Intro to Scala.js - Scala UG CologneIntro to Scala.js - Scala UG Cologne
Intro to Scala.js - Scala UG CologneMarius Soutier
 
JavaFX 2.0 With Alternative Languages - JavaOne 2011
JavaFX 2.0 With Alternative Languages - JavaOne 2011JavaFX 2.0 With Alternative Languages - JavaOne 2011
JavaFX 2.0 With Alternative Languages - JavaOne 2011Stephen Chin
 
Scripting with Java FX - Cédric Tabin - December 2007
Scripting with Java FX - Cédric Tabin - December 2007Scripting with Java FX - Cédric Tabin - December 2007
Scripting with Java FX - Cédric Tabin - December 2007JUG Lausanne
 
Hacking JavaFX with Groovy, Clojure, Scala, and Visage
Hacking JavaFX with Groovy, Clojure, Scala, and VisageHacking JavaFX with Groovy, Clojure, Scala, and Visage
Hacking JavaFX with Groovy, Clojure, Scala, and VisageStephen Chin
 
JavaFX Your Way - Devoxx Version
JavaFX Your Way - Devoxx VersionJavaFX Your Way - Devoxx Version
JavaFX Your Way - Devoxx VersionStephen Chin
 
JavaFX and Scala in the Cloud
JavaFX and Scala in the CloudJavaFX and Scala in the Cloud
JavaFX and Scala in the CloudStephen Chin
 
Scala elegant and exotic part 1
Scala  elegant and exotic part 1Scala  elegant and exotic part 1
Scala elegant and exotic part 1VulcanMinds
 
Java Fx Overview Tech Tour
Java Fx Overview Tech TourJava Fx Overview Tech Tour
Java Fx Overview Tech TourCarol McDonald
 

Ähnlich wie Don't panic in Fortaleza - ScalaFX (20)

JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
 
JavaFX 2.0 With Alternative Languages [Portuguese]
JavaFX 2.0 With Alternative Languages [Portuguese]JavaFX 2.0 With Alternative Languages [Portuguese]
JavaFX 2.0 With Alternative Languages [Portuguese]
 
JavaFX Your Way: Building JavaFX Applications with Alternative Languages
JavaFX Your Way: Building JavaFX Applications with Alternative LanguagesJavaFX Your Way: Building JavaFX Applications with Alternative Languages
JavaFX Your Way: Building JavaFX Applications with Alternative Languages
 
JavaFX 2.0 and Alternative Languages
JavaFX 2.0 and Alternative LanguagesJavaFX 2.0 and Alternative Languages
JavaFX 2.0 and Alternative Languages
 
JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...
JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...
JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...
 
Hacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen Chin
Hacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen ChinHacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen Chin
Hacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen Chin
 
JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...
JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...
JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...
 
JavaFX introduction
JavaFX introductionJavaFX introduction
JavaFX introduction
 
Gatling @ Scala.Io 2013
Gatling @ Scala.Io 2013Gatling @ Scala.Io 2013
Gatling @ Scala.Io 2013
 
Gatling - Paris Perf User Group
Gatling - Paris Perf User GroupGatling - Paris Perf User Group
Gatling - Paris Perf User Group
 
Intro to Scala.js - Scala UG Cologne
Intro to Scala.js - Scala UG CologneIntro to Scala.js - Scala UG Cologne
Intro to Scala.js - Scala UG Cologne
 
JavaFX 2.0 With Alternative Languages - JavaOne 2011
JavaFX 2.0 With Alternative Languages - JavaOne 2011JavaFX 2.0 With Alternative Languages - JavaOne 2011
JavaFX 2.0 With Alternative Languages - JavaOne 2011
 
Scripting with Java FX - Cédric Tabin - December 2007
Scripting with Java FX - Cédric Tabin - December 2007Scripting with Java FX - Cédric Tabin - December 2007
Scripting with Java FX - Cédric Tabin - December 2007
 
Hacking JavaFX with Groovy, Clojure, Scala, and Visage
Hacking JavaFX with Groovy, Clojure, Scala, and VisageHacking JavaFX with Groovy, Clojure, Scala, and Visage
Hacking JavaFX with Groovy, Clojure, Scala, and Visage
 
JavaFX Your Way - Devoxx Version
JavaFX Your Way - Devoxx VersionJavaFX Your Way - Devoxx Version
JavaFX Your Way - Devoxx Version
 
JavaFX and Scala in the Cloud
JavaFX and Scala in the CloudJavaFX and Scala in the Cloud
JavaFX and Scala in the Cloud
 
Scala elegant and exotic part 1
Scala  elegant and exotic part 1Scala  elegant and exotic part 1
Scala elegant and exotic part 1
 
Full Stack Scala
Full Stack ScalaFull Stack Scala
Full Stack Scala
 
Java Fx Overview Tech Tour
Java Fx Overview Tech TourJava Fx Overview Tech Tour
Java Fx Overview Tech Tour
 
Scala in a nutshell
Scala in a nutshellScala in a nutshell
Scala in a nutshell
 

Kürzlich hochgeladen

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 

Kürzlich hochgeladen (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 

Don't panic in Fortaleza - ScalaFX

  • 2. Como fazer em casa algo que custa mais de U$15 mil? Gastando apenas R$20mil?
  • 3.
  • 4. Stage { title: "Hello World" width: 400 height: 250 scene: Scene { fill: Color.ALICEBLUE content: Text { font: Font { name: "Envy Code R" size: 20 } x: 105, y: 120 content: "Hello World!" } } } JavaFX Script 1.3
  • 5. Stage { title: "Hello World" width: 400 height: 250 scene: Scene { fill: Color.ALICEBLUE content: Text { font: Font { name: "Envy Code R" size: 20 } x: 105, y: 120 content: "Hello World!" } } } public class HelloWorld extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) { primaryStage.setTitle("Hello World"); Group root = new Group(); Scene scene = new Scene(root, 400, 250, Color.ALICEBLUE); Text text = new Text(); text.setX(105); text.setY(120); text.setFont(Font.font("Envy Code R", 20)); text.setText("Hello World!"); root.getChildren().add(text); primaryStage.setScene(scene); primaryStage.show(); } }
  • 6. Stage { title: "Hello World" width: 400 height: 250 scene: Scene { fill: Color.ALICEBLUE content: Text { font: Font { name: "Envy Code R" size: 20 } x: 105, y: 120 content: "Hello World!" } } } Stage { Scene { Text { "Hello World!" x: 105, y: 120 font: Font { name: "Envy Code R" size: 20pt } } fill: ALICEBLUE } title: "Hello World" width: 400 height: 250 }
  • 7. Stage { title: "Hello World" width: 400 height: 250 scene: Scene { fill: Color.ALICEBLUE content: Text { font: Font { name: "Envy Code R" size: 20 } x: 105, y: 120 content: "Hello World!" } } } public void start(Stage primaryStage) { primaryStage.setTitle("Hello World"); primaryStage.setScene( SceneBuilder.create() .width(400) .height(250) .fill(Color.ALICEBLUE) .root( GroupBuilder.create().children( TextBuilder.create() .x(105) .y(120) .text("Hello World!") .font(Font.font("Envy Code R", 20)) .build() ).build() ) .build()); primaryStage.show(); }
  • 10. ¿ ?
  • 11. ¿ ?
  • 12.
  • 13.
  • 14. scene graph CSS styling animations & transitions event management .dmg .msi .exe .rpm .deb
  • 15. Stage { title: "Hello World" width: 400 height: 250 scene: Scene { fill: Color.ALICEBLUE content: Text { font: Font { name: "Envy Code R" size: 20 } x: 105, y: 120 content: "Hello World!" } } } GroovyFX.start { primaryStage -> def sg = new SceneGraphBuilder() sg.stage( title: 'Hello World', show: true) { scene( fill: aliceblue, width: 400, height: 250) { text( x: 105, y: 120, text: "Hello World!" font: '20pt "Envy Code R"') } } }
  • 16. Stage { title: "Hello World" width: 400 height: 250 scene: Scene { fill: Color.ALICEBLUE content: Text { font: Font { name: "Envy Code R" size: 20 } x: 105, y: 120 content: "Hello World!" } } } object HelloWorld extends JFXApp { stage = new JFXApp.PrimaryStage { title = "Hello World" scene = new Scene(400, 250) { fill = Color.ALICEBLUE content = new Text { font = Font("Envy Code R", 20) x = 105; y = 120 text = "Hello World!" } } } }
  • 17. I can honestly say if someone had shown me the Programming in Scala book by Martin Odersky, Lex Spoon & Bill Venners back in 2003, I'd probably have never created Groovy. James Strachan
  • 19. Scala is statically typed and compiles down to the same fast bytecode as Java so it's usually about as fast as Java.
  • 20. Scala is statically typed and compiles down to the same fast bytecode as Java so it's usually about as fast as Java. Scala has type inference - so it's typically as concise as Ruby/Groovy but that everything has static types.
  • 21. Scala is statically typed and compiles down to the same fast bytecode as Java so it's usually about as fast as Java. Scala has type inference - so it's typically as concise as Ruby/Groovy but that everything has static types. Scala has high order functions and closure support along with sequence comprehensions so you can write beautifully concise code.
  • 22. Scala is statically typed and compiles down to the same fast bytecode as Java so it's usually about as fast as Java. Scala has type inference - so it's typically as concise as Ruby/Groovy but that everything has static types. Scala does take a little bit of getting used to - I confess the first few times I looked at Scala it wasn't that pleasing on the eye. Scala has high order functions and closure support along with sequence comprehensions so you can write beautifully concise code.
  • 23. Statically typed JVM bytecode Type inference High order functions Closures Sequence comprehension Notthatpleasingontheeye Beautifully concise code
  • 24. Por que Scala? > Compartilha muitas funcionalidades do JavaFX Script que tornam a programação de interfaces mais fácil: Checagem estática de tipos – Encontre seus erros em tempo de compilação Closures / traits – Misture os comportamentos e passe-os como referência Declarativa – Expresse a interface como ela deve aparecer > Scala também permite implementar suas DSLs! Conversões implícitas – extensão de classes typesafe Sobrecarga de operadores – com regras de precedência DelayedInit / @specialized – funcionalides avançadas da linguagem
  • 25. object VanishingCircles extends JFXApp { stage = new JFXApp.PrimaryStage { title = "Vanishing Circles" width = 800 height = 600 scene = new Scene { fill = BLACK content = for (i <- 0 until 50) yield new Circle { centerX = random * 800 centerY = random * 600 radius = 150 fill = color(random, random, random, 0.2) effect = new BoxBlur(10, 10, 3) } } } } Classe base para aplicações ScalaFX
  • 26. object VanishingCircles extends JFXApp { stage = new JFXApp.PrimaryStage { title = "Vanishing Circles" width = 800 height = 600 scene = new Scene { fill = BLACK content = for (i <- 0 until 50) yield new Circle { centerX = random * 800 centerY = random * 600 radius = 150 fill = color(random, random, random, 0.2) effect = new BoxBlur(10, 10, 3) } } } } Definição Declarativa do Stage
  • 27. object VanishingCircles extends JFXApp { stage = new JFXApp.PrimaryStage { title = "Vanishing Circles" width = 800 height = 600 scene = new Scene { fill = BLACK content = for (i <- 0 until 50) yield new Circle { centerX = random * 800 centerY = random * 600 radius = 150 fill = color(random, random, random, 0.2) effect = new BoxBlur(10, 10, 3) } } } } Definições das propriedades no corpo
  • 28. object VanishingCircles extends JFXApp { stage = new JFXApp.PrimaryStage { title = "Vanishing Circles" width = 800 height = 600 scene = new Scene { fill = BLACK content = for (i <- 0 until 50) yield new Circle { centerX = random * 800 centerY = random * 600 radius = 150 fill = color(random, random, random, 0.2) effect = new BoxBlur(10, 10, 3) } } } } Criação de Sequência via Comprehension
  • 29. Animação em ScalaFX val timeline = new Timeline { cycleCount = INDEFINITE autoReverse = true keyFrames = for (circle <- circles) yield at (40 s) { Set( circle.centerX -> random * stage.width.get, circle.centerY -> random * stage.height.get ) } } timeline.play Sintaxe de animação como no JavaFX Script: at (duração) {keyframes}
  • 30. Animação em ScalaFX val timeline = new Timeline { cycleCount = INDEFINITE autoReverse = true keyFrames = for (circle <- circles) yield at (40 s) { Set( circle.centerX -> random * stage.width.get, circle.centerY -> random * stage.height.get ) } } timeline.play Sobrecarga de operador para sintaxe de animação
  • 31. Animação em ScalaFX val timeline = new Timeline { cycleCount = INDEFINITE autoReverse = true keyFrames = for (circle <- circles) yield at (40 s) { Set( circle.centerX -> random * stage.width tween EASE_BOTH, circle.centerY -> random * stage.height tween EASE_IN ) } } timeline.play Sintaxe tween opcional
  • 32. Event Listeners em ScalaFX > Suportado usando sintaxe Closure embutida > Argumentos opcionais para tratamento de eventos > 100% tipagem forte Sintaxe compacta {body} onMouseClicked = { Timeline(at(3 s){radius->0}).play }
  • 33. Event Listeners em ScalaFX > Suportado usando sintaxe Closure embutida > Argumentos opcionais para tratamento de eventos > 100% tipagem forte onMouseClicked = { (e: MouseEvent) => Timeline(at(3 s){radius->0}).play } Evento = parametro opcional {(event) => body}
  • 34. Binding em ScalaFX Adição/Subtração/Multiplicação/Divisão Infixas: height <== rect1.height + rect2.height Operadores de Agregação: width <== max(rect1.width, rect2.width, rect3.width) Expressões Condicionais: strokeWidth <== when (hover) choose 4 otherwise 0 Expressões Compostas: text <== when (rect.hover || circle.hover && !disabled) choose textField.text + " is enabled" otherwise "disabled"
  • 35. 2001 Scala começou 2003/2004 Scala v1.0 2006 Scala v2.0 2013 Scala 2.10.1 (última)
  • 36. Alain Béarez « francês » (* ~10×106 ms Unix Epoch)