Skip to main content

Question: How to make a splashscreen for svg animations

5 replies [Last post]
int0xicated
Offline
Joined: 2008-06-04
Points: 0

hello,

as you can see in the subject: my intend is to make a splashscreen for a SVG animation (not image) to begin at a specific time and that ends at a specific time, but i dont know how to do that. I looked through the source code of this example source:
https://meapplicationdevelopers.dev.java.net/uiLabs/PlaySVGAnimation.html

but this source is just for a normal image and if I try it with svgimages it doesent work. (below is the source of my splashscreen.java)

hope you can help me!
thanks in advance ;) ...

int0
PS: sry for my english :P

import java.io.IOException;
import java.io.InputStream;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.m2g.SVGAnimator;
import javax.microedition.m2g.SVGImage;
import javax.microedition.m2g.ScalableGraphics;

/**
* The SplashCanvas class is used to display an image as soon as
* a MIDlet is started and, possibly, show information about the coming demo
* while that demo is loading.
*/
public class SplashCanvas extends Canvas {
/**
* The minimal amount of time to wait when a splash screen is displayed.
*/
public static final long SPLASH_MIN_LENGTH = 2500; // 2.5s
protected ScalableGraphics sg = ScalableGraphics.createInstance();
/**
* The image this splash screen should show.
*/
SVGImage image;

/**
* The time the last display started.
*/
private long start;

/**
* @param image the image this splash screen should show.
*/
public SplashCanvas(final SVGImage image) {
this.image = image;
}

/**
* @param imageURL the url for the splash screen image.
*/
public SplashCanvas(final String imageURL) {
boolean error = false;

if (imageURL == null) {
error = true;
} else {
InputStream splashStream = getClass().getResourceAsStream(imageURL);

try {
image = (SVGImage) SVGImage.createImage(splashStream,null);
} catch (Exception e) {
e.printStackTrace();
error = true;
}
}

}

public void paint(Graphics g) {
g.setColor(255, 255, 255);
g.fillRect(0, 0, getWidth(), getHeight());
sg.bindTarget(g);
image.setViewportWidth(getWidth());
image.setViewportHeight(getHeight());
sg.render(0, 0, image);
sg.releaseTarget();
}

/**
* @param display the Display on which this splash screen should paint.
*/
public void display(final Display display) {
display.setCurrent(this);
start = System.currentTimeMillis();
}

/**
* Switches to the input Display after the minimal time has elapsed.
*
* @param display the display to switch to.
* @param canvas the canvas to set after the minimal amount of time has elapsed.
*/
public void switchTo(final Display display, final Canvas newCanvas, SVGAnimator an) {
long end = System.currentTimeMillis();
long waitMore = 10000;

if (waitMore != 0) {//>
//try {
an.play();
// Thread.currentThread().sleep(waitMore);
// } catch (InterruptedException ie) {
// Do nothing.
//}
}

display.setCurrent(newCanvas);
}

/**
* Shows the splash screen and waits for SPLASH_MIN_LENGTH before restoring
* the input Displayable.
*
* @param display the display on which to show the splash screen.
* @param displayable the displayable to restore after the help screen has been shown.
*/
public void showAndWait(final Display display) {
// Show the splashCanvas for a little while.
display.setCurrent(this);

Thread th =
new Thread() {
public void run() {
try {
Thread.currentThread().sleep(SPLASH_MIN_LENGTH);
} catch (InterruptedException ie) {
}

// display.setCurrent(displayable);
}
};

th.start();
}
}

[i]

Message was edited by: int0xicated

Message was edited by: int0xicated

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
terrencebarr
Offline
Joined: 2004-03-04
Points: 0

int0xicated,

In your code I don't see where you are actually starting the animation.

Check out the "SVG UI Makeover" application in the ME App Developers project. The main file (localSVGMakeover.java) contains the loading and playback of the animated splash screen.

https://meapplicationdevelopers.dev.java.net/uiLabs/SVGMakeover.html

Hope this helps,

-- Terrence

int0xicated
Offline
Joined: 2008-06-04
Points: 0

ok thanks, but i solved the problem now ... i just make a new thread and before this new thread i play the animation ...

sfitzjava
Offline
Joined: 2003-06-15
Points: 0

When you say it doesn't work, do you mean on the phone or on the WTK emulator?

Have you gone into the settings for the emulator and selected SVG support JSR 226?
Does the phone support JSR226 running on your provider? FYI.. Just because the phone maker says it supports SVG, doesn't mean the operator allowed it for just everyone, or even JavaME to use.

By "doesn't work" do you mean it throws an exception? What's the exception?
Have you looked at the WTK SVGDemo example, and can you get it to work on your system via the emulator or the phone?

-Shawn

int0xicated
Offline
Joined: 2008-06-04
Points: 0

sry for that ... the "doesn't work" means, that when i start my application the image is not played ... i just see the first frame and i dont get to the next menu after a certain time ... the best would be if there is a very easy example of how to make splashscreens for svg animations :( ...

lg

Message was edited by: int0xicated

int0xicated
Offline
Joined: 2008-06-04
Points: 0

nobody wants to help me :( ? ...