23d1ad04a58e956d9754f4845256894304ff70bc
[jalviewjs.git] / site / swingjs / j2s / swingjs / test / Test_3.js
1 Clazz.declarePackage ("swingjs.test");
2 Clazz.load (["java.awt.event.ItemListener", "$.MouseListener", "$.MouseMotionListener", "javax.swing.JApplet", "$.JPanel", "javax.swing.event.DocumentListener", "java.awt.Color", "$.Font", "$.Rectangle"], ["swingjs.test.Test_3Canvas", "$.Test_3Controls", "$.Test_3"], ["java.awt.BasicStroke", "$.BorderLayout", "$.Dimension", "$.FlowLayout", "$.Point", "java.awt.event.ActionListener", "java.beans.PropertyChangeListener", "java.lang.Double", "$.StringBuffer", "javax.swing.ButtonGroup", "$.JButton", "$.JCheckBox", "$.JFrame", "$.JLabel", "$.JRadioButton", "$.JTextField", "javax.swing.event.CaretListener"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.canvas = null;
5 this.controls = null;
6 Clazz.instantialize (this, arguments);
7 }, swingjs.test, "Test_3", javax.swing.JApplet);
8 Clazz.makeConstructor (c$, 
9 function () {
10 Clazz.superConstructor (this, swingjs.test.Test_3, []);
11 this.setName ("Test_3");
12 });
13 Clazz.overrideMethod (c$, "init", 
14 function () {
15 this.setLayout ( new java.awt.BorderLayout ());
16 this.canvas =  new swingjs.test.Test_3Canvas ();
17 this.canvas.setSize (850, 500);
18 var c = this.getContentPane ();
19 c.setSize (850, 500);
20 c.add (this.canvas, "Center");
21 c.add (this.controls =  new swingjs.test.Test_3Controls (this.canvas), "North");
22 System.out.println ("Hello, world!");
23 });
24 Clazz.defineMethod (c$, "setSize", 
25 function (width, height) {
26 Clazz.superCall (this, swingjs.test.Test_3, "setSize", [width, height]);
27 this.validate ();
28 }, "~N,~N");
29 Clazz.overrideMethod (c$, "destroy", 
30 function () {
31 this.remove (this.controls);
32 this.remove (this.canvas);
33 });
34 Clazz.overrideMethod (c$, "start", 
35 function () {
36 this.controls.setEnabled (true);
37 this.controls.f1.requestFocus ();
38 });
39 Clazz.overrideMethod (c$, "stop", 
40 function () {
41 this.controls.setEnabled (false);
42 });
43 Clazz.overrideMethod (c$, "processEvent", 
44 function (e) {
45 if (e.getID () == 201) {
46 System.exit (0);
47 }}, "java.awt.AWTEvent");
48 c$.main = Clazz.defineMethod (c$, "main", 
49 function (args) {
50 var f =  new javax.swing.JFrame ("Tanabe-Sugano");
51 var tanabe =  new swingjs.test.Test_3 ();
52 tanabe.init ();
53 tanabe.start ();
54 f.add ("Center", tanabe);
55 f.pack ();
56 f.setVisible (true);
57 f.setDefaultCloseOperation (3);
58 }, "~A");
59 Clazz.overrideMethod (c$, "getAppletInfo", 
60 function () {
61 return "A d3 octahedral Tanabe-Sugano Diagram";
62 });
63 c$.CalcF4T1g = Clazz.defineMethod (c$, "CalcF4T1g", 
64 function (x1) {
65 return (15 + (3 * x1) - Math.sqrt (225 - (18 * x1) + (x1 * x1))) / 2;
66 }, "~N");
67 c$.CalcP4T1g = Clazz.defineMethod (c$, "CalcP4T1g", 
68 function (x1) {
69 return (15 + (3 * x1) + Math.sqrt (225 - (18 * x1) + (x1 * x1))) / 2;
70 }, "~N");
71 c$.CalcG2Eg = Clazz.defineMethod (c$, "CalcG2Eg", 
72 function (x1) {
73 return 0.0000002727 * x1 * x1 * x1 * x1 * x1 - 0.00003926 * x1 * x1 * x1 * x1 + 0.002110 * x1 * x1 * x1 - 0.05256 * x1 * x1 + 0.6345 * x1 + 17.50161;
74 }, "~N");
75 c$.CalcG2A1g = Clazz.defineMethod (c$, "CalcG2A1g", 
76 function (x1) {
77 return x1 + 17.50161;
78 }, "~N");
79 c$.CalcG2T1g = Clazz.defineMethod (c$, "CalcG2T1g", 
80 function (x1) {
81 return 0.0000003205 * x1 * x1 * x1 * x1 * x1 - 0.00004689 * x1 * x1 * x1 * x1 + 0.00258 * x1 * x1 * x1 - 0.06641 * x1 * x1 + 0.8232 * x1 + 17.50161;
82 }, "~N");
83 c$.CalcG2T2g = Clazz.defineMethod (c$, "CalcG2T2g", 
84 function (x1) {
85 return 0.0000001933 * x1 * x1 * x1 * x1 * x1 - 0.00003336 * x1 * x1 * x1 * x1 + 0.002274 * x1 * x1 * x1 - 0.07898 * x1 * x1 + 1.557 * x1 + 17.50161;
86 }, "~N");
87 c$.CalcH2T2g = Clazz.defineMethod (c$, "CalcH2T2g", 
88 function (x1) {
89 return 0.00000002443 * x1 * x1 * x1 * x1 * x1 + 0.0000002677 * x1 * x1 * x1 * x1 - 0.0003003 * x1 * x1 * x1 + 0.01745 * x1 * x1 + 0.6635 * x1 + 22.50161;
90 }, "~N");
91 c$.CalcH2T1g = Clazz.defineMethod (c$, "CalcH2T1g", 
92 function (x1) {
93 return 0.00000002195 * x1 * x1 * x1 * x1 * x1 - 0.000005305 * x1 * x1 * x1 * x1 + 0.0004933 * x1 * x1 * x1 - 0.02294 * x1 * x1 + 1.570 * x1 + 22.50161;
94 }, "~N");
95 c$.CalcH2Eg = Clazz.defineMethod (c$, "CalcH2Eg", 
96 function (x1) {
97 return 0.0000001881 * x1 * x1 * x1 * x1 * x1 - 0.00002683 * x1 * x1 * x1 * x1 + 0.001416 * x1 * x1 * x1 - 0.0338 * x1 * x1 + 1.3525 * x1 + 22.50161;
98 }, "~N");
99 c$.CalcD2T2g = Clazz.defineMethod (c$, "CalcD2T2g", 
100 function (x1) {
101 return -7.532E-7 * x1 * x1 * x1 * x1 * x1 + 0.00009886 * x1 * x1 * x1 * x1 - 0.004352 * x1 * x1 * x1 + 0.06092 * x1 * x1 + 1.378 * x1 + 24.8951929;
102 }, "~N");
103 Clazz.defineMethod (c$, "processDelB", 
104 function (msgstr) {
105 var x1;
106 var y1;
107 var y2;
108 var y3;
109 var fE;
110 var fT1;
111 var fT2;
112 var fA1;
113 var fT2b;
114 var fT2H;
115 var fT1H;
116 var fEH;
117 var Delta;
118 var Bp;
119 var ret =  new StringBuffer ();
120 var ii = msgstr.indexOf (":");
121 var ll = msgstr.length;
122 Delta = Double.parseDouble (msgstr.substring (0, ii).trim ());
123 Bp = Double.parseDouble (msgstr.substring (ii + 1, ll).trim ());
124 x1 = Delta / Bp;
125 y1 = x1;
126 y2 = swingjs.test.Test_3.CalcF4T1g (x1);
127 y3 = swingjs.test.Test_3.CalcP4T1g (x1);
128 fE = swingjs.test.Test_3.CalcG2Eg (x1);
129 fT1 = swingjs.test.Test_3.CalcG2T1g (x1);
130 fT2 = swingjs.test.Test_3.CalcG2T2g (x1);
131 fA1 = swingjs.test.Test_3.CalcG2A1g (x1);
132 fT2b = swingjs.test.Test_3.CalcD2T2g (x1);
133 fT2H = swingjs.test.Test_3.CalcH2T2g (x1);
134 fEH = swingjs.test.Test_3.CalcH2Eg (x1);
135 fT1H = swingjs.test.Test_3.CalcH2T1g (x1);
136 var sBp = "" + Math.round (Bp);
137 var va1 = "" + Math.round (y1 * Bp);
138 var va2 = "" + Math.round (y2 * Bp);
139 var va3 = "" + Math.round (y3 * Bp);
140 var vfE = "" + Math.round (fE * Bp);
141 var vfT1 = "" + Math.round (fT1 * Bp);
142 var vfT2 = "" + Math.round (fT2 * Bp);
143 var vfA1 = "" + Math.round (fA1 * Bp);
144 var vfT2b = "" + Math.round (fT2b * Bp);
145 var vfT2H = "" + Math.round (fT2H * Bp);
146 var vfEH = "" + Math.round (fEH * Bp);
147 var vfT1H = "" + Math.round (fT1H * Bp);
148 ret.append ("B\' " + sBp + ", A " + va1 + ", " + va2 + ", " + va3 + ", F " + vfE + ", " + vfT1 + ", " + vfT2 + ", " + vfA1 + ", " + vfT2H + ", " + vfEH + ", " + vfT1H + ", " + vfT2b);
149 this.canvas.start_x = 0;
150 this.canvas.end_x = 50;
151 this.canvas.mouseOn = true;
152 this.canvas.deltaB = x1;
153 this.canvas.y1 = x1;
154 this.canvas.y2 = y2;
155 this.canvas.y3 = y3;
156 this.canvas.fE = fE;
157 this.canvas.fT1 = fT1;
158 this.canvas.fT2 = fT2;
159 this.canvas.fA1 = fA1;
160 this.canvas.fT2b = fT2b;
161 this.canvas.fT2H = fT2H;
162 this.canvas.fEH = fEH;
163 this.canvas.fT1H = fT1H;
164 this.canvas.ratio21 = y2 / y1;
165 this.canvas.repaint ();
166 return ret.toString ();
167 }, "~S");
168 Clazz.defineMethod (c$, "processRatio", 
169 function (msgstr) {
170 var x1;
171 var temp_ratio21;
172 var y1;
173 var y2;
174 var y3;
175 var ratio21;
176 var v1;
177 var fE;
178 var fT1;
179 var fT2;
180 var fA1;
181 var fT2b;
182 var fT2H;
183 var fT1H;
184 var fEH;
185 var ii = msgstr.indexOf (":");
186 var ll = msgstr.length;
187 ratio21 = Double.parseDouble (msgstr.substring (0, ii).trim ());
188 v1 = Double.parseDouble (msgstr.substring (ii + 1, ll).trim ());
189 var x;
190 var ratioFound = false;
191 var ret =  new StringBuffer ();
192 ret.append ("no value");
193 for (x = 0; x <= 50; x++) {
194 y1 = x;
195 y2 = swingjs.test.Test_3.CalcF4T1g (x);
196 temp_ratio21 = y2 / y1;
197 if ((temp_ratio21 < ratio21) && (ratio21 > 1.192) && (ratio21 < 1.75)) {
198 ratioFound = true;
199 break;
200 }}
201 if (ratioFound) {
202 for (x1 = (x - 1); x1 < x; x1 += 0.02) {
203 y1 = x1;
204 y2 = swingjs.test.Test_3.CalcF4T1g (x1);
205 y3 = swingjs.test.Test_3.CalcP4T1g (x1);
206 fE = swingjs.test.Test_3.CalcG2Eg (x1);
207 fT1 = swingjs.test.Test_3.CalcG2T1g (x1);
208 fT2 = swingjs.test.Test_3.CalcG2T2g (x1);
209 fA1 = swingjs.test.Test_3.CalcG2A1g (x1);
210 fT2b = swingjs.test.Test_3.CalcD2T2g (x1);
211 fT2H = swingjs.test.Test_3.CalcH2T2g (x1);
212 fEH = swingjs.test.Test_3.CalcH2Eg (x1);
213 fT1H = swingjs.test.Test_3.CalcH2T1g (x1);
214 temp_ratio21 = y2 / y1;
215 if (temp_ratio21 < ratio21) {
216 ret =  new StringBuffer ();
217 var Bp = v1 / x1;
218 var temp = Math.round (Bp * 10);
219 var tmp =  String.instantialize ("" + temp);
220 var Bprime = (tmp.substring (0, tmp.length - 1) + "." + tmp.substring (tmp.length - 1, tmp.length));
221 y3 = swingjs.test.Test_3.CalcP4T1g (x1);
222 var va1 = "" + Math.round (y1 * Bp);
223 var va2 = "" + Math.round (y2 * Bp);
224 var va3 = "" + Math.round (y3 * Bp);
225 var vfE = "" + Math.round (fE * Bp);
226 var vfT1 = "" + Math.round (fT1 * Bp);
227 var vfT2 = "" + Math.round (fT2 * Bp);
228 var vfA1 = "" + Math.round (fA1 * Bp);
229 var vfT2b = "" + Math.round (fT2b * Bp);
230 var vfT2H = "" + Math.round (fT2H * Bp);
231 var vfEH = "" + Math.round (fEH * Bp);
232 var vfT1H = "" + Math.round (fT1H * Bp);
233 ret.append ("B\' " + Bprime + ", A " + va1 + ", " + va2 + ", " + va3 + ", F " + vfE + ", " + vfT1 + ", " + vfT2 + ", " + vfA1 + ", " + vfT2H + ", " + vfEH + ", " + vfT1H + ", " + vfT2b);
234 this.canvas.start_x = 0;
235 this.canvas.end_x = 50;
236 this.canvas.mouseOn = true;
237 this.canvas.deltaB = x1;
238 this.canvas.y1 = x1;
239 this.canvas.y2 = y2;
240 this.canvas.y3 = y3;
241 this.canvas.fE = fE;
242 this.canvas.fT1 = fT1;
243 this.canvas.fT2 = fT2;
244 this.canvas.fA1 = fA1;
245 this.canvas.fT2b = fT2b;
246 this.canvas.fT2H = fT2H;
247 this.canvas.fEH = fEH;
248 this.canvas.fT1H = fT1H;
249 this.canvas.ratio21 = y2 / y1;
250 this.canvas.repaint ();
251 return ret.toString ();
252 }}
253 }this.canvas.mouseOn = false;
254 this.canvas.repaint ();
255 return ret.toString ();
256 }, "~S");
257 c$ = Clazz.decorateAsClass (function () {
258 this.$y = 0;
259 this.bottomLeft = null;
260 this.btmLeft = null;
261 this.start_x = 0;
262 this.end_x = 0;
263 this.lrange = 0;
264 this.$x = 0;
265 this.hlines = 0;
266 this.vlines = 0;
267 this.gx = 0;
268 this.deltaB = 0;
269 this.xScale = 0;
270 this.yScale = 0;
271 this.mouseOn = false;
272 this.x1 = 0;
273 this.y1 = 0;
274 this.y2 = 0;
275 this.y3 = 0;
276 this.ratio21 = 0;
277 this.ratio31 = 0;
278 this.ratio32 = 0;
279 this.fE = 0;
280 this.fT2 = 0;
281 this.fT1 = 0;
282 this.fA1 = 0;
283 this.fT2b = 0;
284 this.fT2H = 0;
285 this.fT1H = 0;
286 this.fEH = 0;
287 this.fb = null;
288 this.f = null;
289 this.dkgreen = null;
290 this.gold = null;
291 this.ltgrey = null;
292 this.teal = null;
293 this.purple = null;
294 this.lgreen = null;
295 this.dgreen = null;
296 this.copper = null;
297 this.graphRec = null;
298 this.outPRec = null;
299 this.backgroundColor = null;
300 Clazz.instantialize (this, arguments);
301 }, swingjs.test, "Test_3Canvas", javax.swing.JPanel, [java.awt.event.MouseListener, java.awt.event.MouseMotionListener]);
302 Clazz.prepareFields (c$, function () {
303 this.fb =  new java.awt.Font ("Arial", 1, 18);
304 this.f =  new java.awt.Font ("Courier", 0, 16);
305 this.dkgreen =  new java.awt.Color (142, 244, 108);
306 this.gold =  new java.awt.Color (191, 139, 32);
307 this.ltgrey =  new java.awt.Color (233, 233, 233);
308 this.teal =  new java.awt.Color (168, 207, 251);
309 this.purple =  new java.awt.Color (192, 12, 255);
310 this.lgreen =  new java.awt.Color (82, 179, 53);
311 this.dgreen =  new java.awt.Color (41, 94, 28);
312 this.copper =  new java.awt.Color (179, 100, 13);
313 this.graphRec =  new java.awt.Rectangle (50, 10, 600, 460);
314 this.outPRec =  new java.awt.Rectangle (650, 10, 685, 360);
315 });
316 Clazz.makeConstructor (c$, 
317 function () {
318 Clazz.superConstructor (this, swingjs.test.Test_3Canvas, []);
319 this.setName ("Test_3Canvas");
320 this.start_x = 0;
321 this.end_x = 50;
322 this.hlines = 10;
323 this.vlines = 10;
324 this.backgroundColor = this.ltgrey;
325 this.addMouseListener (this);
326 this.addMouseMotionListener (this);
327 this.mouseOn = false;
328 });
329 Clazz.overrideMethod (c$, "paint", 
330 function (g) {
331 this.drawDiagram (g);
332 }, "java.awt.Graphics");
333 Clazz.defineMethod (c$, "setRange", 
334 function (start_end) {
335 try {
336 var pt = start_end.indexOf ('-');
337 var start = (Integer.$valueOf (start_end.substring (0, pt))).intValue ();
338 var end = (Integer.$valueOf (start_end.substring (pt + 1))).intValue ();
339 if (start >= end) return;
340 this.lrange = (start == 0 && end == 50 ? 0 : -1);
341 this.start_x = start;
342 this.end_x = end;
343 } catch (e) {
344 if (Clazz.exceptionOf (e, NumberFormatException)) {
345 this.start_x = 0;
346 this.end_x = 50;
347 } else {
348 throw e;
349 }
350 }
351 }, "~S");
352 Clazz.defineMethod (c$, "drawDiagram", 
353  function (g) {
354 this.displayGraph (g);
355 }, "java.awt.Graphics");
356 Clazz.defineMethod (c$, "displayGraph", 
357  function (g) {
358 var g2 = g;
359 g2.setColor (this.backgroundColor);
360 g2.fillRect (0, 0, this.getWidth (), this.getHeight ());
361 g2.setBackground (g2.getBackground ());
362 var stroke2 =  new java.awt.BasicStroke (2);
363 var stroke1 =  new java.awt.BasicStroke (1);
364 var stroke_d1 =  new java.awt.BasicStroke (1, 0, 2, 0,  Clazz.newFloatArray (-1, [6, 6]), 0);
365 var yDivisor;
366 g2.clearRect (this.graphRec.x, this.graphRec.y, this.graphRec.width, this.graphRec.height);
367 g2.setColor (java.awt.Color.black);
368 this.bottomLeft =  new java.awt.Point (this.graphRec.x, this.graphRec.y + this.graphRec.height);
369 this.btmLeft =  new java.awt.Point (this.outPRec.x, this.outPRec.y + this.outPRec.height);
370 g2.drawLine (this.bottomLeft.x, this.bottomLeft.y, this.bottomLeft.x + this.graphRec.width, this.bottomLeft.y);
371 g2.drawLine (this.bottomLeft.x, this.bottomLeft.y, this.bottomLeft.x, this.graphRec.y);
372 this.xScale = (this.graphRec.width / (this.end_x - this.start_x));
373 if (this.end_x < 35) {
374 yDivisor = swingjs.test.Test_3.CalcD2T2g (this.end_x);
375 } else yDivisor = swingjs.test.Test_3.CalcP4T1g (this.end_x);
376 this.yScale = this.graphRec.height / yDivisor;
377 var start_x1 =  Clazz.newIntArray (-1, [(this.bottomLeft.x)]);
378 var start_x2 =  Clazz.newIntArray (-1, [(this.bottomLeft.x)]);
379 var start_x3 =  Clazz.newIntArray (-1, [(this.bottomLeft.x)]);
380 var start_x4 =  Clazz.newIntArray (-1, [(this.bottomLeft.x)]);
381 var start_x5 =  Clazz.newIntArray (-1, [(this.bottomLeft.x)]);
382 var start_x6 =  Clazz.newIntArray (-1, [(this.bottomLeft.x)]);
383 var start_x7 =  Clazz.newIntArray (-1, [(this.bottomLeft.x)]);
384 var start_x8 =  Clazz.newIntArray (-1, [(this.bottomLeft.x)]);
385 var start_x9 =  Clazz.newIntArray (-1, [(this.bottomLeft.x)]);
386 var start_x10 =  Clazz.newIntArray (-1, [(this.bottomLeft.x)]);
387 var start_x11 =  Clazz.newIntArray (-1, [(this.bottomLeft.x)]);
388 var start_y1 =  Clazz.newIntArray (-1, [Clazz.doubleToInt (this.bottomLeft.y - (this.start_x * this.yScale))]);
389 this.$y = swingjs.test.Test_3.CalcF4T1g (this.start_x);
390 var start_y2 =  Clazz.newIntArray (-1, [Clazz.doubleToInt (this.bottomLeft.y - (this.yScale * this.$y))]);
391 this.$y = swingjs.test.Test_3.CalcP4T1g (this.start_x);
392 var start_y3 =  Clazz.newIntArray (-1, [Clazz.doubleToInt (this.bottomLeft.y - (this.yScale * this.$y))]);
393 this.$y = swingjs.test.Test_3.CalcG2Eg (this.start_x);
394 var start_y4 =  Clazz.newIntArray (-1, [Clazz.doubleToInt (this.bottomLeft.y - (this.yScale * this.$y))]);
395 this.$y = swingjs.test.Test_3.CalcG2T1g (this.start_x);
396 var start_y5 =  Clazz.newIntArray (-1, [Clazz.doubleToInt (this.bottomLeft.y - (this.yScale * this.$y))]);
397 this.$y = swingjs.test.Test_3.CalcG2T2g (this.start_x);
398 var start_y6 =  Clazz.newIntArray (-1, [Clazz.doubleToInt (this.bottomLeft.y - (this.yScale * this.$y))]);
399 this.$y = swingjs.test.Test_3.CalcG2A1g (this.start_x);
400 var start_y7 =  Clazz.newIntArray (-1, [Clazz.doubleToInt (this.bottomLeft.y - (this.yScale * this.$y))]);
401 this.$y = swingjs.test.Test_3.CalcD2T2g (this.start_x);
402 var start_y8 =  Clazz.newIntArray (-1, [Clazz.doubleToInt (this.bottomLeft.y - (this.yScale * this.$y))]);
403 this.$y = swingjs.test.Test_3.CalcH2T2g (this.start_x);
404 var start_y9 =  Clazz.newIntArray (-1, [Clazz.doubleToInt (this.bottomLeft.y - (this.yScale * this.$y))]);
405 this.$y = swingjs.test.Test_3.CalcH2T1g (this.start_x);
406 var start_y10 =  Clazz.newIntArray (-1, [Clazz.doubleToInt (this.bottomLeft.y - (this.yScale * this.$y))]);
407 this.$y = swingjs.test.Test_3.CalcH2Eg (this.start_x);
408 var start_y11 =  Clazz.newIntArray (-1, [Clazz.doubleToInt (this.bottomLeft.y - (this.yScale * this.$y))]);
409 var hSlines = Clazz.doubleToInt (this.graphRec.height / this.hlines);
410 var vSlines = Clazz.doubleToInt (this.graphRec.width / this.vlines);
411 g2.setColor (this.ltgrey);
412 g2.setStroke (stroke1);
413 for (var ii = 1; ii <= this.hlines; ii++) {
414 g2.drawLine (this.bottomLeft.x, this.bottomLeft.y - (ii * hSlines), this.bottomLeft.x + this.graphRec.width, this.bottomLeft.y - (ii * hSlines));
415 }
416 for (var ii = 1; ii <= this.vlines; ii++) {
417 g2.drawLine (this.bottomLeft.x + (ii * vSlines), this.bottomLeft.y, this.bottomLeft.x + (ii * vSlines), this.bottomLeft.y - this.graphRec.height);
418 }
419 for (this.$x = this.start_x; this.$x <= this.end_x; this.$x++) {
420 g2.setStroke (stroke2);
421 g2.setColor (java.awt.Color.red);
422 this.$y = this.$x;
423 this.drawXtoY (this.$x, this.$y, start_x1, start_y1, g);
424 g2.setColor (java.awt.Color.blue);
425 this.$y = swingjs.test.Test_3.CalcF4T1g (this.$x);
426 this.drawXtoY (this.$x, this.$y, start_x2, start_y2, g);
427 g2.setColor (this.dkgreen);
428 this.$y = swingjs.test.Test_3.CalcP4T1g (this.$x);
429 this.drawXtoY (this.$x, this.$y, start_x3, start_y3, g);
430 g2.setStroke (stroke_d1);
431 g2.setColor (this.teal);
432 this.$y = swingjs.test.Test_3.CalcG2Eg (this.$x);
433 this.drawXtoY (this.$x, this.$y, start_x4, start_y4, g);
434 g2.setColor (java.awt.Color.orange);
435 this.$y = swingjs.test.Test_3.CalcG2T1g (this.$x);
436 this.drawXtoY (this.$x, this.$y, start_x5, start_y5, g);
437 g2.setColor (this.gold);
438 this.$y = swingjs.test.Test_3.CalcG2T2g (this.$x);
439 this.drawXtoY (this.$x, this.$y, start_x6, start_y6, g);
440 g2.setColor (java.awt.Color.gray);
441 this.$y = swingjs.test.Test_3.CalcG2A1g (this.$x);
442 this.drawXtoY (this.$x, this.$y, start_x7, start_y7, g);
443 g2.setColor (this.purple);
444 this.$y = swingjs.test.Test_3.CalcD2T2g (this.$x);
445 this.drawXtoY (this.$x, this.$y, start_x8, start_y8, g);
446 g2.setColor (this.lgreen);
447 this.$y = swingjs.test.Test_3.CalcH2T2g (this.$x);
448 this.drawXtoY (this.$x, this.$y, start_x9, start_y9, g);
449 g2.setColor (this.copper);
450 this.$y = swingjs.test.Test_3.CalcH2Eg (this.$x);
451 this.drawXtoY (this.$x, this.$y, start_x11, start_y11, g);
452 g2.setColor (this.dgreen);
453 this.$y = swingjs.test.Test_3.CalcH2T1g (this.$x);
454 this.drawXtoY (this.$x, this.$y, start_x10, start_y10, g);
455 }
456 g2.setStroke (stroke1);
457 g2.setColor (java.awt.Color.black);
458 g2.setFont (this.fb);
459 var sx = this.bottomLeft.x;
460 var sy = this.bottomLeft.y;
461 g2.drawString ("" + this.start_x, sx, sy + 15);
462 g2.drawString ("delta/B", sx + 170, sy + 15);
463 g2.drawString ("C/B=4.5", sx + 345, sy + 30);
464 g2.drawString ("" + this.end_x, this.graphRec.width + 35, sy + 15);
465 g2.drawString ("E/B", sx - 35, this.graphRec.y + 100);
466 if (this.lrange == 0) {
467 g2.drawString ("4F", sx - 25, this.graphRec.y + 465);
468 g2.drawString ("4P", sx - 25, this.graphRec.y + 400);
469 g2.drawString ("2G", sx - 25, this.graphRec.y + 385);
470 g2.drawString ("2H", sx - 25, this.graphRec.y + 370);
471 g2.drawString ("2D", sx - 25, this.graphRec.y + 355);
472 }if (this.mouseOn) {
473 g2.setColor (java.awt.Color.black);
474 this.gx = Clazz.doubleToInt (((this.deltaB - this.start_x) * this.xScale) + this.bottomLeft.x);
475 g2.drawLine (this.gx, this.bottomLeft.y, this.gx, this.graphRec.y);
476 g2.setFont (this.f);
477 g2.drawString ("delta/B'   " + this.toThreePlaces (this.deltaB), this.outPRec.x, this.outPRec.y + 15);
478 g2.setColor (java.awt.Color.red);
479 g2.drawString ("v1(T2g)/B' " + this.toThreePlaces (this.y1), this.outPRec.x, this.outPRec.y + 28);
480 g2.setColor (java.awt.Color.blue);
481 g2.drawString ("v2(T1g)/B' " + this.toThreePlaces (this.y2), this.outPRec.x, this.outPRec.y + 43);
482 g2.setColor (this.dkgreen);
483 g2.drawString ("v3(T1g)/B' " + this.toThreePlaces (this.y3), this.outPRec.x, this.outPRec.y + 56);
484 g2.setColor (java.awt.Color.black);
485 g2.drawString ("ratio v2/v1 " + this.toThreePlaces (this.ratio21), this.outPRec.x, this.outPRec.y + 70);
486 g2.setColor (this.teal);
487 g2.drawString ("f1 (Eg)/B' " + this.toThreePlaces (this.fE), this.outPRec.x, this.outPRec.y + 83);
488 g2.setColor (java.awt.Color.orange);
489 g2.drawString ("f2(T1g)/B' " + this.toThreePlaces (this.fT1), this.outPRec.x, this.outPRec.y + 98);
490 g2.setColor (this.gold);
491 g2.drawString ("f3(T2g)/B' " + this.toThreePlaces (this.fT2), this.outPRec.x, this.outPRec.y + 113);
492 g2.setColor (java.awt.Color.gray);
493 g2.drawString ("f4(A1g)/B' " + this.toThreePlaces (this.fA1), this.outPRec.x, this.outPRec.y + 128);
494 g2.setColor (this.lgreen);
495 g2.drawString ("f5(T2g)/B' " + this.toThreePlaces (this.fT2H), this.outPRec.x, this.outPRec.y + 143);
496 g2.setColor (this.copper);
497 g2.drawString ("f6(Eg)/B'  " + this.toThreePlaces (this.fEH), this.outPRec.x, this.outPRec.y + 159);
498 g2.setColor (this.dgreen);
499 g2.drawString ("f7(T1g)/B' " + this.toThreePlaces (this.fT1H), this.outPRec.x, this.outPRec.y + 173);
500 g2.setColor (this.purple);
501 g2.drawString ("f8(T2g)/B' " + this.toThreePlaces (this.fT2b), this.outPRec.x, this.outPRec.y + 189);
502 this.mouseOn = false;
503 }}, "java.awt.Graphics");
504 Clazz.defineMethod (c$, "toThreePlaces", 
505 function ($in) {
506 var temp = Math.round ($in * 1000);
507 var tmp =  String.instantialize ("" + temp);
508 return (tmp.substring (0, tmp.length - 3) + "." + tmp.substring (tmp.length - 3, tmp.length));
509 }, "~N");
510 Clazz.defineMethod (c$, "drawXtoY", 
511  function (x, y, screen_x, screen_y, g) {
512 var end_x1;
513 var end_y1;
514 end_x1 = Clazz.doubleToInt (((x - this.start_x) * this.xScale) + this.bottomLeft.x);
515 end_y1 = Clazz.doubleToInt (this.bottomLeft.y - (y * this.yScale));
516 g.drawLine (screen_x[0], screen_y[0], end_x1, end_y1);
517 screen_x[0] = end_x1;
518 screen_y[0] = end_y1;
519 }, "~N,~N,~A,~A,java.awt.Graphics");
520 Clazz.overrideMethod (c$, "mousePressed", 
521 function (e) {
522 this.mouseOn = true;
523 e.consume ();
524 this.gx = e.getX ();
525 this.deltaB = ((this.gx - this.bottomLeft.x) / this.xScale) + this.start_x;
526 if ((this.deltaB >= this.start_x) && (this.deltaB <= this.end_x)) {
527 this.x1 = this.deltaB;
528 this.y1 = this.x1;
529 this.y2 = swingjs.test.Test_3.CalcF4T1g (this.x1);
530 this.y3 = swingjs.test.Test_3.CalcP4T1g (this.x1);
531 this.fE = swingjs.test.Test_3.CalcG2Eg (this.x1);
532 this.fT1 = swingjs.test.Test_3.CalcG2T1g (this.x1);
533 this.fT2 = swingjs.test.Test_3.CalcG2T2g (this.x1);
534 this.fA1 = swingjs.test.Test_3.CalcG2A1g (this.x1);
535 this.fT2b = swingjs.test.Test_3.CalcD2T2g (this.x1);
536 this.fT2H = swingjs.test.Test_3.CalcH2T2g (this.x1);
537 this.fEH = swingjs.test.Test_3.CalcH2Eg (this.x1);
538 this.fT1H = swingjs.test.Test_3.CalcH2T1g (this.x1);
539 this.ratio21 = this.y2 / this.y1;
540 this.ratio31 = this.y3 / this.y1;
541 this.ratio32 = this.y3 / this.y2;
542 this.repaint ();
543 }}, "java.awt.event.MouseEvent");
544 Clazz.overrideMethod (c$, "mouseEntered", 
545 function (e) {
546 }, "java.awt.event.MouseEvent");
547 Clazz.overrideMethod (c$, "mouseExited", 
548 function (e) {
549 }, "java.awt.event.MouseEvent");
550 Clazz.overrideMethod (c$, "mouseClicked", 
551 function (e) {
552 }, "java.awt.event.MouseEvent");
553 Clazz.overrideMethod (c$, "mouseReleased", 
554 function (e) {
555 }, "java.awt.event.MouseEvent");
556 Clazz.overrideMethod (c$, "mouseDragged", 
557 function (e) {
558 this.mousePressed (e);
559 }, "java.awt.event.MouseEvent");
560 Clazz.overrideMethod (c$, "mouseMoved", 
561 function (e) {
562 }, "java.awt.event.MouseEvent");
563 c$ = Clazz.decorateAsClass (function () {
564 this.s = null;
565 this.e = null;
566 this.f1 = null;
567 this.f2 = null;
568 this.canvas = null;
569 this.bg0 = null;
570 this.bg5 = null;
571 this.bg = null;
572 Clazz.instantialize (this, arguments);
573 }, swingjs.test, "Test_3Controls", javax.swing.JPanel, [java.awt.event.ItemListener, javax.swing.event.DocumentListener]);
574 Clazz.makeConstructor (c$, 
575 function (canvas) {
576 Clazz.superConstructor (this, swingjs.test.Test_3Controls, []);
577 this.setLayout ( new java.awt.FlowLayout ());
578 this.setName ("T3d3Controls");
579 this.canvas = canvas;
580 this.f1 =  new javax.swing.JTextField ("0");
581 this.f1.setFont ( new java.awt.Font ("Arial", 0, 15));
582 this.add ( new javax.swing.JLabel ("from"));
583 this.add (this.f1);
584 this.f1.setPreferredSize ( new java.awt.Dimension (25, 19));
585 this.f1.getDocument ().addDocumentListener (this);
586 this.f1.addCaretListener (((Clazz.isClassDefined ("swingjs.test.Test_3Controls$1") ? 0 : swingjs.test.Test_3Controls.$Test_3Controls$1$ ()), Clazz.innerTypeInstance (swingjs.test.Test_3Controls$1, this, null)));
587 this.f1.addPropertyChangeListener (((Clazz.isClassDefined ("swingjs.test.Test_3Controls$2") ? 0 : swingjs.test.Test_3Controls.$Test_3Controls$2$ ()), Clazz.innerTypeInstance (swingjs.test.Test_3Controls$2, this, null)));
588 this.add ( new javax.swing.JLabel ("to"));
589 this.f2 =  new javax.swing.JTextField ("50");
590 this.f2.setFont ( new java.awt.Font ("Arial", 0, 15));
591 this.add (this.f2);
592 this.f2.setPreferredSize ( new java.awt.Dimension (25, 19));
593 this.f2.getDocument ().addDocumentListener (this);
594 var c =  new javax.swing.JCheckBox ("white");
595 c.addItemListener (this);
596 c.setFont ( new java.awt.Font ("Arial", 0, 15));
597 this.add (c);
598 this.bg =  new javax.swing.ButtonGroup ();
599 this.bg0 = this.addButton (this.bg, "0-50", true);
600 this.addButton (this.bg, "0-10", false);
601 this.addButton (this.bg, "10-20", false);
602 this.addButton (this.bg, "20-30", false);
603 this.addButton (this.bg, "30-40", false);
604 this.bg5 = this.addButton (this.bg, "40-50", false);
605 var enableBtn =  new javax.swing.JButton ("Enable");
606 this.add (enableBtn);
607 enableBtn.addActionListener (((Clazz.isClassDefined ("swingjs.test.Test_3Controls$3") ? 0 : swingjs.test.Test_3Controls.$Test_3Controls$3$ ()), Clazz.innerTypeInstance (swingjs.test.Test_3Controls$3, this, Clazz.cloneFinals ("enableBtn", enableBtn))));
608 this.setVisible (true);
609 }, "swingjs.test.Test_3Canvas");
610 Clazz.overrideMethod (c$, "insertUpdate", 
611 function (evt) {
612 this.resetGraph ();
613 }, "javax.swing.event.DocumentEvent");
614 Clazz.overrideMethod (c$, "removeUpdate", 
615 function (evt) {
616 this.resetGraph ();
617 }, "javax.swing.event.DocumentEvent");
618 Clazz.defineMethod (c$, "resetGraph", 
619  function () {
620 this.canvas.setRange (this.f1.getText () + "-" + this.f2.getText ());
621 this.canvas.repaint ();
622 });
623 Clazz.overrideMethod (c$, "changedUpdate", 
624 function (evt) {
625 System.out.println ("Test_3.JTextField changed " + this.f1.getText ());
626 }, "javax.swing.event.DocumentEvent");
627 Clazz.defineMethod (c$, "addButton", 
628  function (bg, text, b) {
629 var c;
630 bg.add (c =  new javax.swing.JRadioButton (text, b));
631 c.setName (text);
632 this.add (c);
633 c.setEnabled (false);
634 c.addItemListener (this);
635 c.setFont ( new java.awt.Font ("Arial", 0, 15));
636 return c;
637 }, "javax.swing.ButtonGroup,~S,~B");
638 Clazz.overrideMethod (c$, "itemStateChanged", 
639 function (e) {
640 if (Clazz.instanceOf (e.getSource (), javax.swing.JCheckBox)) {
641 if ((e.getSource ()).isSelected ()) {
642 this.canvas.backgroundColor = java.awt.Color.white;
643 } else {
644 this.canvas.backgroundColor = this.canvas.ltgrey;
645 }this.canvas.repaint ();
646 return;
647 }if (Clazz.instanceOf (e.getSource (), javax.swing.JRadioButton) && e.getStateChange () == 1) {
648 this.canvas.setRange ((e.getItemSelectable ()).getText ());
649 var start = this.canvas.start_x;
650 var end = this.canvas.end_x;
651 this.f1.setText ("" + start);
652 this.f2.setText ("" + end);
653 this.canvas.repaint ();
654 }}, "java.awt.event.ItemEvent");
655 c$.$Test_3Controls$1$ = function () {
656 Clazz.pu$h(self.c$);
657 c$ = Clazz.declareAnonymous (swingjs.test, "Test_3Controls$1", null, javax.swing.event.CaretListener);
658 Clazz.overrideMethod (c$, "caretUpdate", 
659 function (e) {
660 System.out.println ("Test_3.JTextField caretEvent " + e.getDot () + " " + e.getMark ());
661 }, "javax.swing.event.CaretEvent");
662 c$ = Clazz.p0p ();
663 };
664 c$.$Test_3Controls$2$ = function () {
665 Clazz.pu$h(self.c$);
666 c$ = Clazz.declareAnonymous (swingjs.test, "Test_3Controls$2", null, java.beans.PropertyChangeListener);
667 Clazz.overrideMethod (c$, "propertyChange", 
668 function (evt) {
669 System.out.println ("Test_3.JTextField property change " + evt.getPropertyName () + " " + this.b$["swingjs.test.Test_3Controls"].f1.getText ());
670 }, "java.beans.PropertyChangeEvent");
671 c$ = Clazz.p0p ();
672 };
673 c$.$Test_3Controls$3$ = function () {
674 Clazz.pu$h(self.c$);
675 c$ = Clazz.declareAnonymous (swingjs.test, "Test_3Controls$3", null, java.awt.event.ActionListener);
676 Clazz.overrideMethod (c$, "actionPerformed", 
677 function (e) {
678 this.enableButtons (this.f$.enableBtn.getText ().equals ("Enable"));
679 }, "java.awt.event.ActionEvent");
680 Clazz.defineMethod (c$, "enableButtons", 
681  function (isEnable) {
682 var x = this.b$["swingjs.test.Test_3Controls"].bg.getElements ();
683 while (x.hasMoreElements ()) x.nextElement ().setEnabled (isEnable);
684
685 this.f$.enableBtn.setText (isEnable ? "Disable" : "Enable");
686 }, "~B");
687 c$ = Clazz.p0p ();
688 };
689 });