Hi Denis,

"Denis Weerasiri" <ddweerasiri@gmail.com> wrote on 11/11/2008 05:47:33 AM:

> I use
> import org.apache.batik.svggen.SVGGraphics2D;
> import org.apache.batik.swing.JSVGCanvas;

> above set of classes for my program. I have some data from a DB and
> based on those data I need to generate a flow diagram using SVG.
> For some components in that flow diagram I need to display png images.

    So you are drawing the diagram using Java
Graphics2D and displaying that in the Canvas?

    You can always use Java2D to fetch an decode the PNG image
using java.awt.Toolkit.createImage(URL) (make sure the image
is fully loaded before you draw it to the SVGGraphics2D).

> import org.w3c.dom.Element;
> import org.w3c.dom.svg.SVGDocument;

    Alternately if you are already manipulating the SVG
document after SVGGraphics2D has generated most of it you
can use Document.createElementNS to create an SVG image element
and the Element.setAttributeNS to set the xlink:href attribute
(to either a URL for the PNG, or base64 data - which you
can get from the Batik.util.Base64EncoderStream).  I suspect
just drawing the Image to the Graphics2D will be your
best bet.

> import org.apache.batik.dom.svg.SVGDOMImplementation;
> import org.w3c.dom.DOMImplementation;