Hello,
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]