xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vincent Hardy <vincent.ha...@sun.com>
Subject Re: how to get access to XML elements from SVGGraphics2D
Date Mon, 03 Sep 2001 06:59:01 GMT
George,

There is actually a way to do 1. which, in effect, boils down to adding
custom information to the generated DOM tree. You can have a look at
SVGSwingPrettyPrinter for an example of adding custom information to 
the generated DOM tree. That example adds ids to the generated content
(Swing components), but it addresses the same issue you have, I believe.

Option 2. is always a possibility but you will end up redoing a lot
of what SVGGraphics2D does for you.

As for option 3., I do not know of someone trying to re-implement the
Graphics2D interface with different return types.

Finally, concerning your mailing list problem, I think your message got
on the list properly so it seems that things are working ok now.

Good luck with your project.
Regards,
Vincent.

George Armhold wrote:
> 
> Hi,
> 
> I've been using the SVGGraphics2D to start converting some existing
> code to SVG, and it's been a real time saver.  Now I'm at the point
> where I need to start adding interactivity to my SVG output via
> JavaScript.  Since I'm using SVGGraphics2D and standard Java2D calls
> for painting, I find that I don't have easy access to the XML elements
> that SVGGraphics2D produces.  For example, with the following code:
> 
>     g.fill(new Rectangle(0, 0, 100, 100));
> 
> I'd like to get access to the XML element corresponding to that
> Rectangle, so I can insert onClick() events, etc.  I see three
> possible ways of doing this:
> 
> 1.  Continue to use SVGGraphics2D, and after each 2D api call,
> traverse the DOM tree to find the most recently added node.  I imagine
> this would be very error prone and perhaps DOM
> implementation-dependent.
> 
> 2. Abandon SVGGraphics2D, and assemble the DOM tree by hand.  This
> would give me complete access to all the graphic elements, but I would
> lose the ease of use I get from using my existing knowledge of the 2D
> api.  I would also lose the ability to easily share my drawing code
> between SVG and native Java UI applications.
> 
> 3. Extend SVGGraphics2D so that all the drawing code, (draw(),
> drawString(), fill(), etc.) return the newly created XML Elements rather
> than void.
> 
> I would appreciate hearing opinions on which route might be the best
> to take, and especially if anyone has attempted route # 3.  If you
> have a reply to this query please include my address on the Cc list,
> as I'm not sure my list subscription is working properly.
> 
> Thanks.
> 
> PS: to the list maintainer- I've subscribed twice to
> batik-users-digest but have yet to see any traffic... is the list
> working ok?  A month or so ago I wrote to the list with a question and
> my mail bounced.  I was surprised to see my question (and several
> responses!) appear in the list archives yesterday when searching at
> http://koala.ilog.fr/batik/.
> 
> --
> George Armhold
> Rutgers University
> Bioinformatics Initiative
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Mime
View raw message