Gunmuc wrote:
im using batik to draw several rectangles via graphics2D.
now i would like to add a link to another html or svg document to the rectangle. if the user clicks on the rectangle, the other document should appear.
how can this be done using batik?
Well, it's not as easy as it might be. Although I've thought about it quite a bit and it isn't real clear how it could be made lots easier (you have a fairly inherent disconnect between the drawing code and the annotation code). Perhaps something interesting with rendering hints could be done (at least to add 'ids' or something).
Anyway to get back to your question:
The basic idea is to wrap the 'rect' elements in 'a' elements with your link on them[1]. The most straight forward way to do it is to repeatedly call 'getRoot'. So you would call 'getRoot' passing in SVG element of your document before you draw the rectangles you want the anchor on, this will add all the content up to that point to your document, then create an 'a' element (using createElementNS), add that to your document (appendChild), then draw your rectangles, then call 'getRoot' again only this time with your 'a' element. Repeat as needed.
[1] Note that squiggle only handles SVG, so you can't link directly to HTML and expect squiggle to do anything. There are methods on the Batik User agent you can use to tap into the opening of links. But I would guess you are trying to generate SVG for consumption by something like the Adobe SVG Viewer.
There is another note that says how to do this with scripting which can have advantages but I think in this case you are looking for a fairly simple anchor.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]