1 Clazz.declarePackage ("java.awt.geom");
2 Clazz.load (["java.awt.geom.RectangularShape"], "java.awt.geom.Rectangle2D", ["java.lang.Double", "java.awt.geom.RectIterator"], function () {
3 c$ = Clazz.declareType (java.awt.geom, "Rectangle2D", java.awt.geom.RectangularShape);
4 Clazz.makeConstructor (c$,
6 Clazz.superConstructor (this, java.awt.geom.Rectangle2D, []);
8 Clazz.defineMethod (c$, "setRect",
10 this.setRect (r.getX (), r.getY (), r.getWidth (), r.getHeight ());
11 }, "java.awt.geom.Rectangle2D");
12 Clazz.defineMethod (c$, "intersectsLine",
13 function (x1, y1, x2, y2) {
16 if ((out2 = this.outcode (x2, y2)) == 0) {
18 }while ((out1 = this.outcode (x1, y1)) != 0) {
19 if ((out1 & out2) != 0) {
21 }if ((out1 & (5)) != 0) {
23 if ((out1 & 4) != 0) {
24 x += this.getWidth ();
25 }y1 = y1 + (x - x1) * (y2 - y1) / (x2 - x1);
29 if ((out1 & 8) != 0) {
30 y += this.getHeight ();
31 }x1 = x1 + (y - y1) * (x2 - x1) / (y2 - y1);
36 Clazz.defineMethod (c$, "intersectsLine",
38 return this.intersectsLine (l.getX1 (), l.getY1 (), l.getX2 (), l.getY2 ());
39 }, "java.awt.geom.Line2D");
40 Clazz.defineMethod (c$, "outcode",
42 return this.outcode (p.getX (), p.getY ());
43 }, "java.awt.geom.Point2D");
44 Clazz.defineMethod (c$, "setFrame",
45 function (x, y, w, h) {
46 this.setRect (x, y, w, h);
48 Clazz.overrideMethod (c$, "getBounds2D",
52 Clazz.defineMethod (c$, "contains",
54 var x0 = this.getX ();
55 var y0 = this.getY ();
56 return (x >= x0 && y >= y0 && x < x0 + this.getWidth () && y < y0 + this.getHeight ());
58 Clazz.defineMethod (c$, "intersects",
59 function (x, y, w, h) {
60 if (this.isEmpty () || w <= 0 || h <= 0) {
62 }var x0 = this.getX ();
63 var y0 = this.getY ();
64 return (x + w > x0 && y + h > y0 && x < x0 + this.getWidth () && y < y0 + this.getHeight ());
66 Clazz.defineMethod (c$, "contains",
67 function (x, y, w, h) {
68 if (this.isEmpty () || w <= 0 || h <= 0) {
70 }var x0 = this.getX ();
71 var y0 = this.getY ();
72 return (x >= x0 && y >= y0 && (x + w) <= x0 + this.getWidth () && (y + h) <= y0 + this.getHeight ());
74 c$.intersect = Clazz.defineMethod (c$, "intersect",
75 function (src1, src2, dest) {
76 var x1 = Math.max (src1.getMinX (), src2.getMinX ());
77 var y1 = Math.max (src1.getMinY (), src2.getMinY ());
78 var x2 = Math.min (src1.getMaxX (), src2.getMaxX ());
79 var y2 = Math.min (src1.getMaxY (), src2.getMaxY ());
80 dest.setFrame (x1, y1, x2 - x1, y2 - y1);
81 }, "java.awt.geom.Rectangle2D,java.awt.geom.Rectangle2D,java.awt.geom.Rectangle2D");
82 c$.union = Clazz.defineMethod (c$, "union",
83 function (src1, src2, dest) {
84 var x1 = Math.min (src1.getMinX (), src2.getMinX ());
85 var y1 = Math.min (src1.getMinY (), src2.getMinY ());
86 var x2 = Math.max (src1.getMaxX (), src2.getMaxX ());
87 var y2 = Math.max (src1.getMaxY (), src2.getMaxY ());
88 dest.setFrameFromDiagonal (x1, y1, x2, y2);
89 }, "java.awt.geom.Rectangle2D,java.awt.geom.Rectangle2D,java.awt.geom.Rectangle2D");
90 Clazz.defineMethod (c$, "add",
91 function (newx, newy) {
92 var x1 = Math.min (this.getMinX (), newx);
93 var x2 = Math.max (this.getMaxX (), newx);
94 var y1 = Math.min (this.getMinY (), newy);
95 var y2 = Math.max (this.getMaxY (), newy);
96 this.setRect (x1, y1, x2 - x1, y2 - y1);
98 Clazz.defineMethod (c$, "add",
100 this.add (pt.getX (), pt.getY ());
101 }, "java.awt.geom.Point2D");
102 Clazz.defineMethod (c$, "add",
104 var x1 = Math.min (this.getMinX (), r.getMinX ());
105 var x2 = Math.max (this.getMaxX (), r.getMaxX ());
106 var y1 = Math.min (this.getMinY (), r.getMinY ());
107 var y2 = Math.max (this.getMaxY (), r.getMaxY ());
108 this.setRect (x1, y1, x2 - x1, y2 - y1);
109 }, "java.awt.geom.Rectangle2D");
110 Clazz.defineMethod (c$, "getPathIterator",
112 return new java.awt.geom.RectIterator (this, at);
113 }, "java.awt.geom.AffineTransform");
114 Clazz.defineMethod (c$, "getPathIterator",
115 function (at, flatness) {
116 return new java.awt.geom.RectIterator (this, at);
117 }, "java.awt.geom.AffineTransform,~N");
118 Clazz.overrideMethod (c$, "hashCode",
120 var bits = java.lang.Double.doubleToLongBits (this.getX ());
121 bits += java.lang.Double.doubleToLongBits (this.getY ()) * 37;
122 bits += java.lang.Double.doubleToLongBits (this.getWidth ()) * 43;
123 bits += java.lang.Double.doubleToLongBits (this.getHeight ()) * 47;
124 return ((bits) ^ ((bits >> 32)));
126 Clazz.overrideMethod (c$, "equals",
130 }if (Clazz.instanceOf (obj, java.awt.geom.Rectangle2D)) {
132 return ((this.getX () == r2d.getX ()) && (this.getY () == r2d.getY ()) && (this.getWidth () == r2d.getWidth ()) && (this.getHeight () == r2d.getHeight ()));
136 c$ = Clazz.decorateAsClass (function () {
141 Clazz.instantialize (this, arguments);
142 }, java.awt.geom.Rectangle2D, "Float", java.awt.geom.Rectangle2D);
143 Clazz.makeConstructor (c$,
144 function (a, b, c, d) {
145 Clazz.superConstructor (this, java.awt.geom.Rectangle2D.Float, []);
147 if (arguments.length == 0)
149 }this.setRect (a, b, c, d);
151 Clazz.defineMethod (c$, "getX",
155 Clazz.defineMethod (c$, "getY",
159 Clazz.defineMethod (c$, "getWidth",
163 Clazz.defineMethod (c$, "getHeight",
167 Clazz.overrideMethod (c$, "isEmpty",
169 return (this.width <= 0.0) || (this.height <= 0.0);
171 Clazz.defineMethod (c$, "setRect",
172 function (a, b, c, d) {
178 Clazz.defineMethod (c$, "setRect",
179 function (a, b, c, d) {
185 Clazz.defineMethod (c$, "setRect",
189 this.width = a.getWidth ();
190 this.height = a.getHeight ();
191 }, "java.awt.geom.Rectangle2D");
192 Clazz.defineMethod (c$, "outcode",
195 if (this.width <= 0) {
197 } else if (a < this.x) {
199 } else if (a > this.x + this.width) {
201 }if (this.height <= 0) {
203 } else if (b < this.y) {
205 } else if (b > this.y + this.height) {
209 Clazz.overrideMethod (c$, "getBounds2D",
211 return new java.awt.geom.Rectangle2D.Float (this.x, this.y, this.width, this.height);
213 Clazz.overrideMethod (c$, "createIntersection",
216 if (Clazz.instanceOf (a, java.awt.geom.Rectangle2D.Float)) {
217 b = new java.awt.geom.Rectangle2D.Float ();
219 b = new java.awt.geom.Rectangle2D.Double ();
220 }java.awt.geom.Rectangle2D.intersect (this, a, b);
222 }, "java.awt.geom.Rectangle2D");
223 Clazz.overrideMethod (c$, "createUnion",
226 if (Clazz.instanceOf (a, java.awt.geom.Rectangle2D.Float)) {
227 b = new java.awt.geom.Rectangle2D.Float ();
229 b = new java.awt.geom.Rectangle2D.Double ();
230 }java.awt.geom.Rectangle2D.union (this, a, b);
232 }, "java.awt.geom.Rectangle2D");
233 Clazz.overrideMethod (c$, "toString",
235 return this.getClass ().getName () + "[x=" + this.x + ",y=" + this.y + ",w=" + this.width + ",h=" + this.height + "]";
239 c$ = Clazz.decorateAsClass (function () {
244 Clazz.instantialize (this, arguments);
245 }, java.awt.geom.Rectangle2D, "Double", java.awt.geom.Rectangle2D);
246 Clazz.makeConstructor (c$,
248 Clazz.superConstructor (this, java.awt.geom.Rectangle2D.Double, []);
250 Clazz.makeConstructor (c$,
251 function (a, b, c, d) {
252 Clazz.superConstructor (this, java.awt.geom.Rectangle2D.Double, []);
253 this.setRect (a, b, c, d);
255 Clazz.defineMethod (c$, "getX",
259 Clazz.defineMethod (c$, "getY",
263 Clazz.defineMethod (c$, "getWidth",
267 Clazz.defineMethod (c$, "getHeight",
271 Clazz.overrideMethod (c$, "isEmpty",
273 return (this.width <= 0.0) || (this.height <= 0.0);
275 Clazz.defineMethod (c$, "setRect",
276 function (a, b, c, d) {
282 Clazz.defineMethod (c$, "setRect",
286 this.width = a.getWidth ();
287 this.height = a.getHeight ();
288 }, "java.awt.geom.Rectangle2D");
289 Clazz.defineMethod (c$, "outcode",
292 if (this.width <= 0) {
294 } else if (a < this.x) {
296 } else if (a > this.x + this.width) {
298 }if (this.height <= 0) {
300 } else if (b < this.y) {
302 } else if (b > this.y + this.height) {
306 Clazz.overrideMethod (c$, "getBounds2D",
308 return new java.awt.geom.Rectangle2D.Double (this.x, this.y, this.width, this.height);
310 Clazz.overrideMethod (c$, "createIntersection",
312 var b = new java.awt.geom.Rectangle2D.Double ();
313 java.awt.geom.Rectangle2D.intersect (this, a, b);
315 }, "java.awt.geom.Rectangle2D");
316 Clazz.overrideMethod (c$, "createUnion",
318 var b = new java.awt.geom.Rectangle2D.Double ();
319 java.awt.geom.Rectangle2D.union (this, a, b);
321 }, "java.awt.geom.Rectangle2D");
322 Clazz.overrideMethod (c$, "toString",
324 return this.getClass ().getName () + "[x=" + this.x + ",y=" + this.y + ",w=" + this.width + ",h=" + this.height + "]";
327 Clazz.defineStatics (c$,