DukeScript

29
DUKESCRIPT Puts the Java in JavaScript

description

DukeScript is a new way of writing JavaScript applications that lets you take advantage of a powerful binding model to connect to Java code running in a local JVM.

Transcript of DukeScript

Page 1: DukeScript

DUKESCRIPTPuts the Java in JavaScript

Page 2: DukeScript

Problem I

Page 3: DukeScript

Problem II

Page 4: DukeScript

Chuck Norris

can instantiate abstract classes

can run Java on iPad and Android without Jailbreak!

uses generics since Java 1.0

overrides final methods

Chuck Norris on the set of "The Delta Force" (1986), Copyright Yoni S.Hamenahem

Page 5: DukeScript

bck2brwsr vs HotSpot„World of Warcraft Commercial" Copyright ©Blizzard Entertainment

Page 6: DukeScript

The Solution

"The Way of the Dragon" Copyright © 20th Century Fox Home Entertainment / Bryanston Distributing / CBS/Fox / Cinema Classics

Page 7: DukeScript

BCK2BRWSR

Page 8: DukeScript

DESIGNER VS DEVELOPER

Page 9: DukeScript

DESIGNER VS DEVELOPER

index.html

<html> <button id="hello"> Say Hello!</button> </html> !

App.java@Model(className="Person", properties={

@Property(name = "selectedName", type=String.class),

})

static class PersonModel{

...

}

Page 10: DukeScript

DUKESCRIPTPuts the Java in JavaScript

Page 11: DukeScript

alternatively use bck2brwsr

Page 12: DukeScript

KNOCKOUT4J

Page 13: DukeScript

@Model(className="Person", properties={

@Property(name = "firstName", type=String.class),

@Property(name = "lastName", type=String.class)

@Property(name = "addresses", type=Address.class, array = true)

})

static class PersonModel {

http://bits.netbeans.org/html4j/0.7.5/net/java/html/json/package-summary.html

Page 14: DukeScript

@Model(className="Address", properties={

@Property(name = "street", type=String.class),

@Property(name = "town", type=String.class)

})

static class AddressModel {

}

http://bits.netbeans.org/html4j/0.7.5/net/java/html/json/package-summary.html

Page 15: DukeScript

@ComputedProperty

static String fullName(String firstName, String lastName) {

return firstName + " " + lastName;

}

http://bits.netbeans.org/html4j/0.7.5/net/java/html/json/package-summary.html

Page 16: DukeScript

<span data-bind="text: fullName">

<div data-bind="foreach: addresses">

Lives in <span data-bind="text: town"/>

</div>

http://bits.netbeans.org/html4j/0.7.5/net/java/html/json/package-summary.html

Page 17: DukeScript

@ComputedProperty

static String fullName(String firstName, String lastName) {

return firstName + " " + lastName;

}

http://bits.netbeans.org/html4j/0.7.5/net/java/html/json/package-summary.html

Page 18: DukeScript

CANVAS 0.5.2

https://github.com/eppleton/canvas

Page 19: DukeScript

!

≈!HTML5 CANVAS!

CANVAS API

Page 20: DukeScript

CANVAS API

GraphicsContext2D gc = HTML5Graphics.getOrCreate("canvas"); gc.setLineWidth(30); gc.setFont("24px Helvetica"); gc.fillText("Hello World!", 175, 200); gc.setFillStyle(new Color("rgba(0, 0, 255, 0.5)“)); gc.strokeRect(75, 100, 200, 200); gc.fillRect(325, 100, 200, 200);

Page 21: DukeScript
Page 22: DukeScript

JAVAFX WITH CANVAS API IN BCK2BRWSR

http://xelfi.cz/fishsim/

Page 23: DukeScript

FXGAMES

https://github.com/eppleton/FXGameEngine

Page 24: DukeScript

DUKESCRIPT !

!

!

UNIVERSITY

Page 25: DukeScript

Task 1

Create your own application in Java that renders through HTML.!Write your own model and display and animate it.

mvn archetype:generate -DarchetypeGroupId=org.apidesign.html -DarchetypeArtifactId=knockout4j-archetype -DarchetypeVersion=0.7.5

Page 26: DukeScript

Task 2

Create your own application using the Canvas API

mvn archetype:generate -DarchetypeGroupId=org.apidesign.canvas -DarchetypeArtifactId=canvas-archetype -DarchetypeVersion=0.5.2

Page 27: DukeScript

Task 3

Use JSON/REST to communicate with a server

API Doc:

http://bits.netbeans.org/html4j/0.7.5/net/java/html/json/OnReceive.html

Demo:

http://dew.apidesign.org/dew/#7138581

See also:

http://bits.netbeans.org/html4j/0.7.5/net/java/html/json/doc-files/websockets.html

Page 28: DukeScript

HOW CAN WE IMPROVE IT?

Page 29: DukeScript

We want you for

DukeScript http://bits.netbeans.org/html4j/0.7.5/ and https://github.com/eppleton/canvas

Thank you! !

@monacotoni