Embed presentation
Downloaded 64 times









![Example Applicationpublic class HelloStage extends Application { @Override public void start(Stage stage) { stage.setTitle("Hello Stage"); stage.setWidth(600); stage.setHeight(450); Group root = new Group(); Scene scene = new Scene(root); scene.setFill(Color.LIGHTGREEN); stage.setScene(scene); stage.show(); } public static void main(String[] args) { Application.launch(args); } }](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-10-2048.jpg&f=jpg&w=240)
![Example Application Using Builderspublic class HelloStage extends Application { @Override public void start(Stage stage) { stage.setTitle("Hello Stage"); stage.setScene(SceneBuilder.create() .fill(Color.LIGHTGREEN) .width(600) .height(450) .build()); stage.show(); } public static void main(String[] args) { Application.launch(args); } }](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-11-2048.jpg&f=jpg&w=240)









![Vanishing Circles in Javapublic class VanishingCircles extends Application { public static void main(String[] args) { Application.launch(args); } @Override public void start(Stage primaryStage) { primaryStage.setTitle("Vanishing Circles"); Group root = new Group(); Scene scene = new Scene(root, 800, 600, Color.BLACK); List<Circle> circles = new ArrayList<Circle>(); for (int i = 0; i < 50; i++) { 40 Lines final Circle circle = new Circle(150); circle.setCenterX(Math.random() * 800); circle.setCenterY(Math.random() * 600); circle.setFill(new Color(Math.random(), Math.random(), Math.random(), .2)); 1299 Characters circle.setEffect(new BoxBlur(10, 10, 3)); circle.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() { public void handle(MouseEvent t) { KeyValue collapse = new KeyValue(circle.radiusProperty(), 0); new Timeline(new KeyFrame(Duration.seconds(3), collapse)).play(); } }); circle.setStroke(Color.WHITE); circle.strokeWidthProperty().bind(Bindings.when(circle.hoverProperty()) .then(4) .otherwise(0)); circles.add(circle); } root.getChildren().addAll(circles); primaryStage.setScene(scene); primaryStage.show(); Timeline moveCircles = new Timeline(); for (Circle circle : circles) { KeyValue moveX = new KeyValue(circle.centerXProperty(), Math.random() * 800); KeyValue moveY = new KeyValue(circle.centerYProperty(), Math.random() * 600); moveCircles.getKeyFrames().add(new KeyFrame(Duration.seconds(40), moveX, moveY)); } moveCircles.play(); } } 21](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-21-2048.jpg&f=jpg&w=240)
![Application Skeletonpublic class VanishingCircles extends Application { public static void main(String[] args) { Application.launch(args); } @Override public void start(Stage primaryStage) { primaryStage.setTitle("Vanishing Circles"); Group root = new Group(); Scene scene = new Scene(root, 800, 600, Color.BLACK); [create the circles…] root.getChildren().addAll(circles); primaryStage.setScene(scene); primaryStage.show(); [begin the animation…] } }](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-22-2048.jpg&f=jpg&w=240)
![Create the CirclesList<Circle> circles = new ArrayList<Circle>(); for (int i = 0; i < 50; i++) { final Circle circle = new Circle(150); circle.setCenterX(Math.random() * 800); circle.setCenterY(Math.random() * 600); circle.setFill(new Color(Math.random(), Math.random(), Math.random(), .2)); circle.setEffect(new BoxBlur(10, 10, 3)); circle.setStroke(Color.WHITE); [setup binding…] [setup event listeners…] circles.add(circle); } 23](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-23-2048.jpg&f=jpg&w=240)





