I'm doing some testing with some of my older SVG applications and ran
into an odd behavior in Batik 1.6 and 1.7.
I am applying a linear gradient as a fill to a path. The path starts
out as a point at (0, 0). In my application, I extend the path through
scripting to make a sort of strip chart.
The problem is that Squiggle (in either 1.6 or 1.7) immediately fails
with an NPE if I use a linear gradient on this empty path. If I use a
solid color, there is no problem.
Since I originally developed this application with Squiggle as my
viewer, I quite certain it worked once upon a time. But, now I get the
following error.
-----------------------------
java.lang.NullPointerException
at
org.apache.batik.bridge.SVGLinearGradientElementBridge.buildGradient(SVGLinearGradientElementBridge.java:127)
at
org.apache.batik.bridge.AbstractSVGGradientElementBridge.createPaint(AbstractSVGGradientElementBridge.java:113)
at
org.apache.batik.bridge.PaintServer.convertURIPaint(PaintServer.java:359)
at
org.apache.batik.bridge.PaintServer.convertPaint(PaintServer.java:259)
at
org.apache.batik.bridge.PaintServer.convertFillPaint(PaintServer.java:228)
at
org.apache.batik.bridge.PaintServer.convertFillAndStroke(PaintServer.java:146)
at
org.apache.batik.bridge.SVGShapeElementBridge.createShapePainter(SVGShapeElementBridge.java:117)
at
org.apache.batik.bridge.SVGDecoratedShapeElementBridge.createFillStrokePainter(SVGDecoratedShapeElementBridge.java:58)
at
org.apache.batik.bridge.SVGDecoratedShapeElementBridge.createShapePainter(SVGDecoratedShapeElementBridge.java:84)
at
org.apache.batik.bridge.SVGShapeElementBridge.buildGraphicsNode(SVGShapeElementBridge.java:91)
at
org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(GVTBuilder.java:224)
at
org.apache.batik.bridge.GVTBuilder.buildComposite(GVTBuilder.java:171)
at
org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(GVTBuilder.java:219)
at
org.apache.batik.bridge.GVTBuilder.buildComposite(GVTBuilder.java:171)
at org.apache.batik.bridge.GVTBuilder.build(GVTBuilder.java:82) at
org.apache.batik.swing.svg.GVTTreeBuilder.run(GVTTreeBuilder.java:96)
-------------------------------
I've reduced the example to the following:
-------------------------------
<svg height="600" width="800" viewBox="0 0 400 300"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<linearGradient id="fade" x1="0%" y1="100%" x2="0%" y2="0%">
<stop offset="0%" style="stop-color:orange;"/>
<stop offset="100%" style="stop-color:yellow;"/>
</linearGradient>
</defs>
<rect x="100" y="50" width="200" height="25" style="fill:url(#fade);
stroke:none;"/> <g transform="translate(100,100) scale(1,-1)">
<path id="fadefilled" style="fill:url(#fade); stroke:none;"
d="M0,0"/>
</g>
</svg>
-------------------------------
If I add 'l0,0' or 'v0' or 'h0' to the path, it works fine. So I have a
workaround.
Both Firefox 3.03 and Opera 9.6 handle this case without problems, and
I couldn't find anything in the spec that suggests it's invalid.
Am I confused or should this work?
G. Wade
--
Virtual is when it's not but it looks like it is and transparent is
when it is but it looks like it isn't. -- Rick Hoselton
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]