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 () {
6 Clazz.instantialize (this, arguments);
7 }, swingjs.test, "Test_3", javax.swing.JApplet);
8 Clazz.makeConstructor (c$,
10 Clazz.superConstructor (this, swingjs.test.Test_3, []);
11 this.setName ("Test_3");
13 Clazz.overrideMethod (c$, "init",
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 ();
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!");
24 Clazz.defineMethod (c$, "setSize",
25 function (width, height) {
26 Clazz.superCall (this, swingjs.test.Test_3, "setSize", [width, height]);
29 Clazz.overrideMethod (c$, "destroy",
31 this.remove (this.controls);
32 this.remove (this.canvas);
34 Clazz.overrideMethod (c$, "start",
36 this.controls.setEnabled (true);
37 this.controls.f1.requestFocus ();
39 Clazz.overrideMethod (c$, "stop",
41 this.controls.setEnabled (false);
43 Clazz.overrideMethod (c$, "processEvent",
45 if (e.getID () == 201) {
47 }}, "java.awt.AWTEvent");
48 c$.main = Clazz.defineMethod (c$, "main",
50 var f = new javax.swing.JFrame ("Tanabe-Sugano");
51 var tanabe = new swingjs.test.Test_3 ();
54 f.add ("Center", tanabe);
57 f.setDefaultCloseOperation (3);
59 Clazz.overrideMethod (c$, "getAppletInfo",
61 return "A d3 octahedral Tanabe-Sugano Diagram";
63 c$.CalcF4T1g = Clazz.defineMethod (c$, "CalcF4T1g",
65 return (15 + (3 * x1) - Math.sqrt (225 - (18 * x1) + (x1 * x1))) / 2;
67 c$.CalcP4T1g = Clazz.defineMethod (c$, "CalcP4T1g",
69 return (15 + (3 * x1) + Math.sqrt (225 - (18 * x1) + (x1 * x1))) / 2;
71 c$.CalcG2Eg = Clazz.defineMethod (c$, "CalcG2Eg",
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;
75 c$.CalcG2A1g = Clazz.defineMethod (c$, "CalcG2A1g",
79 c$.CalcG2T1g = Clazz.defineMethod (c$, "CalcG2T1g",
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;
83 c$.CalcG2T2g = Clazz.defineMethod (c$, "CalcG2T2g",
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;
87 c$.CalcH2T2g = Clazz.defineMethod (c$, "CalcH2T2g",
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;
91 c$.CalcH2T1g = Clazz.defineMethod (c$, "CalcH2T1g",
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;
95 c$.CalcH2Eg = Clazz.defineMethod (c$, "CalcH2Eg",
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;
99 c$.CalcD2T2g = Clazz.defineMethod (c$, "CalcD2T2g",
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;
103 Clazz.defineMethod (c$, "processDelB",
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 ());
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;
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 ();
168 Clazz.defineMethod (c$, "processRatio",
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 ());
190 var ratioFound = false;
191 var ret = new StringBuffer ();
192 ret.append ("no value");
193 for (x = 0; x <= 50; 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)) {
202 for (x1 = (x - 1); x1 < x; x1 += 0.02) {
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 ();
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;
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 ();
253 }this.canvas.mouseOn = false;
254 this.canvas.repaint ();
255 return ret.toString ();
257 c$ = Clazz.decorateAsClass (function () {
259 this.bottomLeft = null;
271 this.mouseOn = false;
297 this.graphRec = 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);
316 Clazz.makeConstructor (c$,
318 Clazz.superConstructor (this, swingjs.test.Test_3Canvas, []);
319 this.setName ("Test_3Canvas");
324 this.backgroundColor = this.ltgrey;
325 this.addMouseListener (this);
326 this.addMouseMotionListener (this);
327 this.mouseOn = false;
329 Clazz.overrideMethod (c$, "paint",
331 this.drawDiagram (g);
332 }, "java.awt.Graphics");
333 Clazz.defineMethod (c$, "setRange",
334 function (start_end) {
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;
344 if (Clazz.exceptionOf (e, NumberFormatException)) {
352 Clazz.defineMethod (c$, "drawDiagram",
354 this.displayGraph (g);
355 }, "java.awt.Graphics");
356 Clazz.defineMethod (c$, "displayGraph",
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);
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));
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);
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);
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);
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);
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);
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",
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));
510 Clazz.defineMethod (c$, "drawXtoY",
511 function (x, y, screen_x, screen_y, g) {
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",
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;
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;
543 }}, "java.awt.event.MouseEvent");
544 Clazz.overrideMethod (c$, "mouseEntered",
546 }, "java.awt.event.MouseEvent");
547 Clazz.overrideMethod (c$, "mouseExited",
549 }, "java.awt.event.MouseEvent");
550 Clazz.overrideMethod (c$, "mouseClicked",
552 }, "java.awt.event.MouseEvent");
553 Clazz.overrideMethod (c$, "mouseReleased",
555 }, "java.awt.event.MouseEvent");
556 Clazz.overrideMethod (c$, "mouseDragged",
558 this.mousePressed (e);
559 }, "java.awt.event.MouseEvent");
560 Clazz.overrideMethod (c$, "mouseMoved",
562 }, "java.awt.event.MouseEvent");
563 c$ = Clazz.decorateAsClass (function () {
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$,
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"));
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));
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));
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",
613 }, "javax.swing.event.DocumentEvent");
614 Clazz.overrideMethod (c$, "removeUpdate",
617 }, "javax.swing.event.DocumentEvent");
618 Clazz.defineMethod (c$, "resetGraph",
620 this.canvas.setRange (this.f1.getText () + "-" + this.f2.getText ());
621 this.canvas.repaint ();
623 Clazz.overrideMethod (c$, "changedUpdate",
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) {
630 bg.add (c = new javax.swing.JRadioButton (text, b));
633 c.setEnabled (false);
634 c.addItemListener (this);
635 c.setFont ( new java.awt.Font ("Arial", 0, 15));
637 }, "javax.swing.ButtonGroup,~S,~B");
638 Clazz.overrideMethod (c$, "itemStateChanged",
640 if (Clazz.instanceOf (e.getSource (), javax.swing.JCheckBox)) {
641 if ((e.getSource ()).isSelected ()) {
642 this.canvas.backgroundColor = java.awt.Color.white;
644 this.canvas.backgroundColor = this.canvas.ltgrey;
645 }this.canvas.repaint ();
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 () {
657 c$ = Clazz.declareAnonymous (swingjs.test, "Test_3Controls$1", null, javax.swing.event.CaretListener);
658 Clazz.overrideMethod (c$, "caretUpdate",
660 System.out.println ("Test_3.JTextField caretEvent " + e.getDot () + " " + e.getMark ());
661 }, "javax.swing.event.CaretEvent");
664 c$.$Test_3Controls$2$ = function () {
666 c$ = Clazz.declareAnonymous (swingjs.test, "Test_3Controls$2", null, java.beans.PropertyChangeListener);
667 Clazz.overrideMethod (c$, "propertyChange",
669 System.out.println ("Test_3.JTextField property change " + evt.getPropertyName () + " " + this.b$["swingjs.test.Test_3Controls"].f1.getText ());
670 }, "java.beans.PropertyChangeEvent");
673 c$.$Test_3Controls$3$ = function () {
675 c$ = Clazz.declareAnonymous (swingjs.test, "Test_3Controls$3", null, java.awt.event.ActionListener);
676 Clazz.overrideMethod (c$, "actionPerformed",
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);
685 this.f$.enableBtn.setText (isEnable ? "Disable" : "Enable");