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

Constructing Area from valid path can contain NaN values

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 6
    • 1.2.2, 5.0
    • client-libs
    • 2d
    • b81
    • generic, x86
    • generic, windows_xp

      The following test case fills a GeneralPath with some finite geometry and
      then constructs an Area from that path. The bounds of the Area object have
      NaN values which makes calculations on the geometry difficult or impossible.

      ---- Test Case ----
      import java.awt.geom.*;

      public class AreaNaN {
          public static void main(String argv[]) {
              GeneralPath gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD);
              gp.moveTo(-38.05311f, 75.25694f);
              gp.curveTo(-48.18971f, 71.23722f,
                         -46.495422f, -113.844574f,
                         124.16219f, 87.604744f);
              gp.quadTo(105.644554f, 114.52495f,
                        72.98282f, -78.52084f);
              gp.lineTo(107.358795f, 29.33548f);
              gp.quadTo(-16.562698f, -43.91586f,
                        51.50203f, 38.51295f);
              gp.lineTo(20.715876f, 44.4093f);
              gp.closePath();
              Area a = new Area(gp);
              Rectangle2D r2d = a.getBounds2D();
              if (Double.isNaN(r2d.getX()) ||
                  Double.isNaN(r2d.getY()) ||
                  Double.isNaN(r2d.getWidth()) ||
                  Double.isNaN(r2d.getHeight()))
              {
                  throw new RuntimeException("Area bounds have NaN");
              }
          }
      }

            flar Jim Graham
            flar Jim Graham
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: