1 Clazz.declarePackage ("jssun.awt.geom");
\r
2 Clazz.load (["jssun.awt.geom.Curve"], "jssun.awt.geom.Order2", null, function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
18 Clazz.instantialize (this, arguments);
\r
19 }, jssun.awt.geom, "Order2", jssun.awt.geom.Curve);
\r
20 c$.insert = Clazz.defineMethod (c$, "insert",
\r
21 function (curves, tmp, x0, y0, cx0, cy0, x1, y1, direction) {
\r
22 var numparams = jssun.awt.geom.Order2.getHorizontalParams (y0, cy0, y1, tmp);
\r
23 if (numparams == 0) {
\r
24 jssun.awt.geom.Order2.addInstance (curves, x0, y0, cx0, cy0, x1, y1, direction);
\r
33 jssun.awt.geom.Order2.split (tmp, 0, t);
\r
34 var i0 = (direction == 1) ? 0 : 4;
\r
36 jssun.awt.geom.Order2.addInstance (curves, tmp[i0], tmp[i0 + 1], tmp[i0 + 2], tmp[i0 + 3], tmp[i0 + 4], tmp[i0 + 5], direction);
\r
37 jssun.awt.geom.Order2.addInstance (curves, tmp[i1], tmp[i1 + 1], tmp[i1 + 2], tmp[i1 + 3], tmp[i1 + 4], tmp[i1 + 5], direction);
\r
38 }, "java.util.Vector,~A,~N,~N,~N,~N,~N,~N,~N");
\r
39 c$.addInstance = Clazz.defineMethod (c$, "addInstance",
\r
40 function (curves, x0, y0, cx0, cy0, x1, y1, direction) {
\r
42 curves.add ( new jssun.awt.geom.Order2 (x1, y1, cx0, cy0, x0, y0, -direction));
\r
43 } else if (y1 > y0) {
\r
44 curves.add ( new jssun.awt.geom.Order2 (x0, y0, cx0, cy0, x1, y1, direction));
\r
45 }}, "java.util.Vector,~N,~N,~N,~N,~N,~N,~N");
\r
46 c$.getHorizontalParams = Clazz.defineMethod (c$, "getHorizontalParams",
\r
47 function (c0, cp, c1, ret) {
\r
48 if (c0 <= cp && cp <= c1) {
\r
52 var denom = c0 + c1;
\r
55 }var t = c0 / denom;
\r
56 if (t <= 0 || t >= 1) {
\r
61 c$.split = Clazz.defineMethod (c$, "split",
\r
62 function (coords, pos, t) {
\r
69 coords[pos + 8] = x1 = coords[pos + 4];
\r
70 coords[pos + 9] = y1 = coords[pos + 5];
\r
71 cx = coords[pos + 2];
\r
72 cy = coords[pos + 3];
\r
73 x1 = cx + (x1 - cx) * t;
\r
74 y1 = cy + (y1 - cy) * t;
\r
75 x0 = coords[pos + 0];
\r
76 y0 = coords[pos + 1];
\r
77 x0 = x0 + (cx - x0) * t;
\r
78 y0 = y0 + (cy - y0) * t;
\r
79 cx = x0 + (x1 - x0) * t;
\r
80 cy = y0 + (y1 - y0) * t;
\r
81 coords[pos + 2] = x0;
\r
82 coords[pos + 3] = y0;
\r
83 coords[pos + 4] = cx;
\r
84 coords[pos + 5] = cy;
\r
85 coords[pos + 6] = x1;
\r
86 coords[pos + 7] = y1;
\r
88 Clazz.makeConstructor (c$,
\r
89 function (x0, y0, cx0, cy0, x1, y1, direction) {
\r
90 Clazz.superConstructor (this, jssun.awt.geom.Order2, [direction]);
\r
93 } else if (cy0 > y1) {
\r
101 this.xmin = Math.min (Math.min (x0, x1), cx0);
\r
102 this.xmax = Math.max (Math.max (x0, x1), cx0);
\r
104 this.xcoeff1 = cx0 + cx0 - x0 - x0;
\r
105 this.xcoeff2 = x0 - cx0 - cx0 + x1;
\r
107 this.ycoeff1 = cy0 + cy0 - y0 - y0;
\r
108 this.ycoeff2 = y0 - cy0 - cy0 + y1;
\r
109 }, "~N,~N,~N,~N,~N,~N,~N");
\r
110 Clazz.overrideMethod (c$, "getOrder",
\r
114 Clazz.overrideMethod (c$, "getXTop",
\r
118 Clazz.overrideMethod (c$, "getYTop",
\r
122 Clazz.overrideMethod (c$, "getXBot",
\r
126 Clazz.overrideMethod (c$, "getYBot",
\r
130 Clazz.overrideMethod (c$, "getXMin",
\r
134 Clazz.overrideMethod (c$, "getXMax",
\r
138 Clazz.overrideMethod (c$, "getX0",
\r
140 return (this.direction == 1) ? this.x0 : this.x1;
\r
142 Clazz.overrideMethod (c$, "getY0",
\r
144 return (this.direction == 1) ? this.y0 : this.y1;
\r
146 Clazz.defineMethod (c$, "getCX0",
\r
150 Clazz.defineMethod (c$, "getCY0",
\r
154 Clazz.overrideMethod (c$, "getX1",
\r
156 return (this.direction == -1) ? this.x0 : this.x1;
\r
158 Clazz.overrideMethod (c$, "getY1",
\r
160 return (this.direction == -1) ? this.y0 : this.y1;
\r
162 Clazz.overrideMethod (c$, "XforY",
\r
164 if (y <= this.y0) {
\r
166 }if (y >= this.y1) {
\r
168 }return this.XforT (this.TforY (y));
\r
170 Clazz.defineMethod (c$, "TforY",
\r
172 if (y <= this.y0) {
\r
174 }if (y >= this.y1) {
\r
176 }return jssun.awt.geom.Order2.TforY (y, this.ycoeff0, this.ycoeff1, this.ycoeff2);
\r
178 c$.TforY = Clazz.defineMethod (c$, "TforY",
\r
179 function (y, ycoeff0, ycoeff1, ycoeff2) {
\r
181 if (ycoeff2 == 0.0) {
\r
182 var root = -ycoeff0 / ycoeff1;
\r
183 if (root >= 0 && root <= 1) {
\r
186 var d = ycoeff1 * ycoeff1 - 4.0 * ycoeff2 * ycoeff0;
\r
189 if (ycoeff1 < 0.0) {
\r
191 }var q = (ycoeff1 + d) / -2.0;
\r
192 var root = q / ycoeff2;
\r
193 if (root >= 0 && root <= 1) {
\r
196 root = ycoeff0 / q;
\r
197 if (root >= 0 && root <= 1) {
\r
199 }}}}var y0 = ycoeff0;
\r
200 var y1 = ycoeff0 + ycoeff1 + ycoeff2;
\r
201 return (0 < (y0 + y1) / 2) ? 0.0 : 1.0;
\r
203 Clazz.overrideMethod (c$, "XforT",
\r
205 return (this.xcoeff2 * t + this.xcoeff1) * t + this.xcoeff0;
\r
207 Clazz.overrideMethod (c$, "YforT",
\r
209 return (this.ycoeff2 * t + this.ycoeff1) * t + this.ycoeff0;
\r
211 Clazz.overrideMethod (c$, "dXforT",
\r
212 function (t, deriv) {
\r
215 return (this.xcoeff2 * t + this.xcoeff1) * t + this.xcoeff0;
\r
217 return 2 * this.xcoeff2 * t + this.xcoeff1;
\r
219 return 2 * this.xcoeff2;
\r
224 Clazz.overrideMethod (c$, "dYforT",
\r
225 function (t, deriv) {
\r
228 return (this.ycoeff2 * t + this.ycoeff1) * t + this.ycoeff0;
\r
230 return 2 * this.ycoeff2 * t + this.ycoeff1;
\r
232 return 2 * this.ycoeff2;
\r
237 Clazz.overrideMethod (c$, "nextVertical",
\r
238 function (t0, t1) {
\r
239 var t = -this.xcoeff1 / (2 * this.xcoeff2);
\r
240 if (t > t0 && t < t1) {
\r
244 Clazz.overrideMethod (c$, "enlarge",
\r
246 r.add (this.x0, this.y0);
\r
247 var t = -this.xcoeff1 / (2 * this.xcoeff2);
\r
248 if (t > 0 && t < 1) {
\r
249 r.add (this.XforT (t), this.YforT (t));
\r
250 }r.add (this.x1, this.y1);
\r
251 }, "java.awt.geom.Rectangle2D");
\r
252 Clazz.defineMethod (c$, "getSubCurve",
\r
253 function (ystart, yend, dir) {
\r
256 if (ystart <= this.y0) {
\r
257 if (yend >= this.y1) {
\r
258 return this.getWithDirection (dir);
\r
261 t0 = jssun.awt.geom.Order2.TforY (ystart, this.ycoeff0, this.ycoeff1, this.ycoeff2);
\r
262 }if (yend >= this.y1) {
\r
265 t1 = jssun.awt.geom.Order2.TforY (yend, this.ycoeff0, this.ycoeff1, this.ycoeff2);
\r
266 }var eqn = Clazz.newDoubleArray (10, 0);
\r
274 jssun.awt.geom.Order2.split (eqn, 0, t1);
\r
279 jssun.awt.geom.Order2.split (eqn, 0, t0 / t1);
\r
281 }return new jssun.awt.geom.Order2 (eqn[i + 0], ystart, eqn[i + 2], eqn[i + 3], eqn[i + 4], yend, dir);
\r
283 Clazz.overrideMethod (c$, "getReversedCurve",
\r
285 return new jssun.awt.geom.Order2 (this.x0, this.y0, this.cx0, this.cy0, this.x1, this.y1, -this.direction);
\r
287 Clazz.overrideMethod (c$, "getSegment",
\r
288 function (coords) {
\r
289 coords[0] = this.cx0;
\r
290 coords[1] = this.cy0;
\r
291 if (this.direction == 1) {
\r
292 coords[2] = this.x1;
\r
293 coords[3] = this.y1;
\r
295 coords[2] = this.x0;
\r
296 coords[3] = this.y0;
\r
299 Clazz.overrideMethod (c$, "controlPointString",
\r
301 return ("(" + jssun.awt.geom.Curve.round (this.cx0) + ", " + jssun.awt.geom.Curve.round (this.cy0) + "), ");
\r