Sorry about the red box, but we really need you to update your browser. Read this excellent article if you're wondering why we are no longer supporting this browser version. Go to Browse Happy for browser suggestions and how to update.

SVG animation sample app

The SVG animation sample application demonstrates how to display an animated SVG on the BlackBerry device. The sample application uses APIs implemented using the JSR 226 standard for interactive and animated 2-D graphics on the Java ME platform.

The sample application contains an SVG file, sample.svg, which includes the definitions for three distinct animations: a bouncing ball, a running stick figure, and an orbiting solar system. The sample application allows you to change which of the three animations you want to display at any time and provides a play control for starting each animation.

Filename

Description

SVGAnimatorDemo.java

application that includes the main method that starts the application and displays the SVGScreen

SVGScreen.java

class that displays all the UI components, which include a drop-down list that allows the user to change the animation, a button to start the animation, and the animation

sample.svg

file that defines the three animations (a running stick figure, a bouncing ball, and an orbiting solar system), according to the W3C SVG Tiny 1.2 profile standard

This sample features the following classes:

javax.microedition.m2g.SVGImage

This class represents an SVG image that conforms to the W3C SVG Tiny 1.2 profile.

In the sample application, the private method loadSVGimage() in the SVGScreen class demonstrates how to create an SVGImage object from a file.

javax.microedition.m2g.SVGAnimator

This class provides methods that you can use to load an animation from an SVGImage object and to control the animation.

The sample application uses the SVGAnimator to switch between the three distinct animations that are defined in the sample.svg file using the createAnimator() method. The sample application also makes it possible for you to start the animation by clicking a button on the screen.

Install the sample app

Visit http://www.blackberry.com/go/svganimatorsample to download the sample application.

Extract the svganimator.zip file.

On the taskbar, click Start > Programs > Research In Motion > BlackBerry JDE 4.7.0 > JDE.

Open the workspace that you want to add the sample application to.

In the workspace tree, right-click the project that you want to add the sample application to.

Click Add project to <workspace directory> .

In the Add project to <workspace> dialog box, browse to the folder where you extracted the sample application.

Click the SVGAnimatorDemo.jdp file.

Click Open.

The sample app is also available in github.

Run the sample app

In the workspace where you added the svganimator demo project, right-click svganimatordemo.

Click Build project.

On the taskbar, click Start > Applications > Research in Motion > BlackBerry JDE 4.7.0 > Device Simulator.

On the Home screen of the BlackBerry Smartphone Simulator, click the Downloads folder.

Click the svganimatordemo icon.