xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lila Tran <chinaros...@gmail.com>
Subject Re: How come my piechart is gray when using svg
Date Mon, 22 Aug 2005 16:09:36 GMT
Went to work this morning, checked out batik from svn, did what you
told, it worked!

I have a few questions, when users few my charts online, do they have
to also checkout the latest batik from svn also in order to view the
charts correctly?  Another question is when are you guys going to
release the batik version from svn that has a fix for that?

Please let me know thanks!

Lila

On 8/20/05, Archie Cobbs <archie@dellroad.org> wrote:
> Lila Tran wrote:
> > Actually, I am using batik 1.6, just downloaded about three weeks ago.
> >  In the forum, I stated that I also tried batik 1.5, but that didn't
> > do any changes.  Do you have any other suggestions?  Below is the
> > method that I use to save the chart as svg file.
> 
> There is a bug in 1.6 when drawing certain arcs. This may or may
> not be your problem (it looks suspiciously similar). You can try
> applying the attached patch and rebuilding Batik.
> 
> -Archie
> 
> __________________________________________________________________________
> Archie Cobbs      *        CTO, Awarix        *      http://www.awarix.com
> 
> 
> --- sources/org/apache/batik/svggen/SVGArc.java.orig    2005-06-20 10:35:30.191343072
-0500
> +++ sources/org/apache/batik/svggen/SVGArc.java 2005-06-20 10:46:41.765248320 -0500
> @@ -18,6 +18,7 @@
>  package org.apache.batik.svggen;
> 
>  import java.awt.geom.Arc2D;
> +import java.awt.geom.Ellipse2D;
>  import java.awt.geom.Line2D;
>  import java.awt.geom.Point2D;
> 
> @@ -38,6 +39,11 @@
>      private SVGLine svgLine;
> 
>      /**
> +     * Ellipse converter for 360 degree arcs.
> +     */
> +    private SVGEllipse svgEllipse;
> +
> +    /**
>       * @param generatorContext used to build Elements
>       */
>      public SVGArc(SVGGeneratorContext generatorContext) {
> @@ -48,23 +54,36 @@
>       * @param arc the Arc2D object to be converted
>       */
>      public Element toSVG(Arc2D arc) {
> -        if ((arc.getWidth() == 0) ||  (arc.getHeight() == 0)) {
> +        double ext    = arc.getAngleExtent();
> +        double width  = arc.getWidth();
> +        double height = arc.getHeight();
> +
> +        if (width == 0 || height == 0) {
>              Line2D line = new Line2D.Double
>                  (arc.getX(), arc.getY(),
> -                 arc.getX() + arc.getWidth(),
> -                 arc.getY() + arc.getHeight());
> -            if (svgLine == null)
> +                 arc.getX() + width,
> +                 arc.getY() + height);
> +            if (svgLine == null) {
>                  svgLine = new SVGLine(generatorContext);
> +            }
>              return svgLine.toSVG(line);
>          }
> 
> +        if (ext >= 360 || ext <= -360) {
> +            Ellipse2D ellipse = new Ellipse2D.Double
> +                (arc.getX(), arc.getY(), width, height);
> +            if (svgEllipse == null) {
> +                svgEllipse = new SVGEllipse(generatorContext);
> +            }
> +            return svgEllipse.toSVG(ellipse);
> +        }
> +
>          Element svgPath = generatorContext.domFactory.createElementNS
>              (SVG_NAMESPACE_URI, SVG_PATH_TAG);
>          StringBuffer d = new StringBuffer("");
> 
>          Point2D startPt = arc.getStartPoint();
>          Point2D endPt   = arc.getEndPoint();
> -        double  ext     = arc.getAngleExtent();
>          int     type    = arc.getArcType();
> 
>          d.append(PATH_MOVE);
> @@ -74,17 +93,25 @@
>          d.append(SPACE);
> 
>          d.append(PATH_ARC);
> -        d.append(doubleString(arc.getWidth()/2));
> +        d.append(doubleString(width / 2));
>          d.append(SPACE);
> -        d.append(doubleString(arc.getHeight()/2));
> +        d.append(doubleString(height / 2));
>          d.append(SPACE);
>          d.append("0");  // no rotation with J2D arc.
>          d.append(SPACE);
> -        if (ext > 180)  d.append("1");  // use large arc.
> -        else            d.append("0");  // use small arc.
> -        d.append(SPACE);
> -        if (ext > 0)    d.append("0");  // sweep ccw
> -        else            d.append("1");  // sweep cw
> +        if (ext > 0) {
> +            // CCW sweep case, ext > 0
> +            if (ext > 180)  d.append("1");  // use large arc.
> +            else            d.append("0");  // use small arc.
> +            d.append(SPACE);
> +            d.append("0"); //sweep ccw
> +        } else {
> +            // CW sweep case, ext < 0
> +            if (ext < -180) d.append("1"); // use large arc
> +            else            d.append("0"); // use small arc
> +            d.append(SPACE);
> +            d.append("1");
> +        }
> 
>          d.append(SPACE);
>          d.append(doubleString(endPt.getX()));
> @@ -94,8 +121,8 @@
>          if (type == Arc2D.CHORD) {
>              d.append(PATH_CLOSE);
>          } else if (type == Arc2D.PIE) {
> -            double cx = arc.getX()+arc.getWidth()/2;
> -            double cy = arc.getY()+arc.getHeight()/2;
> +            double cx = arc.getX() + width / 2;
> +            double cy = arc.getY() + height / 2;
>              d.append(PATH_LINE_TO);
>              d.append(SPACE);
>              d.append(doubleString(cx));
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 
>

---------------------------------------------------------------------
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