Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4558900

Pathiterator is inconsistent between GeneralPath and Area objects

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P4
    • None
    • 1.4.0
    • client-libs
    • 2d
    • sparc
    • solaris_2.6

    Description

      Name: jk109818 Date: 12/07/2001


      java version "1.2.1"
      Solaris VM (build Solaris_JDK_1.2.2_05,native threads,subwjit)

      Querying the pathiterator returns two different set of coordinates for the same
      geometry.

      Run this example:

      import java.io.*;
      import java.util.*;
      import java.awt.geom.GeneralPath;
      import java.awt.geom.*;
      import java.awt.*;

      import java.lang.Math;

      public class tempShape {


       public static void getPoints(PathIterator pi){
        double [] coords = new double[6];
        int curseg;
        Point2D.Double p;
        while (!pi.isDone()){
          curseg = pi.currentSegment(coords);
          switch(curseg){
            case PathIterator.SEG_MOVETO:{
               p = new Point2D.Double(coords[0],coords[1]);
      System.out.println("MOVE TO:"+p.x+" "+p.y);
                break;
            }
            case PathIterator.SEG_LINETO:{
               p = new Point2D.Double(coords[0],coords[1]);
      System.out.println("LINE TO:"+p.x+" "+p.y);
                break;
            }
            case PathIterator.SEG_CLOSE:{
      System.out.println("CLOSE");
                 break;
            }
            default:{
              System.out.println("Undefined Seg type");
              break;
            }
          }
          pi.next();
        }
       }
       public static void main(String args[]){
          GeneralPath gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD);
          gp.moveTo(40705662f, 104785693f);
          gp.lineTo(40705878f, 104785687f);
          gp.lineTo(40705845f, 104785332f);
          gp.lineTo(40705799f,104784340f);
          gp.lineTo(40706901f, 104784342f);
          gp.lineTo(40706896f, 104785325f);
          gp.lineTo(40706900f, 104785409f);
          gp.lineTo(40706878f, 104785483f);
          gp.lineTo(40706813f, 104785578f);
          gp.lineTo(40706776f, 104785621f);
          gp.lineTo(40706720f, 104785684f);
          gp.lineTo(40705846f, 104785691f);
          gp.lineTo(40705662f, 104785693f);
          gp.closePath();
          Area a = new Area(gp);
          System.out.println("****POINTS FROM GENERALPATH OBJECT****");
          getPoints(gp.getPathIterator(null));
          System.out.println("****POINTS FROM AREA OBJECT****");
          getPoints(a.getPathIterator(null));
       }
      }



      The results from gp.getPathIterator and a.getPathIterator should be the same.
      But they are not.

      Results returned:

      ****POINTS FROM GENERALPATH OBJECT****
      MOVE TO:4.0705664E7 1.04785696E8
      LINE TO:4.070588E7 1.04785688E8
      LINE TO:4.0705844E7 1.04785328E8
      LINE TO:4.07058E7 1.04784336E8
      LINE TO:4.07069E7 1.04784344E8
      LINE TO:4.0706896E7 1.04785328E8
      LINE TO:4.07069E7 1.04785408E8
      LINE TO:4.070688E7 1.0478548E8
      LINE TO:4.0706812E7 1.04785576E8
      LINE TO:4.0706776E7 1.04785624E8
      LINE TO:4.070672E7 1.0478568E8
      LINE TO:4.0705848E7 1.04785688E8
      LINE TO:4.0705664E7 1.04785696E8
      CLOSE
      ****POINTS FROM AREA OBJECT****
      MOVE TO:4.07058E7 1.04784336E8
      LINE TO:4.0705844E7 1.04785328E8
      LINE TO:4.070587997066911E7 1.0478568770669112E8
      LINE TO:4.0705879970668346E7 1.0478568770669112E8
      LINE TO:4.070672E7 1.0478568E8
      LINE TO:4.0706776E7 1.04785624E8
      LINE TO:4.0706812E7 1.04785576E8
      LINE TO:4.070688E7 1.0478548E8
      LINE TO:4.07069E7 1.04785408E8
      LINE TO:4.0706896E7 1.04785328E8
      LINE TO:4.07069E7 1.04784344E8
      LINE TO:4.07058E7 1.04784336E8
      CLOSE
      MOVE TO:4.0705879970668346E7 1.0478568770669112E8
      LINE TO:4.0705848E7 1.04785688E8
      LINE TO:4.0705664E7 1.04785696E8
      LINE TO:4.070588E7 1.04785688E8
      LINE TO:4.070587997066911E7 1.0478568770669112E8
      CLOSE

      The same problem was duplicated on java version 1.3.1-b24 on NT. The second path
       (5 points) returned from the Area object is inaccuarate and extraneous.
      (Review ID: 136975)
      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              flar Jim Graham
              jkimsunw Jeffrey Kim (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: