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

GeneralPath precision limit too high

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 1.2.2
    • 1.2.2
    • client-libs
    • 2d
    • 1.2.2
    • sparc
    • solaris_2.6
    • Verified

    Description

      Name: mc57594 Date: 07/01/99

      The following code demonstrates a failure to give the correct
      boolean result for a point in a GeneralPath. Notice that, for me
      at least, the first scaling succeeds while the second fails. Is
      this a feature or a bug or a possibility for an enhancement?


      import java.awt.geom.*;
       
      public class test {
       
         private GeneralPath gp;
       
         public test() {
            make2GP();
         }
       
         public void make2GP() {
       
       
            double[] scale = {399.9999, 400.0};
            // success is 0.0025000006
            // failure is 0.0025
       
            for ( int i = 0; i < scale.length; i++ ) {
               gp = new GeneralPath(GeneralPath.WIND_NON_ZERO);
               
               float x1 = (float) (1.0/scale[i]);
               float y1 = (float) (1.0/scale[i]);
       
               float x2 = (float) (-1.0/scale[i]);
               float y2 = (float) (1.0/scale[i]);
       
               float x3 = (float) (-1.0/scale[i]);
               float y3 = (float) (-1.0/scale[i]);
       
               float x4 = (float) (1.0/scale[i]);
               float y4 = (float) (-1.0/scale[i]);
       
               gp.moveTo(x1, y1);
               gp.lineTo(x2, y2);
               gp.lineTo(x3, y3);
               gp.lineTo(x4, y4);
               gp.closePath();
       
               System.err.println( "\nChecking scale: " + scale[i] );
               if ( gp.contains( 0.0f, 0.0f ) )
                  System.err.println("gp contains 0.0, 0.0");
               else
                  System.err.println("gp does NOT contain 0.0, 0.0");
       
               System.err.println( gp.getBounds2D() );
            }
         }
       
         static public void main(String args[]) {
            test s = new test();
         }
      }
      (Review ID: 85105)
      ======================================================================

      Attachments

        Activity

          People

            flar Jim Graham
            mchamnessunw Mark Chamness (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: