Hi all, I am using batik to user regular Graphics2D code to paint into a SVG file. Now I would like to add links from some of the elements in the SVG to extarnal urls. What I am doing goes along this... String filename = "chrommap_"+ StringTools.getRandomString(6)+".svg"; resp.setContentType("image/svg+xml"); resp.setHeader("Content-disposition", "inline; filename="+filename); canvas.setSize(x_size,y_size); DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation(); org.w3c.dom.Document document = domImpl.createDocument(null, "svg", null); SVGGraphics2D svgGenerator = new SVGGraphics2D(document); canvas.paint(svgGenerator); Writer out = new OutputStreamWriter(resp.getOutputStream(), "UTF-8"); svgGenerator.stream(out, useCSS); I have been looking around in archieves and found this http://www.nabble.com/SVGGraphics2D-and-id-t1593800.html#a4325094, but what I really want is to do something like class MyCanvas { ... public void paint(Graphics) { ... g.fillRectangle(2,2,40,40); if (Graphics instanceof SVGGraphics2D) { ** Add and to the last element painted } ... } } Mads Hjorth cand.scient.dat, Scientific Programmer Wilhelm Johannsen Center for Funktional Genome Research Institut for Medical Biochemistry and Genetics 2200 Copenhagen N www.wjc.ku.dk/~madsh |
