1 Clazz.declarePackage ("java.awt");
2 Clazz.load (["java.awt.Shape", "java.awt.geom.Rectangle2D"], "java.awt.Rectangle", ["java.awt.Dimension", "$.Point"], function () {
3 c$ = Clazz.decorateAsClass (function () {
8 Clazz.instantialize (this, arguments);
9 }, java.awt, "Rectangle", java.awt.geom.Rectangle2D, java.awt.Shape);
10 Clazz.makeConstructor (c$,
12 this.construct (0, 0, 0, 0);
14 Clazz.makeConstructor (c$,
16 this.construct (r.x, r.y, r.width, r.height);
17 }, "java.awt.Rectangle");
18 Clazz.makeConstructor (c$,
19 function (x, y, width, height) {
20 Clazz.superConstructor (this, java.awt.Rectangle, []);
26 Clazz.makeConstructor (c$,
27 function (width, height) {
28 this.construct (0, 0, width, height);
30 Clazz.makeConstructor (c$,
32 this.construct (p.x, p.y, d.width, d.height);
33 }, "java.awt.Point,java.awt.Dimension");
34 Clazz.makeConstructor (c$,
36 this.construct (p.x, p.y, 0, 0);
38 Clazz.makeConstructor (c$,
40 this.construct (0, 0, d.width, d.height);
41 }, "java.awt.Dimension");
42 Clazz.overrideMethod (c$, "getX",
46 Clazz.overrideMethod (c$, "getY",
50 Clazz.overrideMethod (c$, "getWidth",
54 Clazz.overrideMethod (c$, "getHeight",
58 Clazz.overrideMethod (c$, "getBounds",
60 return new java.awt.Rectangle (this.x, this.y, this.width, this.height);
62 Clazz.overrideMethod (c$, "getBounds2D",
64 return new java.awt.Rectangle (this.x, this.y, this.width, this.height);
66 Clazz.defineMethod (c$, "setBounds",
68 this.reshape (r.x, r.y, r.width, r.height);
69 }, "java.awt.Rectangle");
70 Clazz.defineMethod (c$, "setBounds",
71 function (x, y, width, height) {
72 this.reshape (x, y, width, height);
74 Clazz.defineMethod (c$, "setRect",
75 function (x, y, width, height) {
80 if (x > 4.294967294E9) {
84 newx = java.awt.Rectangle.clip (x, false);
85 if (width >= 0) width += x - newx;
86 neww = java.awt.Rectangle.clip (width, width >= 0);
87 }if (y > 4.294967294E9) {
91 newy = java.awt.Rectangle.clip (y, false);
92 if (height >= 0) height += y - newy;
93 newh = java.awt.Rectangle.clip (height, height >= 0);
94 }this.reshape (newx, newy, neww, newh);
96 c$.clip = Clazz.defineMethod (c$, "clip",
97 function (v, doceil) {
98 if (v <= -2147483648) {
100 }if (v >= 2147483647) {
102 }return Clazz.doubleToInt (doceil ? Math.ceil (v) : Math.floor (v));
104 Clazz.defineMethod (c$, "reshape",
105 function (x, y, width, height) {
109 this.height = height;
111 Clazz.defineMethod (c$, "getLocation",
113 return new java.awt.Point (this.x, this.y);
115 Clazz.defineMethod (c$, "setLocation",
117 this.setLocation (p.x, p.y);
118 }, "java.awt.Point");
119 Clazz.defineMethod (c$, "setLocation",
123 Clazz.defineMethod (c$, "move",
128 Clazz.defineMethod (c$, "translate",
131 var newv = oldv + dx;
134 if (this.width >= 0) {
135 this.width += newv - -2147483648;
139 if (this.width >= 0) {
140 this.width += newv - 2147483647;
141 if (this.width < 0) this.width = 2147483647;
148 if (this.height >= 0) {
149 this.height += newv - -2147483648;
153 if (this.height >= 0) {
154 this.height += newv - 2147483647;
155 if (this.height < 0) this.height = 2147483647;
159 Clazz.defineMethod (c$, "getSize",
161 return new java.awt.Dimension (this.width, this.height);
163 Clazz.defineMethod (c$, "setSize",
165 this.setSize (d.width, d.height);
166 }, "java.awt.Dimension");
167 Clazz.defineMethod (c$, "setSize",
168 function (width, height) {
169 this.resize (width, height);
171 Clazz.defineMethod (c$, "resize",
172 function (width, height) {
174 this.height = height;
176 Clazz.defineMethod (c$, "contains",
178 return this.contains (p.x, p.y);
179 }, "java.awt.Point");
180 Clazz.defineMethod (c$, "contains",
182 return this.inside (x, y);
184 Clazz.defineMethod (c$, "contains",
186 return this.contains (r.x, r.y, r.width, r.height);
187 }, "java.awt.Rectangle");
188 Clazz.defineMethod (c$, "contains",
189 function (X, Y, W, H) {
192 if ((w | h | W | H) < 0) {
196 if (X < x || Y < y) {
201 if (w >= x || W > w) return false;
203 if (w >= x && W > w) return false;
207 if (h >= y || H > h) return false;
209 if (h >= y && H > h) return false;
212 Clazz.defineMethod (c$, "inside",
220 if (X < x || Y < y) {
224 return ((w < x || w > X) && (h < y || h > Y));
226 Clazz.defineMethod (c$, "intersects",
229 var th = this.height;
232 if (rw <= 0 || rh <= 0 || tw <= 0 || th <= 0) {
242 return ((rw < rx || rw > tx) && (rh < ry || rh > ty) && (tw < tx || tw > rx) && (th < ty || th > ry));
243 }, "java.awt.Rectangle");
244 Clazz.defineMethod (c$, "intersection",
258 if (tx1 < rx1) tx1 = rx1;
259 if (ty1 < ry1) ty1 = ry1;
260 if (tx2 > rx2) tx2 = rx2;
261 if (ty2 > ry2) ty2 = ry2;
264 if (tx2 < -2147483648) tx2 = -2147483648;
265 if (ty2 < -2147483648) ty2 = -2147483648;
266 return new java.awt.Rectangle (tx1, ty1, tx2, ty2);
267 }, "java.awt.Rectangle");
268 Clazz.defineMethod (c$, "union",
270 var tx2 = this.width;
271 var ty2 = this.height;
272 if ((tx2 | ty2) < 0) {
273 return new java.awt.Rectangle (r);
276 if ((rx2 | ry2) < 0) {
277 return new java.awt.Rectangle (this);
286 if (tx1 > rx1) tx1 = rx1;
287 if (ty1 > ry1) ty1 = ry1;
288 if (tx2 < rx2) tx2 = rx2;
289 if (ty2 < ry2) ty2 = ry2;
292 if (tx2 > 2147483647) tx2 = 2147483647;
293 if (ty2 > 2147483647) ty2 = 2147483647;
294 return new java.awt.Rectangle (tx1, ty1, tx2, ty2);
295 }, "java.awt.Rectangle");
296 Clazz.defineMethod (c$, "add",
297 function (newx, newy) {
298 if ((this.width | this.height) < 0) {
301 this.width = this.height = 0;
306 var y2 = this.height;
309 if (x1 > newx) x1 = newx;
310 if (y1 > newy) y1 = newy;
311 if (x2 < newx) x2 = newx;
312 if (y2 < newy) y2 = newy;
315 if (x2 > 2147483647) x2 = 2147483647;
316 if (y2 > 2147483647) y2 = 2147483647;
317 this.reshape (x1, y1, x2, y2);
319 Clazz.defineMethod (c$, "add",
321 this.add (pt.x, pt.y);
322 }, "java.awt.Point");
323 Clazz.defineMethod (c$, "add",
325 var tx2 = this.width;
326 var ty2 = this.height;
327 if ((tx2 | ty2) < 0) {
328 this.reshape (r.x, r.y, r.width, r.height);
331 if ((rx2 | ry2) < 0) {
341 if (tx1 > rx1) tx1 = rx1;
342 if (ty1 > ry1) ty1 = ry1;
343 if (tx2 < rx2) tx2 = rx2;
344 if (ty2 < ry2) ty2 = ry2;
347 if (tx2 > 2147483647) tx2 = 2147483647;
348 if (ty2 > 2147483647) ty2 = 2147483647;
349 this.reshape (tx1, ty1, tx2, ty2);
350 }, "java.awt.Rectangle");
351 Clazz.defineMethod (c$, "grow",
356 var y1 = this.height;
365 if (x1 < -2147483648) x1 = -2147483648;
366 if (x0 < -2147483648) x0 = -2147483648;
367 else if (x0 > 2147483647) x0 = 2147483647;
369 if (x0 < -2147483648) x0 = -2147483648;
370 else if (x0 > 2147483647) x0 = 2147483647;
372 if (x1 < -2147483648) x1 = -2147483648;
373 else if (x1 > 2147483647) x1 = 2147483647;
376 if (y1 < -2147483648) y1 = -2147483648;
377 if (y0 < -2147483648) y0 = -2147483648;
378 else if (y0 > 2147483647) y0 = 2147483647;
380 if (y0 < -2147483648) y0 = -2147483648;
381 else if (y0 > 2147483647) y0 = 2147483647;
383 if (y1 < -2147483648) y1 = -2147483648;
384 else if (y1 > 2147483647) y1 = 2147483647;
385 }this.reshape (x0, y0, x1, y1);
387 Clazz.overrideMethod (c$, "isEmpty",
389 return (this.width <= 0) || (this.height <= 0);
391 Clazz.defineMethod (c$, "outcode",
394 if (this.width <= 0) {
396 } else if (x < this.x) {
398 } else if (x > this.x + this.width) {
400 }if (this.height <= 0) {
402 } else if (y < this.y) {
404 } else if (y > this.y + this.height) {
408 Clazz.overrideMethod (c$, "createIntersection",
410 if (Clazz.instanceOf (r, java.awt.Rectangle)) {
411 return this.intersection (r);
412 }var dest = new java.awt.geom.Rectangle2D.Double ();
413 java.awt.geom.Rectangle2D.intersect (this, r, dest);
415 }, "java.awt.geom.Rectangle2D");
416 Clazz.overrideMethod (c$, "createUnion",
418 if (Clazz.instanceOf (r, java.awt.Rectangle)) {
419 return this.union (r);
420 }var dest = new java.awt.geom.Rectangle2D.Double ();
421 java.awt.geom.Rectangle2D.union (this, r, dest);
423 }, "java.awt.geom.Rectangle2D");
424 Clazz.defineMethod (c$, "equals",
426 if (Clazz.instanceOf (obj, java.awt.Rectangle)) {
428 return ((this.x == r.x) && (this.y == r.y) && (this.width == r.width) && (this.height == r.height));
429 }return Clazz.superCall (this, java.awt.Rectangle, "equals", [obj]);
431 Clazz.overrideMethod (c$, "toString",
433 return this.getClass ().getName () + "[x=" + this.x + ",y=" + this.y + ",width=" + this.width + ",height=" + this.height + "]";