src/share/classes/sun/awt/geom/Crossings.java

Print this page




 295             }
 296             return false;
 297         }
 298         Curve.insertCubic(tmp, x0, y0, coords);
 299         Enumeration<Curve> enum_ = tmp.elements();
 300         while (enum_.hasMoreElements()) {
 301             Curve c = enum_.nextElement();
 302             if (c.accumulateCrossings(this)) {
 303                 return true;
 304             }
 305         }
 306         tmp.clear();
 307         return false;
 308     }
 309 
 310     public final static class EvenOdd extends Crossings {
 311         public EvenOdd(double xlo, double ylo, double xhi, double yhi) {
 312             super(xlo, ylo, xhi, yhi);
 313         }
 314 
 315         public final boolean covers(double ystart, double yend) {
 316             return (limit == 2 && yranges[0] <= ystart && yranges[1] >= yend);
 317         }
 318 
 319         public void record(double ystart, double yend, int direction) {
 320             if (ystart >= yend) {
 321                 return;
 322             }
 323             int from = 0;
 324             // Quickly jump over all pairs that are completely "above"
 325             while (from < limit && ystart > yranges[from+1]) {
 326                 from += 2;
 327             }
 328             int to = from;
 329             while (from < limit) {
 330                 double yrlo = yranges[from++];
 331                 double yrhi = yranges[from++];
 332                 if (yend < yrlo) {
 333                     // Quickly handle insertion of the new range
 334                     yranges[to++] = ystart;
 335                     yranges[to++] = yend;


 381                 if (to >= yranges.length) {
 382                     double newranges[] = new double[to+10];
 383                     System.arraycopy(yranges, 0, newranges, 0, to);
 384                     yranges = newranges;
 385                 }
 386                 yranges[to++] = ystart;
 387                 yranges[to++] = yend;
 388             }
 389             limit = to;
 390         }
 391     }
 392 
 393     public final static class NonZero extends Crossings {
 394         private int crosscounts[];
 395 
 396         public NonZero(double xlo, double ylo, double xhi, double yhi) {
 397             super(xlo, ylo, xhi, yhi);
 398             crosscounts = new int[yranges.length / 2];
 399         }
 400 
 401         public final boolean covers(double ystart, double yend) {
 402             int i = 0;
 403             while (i < limit) {
 404                 double ylo = yranges[i++];
 405                 double yhi = yranges[i++];
 406                 if (ystart >= yhi) {
 407                     continue;
 408                 }
 409                 if (ystart < ylo) {
 410                     return false;
 411                 }
 412                 if (yend <= yhi) {
 413                     return true;
 414                 }
 415                 ystart = yhi;
 416             }
 417             return (ystart >= yend);
 418         }
 419 
 420         public void remove(int cur) {
 421             limit -= 2;




 295             }
 296             return false;
 297         }
 298         Curve.insertCubic(tmp, x0, y0, coords);
 299         Enumeration<Curve> enum_ = tmp.elements();
 300         while (enum_.hasMoreElements()) {
 301             Curve c = enum_.nextElement();
 302             if (c.accumulateCrossings(this)) {
 303                 return true;
 304             }
 305         }
 306         tmp.clear();
 307         return false;
 308     }
 309 
 310     public final static class EvenOdd extends Crossings {
 311         public EvenOdd(double xlo, double ylo, double xhi, double yhi) {
 312             super(xlo, ylo, xhi, yhi);
 313         }
 314 
 315         public boolean covers(double ystart, double yend) {
 316             return (limit == 2 && yranges[0] <= ystart && yranges[1] >= yend);
 317         }
 318 
 319         public void record(double ystart, double yend, int direction) {
 320             if (ystart >= yend) {
 321                 return;
 322             }
 323             int from = 0;
 324             // Quickly jump over all pairs that are completely "above"
 325             while (from < limit && ystart > yranges[from+1]) {
 326                 from += 2;
 327             }
 328             int to = from;
 329             while (from < limit) {
 330                 double yrlo = yranges[from++];
 331                 double yrhi = yranges[from++];
 332                 if (yend < yrlo) {
 333                     // Quickly handle insertion of the new range
 334                     yranges[to++] = ystart;
 335                     yranges[to++] = yend;


 381                 if (to >= yranges.length) {
 382                     double newranges[] = new double[to+10];
 383                     System.arraycopy(yranges, 0, newranges, 0, to);
 384                     yranges = newranges;
 385                 }
 386                 yranges[to++] = ystart;
 387                 yranges[to++] = yend;
 388             }
 389             limit = to;
 390         }
 391     }
 392 
 393     public final static class NonZero extends Crossings {
 394         private int crosscounts[];
 395 
 396         public NonZero(double xlo, double ylo, double xhi, double yhi) {
 397             super(xlo, ylo, xhi, yhi);
 398             crosscounts = new int[yranges.length / 2];
 399         }
 400 
 401         public boolean covers(double ystart, double yend) {
 402             int i = 0;
 403             while (i < limit) {
 404                 double ylo = yranges[i++];
 405                 double yhi = yranges[i++];
 406                 if (ystart >= yhi) {
 407                     continue;
 408                 }
 409                 if (ystart < ylo) {
 410                     return false;
 411                 }
 412                 if (yend <= yhi) {
 413                     return true;
 414                 }
 415                 ystart = yhi;
 416             }
 417             return (ystart >= yend);
 418         }
 419 
 420         public void remove(int cur) {
 421             limit -= 2;