xmlgraphics-batik-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vha...@apache.org
Subject cvs commit: xml-batik/sources/org/apache/batik/gvt MarkerShapePainter.java
Date Mon, 02 Dec 2002 13:02:39 GMT
vhardy      2002/12/02 05:02:39

  Modified:    sources/org/apache/batik/gvt MarkerShapePainter.java
  Log:
  Fixed bug reported on public mailing list regarding marker. This actually showed an error
in reference image markersOrientB.png
  
  Revision  Changes    Path
  1.9       +24 -9     xml-batik/sources/org/apache/batik/gvt/MarkerShapePainter.java
  
  Index: MarkerShapePainter.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/MarkerShapePainter.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- MarkerShapePainter.java	9 Jul 2002 17:17:54 -0000	1.8
  +++ MarkerShapePainter.java	2 Dec 2002 13:02:39 -0000	1.9
  @@ -562,12 +562,17 @@
           if (inSlope == null) {
               return 0;
           }
  -       
  -        double rotationIn  = Math.atan2(inSlope[1], inSlope[0])*180./Math.PI;
  -        double rotationOut = Math.atan2(outSlope[1], outSlope[0])*180./Math.PI;
  -        double rotation = (rotationIn + rotationOut)/2;
  -	
  -        return rotation;
  +
  +        double dx = inSlope[0] + outSlope[0];
  +        double dy = inSlope[1] + outSlope[1];
  +
  +        if (dx == 0 && dy == 0) {
  +            // The two vectors are exact opposites. There is no way to 
  +            // know which direction to go (+90 or -90). Choose +90
  +            return Math.atan2(inSlope[1], inSlope[0])*180./Math.PI + 90;
  +        } else {
  +            return Math.atan2(dy, dx)*180./Math.PI;
  +        }
       }
   
       /**
  @@ -657,7 +662,7 @@
               return null;
           }
   
  -        return new double[] { dx, dy };
  +        return normalize(new double[] { dx, dy });
       }
   
       /**
  @@ -730,7 +735,17 @@
               return null;
           }
   
  -        return new double[] { dx, dy };
  +        return normalize(new double[] { dx, dy });
  +    }
  +
  +    /**
  +     * Normalizes the input vector. This assumes an non-zero length
  +     */
  +    public double[] normalize(double[] v) {
  +        double n = Math.sqrt(v[0]*v[0]+v[1]*v[1]);
  +        v[0] /= n;
  +        v[1] /= n;
  +        return v;
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org


Mime
View raw message