Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / java / awt / geom / Ellipse2D.js
1 Clazz.declarePackage ("java.awt.geom");
2 Clazz.load (["java.awt.geom.RectangularShape"], "java.awt.geom.Ellipse2D", ["java.lang.Double", "java.awt.geom.EllipseIterator", "$.Rectangle2D"], function () {
3 c$ = Clazz.declareType (java.awt.geom, "Ellipse2D", java.awt.geom.RectangularShape);
4 Clazz.makeConstructor (c$, 
5 function () {
6 Clazz.superConstructor (this, java.awt.geom.Ellipse2D, []);
7 });
8 Clazz.defineMethod (c$, "contains", 
9 function (x, y) {
10 var ellw = this.getWidth ();
11 if (ellw <= 0.0) {
12 return false;
13 }var normx = (x - this.getX ()) / ellw - 0.5;
14 var ellh = this.getHeight ();
15 if (ellh <= 0.0) {
16 return false;
17 }var normy = (y - this.getY ()) / ellh - 0.5;
18 return (normx * normx + normy * normy) < 0.25;
19 }, "~N,~N");
20 Clazz.defineMethod (c$, "intersects", 
21 function (x, y, w, h) {
22 if (w <= 0.0 || h <= 0.0) {
23 return false;
24 }var ellw = this.getWidth ();
25 if (ellw <= 0.0) {
26 return false;
27 }var normx0 = (x - this.getX ()) / ellw - 0.5;
28 var normx1 = normx0 + w / ellw;
29 var ellh = this.getHeight ();
30 if (ellh <= 0.0) {
31 return false;
32 }var normy0 = (y - this.getY ()) / ellh - 0.5;
33 var normy1 = normy0 + h / ellh;
34 var nearx;
35 var neary;
36 if (normx0 > 0.0) {
37 nearx = normx0;
38 } else if (normx1 < 0.0) {
39 nearx = normx1;
40 } else {
41 nearx = 0.0;
42 }if (normy0 > 0.0) {
43 neary = normy0;
44 } else if (normy1 < 0.0) {
45 neary = normy1;
46 } else {
47 neary = 0.0;
48 }return (nearx * nearx + neary * neary) < 0.25;
49 }, "~N,~N,~N,~N");
50 Clazz.defineMethod (c$, "contains", 
51 function (x, y, w, h) {
52 return (this.contains (x, y) && this.contains (x + w, y) && this.contains (x, y + h) && this.contains (x + w, y + h));
53 }, "~N,~N,~N,~N");
54 Clazz.defineMethod (c$, "getPathIterator", 
55 function (at) {
56 return  new java.awt.geom.EllipseIterator (this, at);
57 }, "java.awt.geom.AffineTransform");
58 Clazz.overrideMethod (c$, "hashCode", 
59 function () {
60 var bits = java.lang.Double.doubleToLongBits (this.getX ());
61 bits += java.lang.Double.doubleToLongBits (this.getY ()) * 37;
62 bits += java.lang.Double.doubleToLongBits (this.getWidth ()) * 43;
63 bits += java.lang.Double.doubleToLongBits (this.getHeight ()) * 47;
64 return ((bits) ^ ((bits >> 32)));
65 });
66 Clazz.overrideMethod (c$, "equals", 
67 function (obj) {
68 if (obj === this) {
69 return true;
70 }if (Clazz.instanceOf (obj, java.awt.geom.Ellipse2D)) {
71 var e2d = obj;
72 return ((this.getX () == e2d.getX ()) && (this.getY () == e2d.getY ()) && (this.getWidth () == e2d.getWidth ()) && (this.getHeight () == e2d.getHeight ()));
73 }return false;
74 }, "~O");
75 Clazz.pu$h(self.c$);
76 c$ = Clazz.decorateAsClass (function () {
77 this.x = 0;
78 this.y = 0;
79 this.width = 0;
80 this.height = 0;
81 Clazz.instantialize (this, arguments);
82 }, java.awt.geom.Ellipse2D, "Float", java.awt.geom.Ellipse2D);
83 Clazz.makeConstructor (c$, 
84 function () {
85 Clazz.superConstructor (this, java.awt.geom.Ellipse2D.Float, []);
86 });
87 Clazz.makeConstructor (c$, 
88 function (a, b, c, d) {
89 Clazz.superConstructor (this, java.awt.geom.Ellipse2D.Float, []);
90 this.setFrame (a, b, c, d);
91 }, "~N,~N,~N,~N");
92 Clazz.overrideMethod (c$, "getX", 
93 function () {
94 return this.x;
95 });
96 Clazz.overrideMethod (c$, "getY", 
97 function () {
98 return this.y;
99 });
100 Clazz.overrideMethod (c$, "getWidth", 
101 function () {
102 return this.width;
103 });
104 Clazz.overrideMethod (c$, "getHeight", 
105 function () {
106 return this.height;
107 });
108 Clazz.overrideMethod (c$, "isEmpty", 
109 function () {
110 return (this.width <= 0.0 || this.height <= 0.0);
111 });
112 Clazz.defineMethod (c$, "setFrame", 
113 function (a, b, c, d) {
114 this.x = a;
115 this.y = b;
116 this.width = c;
117 this.height = d;
118 }, "~N,~N,~N,~N");
119 Clazz.defineMethod (c$, "setFrame", 
120 function (a, b, c, d) {
121 this.x = a;
122 this.y = b;
123 this.width = c;
124 this.height = d;
125 }, "~N,~N,~N,~N");
126 Clazz.overrideMethod (c$, "getBounds2D", 
127 function () {
128 return  new java.awt.geom.Rectangle2D.Float (this.x, this.y, this.width, this.height);
129 });
130 c$ = Clazz.p0p ();
131 Clazz.pu$h(self.c$);
132 c$ = Clazz.decorateAsClass (function () {
133 this.x = 0;
134 this.y = 0;
135 this.width = 0;
136 this.height = 0;
137 Clazz.instantialize (this, arguments);
138 }, java.awt.geom.Ellipse2D, "Double", java.awt.geom.Ellipse2D);
139 Clazz.makeConstructor (c$, 
140 function () {
141 Clazz.superConstructor (this, java.awt.geom.Ellipse2D.Double, []);
142 });
143 Clazz.makeConstructor (c$, 
144 function (a, b, c, d) {
145 Clazz.superConstructor (this, java.awt.geom.Ellipse2D.Double, []);
146 this.setFrame (a, b, c, d);
147 }, "~N,~N,~N,~N");
148 Clazz.overrideMethod (c$, "getX", 
149 function () {
150 return this.x;
151 });
152 Clazz.overrideMethod (c$, "getY", 
153 function () {
154 return this.y;
155 });
156 Clazz.overrideMethod (c$, "getWidth", 
157 function () {
158 return this.width;
159 });
160 Clazz.overrideMethod (c$, "getHeight", 
161 function () {
162 return this.height;
163 });
164 Clazz.overrideMethod (c$, "isEmpty", 
165 function () {
166 return (this.width <= 0.0 || this.height <= 0.0);
167 });
168 Clazz.defineMethod (c$, "setFrame", 
169 function (a, b, c, d) {
170 this.x = a;
171 this.y = b;
172 this.width = c;
173 this.height = d;
174 }, "~N,~N,~N,~N");
175 Clazz.overrideMethod (c$, "getBounds2D", 
176 function () {
177 return  new java.awt.geom.Rectangle2D.Double (this.x, this.y, this.width, this.height);
178 });
179 c$ = Clazz.p0p ();
180 });