Jens,
Thanks for your report,
About your first fix, If I look at current Batik release, both
SVGGraphics2D(Document,ImageHandler, ExtensionHandler, boolean) and
SVGGraphics2D(SVGGeneratorContext, boolean) seem to look as they are
actually initializing the SVGGeneratorContext and allow rendering of
text as shapes because the first ctor calls the second one. However as
you encounter an exception there's certainly a problem somewhere! What
version of Batik are you using? What is the exact exception you
encounter? Do you have an example showing the problem?
On the second point, the imageHandler not beeing called because of a
problem in BufferedImageHintKey, there's really a problem
somewhere in this area. You're right, in the past, Thomas changed
BufferedImageHintKey to use References instead of directly using
BufferedImages and it may have cause some problems on the SVGGenerator
as it looks as it is using it with BufferedImages and not References.
Thomas who is the one that modified
org/apache/batik/svggen/AbstractImageHandlerEncoder.java on this subject
(rev 1.4&1.5) may have more information on this subject.
Thanks a lot!
Thieler Jens wrote:
> is there a body, who has ever used the nice configuration switches in Batik.
>
> There are the options to convert text strings to shapes
> and to put images into separate files.
> (I need these.)
>
> Unfortunately, the necessary constructors use a only partly initialized
> SVGGeneratorContext, thus causing an exception somewhere downstream.
>
> I applied a few straightforward fixes to org.apache.svggen.SVGGraphics2D.
> Now text could be rendered as shapes.
> But the optional ImageHandlers still didn't work.
> Then I fiddled with org.apache.ext.awt.BufferedImageHintKey
> and all seems to be well now
> (although I've not the faintest idea of what I did there.)
>
> I would appreciate, if someone with more insight
> could see into this.
>
> Greetings
> Jens Thieler
>
> =======================================
> CHANGED CONSTRUCTORS AND NEW METHOD IN
> org.apache.svggen.SVGGraphics2D.java:
> =======================================
> public SVGGraphics2D(Document domFactory,
> ImageHandler imageHandler,
> ExtensionHandler extensionHandler,
> boolean textAsShapes) {
> super( textAsShapes );
> SVGGeneratorContext generatorCtx =
> SVGGeneratorContext.createDefault(domFactory);
> generatorCtx.setImageHandler(imageHandler);
> generatorCtx.setExtensionHandler(extensionHandler);
> this.initGeneratorContext( generatorCtx );
> }
>
> public SVGGraphics2D(SVGGeneratorContext generatorCtx,
> boolean textAsShapes) {
> super(textAsShapes);
> this.initGeneratorContext( generatorCtx );
> }
>
> /**
> * Constructor utility, added on 2001-05-14
> *
> * @param generatorContext the <code>SVGGeneratorContext</code> instance
> * that will provide all useful information to the generator.
> *
> * @exception SVGGraphics2DRuntimeException if generatorContext is null.
> */
> private void initGeneratorContext( SVGGeneratorContext generatorCtx ) {
> if( generatorCtx == null ) {
> // not error handler here as we don't have the ctx...
> throw new SVGGraphics2DRuntimeException(ERR_CONTEXT_NULL);
> }
> this.generatorCtx = generatorCtx;
>
> this.gc = new GraphicContext(new AffineTransform());
> this.shapeConverter = new SVGShape(generatorCtx);
> this.domTreeManager = new DOMTreeManager( gc,
> generatorCtx,
> DEFAULT_MAX_GC_OVERRIDES);
> this.domGroupManager = new DOMGroupManager(this.gc, this.domTreeManager);
> this.domTreeManager.addGroupManager(this.domGroupManager);
> } // end initGeneratorContext()
>
> =======================================
> CHANGED METHOD IN
> org.apache.ext.awt.BufferedImageHintKey.java
> =======================================
> public boolean isCompatibleValue(Object val) {
> if(val == null)
> return true;
>
> if(!(val instanceof Reference)) {
> if(val instanceof BufferedImage)
> return true;
> else
> return false;
> } else {
> Reference ref = (Reference)val;
> val = ref.get();
> if(val == null)
> return true;
> if(val instanceof BufferedImage)
> return true;
> }
> return false;
> }
> ========================================
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
--
Christophe
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]