Java Reference
In-Depth Information
3. Get the component—a Canvas when using the MIDP—on which the SVGAnimator
will render the image.
4. Set the bounds of the SVGImage to the bounds the SVGAnimator 's component.
5. Make the SVGAnimator 's component visible.
6. Use the SVGAnimator to start playing the animation.
When rendering an animated SVG, the SVGAnimator implementation uses the desired
SVG image and a container of some kind provided by the platform's actual GUI hierarchy,
such as the MIDP or the AWT. The designers of the SVGAnimator class assumed that it
would be used on both CLDC and CDC platforms, so it doesn't return a specific instance
of an MIDP class such as Canvas . Instead, the SVGAnimator provides the getTargetComponent
to return a component into which it renders the SVG, much as an MMAPI VideoControl
instance returns a component via its initDisplayComponent method. When using the
SVGAPI on an MIDP platform, the object that getTargetComponent returns is a Canvas
instance; on other platforms, it's a subclass of Component . Thus, on MIDP platforms,
you can use the Display class's setCurrent method to set the resulting Canvas as the
Displayable to draw; on other platforms, you can insert the resulting component into
the appropriate container in your GUI's view hierarchy.
The SVGAnimator class implements an update thread, which it uses to render the SVG
image as an animated image. The thread itself implements a simple state machine with
the three states that you see in Figure 16-5.
Figure 16-5. The SVGAnimator state machine
 
Search WWH ::




Custom Search