Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / java / awt / geom / RoundRectangle2D.js
1 Clazz.declarePackage ("java.awt.geom");
2 Clazz.load (["java.awt.geom.RectangularShape"], "java.awt.geom.RoundRectangle2D", ["java.lang.Double", "java.awt.geom.Rectangle2D", "$.RoundRectIterator"], function () {
3 c$ = Clazz.declareType (java.awt.geom, "RoundRectangle2D", java.awt.geom.RectangularShape);
4 Clazz.makeConstructor (c$, 
5 function () {
6 Clazz.superConstructor (this, java.awt.geom.RoundRectangle2D, []);
7 });
8 Clazz.defineMethod (c$, "setRoundRect", 
9 function (rr) {
10 this.setRoundRect (rr.getX (), rr.getY (), rr.getWidth (), rr.getHeight (), rr.getArcWidth (), rr.getArcHeight ());
11 }, "java.awt.geom.RoundRectangle2D");
12 Clazz.defineMethod (c$, "setFrame", 
13 function (x, y, w, h) {
14 this.setRoundRect (x, y, w, h, this.getArcWidth (), this.getArcHeight ());
15 }, "~N,~N,~N,~N");
16 Clazz.defineMethod (c$, "contains", 
17 function (x, y) {
18 if (this.isEmpty ()) {
19 return false;
20 }var rrx0 = this.getX ();
21 var rry0 = this.getY ();
22 var rrx1 = rrx0 + this.getWidth ();
23 var rry1 = rry0 + this.getHeight ();
24 if (x < rrx0 || y < rry0 || x >= rrx1 || y >= rry1) {
25 return false;
26 }var aw = Math.min (this.getWidth (), Math.abs (this.getArcWidth ())) / 2.0;
27 var ah = Math.min (this.getHeight (), Math.abs (this.getArcHeight ())) / 2.0;
28 if (x >= (rrx0 += aw) && x < (rrx0 = rrx1 - aw)) {
29 return true;
30 }if (y >= (rry0 += ah) && y < (rry0 = rry1 - ah)) {
31 return true;
32 }x = (x - rrx0) / aw;
33 y = (y - rry0) / ah;
34 return (x * x + y * y <= 1.0);
35 }, "~N,~N");
36 Clazz.defineMethod (c$, "classify", 
37  function (coord, left, right, arcsize) {
38 if (coord < left) {
39 return 0;
40 } else if (coord < left + arcsize) {
41 return 1;
42 } else if (coord < right - arcsize) {
43 return 2;
44 } else if (coord < right) {
45 return 3;
46 } else {
47 return 4;
48 }}, "~N,~N,~N,~N");
49 Clazz.defineMethod (c$, "intersects", 
50 function (x, y, w, h) {
51 if (this.isEmpty () || w <= 0 || h <= 0) {
52 return false;
53 }var rrx0 = this.getX ();
54 var rry0 = this.getY ();
55 var rrx1 = rrx0 + this.getWidth ();
56 var rry1 = rry0 + this.getHeight ();
57 if (x + w <= rrx0 || x >= rrx1 || y + h <= rry0 || y >= rry1) {
58 return false;
59 }var aw = Math.min (this.getWidth (), Math.abs (this.getArcWidth ())) / 2.0;
60 var ah = Math.min (this.getHeight (), Math.abs (this.getArcHeight ())) / 2.0;
61 var x0class = this.classify (x, rrx0, rrx1, aw);
62 var x1class = this.classify (x + w, rrx0, rrx1, aw);
63 var y0class = this.classify (y, rry0, rry1, ah);
64 var y1class = this.classify (y + h, rry0, rry1, ah);
65 if (x0class == 2 || x1class == 2 || y0class == 2 || y1class == 2) {
66 return true;
67 }if ((x0class < 2 && x1class > 2) || (y0class < 2 && y1class > 2)) {
68 return true;
69 }x = (x1class == 1) ? (x = x + w - (rrx0 + aw)) : (x = x - (rrx1 - aw));
70 y = (y1class == 1) ? (y = y + h - (rry0 + ah)) : (y = y - (rry1 - ah));
71 x = x / aw;
72 y = y / ah;
73 return (x * x + y * y <= 1.0);
74 }, "~N,~N,~N,~N");
75 Clazz.defineMethod (c$, "contains", 
76 function (x, y, w, h) {
77 if (this.isEmpty () || w <= 0 || h <= 0) {
78 return false;
79 }return (this.contains (x, y) && this.contains (x + w, y) && this.contains (x, y + h) && this.contains (x + w, y + h));
80 }, "~N,~N,~N,~N");
81 Clazz.defineMethod (c$, "getPathIterator", 
82 function (at) {
83 return  new java.awt.geom.RoundRectIterator (this, at);
84 }, "java.awt.geom.AffineTransform");
85 Clazz.overrideMethod (c$, "hashCode", 
86 function () {
87 var bits = java.lang.Double.doubleToLongBits (this.getX ());
88 bits += java.lang.Double.doubleToLongBits (this.getY ()) * 37;
89 bits += java.lang.Double.doubleToLongBits (this.getWidth ()) * 43;
90 bits += java.lang.Double.doubleToLongBits (this.getHeight ()) * 47;
91 bits += java.lang.Double.doubleToLongBits (this.getArcWidth ()) * 53;
92 bits += java.lang.Double.doubleToLongBits (this.getArcHeight ()) * 59;
93 return ((bits) ^ ((bits >> 32)));
94 });
95 Clazz.overrideMethod (c$, "equals", 
96 function (obj) {
97 if (obj === this) {
98 return true;
99 }if (Clazz.instanceOf (obj, java.awt.geom.RoundRectangle2D)) {
100 var rr2d = obj;
101 return ((this.getX () == rr2d.getX ()) && (this.getY () == rr2d.getY ()) && (this.getWidth () == rr2d.getWidth ()) && (this.getHeight () == rr2d.getHeight ()) && (this.getArcWidth () == rr2d.getArcWidth ()) && (this.getArcHeight () == rr2d.getArcHeight ()));
102 }return false;
103 }, "~O");
104 Clazz.pu$h(self.c$);
105 c$ = Clazz.decorateAsClass (function () {
106 this.x = 0;
107 this.y = 0;
108 this.width = 0;
109 this.height = 0;
110 this.arcwidth = 0;
111 this.archeight = 0;
112 Clazz.instantialize (this, arguments);
113 }, java.awt.geom.RoundRectangle2D, "Float", java.awt.geom.RoundRectangle2D);
114 Clazz.makeConstructor (c$, 
115 function () {
116 Clazz.superConstructor (this, java.awt.geom.RoundRectangle2D.Float, []);
117 });
118 Clazz.makeConstructor (c$, 
119 function (a, b, c, d, e, f) {
120 Clazz.superConstructor (this, java.awt.geom.RoundRectangle2D.Float, []);
121 this.setRoundRect (a, b, c, d, e, f);
122 }, "~N,~N,~N,~N,~N,~N");
123 Clazz.defineMethod (c$, "getX", 
124 function () {
125 return this.x;
126 });
127 Clazz.defineMethod (c$, "getY", 
128 function () {
129 return this.y;
130 });
131 Clazz.defineMethod (c$, "getWidth", 
132 function () {
133 return this.width;
134 });
135 Clazz.defineMethod (c$, "getHeight", 
136 function () {
137 return this.height;
138 });
139 Clazz.defineMethod (c$, "getArcWidth", 
140 function () {
141 return this.arcwidth;
142 });
143 Clazz.defineMethod (c$, "getArcHeight", 
144 function () {
145 return this.archeight;
146 });
147 Clazz.overrideMethod (c$, "isEmpty", 
148 function () {
149 return (this.width <= 0.0) || (this.height <= 0.0);
150 });
151 Clazz.defineMethod (c$, "setRoundRect", 
152 function (a, b, c, d, e, f) {
153 this.x = a;
154 this.y = b;
155 this.width = c;
156 this.height = d;
157 this.arcwidth = e;
158 this.archeight = f;
159 }, "~N,~N,~N,~N,~N,~N");
160 Clazz.defineMethod (c$, "setRoundRect", 
161 function (a, b, c, d, e, f) {
162 this.x = a;
163 this.y = b;
164 this.width = c;
165 this.height = d;
166 this.arcwidth = e;
167 this.archeight = f;
168 }, "~N,~N,~N,~N,~N,~N");
169 Clazz.defineMethod (c$, "setRoundRect", 
170 function (a) {
171 this.x = a.getX ();
172 this.y = a.getY ();
173 this.width = a.getWidth ();
174 this.height = a.getHeight ();
175 this.arcwidth = a.getArcWidth ();
176 this.archeight = a.getArcHeight ();
177 }, "java.awt.geom.RoundRectangle2D");
178 Clazz.overrideMethod (c$, "getBounds2D", 
179 function () {
180 return  new java.awt.geom.Rectangle2D.Float (this.x, this.y, this.width, this.height);
181 });
182 c$ = Clazz.p0p ();
183 Clazz.pu$h(self.c$);
184 c$ = Clazz.decorateAsClass (function () {
185 this.x = 0;
186 this.y = 0;
187 this.width = 0;
188 this.height = 0;
189 this.arcwidth = 0;
190 this.archeight = 0;
191 Clazz.instantialize (this, arguments);
192 }, java.awt.geom.RoundRectangle2D, "Double", java.awt.geom.RoundRectangle2D);
193 Clazz.makeConstructor (c$, 
194 function () {
195 Clazz.superConstructor (this, java.awt.geom.RoundRectangle2D.Double, []);
196 });
197 Clazz.makeConstructor (c$, 
198 function (a, b, c, d, e, f) {
199 Clazz.superConstructor (this, java.awt.geom.RoundRectangle2D.Double, []);
200 this.setRoundRect (a, b, c, d, e, f);
201 }, "~N,~N,~N,~N,~N,~N");
202 Clazz.defineMethod (c$, "getX", 
203 function () {
204 return this.x;
205 });
206 Clazz.defineMethod (c$, "getY", 
207 function () {
208 return this.y;
209 });
210 Clazz.defineMethod (c$, "getWidth", 
211 function () {
212 return this.width;
213 });
214 Clazz.defineMethod (c$, "getHeight", 
215 function () {
216 return this.height;
217 });
218 Clazz.defineMethod (c$, "getArcWidth", 
219 function () {
220 return this.arcwidth;
221 });
222 Clazz.defineMethod (c$, "getArcHeight", 
223 function () {
224 return this.archeight;
225 });
226 Clazz.overrideMethod (c$, "isEmpty", 
227 function () {
228 return (this.width <= 0.0) || (this.height <= 0.0);
229 });
230 Clazz.defineMethod (c$, "setRoundRect", 
231 function (a, b, c, d, e, f) {
232 this.x = a;
233 this.y = b;
234 this.width = c;
235 this.height = d;
236 this.arcwidth = e;
237 this.archeight = f;
238 }, "~N,~N,~N,~N,~N,~N");
239 Clazz.defineMethod (c$, "setRoundRect", 
240 function (a) {
241 this.x = a.getX ();
242 this.y = a.getY ();
243 this.width = a.getWidth ();
244 this.height = a.getHeight ();
245 this.arcwidth = a.getArcWidth ();
246 this.archeight = a.getArcHeight ();
247 }, "java.awt.geom.RoundRectangle2D");
248 Clazz.overrideMethod (c$, "getBounds2D", 
249 function () {
250 return  new java.awt.geom.Rectangle2D.Double (this.x, this.y, this.width, this.height);
251 });
252 c$ = Clazz.p0p ();
253 });