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