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$,
6 Clazz.superConstructor (this, java.awt.geom.RoundRectangle2D, []);
8 Clazz.defineMethod (c$, "setRoundRect",
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 ());
16 Clazz.defineMethod (c$, "contains",
18 if (this.isEmpty ()) {
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) {
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)) {
30 }if (y >= (rry0 += ah) && y < (rry0 = rry1 - ah)) {
34 return (x * x + y * y <= 1.0);
36 Clazz.defineMethod (c$, "classify",
37 function (coord, left, right, arcsize) {
40 } else if (coord < left + arcsize) {
42 } else if (coord < right - arcsize) {
44 } else if (coord < right) {
49 Clazz.defineMethod (c$, "intersects",
50 function (x, y, w, h) {
51 if (this.isEmpty () || w <= 0 || h <= 0) {
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) {
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) {
67 }if ((x0class < 2 && x1class > 2) || (y0class < 2 && y1class > 2)) {
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));
73 return (x * x + y * y <= 1.0);
75 Clazz.defineMethod (c$, "contains",
76 function (x, y, w, h) {
77 if (this.isEmpty () || w <= 0 || h <= 0) {
79 }return (this.contains (x, y) && this.contains (x + w, y) && this.contains (x, y + h) && this.contains (x + w, y + h));
81 Clazz.defineMethod (c$, "getPathIterator",
83 return new java.awt.geom.RoundRectIterator (this, at);
84 }, "java.awt.geom.AffineTransform");
85 Clazz.overrideMethod (c$, "hashCode",
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)));
95 Clazz.overrideMethod (c$, "equals",
99 }if (Clazz.instanceOf (obj, java.awt.geom.RoundRectangle2D)) {
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 ()));
105 c$ = Clazz.decorateAsClass (function () {
112 Clazz.instantialize (this, arguments);
113 }, java.awt.geom.RoundRectangle2D, "Float", java.awt.geom.RoundRectangle2D);
114 Clazz.makeConstructor (c$,
116 Clazz.superConstructor (this, java.awt.geom.RoundRectangle2D.Float, []);
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",
127 Clazz.defineMethod (c$, "getY",
131 Clazz.defineMethod (c$, "getWidth",
135 Clazz.defineMethod (c$, "getHeight",
139 Clazz.defineMethod (c$, "getArcWidth",
141 return this.arcwidth;
143 Clazz.defineMethod (c$, "getArcHeight",
145 return this.archeight;
147 Clazz.overrideMethod (c$, "isEmpty",
149 return (this.width <= 0.0) || (this.height <= 0.0);
151 Clazz.defineMethod (c$, "setRoundRect",
152 function (a, b, c, d, e, f) {
159 }, "~N,~N,~N,~N,~N,~N");
160 Clazz.defineMethod (c$, "setRoundRect",
161 function (a, b, c, d, e, f) {
168 }, "~N,~N,~N,~N,~N,~N");
169 Clazz.defineMethod (c$, "setRoundRect",
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",
180 return new java.awt.geom.Rectangle2D.Float (this.x, this.y, this.width, this.height);
184 c$ = Clazz.decorateAsClass (function () {
191 Clazz.instantialize (this, arguments);
192 }, java.awt.geom.RoundRectangle2D, "Double", java.awt.geom.RoundRectangle2D);
193 Clazz.makeConstructor (c$,
195 Clazz.superConstructor (this, java.awt.geom.RoundRectangle2D.Double, []);
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",
206 Clazz.defineMethod (c$, "getY",
210 Clazz.defineMethod (c$, "getWidth",
214 Clazz.defineMethod (c$, "getHeight",
218 Clazz.defineMethod (c$, "getArcWidth",
220 return this.arcwidth;
222 Clazz.defineMethod (c$, "getArcHeight",
224 return this.archeight;
226 Clazz.overrideMethod (c$, "isEmpty",
228 return (this.width <= 0.0) || (this.height <= 0.0);
230 Clazz.defineMethod (c$, "setRoundRect",
231 function (a, b, c, d, e, f) {
238 }, "~N,~N,~N,~N,~N,~N");
239 Clazz.defineMethod (c$, "setRoundRect",
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",
250 return new java.awt.geom.Rectangle2D.Double (this.x, this.y, this.width, this.height);