>>>>> "George" == George Armhold <[EMAIL PROTECTED]> writes:
George> Greetings, I'd like to inquire about the current state of
George> Batik with respect to dynamically updating documents via
George> the DOM. I've seen a few messages in the list archives
George> suggesting that some dynamic features work in the 1.5
George> beta, however my updates don't seem to work. (I also
George> tried the latest version from CVS, no luck.) What I'm
George> doing is extending JSVGComponent with a class that loads a
George> document, and then modifies the DOM programmatically via
George> Java (no scripting.) My changes never seem to get
George> displayed in the JSVGComponent. The updates I'm doing are
George> pretty simple- I'm adding <svg> elements that contain
George> <line> elements. If I write out the updated SVG document
George> to a file, I can successfully view my added items with the
George> batik-svgbrowser.
George> I also tried forcing a re-display by calling
George> setSVGDocument(getSVGocument());
George> but I get a NullPointerException.
I think I had a similar problem with the setSVGDocument method. I
I could only make it render my document after making sure that every <svg>
element had certain attributes, like this:
<svg x="0.0" contentScriptType="text/ecmascript" y="0.0" width="210.0"
zoomAndPan="magnify" contentStyleType="text/css" id="N400001tag1"
height="80.0" preserveAspectRatio="xMidYMid meet"
xmlns="http://www.w3.org/2000/svg" version="1.0">
This one wouldn't be displayed (or raise some exceptions):
<svg height="40.0" id="N400008tag1" width="70.0" x="140.0" y="40.0">
To transform the initial SVG to the one that would be rendered, I
serialized it first and then used the SAXSVGDocumentFactory (there may
be a less clumsy way to do it, but I don't know better) like:
the serialization:
StringWriter osw = new StringWriter();
PrintWriter pw = new PrintWriter(osw, false);
serializer.transform(new javax.xml.transform.dom.DOMSource(SVG),
new javax.xml.transform.stream.StreamResult(pw));
transformation of "plain" SVG to batik-SVGDocument:
String parser =
org.apache.batik.util.XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(parser);
Document svgDoc = factory.createDocument(null, new StringReader(osw.toString()));
I'd like to know if this helped and whether you know about any
improvements
best
Ingrid
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]