Muthuganesh Jothi Ramalingam wrote:

I've been searching and trying a bunch of different things over the last couple of days, and I can't seem to get the desired results. Here is my requirement: I have a bunch of Java2D Shapes that I would like to pass through the SVGGenerator to generate my SVG file via SVGGraphics2D.stream(). However, I haven't quite figured out the best way to modify the DOM so I can associate my own intelligent information with the svg paths or even modify the DOM to change or add some SVG tags.

   At any point you can get the generated subtree by
calling 'svgg2d.getRoot(parent)'.  So you can get the just generated
element.  You can also look at extending the SVGGeneratorContext
(see the web page for some examples).

For example: I have drawn a rectangle and on mouse clicked event i am plotting circles over the rectangle. Now, on click of a button i should be able to hide all the circles. This can be done by getting the circle elments from SVG Dom and set the visible attribute.

   Unless you have some funny stacking requirements I would hide/unhide
by toggling visibility on a single 'g' that the circles are children of.

my question is,

1. There is no id element in the DEFAULT SVG content generated by the SVGGraphics2D. How to give id attribute to each element ?

   If you do the above you don't need to, you just need the 'id' of
the 'g' element which can already be in the displayed document.

- Should i create the SVG circle elements myself and should add it to the SVGDom, is that the correct way ? and should take care of adding it under appropriate parents etc., So each time for a mouse click this must be done ? Ooops!!! then lot of work, performance will be poor, i think.

   What do you think the SVGGraphics2D is doing?  This will probably
be faster than using the Graphics2D as you can likely construct
the element quicker since you don't need to handle all cases.

   Just make sure that you only modify the SVGDocument in the
UpdateManager thread.

Any hints would be greatly appreciated because I'm trying to come up with a proof of concept to show off the advantages of on-the-fly, generated SVG.

Note: No swing components only java2d shapes.

Thanks,
Leo


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

Reply via email to