This idea came up on the piccolo2d-dev maillist.
TODO: insert the options Michael mentioned and the example from the comment below.
See also issue#61 (on Google Code) issue#81 (on Google Code)
And have a look at http://wiki.svg.org/JSR_226 and http://wiki.svg.org/JSR_287
Piccolo2d is a scenegraph ZUI toolkit, svg is a 2d vector graphics description language. Both share the idea of a scene graph and the grouping and transformation concepts also look similar at a first glance.
Is it possible to use svg documents e.g. generated by inkscape as input and convert them to piccolo2d scenegraphs?
There was some idea to build svg support into jazz. The v1.1 API has some svg classes.
- parse svg xml (e.g. using the super-lightweight XPP3 min xml pull parser).
- parse css and build up a hierarchy.
- parse svg paths and convert to generalpaths (shapes)
- look up nodes in a piccolo2d scenegraph according to their ID (tree search)
- keep it as lean as possible (<100K ?)
- do NOT add any new runtime/build requirements
- use a factory/strategy to parse the svg input
- add a css manager class
- create a scenegraph (PNode) using out-of-the-box PNode, PPath, PText, PImage classes
- attach node id, css classes etc. as attributes.
Aim for for SVG 1.1 Tiny and use the examples from the specification as test input. Development happens in the svg2009 branch.
As I develop this in a local git repo and merge to svn, a finer-grained commit history can be obtained from the git://github.com/mro/piccolo2d.java.git repository.
- Proof a concept 1. Sax Parser to read the svg xml 1. The following Basic Shapes with styling via attributes (no CSS, no "style" attribute)
- CSS, step I: 1. "style" attribute
- Complete the basic shape module 1. <ellipse /> 1. <line /> 1. <polyline /> 1. <polygon /> 1. <path /> without elliptical arcs
- CSS, step II: 1. "style" element
- <use /> Element
- Basic Text
- Images
- evtl. Basic Font
- css parsing: more than rudimentary support is a terrible lot of code. See http://www.w3.org/Style/CSS/SAC/, http://cssparser.sourceforge.net/ and http://today.java.net/pub/a/today/2003/10/14/swingcss.html
- the "path" element arcs require complex code. See Batik ExtendedGeneralPath
- the "use" element requires cloning and re-application of the CSS on every node. The PNode.clone() implementation is rather slow.
- the "text" element will be only rudimentary (no text along a path, rotated glyphs etc.)
- graceful failure for unexpected svg features?
- fatal failure for invalid svg (validating parser?)