![Java vs. GroovyFX DSLpublic class VanishingCircles extends Application { GroovyFX.start { primaryStage -‐> def sg = new SceneGraphBuilder() public static void main(String[] args) { def rand = new Random().&nextInt Application.launch(args); def circles = [] } sg.stage(title: 'Vanishing Circles', show: true) { @Override scene(fill: black, width: 800, height: 600) { public void start(Stage primaryStage) { 50.times { primaryStage.setTitle("Vanishing Circles"); circles << circle(centerX: rand(800), centerY: rand(600), radius: 150, stroke: white, Group root = new Group(); strokeWidth: bind('hover', converter: {val -‐> val ? 4 : 0})) { Scene scene = new Scene(root, 800, 600, Color.BLACK); fill rgb(rand(255), rand(255), rand(255), 0.2) List<Circle> circles = new ArrayList<Circle>(); effect boxBlur(width: 10, height: 10, iterations: 3) for (int i = 0; i < 50; i++) { onMouseClicked { e -‐> 40 Lines 29 Lines final Circle circle = new Circle(150); timeline { circle.setCenterX(Math.random() * 800); at(3.s) { change e.source.radiusProperty() to 0 } circle.setCenterY(Math.random() * 600); }.play() circle.setFill(new Color(Math.random(), Math.random(), Math.random(), .2)); } 671 Characters circle.setEffect(new BoxBlur(10, 10, 3)); } 1299 Characters circle.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() { public void handle(MouseEvent t) { KeyValue collapse = new KeyValue(circle.radiusProperty(), 0); new Timeline(new KeyFrame(Duration.seconds(3), collapse)).play(); } } timeline(cycleCount: Timeline.INDEFINITE, autoReverse: true) { } circles.each { circle -‐> }); at (40.s) { circle.setStroke(Color.WHITE); change circle.centerXProperty() to rand(800) circle.strokeWidthProperty().bind(Bindings.when(circle.hoverProperty()) change circle.centerYProperty() to rand(600) .then(4) } .otherwise(0)); } circles.add(circle); }.play() } } root.getChildren().addAll(circles); } primaryStage.setScene(scene); primaryStage.show(); Timeline moveCircles = new Timeline(); for (Circle circle : circles) { KeyValue moveX = new KeyValue(circle.centerXProperty(), Math.random() * 800); KeyValue moveY = new KeyValue(circle.centerYProperty(), Math.random() * 600); moveCircles.getKeyFrames().add(new KeyFrame(Duration.seconds(40), moveX, moveY)); } moveCircles.play(); } } 29](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-29-2048.jpg&f=jpg&w=240)
![GroovyFX.start { primaryStage -‐> def sg = new SceneGraphBuilder() def rand = new Random().&nextInt def circles = [] sg.stage(title: 'Vanishing Circles', show: true) { scene(fill: black, width: 800, height: 600) { 50.times { circles << circle(centerX: rand(800), centerY: rand(600), radius: 150, stroke: white, strokeWidth: bind('hover', converter: {val -‐> val ? 4 : 0})) { fill rgb(rand(255), rand(255), rand(255), 0.2) effect boxBlur(width: 10, height: 10, iterations: 3) } } } } } 30](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-30-2048.jpg&f=jpg&w=240)
![GroovyFX.start { primaryStage -‐> def sg = new SceneGraphBuilder() def rand = new Random().&nextInt def circles = [] sg.stage(title: 'Vanishing Circles', show: true) { Builder for GroovyFX scene graphs scene(fill: black, width: 800, height: 600) { 50.times { circles << circle(centerX: rand(800), centerY: rand(600), radius: 150, stroke: white, strokeWidth: bind('hover', converter: {val -‐> val ? 4 : 0})) { fill rgb(rand(255), rand(255), rand(255), 0.2) effect boxBlur(width: 10, height: 10, iterations: 3) } } } } } 31](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-31-2048.jpg&f=jpg&w=240)
![GroovyFX.start { primaryStage -‐> def sg = new SceneGraphBuilder() def rand = new Random().&nextInt def circles = [] sg.stage(title: 'Vanishing Circles', show: true) { scene(fill: black, width: 800, height: 600) { 50.times { circles << circle(centerX: rand(800), centerY: rand(600), radius: 150, stroke: white, Declarative Stage definition strokeWidth: bind('hover', converter: {val -‐> val ? 4 : 0})) { fill rgb(rand(255), rand(255), rand(255), 0.2) effect boxBlur(width: 10, height: 10, iterations: 3) } } } } } 32](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-32-2048.jpg&f=jpg&w=240)
![GroovyFX.start { primaryStage -‐> def sg = new SceneGraphBuilder() def rand = new Random().&nextInt def circles = [] Inline property definitions sg.stage(title: 'Vanishing Circles', show: true) { scene(fill: black, width: 800, height: 600) { 50.times { circles << circle(centerX: rand(800), centerY: rand(600), radius: 150, stroke: white, strokeWidth: bind('hover', converter: {val -‐> val ? 4 : 0})) { fill rgb(rand(255), rand(255), rand(255), 0.2) effect boxBlur(width: 10, height: 10, iterations: 3) } } } } } 33](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-33-2048.jpg&f=jpg&w=240)
![GroovyFX.start { primaryStage -‐> def sg = new SceneGraphBuilder() def rand = new Random().&nextInt def circles = [] sg.stage(title: 'Vanishing Circles', show: true) { scene(fill: black, width: 800, height: 600) { Bind to properties 50.times { circles << circle(centerX: rand(800), centerY: rand(600), radius: 150, stroke: white, strokeWidth: bind('hover', converter: {val -‐> val ? 4 : 0})) { fill rgb(rand(255), rand(255), rand(255), 0.2) effect boxBlur(width: 10, height: 10, iterations: 3) } } } } } 34](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-34-2048.jpg&f=jpg&w=240)
![GroovyFX.start { primaryStage -‐> def sg = new SceneGraphBuilder() def rand = new Random().&nextInt def circles = [] sg.stage(title: 'Vanishing Circles', show: true) { Creation Via Loop Sequence scene(fill: black, width: 800, height: 600) { 50.times { circles << circle(centerX: rand(800), centerY: rand(600), radius: 150, stroke: white, strokeWidth: bind('hover', converter: {val -‐> val ? 4 : 0})) { fill rgb(rand(255), rand(255), rand(255), 0.2) effect boxBlur(width: 10, height: 10, iterations: 3) } } } } } 35](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-35-2048.jpg&f=jpg&w=240)



















