Java Reference
In-Depth Information
what version of SVG-T your phone supports, you can query the system
property as follows:
String svgVersion = System.getProperty("microedition.m2g.version");
boolean useSVG = svgVersion.equals("1.1");
In order to read the XML, the SVG-T specification defines a micro-
DOM that the implementation of the JSR must provide. This is a small
XML parser specifically designed to parse SVG elements. Note that as
part of the SVG-T implementation, it should not be considered an XML
parser for general use.
There are two ways to create SVG content: SVG images can be created
programmatically through a series of API calls but it is far more common
to load and manipulate SVG images prepared using a third-party graphics
tool such as Adobe Illustrator. If you don't have access to this, a common
open-source, free alternative for SVG content creation is Inkscape. 8 All
of the SVG images used for the menu system in this chapter were created
using Inkscape.
Before you attempt to load or display an SVG image from a MIDlet,
you need to convert it to SVG-T format. The S60 3rd Edition SDKs come
with an SVG to SVG-T conversion tool which you can use for this. The
installer can be found in the
subdirectory of your SDK root.
There are some incompatibilities with support for the 'text' element on
the Symbian OS implementation at this stage so it is best to convert any
text to a path (a series of line segments and arcs) in Illustrator or Inkscape
(see Figure 8.7) before converting it to SVG-T. The resulting SVG file will
be quite a bit bigger, depending on how much text it contains but for
simple menus like ours this is not an issue - remember that we don't need
to care too much about JAR size on Symbian OS.
Rendering to screen is done with an instance of the ScalableGraph-
ics class. Within our paint() method, we simply bind our Graphics
context to our scalable context, directly render SVG images to our canvas
and then release our context. By obtaining a handle to the root element of
an SVGImage instance we can also directly scale, rotate and translate the
image itself as well as change its properties such as its CSS style attribute
which defines fills, strokes, color, and so on.
The following code snippets are taken from the BasicSVGMenu-
Screen class which forms the base class for all the SVG menus in the
game. It is surprising how easy it is to get good effects with very little
\ S60Tools \
Search WWH ::

Custom Search