SlideShare une entreprise Scribd logo
1  sur  73
Plataforma JavaFX 2.0,
                               GroovyFX, ScalaFX e Visage
                                          Stephen Chin
                                          Chefe de metodologias Ageis, GXS
                                          steveonjava@gmail.com
                                          tweet: @steveonjava
Translated by Marcelo Quinta
Conheca o palestrante
             Stephen Chin
       http://steveonjava.com/
                                       •   Java Champion
                                       •   Autor
       Family Man                          •   Pro JavaFX Platform
                                           •   Pro Android Flash
                                       •   Fundador de projetos Open
                        Motorcyclist       Source
                                           •   JFXtras
                                           •   ScalaFX
                                           •   WidgetFX
                                           •   Visage
A plataforma JavaFX 2.0
Experiencia imersiva Desktop combinando o
melhor do JavaFX e HTML5
>   Use seus conhecimentos Java com as
    modernas APIs JavaFX
>   Integre Java, JavaScript e HTML5 na mesma
    aplicacao
>   Nova gama de graficos usa as vantagens de
    aceleracao de hardware para aplicacoes 2D e
    3D
>   Use sua IDE favorita:
    NetBeans, Eclipse, IntelliJ, etc.
JavaFX agora e Open Source!
Parte do projeto OpenJDK

Controles disponiveis agora
     codigo adicional adicionado
incrementalmente

Pagina do projeto:
> http://openjdk.java.net/projects/openjfx/




                                              4
E vai rodar nos Tablets!

> iPad (iOS)
> Linux
    (plataforma
    popular que
    executa algo
    semelhante a
    Java)
    Nenhuma data de release foi anunciada
                                            5
Construindo Aplicacoes JavaFX
>   Pode ser executada no navegador ou no Desktop
>   Inclui builders para construcoes declarativas
>   Linguagens alternativas tambem podem ser utilizadas para
    simplificar a criacao da interface de usuario
       GroovyFX
       ScalaFX
       Visage




                                                               6
Ola JUG (Versao Java)
public class HelloJUG extends Application {
  public static void main(String[] args) {
    launch(args);
  }
  @Override
  public void start(Stage primaryStage) {
    primaryStage.setTitle("Ola JUG");
    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(new Font(30));
    text.setText("Ola JUG");
    root.getChildren().add(text);
    primaryStage.setScene(scene);
    primaryStage.show();
  }
}
                                                                7
Ola JUG (Versao com o Builder)
public void start(Stage primaryStage) {
  primaryStage.setTitle("Ola JUG");
  primaryStage.setScene(SceneBuilder.create()
    .width(400)
    .height(250)
    .fill(Color.ALICEBLUE)
    .root(
      GroupBuilder.create().children(
      TextBuilder.create()
        .x(105)
        .y(120)
        .text("Ola JUG")
        .font(new Font(30))
        .build()
      ).build()
    )
  .build());
  primaryStage.show();
}
                                                8
Ola JUG (Versao GroovyFX)
GroovyFX.start { primaryStage ->
  def sg = new SceneGraphBuilder()
  sg.stage(
    title: 'Ola JUG',
    show: true) {
      scene(
        fill: aliceblue,
        width: 400,
        height: 250) {
          text(
             x: 105,
             y: 120,
             text: "Ola JUG"
             font: "30pt")
        }
    }
}
                                     9
Ola JUG (Versao JavaFX)
object HelloJUG extends JFXApp {
  stage = new Stage {
    title = "Ola JUG"
    width = 400
    height = 250
    scene = new Scene {
      fill = BLUE
      Text {
        x = 105
        y = 120
        text = "Ola JUG"
        font = Font(size: 30)
      }
    }
  }
}
                                   10
Ola JUG (Versao Visage)
Stage {
  title: "Ola JUG"
  width: 400
  height: 250
  scene: Scene {
    fill: BLUE
    content: Text {
      x: 105
      y: 120
      text: "Ola JUG"
      font: Font {size: 30pt}
    }
  }
}



                                11
Mostrando HTML no JavaFX
public class WebViewTest extends Application {
   public static void main(String[] args) {
     launch(WebViewTest.class, args);
   }
   @Override public void start(Stage stage) {
     WebView webView = new WebView();
     webView.getEngine().load("http://google.com");
     Scene scene = new Scene(webView);
     stage.setScene(scene);
     stage.setTitle("Web Test");
     stage.show();
}}
                                                      12
Mostrando HTML no JavaFX




                           13
Chamando Javascript pelo JavaFX
String script = "alert('Aooo Goiania!');”;
eng.executeScript(script);




                                             14
Respondendo a eventos do browser
Eventos suportados:
> Alert/Confirm/Prompt:
       Responda funcoes do Javascript de interacao do usuario
>   Resize:
       Web page move-se ou rearranja ao tamanho da janela
>   Status
       Web page muda o texto do status
>   Visibility
       Esconde ou mostra algum objeto da janela
>   Popup
       Cria uma segunda janela

                                                                 15
Demo de integracao HTML5/JavaFX




                                  16
JavaFX com Groovy
Features of Groovy
>   Linguagem moderna
       Closures
       Transforms AST
       Linguagem fortemente tipada

>   Grande integracao com Java
       Muito facil fazer a portabilidade de Java para Groovy

>   Sintaxe declarativa com builders GroovyFX
       Familiar aos desenvolvedores Groovy e JavaFX Script
Java vs. GroovyFX DSL
public class HelloStage extends Application {   GroovyFX.start { stage ->
                                                  def sg = new SceneGraphBuilder(stage)
    public void start(Stage stage) {
      stage.setTitle("Hello Stage");                sg.stage(title: “Hello Stage”, width: 600, height: 450) {
      stage.setWidth(600);                             scene(fill: groovyblue) {
      stage.setHeight(450);                              rectangle(x: 25, y: 40, width: 100, height: 50, fill:
      Scene scene = new Scene();                      red)
      scene.setFill(Color.LIGHTGREEN);                 }
          21 Linhas
      Rectangle rect = new Rectangle();
      rect.setX(25);                            }
                                                    }        8 Linhas
      rect.setY(40);
          430 Caracteres
      rect.setWidth(100);
      rect.setHeight(50);
                                                             180 Caracteres
      rect.setFill(Color.RED);
      scene.setRoot(new Group(rect));
      stage.setScene(scene);
      stage.show();
    }

    public static void main(String[] args) {
      launch(HelloStage.class, args);
    }
}




                                                                                                                 19
def sg = new SceneGraphBuilder()
def hc = { hover -> hover ? 4 : 0 }

sg.stage(title: 'Vanishing Circles', show: true) {
  scene(fill: black, width: 800, height: 600) {
    50.times {
      circle(centerX: rand(800), centerY: rand(600),
             radius: 150, stroke: white,
             strokeWidth: bind('hover', converter: hc)) {
        fill rgb(rand(255), rand(255), rand(255), 0.2)
        effect boxBlur(width: 10, height: 10, iterations: 3)
      }
    }
  }
}
                                                               20
def sg = new SceneGraphBuilder()
def hc = { hover -> hover ? 4 : 0 }

sg.stage(title: 'Vanishing Circles',Builder para Scene Graphs do
                                     show: true) {
                                              GroovyFX
  scene(fill: black, width: 800, height: 600) {
    50.times {
      circle(centerX: rand(800), centerY: rand(600),
             radius: 150, stroke: white,
             strokeWidth: bind('hover', converter: hc)) {
        fill rgb(rand(255), rand(255), rand(255), 0.2)
        effect boxBlur(width: 10, height: 10, iterations: 3)
      }
    }
  }
}
                                                                   21
def sg = new SceneGraphBuilder()
def hc = { hover -> hover ? 4 : 0 }

sg.stage(title: 'Vanishing Circles', show: true) {
  scene(fill: black, width: 800, height: 600) {
    50.times {
      circle(centerX: rand(800), centerY: rand(600),
                                Definicao declarativa do Stage
             radius: 150, stroke: white,
             strokeWidth: bind('hover', converter: hc)) {
        fill rgb(rand(255), rand(255), rand(255), 0.2)
        effect boxBlur(width: 10, height: 10, iterations: 3)
      }
    }
  }
}
                                                                 22
def sg = new SceneGraphBuilder()
def hc = { hover -> hover ? 4 : 0 }
                          Definicao de propriedades
sg.stage(title: 'Vanishing Circles', show: true) {
                                 embutdidas
    scene(fill: black, width: 800, height: 600) {
      50.times {
        circle(centerX: rand(800), centerY: rand(600),
               radius: 150, stroke: white,
               strokeWidth: bind('hover', converter: hc)) {
          fill rgb(rand(255), rand(255), rand(255), 0.2)
          effect boxBlur(width: 10, height: 10, iterations: 3)
        }
      }
    }
}
                                                                 23
def sg = new SceneGraphBuilder()
def hc = { hover -> hover ? 4 : 0 }

sg.stage(title: 'Vanishing Circles', show: true) {
  scene(fill: black, width: 800, height: Bind para propriedades
                                         600) {
    50.times {
      circle(centerX: rand(800), centerY: rand(600),
             radius: 150, stroke: white,
             strokeWidth: bind('hover', converter: hc)) {
        fill rgb(rand(255), rand(255), rand(255), 0.2)
        effect boxBlur(width: 10, height: 10, iterations: 3)
      }
    }
  }
}
                                                                  24
def sg = new SceneGraphBuilder()
def hc = { hover -> hover ? 4 : 0 }

sg.stage(title: 'Vanishing Circles', show: true) {
                                     Criacao de sequencias via loop
  scene(fill: black, width: 800, height: 600) {
    50.times {
      circle(centerX: rand(800), centerY: rand(600),
             radius: 150, stroke: white,
             strokeWidth: bind('hover', converter: hc)) {
        fill rgb(rand(255), rand(255), rand(255), 0.2)
        effect boxBlur(width: 10, height: 10, iterations: 3)
      }
    }
  }
}
                                                                      25
Propriedades em Java
public class Person {
 private StringProperty firstName;
 public void setFirstName(String val) { firstNameProperty().set(val); }
 public String getFirstName() { return firstNameProperty().get(); }
 public StringProperty firstNameProperty() {
   if (firstName == null)
     firstName = new SimpleStringProperty(this, "firstName");
   return firstName;
 }

    private StringProperty lastName;
    public void setLastName(String value) { lastNameProperty().set(value); }
    public String getLastName() { return lastNameProperty().get(); }
    public StringProperty lastNameProperty() {
      if (lastName == null) // etc.
    }
}


                                                                               26
Propriedades em GroovyFX
public class Person {
  @FXBindable String firstName;
  @FXBindable String lastName;
}




                                  27
Propriedades em GroovyFX
public class Person {
  @FXBindable String firstName;
  @FXBindable String lastName = “Smith”;
}

                                           Inicializadores opcionais




                                                                       28
Propriedades em GroovyFX
public class Person {
  @FXBindable String firstName;
  @FXBindable String lastName = “Smith”;
}
                                           Valores get and set
def p = new Person()
def last = p.lastName
p.firstName = “Agent”




                                                                 29
Propriedades em GroovyFX
public class Person {
  @FXBindable String firstName;
  @FXBindable String lastName = “Smith”;
}

def p = new Person()
def last = p.lastName                         Acesso a propriedades
p.firstName = “Agent”                         embutidas para binding

textField(text: bind(p.lastNameProperty()))



                                                                       30
Binding em GroovyFX
@FXBindable
class Time {
  Integer hours
  Integer minutes
  Integer seconds

    Double hourAngle
    Double minuteAngle
    Double secondAngle

    public Time() {
      // bind the angle properties to the clock time
      hourAngleProperty().bind((hoursProperty() * 30.0) + (minutesProperty() * 0.5))
      minuteAngleProperty().bind(minutesProperty() * 6.0)
      secondAngleProperty().bind(secondsProperty() * 6.0)
    }
}
                                                                                       31
Animation em GroovyFX
timeline(cycleCount: Timeline.INDEFINITE, autoReverse: true) {
  at (1000.ms) {
    change(rect1, 'x') to 200 tween ease_both
    change rect2.yProperty() to 200 tween linear
  }
}.play()




                                                                 32
Animation em GroovyFX
timeline(cycleCount: Timeline.INDEFINITE, autoReverse: true) {
  at (1000.ms) {
    change(rect1, 'x') to 200 tween ease_both
    change rect2.yProperty() to 200 tween linear
  }
}.play()
                                    Sintaxe facil para animacoes:
                                      at (duration) {keyframes}




                                                                    33
Animation em GroovyFX
timeline(cycleCount: Timeline.INDEFINITE, autoReverse: true) {
  at (1000.ms) {
    change(rect1, 'x') to 200
    change rect2.yProperty() to 200
  }
}.play()

                                      Key frame DSL




                                                                 34
Animation em GroovyFX
timeline(cycleCount: Timeline.INDEFINITE, autoReverse: true) {
  at (1000.ms) {
    change(rect1, 'x') to 200 tween ease_both
    change rect2.yProperty() to 200 tween linear
  }
}.play()

                               Controle de velocidade opcional




                                                                 35
Event Listeners em GroovyFX
>   Sintaxe para Closure usando controles embutidos
>   Argumentos opcionais para eventos

onMouseClicked { e ->
  timeline {
    at(3.s) { change e.source.radiusProperty() to 0 }
  }.play()
}



                                                        36
Event Listeners em GroovyFX
>   Sintaxe para Closure usando controles embutidos
>   Argumentos opcionais para eventos

onMouseClicked { MouseEvent e ->
  timeline {
    at(3.s) { change e.source.radiusProperty() to 0 }
  }.play()
}
                     Sintaxe compacta
                           {body}
                                                        37
Event Listeners em GroovyFX
>   Sintaxe para Closure usando controles embutidos
                                                Parametros opcionais para
>   Argumentos opcionais para eventos                   eventos
                                                         {event -> body}

onMouseClicked { MouseEvent e ->
  timeline {
    at(3.s) { change e.source.radiusProperty() to 0 }
  }.play()
}



                                                                            38
TableView em Java
ObservableList<Person> items = ...
TableView<Person> tableView = new TableView<Person>(items);

TableColumn<Person,String> firstNameCol =
     new TableColumn<Person,String>("First Name");

firstNameCol.setCellValueFactory(
       new Callback<CellDataFeatures<Person, String>,
               ObservableValue<String>>() {
  public ObservableValue<String> call(CellDataFeatures<Person, String> p)
  {
    return p.getValue().firstNameProperty();
  }
});

tableView.getColumns().add(firstNameCol);
                                                                            39
TableView em GroovyFX
def dateFormat = new SimpleDateFormat("yyyy-MM-dd");

tableView(items: persons) {
  tableColumn(property: "name", text: "Name", prefWidth: 150)
  tableColumn(property: "age", text: "Age", prefWidth: 50)
  tableColumn(property: "gender", text: "Gender", prefWidth: 150)
  tableColumn(property: "dob", text: "Birth", prefWidth: 150,
         type: Date,
         converter: { from -> return dateFormat.format(from) })
}




                                                                    40
