alex_philippi wrote: > > --- In [email protected], Thomas DeWeese wrote:
>> Sure check out: http://xml.apache.org/batik/svggen.html >> >> It gives an overview of the SVGGraphics2D with sample code. > > Thnx a lot. Now I know that i will use batik only for create pdf or > image files and code the rest manually because I dont use in a > servlet the graphic classes (e.g. drawrect). Perhaps I could use > the DOM Model for my Project but the output stream of a servlet > seems to be the better solution(e.g. below). For simple projects println is a fine solution, the learning curve is tiny, but the drawback is that there is nothing checking what you are doing. By using the SVGGraphics2D when you draw a rect it makes sure you provide the proper parameters, in other words it gives you a strongly typed interface (DOM BTW is little better than println, because everything is still strings, except that the final XML is machine generated so silly things like missing quotes, or not using XML entities won't happen). The only other advantage of using DOM (or potentially graphics2D) is that with Batik you can have access to the SVG DOM so you can get things like the bounding box of elements. This isn't a big deal for simple things like lines & boxes, but is _really_ nice for things like text. Also you might want to check out the Batik mailing lists: http://xml.apache.org/batik/mailList.html > <DOM BATIK example> > // set the width and height attribute on the root svg element > svgRoot.setAttributeNS(null, "width", "400"); > svgRoot.setAttributeNS(null, "height", "450"); > > // create the rectangle > Element rectangle = doc.createElementNS(svgNS, "rect"); > rectangle.setAttributeNS(null, "x", "10"); > rectangle.setAttributeNS(null, "y", "20"); > rectangle.setAttributeNS(null, "width", "100"); > rectangle.setAttributeNS(null, "height", "50"); > rectangle.setAttributeNS(null, "style", "fill:red"); > > // attach the rectangle to the svg root element > svgRoot.appendChild(rectangle); > </DOM BATIK example> > > <OUTPUT STREAM SERVLET> > PrintWriter out = response.getWriter(); > out.println("<svg width=\"400\" height=\"450\"> > <rect x=\"10\" y=\"20\" width=\"100\" height=\"50\" style=\"fill: > red\"/> > </svg>"); > </OUTPUT STREAM SERVLET> ----- To unsubscribe send a message to: [EMAIL PROTECTED] -or- visit http://groups.yahoo.com/group/svg-developers and click "edit my membership" ---- Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/svg-developers/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