![Layout in GroovyFXgridPane(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")!}! 55](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-55-2048.jpg&f=jpg&w=240)




![A Little About Clojure> Started in 2007 by Rich Hickey> Functional Programming Language> Derived from LISP> Optimized for High Concurrency (def hello (fn [] "Hello world")) (hello)> … and looks nothing like Java! 60](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-60-2048.jpg&f=jpg&w=240)
![Clojure Syntax in One Slide Symbols Collections (commas optional) > numbers – 2.178 > Lists > ratios – 355/113 (1, 2, 3, 4, 5) > strings – “clojure”, “rocks” > Vectors > characters – a b c d [1, 2, 3, 4, 5] > symbols – a b c d > Maps > keywords – :alpha :beta {:a 1, :b 2, :c 3, :d 4} > boolean – true, false > Sets > null - nil #{:a :b :c :d :e} (plus macros that are syntactic sugar wrapping the above) 61](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-61-2048.jpg&f=jpg&w=240)
![Clojure GUI Example(defn javafxapp [] (let [stage (Stage. "JavaFX Stage") scene (Scene.)] (.setFill scene Color/LIGHTGREEN) (.setWidth stage 600) (.setHeight stage 450) (.setScene stage scene) (.setVisible stage true))) (javafxapp) 62](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-62-2048.jpg&f=jpg&w=240)
![Refined Clojure GUI Example(defn javafxapp [] (doto (Stage. "JavaFX Stage") (.setWidth 600) (.setHeight 450) (.setScene (doto (Scene.) (.setFill Color/LIGHTGREEN) (.setContent (list (doto (Rectangle.) (.setX 25) (.setY 40) (.setWidth 100) (.setHeight 50) (.setFill Color/RED)))))) (.setVisible true))) (javafxapp) 63](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-63-2048.jpg&f=jpg&w=240)
![Refined Clojure GUI Example(defn javafxapp [] (doto (Stage. "JavaFX Stage") (.setWidth 600) Doto allows nested data (.setHeight 450) (.setScene (doto (Scene.) structures (.setFill Color/LIGHTGREEN) (.setContent (list (doto (Rectangle.) (.setX 25) (.setY 40) (.setWidth 100) (.setHeight 50) (.setFill Color/RED)))))) (.setVisible true))) (javafxapp) 64](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-64-2048.jpg&f=jpg&w=240)
![Closures in Clojure> Inner classes can be created using proxy (.addListener hoverProperty (proxy [ChangeListener] [] (handle [p, o, v] (.setFill rect (if (.isHover rect) Color/GREEN Color/RED))))) 65](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-65-2048.jpg&f=jpg&w=240)
![Closures in Clojure> Inner classes can be created using proxy Proxy form: (proxy [class] [args] fs+) f => (name [params*] body) (.addListener hoverProperty (proxy [ChangeListener] [] (handle [p, o, v] (.setFill rect (if (.isHover rect) Color/GREEN Color/RED))))) 66](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-66-2048.jpg&f=jpg&w=240)



![Java vs. Scala DSLpublic class VanishingCircles extends Application { object VanishingCircles extends JFXApp { var circles: Seq[Circle] = null public static void main(String[] args) { stage = new Stage { Application.launch(args); title = "Vanishing Circles" } width = 800 height = 600 @Override scene = new Scene { public void start(Stage primaryStage) { fill = BLACK primaryStage.setTitle("Vanishing Circles"); circles = for (i <-‐ 0 until 50) yield new Circle { Group root = new Group(); centerX = random * 800 Scene scene = new Scene(root, 800, 600, Color.BLACK); centerY = random * 600 List<Circle> circles = new ArrayList<Circle>(); radius = 150 for (int i = 0; i < 50; i++) { fill = color(random, random, random, .2) 40 Lines 33 Lines final Circle circle = new Circle(150); effect = new BoxBlur(10, 10, 3) circle.setCenterX(Math.random() * 800); strokeWidth <== when (hover) then 4 otherwise 0 circle.setCenterY(Math.random() * 600); stroke = WHITE circle.setFill(new Color(Math.random(), Math.random(), Math.random(), .2)); onMouseClicked = { circle.setEffect(new BoxBlur(10, 10, 3)); Timeline(at (3 s) {radius -‐> 0}).play() 1299 Characters circle.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() { public void handle(MouseEvent t) { KeyValue collapse = new KeyValue(circle.radiusProperty(), 0); new Timeline(new KeyFrame(Duration.seconds(3), collapse)).play(); } 591 Characters } content = circles } } } }); circle.setStroke(Color.WHITE); new Timeline { circle.strokeWidthProperty().bind(Bindings.when(circle.hoverProperty()) cycleCount = INDEFINITE .then(4) autoReverse = true .otherwise(0)); keyFrames = for (circle <-‐ circles) yield at (40 s) { circles.add(circle); Set( } circle.centerX -‐> random * stage.width, root.getChildren().addAll(circles); circle.centerY -‐> random * stage.height primaryStage.setScene(scene); ) primaryStage.show(); } }.play(); Timeline moveCircles = new Timeline(); } for (Circle circle : circles) { KeyValue moveX = new KeyValue(circle.centerXProperty(), Math.random() * 800); KeyValue moveY = new KeyValue(circle.centerYProperty(), Math.random() * 600); moveCircles.getKeyFrames().add(new KeyFrame(Duration.seconds(40), moveX, moveY)); } moveCircles.play(); } } 70](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-70-2048.jpg&f=jpg&w=240)













 {! columns = Seq(! new TableColumn[Speaker, String] {! text: "Name"! converter = {_.firstName}! } new TableColumn[Speaker, String] {! text: "Age"! converter = {_.age}! }! new TableColumn[Speaker, String] {! text: "Gender"! converter = {_.gender}! }! new TableColumn[Speaker, String] {! text: "Birth"! converter = {dateFormat.format(_.dob)}, ! }!)}! 84](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-84-2048.jpg&f=jpg&w=240)


![Java vs. Visage DSLpublic class VanishingCircles extends Application { var circles:Circle[]; Stage { public static void main(String[] args) { title: "Vanishing Circles" Application.launch(args); Scene { } width: 800 height: 600 @Override fill: BLACK public void start(Stage primaryStage) { Group { primaryStage.setTitle("Vanishing Circles"); circles = for (i in [1..50]) { Group root = new Group(); def c:Circle = Circle { Scene scene = new Scene(root, 800, 600, Color.BLACK); centerX: random() * 800 List<Circle> circles = new ArrayList<Circle>(); centerY: random() * 600 for (int i = 0; i < 50; i++) { radius: 150 40 Lines 35 Lines final Circle circle = new Circle(150); fill: color(random(), random(), random(), .2) circle.setCenterX(Math.random() * 800); effect: BoxBlur { circle.setCenterY(Math.random() * 600); height: 10 circle.setFill(new Color(Math.random(), Math.random(), Math.random(), .2)); width: 10 circle.setEffect(new BoxBlur(10, 10, 3)); iterations: 3 1299 Characters circle.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() { public void handle(MouseEvent t) { KeyValue collapse = new KeyValue(circle.radiusProperty(), 0); new Timeline(new KeyFrame(Duration.seconds(3), collapse)).play(); 487 Characters } stroke: WHITE strokeWidth: bind if (c.hover) 5 else 0 onMouseClicked: function(e) { } Timeline {at (3s) {c.radius => 0}}.play() }); } circle.setStroke(Color.WHITE); } circle.strokeWidthProperty().bind(Bindings.when(circle.hoverProperty()) } .then(4) } .otherwise(0)); } circles.add(circle); } } root.getChildren().addAll(circles); Timeline { primaryStage.setScene(scene); for (circle in circles) at (40s) { primaryStage.show(); circle.centerX => random() * 800; circle.centerY => random() * 600 Timeline moveCircles = new Timeline(); } for (Circle circle : circles) { }.play() KeyValue moveX = new KeyValue(circle.centerXProperty(), Math.random() * 800); KeyValue moveY = new KeyValue(circle.centerYProperty(), Math.random() * 600); moveCircles.getKeyFrames().add(new KeyFrame(Duration.seconds(40), moveX, moveY)); } moveCircles.play(); } } 87](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-87-2048.jpg&f=jpg&w=240)
![How about JavaFX on… VisageStage { title: "Vanishing Circles" scene: Scene { width: 800 height: 600 fill: BLACK content: Group { circles = for (i in [1..50]) { Circle { centerX: random() * 800 centerY: random() * 600 } } } } } 88](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-88-2048.jpg&f=jpg&w=240)
![How about JavaFX on… VisageStage { title: "Vanishing Circles" scene: Scene { width: 800 height: 600 fill: BLACK content: Group { circles = for (i in [1..50]) { Circle { centerX: random() * 800 centerY: random() * 600 } } } } } 89](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-89-2048.jpg&f=jpg&w=240)
![How about JavaFX on… VisageStage { title: "Vanishing Circles" Scene { width: 800 height: 600 fill: BLACK Group { circles = for (i in [1..50]) { Circle { centerX: random() * 800 centerY: random() * 600 } } } } } 90](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-90-2048.jpg&f=jpg&w=240)
![Visage is JavaFX Script++> Default Parameters> New Literal Syntax For: l Angles – 35deg, 4rad, 1turn l Colors – #DDCCBB, #AA33AA|CC l Lengths – 5px, 2pt, 3in, 4sp > Null-check Dereference l var width = rect.!width> Built-in Bindable Maps (coming soon!) l var fruitMap = ["red" : apple, "yellow" : banana] l var fruit = bind fruitMap["red"] 91](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-91-2048.jpg&f=jpg&w=240)




The document presents an overview of JavaFX 2.0, highlighting its open-source status and capabilities for building immersive applications using modern Java APIs, supporting multiple JVM languages, including Groovy, Scala, and Clojure. It describes key features such as binding, observable properties, and examples of animations and UI components implemented in Java and GroovyFX. The presenter, Stephen Chin, is an advocate for utilizing Java skills in the development of cross-platform applications with a focus on rich graphics and interactions.









![Example Applicationpublic class HelloStage extends Application { @Override public void start(Stage stage) { stage.setTitle("Hello Stage"); stage.setWidth(600); stage.setHeight(450); Group root = new Group(); Scene scene = new Scene(root); scene.setFill(Color.LIGHTGREEN); stage.setScene(scene); stage.show(); } public static void main(String[] args) { Application.launch(args); } }](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-10-2048.jpg&f=jpg&w=240)
![Example Application Using Builderspublic class HelloStage extends Application { @Override public void start(Stage stage) { stage.setTitle("Hello Stage"); stage.setScene(SceneBuilder.create() .fill(Color.LIGHTGREEN) .width(600) .height(450) .build()); stage.show(); } public static void main(String[] args) { Application.launch(args); } }](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-11-2048.jpg&f=jpg&w=240)









![Vanishing Circles in Javapublic class VanishingCircles extends Application { public static void main(String[] args) { Application.launch(args); } @Override public void start(Stage primaryStage) { primaryStage.setTitle("Vanishing Circles"); Group root = new Group(); Scene scene = new Scene(root, 800, 600, Color.BLACK); List<Circle> circles = new ArrayList<Circle>(); for (int i = 0; i < 50; i++) { 40 Lines final Circle circle = new Circle(150); circle.setCenterX(Math.random() * 800); circle.setCenterY(Math.random() * 600); circle.setFill(new Color(Math.random(), Math.random(), Math.random(), .2)); 1299 Characters circle.setEffect(new BoxBlur(10, 10, 3)); circle.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() { public void handle(MouseEvent t) { KeyValue collapse = new KeyValue(circle.radiusProperty(), 0); new Timeline(new KeyFrame(Duration.seconds(3), collapse)).play(); } }); circle.setStroke(Color.WHITE); circle.strokeWidthProperty().bind(Bindings.when(circle.hoverProperty()) .then(4) .otherwise(0)); circles.add(circle); } root.getChildren().addAll(circles); primaryStage.setScene(scene); primaryStage.show(); Timeline moveCircles = new Timeline(); for (Circle circle : circles) { KeyValue moveX = new KeyValue(circle.centerXProperty(), Math.random() * 800); KeyValue moveY = new KeyValue(circle.centerYProperty(), Math.random() * 600); moveCircles.getKeyFrames().add(new KeyFrame(Duration.seconds(40), moveX, moveY)); } moveCircles.play(); } } 21](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-21-2048.jpg&f=jpg&w=240)
![Application Skeletonpublic class VanishingCircles extends Application { public static void main(String[] args) { Application.launch(args); } @Override public void start(Stage primaryStage) { primaryStage.setTitle("Vanishing Circles"); Group root = new Group(); Scene scene = new Scene(root, 800, 600, Color.BLACK); [create the circles…] root.getChildren().addAll(circles); primaryStage.setScene(scene); primaryStage.show(); [begin the animation…] } }](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-22-2048.jpg&f=jpg&w=240)
![Create the CirclesList<Circle> circles = new ArrayList<Circle>(); for (int i = 0; i < 50; i++) { final Circle circle = new Circle(150); circle.setCenterX(Math.random() * 800); circle.setCenterY(Math.random() * 600); circle.setFill(new Color(Math.random(), Math.random(), Math.random(), .2)); circle.setEffect(new BoxBlur(10, 10, 3)); circle.setStroke(Color.WHITE); [setup binding…] [setup event listeners…] circles.add(circle); } 23](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-23-2048.jpg&f=jpg&w=240)





![Java vs. GroovyFX DSLpublic class VanishingCircles extends Application { GroovyFX.start { primaryStage -‐> def sg = new SceneGraphBuilder() public static void main(String[] args) { def rand = new Random().&nextInt Application.launch(args); def circles = [] } sg.stage(title: 'Vanishing Circles', show: true) { @Override scene(fill: black, width: 800, height: 600) { public void start(Stage primaryStage) { 50.times { primaryStage.setTitle("Vanishing Circles"); circles << circle(centerX: rand(800), centerY: rand(600), radius: 150, stroke: white, Group root = new Group(); strokeWidth: bind('hover', converter: {val -‐> val ? 4 : 0})) { Scene scene = new Scene(root, 800, 600, Color.BLACK); fill rgb(rand(255), rand(255), rand(255), 0.2) List<Circle> circles = new ArrayList<Circle>(); effect boxBlur(width: 10, height: 10, iterations: 3) for (int i = 0; i < 50; i++) { onMouseClicked { e -‐> 40 Lines 29 Lines final Circle circle = new Circle(150); timeline { circle.setCenterX(Math.random() * 800); at(3.s) { change e.source.radiusProperty() to 0 } circle.setCenterY(Math.random() * 600); }.play() circle.setFill(new Color(Math.random(), Math.random(), Math.random(), .2)); } 671 Characters circle.setEffect(new BoxBlur(10, 10, 3)); } 1299 Characters circle.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() { public void handle(MouseEvent t) { KeyValue collapse = new KeyValue(circle.radiusProperty(), 0); new Timeline(new KeyFrame(Duration.seconds(3), collapse)).play(); } } timeline(cycleCount: Timeline.INDEFINITE, autoReverse: true) { } circles.each { circle -‐> }); at (40.s) { circle.setStroke(Color.WHITE); change circle.centerXProperty() to rand(800) circle.strokeWidthProperty().bind(Bindings.when(circle.hoverProperty()) change circle.centerYProperty() to rand(600) .then(4) } .otherwise(0)); } circles.add(circle); }.play() } } root.getChildren().addAll(circles); } primaryStage.setScene(scene); primaryStage.show(); Timeline moveCircles = new Timeline(); for (Circle circle : circles) { KeyValue moveX = new KeyValue(circle.centerXProperty(), Math.random() * 800); KeyValue moveY = new KeyValue(circle.centerYProperty(), Math.random() * 600); moveCircles.getKeyFrames().add(new KeyFrame(Duration.seconds(40), moveX, moveY)); } moveCircles.play(); } } 29](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-29-2048.jpg&f=jpg&w=240)
![GroovyFX.start { primaryStage -‐> def sg = new SceneGraphBuilder() def rand = new Random().&nextInt def circles = [] sg.stage(title: 'Vanishing Circles', show: true) { scene(fill: black, width: 800, height: 600) { 50.times { circles << circle(centerX: rand(800), centerY: rand(600), radius: 150, stroke: white, strokeWidth: bind('hover', converter: {val -‐> val ? 4 : 0})) { fill rgb(rand(255), rand(255), rand(255), 0.2) effect boxBlur(width: 10, height: 10, iterations: 3) } } } } } 30](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-30-2048.jpg&f=jpg&w=240)
![GroovyFX.start { primaryStage -‐> def sg = new SceneGraphBuilder() def rand = new Random().&nextInt def circles = [] sg.stage(title: 'Vanishing Circles', show: true) { Builder for GroovyFX scene graphs scene(fill: black, width: 800, height: 600) { 50.times { circles << circle(centerX: rand(800), centerY: rand(600), radius: 150, stroke: white, strokeWidth: bind('hover', converter: {val -‐> val ? 4 : 0})) { fill rgb(rand(255), rand(255), rand(255), 0.2) effect boxBlur(width: 10, height: 10, iterations: 3) } } } } } 31](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-31-2048.jpg&f=jpg&w=240)
![GroovyFX.start { primaryStage -‐> def sg = new SceneGraphBuilder() def rand = new Random().&nextInt def circles = [] sg.stage(title: 'Vanishing Circles', show: true) { scene(fill: black, width: 800, height: 600) { 50.times { circles << circle(centerX: rand(800), centerY: rand(600), radius: 150, stroke: white, Declarative Stage definition strokeWidth: bind('hover', converter: {val -‐> val ? 4 : 0})) { fill rgb(rand(255), rand(255), rand(255), 0.2) effect boxBlur(width: 10, height: 10, iterations: 3) } } } } } 32](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-32-2048.jpg&f=jpg&w=240)
![GroovyFX.start { primaryStage -‐> def sg = new SceneGraphBuilder() def rand = new Random().&nextInt def circles = [] Inline property definitions sg.stage(title: 'Vanishing Circles', show: true) { scene(fill: black, width: 800, height: 600) { 50.times { circles << circle(centerX: rand(800), centerY: rand(600), radius: 150, stroke: white, strokeWidth: bind('hover', converter: {val -‐> val ? 4 : 0})) { fill rgb(rand(255), rand(255), rand(255), 0.2) effect boxBlur(width: 10, height: 10, iterations: 3) } } } } } 33](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-33-2048.jpg&f=jpg&w=240)
![GroovyFX.start { primaryStage -‐> def sg = new SceneGraphBuilder() def rand = new Random().&nextInt def circles = [] sg.stage(title: 'Vanishing Circles', show: true) { scene(fill: black, width: 800, height: 600) { Bind to properties 50.times { circles << circle(centerX: rand(800), centerY: rand(600), radius: 150, stroke: white, strokeWidth: bind('hover', converter: {val -‐> val ? 4 : 0})) { fill rgb(rand(255), rand(255), rand(255), 0.2) effect boxBlur(width: 10, height: 10, iterations: 3) } } } } } 34](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-34-2048.jpg&f=jpg&w=240)
![GroovyFX.start { primaryStage -‐> def sg = new SceneGraphBuilder() def rand = new Random().&nextInt def circles = [] sg.stage(title: 'Vanishing Circles', show: true) { Creation Via Loop Sequence scene(fill: black, width: 800, height: 600) { 50.times { circles << circle(centerX: rand(800), centerY: rand(600), radius: 150, stroke: white, strokeWidth: bind('hover', converter: {val -‐> val ? 4 : 0})) { fill rgb(rand(255), rand(255), rand(255), 0.2) effect boxBlur(width: 10, height: 10, iterations: 3) } } } } } 35](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-35-2048.jpg&f=jpg&w=240)



















![Layout in GroovyFXgridPane(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")!}! 55](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-55-2048.jpg&f=jpg&w=240)




![A Little About Clojure> Started in 2007 by Rich Hickey> Functional Programming Language> Derived from LISP> Optimized for High Concurrency (def hello (fn [] "Hello world")) (hello)> … and looks nothing like Java! 60](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-60-2048.jpg&f=jpg&w=240)
![Clojure Syntax in One Slide Symbols Collections (commas optional) > numbers – 2.178 > Lists > ratios – 355/113 (1, 2, 3, 4, 5) > strings – “clojure”, “rocks” > Vectors > characters – a b c d [1, 2, 3, 4, 5] > symbols – a b c d > Maps > keywords – :alpha :beta {:a 1, :b 2, :c 3, :d 4} > boolean – true, false > Sets > null - nil #{:a :b :c :d :e} (plus macros that are syntactic sugar wrapping the above) 61](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-61-2048.jpg&f=jpg&w=240)
![Clojure GUI Example(defn javafxapp [] (let [stage (Stage. "JavaFX Stage") scene (Scene.)] (.setFill scene Color/LIGHTGREEN) (.setWidth stage 600) (.setHeight stage 450) (.setScene stage scene) (.setVisible stage true))) (javafxapp) 62](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-62-2048.jpg&f=jpg&w=240)
![Refined Clojure GUI Example(defn javafxapp [] (doto (Stage. "JavaFX Stage") (.setWidth 600) (.setHeight 450) (.setScene (doto (Scene.) (.setFill Color/LIGHTGREEN) (.setContent (list (doto (Rectangle.) (.setX 25) (.setY 40) (.setWidth 100) (.setHeight 50) (.setFill Color/RED)))))) (.setVisible true))) (javafxapp) 63](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-63-2048.jpg&f=jpg&w=240)
![Refined Clojure GUI Example(defn javafxapp [] (doto (Stage. "JavaFX Stage") (.setWidth 600) Doto allows nested data (.setHeight 450) (.setScene (doto (Scene.) structures (.setFill Color/LIGHTGREEN) (.setContent (list (doto (Rectangle.) (.setX 25) (.setY 40) (.setWidth 100) (.setHeight 50) (.setFill Color/RED)))))) (.setVisible true))) (javafxapp) 64](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-64-2048.jpg&f=jpg&w=240)
![Closures in Clojure> Inner classes can be created using proxy (.addListener hoverProperty (proxy [ChangeListener] [] (handle [p, o, v] (.setFill rect (if (.isHover rect) Color/GREEN Color/RED))))) 65](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-65-2048.jpg&f=jpg&w=240)
![Closures in Clojure> Inner classes can be created using proxy Proxy form: (proxy [class] [args] fs+) f => (name [params*] body) (.addListener hoverProperty (proxy [ChangeListener] [] (handle [p, o, v] (.setFill rect (if (.isHover rect) Color/GREEN Color/RED))))) 66](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-66-2048.jpg&f=jpg&w=240)



![Java vs. Scala DSLpublic class VanishingCircles extends Application { object VanishingCircles extends JFXApp { var circles: Seq[Circle] = null public static void main(String[] args) { stage = new Stage { Application.launch(args); title = "Vanishing Circles" } width = 800 height = 600 @Override scene = new Scene { public void start(Stage primaryStage) { fill = BLACK primaryStage.setTitle("Vanishing Circles"); circles = for (i <-‐ 0 until 50) yield new Circle { Group root = new Group(); centerX = random * 800 Scene scene = new Scene(root, 800, 600, Color.BLACK); centerY = random * 600 List<Circle> circles = new ArrayList<Circle>(); radius = 150 for (int i = 0; i < 50; i++) { fill = color(random, random, random, .2) 40 Lines 33 Lines final Circle circle = new Circle(150); effect = new BoxBlur(10, 10, 3) circle.setCenterX(Math.random() * 800); strokeWidth <== when (hover) then 4 otherwise 0 circle.setCenterY(Math.random() * 600); stroke = WHITE circle.setFill(new Color(Math.random(), Math.random(), Math.random(), .2)); onMouseClicked = { circle.setEffect(new BoxBlur(10, 10, 3)); Timeline(at (3 s) {radius -‐> 0}).play() 1299 Characters circle.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() { public void handle(MouseEvent t) { KeyValue collapse = new KeyValue(circle.radiusProperty(), 0); new Timeline(new KeyFrame(Duration.seconds(3), collapse)).play(); } 591 Characters } content = circles } } } }); circle.setStroke(Color.WHITE); new Timeline { circle.strokeWidthProperty().bind(Bindings.when(circle.hoverProperty()) cycleCount = INDEFINITE .then(4) autoReverse = true .otherwise(0)); keyFrames = for (circle <-‐ circles) yield at (40 s) { circles.add(circle); Set( } circle.centerX -‐> random * stage.width, root.getChildren().addAll(circles); circle.centerY -‐> random * stage.height primaryStage.setScene(scene); ) primaryStage.show(); } }.play(); Timeline moveCircles = new Timeline(); } for (Circle circle : circles) { KeyValue moveX = new KeyValue(circle.centerXProperty(), Math.random() * 800); KeyValue moveY = new KeyValue(circle.centerYProperty(), Math.random() * 600); moveCircles.getKeyFrames().add(new KeyFrame(Duration.seconds(40), moveX, moveY)); } moveCircles.play(); } } 70](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-70-2048.jpg&f=jpg&w=240)













 {! columns = Seq(! new TableColumn[Speaker, String] {! text: "Name"! converter = {_.firstName}! } new TableColumn[Speaker, String] {! text: "Age"! converter = {_.age}! }! new TableColumn[Speaker, String] {! text: "Gender"! converter = {_.gender}! }! new TableColumn[Speaker, String] {! text: "Birth"! converter = {dateFormat.format(_.dob)}, ! }!)}! 84](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-84-2048.jpg&f=jpg&w=240)


![Java vs. Visage DSLpublic class VanishingCircles extends Application { var circles:Circle[]; Stage { public static void main(String[] args) { title: "Vanishing Circles" Application.launch(args); Scene { } width: 800 height: 600 @Override fill: BLACK public void start(Stage primaryStage) { Group { primaryStage.setTitle("Vanishing Circles"); circles = for (i in [1..50]) { Group root = new Group(); def c:Circle = Circle { Scene scene = new Scene(root, 800, 600, Color.BLACK); centerX: random() * 800 List<Circle> circles = new ArrayList<Circle>(); centerY: random() * 600 for (int i = 0; i < 50; i++) { radius: 150 40 Lines 35 Lines final Circle circle = new Circle(150); fill: color(random(), random(), random(), .2) circle.setCenterX(Math.random() * 800); effect: BoxBlur { circle.setCenterY(Math.random() * 600); height: 10 circle.setFill(new Color(Math.random(), Math.random(), Math.random(), .2)); width: 10 circle.setEffect(new BoxBlur(10, 10, 3)); iterations: 3 1299 Characters circle.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() { public void handle(MouseEvent t) { KeyValue collapse = new KeyValue(circle.radiusProperty(), 0); new Timeline(new KeyFrame(Duration.seconds(3), collapse)).play(); 487 Characters } stroke: WHITE strokeWidth: bind if (c.hover) 5 else 0 onMouseClicked: function(e) { } Timeline {at (3s) {c.radius => 0}}.play() }); } circle.setStroke(Color.WHITE); } circle.strokeWidthProperty().bind(Bindings.when(circle.hoverProperty()) } .then(4) } .otherwise(0)); } circles.add(circle); } } root.getChildren().addAll(circles); Timeline { primaryStage.setScene(scene); for (circle in circles) at (40s) { primaryStage.show(); circle.centerX => random() * 800; circle.centerY => random() * 600 Timeline moveCircles = new Timeline(); } for (Circle circle : circles) { }.play() KeyValue moveX = new KeyValue(circle.centerXProperty(), Math.random() * 800); KeyValue moveY = new KeyValue(circle.centerYProperty(), Math.random() * 600); moveCircles.getKeyFrames().add(new KeyFrame(Duration.seconds(40), moveX, moveY)); } moveCircles.play(); } } 87](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-87-2048.jpg&f=jpg&w=240)
![How about JavaFX on… VisageStage { title: "Vanishing Circles" scene: Scene { width: 800 height: 600 fill: BLACK content: Group { circles = for (i in [1..50]) { Circle { centerX: random() * 800 centerY: random() * 600 } } } } } 88](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-88-2048.jpg&f=jpg&w=240)
![How about JavaFX on… VisageStage { title: "Vanishing Circles" scene: Scene { width: 800 height: 600 fill: BLACK content: Group { circles = for (i in [1..50]) { Circle { centerX: random() * 800 centerY: random() * 600 } } } } } 89](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-89-2048.jpg&f=jpg&w=240)
![How about JavaFX on… VisageStage { title: "Vanishing Circles" Scene { width: 800 height: 600 fill: BLACK Group { circles = for (i in [1..50]) { Circle { centerX: random() * 800 centerY: random() * 600 } } } } } 90](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-90-2048.jpg&f=jpg&w=240)
![Visage is JavaFX Script++> Default Parameters> New Literal Syntax For: l Angles – 35deg, 4rad, 1turn l Colors – #DDCCBB, #AA33AA|CC l Lengths – 5px, 2pt, 3in, 4sp > Null-check Dereference l var width = rect.!width> Built-in Bindable Maps (coming soon!) l var fruitMap = ["red" : apple, "yellow" : banana] l var fruit = bind fruitMap["red"] 91](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fhackingjavafxwithgroovyclojurescalaandvisage-120719084046-phpapp01%2f75%2fHacking-JavaFX-with-Groovy-Clojure-Scala-and-Visage-Stephen-Chin-91-2048.jpg&f=jpg&w=240)