Layout em Java
TextField urlField = new TextField(“http://www.google.com”);
HBox.setHgrow(urlField, Priority.ALWAYS);

HBox hbox = new HBox();
hbox.getChildren().add(urlField);

WebView webView = new WebView();
VBox.setVgrow(webView, Priority.ALWAYS);

VBox vbox = new VBox();
vbox.getChildren().addAll(hbox, webView);




                                                               41
Layout em GroovyFX

sg.stage(title: "GroovyFX WebView Demo", show: true) {
  scene(fill: groovyblue, width: 1024, height: 800) {
     vbox {
       hbox(padding: 10, spacing: 5) {
          textField(“http://www.yahoo.com”, hgrow: "always")
          button("Go”)
       }
       webView(vgrow: "always")
     }
  }
}

                                                               42
Layout em GroovyFX




                     43
Layout em GroovyFX
gridPane(hgap: 5, vgap: 10, padding: 25) {
 columnConstraints(minWidth: 50, halignment: "right")
 columnConstraints(prefWidth: 250)
 label("Send Us Your Feedback", font: "24pt sanserif",
     row: 0, columnSpan: GridPane.REMAINING, halignment: "center",
     margin: [0, 0, 10])

    label("Name: ", row: 1, column: 0)
    textField(promptText: "Your name", row: 1, column: 1, hgrow: 'always')

    label("Email:", row: 2, column: 0)
    textField(promptText: "Your email", row: 2, column: 1, hgrow: 'always')

    label("Message:", row: 3, column: 0, valignment: "baseline")
    textArea(row: 3, column: 1, hgrow: "always", vgrow: "always")

    button("Send Message", row: 4, column: 1, halignment: "right")
}
                                                                              44
Layout em GroovyFX




                     45
GroovyFX Suporta…




                    46
GroovyFX Suporta…




                    47
JavaFX Com Scala




                   48
O Que e Scala
     2001                             2006
     • Scala Comecou                  • Scala v2.0




                       2003/2004                     2011
                       • Scala v1.0                  • Scala 2.9.0 (ultima)



>   Comecou em 2001 by Martin Odersky
>   Compila para bytecodes Java
>   Linguagem puramente orientada a objetos
>   Tambem para programacao declarativa
                                                                              49
Por que Scala?
>   Compartilha muitas funcionalidades do JavaFX Script que fazem a
    programacao de interfaces mais facil:
       Checagem estatica de tipos – Encontre seus erros em tempo de
        compilacao
       Closures – Misture os comportamentos e passe-os como referencia
       Declarativa – Expresse a interface como ela deve aparecer

>   Scala tambem suporta Type Safe DSLs!
       Conversoes implicitas – extensao de classes typesafe
       Overloading de operadores – com regras de precedencia
       DelayedInit / @specialized – funcionalides avancadas da linguagem
                                                                            50
Java vs. Scala DSL
public class HelloStage extends Application {   object HelloJavaFX extends JFXApp {
                                                  stage = new Stage {
    public void start(Stage stage) {                title = "Hello Stage"
      stage.setTitle("Hello Stage");                width = 600
      stage.setWidth(600);                          height = 450
      stage.setHeight(450);                         scene = new Scene {
      Scene scene = new Scene();                      fill = LIGHTGREEN
      scene.setFill(Color.LIGHTGREEN);                content = Seq(new Rectangle {
          21 Linhas
      Rectangle rect = new Rectangle();
      rect.setX(25);                                      17 Linhas
                                                         x = 25
                                                         y = 40
      rect.setY(40);                                     width = 100
          430 Caracteres
      rect.setWidth(100);
      rect.setHeight(50);
                                                          177 Caracteres
                                                         height = 50
                                                         fill = RED
      rect.setFill(Color.RED);                        })
      scene.setRoot(new Group(rect));               }
      stage.setScene(scene);                      }
      stage.show();                             }
    }

    public static void main(String[] args) {
      launch(HelloStage.class, args);
    }
}




                                                                                      51
object DisappearingCircles extends JFXApp {
  stage = new Stage {
    title = "Disappearing 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)
      }
    }
  }
}
                                                           52
object DisappearingCircles extends JFXApp {
  stage = new Stage {
    title = "Disappearing Circles"
    width = 800
    height = 600
         Classe base para aplicacoes JavaFX
    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)
      }
    }
  }
}
                                                           53
object DisappearingCircles extends JFXApp {
  stage = new Stage {
    title = "Disappearing Circles"
    width = 800
    height = 600
    scene = new Scene {              Definicao declarativa do Stage
      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)
      }
    }
  }
}
                                                                      54
object DisappearingCircles extends JFXApp {
  stage = new Stage {
    title = "Disappearing Circles"      Definicoes de propriedades
    width = 800
    height = 600                                embutidas
    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)
      }
    }
  }
}
                                                                     55
object DisappearingCircles extends JFXApp {
  stage = new Stage {
    title = "Disappearing Circles"
    width = 800
    height = 600                        Criacao de sequencias via
    scene = new Scene {                           Loop
      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)
      }
    }
  }
}
                                                                    56
Binding em Scala
Infix Addition/Subtraction/Multiplication/Division:
height <== rect1.height + rect2.height
Aggregate Operators:
width <== max(rect1.width, rect2.width, rect3.width)
Conditional Expressions:
strokeWidth <== when (hover) then 4 otherwise 0
Compound Expressions:
text <== when (rect.hover || circle.hover && !disabled) then
  textField.text + " is enabled" otherwise "disabled"

                                                               57
Animation em Scala
val timeline = new Timeline {
  cycleCount = INDEFINITE
  autoReverse = true
  keyFrames = for (circle <- circles) yield at (40 s) {
    Set(
      circle.centerX -> random * stage.width,
      circle.centerY -> random * stage.height
    )
  }
}
timeline.play();

                                                          58
Animacoes JavaFX Script-like
Animation em Scala      syntax: at (duration) {keyframes}
val timeline = new Timeline {
  cycleCount = INDEFINITE
  autoReverse = true
  keyFrames = for (circle <- circles) yield at (40 s) {
    Set(
      circle.centerX -> random * stage.width,
      circle.centerY -> random * stage.height
    )
  }
}
timeline.play();

                                                            59
Animation in Scala
val timeline = new Timeline {
  cycleCount = INDEFINITE
  autoReverse = true
  keyFrames = for (circle <- circles) yield at (40 s) {
    Set(
      circle.centerX -> random * stage.width,
      circle.centerY -> random * stage.height
    )
  }
}
                              overloading de operadores para
timeline.play();
                                     sintaxe da animacao
                                                               60
Animation in Scala
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();             Controle de
                         velocidade opcional
                                                           61
Event Listeners em Scala
>   Suportado usando sintaxe Closure embutida
>   Argumentos opcionais para tratamento de eventos
>   100% tipagem forte


    onMouseClicked = {
      Timeline(at(3 s){radius->0}).play()
    }


                                                      62
Event Listeners em Scala
>   Suportado usando sintaxe Closure embutida
>   Argumentos opcionais para tratamento de eventos
>   100% tipagem forte


    onMouseClicked = {
      Timeline(at(3 s){radius->0}).play()
    }
                     Sintaxe compacta
                           {body}
                                                      63
Event Listeners em Scala
>   Suportado usando sintaxe Closure embutida
>   Argumentos opcionais para tratamento de eventos
                                               Evento = parametro opcional
>   100% tipagem forte                              {(event) => body}



    onMouseClicked = { (e: MouseEvent) =>
      Timeline(at(3 s){radius->0}).play()
    }


                                                                             64
Sobre o projeto Visage
>   “Visage e uma domain specific language (DSL) projetada para
    suportar a funcao de construcao de interfaces.”



>   Metas do projeto Visage:
       Compila para JavaFX Java APIs
       Envolve toda a linguagem (Annotations, Maps, etc.)
       Suporta outros Toolkits

>   Venha participar do time!
>   Para mais informacoes: http://visage-lang.org/
                                                                  65
E sobre o JavaFX no… Visage
Stage {
  title: "Hello Stage"
  width: 600
  height: 450
  scene: Scene {
    fill: Color.LIGHTGREEN
    content: Rectangle {
      x: 25
      y: 40
      width: 100
      height: 50
      fill: Color.RED
    }
  }
}

                              66
E sobre o JavaFX no… Visage
Stage {
  title: "Hello Stage"
  width: 600
  height: 450
  scene: Scene {
    fill: Color.LIGHTGREEN
    content: Rectangle {
      x: 25
      y: 40
      width: 100
      height: 50
      fill: Color.RED
    }
  }
}

                              67
E sobre o JavaFX no… Visage
Stage {
  title: "Hello Stage"
  width: 600
  height: 450
  Scene {
    fill: Color.LIGHTGREEN
    Rectangle {
      x: 25
      y: 40
      width: 100
      height: 50
      fill: Color.RED
    }
  }
}

                              68
Visage e um JavaFX Script++
>   Parametros padrao
>   Nova sintaxe para:
       Angulos – 35deg, 4rad, 1turn
       Cores – #DDCCBB, #AA33AA|CC
       Medidas – 5px, 2pt, 3in, 4sp
>   Checagem de null-reference
       var width = rect!.width
