30
Creating Dynamic Thin- Creating Dynamic Thin- Client User-Interfaces Client User-Interfaces with Flash and Java with Flash and Java Brad Neuberg, [email protected]

Creating Dynamic Thin-Client User-Interfaces with Flash and Java

Embed Size (px)

Citation preview

Page 1: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

Creating Dynamic Thin-Client Creating Dynamic Thin-Client User-Interfaces with Flash and User-Interfaces with Flash and

JavaJava

Brad Neuberg, [email protected]

Page 2: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

The Problem & MotivationThe Problem & Motivation

The Problem: Find a new rendering engine for Java.

Motivation: Java is a fabulous networking language and “model” language, but is a lousy “display” language.

Page 3: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

Problems with Java’s Current Problems with Java’s Current Rendering Engine (JRE 1.2.2)Rendering Engine (JRE 1.2.2)Large (many megabytes)SlowNot truly cross-platform (disparate support

across platforms)No installed base (Sun has been terrible

with bundling deals

Page 4: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

Requirements for a New Requirements for a New Rendering EngineRendering Engine

1) Must be cross-platform

2) Must be very fast

3) Must be small

4) Can be integrated well with Java

5) Supports the “new way” of creating UIs

6) Creates good looking, dynamic UIs

7) Easy to work with

Page 5: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

The “New Way” to Create The “New Way” to Create User-InterfacesUser-Interfaces

First appeared with HTML, similar to Model-View-Controller

User-interface is completely “unhooked” from behavior of program

Designer draws and creates user-interface using some tools (Dreamweaver, Director, etc.)

Program “hooks onto” UI to control it

Page 6: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

The “New Way” to Create The “New Way” to Create User-Interfaces (Continued)User-Interfaces (Continued)

Example: JSP file has UI which “calls” JavaBeans for behavior.

Page 7: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

Advantages of this New ModelAdvantages of this New Model

Can offer great productivityCreates much better-looking UIsOffers greater flexibility to evolve UIsNo throwaway prototype UI

Page 8: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

Candidates for the New Candidates for the New Rendering EngineRendering Engine

DHTML + JavaScript– DHTML totally incompatible across browsers– Even IE for Mac and IE for Windows have

different programming models– Slow– JavaScript is terrible for large-scale engineering– JavaScript also has few good built-in libraries

Page 9: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

Candidates for the New Candidates for the New Rendering Engine (Continued)Rendering Engine (Continued)DHTML + Java through IBM’s DirectDom

(formally Weblets) Toolkit– Allows Java to control browser HTML

elements– Promising, but still at alpha-level– Large download (~1.5 megs)

Page 10: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

Candidates for the New Candidates for the New Rendering Engine (Continued)Rendering Engine (Continued)Servlet/JSP generated HTML

– No downloads– Slow trips back to server– Limited user-interface ability

Page 11: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

Candidates for the New Candidates for the New Rendering Engine (Continued)Rendering Engine (Continued) Mozilla

– XUL (eXtensible UI Language) allows for UIs that are controlled by Java

– Very cross-platform (available for Linux, Windows, Mac, Solaris, HP-UX, BeOS, etc.)

– Still unstable and alpha-level– Large Download (~2 - ~15 megs, depending on number

of components)– Sluggish– Promising, but not mature yet

Page 12: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

Candidates for the New Candidates for the New Rendering Engine (Continued)Rendering Engine (Continued) SVG (Scalable Vector Graphics) through Adobe’s

Plugin controlled by DirectDom– Wonderful, easy programming model– SVG is a standard– Standard is still immature, though– Viewers are slow– Large download – SVG plugin (~3 megs) + DirectDom

(~1.5 megs)– Both SVG plugin & Direct Dom are alpha-level– No tool support to create SVG files

Page 13: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

Candidates for the New Candidates for the New Rendering Engine (Continued)Rendering Engine (Continued)JRE 1.3

– Much faster than previous JREs, but still not fast enough

– Swing is now truly mature with JRE 1.3– Large download (~5 megs)– Still beta– Major memory requirements for Swing apps

Page 14: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

Candidates for the New Candidates for the New Rendering Engine (Continued)Rendering Engine (Continued) Flash 4 Plugin + Java 1.1 Native Browser VM

– Flash plugin very ubiquitous (on about ~85% of browsers)

– Flash plugin is extremely small download (~150K)– Flash is extremely cross-platform (Flash 4 plugin

available for Windows 95/98/NT, Mac, Solaris, Linux, and Irix)

– Flash is very fast

Page 15: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

Candidates for the New Candidates for the New Rendering Engine (Continued)Rendering Engine (Continued) Flash 4 Plugin + Java 1.1 Native Browser VM

(Continued)– Flash has advanced rendering engine (anti-aliased text,

cross-platform fonts, alpha-channel/transparency, text-fields, sprites, tweening, etc.)

– Flash has very small compressed files– Easy to create using Macromedia Flash Authoring

application– Flash is well-known to designers

Page 16: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

What is Flash?What is Flash?

Binary vector based format that supports animation, interactivity, and text-rendering

Created with an authoring tool named FlashVector format offers small, fast downloads,

screen-size independence, easy conversion to print-format, and animation

Page 17: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

Flash ExamplesFlash Examples

Eye4U (shows speed)Balthaser (shows text-effects and UI

widgets)Yugop Scrolling UI (shows UI widgets)FlashZone Action Demo (shows UI

widgets)Romeo Design (shows multimedia)

Page 18: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

FlashFlash (advanced rendering) (advanced rendering)++

JavaJava (advanced networking (advanced networking and programming)and programming)

==Killer cross-platform Killer cross-platform

solutionsolution

Page 19: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

Flash/Java IntegrationFlash/Java Integration

1. Allow Java to call methods on Flash Plugin (Done)

2. Allow Flash to call Java methods and create new Java instances (80% Done)

3. Build on (1) to give the illusion that objects in Flash are actually Java objects (TBD)

Page 20: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

Allow Java to Call Methods on Allow Java to Call Methods on Flash PluginFlash Plugin

The Flash Plugin exposes several methods to JavaScript– Play()– GetVariable(varName)– GotoFrame(frameNumber)– Etc.

Page 21: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

Allow Java to Call Methods on Allow Java to Call Methods on Flash Plugin (Continued)Flash Plugin (Continued)

Made JavaScript and Java wrapper around plugin, using LiveConnect

LiveConnect allows JavaScript to call Java, and vice-versa

Most people assume it’s only supported in Netscape, but it is also completely compatible with IE

Page 22: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

Allow Java to Call Methods on Allow Java to Call Methods on Flash Plugin (Continued)Flash Plugin (Continued)

Example use of FlashPlugin class:import org.twoofdiscs.flash.FlashPlugin;

import org.twoofdiscs.flash.MainController;

public class AddressBook {

public void displayAddressBook() {

// get FlashPlugin

FlashPlugin plugin = MainController.getFlashPlugin();

plugin.TCallLabel("/", "DISPLAY_ADDRESSBOOK");

}

}

Page 23: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

Allow Flash to call Java Allow Flash to call Java methods and create new Java methods and create new Java

instancesinstancesFlash has a light-weight scripting language

called ActionScriptActionScript has a command call

FSCommand(String command, String arguments)

This command can be used to call external JavaScript functions

Page 24: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

Allow Flash to call Java Allow Flash to call Java methods and Create New methods and Create New

Java Instances (Continued)Java Instances (Continued)

Created reflective Java and JavaScript glue to let Flash FSCommands call Java methods and create Java objects

Page 25: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

Allow Flash to Call Java Allow Flash to Call Java Methods and Create New Methods and Create New

Java Instances (Continued)Java Instances (Continued)

Creating Java Object from Flash:– FSCommand(‘org.twoofdiscs.demo.AddressBook

myAddressBook = new org.twoofdiscs.demo.AddressBook(“Brad Neuberg”)’)

org.twoofdiscs.demo.AddressBook myAddressBook = new

org.twoofdiscs.demo.AddressBook(“Brad Neuberg”)- Java object to create

Page 26: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

Allow Flash to Call Java Allow Flash to Call Java Methods and Create New Methods and Create New

Java Instances (Continued)Java Instances (Continued) Calling Java Methods from Flash

– FSCommand(‘myAddressBook.getContacts()’, ‘/someTarget:var1, true, /, RETURN_RESULT_READY’

– Stop

FSCommand(‘myAddressBook.getContacts()’ – Gives instance name of previously created Java object and method to run

/someTarget:var1, true, /, RETURN_RESULT_READY - Specifies name of Flash variable to put results into, whether the results are an array, and the movie target and label to restart at

Page 27: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

Give the Illusion that Objects Give the Illusion that Objects in Flash are Actually Java in Flash are Actually Java

ObjectsObjects Will allow one to define a Java interface:public interface BankSummary { public int getUsersChoice(); public void resetColumns();} Then, a Flash compiler will be run:

– java org.twoofdiscs.flash.callingflash.FlashCompile BankSummary

Page 28: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

Give the Illusion that Objects Give the Illusion that Objects in Flash are Actually Java in Flash are Actually Java

Objects (Continued)Objects (Continued)

This will generate a Flash file, that can be imported into a Flash movie

This Flash movie will now appear to have an object named BankSummary that can be created, cloned, and have methods called on just like an ordinary Java object.

Page 29: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

Give the Illusion that Objects Give the Illusion that Objects in Flash are Actually Java in Flash are Actually Java

Objects (Continued)Objects (Continued)

The Java will have no clue that it is talking to Flash

Similar to CORBA proxies

Page 30: Creating Dynamic Thin-Client User-Interfaces with Flash and Java

The FutureThe Future

As Java 2D speed increases, the Flash engine can be written in Java

An open-source Java Flash engine is already available

Everything will be able to remain the sameWill make it possible to embed Swing

components into the GUI where appropriate