On Wednesday 06 June 2001 16:07, you 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?
That's not so easy :) The JSVGCanvas implements the paint method but also
uses some internal states of the component itself such as its size
(getSize()...). So if you only deleguate the paint method, that won't work.
Anyway, you can try this way (doing the proper things with the component's
bounds) or you can have a look at the code of the JSVGComponent and
JGVTComponent (the super class of JSVGComponent) and that in your own world.
Basically, it means to use the GVTBuilder class and the Renderer.
> 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?
The ImageTranscoder class creates a java.awt.image.BufferedImage (subclass of
java.awt.Image). You can then manipulate this image or write it in a byte
array.
Thierry.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]