>   Bindable Maps embutida (Em breve!)
       var fruitMap = ["red" : apple, "yellow" : banana]
       var fruit = bind fruitMap["red"]
                                                            69
Visage e JavaFX 2.0 foram feitos um para o outro…
>   Binding melhorado
       Retem a avaliacao tardia de variaveis com um poder expressivo
        adicional
>   Colecoes integradas
       Sequencias e mapas automaticamente convertidos entre JavaFX
        Observable Lists/Maps
>   Sintaxe de animacoes embutida
       Coloca o JavaFX em um subsistema de animacoes
       Prove uma API mais limpa e consistente


                                                                        70
Conclusao
>   Voce pode escrever aplicacoes JavaFX com Java puro
>   JavaFX tambem e utilizavel por linguagens alternativas
>   Voce pode ter o suporte melhorado utilizando bibliotecas
    DSL
     GroovyFX

     ScalaFX

>   Ou uma linguagem de interfaces que roda na JVM
     Visage
Pro JavaFX 2 Platform em breve!

          >   Primeiro trimestre de 2012
          >   Todos os exemplos reescritos em Java
          >   Cobre as novas bibliotecas da versao
              2.0
          >   Incluira ScalaFX, GroovyFX e Visage


                                                     72
Stephen Chin
steveonjava@gmail.com
tweet: @steveonjava
                        73

Contenu connexe

Tendances

Specification-Driven Development of REST APIs by Alexander Zinchuk
Specification-Driven Development of REST APIs by Alexander Zinchuk   Specification-Driven Development of REST APIs by Alexander Zinchuk
Specification-Driven Development of REST APIs by Alexander Zinchuk OdessaJS Conf
 
TDC2018SP | Trilha Go - Processando analise genetica em background com Go
TDC2018SP | Trilha Go - Processando analise genetica em background com GoTDC2018SP | Trilha Go - Processando analise genetica em background com Go
TDC2018SP | Trilha Go - Processando analise genetica em background com Gotdc-globalcode
 
FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6Dmitry Soshnikov
 
Building fast interpreters in Rust
Building fast interpreters in RustBuilding fast interpreters in Rust
Building fast interpreters in RustIngvar Stepanyan
 
Clojure: Functional Concurrency for the JVM (presented at Open Source Bridge)
Clojure: Functional Concurrency for the JVM (presented at Open Source Bridge)Clojure: Functional Concurrency for the JVM (presented at Open Source Bridge)
Clojure: Functional Concurrency for the JVM (presented at Open Source Bridge)Howard Lewis Ship
 
HTML5 JavaScript APIs
HTML5 JavaScript APIsHTML5 JavaScript APIs
HTML5 JavaScript APIsRemy Sharp
 
JavaScript and the AST
JavaScript and the ASTJavaScript and the AST
JavaScript and the ASTJarrod Overson
 
Node.js in action
Node.js in actionNode.js in action
Node.js in actionSimon Su
 
When Bad Things Come In Good Packages
When Bad Things Come In Good PackagesWhen Bad Things Come In Good Packages
When Bad Things Come In Good PackagesSaumil Shah
 
Ruby closures, how are they possible?
Ruby closures, how are they possible?Ruby closures, how are they possible?
Ruby closures, how are they possible?Carlos Alonso Pérez
 
Intravert Server side processing for Cassandra
Intravert Server side processing for CassandraIntravert Server side processing for Cassandra
Intravert Server side processing for CassandraEdward Capriolo
 
Heroku pop-behind-the-sense
Heroku pop-behind-the-senseHeroku pop-behind-the-sense
Heroku pop-behind-the-senseBen Lin
 
Обзор фреймворка Twisted
Обзор фреймворка TwistedОбзор фреймворка Twisted
Обзор фреймворка TwistedMaxim Kulsha
 
Open Source Ajax Solution @OSDC.tw 2009
Open Source Ajax  Solution @OSDC.tw 2009Open Source Ajax  Solution @OSDC.tw 2009
Open Source Ajax Solution @OSDC.tw 2009Robbie Cheng
 
PHPUnit elevato alla Symfony2
PHPUnit elevato alla Symfony2PHPUnit elevato alla Symfony2
PHPUnit elevato alla Symfony2eugenio pombi
 

Tendances (20)

Specification-Driven Development of REST APIs by Alexander Zinchuk
Specification-Driven Development of REST APIs by Alexander Zinchuk   Specification-Driven Development of REST APIs by Alexander Zinchuk
Specification-Driven Development of REST APIs by Alexander Zinchuk
 
TDD per Webapps
TDD per WebappsTDD per Webapps
TDD per Webapps
 
TDC2018SP | Trilha Go - Processando analise genetica em background com Go
TDC2018SP | Trilha Go - Processando analise genetica em background com GoTDC2018SP | Trilha Go - Processando analise genetica em background com Go
TDC2018SP | Trilha Go - Processando analise genetica em background com Go
 
Groovy's Builder
Groovy's BuilderGroovy's Builder
Groovy's Builder
 
FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6
 
Building fast interpreters in Rust
Building fast interpreters in RustBuilding fast interpreters in Rust
Building fast interpreters in Rust
 
Clojure: Functional Concurrency for the JVM (presented at Open Source Bridge)
Clojure: Functional Concurrency for the JVM (presented at Open Source Bridge)Clojure: Functional Concurrency for the JVM (presented at Open Source Bridge)
Clojure: Functional Concurrency for the JVM (presented at Open Source Bridge)
 
HTML5 JavaScript APIs
HTML5 JavaScript APIsHTML5 JavaScript APIs
HTML5 JavaScript APIs
 
Vaadin 7
Vaadin 7Vaadin 7
Vaadin 7
 
JavaScript and the AST
JavaScript and the ASTJavaScript and the AST
JavaScript and the AST
 
Node.js in action
Node.js in actionNode.js in action
Node.js in action
 
mobl
moblmobl
mobl
 
When Bad Things Come In Good Packages
When Bad Things Come In Good PackagesWhen Bad Things Come In Good Packages
When Bad Things Come In Good Packages
 
ES2015 workflows
ES2015 workflowsES2015 workflows
ES2015 workflows
 
Ruby closures, how are they possible?
Ruby closures, how are they possible?Ruby closures, how are they possible?
Ruby closures, how are they possible?
 
Intravert Server side processing for Cassandra
Intravert Server side processing for CassandraIntravert Server side processing for Cassandra
Intravert Server side processing for Cassandra
 
Heroku pop-behind-the-sense
Heroku pop-behind-the-senseHeroku pop-behind-the-sense
Heroku pop-behind-the-sense
 
Обзор фреймворка Twisted
Обзор фреймворка TwistedОбзор фреймворка Twisted
Обзор фреймворка Twisted
 
Open Source Ajax Solution @OSDC.tw 2009
Open Source Ajax  Solution @OSDC.tw 2009Open Source Ajax  Solution @OSDC.tw 2009
Open Source Ajax Solution @OSDC.tw 2009
 
PHPUnit elevato alla Symfony2
PHPUnit elevato alla Symfony2PHPUnit elevato alla Symfony2
PHPUnit elevato alla Symfony2
 

Similaire à JavaFX 2.0 With Alternative Languages [Portuguese]

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
 
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 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
 
Java Fx Overview Tech Tour
Java Fx Overview Tech TourJava Fx Overview Tech Tour
Java Fx Overview Tech TourCarol McDonald
 
Don't panic in Fortaleza - ScalaFX
Don't panic in Fortaleza - ScalaFXDon't panic in Fortaleza - ScalaFX
Don't panic in Fortaleza - ScalaFXAlain Béarez
 
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
 
Java FX 2.0 - A Developer's Guide
Java FX 2.0 - A Developer's GuideJava FX 2.0 - A Developer's Guide
Java FX 2.0 - A Developer's GuideStephen Chin
 
Greach, GroovyFx Workshop
Greach, GroovyFx WorkshopGreach, GroovyFx Workshop
Greach, GroovyFx WorkshopDierk König
 
How to build a html5 websites.v1
How to build a html5 websites.v1How to build a html5 websites.v1
How to build a html5 websites.v1Bitla Software
 
Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)Yevgeniy Brikman
 
