Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / java / awt / geom / Rectangle2D.js
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$, 
5 function () {
6 Clazz.superConstructor (this, java.awt.geom.Rectangle2D, []);
7 });
8 Clazz.defineMethod (c$, "setRect", 
9 function (r) {
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) {
14 var out1;
15 var out2;
16 if ((out2 = this.outcode (x2, y2)) == 0) {
17 return true;
18 }while ((out1 = this.outcode (x1, y1)) != 0) {
19 if ((out1 & out2) != 0) {
20 return false;
21 }if ((out1 & (5)) != 0) {
22 var x = this.getX ();
23 if ((out1 & 4) != 0) {
24 x += this.getWidth ();
25 }y1 = y1 + (x - x1) * (y2 - y1) / (x2 - x1);
26 x1 = x;
27 } else {
28 var y = this.getY ();
29 if ((out1 & 8) != 0) {
30 y += this.getHeight ();
31 }x1 = x1 + (y - y1) * (x2 - x1) / (y2 - y1);
32 y1 = y;
33 }}
34 return true;
35 }, "~N,~N,~N,~N");
36 Clazz.defineMethod (c$, "intersectsLine", 
37 function (l) {
38 return this.intersectsLine (l.getX1 (), l.getY1 (), l.getX2 (), l.getY2 ());
39 }, "java.awt.geom.Line2D");
40 Clazz.defineMethod (c$, "outcode", 
41 function (p) {
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);
47 }, "~N,~N,~N,~N");
48 Clazz.overrideMethod (c$, "getBounds2D", 
49 function () {
50 return this.clone ();
51 });
52 Clazz.defineMethod (c$, "contains", 
53 function (x, y) {
54 var x0 = this.getX ();
55 var y0 = this.getY ();
56 return (x >= x0 && y >= y0 && x < x0 + this.getWidth () && y < y0 + this.getHeight ());
57 }, "~N,~N");
58 Clazz.defineMethod (c$, "intersects", 
59 function (x, y, w, h) {
60 if (this.isEmpty () || w <= 0 || h <= 0) {
61 return false;
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 ());
65 }, "~N,~N,~N,~N");
66 Clazz.defineMethod (c$, "contains", 
67 function (x, y, w, h) {
68 if (this.isEmpty () || w <= 0 || h <= 0) {
69 return false;
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 ());
73 }, "~N,~N,~N,~N");
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);
97 }, "~N,~N");
98 Clazz.defineMethod (c$, "add", 
99 function (pt) {
100 this.add (pt.getX (), pt.getY ());
101 }, "java.awt.geom.Point2D");
102 Clazz.defineMethod (c$, "add", 
103 function (r) {
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", 
111 function (at) {
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", 
119 function () {
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)));
125 });
126 Clazz.overrideMethod (c$, "equals", 
127 function (obj) {
128 if (obj === this) {
129 return true;
130 }if (Clazz.instanceOf (obj, java.awt.geom.Rectangle2D)) {
131 var r2d = obj;
132 return ((this.getX () == r2d.getX ()) && (this.getY () == r2d.getY ()) && (this.getWidth () == r2d.getWidth ()) && (this.getHeight () == r2d.getHeight ()));
133 }return false;
134 }, "~O");
135 Clazz.pu$h(self.c$);
136 c$ = Clazz.decorateAsClass (function () {
137 this.x = 0;
138 this.y = 0;
139 this.width = 0;
140 this.height = 0;
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, []);
146 {
147 if (arguments.length == 0)
148 return;
149 }this.setRect (a, b, c, d);
150 }, "~N,~N,~N,~N");
151 Clazz.defineMethod (c$, "getX", 
152 function () {
153 return this.x;
154 });
155 Clazz.defineMethod (c$, "getY", 
156 function () {
157 return this.y;
158 });
159 Clazz.defineMethod (c$, "getWidth", 
160 function () {
161 return this.width;
162 });
163 Clazz.defineMethod (c$, "getHeight", 
164 function () {
165 return this.height;
166 });
167 Clazz.overrideMethod (c$, "isEmpty", 
168 function () {
169 return (this.width <= 0.0) || (this.height <= 0.0);
170 });
171 Clazz.defineMethod (c$, "setRect", 
172 function (a, b, c, d) {
173 this.x = a;
174 this.y = b;
175 this.width = c;
176 this.height = d;
177 }, "~N,~N,~N,~N");
178 Clazz.defineMethod (c$, "setRect", 
179 function (a, b, c, d) {
180 this.x = a;
181 this.y = b;
182 this.width = c;
183 this.height = d;
184 }, "~N,~N,~N,~N");
185 Clazz.defineMethod (c$, "setRect", 
186 function (a) {
187 this.x = a.getX ();
188 this.y = a.getY ();
189 this.width = a.getWidth ();
190 this.height = a.getHeight ();
191 }, "java.awt.geom.Rectangle2D");
192 Clazz.defineMethod (c$, "outcode", 
193 function (a, b) {
194 var c = 0;
195 if (this.width <= 0) {
196 c |= 5;
197 } else if (a < this.x) {
198 c |= 1;
199 } else if (a > this.x + this.width) {
200 c |= 4;
201 }if (this.height <= 0) {
202 c |= 10;
203 } else if (b < this.y) {
204 c |= 2;
205 } else if (b > this.y + this.height) {
206 c |= 8;
207 }return c;
208 }, "~N,~N");
209 Clazz.overrideMethod (c$, "getBounds2D", 
210 function () {
211 return  new java.awt.geom.Rectangle2D.Float (this.x, this.y, this.width, this.height);
212 });
213 Clazz.overrideMethod (c$, "createIntersection", 
214 function (a) {
215 var b;
216 if (Clazz.instanceOf (a, java.awt.geom.Rectangle2D.Float)) {
217 b =  new java.awt.geom.Rectangle2D.Float ();
218 } else {
219 b =  new java.awt.geom.Rectangle2D.Double ();
220 }java.awt.geom.Rectangle2D.intersect (this, a, b);
221 return b;
222 }, "java.awt.geom.Rectangle2D");
223 Clazz.overrideMethod (c$, "createUnion", 
224 function (a) {
225 var b;
226 if (Clazz.instanceOf (a, java.awt.geom.Rectangle2D.Float)) {
227 b =  new java.awt.geom.Rectangle2D.Float ();
228 } else {
229 b =  new java.awt.geom.Rectangle2D.Double ();
230 }java.awt.geom.Rectangle2D.union (this, a, b);
231 return b;
232 }, "java.awt.geom.Rectangle2D");
233 Clazz.overrideMethod (c$, "toString", 
234 function () {
235 return this.getClass ().getName () + "[x=" + this.x + ",y=" + this.y + ",w=" + this.width + ",h=" + this.height + "]";
236 });
237 c$ = Clazz.p0p ();
238 Clazz.pu$h(self.c$);
239 c$ = Clazz.decorateAsClass (function () {
240 this.x = 0;
241 this.y = 0;
242 this.width = 0;
243 this.height = 0;
244 Clazz.instantialize (this, arguments);
245 }, java.awt.geom.Rectangle2D, "Double", java.awt.geom.Rectangle2D);
246 Clazz.makeConstructor (c$, 
247 function () {
248 Clazz.superConstructor (this, java.awt.geom.Rectangle2D.Double, []);
249 });
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);
254 }, "~N,~N,~N,~N");
255 Clazz.defineMethod (c$, "getX", 
256 function () {
257 return this.x;
258 });
259 Clazz.defineMethod (c$, "getY", 
260 function () {
261 return this.y;
262 });
263 Clazz.defineMethod (c$, "getWidth", 
264 function () {
265 return this.width;
266 });
267 Clazz.defineMethod (c$, "getHeight", 
268 function () {
269 return this.height;
270 });
271 Clazz.overrideMethod (c$, "isEmpty", 
272 function () {
273 return (this.width <= 0.0) || (this.height <= 0.0);
274 });
275 Clazz.defineMethod (c$, "setRect", 
276 function (a, b, c, d) {
277 this.x = a;
278 this.y = b;
279 this.width = c;
280 this.height = d;
281 }, "~N,~N,~N,~N");
282 Clazz.defineMethod (c$, "setRect", 
283 function (a) {
284 this.x = a.getX ();
285 this.y = a.getY ();
286 this.width = a.getWidth ();
287 this.height = a.getHeight ();
288 }, "java.awt.geom.Rectangle2D");
289 Clazz.defineMethod (c$, "outcode", 
290 function (a, b) {
291 var c = 0;
292 if (this.width <= 0) {
293 c |= 5;
294 } else if (a < this.x) {
295 c |= 1;
296 } else if (a > this.x + this.width) {
297 c |= 4;
298 }if (this.height <= 0) {
299 c |= 10;
300 } else if (b < this.y) {
301 c |= 2;
302 } else if (b > this.y + this.height) {
303 c |= 8;
304 }return c;
305 }, "~N,~N");
306 Clazz.overrideMethod (c$, "getBounds2D", 
307 function () {
308 return  new java.awt.geom.Rectangle2D.Double (this.x, this.y, this.width, this.height);
309 });
310 Clazz.overrideMethod (c$, "createIntersection", 
311 function (a) {
312 var b =  new java.awt.geom.Rectangle2D.Double ();
313 java.awt.geom.Rectangle2D.intersect (this, a, b);
314 return b;
315 }, "java.awt.geom.Rectangle2D");
316 Clazz.overrideMethod (c$, "createUnion", 
317 function (a) {
318 var b =  new java.awt.geom.Rectangle2D.Double ();
319 java.awt.geom.Rectangle2D.union (this, a, b);
320 return b;
321 }, "java.awt.geom.Rectangle2D");
322 Clazz.overrideMethod (c$, "toString", 
323 function () {
324 return this.getClass ().getName () + "[x=" + this.x + ",y=" + this.y + ",w=" + this.width + ",h=" + this.height + "]";
325 });
326 c$ = Clazz.p0p ();
327 Clazz.defineStatics (c$,
328 "OUT_LEFT", 1,
329 "OUT_TOP", 2,
330 "OUT_RIGHT", 4,
331 "OUT_BOTTOM", 8);
332 });