You can render the svg document directly to a java Graphic.
ie.
something like this.
protected void renderSVGDocument(Document doc, int x, int y) {
UserAgent userAgent = new MUserAgent(new AffineTransform());
GVTBuilder builder = new GVTBuilder();
GraphicsNodeRenderContext rc = getRenderContext();
BridgeContext ctx = new BridgeContext(userAgent, rc);
GraphicsNode root;
graphics.translate(x, pageHeight - y);
graphics.setRenderingHints(rc.getRenderingHints());
try {
root = builder.build(ctx, doc);
root.paint(graphics, rc);
} catch (Exception e) {
e.printStackTrace();
}
graphics.translate(-x, y - pageHeight);
}
Where the graphic is where it is being drawn into (after some translation
etc.)
This is how it is done in the AWTRenderer for the FOP project. So if you
want to see the rest of the code look there.
Basically it builds the Root GraphicsNode from the DOM then paints that
into the Graphic.
On Wed, 06 Jun 2001 16:07:21 Eli Gordon wrote:
> Sorry for the newbie question, but this one has me stuck...
>
> I need to be able to display SVG graphics in an application, but I can't
> use
> JSVGCanvas (the portion of the app in question isn't using a Swing
> component
> model). So, as far as I can tell, I have two options with Batik:
>
> 1. Create a JSVGCanvas anyway, and just try to re-direct its paint method
> to
> use my Graphics instead of its parent's.
> - I've tried doing this by just sending a paint() message and specifying
> my
> Graphics, but to no avail... I'm not very familiar with Swing, so I may
> be
> missing something... Is this at all a feasible method?
>
> 2. Use a transcoder to grab a raster version, and then re-transcode each
> time the size of the displayed image needs to change.
> - This seems like it should be quite simple. However, as far as I can
> tell,
> Batik only comes with Transcoders for storage formats (JPEG, PNG, TIFF),
> and
> not a Transcoder for rendering into something like an Java Image or a
> byte
> array. Should I write my own Transcoder for this, or is there already a
> way
> to accomplish this? What would the speed difference be in comparison with
>
> JSVGCanvas?
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]