xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathan wood <jonathanshaww...@gmail.com>
Subject Re: Exporting a RadialGradientPaint
Date Tue, 30 Aug 2011 23:14:22 GMT
Hi Ryan,

  Although Batik most certainly supports radial gradients, I'm not sure that
support currently extends to the SVGGraphics2D arena.  You can likely add
support for it quickly though by extending DefaultExtensionHandler and
overriding the handlePaint method...something like this...

public class RadialGradientPaintExtensionHander extends
DefaultExtensionHandler {
    @Override
    public SVGPaintDescriptor handlePaint(Paint paint, SVGGeneratorContext
svggc) {
        if(paint instanceof RadialGradientPaint) {
            // create svg radial gradient dom elements
            ...
            // return an extension of SVGPaintDescriptor appropriate for
this radial gradient
        }
        return null;
    }
}

You can also use the dom directly and then transcode the resulting document,
but that is an entirely different approach.

Hope this helps,

 jonathan


On Mon, Aug 29, 2011 at 2:56 PM, Ryan Noon <rmnoon@gmail.com> wrote:

> Hi All,
>
> I just started learning Batik and I'm really amazed by it so far!  I'm
> kind of new to SVG to please bear with me.
>
> I've got a Java 2D method that draws a circle of nodes connected by
> edges.  Each node is drawn using a java.awt.RadialGradientPaint (see
> attached circle_swing.png).
>
> When I try to render this to an SVG using SVGGraphics2D everything
> goes fine except that the nodes are drawn as a solid color, which I
> believe is the color of the last node.  (see attached circle_svg.png
> and circle.svg).
>
> How can I get the radial gradients to draw properly?  I've read that
> they exist in SVG and the Batik status list says they're supported
> currently.
>
> The export code I'm using is a direct port of the tutorial here:
> http://xmlgraphics.apache.org/batik/using/svg-generator.html
>
> I'm using the latest SVN of Batik on OS X Lion with the Apple JRE.
>
> Thanks!
>
> Ryan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>

Mime
View raw message