< prev index next >

src/java.desktop/share/classes/sun/awt/geom/AreaOp.java

Print this page


   1 /*
   2  * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 197 
 198     private Vector<Curve> pruneEdges(Vector<Edge> edges) {
 199         int numedges = edges.size();
 200         if (numedges < 2) {
 201             // empty vector is expected with less than 2 edges
 202             return new Vector<>();
 203         }
 204         Edge[] edgelist = edges.toArray(new Edge[numedges]);
 205         Arrays.sort(edgelist, YXTopComparator);
 206         if (false) {
 207             System.out.println("pruning: ");
 208             for (int i = 0; i < numedges; i++) {
 209                 System.out.println("edgelist["+i+"] = "+edgelist[i]);
 210             }
 211         }
 212         Edge e;
 213         int left = 0;
 214         int right = 0;
 215         int cur = 0;
 216         int next = 0;
 217         double yrange[] = new double[2];
 218         Vector<CurveLink> subcurves = new Vector<>();
 219         Vector<ChainEnd> chains = new Vector<>();
 220         Vector<CurveLink> links = new Vector<>();
 221         // Active edges are between left (inclusive) and right (exclusive)
 222         while (left < numedges) {
 223             double y = yrange[0];
 224             // Prune active edges that fall off the top of the active y range
 225             for (cur = next = right - 1; cur >= left; cur--) {
 226                 e = edgelist[cur];
 227                 if (e.getCurve().getYBot() > y) {
 228                     if (next > cur) {
 229                         edgelist[next] = e;
 230                     }
 231                     next--;
 232                 }
 233             }
 234             left = next + 1;
 235             // Grab a new "top of Y range" if the active edges are empty
 236             if (left >= right) {
 237                 if (right >= numedges) {


   1 /*
   2  * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 197 
 198     private Vector<Curve> pruneEdges(Vector<Edge> edges) {
 199         int numedges = edges.size();
 200         if (numedges < 2) {
 201             // empty vector is expected with less than 2 edges
 202             return new Vector<>();
 203         }
 204         Edge[] edgelist = edges.toArray(new Edge[numedges]);
 205         Arrays.sort(edgelist, YXTopComparator);
 206         if (false) {
 207             System.out.println("pruning: ");
 208             for (int i = 0; i < numedges; i++) {
 209                 System.out.println("edgelist["+i+"] = "+edgelist[i]);
 210             }
 211         }
 212         Edge e;
 213         int left = 0;
 214         int right = 0;
 215         int cur = 0;
 216         int next = 0;
 217         double[] yrange = new double[2];
 218         Vector<CurveLink> subcurves = new Vector<>();
 219         Vector<ChainEnd> chains = new Vector<>();
 220         Vector<CurveLink> links = new Vector<>();
 221         // Active edges are between left (inclusive) and right (exclusive)
 222         while (left < numedges) {
 223             double y = yrange[0];
 224             // Prune active edges that fall off the top of the active y range
 225             for (cur = next = right - 1; cur >= left; cur--) {
 226                 e = edgelist[cur];
 227                 if (e.getCurve().getYBot() > y) {
 228                     if (next > cur) {
 229                         edgelist[next] = e;
 230                     }
 231                     next--;
 232                 }
 233             }
 234             left = next + 1;
 235             // Grab a new "top of Y range" if the active edges are empty
 236             if (left >= right) {
 237                 if (right >= numedges) {


< prev index next >