DukeScript

Post on 15-Jan-2015

2.266 views 0 download

Tags:

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

DUKESCRIPTPuts the Java in JavaScript

Problem I

Problem II

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

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

The Solution

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

BCK2BRWSR

DESIGNER VS DEVELOPER

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{

...

}

DUKESCRIPTPuts the Java in JavaScript

alternatively use bck2brwsr

KNOCKOUT4J

@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

@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

@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

<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

@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

CANVAS 0.5.2

https://github.com/eppleton/canvas

!

≈!HTML5 CANVAS!

CANVAS API

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);

JAVAFX WITH CANVAS API IN BCK2BRWSR

http://xelfi.cz/fishsim/

FXGAMES

https://github.com/eppleton/FXGameEngine

DUKESCRIPT !

!

!

UNIVERSITY

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

Task 2

Create your own application using the Canvas API

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

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

HOW CAN WE IMPROVE IT?

We want you for

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

Thank you! !

@monacotoni