Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / jalview / util / AWTConsole.js
index d03b9fa..7e1b5ee 100644 (file)
-Clazz.declarePackage ("jalview.util");\r
-Clazz.load (["java.awt.event.ActionListener", "$.WindowAdapter", "$.WindowListener", "java.io.PipedInputStream"], "jalview.util.AWTConsole", ["jalview.util.MessageManager", "java.awt.BorderLayout", "$.Button", "$.Dimension", "$.Frame", "$.GraphicsEnvironment", "$.Panel", "$.TextArea", "$.Toolkit", "java.io.PipedOutputStream", "java.lang.NullPointerException", "$.Thread"], function () {\r
-c$ = Clazz.decorateAsClass (function () {\r
-this.frame = null;\r
-this.textArea = null;\r
-this.reader = null;\r
-this.reader2 = null;\r
-this.quit = false;\r
-this.pin = null;\r
-this.pin2 = null;\r
-this.errorThrower = null;\r
-Clazz.instantialize (this, arguments);\r
-}, jalview.util, "AWTConsole", java.awt.event.WindowAdapter, [java.awt.event.WindowListener, java.awt.event.ActionListener, Runnable]);\r
-Clazz.prepareFields (c$, function () {\r
-this.pin =  new java.io.PipedInputStream ();\r
-this.pin2 =  new java.io.PipedInputStream ();\r
-});\r
-Clazz.makeConstructor (c$, \r
-function () {\r
-Clazz.superConstructor (this, jalview.util.AWTConsole, []);\r
-this.frame =  new java.awt.Frame ("Java Console");\r
-var screenSize = java.awt.Toolkit.getDefaultToolkit ().getScreenSize ();\r
-var frameSize =  new java.awt.Dimension ((Clazz.doubleToInt (screenSize.width / 2)), (Clazz.doubleToInt (screenSize.height / 2)));\r
-var x = (Clazz.doubleToInt (frameSize.width / 2));\r
-var y = (Clazz.doubleToInt (frameSize.height / 2));\r
-this.frame.setBounds (x, y, frameSize.width, frameSize.height);\r
-this.textArea =  new java.awt.TextArea ();\r
-this.textArea.setEditable (false);\r
-var button =  new java.awt.Button ("clear");\r
-var panel =  new java.awt.Panel ();\r
-panel.setLayout ( new java.awt.BorderLayout ());\r
-panel.add (this.textArea, "Center");\r
-panel.add (button, "South");\r
-this.frame.add (panel);\r
-this.frame.setVisible (true);\r
-this.frame.addWindowListener (this);\r
-button.addActionListener (this);\r
-try {\r
-var pout =  new java.io.PipedOutputStream (this.pin);\r
-System.setOut ( new java.io.PrintStream (pout, true));\r
-} catch (e$$) {\r
-if (Clazz.exceptionOf (e$$, java.io.IOException)) {\r
-var io = e$$;\r
-{\r
-this.textArea.append ("Couldn't redirect STDOUT to this console\n" + io.getMessage ());\r
-}\r
-} else if (Clazz.exceptionOf (e$$, SecurityException)) {\r
-var se = e$$;\r
-{\r
-this.textArea.append ("Couldn't redirect STDOUT to this console\n" + se.getMessage ());\r
-}\r
-} else {\r
-throw e$$;\r
-}\r
-}\r
-try {\r
-var pout2 =  new java.io.PipedOutputStream (this.pin2);\r
-System.setErr ( new java.io.PrintStream (pout2, true));\r
-} catch (e$$) {\r
-if (Clazz.exceptionOf (e$$, java.io.IOException)) {\r
-var io = e$$;\r
-{\r
-this.textArea.append ("Couldn't redirect STDERR to this console\n" + io.getMessage ());\r
-}\r
-} else if (Clazz.exceptionOf (e$$, SecurityException)) {\r
-var se = e$$;\r
-{\r
-this.textArea.append ("Couldn't redirect STDERR to this console\n" + se.getMessage ());\r
-}\r
-} else {\r
-throw e$$;\r
-}\r
-}\r
-this.quit = false;\r
-this.reader =  new Thread (this);\r
-this.reader.setDaemon (true);\r
-this.reader.start ();\r
-this.reader2 =  new Thread (this);\r
-this.reader2.setDaemon (true);\r
-this.reader2.start ();\r
-System.out.println ("Hello World 2");\r
-System.out.println ("All fonts available to Graphic2D:\n");\r
-var ge = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment ();\r
-var fontNames = ge.getAvailableFontFamilyNames ();\r
-for (var n = 0; n < fontNames.length; n++) System.out.println (fontNames[n]);\r
-\r
-System.out.println ("\nLets throw an error on this console");\r
-this.errorThrower =  new Thread (this);\r
-this.errorThrower.setDaemon (true);\r
-this.errorThrower.start ();\r
-});\r
-Clazz.overrideMethod (c$, "windowClosed", \r
-function (evt) {\r
-this.quit = true;\r
-this.notifyAll ();\r
-try {\r
-this.reader.join (1000);\r
-this.pin.close ();\r
-} catch (e) {\r
-if (Clazz.exceptionOf (e, Exception)) {\r
-} else {\r
-throw e;\r
-}\r
-}\r
-try {\r
-this.reader2.join (1000);\r
-this.pin2.close ();\r
-} catch (e) {\r
-if (Clazz.exceptionOf (e, Exception)) {\r
-} else {\r
-throw e;\r
-}\r
-}\r
-System.exit (0);\r
-}, "java.awt.event.WindowEvent");\r
-Clazz.overrideMethod (c$, "windowClosing", \r
-function (evt) {\r
-this.frame.setVisible (false);\r
-this.frame.dispose ();\r
-}, "java.awt.event.WindowEvent");\r
-Clazz.overrideMethod (c$, "actionPerformed", \r
-function (evt) {\r
-this.textArea.setText ("");\r
-}, "java.awt.event.ActionEvent");\r
-Clazz.overrideMethod (c$, "run", \r
-function () {\r
-try {\r
-while (Thread.currentThread () === this.reader) {\r
-try {\r
-this.wait (100);\r
-} catch (ie) {\r
-if (Clazz.exceptionOf (ie, InterruptedException)) {\r
-} else {\r
-throw ie;\r
-}\r
-}\r
-if (this.pin.available () != 0) {\r
-var input = this.readLine (this.pin);\r
-this.textArea.append (input);\r
-}if (this.quit) return;\r
-}\r
-while (Thread.currentThread () === this.reader2) {\r
-try {\r
-this.wait (100);\r
-} catch (ie) {\r
-if (Clazz.exceptionOf (ie, InterruptedException)) {\r
-} else {\r
-throw ie;\r
-}\r
-}\r
-if (this.pin2.available () != 0) {\r
-var input = this.readLine (this.pin2);\r
-this.textArea.append (input);\r
-}if (this.quit) return;\r
-}\r
-} catch (e) {\r
-if (Clazz.exceptionOf (e, Exception)) {\r
-this.textArea.append ("\nConsole reports an Internal error.");\r
-this.textArea.append ("The error is: " + e);\r
-} else {\r
-throw e;\r
-}\r
-}\r
-if (Thread.currentThread () === this.errorThrower) {\r
-try {\r
-this.wait (1000);\r
-} catch (ie) {\r
-if (Clazz.exceptionOf (ie, InterruptedException)) {\r
-} else {\r
-throw ie;\r
-}\r
-}\r
-throw  new NullPointerException (jalview.util.MessageManager.getString ("exception.application_test_npe"));\r
-}});\r
-Clazz.defineMethod (c$, "readLine", \r
-function ($in) {\r
-var input = "";\r
-do {\r
-var available = $in.available ();\r
-if (available == 0) break;\r
-var b =  Clazz.newByteArray (available, 0);\r
-$in.read (b);\r
-input = input +  String.instantialize (b, 0, b.length);\r
-} while (!input.endsWith ("\n") && !input.endsWith ("\r\n") && !this.quit);\r
-return input;\r
-}, "java.io.PipedInputStream");\r
-});\r
+Clazz.declarePackage ("jalview.util");
+Clazz.load (["java.awt.event.ActionListener", "$.WindowAdapter", "$.WindowListener", "java.io.PipedInputStream"], "jalview.util.AWTConsole", ["jalview.util.MessageManager", "java.awt.BorderLayout", "$.Button", "$.Dimension", "$.Frame", "$.GraphicsEnvironment", "$.Panel", "$.TextArea", "$.Toolkit", "java.io.PipedOutputStream", "java.lang.NullPointerException", "$.Thread"], function () {
+c$ = Clazz.decorateAsClass (function () {
+this.frame = null;
+this.textArea = null;
+this.reader = null;
+this.reader2 = null;
+this.quit = false;
+this.pin = null;
+this.pin2 = null;
+this.errorThrower = null;
+Clazz.instantialize (this, arguments);
+}, jalview.util, "AWTConsole", java.awt.event.WindowAdapter, [java.awt.event.WindowListener, java.awt.event.ActionListener, Runnable]);
+Clazz.prepareFields (c$, function () {
+this.pin =  new java.io.PipedInputStream ();
+this.pin2 =  new java.io.PipedInputStream ();
+});
+Clazz.makeConstructor (c$, 
+function () {
+Clazz.superConstructor (this, jalview.util.AWTConsole, []);
+this.frame =  new java.awt.Frame ("Java Console");
+var screenSize = java.awt.Toolkit.getDefaultToolkit ().getScreenSize ();
+var frameSize =  new java.awt.Dimension ((Clazz.doubleToInt (screenSize.width / 2)), (Clazz.doubleToInt (screenSize.height / 2)));
+var x = (Clazz.doubleToInt (frameSize.width / 2));
+var y = (Clazz.doubleToInt (frameSize.height / 2));
+this.frame.setBounds (x, y, frameSize.width, frameSize.height);
+this.textArea =  new java.awt.TextArea ();
+this.textArea.setEditable (false);
+var button =  new java.awt.Button ("clear");
+var panel =  new java.awt.Panel ();
+panel.setLayout ( new java.awt.BorderLayout ());
+panel.add (this.textArea, "Center");
+panel.add (button, "South");
+this.frame.add (panel);
+this.frame.setVisible (true);
+this.frame.addWindowListener (this);
+button.addActionListener (this);
+try {
+var pout =  new java.io.PipedOutputStream (this.pin);
+System.setOut ( new java.io.PrintStream (pout, true));
+} catch (e$$) {
+if (Clazz.exceptionOf (e$$, java.io.IOException)) {
+var io = e$$;
+{
+this.textArea.append ("Couldn't redirect STDOUT to this console\n" + io.getMessage ());
+}
+} else if (Clazz.exceptionOf (e$$, SecurityException)) {
+var se = e$$;
+{
+this.textArea.append ("Couldn't redirect STDOUT to this console\n" + se.getMessage ());
+}
+} else {
+throw e$$;
+}
+}
+try {
+var pout2 =  new java.io.PipedOutputStream (this.pin2);
+System.setErr ( new java.io.PrintStream (pout2, true));
+} catch (e$$) {
+if (Clazz.exceptionOf (e$$, java.io.IOException)) {
+var io = e$$;
+{
+this.textArea.append ("Couldn't redirect STDERR to this console\n" + io.getMessage ());
+}
+} else if (Clazz.exceptionOf (e$$, SecurityException)) {
+var se = e$$;
+{
+this.textArea.append ("Couldn't redirect STDERR to this console\n" + se.getMessage ());
+}
+} else {
+throw e$$;
+}
+}
+this.quit = false;
+this.reader =  new Thread (this);
+this.reader.setDaemon (true);
+this.reader.start ();
+this.reader2 =  new Thread (this);
+this.reader2.setDaemon (true);
+this.reader2.start ();
+System.out.println ("Hello World 2");
+System.out.println ("All fonts available to Graphic2D:\n");
+var ge = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment ();
+var fontNames = ge.getAvailableFontFamilyNames ();
+for (var n = 0; n < fontNames.length; n++) System.out.println (fontNames[n]);
+
+System.out.println ("\nLets throw an error on this console");
+this.errorThrower =  new Thread (this);
+this.errorThrower.setDaemon (true);
+this.errorThrower.start ();
+});
+Clazz.overrideMethod (c$, "windowClosed", 
+function (evt) {
+this.quit = true;
+this.notifyAll ();
+try {
+this.reader.join (1000);
+this.pin.close ();
+} catch (e) {
+if (Clazz.exceptionOf (e, Exception)) {
+} else {
+throw e;
+}
+}
+try {
+this.reader2.join (1000);
+this.pin2.close ();
+} catch (e) {
+if (Clazz.exceptionOf (e, Exception)) {
+} else {
+throw e;
+}
+}
+System.exit (0);
+}, "java.awt.event.WindowEvent");
+Clazz.overrideMethod (c$, "windowClosing", 
+function (evt) {
+this.frame.setVisible (false);
+this.frame.dispose ();
+}, "java.awt.event.WindowEvent");
+Clazz.overrideMethod (c$, "actionPerformed", 
+function (evt) {
+this.textArea.setText ("");
+}, "java.awt.event.ActionEvent");
+Clazz.overrideMethod (c$, "run", 
+function () {
+try {
+while (Thread.currentThread () === this.reader) {
+try {
+this.wait (100);
+} catch (ie) {
+if (Clazz.exceptionOf (ie, InterruptedException)) {
+} else {
+throw ie;
+}
+}
+if (this.pin.available () != 0) {
+var input = this.readLine (this.pin);
+this.textArea.append (input);
+}if (this.quit) return;
+}
+while (Thread.currentThread () === this.reader2) {
+try {
+this.wait (100);
+} catch (ie) {
+if (Clazz.exceptionOf (ie, InterruptedException)) {
+} else {
+throw ie;
+}
+}
+if (this.pin2.available () != 0) {
+var input = this.readLine (this.pin2);
+this.textArea.append (input);
+}if (this.quit) return;
+}
+} catch (e) {
+if (Clazz.exceptionOf (e, Exception)) {
+this.textArea.append ("\nConsole reports an Internal error.");
+this.textArea.append ("The error is: " + e);
+} else {
+throw e;
+}
+}
+if (Thread.currentThread () === this.errorThrower) {
+try {
+this.wait (1000);
+} catch (ie) {
+if (Clazz.exceptionOf (ie, InterruptedException)) {
+} else {
+throw ie;
+}
+}
+throw  new NullPointerException (jalview.util.MessageManager.getString ("exception.application_test_npe"));
+}});
+Clazz.defineMethod (c$, "readLine", 
+function ($in) {
+var input = "";
+do {
+var available = $in.available ();
+if (available == 0) break;
+var b =  Clazz.newByteArray (available, 0);
+$in.read (b);
+input = input +  String.instantialize (b, 0, b.length);
+} while (!input.endsWith ("\n") && !input.endsWith ("\r\n") && !this.quit);
+return input;
+}, "java.io.PipedInputStream");
+});