GWT Plus HTML 5

Post on 07-Dec-2014

2.324 views 2 download

description

Discussion of GWT+HTML5 at Atlanta GTUG. See also http://www.google.com/events/io/2011/sessions/gwt-html5-a-web-developers-dream.html

Transcript of GWT Plus HTML 5

GWT + HTML5GTUG AtlantaDavid Chandler drfibonacci@google.comPhilip Rogers pdr@google.com

1Thursday, June 30, 2011

Agenda

• Overview• Local Storage for performance• Visualizations via Canvas• Enrich your app with Audio• Embedding Video in your app• Drag and Drop support• Handling unsupported browser versions• CSS3 makes its way into GWT• Angry Birds / ForPlay

2Thursday, June 30, 2011

Overview

• What to expecto Lots of demoso Lots of code examples

• What you will learno How to use HTML5 in your GWT app

3Thursday, June 30, 2011

OverviewWhat is HTML5?

• HTML5 includes lots of stuffo Media rich DOM elementso Useful new APIso CSS3 enhancements

• Support is increasing very rapidly• Embrace it to make your apps stand out

4Thursday, June 30, 2011

Why now?

5Thursday, June 30, 2011

Why now?

Hint:

6Thursday, June 30, 2011

HTML5 for Designers

header,nav,footer -- more semantic meaningaside conceptHSL color@font-faceborder-radiustransforms, transitionsCanvasHTML5 video player (sans Flash)

7Thursday, June 30, 2011

HTML5 for Programmers

• WebSockets• Client-side storage

o LocalStorage APIo Web SQL (it's dead, Jim)o indexedDB

• Web Workers• form fields

o type=email,date,range,search,tel,color,...• <meter>,<progress>• app cache• notifications• geolocation• device orientation• server side events

8Thursday, June 30, 2011

HTML5 support

http://www.html5rocks.com/

http://html5test.com

9Thursday, June 30, 2011

Agenda

• Overview• Local Storage for performance• Visualizations via Canvas• Enrich your app with Audio• Embedding Video in your app• Drag and Drop support• Handling unsupported browser versions• CSS3 makes its way into GWT• Angry Birds / ForPlay

10Thursday, June 30, 2011

Local StorageIsn't it just a cookie?

11Thursday, June 30, 2011

Local StorageIsn't it just a cookie?

• Cookies are sent with each request!• Local storage provides MBs worth of storage• Local storage can be shared between browser windows

12Thursday, June 30, 2011

Storage storage = Storage.getLocalStorageIfSupported();if (storage != null) {  String value = storage.getItem("foo");}

Storage storage = Storage.getLocalStorageIfSupported();if (storage != null) {  storage.setItem("foo", "bar");}

• GWT provides a Storage API

Available in GWTLocal Storage

13Thursday, June 30, 2011

Storage storage = Storage.getLocalStorageIfSupported();if (storage != null) {  String value = storage.getItem("foo");}

Storage storage = Storage.getLocalStorageIfSupported();if (storage != null) {  storage.setItem("foo", "bar");}

• GWT provides a Storage API

Available in GWTLocal Storage

14Thursday, June 30, 2011

Storage storage = Storage.getLocalStorageIfSupported();if (storage != null) {  String value = storage.getItem("foo");}

Storage storage = Storage.getLocalStorageIfSupported();if (storage != null) {  storage.setItem("foo", "bar");}

• GWT provides a Storage API

Available in GWTLocal Storage

15Thursday, June 30, 2011

Storage storage = Storage.getLocalStorageIfSupported();if (storage != null) {  StorageMap map = new StorageMap(storage);  storage.put("foo", "bar");}

Available in GWT

• StorageMap lets you access storage using a java.util.Mapo Contributions by Bart Guijt

Local Storage

16Thursday, June 30, 2011

Local StorageFor improved performance

• Cache data from RPC calls• Load cached data on startup for faster startup times

17Thursday, June 30, 2011

Local StorageFor improved performance

• Cache data from RPC calls• Load cached data on startup for faster startup times

18Thursday, June 30, 2011

Local StorageFor improved performance

Demo

19Thursday, June 30, 2011

Local StorageFor improved user experience

• Save temporary state to local storage• Restore state when user re-enters app• Prevent lost work on network disconnect

20Thursday, June 30, 2011

Agenda

• Overview• Local Storage for performance• Visualizations via Canvas• Enrich your app with Audio• Embedding Video in your app• Drag and Drop support• Handling unsupported browser versions• CSS3 makes its way into GWT• Angry Birds / ForPlay

21Thursday, June 30, 2011

CanvasAdding visualizations to your app

• This slide is boring

Past Due 3Due Tomorrow 1

On Time 1

No Due Date 6

22Thursday, June 30, 2011

CanvasAdding visualizations to your app

• Charts bring data to life• Canvas brings charts to the web

23Thursday, June 30, 2011

CanvasAdding visualizations to your app

Demo

24Thursday, June 30, 2011

CanvasAdding visualizations to your app

1. Initialize the canvas2. Calculate values for new shapes3. Clear the current canvas4. Draw the new shapes

25Thursday, June 30, 2011

  // Initialize the canvas.  final Canvas canvas = Canvas.createIfSupported();  canvas.setCoordinateSpaceHeight(300);  canvas.setCoordinateSpaceWidth(300);  canvas.setPixelSize(300, 300);  // Get the dimensions of the canvas.  int width = canvas.getCoordinateSpaceWidth();  int height = canvas.getCoordinateSpaceHeight();  double radius = Math.min(width, height) / 2.0;  double cx = width / 2.0;  double cy = height / 2.0;  // Clear the context.  Context2d context = canvas.getContext2d();  context.clearRect(0, 0, width, height);  // Draw a filled arc.  context.setFillStyle(CssColor.make(255, 211, 25));  context.beginPath();  context.moveTo(cx, cy);  context.arc(cx, cy, radius, 0, Math.PI);  context.fill();

26Thursday, June 30, 2011

  // Initialize the canvas.  final Canvas canvas = Canvas.createIfSupported();  canvas.setCoordinateSpaceHeight(300);  canvas.setCoordinateSpaceWidth(300);  canvas.setPixelSize(300, 300);  // Get the dimensions of the canvas.  int width = canvas.getCoordinateSpaceWidth();  int height = canvas.getCoordinateSpaceHeight();  double radius = Math.min(width, height) / 2.0;  double cx = width / 2.0;  double cy = height / 2.0;  // Clear the context.  Context2d context = canvas.getContext2d();  context.clearRect(0, 0, width, height);  // Draw a filled arc.  context.setFillStyle(CssColor.make(255, 211, 25));  context.beginPath();  context.moveTo(cx, cy);  context.arc(cx, cy, radius, 0, Math.PI);  context.fill();

27Thursday, June 30, 2011

  // Initialize the canvas.  final Canvas canvas = Canvas.createIfSupported();  canvas.setCoordinateSpaceHeight(300);  canvas.setCoordinateSpaceWidth(300);  canvas.setPixelSize(300, 300);  // Get the dimensions of the canvas.  int width = canvas.getCoordinateSpaceWidth();  int height = canvas.getCoordinateSpaceHeight();  double radius = Math.min(width, height) / 2.0;  double cx = width / 2.0;  double cy = height / 2.0;  // Clear the context.  Context2d context = canvas.getContext2d();  context.clearRect(0, 0, width, height);  // Draw a filled arc.  context.setFillStyle(CssColor.make(255, 211, 25));  context.beginPath();  context.moveTo(cx, cy);  context.arc(cx, cy, radius, 0, Math.PI);  context.fill();

28Thursday, June 30, 2011

  // Initialize the canvas.  final Canvas canvas = Canvas.createIfSupported();  canvas.setCoordinateSpaceHeight(300);  canvas.setCoordinateSpaceWidth(300);  canvas.setPixelSize(300, 300);  // Get the dimensions of the canvas.  int width = canvas.getCoordinateSpaceWidth();  int height = canvas.getCoordinateSpaceHeight();  double radius = Math.min(width, height) / 2.0;  double cx = width / 2.0;  double cy = height / 2.0;  // Clear the context.  Context2d context = canvas.getContext2d();  context.clearRect(0, 0, width, height);  // Draw a filled arc.  context.setFillStyle(CssColor.make(255, 211, 25));  context.beginPath();  context.moveTo(cx, cy);  context.arc(cx, cy, radius, 0, Math.PI);  context.fill();

29Thursday, June 30, 2011

CanvasAdding visualizations to your app

• Canvas has a coordinate space separate from DOM size• Coordinate space is scaled to the DOM size

o Small coordinate space = faster performanceo Large coordinate space = higher quality

• Match coordinate space to DOM sizeo Assign a fixed size to the DOM element, oro Catch resize events and adjust the coordinate space

300x300 30x30

30Thursday, June 30, 2011

Agenda

• Overview• Local Storage for performance• Visualizations via Canvas• Enrich your app with Audio• Embedding Video in your app• Drag and Drop support• Handling unsupported browser versions• CSS3 makes its way into GWT• Angry Birds / ForPlay

31Thursday, June 30, 2011

Audio

• Embed audio using the Audio widget• Play a sound or stream

32Thursday, June 30, 2011

Audio

Demo

33Thursday, June 30, 2011

Ogg Vorbis MP3 WAV

Chrome ✓ ✓Firefox ✓ ✓Internet Explorer ✓ ✓Opera ✓ ✓Safari ✓ ✓

Audio

• Format support varies across browsers• Choose at least two of the three main formats

Source: http://html5doctor.com/native-audio-in-the-browser/

34Thursday, June 30, 2011

AudioSpecify multiple sources

• You can specify multiple sources in HTML5 • Don't forget the "type" attribute

o Browsers will load all source files o Must load meta data to detect mime-type o Cannot assume mime-type from file extension

<audio controls> <source src="path/file.ogg" type="audio/ogg" /> <source src="path/file.mp3" type="audio/mpeg" /> <source src="path/file.wav" type="audio/wav" /> </audio>

35Thursday, June 30, 2011

public Audio createAudio() { Audio audio = Audio.createIfSupported(); if (audio == null) { return; }

audio.addSource("path/file.ogg", AudioElement.TYPE_OGG); audio.addSource("path/file.mp3", AudioElement.TYPE_MP3); audio.addSource("path/file.wav", AudioElement.TYPE_WAV);

// Show audio controls. audio.setControls(true); return audio;}

AudioSpecify multiple sources (2.4)

36Thursday, June 30, 2011

public Audio createAudio() { Audio audio = Audio.createIfSupported(); if (audio == null) { return; }

audio.addSource("path/file.ogg", AudioElement.TYPE_OGG); audio.addSource("path/file.mp3", AudioElement.TYPE_MP3); audio.addSource("path/file.wav", AudioElement.TYPE_WAV);

// Show audio controls. audio.setControls(true); return audio;}

AudioSpecify multiple sources (2.4)

37Thursday, June 30, 2011

public Audio createAudio() { Audio audio = Audio.createIfSupported(); if (audio == null) { return; }

audio.addSource("path/file.ogg", AudioElement.TYPE_OGG); audio.addSource("path/file.mp3", AudioElement.TYPE_MP3); audio.addSource("path/file.wav", AudioElement.TYPE_WAV);

// Show audio controls. audio.setControls(true); return audio;}

AudioSpecify multiple sources (2.4)

38Thursday, June 30, 2011

public Audio createAudio() { Audio audio = Audio.createIfSupported(); if (audio == null) { return; }

audio.addSource("path/file.ogg", AudioElement.TYPE_OGG); audio.addSource("path/file.mp3", AudioElement.TYPE_MP3); audio.addSource("path/file.wav", AudioElement.TYPE_WAV);

// Show audio controls. audio.setControls(true); return audio;}

AudioSpecify multiple sources (2.4)

39Thursday, June 30, 2011

AudioManually choose the source

• You can ask the browser which files it might supporto Tells you "probably", "maybe", or ""

• Ensures that you only load that source

40Thursday, June 30, 2011

public Audio createAudio() { Audio audio = Audio.createIfSupported(); if (audio == null) { return; } if (MediaElement.CAN_PLAY_PROBABLY.equals( audio.canPlayType(AudioElement.TYPE_OGG)) { audio.setSrc("path/file.ogg"); } else if (MediaElement.CAN_PLAY_PROBABLY.equals( audio.canPlayType(AudioElement.TYPE_MP3)) { audio.setSrc("path/file.mp3"); } else if (MediaElement.CAN_PLAY_MAYBE.equals( audio.canPlayType(AudioElement.TYPE_OGG)) { audio.setSrc("path/file.mp3"); } else if (MediaElement.CAN_PLAY_MAYBE.equals( audio.canPlayType(AudioElement.TYPE_MP3)) { audio.setSrc("path/file.mp3"); } return audio;}

41Thursday, June 30, 2011

public Audio createAudio() { Audio audio = Audio.createIfSupported(); if (audio == null) { return; } if (MediaElement.CAN_PLAY_PROBABLY.equals( audio.canPlayType(AudioElement.TYPE_OGG)) { audio.setSrc("path/file.ogg"); } else if (MediaElement.CAN_PLAY_PROBABLY.equals( audio.canPlayType(AudioElement.TYPE_MP3)) { audio.setSrc("path/file.mp3"); } else if (MediaElement.CAN_PLAY_MAYBE.equals( audio.canPlayType(AudioElement.TYPE_OGG)) { audio.setSrc("path/file.mp3"); } else if (MediaElement.CAN_PLAY_MAYBE.equals( audio.canPlayType(AudioElement.TYPE_MP3)) { audio.setSrc("path/file.mp3"); } return audio;}

42Thursday, June 30, 2011

Audio audio = Audio.createIfSupported();audio.setSrc("path/file.ogg");audio.load();

AudioPreloading a file

• Let the browser decide when to preload

Audio audio = Audio.createIfSupported();audio.setSrc("path/file.ogg");audio.setPreload(MediaElement.PRELOAD_AUTO);

• Or force the browser to preload

43Thursday, June 30, 2011

Audio audio = Audio.createIfSupported();audio.setSrc("path/file.ogg");audio.load();

AudioPreloading a file

• Let the browser decide when to preload

Audio audio = Audio.createIfSupported();audio.setSrc("path/file.ogg");audio.setPreload(MediaElement.PRELOAD_AUTO);

• Or force the browser to preload

44Thursday, June 30, 2011

Audio audio = Audio.createIfSupported();audio.setSrc("path/file.ogg");audio.load();

AudioPreloading a file

• Let the browser decide when to preload

Audio audio = Audio.createIfSupported();audio.setSrc("path/file.ogg");audio.setPreload(MediaElement.PRELOAD_AUTO);

• Or force the browser to preload

45Thursday, June 30, 2011

Agenda

• Overview• Local Storage for performance• Visualizations via Canvas• Enrich your app with Audio• Embedding Video in your app• Drag and Drop support• Handling unsupported browser versions• CSS3 makes its way into GWT• Angry Birds / ForPlay

46Thursday, June 30, 2011

Video

• Embed videos using the Video widget• Play a static video or a stream

47Thursday, June 30, 2011

Video

Demo

48Thursday, June 30, 2011

Ogg Vorbis MP4 WebM

Chrome ✓ ✓Firefox ✓ ✓Internet Explorer ✓Opera ✓ ✓Safari ✓

Video

• Format support varies across browsers• Choose at least two of the three main formats

o Safari only supports mp4

Source: http://en.wikipedia.org/wiki/HTML5_video

49Thursday, June 30, 2011

public Video createVideo() {  Video video = Video.createIfSupported();  if (video == null) {    return null;  }

  video.addSource("path/file.ogg", VideoElement.TYPE_OGG);  video.addSource("path/file.mp4", VideoElement.TYPE_MP4);  video.addSource("path/file.webm", VideoElement.TYPE_WEBM);

  // Show audio controls.  video.setControls(true);  return video;}

Video

50Thursday, June 30, 2011

public Video createVideo() {  Video video = Video.createIfSupported();  if (video == null) {    return null;  }

  video.addSource("path/file.ogg", VideoElement.TYPE_OGG);  video.addSource("path/file.mp4", VideoElement.TYPE_MP4);  video.addSource("path/file.webm", VideoElement.TYPE_WEBM);

  // Show audio controls.  video.setControls(true);  return video;}

Video

51Thursday, June 30, 2011

public Video createVideo() {  Video video = Video.createIfSupported();  if (video == null) {    return null;  }

  video.addSource("path/file.ogg", VideoElement.TYPE_OGG);  video.addSource("path/file.mp4", VideoElement.TYPE_MP4);  video.addSource("path/file.webm", VideoElement.TYPE_WEBM);

  // Show audio controls.  video.setControls(true);  return video;}

Video

52Thursday, June 30, 2011

public Video createVideo() {  Video video = Video.createIfSupported();  if (video == null) {    return null;  }

  video.addSource("path/file.ogg", VideoElement.TYPE_OGG);  video.addSource("path/file.mp4", VideoElement.TYPE_MP4);  video.addSource("path/file.webm", VideoElement.TYPE_WEBM);

  // Show audio controls.  video.setControls(true);  return video;}

Video

53Thursday, June 30, 2011

Agenda

• Overview• Local Storage for performance• Visualizations via Canvas• Enrich your app with Audio• Embedding Video in your app• Drag and Drop support• Handling unsupported browser versions• CSS3 makes its way into GWT• Angry Birds / ForPlay

54Thursday, June 30, 2011

Drag and Drop

• Move stuff around... with style• Associate text or ID with the event• Many types of drag events

55Thursday, June 30, 2011

Drag and Drop

Demo

56Thursday, June 30, 2011

• Set the "draggable" attribute to "true"• Add a DragStart handler• Set data in the DragStart handler

Drag and DropMake a widget draggable

57Thursday, June 30, 2011

// Make the widget draggable.Label w = new Label("Drag Me");w.getElement().setDraggable(Element.DRAGGABLE_TRUE);

// Add a DragStartHandler.w.addDragStartHandler(new DragStartHandler() {  public void onDragStart(DragStartEvent event) {    // Required: set data for the event.    event.setData("text", "Hello World");

    // Optional: show a copy of the widget under cursor.    event.getDataTransfer().setDragImage(w.getElement(),        10, 10);  }});

Drag and DropMake a widget draggable

58Thursday, June 30, 2011

// Make the widget draggable.Label w = new Label("Drag Me");w.getElement().setDraggable(Element.DRAGGABLE_TRUE);

// Add a DragStartHandler.w.addDragStartHandler(new DragStartHandler() {  public void onDragStart(DragStartEvent event) {    // Required: set data for the event.    event.setData("text", "Hello World");

    // Optional: show a copy of the widget under cursor.    event.getDataTransfer().setDragImage(w.getElement(),        10, 10);  }});

Drag and DropMake a widget draggable

59Thursday, June 30, 2011

// Make the widget draggable.Label w = new Label("Drag Me");w.getElement().setDraggable(Element.DRAGGABLE_TRUE);

// Add a DragStartHandler.w.addDragStartHandler(new DragStartHandler() {  public void onDragStart(DragStartEvent event) {    // Required: set data for the event.    event.setData("text", "Hello World");

    // Optional: show a copy of the widget under cursor.    event.getDataTransfer().setDragImage(w.getElement(),        10, 10);  }});

Drag and DropMake a widget draggable

60Thursday, June 30, 2011

// Make the widget draggable.Label w = new Label("Drag Me");w.getElement().setDraggable(Element.DRAGGABLE_TRUE);

// Add a DragStartHandler.w.addDragStartHandler(new DragStartHandler() {  public void onDragStart(DragStartEvent event) {    // Required: set data for the event.    event.setData("text", "Hello World");

    // Optional: show a copy of the widget under cursor.    event.getDataTransfer().setDragImage(w.getElement(),        10, 10);  }});

Drag and DropMake a widget draggable

61Thursday, June 30, 2011

// Make the widget draggable.Label w = new Label("Drag Me");w.getElement().setDraggable(Element.DRAGGABLE_TRUE);

// Add a DragStartHandler.w.addDragStartHandler(new DragStartHandler() {  public void onDragStart(DragStartEvent event) {    // Required: set data for the event.    event.setData("text", "Hello World");

    // Optional: show a copy of the widget under cursor.    event.getDataTransfer().setDragImage(w.getElement(),        10, 10);  }});

Drag and DropMake a widget draggable

62Thursday, June 30, 2011

• Add a DragOver handler• Add a Drop handler

o Prevent default actiono Get the data from the transfer object

Drag and DropCreate a target

63Thursday, June 30, 2011

Label target = new Label("Drag onto me"); // Required: You must add a DragOverHandler to// create a target.target.addDragOverHandler(new DragOverHandler() { public void onDragOver(DragOverEvent event) { target.getElement().setBackgroundColor("#ffa"); }}); // Add a DropHandler.target.addDropHandler(new DropHandler() { public void onDrop(DropEvent event) { // Prevent the native text drop. event.preventDefault();

// Get the data out of the event. String data = event.getData("text"); target.setText(data); }});

64Thursday, June 30, 2011

Label target = new Label("Drag onto me"); // Required: You must add a DragOverHandler to// create a target.target.addDragOverHandler(new DragOverHandler() { public void onDragOver(DragOverEvent event) { target.getElement().setBackgroundColor("#ffa"); }}); // Add a DropHandler.target.addDropHandler(new DropHandler() { public void onDrop(DropEvent event) { // Prevent the native text drop. event.preventDefault();

// Get the data out of the event. String data = event.getData("text"); target.setText(data); }});

65Thursday, June 30, 2011

Label target = new Label("Drag onto me"); // Required: You must add a DragOverHandler to// create a target.target.addDragOverHandler(new DragOverHandler() { public void onDragOver(DragOverEvent event) { target.getElement().setBackgroundColor("#ffa"); }}); // Add a DropHandler.target.addDropHandler(new DropHandler() { public void onDrop(DropEvent event) { // Prevent the native text drop. event.preventDefault();

// Get the data out of the event. String data = event.getData("text"); target.setText(data); }});

66Thursday, June 30, 2011

Label target = new Label("Drag onto me"); // Required: You must add a DragOverHandler to// create a target.target.addDragOverHandler(new DragOverHandler() { public void onDragOver(DragOverEvent event) { target.getElement().setBackgroundColor("#ffa"); }}); // Add a DropHandler.target.addDropHandler(new DropHandler() { public void onDrop(DropEvent event) { // Prevent the native text drop. event.preventDefault();

// Get the data out of the event. String data = event.getData("text"); target.setText(data); }});

67Thursday, June 30, 2011

Label target = new Label("Drag onto me"); // Required: You must add a DragOverHandler to// create a target.target.addDragOverHandler(new DragOverHandler() { public void onDragOver(DragOverEvent event) { target.getElement().setBackgroundColor("#ffa"); }}); // Add a DropHandler.target.addDropHandler(new DropHandler() { public void onDrop(DropEvent event) { // Prevent the native text drop. event.preventDefault();

// Get the data out of the event. String data = event.getData("text"); target.setText(data); }});

68Thursday, June 30, 2011

// Add a DragStartHandler.w.addDomHandler(new DragStartHandler() {  public void onDragStart(DragStartEvent event) {    // Required: set data for the event.    event.setData("text", "Hello World");

    // Optional: show a copy of the widget under cursor.    event.getDataTransfer().setDragImage(w.getElement,         10, 10);  }}, DragStartEvent.getType());

Drag and DropOn any widget

• Some widgets do not implement drag handlers• You can always use addDomHandler() to add a handler

69Thursday, June 30, 2011

  File[] files = event.getDataTransfer().getFiles();

  // read an entire file  String txt = FileReader.readAsBinaryString(files[0]);

  // read a chunk of a file  Reader reader = new Reader();  Blob blob = files[0].slice(startingByte, length);  String txt = reader.readAsBinaryString(blob);

Drag and Drop+ File API?

• Spec is still changing rapidly.• Not in GWT (yet!)

70Thursday, June 30, 2011

Drag and Drop Uploader

Demo

71Thursday, June 30, 2011

Agenda

• Overview• Local Storage for performance• Visualizations via Canvas• Enrich your app with Audio• Embedding Video in your app• Drag and Drop support• Handling unsupported browser versions• CSS3 makes its way into GWT• Angry Birds / ForPlay

72Thursday, June 30, 2011

Partial SupportBecause if all browsers supported it, it would be too easy

• GWT provides APIs that are not supported in all browserso Modern browsers gaining market share rapidly

• Implementors of PartialSupport provide two static methods:o isSupported()o createIfSupported()

"Compiles out" if on a non-supported permutation!

73Thursday, June 30, 2011

public void showChart(AcceptsOneWidget panel,    ChartData data) {  Canvas canvas = Canvas.createIfSupported();  if (canvas == null) {    // Fallback to an image if Canvas isn't supported.    String imageUrl = encodeChartData(data);    panel.setWidget(new Image(imageUrl);    return;  }

  // Create a canvas chart.  ...

  // Display the canvas.  panel.setWidget(canvas);}

Partial SupportFallback to another implementation

74Thursday, June 30, 2011

Agenda

• Overview• Local Storage for performance• Visualizations via Canvas• Enrich your app with Audio• Embedding Video in your app• Drag and Drop support• Handling unsupported browser versions• CSS3 makes its way into GWT• Angry Birds / ForPlay

75Thursday, June 30, 2011

CSS3Style your GWT app

• Nothing special required for CSS3o Rounded corners, drop shadows, animations, group opacity,

multiple backgrounds, 3D transforms, etc.o No changes required for GWT's UIBinder

76Thursday, June 30, 2011

Example: Rounded Corners

CSS3 in GWT's Widgets

• As of GWT 2.3, widgets now use CSS3• On legacy browsers, widgets will be "usable"

77Thursday, June 30, 2011

Agenda

• Overview• Local Storage for performance• Visualizations via Canvas• Enrich your app with Audio• Embedding Video in your app• Drag and Drop support• Handling unsupported browser versions• CSS3 makes its way into GWT• Angry Birds / ForPlay

78Thursday, June 30, 2011

Angry Birds / ForPlay

Demo

79Thursday, June 30, 2011

Angry BirdsAn HTML5 GWT app

• Announced at Google IO 2011• Built with a library called ForPlay

o Uses GWT for Java -> HTML5 step.• Uses most of the technologies talked about here

o Canvas, Audio*, Storage, CSS3o Prove it

80Thursday, June 30, 2011

Angry BirdsAn HTML5 GWT app

• Announced at Google IO 2011• Built with a library called ForPlay

o Uses GWT for Java -> HTML5 step.• Uses most of the technologies talked about here

o Canvas, Audio*, Storage, CSS3o Prove it

• Check out the I/O talk:Kick-Ass Game Programming with Google Web Toolkit

• http://goo.gl/UZ4X4

81Thursday, June 30, 2011

ForPlayIn 30 seconds

• Cross-platform library for gameso Cross-browser (HTML5): WebGL, Canvas, 3D CSSo Android, Flash, and Java apps too

• Write and debug games using the ForPlay API, compile onto many platforms.

• API includes cross-platform abstractions for startup, asset management, input (keyboard, touch, mouse), audio, graphics, physics engine (box2d), json parsing, etc.

82Thursday, June 30, 2011

ForPlayAn GWT library for games

• Some demoso Joel Webber's XNA Platormer porto Aquarium by Mohamed Ousgougou / SFEIRo http://p4cdroid.appspot.com/o more examples, including source at gwtforplay.com

• For more info or if you'd like to join in: http://gwtforplay.com

83Thursday, June 30, 2011

GWT + HTML5GTUG AtlantaDavid Chandler drfibonacci@google.comPhilip Rogers pdr@google.com

84Thursday, June 30, 2011