xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From George Armhold <armh...@taproot.rutgers.edu>
Subject how to get access to XML elements from SVGGraphics2D
Date Thu, 30 Aug 2001 14:52:20 GMT

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

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. 


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

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

View raw message