1 Clazz.declarePackage ("jssun.awt.geom");
\r
2 Clazz.load (["java.util.Vector"], "jssun.awt.geom.Crossings", ["jssun.awt.geom.Curve"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
11 Clazz.instantialize (this, arguments);
\r
12 }, jssun.awt.geom, "Crossings");
\r
13 Clazz.prepareFields (c$, function () {
\r
14 this.yranges = Clazz.newDoubleArray (10, 0);
\r
15 this.tmp = new java.util.Vector ();
\r
17 Clazz.makeConstructor (c$,
\r
18 function (xlo, ylo, xhi, yhi) {
\r
24 Clazz.defineMethod (c$, "getXLo",
\r
28 Clazz.defineMethod (c$, "getYLo",
\r
32 Clazz.defineMethod (c$, "getXHi",
\r
36 Clazz.defineMethod (c$, "getYHi",
\r
40 Clazz.defineMethod (c$, "print",
\r
42 System.out.println ("Crossings [");
\r
43 System.out.println (" bounds = [" + this.ylo + ", " + this.yhi + "]");
\r
44 for (var i = 0; i < this.limit; i += 2) {
\r
45 System.out.println (" [" + this.yranges[i] + ", " + this.yranges[i + 1] + "]");
\r
47 System.out.println ("]");
\r
49 Clazz.defineMethod (c$, "isEmpty",
\r
51 return (this.limit == 0);
\r
53 c$.findCrossings = Clazz.defineMethod (c$, "findCrossings",
\r
54 function (curves, xlo, ylo, xhi, yhi) {
\r
55 var cross = new jssun.awt.geom.Crossings.EvenOdd (xlo, ylo, xhi, yhi);
\r
56 var enum_ = curves.elements ();
\r
57 while (enum_.hasMoreElements ()) {
\r
58 var c = enum_.nextElement ();
\r
59 if (c.accumulateCrossings (cross)) {
\r
63 }, "java.util.Vector,~N,~N,~N,~N");
\r
64 Clazz.defineMethod (c$, "accumulateLine",
\r
65 function (x0, y0, x1, y1) {
\r
67 return this.accumulateLine (x0, y0, x1, y1, 1);
\r
69 return this.accumulateLine (x1, y1, x0, y0, -1);
\r
71 Clazz.defineMethod (c$, "accumulateLine",
\r
72 function (x0, y0, x1, y1, direction) {
\r
73 if (this.yhi <= y0 || this.ylo >= y1) {
\r
75 }if (x0 >= this.xhi && x1 >= this.xhi) {
\r
78 return (x0 >= this.xlo || x1 >= this.xlo);
\r
85 if (y0 < this.ylo) {
\r
86 xstart = x0 + (this.ylo - y0) * dx / dy;
\r
91 }if (this.yhi < y1) {
\r
92 xend = x0 + (this.yhi - y0) * dx / dy;
\r
97 }if (xstart >= this.xhi && xend >= this.xhi) {
\r
99 }if (xstart > this.xlo || xend > this.xlo) {
\r
101 }this.record (ystart, yend, direction);
\r
103 }, "~N,~N,~N,~N,~N");
\r
104 Clazz.defineMethod (c$, "accumulateQuad",
\r
105 function (x0, y0, coords) {
\r
106 if (y0 < this.ylo && coords[1] < this.ylo && coords[3] < this.ylo) {
\r
108 }if (y0 > this.yhi && coords[1] > this.yhi && coords[3] > this.yhi) {
\r
110 }if (x0 > this.xhi && coords[0] > this.xhi && coords[2] > this.xhi) {
\r
112 }if (x0 < this.xlo && coords[0] < this.xlo && coords[2] < this.xlo) {
\r
113 if (y0 < coords[3]) {
\r
114 this.record (Math.max (y0, this.ylo), Math.min (coords[3], this.yhi), 1);
\r
115 } else if (y0 > coords[3]) {
\r
116 this.record (Math.max (coords[3], this.ylo), Math.min (y0, this.yhi), -1);
\r
118 }jssun.awt.geom.Curve.insertQuad (this.tmp, x0, y0, coords);
\r
119 var enum_ = this.tmp.elements ();
\r
120 while (enum_.hasMoreElements ()) {
\r
121 var c = enum_.nextElement ();
\r
122 if (c.accumulateCrossings (this)) {
\r
128 Clazz.defineMethod (c$, "accumulateCubic",
\r
129 function (x0, y0, coords) {
\r
130 if (y0 < this.ylo && coords[1] < this.ylo && coords[3] < this.ylo && coords[5] < this.ylo) {
\r
132 }if (y0 > this.yhi && coords[1] > this.yhi && coords[3] > this.yhi && coords[5] > this.yhi) {
\r
134 }if (x0 > this.xhi && coords[0] > this.xhi && coords[2] > this.xhi && coords[4] > this.xhi) {
\r
136 }if (x0 < this.xlo && coords[0] < this.xlo && coords[2] < this.xlo && coords[4] < this.xlo) {
\r
137 if (y0 <= coords[5]) {
\r
138 this.record (Math.max (y0, this.ylo), Math.min (coords[5], this.yhi), 1);
\r
140 this.record (Math.max (coords[5], this.ylo), Math.min (y0, this.yhi), -1);
\r
142 }jssun.awt.geom.Curve.insertCubic (this.tmp, x0, y0, coords);
\r
143 var enum_ = this.tmp.elements ();
\r
144 while (enum_.hasMoreElements ()) {
\r
145 var c = enum_.nextElement ();
\r
146 if (c.accumulateCrossings (this)) {
\r
152 Clazz.pu$h(self.c$);
\r
153 c$ = Clazz.declareType (jssun.awt.geom.Crossings, "EvenOdd", jssun.awt.geom.Crossings);
\r
154 Clazz.overrideMethod (c$, "covers",
\r
156 return (this.limit == 2 && this.yranges[0] <= a && this.yranges[1] >= b);
\r
158 Clazz.overrideMethod (c$, "record",
\r
159 function (a, b, c) {
\r
163 while (d < this.limit && a > this.yranges[d + 1]) {
\r
167 while (d < this.limit) {
\r
168 var f = this.yranges[d++];
\r
169 var g = this.yranges[d++];
\r
171 this.yranges[e++] = a;
\r
172 this.yranges[e++] = b;
\r
201 this.yranges[e++] = h;
\r
202 this.yranges[e++] = i;
\r
208 if (e < d && d < this.limit) {
\r
209 System.arraycopy (this.yranges, d, this.yranges, e, this.limit - d);
\r
210 }e += (this.limit - d);
\r
212 if (e >= this.yranges.length) {
\r
213 var f = Clazz.newDoubleArray (e + 10, 0);
\r
214 System.arraycopy (this.yranges, 0, f, 0, e);
\r
216 }this.yranges[e++] = a;
\r
217 this.yranges[e++] = b;
\r
221 Clazz.pu$h(self.c$);
\r
222 c$ = Clazz.decorateAsClass (function () {
\r
223 this.crosscounts = null;
\r
224 Clazz.instantialize (this, arguments);
\r
225 }, jssun.awt.geom.Crossings, "NonZero", jssun.awt.geom.Crossings);
\r
226 Clazz.makeConstructor (c$,
\r
227 function (a, b, c, d) {
\r
228 Clazz.superConstructor (this, jssun.awt.geom.Crossings.NonZero, [a, b, c, d]);
\r
229 this.crosscounts = Clazz.newIntArray (Clazz.doubleToInt (this.yranges.length / 2), 0);
\r
231 Clazz.overrideMethod (c$, "covers",
\r
234 while (c < this.limit) {
\r
235 var d = this.yranges[c++];
\r
236 var e = this.yranges[c++];
\r
247 Clazz.defineMethod (c$, "remove",
\r
250 var b = this.limit - a;
\r
252 System.arraycopy (this.yranges, a + 2, this.yranges, a, b);
\r
253 System.arraycopy (this.crosscounts, Clazz.doubleToInt (a / 2) + 1, this.crosscounts, Clazz.doubleToInt (a / 2), Clazz.doubleToInt (b / 2));
\r
255 Clazz.defineMethod (c$, "insert",
\r
256 function (a, b, c, d) {
\r
257 var e = this.limit - a;
\r
258 var f = this.yranges;
\r
259 var g = this.crosscounts;
\r
260 if (this.limit >= this.yranges.length) {
\r
261 this.yranges = Clazz.newDoubleArray (this.limit + 10, 0);
\r
262 System.arraycopy (f, 0, this.yranges, 0, a);
\r
263 this.crosscounts = Clazz.newIntArray (Clazz.doubleToInt ((this.limit + 10) / 2), 0);
\r
264 System.arraycopy (g, 0, this.crosscounts, 0, Clazz.doubleToInt (a / 2));
\r
266 System.arraycopy (f, a, this.yranges, a + 2, e);
\r
267 System.arraycopy (g, Clazz.doubleToInt (a / 2), this.crosscounts, Clazz.doubleToInt (a / 2) + 1, Clazz.doubleToInt (e / 2));
\r
268 }this.yranges[a + 0] = b;
\r
269 this.yranges[a + 1] = c;
\r
270 this.crosscounts[Clazz.doubleToInt (a / 2)] = d;
\r
273 Clazz.overrideMethod (c$, "record",
\r
274 function (a, b, c) {
\r
278 while (d < this.limit && a > this.yranges[d + 1]) {
\r
281 if (d < this.limit) {
\r
282 var e = this.crosscounts[Clazz.doubleToInt (d / 2)];
\r
283 var f = this.yranges[d + 0];
\r
284 var g = this.yranges[d + 1];
\r
285 if (g == a && e == c) {
\r
286 if (d + 2 == this.limit) {
\r
287 this.yranges[d + 1] = b;
\r
291 e = this.crosscounts[Clazz.doubleToInt (d / 2)];
\r
292 f = this.yranges[d + 0];
\r
293 g = this.yranges[d + 1];
\r
295 this.insert (d, a, b, c);
\r
297 }if (b == f && e == c) {
\r
298 this.yranges[d] = a;
\r
301 this.insert (d, a, f, c);
\r
304 } else if (f < a) {
\r
305 this.insert (d, f, a, e);
\r
309 var i = Math.min (b, g);
\r
313 this.crosscounts[Clazz.doubleToInt (d / 2)] = h;
\r
314 this.yranges[d++] = a;
\r
315 this.yranges[d++] = i;
\r
318 this.insert (d, f, g, e);
\r
320 this.insert (d, a, b, c);
\r