|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.microedition.m2g.SVGAnimator
public abstract class SVGAnimator
The SVGAnimator
class handles automatic rendering of updates and
animations in an SVGImage
to a target user interface (UI) component.
The target component type depends on the Java profile this specification is
implemented on, as described in the createAnimator
and
getTargetComponent
methods documentation.
There are two types of rendering updates the SVGAnimator
handles:
SVGAnimator
can run animations
and automatically and periodically refreshes its rendering to
reflect the effect of animations.SVGAnimator
updates its rendering
following alterations of the associated SVGImage
,
for example if the position of one of the graphical elements is
modified by an API call.SVGAnimator
instance can be in one of the following states:
SVGAnimator
performs no rendering updates. play
method.SVGAnimator
. In that state, the SVGAnimator
performs both Animation and SVGImage updates.
While there are active animations,
the animator updates the rendering at a rate not faster than the one
defined by the setTimeIncrement
method. If SVGImage updates are made
(e.g., with calls to the SVGElement
setTrait
method, see examples), the rendering is updated at the time of
the next animation rendering.Runnable
passed to the invokeLater
or
invokeAndWait
methods has finished executing.
stop
method.pause
method.SVGAnimator
only
performs SVGImage updates rendering. The animator no longer automatically
advances the SVG document's current time, so rendering reflects the animation
at the document's current time. Note that a change to the document's current
time while in the paused state will trigger a new rendering for the
new current time.
stop
method.play
method.The SVGAnimator
dispatches events to the SVGEventListener
and automatically dispatches events it
detects to the SVGImage
. Events dispatched by the SVGAnimator are limited to the at-target and bubble phase of the
DOM Level 2 event flow.
// Create an SVGAnimator SVGImage map = ...; // See the SVGImage documentation. SVGAnimator svgAnimator = SVGAnimator.createAnimator(map); // Display the associated SVGAnimator component. // Depends on the platform. // =============== AWT Example =============== Panel panel = ....; panel.add((Component) svgAnimator.getTargetComponent()); ... // =============== MIDP Example =============== Canvas svgCanvas = (Canvas) svgAnimator.getTargetComponent()); ... // Start rendering animations. svgAnimator.play(); .... class MapRunnable implements Runnable { public void run() { // Perform map updates based on current // traffic information. SVGElement statusRect = map.getDocument().getElementById("statusRect"); // Reflect that traffic status. statusRect.setRGBTrait(...); // See setRGBTrait documentation. } } Runnable mapUpdates = new MapRunnable(); .... while (someLoopCondition) { if(hasMapUpdate) { svgAnimator.invokeAndWait(mapUpdates); } }
Constructor Summary | |
---|---|
SVGAnimator()
|
Method Summary | |
---|---|
static SVGAnimator |
createAnimator(SVGImage svgImage)
This method creates a new SVGAnimator for the specified SVGImage. |
static SVGAnimator |
createAnimator(SVGImage svgImage,
java.lang.String componentBaseClass)
This method creates a new SVGAnimator for the specified SVGImage. |
abstract java.lang.Object |
getTargetComponent()
The type of target component associated with the animator depends on the Java profile this specification is implemented on: javax.microedition.lcdui.Canvas on profiles supporting LCDUI java.awt.Component on profiles supporting AWT |
abstract float |
getTimeIncrement()
Returns the current time increment used for animation rendering. |
abstract void |
invokeAndWait(java.lang.Runnable runnable)
Invoke the input Runnable in the Document update thread and return after the Runnable has completed. |
abstract void |
invokeLater(java.lang.Runnable runnable)
Schedule the input Runnable for execution in the update thread at a later time. |
abstract void |
pause()
Transitions this SVGAnimator to the paused state. |
abstract void |
play()
Transitions this SVGAnimator to the playing
state. |
abstract void |
setSVGEventListener(SVGEventListener svgEventListener)
Sets the SVGEventListener associated with this
SVGAnimator . |
abstract void |
setTimeIncrement(float timeIncrement)
Sets the time increment to use for animation rendering. |
abstract void |
stop()
Transitions this SVGAnimator to the stopped state. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SVGAnimator()
Method Detail |
---|
public static SVGAnimator createAnimator(SVGImage svgImage)
SVGAnimator
for the specified SVGImage.
svgImage
- the SVGImage
this animator should render.
SVGAnimator
instance.
java.lang.NullPointerException
- if svgImage
is null.public static SVGAnimator createAnimator(SVGImage svgImage, java.lang.String componentBaseClass)
SVGAnimator
for the specified SVGImage.
The following components types must be supported:
svgImage
- the SVGImage
this animator should render.componentBaseClass
- the desired base class for the component associated
with the animator. This is used when the platform this specification
is implemented on supports multiple UI component frameworks. If
componentBaseClass is null, this is equivalent to invoking the
createAnimator
method with the svgImage parameter only.
SVGAnimator
instance.
java.lang.NullPointerException
- if svgImage
is null.
java.lang.IllegalArgumentException
- if the requested
componentBaseClass
is not supported by the
implementation.public abstract void setSVGEventListener(SVGEventListener svgEventListener)
SVGEventListener
associated with this
SVGAnimator
.
svgEventListener
- the new SVGEventListener which will receive
events forwarded by this SVGAnimator
. May be null,
in which case events are not forwarded by the SVGAnimator
.public abstract void setTimeIncrement(float timeIncrement)
timeIncrement
- the minimal time that should ellapse between frame
rendering. In seconds. Should be greater than zero.
java.lang.IllegalArgumentException
- if timeIncrement is less than or equal to
zero.getTimeIncrement()
public abstract float getTimeIncrement()
setTimeIncrement(float)
public abstract void play()
SVGAnimator
to the playing
state. While in the playing state, both Animation and SVGImage
updates trigger rendering updates. Note that a change to the document's
current time while in the playing state will cause the animator to seek
to the new time, and continue to play animations forward.
java.lang.IllegalStateException
- if the animator is not currently in
the stopped or paused state.public abstract void pause()
SVGAnimator
to the paused state.
The SVGAnimator
stops advancing the document's current time
automatically (see the SVGDocument's setCurrentTime method). As a result,
animations are paused until another call to the play
method
is made, at which points animations resume from the document's current
time. SVGImage updates (through API calls) trigger a rendering update
while the SVGAnimator
is in the paused state.
java.lang.IllegalStateException
- if the animator is not in the playing
state.public abstract void stop()
SVGAnimator
to the stopped state.
This causes the SVGAnimator
to stop advancing the document's
current time automatically, and no rendering updates are performed while
in stopped state. A call to the play method will cause
the animations to resume from the document's current time.
java.lang.IllegalStateException
- if the animator is not in the playing
or paused state.public abstract java.lang.Object getTargetComponent()
createAnimator(javax.microedition.m2g.SVGImage)
public abstract void invokeAndWait(java.lang.Runnable runnable) throws java.lang.InterruptedException
runnable
- the new Runnable to invoke.
java.lang.InterruptedException
- if the current thread is waiting,
sleeping, or otherwise paused for a long time and another thread
interrupts it.
java.lang.NullPointerException
- if runnable
is null.
java.lang.IllegalStateException
- if the animator is in the stopped state.public abstract void invokeLater(java.lang.Runnable runnable)
runnable
- the new Runnable to execute in the Document's update
thread when time permits.
java.lang.NullPointerException
- if runnable
is null.
java.lang.IllegalStateException
- if the animator is in the stopped state.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |