Hi Dominik.

Dominik Lindner:
> I have few problems with SVGGraphics2D.
> I want to create a SVG document, draw in it's graphics context, stream it 
> out, 
> reset the graphic content, redraw, and so on.
> 
> Example:
> 
> DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation();
> Document document = domImpl.createDocument(null, "svg", null);
> SVGGraphics2D g = new SVGGraphics2D(document);
> // draw graphics in g
> // ...
> FileWriter out = new FileWriter("/home/dominik/test.svg");
> g.stream(out, false);
> //...
> g.dispose() //delete graphics content
> // redraw graphics in g
> //...
> out = new FileWriter("/home/dominik/test2.svg");
> g.stream(out, false);
> 
> There seem's to be a known bug in batik, so that streaming out results in a 
> corrupted document. So I tried the work-around:

What do you mean that it results in a corrupted document?

> Element e = document.getDocumentElement();
> g.getRoot(e);
> g.stream(root, out, false);
> But this has the consequence that I cannot reset SVGGraphics2D, I can't 
> delete 
> the graphics content. SVGGraphics2D.dispose() seems to have no effect.
> How can I delete the graphics content of SVGGraphics2D? Is there a way for 
> doing this task?

The javadoc for the dispose method says:

  A Graphics object cannot be used after dispose has been called.

so presumably can't use that to do what you want.

But the getTopLevelGroup method, which returns the 'g' element into
which the SVG elements so far have been stored, claims that it will
"also cause this object to start working with a new topLevelGroup", so
perhaps this will do what you want.

Otherwise, is there any reason you don't want to create a new
SVGGraphics2D object?  There's maybe a slight overhead, but I don't
think it's too great.

Cameron

-- 
 Cameron McCormack                      ICQ: 26955922
 cam (at) mcc.id.au                     MSN: cam (at) mcc.id.au
 http://mcc.id.au/                      JBR: heycam (at) jabber.org

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to