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