I Can't Believe It's Not Flash
I Can't Believe It's Not FlashI Can't Believe It's Not Flash
I Can't Believe It's Not FlashThomas Fuchs
 
Intro to JavaFX & Widget FX
Intro to JavaFX & Widget FXIntro to JavaFX & Widget FX
Intro to JavaFX & Widget FXStephen Chin
 
JavaFX in Action (devoxx'16)
JavaFX in Action (devoxx'16)JavaFX in Action (devoxx'16)
JavaFX in Action (devoxx'16)Alexander Casall
 
Building mobile web apps with Mobello
Building mobile web apps with MobelloBuilding mobile web apps with Mobello
Building mobile web apps with MobelloJeong-Geun Kim
 
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
 

Similaire à JavaFX 2.0 With Alternative Languages [Portuguese] (20)

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
 
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 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
 
Java Fx Overview Tech Tour
Java Fx Overview Tech TourJava Fx Overview Tech Tour
Java Fx Overview Tech Tour
 
Don't panic in Fortaleza - ScalaFX
Don't panic in Fortaleza - ScalaFXDon't panic in Fortaleza - ScalaFX
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)
 
Java FX 2.0 - A Developer's Guide
Java FX 2.0 - A Developer's GuideJava FX 2.0 - A Developer's Guide
Java FX 2.0 - A Developer's Guide
 
Greach, GroovyFx Workshop
Greach, GroovyFx WorkshopGreach, GroovyFx Workshop
Greach, GroovyFx Workshop
 
JavaFX introduction
JavaFX introductionJavaFX introduction
JavaFX introduction
 
How to build a html5 websites.v1
How to build a html5 websites.v1How to build a html5 websites.v1
How to build a html5 websites.v1
 
Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)
 
I Can't Believe It's Not Flash
I Can't Believe It's Not FlashI Can't Believe It's Not Flash
I Can't Believe It's Not Flash
 
JavaFX
JavaFXJavaFX
JavaFX
 
Griffon @ Svwjug
Griffon @ SvwjugGriffon @ Svwjug
Griffon @ Svwjug
 
Intro to JavaFX & Widget FX
Intro to JavaFX & Widget FXIntro to JavaFX & Widget FX
Intro to JavaFX & Widget FX
 
JavaFX in Action (devoxx'16)
JavaFX in Action (devoxx'16)JavaFX in Action (devoxx'16)
JavaFX in Action (devoxx'16)
 
JavaFX Overview
JavaFX OverviewJavaFX Overview
JavaFX Overview
 
Building mobile web apps with Mobello
Building mobile web apps with MobelloBuilding mobile web apps with Mobello
Building mobile web apps with Mobello
 
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
 

Plus de Stephen Chin

DevOps Tools for Java Developers v2
DevOps Tools for Java Developers v2DevOps Tools for Java Developers v2
DevOps Tools for Java Developers v2Stephen Chin
 
10 Ways Everyone Can Support the Java Community
10 Ways Everyone Can Support the Java Community10 Ways Everyone Can Support the Java Community
10 Ways Everyone Can Support the Java CommunityStephen Chin
 
Java Clients and JavaFX: The Definitive Guide
Java Clients and JavaFX: The Definitive GuideJava Clients and JavaFX: The Definitive Guide
Java Clients and JavaFX: The Definitive GuideStephen Chin
 
DevOps Tools for Java Developers
DevOps Tools for Java DevelopersDevOps Tools for Java Developers
DevOps Tools for Java DevelopersStephen Chin
 
Java Clients and JavaFX - Presented to LJC
Java Clients and JavaFX - Presented to LJCJava Clients and JavaFX - Presented to LJC
Java Clients and JavaFX - Presented to LJCStephen Chin
 
RetroPi Handheld Raspberry Pi Gaming Console
RetroPi Handheld Raspberry Pi Gaming ConsoleRetroPi Handheld Raspberry Pi Gaming Console
RetroPi Handheld Raspberry Pi Gaming ConsoleStephen Chin
 
JavaFX on Mobile (by Johan Vos)
JavaFX on Mobile (by Johan Vos)JavaFX on Mobile (by Johan Vos)
JavaFX on Mobile (by Johan Vos)Stephen Chin
 
Confessions of a Former Agile Methodologist (JFrog Edition)
Confessions of a Former Agile Methodologist (JFrog Edition)Confessions of a Former Agile Methodologist (JFrog Edition)
Confessions of a Former Agile Methodologist (JFrog Edition)Stephen Chin
 
Devoxx4Kids Lego Workshop
Devoxx4Kids Lego WorkshopDevoxx4Kids Lego Workshop
Devoxx4Kids Lego WorkshopStephen Chin
 
Raspberry Pi with Java (JJUG)
Raspberry Pi with Java (JJUG)Raspberry Pi with Java (JJUG)
Raspberry Pi with Java (JJUG)Stephen Chin
 
Confessions of a Former Agile Methodologist
Confessions of a Former Agile MethodologistConfessions of a Former Agile Methodologist
Confessions of a Former Agile MethodologistStephen Chin
 
Internet of Things Magic Show
Internet of Things Magic ShowInternet of Things Magic Show
Internet of Things Magic ShowStephen Chin
 
Zombie Time - JSR 310 for the Undead
Zombie Time - JSR 310 for the UndeadZombie Time - JSR 310 for the Undead
Zombie Time - JSR 310 for the UndeadStephen Chin
 
JCrete Embedded Java Workshop
JCrete Embedded Java WorkshopJCrete Embedded Java Workshop
JCrete Embedded Java WorkshopStephen Chin
 
Oracle IoT Kids Workshop
Oracle IoT Kids WorkshopOracle IoT Kids Workshop
Oracle IoT Kids WorkshopStephen Chin
 
OpenJFX on Android and Devices
OpenJFX on Android and DevicesOpenJFX on Android and Devices
OpenJFX on Android and DevicesStephen Chin
 
Java on Raspberry Pi Lab
Java on Raspberry Pi LabJava on Raspberry Pi Lab
Java on Raspberry Pi LabStephen Chin
 
Java 8 for Tablets, Pis, and Legos
Java 8 for Tablets, Pis, and LegosJava 8 for Tablets, Pis, and Legos
Java 8 for Tablets, Pis, and LegosStephen Chin
 
Devoxx4Kids NAO Workshop
Devoxx4Kids NAO WorkshopDevoxx4Kids NAO Workshop
Devoxx4Kids NAO WorkshopStephen Chin
 

Plus de Stephen Chin (20)

DevOps Tools for Java Developers v2
DevOps Tools for Java Developers v2DevOps Tools for Java Developers v2
DevOps Tools for Java Developers v2
 
10 Ways Everyone Can Support the Java Community
10 Ways Everyone Can Support the Java Community10 Ways Everyone Can Support the Java Community
10 Ways Everyone Can Support the Java Community
 
Java Clients and JavaFX: The Definitive Guide
Java Clients and JavaFX: The Definitive GuideJava Clients and JavaFX: The Definitive Guide
Java Clients and JavaFX: The Definitive Guide
 
DevOps Tools for Java Developers
DevOps Tools for Java DevelopersDevOps Tools for Java Developers
DevOps Tools for Java Developers
 
Java Clients and JavaFX - Presented to LJC
Java Clients and JavaFX - Presented to LJCJava Clients and JavaFX - Presented to LJC
Java Clients and JavaFX - Presented to LJC
 
RetroPi Handheld Raspberry Pi Gaming Console
RetroPi Handheld Raspberry Pi Gaming ConsoleRetroPi Handheld Raspberry Pi Gaming Console
RetroPi Handheld Raspberry Pi Gaming Console
 
JavaFX on Mobile (by Johan Vos)
JavaFX on Mobile (by Johan Vos)JavaFX on Mobile (by Johan Vos)
JavaFX on Mobile (by Johan Vos)
 
Confessions of a Former Agile Methodologist (JFrog Edition)
Confessions of a Former Agile Methodologist (JFrog Edition)Confessions of a Former Agile Methodologist (JFrog Edition)
Confessions of a Former Agile Methodologist (JFrog Edition)
 
Devoxx4Kids Lego Workshop
Devoxx4Kids Lego WorkshopDevoxx4Kids Lego Workshop
Devoxx4Kids Lego Workshop
 
Raspberry Pi with Java (JJUG)
Raspberry Pi with Java (JJUG)Raspberry Pi with Java (JJUG)
Raspberry Pi with Java (JJUG)
 
Confessions of a Former Agile Methodologist
Confessions of a Former Agile MethodologistConfessions of a Former Agile Methodologist
Confessions of a Former Agile Methodologist
 
Internet of Things Magic Show
Internet of Things Magic ShowInternet of Things Magic Show
Internet of Things Magic Show
 
Zombie Time - JSR 310 for the Undead
Zombie Time - JSR 310 for the UndeadZombie Time - JSR 310 for the Undead
Zombie Time - JSR 310 for the Undead
 
JCrete Embedded Java Workshop
JCrete Embedded Java WorkshopJCrete Embedded Java Workshop
JCrete Embedded Java Workshop
 
Oracle IoT Kids Workshop
Oracle IoT Kids WorkshopOracle IoT Kids Workshop
Oracle IoT Kids Workshop
 
OpenJFX on Android and Devices
OpenJFX on Android and DevicesOpenJFX on Android and Devices
OpenJFX on Android and Devices
 
Java on Raspberry Pi Lab
Java on Raspberry Pi LabJava on Raspberry Pi Lab
Java on Raspberry Pi Lab
 
Java 8 for Tablets, Pis, and Legos
Java 8 for Tablets, Pis, and LegosJava 8 for Tablets, Pis, and Legos
Java 8 for Tablets, Pis, and Legos
 
DukeScript
DukeScriptDukeScript
DukeScript
 
Devoxx4Kids NAO Workshop
Devoxx4Kids NAO WorkshopDevoxx4Kids NAO Workshop
Devoxx4Kids NAO Workshop
 

Dernier

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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
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
 
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
 
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
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 

Dernier (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...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
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
 
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
 
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...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 

JavaFX 2.0 With Alternative Languages [Portuguese]

  • 1. Plataforma JavaFX 2.0, GroovyFX, ScalaFX e Visage Stephen Chin Chefe de metodologias Ageis, GXS steveonjava@gmail.com tweet: @steveonjava Translated by Marcelo Quinta
  • 2. Conheca o palestrante Stephen Chin http://steveonjava.com/ • Java Champion • Autor Family Man • Pro JavaFX Platform • Pro Android Flash • Fundador de projetos Open Motorcyclist Source • JFXtras • ScalaFX • WidgetFX • Visage
  • 3. A plataforma JavaFX 2.0 Experiencia imersiva Desktop combinando o melhor do JavaFX e HTML5 > Use seus conhecimentos Java com as modernas APIs JavaFX > Integre Java, JavaScript e HTML5 na mesma aplicacao > Nova gama de graficos usa as vantagens de aceleracao de hardware para aplicacoes 2D e 3D > Use sua IDE favorita: NetBeans, Eclipse, IntelliJ, etc.
  • 4. JavaFX agora e Open Source! Parte do projeto OpenJDK Controles disponiveis agora codigo adicional adicionado incrementalmente Pagina do projeto: > http://openjdk.java.net/projects/openjfx/ 4
  • 5. E vai rodar nos Tablets! > iPad (iOS) > Linux (plataforma popular que executa algo semelhante a Java) Nenhuma data de release foi anunciada 5
  • 6. Construindo Aplicacoes JavaFX > Pode ser executada no navegador ou no Desktop > Inclui builders para construcoes declarativas > Linguagens alternativas tambem podem ser utilizadas para simplificar a criacao da interface de usuario  GroovyFX  ScalaFX  Visage 6
  • 7. Ola JUG (Versao Java) public class HelloJUG extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) { primaryStage.setTitle("Ola JUG"); 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(new Font(30)); text.setText("Ola JUG"); root.getChildren().add(text); primaryStage.setScene(scene); primaryStage.show(); } } 7
  • 8. Ola JUG (Versao com o Builder) public void start(Stage primaryStage) { primaryStage.setTitle("Ola JUG"); primaryStage.setScene(SceneBuilder.create() .width(400) .height(250) .fill(Color.ALICEBLUE) .root( GroupBuilder.create().children( TextBuilder.create() .x(105) .y(120) .text("Ola JUG") .font(new Font(30)) .build() ).build() ) .build()); primaryStage.show(); } 8
  • 9. Ola JUG (Versao GroovyFX) GroovyFX.start { primaryStage -> def sg = new SceneGraphBuilder() sg.stage( title: 'Ola JUG', show: true) { scene( fill: aliceblue, width: 400, height: 250) { text( x: 105, y: 120, text: "Ola JUG" font: "30pt") } } } 9
  • 10. Ola JUG (Versao JavaFX) object HelloJUG extends JFXApp { stage = new Stage { title = "Ola JUG" width = 400 height = 250 scene = new Scene { fill = BLUE Text { x = 105 y = 120 text = "Ola JUG" font = Font(size: 30) } } } } 10
  • 11. Ola JUG (Versao Visage) Stage { title: "Ola JUG" width: 400 height: 250 scene: Scene { fill: BLUE content: Text { x: 105 y: 120 text: "Ola JUG" font: Font {size: 30pt} } } } 11
  • 12. Mostrando HTML no JavaFX public class WebViewTest extends Application { public static void main(String[] args) { launch(WebViewTest.class, args); } @Override public void start(Stage stage) { WebView webView = new WebView(); webView.getEngine().load("http://google.com"); Scene scene = new Scene(webView); stage.setScene(scene); stage.setTitle("Web Test"); stage.show(); }} 12
  • 13. Mostrando HTML no JavaFX 13
  • 14. Chamando Javascript pelo JavaFX String script = "alert('Aooo Goiania!');”; eng.executeScript(script); 14
  • 15. Respondendo a eventos do browser Eventos suportados: > Alert/Confirm/Prompt:  Responda funcoes do Javascript de interacao do usuario > Resize:  Web page move-se ou rearranja ao tamanho da janela > Status  Web page muda o texto do status > Visibility  Esconde ou mostra algum objeto da janela > Popup  Cria uma segunda janela 15
  • 16. Demo de integracao HTML5/JavaFX 16
  • 18. Features of Groovy > Linguagem moderna  Closures  Transforms AST  Linguagem fortemente tipada > Grande integracao com Java  Muito facil fazer a portabilidade de Java para Groovy > Sintaxe declarativa com builders GroovyFX  Familiar aos desenvolvedores Groovy e JavaFX Script
  • 19. Java vs. GroovyFX DSL public class HelloStage extends Application { GroovyFX.start { stage -> def sg = new SceneGraphBuilder(stage) public void start(Stage stage) { stage.setTitle("Hello Stage"); sg.stage(title: “Hello Stage”, width: 600, height: 450) { stage.setWidth(600); scene(fill: groovyblue) { stage.setHeight(450); rectangle(x: 25, y: 40, width: 100, height: 50, fill: Scene scene = new Scene(); red) scene.setFill(Color.LIGHTGREEN); } 21 Linhas Rectangle rect = new Rectangle(); rect.setX(25); } } 8 Linhas rect.setY(40); 430 Caracteres rect.setWidth(100); rect.setHeight(50); 180 Caracteres rect.setFill(Color.RED); scene.setRoot(new Group(rect)); stage.setScene(scene); stage.show(); } public static void main(String[] args) { launch(HelloStage.class, args); } } 19
  • 20. def sg = new SceneGraphBuilder() def hc = { hover -> hover ? 4 : 0 } sg.stage(title: 'Vanishing Circles', show: true) { scene(fill: black, width: 800, height: 600) { 50.times { circle(centerX: rand(800), centerY: rand(600), radius: 150, stroke: white, strokeWidth: bind('hover', converter: hc)) { fill rgb(rand(255), rand(255), rand(255), 0.2) effect boxBlur(width: 10, height: 10, iterations: 3) } } } } 20
  • 21. def sg = new SceneGraphBuilder() def hc = { hover -> hover ? 4 : 0 } sg.stage(title: 'Vanishing Circles',Builder para Scene Graphs do show: true) { GroovyFX scene(fill: black, width: 800, height: 600) { 50.times { circle(centerX: rand(800), centerY: rand(600), radius: 150, stroke: white, strokeWidth: bind('hover', converter: hc)) { fill rgb(rand(255), rand(255), rand(255), 0.2) effect boxBlur(width: 10, height: 10, iterations: 3) } } } } 21
  • 22. def sg = new SceneGraphBuilder() def hc = { hover -> hover ? 4 : 0 } sg.stage(title: 'Vanishing Circles', show: true) { scene(fill: black, width: 800, height: 600) { 50.times { circle(centerX: rand(800), centerY: rand(600), Definicao declarativa do Stage radius: 150, stroke: white, strokeWidth: bind('hover', converter: hc)) { fill rgb(rand(255), rand(255), rand(255), 0.2) effect boxBlur(width: 10, height: 10, iterations: 3) } } } } 22
  • 23. def sg = new SceneGraphBuilder() def hc = { hover -> hover ? 4 : 0 } Definicao de propriedades sg.stage(title: 'Vanishing Circles', show: true) { embutdidas scene(fill: black, width: 800, height: 600) { 50.times { circle(centerX: rand(800), centerY: rand(600), radius: 150, stroke: white, strokeWidth: bind('hover', converter: hc)) { fill rgb(rand(255), rand(255), rand(255), 0.2) effect boxBlur(width: 10, height: 10, iterations: 3) } } } } 23
  • 24. def sg = new SceneGraphBuilder() def hc = { hover -> hover ? 4 : 0 } sg.stage(title: 'Vanishing Circles', show: true) { scene(fill: black, width: 800, height: Bind para propriedades 600) { 50.times { circle(centerX: rand(800), centerY: rand(600), radius: 150, stroke: white, strokeWidth: bind('hover', converter: hc)) { fill rgb(rand(255), rand(255), rand(255), 0.2) effect boxBlur(width: 10, height: 10, iterations: 3) } } } } 24
  • 25. def sg = new SceneGraphBuilder() def hc = { hover -> hover ? 4 : 0 } sg.stage(title: 'Vanishing Circles', show: true) { Criacao de sequencias via loop scene(fill: black, width: 800, height: 600) { 50.times { circle(centerX: rand(800), centerY: rand(600), radius: 150, stroke: white, strokeWidth: bind('hover', converter: hc)) { fill rgb(rand(255), rand(255), rand(255), 0.2) effect boxBlur(width: 10, height: 10, iterations: 3) } } } } 25
  • 26. Propriedades em Java public class Person { private StringProperty firstName; public void setFirstName(String val) { firstNameProperty().set(val); } public String getFirstName() { return firstNameProperty().get(); } public StringProperty firstNameProperty() { if (firstName == null) firstName = new SimpleStringProperty(this, "firstName"); return firstName; } private StringProperty lastName; public void setLastName(String value) { lastNameProperty().set(value); } public String getLastName() { return lastNameProperty().get(); } public StringProperty lastNameProperty() { if (lastName == null) // etc. } } 26
  • 27. Propriedades em GroovyFX public class Person { @FXBindable String firstName; @FXBindable String lastName; } 27
  • 28. Propriedades em GroovyFX public class Person { @FXBindable String firstName; @FXBindable String lastName = “Smith”; } Inicializadores opcionais 28
  • 29. Propriedades em GroovyFX public class Person { @FXBindable String firstName; @FXBindable String lastName = “Smith”; } Valores get and set def p = new Person() def last = p.lastName p.firstName = “Agent” 29
  • 30. Propriedades em GroovyFX public class Person { @FXBindable String firstName; @FXBindable String lastName = “Smith”; } def p = new Person() def last = p.lastName Acesso a propriedades p.firstName = “Agent” embutidas para binding textField(text: bind(p.lastNameProperty())) 30
  • 31. Binding em GroovyFX @FXBindable class Time { Integer hours Integer minutes Integer seconds Double hourAngle Double minuteAngle Double secondAngle public Time() { // bind the angle properties to the clock time hourAngleProperty().bind((hoursProperty() * 30.0) + (minutesProperty() * 0.5)) minuteAngleProperty().bind(minutesProperty() * 6.0) secondAngleProperty().bind(secondsProperty() * 6.0) } } 31
  • 32. Animation em GroovyFX timeline(cycleCount: Timeline.INDEFINITE, autoReverse: true) { at (1000.ms) { change(rect1, 'x') to 200 tween ease_both change rect2.yProperty() to 200 tween linear } }.play() 32
  • 33. Animation em GroovyFX timeline(cycleCount: Timeline.INDEFINITE, autoReverse: true) { at (1000.ms) { change(rect1, 'x') to 200 tween ease_both change rect2.yProperty() to 200 tween linear } }.play() Sintaxe facil para animacoes: at (duration) {keyframes} 33
  • 34. Animation em GroovyFX timeline(cycleCount: Timeline.INDEFINITE, autoReverse: true) { at (1000.ms) { change(rect1, 'x') to 200 change rect2.yProperty() to 200 } }.play() Key frame DSL 34
  • 35. Animation em GroovyFX timeline(cycleCount: Timeline.INDEFINITE, autoReverse: true) { at (1000.ms) { change(rect1, 'x') to 200 tween ease_both change rect2.yProperty() to 200 tween linear } }.play() Controle de velocidade opcional 35
  • 36. Event Listeners em GroovyFX > Sintaxe para Closure usando controles embutidos > Argumentos opcionais para eventos onMouseClicked { e -> timeline { at(3.s) { change e.source.radiusProperty() to 0 } }.play() } 36
  • 37. Event Listeners em GroovyFX > Sintaxe para Closure usando controles embutidos > Argumentos opcionais para eventos onMouseClicked { MouseEvent e -> timeline { at(3.s) { change e.source.radiusProperty() to 0 } }.play() } Sintaxe compacta {body} 37
  • 38. Event Listeners em GroovyFX > Sintaxe para Closure usando controles embutidos Parametros opcionais para > Argumentos opcionais para eventos eventos {event -> body} onMouseClicked { MouseEvent e -> timeline { at(3.s) { change e.source.radiusProperty() to 0 } }.play() } 38
  • 39. TableView em Java ObservableList<Person> items = ... TableView<Person> tableView = new TableView<Person>(items); TableColumn<Person,String> firstNameCol = new TableColumn<Person,String>("First Name"); firstNameCol.setCellValueFactory( new Callback<CellDataFeatures<Person, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<Person, String> p) { return p.getValue().firstNameProperty(); } }); tableView.getColumns().add(firstNameCol); 39
  • 40. TableView em GroovyFX def dateFormat = new SimpleDateFormat("yyyy-MM-dd"); tableView(items: persons) { tableColumn(property: "name", text: "Name", prefWidth: 150) tableColumn(property: "age", text: "Age", prefWidth: 50) tableColumn(property: "gender", text: "Gender", prefWidth: 150) tableColumn(property: "dob", text: "Birth", prefWidth: 150, type: Date, converter: { from -> return dateFormat.format(from) }) } 40
  • 41. Layout em Java TextField urlField = new TextField(“http://www.google.com”); HBox.setHgrow(urlField, Priority.ALWAYS); HBox hbox = new HBox(); hbox.getChildren().add(urlField); WebView webView = new WebView(); VBox.setVgrow(webView, Priority.ALWAYS); VBox vbox = new VBox(); vbox.getChildren().addAll(hbox, webView); 41
  • 42. Layout em GroovyFX sg.stage(title: "GroovyFX WebView Demo", show: true) { scene(fill: groovyblue, width: 1024, height: 800) { vbox { hbox(padding: 10, spacing: 5) { textField(“http://www.yahoo.com”, hgrow: "always") button("Go”) } webView(vgrow: "always") } } } 42
  • 44. Layout em GroovyFX gridPane(hgap: 5, vgap: 10, padding: 25) { columnConstraints(minWidth: 50, halignment: "right") columnConstraints(prefWidth: 250) label("Send Us Your Feedback", font: "24pt sanserif", row: 0, columnSpan: GridPane.REMAINING, halignment: "center", margin: [0, 0, 10]) label("Name: ", row: 1, column: 0) textField(promptText: "Your name", row: 1, column: 1, hgrow: 'always') label("Email:", row: 2, column: 0) textField(promptText: "Your email", row: 2, column: 1, hgrow: 'always') label("Message:", row: 3, column: 0, valignment: "baseline") textArea(row: 3, column: 1, hgrow: "always", vgrow: "always") button("Send Message", row: 4, column: 1, halignment: "right") } 44
  • 49. O Que e Scala 2001 2006 • Scala Comecou • Scala v2.0 2003/2004 2011 • Scala v1.0 • Scala 2.9.0 (ultima) > Comecou em 2001 by Martin Odersky > Compila para bytecodes Java > Linguagem puramente orientada a objetos > Tambem para programacao declarativa 49
  • 50. Por que Scala? > Compartilha muitas funcionalidades do JavaFX Script que fazem a programacao de interfaces mais facil:  Checagem estatica de tipos – Encontre seus erros em tempo de compilacao  Closures – Misture os comportamentos e passe-os como referencia  Declarativa – Expresse a interface como ela deve aparecer > Scala tambem suporta Type Safe DSLs!  Conversoes implicitas – extensao de classes typesafe  Overloading de operadores – com regras de precedencia  DelayedInit / @specialized – funcionalides avancadas da linguagem 50
  • 51. Java vs. Scala DSL public class HelloStage extends Application { object HelloJavaFX extends JFXApp { stage = new Stage { public void start(Stage stage) { title = "Hello Stage" stage.setTitle("Hello Stage"); width = 600 stage.setWidth(600); height = 450 stage.setHeight(450); scene = new Scene { Scene scene = new Scene(); fill = LIGHTGREEN scene.setFill(Color.LIGHTGREEN); content = Seq(new Rectangle { 21 Linhas Rectangle rect = new Rectangle(); rect.setX(25); 17 Linhas x = 25 y = 40 rect.setY(40); width = 100 430 Caracteres rect.setWidth(100); rect.setHeight(50); 177 Caracteres height = 50 fill = RED rect.setFill(Color.RED); }) scene.setRoot(new Group(rect)); } stage.setScene(scene); } stage.show(); } } public static void main(String[] args) { launch(HelloStage.class, args); } } 51
  • 52. object DisappearingCircles extends JFXApp { stage = new Stage { title = "Disappearing 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) } } } } 52
  • 53. object DisappearingCircles extends JFXApp { stage = new Stage { title = "Disappearing Circles" width = 800 height = 600 Classe base para aplicacoes JavaFX 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) } } } } 53
  • 54. object DisappearingCircles extends JFXApp { stage = new Stage { title = "Disappearing Circles" width = 800 height = 600 scene = new Scene { Definicao declarativa do Stage 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) } } } } 54
  • 55. object DisappearingCircles extends JFXApp { stage = new Stage { title = "Disappearing Circles" Definicoes de propriedades width = 800 height = 600 embutidas 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) } } } } 55
  • 56. object DisappearingCircles extends JFXApp { stage = new Stage { title = "Disappearing Circles" width = 800 height = 600 Criacao de sequencias via scene = new Scene { Loop 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) } } } } 56
  • 57. Binding em Scala Infix Addition/Subtraction/Multiplication/Division: height <== rect1.height + rect2.height Aggregate Operators: width <== max(rect1.width, rect2.width, rect3.width) Conditional Expressions: strokeWidth <== when (hover) then 4 otherwise 0 Compound Expressions: text <== when (rect.hover || circle.hover && !disabled) then textField.text + " is enabled" otherwise "disabled" 57
  • 58. Animation em Scala val timeline = new Timeline { cycleCount = INDEFINITE autoReverse = true keyFrames = for (circle <- circles) yield at (40 s) { Set( circle.centerX -> random * stage.width, circle.centerY -> random * stage.height ) } } timeline.play(); 58
  • 59. Animacoes JavaFX Script-like Animation em Scala syntax: at (duration) {keyframes} val timeline = new Timeline { cycleCount = INDEFINITE autoReverse = true keyFrames = for (circle <- circles) yield at (40 s) { Set( circle.centerX -> random * stage.width, circle.centerY -> random * stage.height ) } } timeline.play(); 59
  • 60. Animation in Scala val timeline = new Timeline { cycleCount = INDEFINITE autoReverse = true keyFrames = for (circle <- circles) yield at (40 s) { Set( circle.centerX -> random * stage.width, circle.centerY -> random * stage.height ) } } overloading de operadores para timeline.play(); sintaxe da animacao 60
  • 61. Animation in Scala 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(); Controle de velocidade opcional 61
  • 62. Event Listeners em Scala > Suportado usando sintaxe Closure embutida > Argumentos opcionais para tratamento de eventos > 100% tipagem forte onMouseClicked = { Timeline(at(3 s){radius->0}).play() } 62
  • 63. Event Listeners em Scala > Suportado usando sintaxe Closure embutida > Argumentos opcionais para tratamento de eventos > 100% tipagem forte onMouseClicked = { Timeline(at(3 s){radius->0}).play() } Sintaxe compacta {body} 63
  • 64. Event Listeners em Scala > Suportado usando sintaxe Closure embutida > Argumentos opcionais para tratamento de eventos Evento = parametro opcional > 100% tipagem forte {(event) => body} onMouseClicked = { (e: MouseEvent) => Timeline(at(3 s){radius->0}).play() } 64
  • 65. Sobre o projeto Visage > “Visage e uma domain specific language (DSL) projetada para suportar a funcao de construcao de interfaces.” > Metas do projeto Visage:  Compila para JavaFX Java APIs  Envolve toda a linguagem (Annotations, Maps, etc.)  Suporta outros Toolkits > Venha participar do time! > Para mais informacoes: http://visage-lang.org/ 65
  • 66. E sobre o JavaFX no… Visage Stage { title: "Hello Stage" width: 600 height: 450 scene: Scene { fill: Color.LIGHTGREEN content: Rectangle { x: 25 y: 40 width: 100 height: 50 fill: Color.RED } } } 66
  • 67. E sobre o JavaFX no… Visage Stage { title: "Hello Stage" width: 600 height: 450 scene: Scene { fill: Color.LIGHTGREEN content: Rectangle { x: 25 y: 40 width: 100 height: 50 fill: Color.RED } } } 67
  • 68. E sobre o JavaFX no… Visage Stage { title: "Hello Stage" width: 600 height: 450 Scene { fill: Color.LIGHTGREEN Rectangle { x: 25 y: 40 width: 100 height: 50 fill: Color.RED } } } 68
  • 69. Visage e um JavaFX Script++ > Parametros padrao > Nova sintaxe para:  Angulos – 35deg, 4rad, 1turn  Cores – #DDCCBB, #AA33AA|CC  Medidas – 5px, 2pt, 3in, 4sp > Checagem de null-reference  var width = rect!.width > Bindable Maps embutida (Em breve!)  var fruitMap = ["red" : apple, "yellow" : banana]  var fruit = bind fruitMap["red"] 69
  • 70. Visage e JavaFX 2.0 foram feitos um para o outro… > Binding melhorado  Retem a avaliacao tardia de variaveis com um poder expressivo adicional > Colecoes integradas  Sequencias e mapas automaticamente convertidos entre JavaFX Observable Lists/Maps > Sintaxe de animacoes embutida  Coloca o JavaFX em um subsistema de animacoes  Prove uma API mais limpa e consistente 70
  • 71. Conclusao > Voce pode escrever aplicacoes JavaFX com Java puro > JavaFX tambem e utilizavel por linguagens alternativas > Voce pode ter o suporte melhorado utilizando bibliotecas DSL  GroovyFX  ScalaFX > Ou uma linguagem de interfaces que roda na JVM  Visage
  • 72. Pro JavaFX 2 Platform em breve! > Primeiro trimestre de 2012 > Todos os exemplos reescritos em Java > Cobre as novas bibliotecas da versao 2.0 > Incluira ScalaFX, GroovyFX e Visage 72

Notes de l'éditeur

  1. Stage.add??