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