Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / swingjs / test / JumbledImageApplet.js
index a9201bc..69b33dc 100644 (file)
-Clazz.declarePackage ("swingjs.test");\r
-Clazz.load (["javax.swing.JApplet", "$.JPanel"], ["swingjs.test.JumbledImageApplet", "$.JumbledImage"], ["java.awt.Dimension", "java.awt.event.ActionListener", "$.WindowAdapter", "java.io.File", "java.net.URL", "java.util.Random", "javax.imageio.ImageIO", "javax.swing.JButton", "$.JFrame"], function () {\r
-c$ = Clazz.decorateAsClass (function () {\r
-this.numlocs = 2;\r
-this.numcells = 0;\r
-this.cells = null;\r
-this.bi = null;\r
-this.w = 0;\r
-this.h = 0;\r
-this.cw = 0;\r
-this.ch = 0;\r
-Clazz.instantialize (this, arguments);\r
-}, swingjs.test, "JumbledImage", javax.swing.JPanel);\r
-Clazz.prepareFields (c$, function () {\r
-this.numcells = this.numlocs * this.numlocs;\r
-});\r
-Clazz.makeConstructor (c$, \r
-function (imageSrc) {\r
-Clazz.superConstructor (this, swingjs.test.JumbledImage, []);\r
-try {\r
-this.bi = javax.imageio.ImageIO.read (imageSrc);\r
-this.w = this.bi.getWidth (null);\r
-this.h = this.bi.getHeight (null);\r
-} catch (e) {\r
-if (Clazz.exceptionOf (e, java.io.IOException)) {\r
-System.out.println ("Image could not be read");\r
-} else {\r
-throw e;\r
-}\r
-}\r
-this.cw = Clazz.doubleToInt (this.w / this.numlocs);\r
-this.ch = Clazz.doubleToInt (this.h / this.numlocs);\r
-this.cells =  Clazz.newIntArray (this.numcells, 0);\r
-for (var i = 0; i < this.numcells; i++) {\r
-this.cells[i] = i;\r
-}\r
-}, "java.net.URL");\r
-Clazz.defineMethod (c$, "jumble", \r
-function () {\r
-var rand =  new java.util.Random ();\r
-var ri;\r
-for (var i = 0; i < this.numcells; i++) {\r
-while ((ri = rand.nextInt (this.numlocs)) == i) ;\r
-var tmp = this.cells[i];\r
-this.cells[i] = this.cells[ri];\r
-this.cells[ri] = tmp;\r
-}\r
-});\r
-Clazz.overrideMethod (c$, "getPreferredSize", \r
-function () {\r
-return  new java.awt.Dimension (this.w, this.h);\r
-});\r
-Clazz.overrideMethod (c$, "paint", \r
-function (g) {\r
-var dx;\r
-var dy;\r
-for (var x = 0; x < this.numlocs; x++) {\r
-var sx = x * this.cw;\r
-for (var y = 0; y < this.numlocs; y++) {\r
-var sy = y * this.ch;\r
-var cell = this.cells[x * this.numlocs + y];\r
-dx = (Clazz.doubleToInt (cell / this.numlocs)) * this.cw;\r
-dy = (cell % this.numlocs) * this.ch;\r
-g.drawImage (this.bi, dx, dy, dx + this.cw, dy + this.ch, sx, sy, sx + this.cw, sy + this.ch, null);\r
-}\r
-}\r
-}, "java.awt.Graphics");\r
-c$ = Clazz.decorateAsClass (function () {\r
-this.imageSrc = null;\r
-this.jumbledImage = null;\r
-Clazz.instantialize (this, arguments);\r
-}, swingjs.test, "JumbledImageApplet", javax.swing.JApplet);\r
-Clazz.makeConstructor (c$, \r
-function () {\r
-Clazz.superConstructor (this, swingjs.test.JumbledImageApplet, []);\r
-});\r
-Clazz.makeConstructor (c$, \r
-function (imageSrc) {\r
-Clazz.superConstructor (this, swingjs.test.JumbledImageApplet, []);\r
-this.imageSrc = imageSrc;\r
-}, "java.net.URL");\r
-Clazz.overrideMethod (c$, "init", \r
-function () {\r
-try {\r
-this.imageSrc = this.pathTo (swingjs.test.JumbledImageApplet.imageFileName);\r
-} catch (e) {\r
-if (Clazz.exceptionOf (e, java.net.MalformedURLException)) {\r
-} else {\r
-throw e;\r
-}\r
-}\r
-this.buildUI ();\r
-});\r
-Clazz.defineMethod (c$, "buildUI", \r
-function () {\r
-var ji =  new swingjs.test.JumbledImage (this.imageSrc);\r
-this.add ("Center", ji);\r
-var jumbleButton =  new javax.swing.JButton ("Jumble");\r
-jumbleButton.addActionListener (((Clazz.isClassDefined ("swingjs.test.JumbledImageApplet$1") ? 0 : swingjs.test.JumbledImageApplet.$JumbledImageApplet$1$ ()), Clazz.innerTypeInstance (swingjs.test.JumbledImageApplet$1, this, Clazz.cloneFinals ("ji", ji))));\r
-var jumbleSize = ji.getPreferredSize ();\r
-this.resize (jumbleSize.width, jumbleSize.height + 40);\r
-this.add ("South", jumbleButton);\r
-});\r
-c$.main = Clazz.defineMethod (c$, "main", \r
-function (s) {\r
-var f =  new javax.swing.JFrame ("Jumbled Image");\r
-f.addWindowListener (((Clazz.isClassDefined ("swingjs.test.JumbledImageApplet$2") ? 0 : swingjs.test.JumbledImageApplet.$JumbledImageApplet$2$ ()), Clazz.innerTypeInstance (swingjs.test.JumbledImageApplet$2, this, null)));\r
-var imageSrc = null;\r
-try {\r
-imageSrc = (( new java.io.File (swingjs.test.JumbledImageApplet.imageFileName)).toURI ()).toURL ();\r
-} catch (e) {\r
-if (Clazz.exceptionOf (e, java.net.MalformedURLException)) {\r
-} else {\r
-throw e;\r
-}\r
-}\r
-var jumbler =  new swingjs.test.JumbledImageApplet (imageSrc);\r
-jumbler.buildUI ();\r
-f.add ("Center", jumbler);\r
-f.pack ();\r
-f.setVisible (true);\r
-}, "~A");\r
-Clazz.defineMethod (c$, "pathTo", \r
- function (file) {\r
-var path = this.getDocumentBase ().toString ();\r
-var pt = path.indexOf ("/bin/");\r
-if (pt > 0) path = path.substring (0, pt) + "/html/" + path.substring (pt + 5);\r
-path = path.substring (0, path.lastIndexOf ("/") + 1) + file;\r
-if (path.startsWith ("/")) path = "file://" + path;\r
-return  new java.net.URL (path);\r
-}, "~S");\r
-c$.$JumbledImageApplet$1$ = function () {\r
-Clazz.pu$h(self.c$);\r
-c$ = Clazz.declareAnonymous (swingjs.test, "JumbledImageApplet$1", null, java.awt.event.ActionListener);\r
-Clazz.overrideMethod (c$, "actionPerformed", \r
-function (e) {\r
-var b = e.getSource ();\r
-this.f$.ji.jumble ();\r
-this.f$.ji.repaint ();\r
-}, "java.awt.event.ActionEvent");\r
-c$ = Clazz.p0p ();\r
-};\r
-c$.$JumbledImageApplet$2$ = function () {\r
-Clazz.pu$h(self.c$);\r
-c$ = Clazz.declareAnonymous (swingjs.test, "JumbledImageApplet$2", java.awt.event.WindowAdapter);\r
-Clazz.overrideMethod (c$, "windowClosing", \r
-function (e) {\r
-System.exit (0);\r
-}, "java.awt.event.WindowEvent");\r
-c$ = Clazz.p0p ();\r
-};\r
-Clazz.defineStatics (c$,\r
-"imageFileName", "examples/duke_skateboard.jpg");\r
-});\r
+Clazz.declarePackage ("swingjs.test");
+Clazz.load (["javax.swing.JApplet", "$.JPanel"], ["swingjs.test.JumbledImageApplet", "$.JumbledImage"], ["java.awt.Dimension", "java.awt.event.ActionListener", "$.WindowAdapter", "java.io.File", "java.net.URL", "java.util.Random", "javax.imageio.ImageIO", "javax.swing.JButton", "$.JFrame"], function () {
+c$ = Clazz.decorateAsClass (function () {
+this.numlocs = 2;
+this.numcells = 0;
+this.cells = null;
+this.bi = null;
+this.w = 0;
+this.h = 0;
+this.cw = 0;
+this.ch = 0;
+Clazz.instantialize (this, arguments);
+}, swingjs.test, "JumbledImage", javax.swing.JPanel);
+Clazz.prepareFields (c$, function () {
+this.numcells = this.numlocs * this.numlocs;
+});
+Clazz.makeConstructor (c$, 
+function (imageSrc) {
+Clazz.superConstructor (this, swingjs.test.JumbledImage, []);
+try {
+this.bi = javax.imageio.ImageIO.read (imageSrc);
+this.w = this.bi.getWidth (null);
+this.h = this.bi.getHeight (null);
+} catch (e) {
+if (Clazz.exceptionOf (e, java.io.IOException)) {
+System.out.println ("Image could not be read");
+} else {
+throw e;
+}
+}
+this.cw = Clazz.doubleToInt (this.w / this.numlocs);
+this.ch = Clazz.doubleToInt (this.h / this.numlocs);
+this.cells =  Clazz.newIntArray (this.numcells, 0);
+for (var i = 0; i < this.numcells; i++) {
+this.cells[i] = i;
+}
+}, "java.net.URL");
+Clazz.defineMethod (c$, "jumble", 
+function () {
+var rand =  new java.util.Random ();
+var ri;
+for (var i = 0; i < this.numcells; i++) {
+while ((ri = rand.nextInt (this.numlocs)) == i) ;
+var tmp = this.cells[i];
+this.cells[i] = this.cells[ri];
+this.cells[ri] = tmp;
+}
+});
+Clazz.overrideMethod (c$, "getPreferredSize", 
+function () {
+return  new java.awt.Dimension (this.w, this.h);
+});
+Clazz.overrideMethod (c$, "paint", 
+function (g) {
+var dx;
+var dy;
+for (var x = 0; x < this.numlocs; x++) {
+var sx = x * this.cw;
+for (var y = 0; y < this.numlocs; y++) {
+var sy = y * this.ch;
+var cell = this.cells[x * this.numlocs + y];
+dx = (Clazz.doubleToInt (cell / this.numlocs)) * this.cw;
+dy = (cell % this.numlocs) * this.ch;
+g.drawImage (this.bi, dx, dy, dx + this.cw, dy + this.ch, sx, sy, sx + this.cw, sy + this.ch, null);
+}
+}
+}, "java.awt.Graphics");
+c$ = Clazz.decorateAsClass (function () {
+this.imageSrc = null;
+this.jumbledImage = null;
+Clazz.instantialize (this, arguments);
+}, swingjs.test, "JumbledImageApplet", javax.swing.JApplet);
+Clazz.makeConstructor (c$, 
+function () {
+Clazz.superConstructor (this, swingjs.test.JumbledImageApplet, []);
+});
+Clazz.makeConstructor (c$, 
+function (imageSrc) {
+Clazz.superConstructor (this, swingjs.test.JumbledImageApplet, []);
+this.imageSrc = imageSrc;
+}, "java.net.URL");
+Clazz.overrideMethod (c$, "init", 
+function () {
+try {
+this.imageSrc = this.pathTo (swingjs.test.JumbledImageApplet.imageFileName);
+} catch (e) {
+if (Clazz.exceptionOf (e, java.net.MalformedURLException)) {
+} else {
+throw e;
+}
+}
+this.buildUI ();
+});
+Clazz.defineMethod (c$, "buildUI", 
+function () {
+var ji =  new swingjs.test.JumbledImage (this.imageSrc);
+this.add ("Center", ji);
+var jumbleButton =  new javax.swing.JButton ("Jumble");
+jumbleButton.addActionListener (((Clazz.isClassDefined ("swingjs.test.JumbledImageApplet$1") ? 0 : swingjs.test.JumbledImageApplet.$JumbledImageApplet$1$ ()), Clazz.innerTypeInstance (swingjs.test.JumbledImageApplet$1, this, Clazz.cloneFinals ("ji", ji))));
+var jumbleSize = ji.getPreferredSize ();
+this.resize (jumbleSize.width, jumbleSize.height + 40);
+this.add ("South", jumbleButton);
+});
+c$.main = Clazz.defineMethod (c$, "main", 
+function (s) {
+var f =  new javax.swing.JFrame ("Jumbled Image");
+f.addWindowListener (((Clazz.isClassDefined ("swingjs.test.JumbledImageApplet$2") ? 0 : swingjs.test.JumbledImageApplet.$JumbledImageApplet$2$ ()), Clazz.innerTypeInstance (swingjs.test.JumbledImageApplet$2, this, null)));
+var imageSrc = null;
+try {
+imageSrc = (( new java.io.File (swingjs.test.JumbledImageApplet.imageFileName)).toURI ()).toURL ();
+} catch (e) {
+if (Clazz.exceptionOf (e, java.net.MalformedURLException)) {
+} else {
+throw e;
+}
+}
+var jumbler =  new swingjs.test.JumbledImageApplet (imageSrc);
+jumbler.buildUI ();
+f.add ("Center", jumbler);
+f.pack ();
+f.setVisible (true);
+}, "~A");
+Clazz.defineMethod (c$, "pathTo", 
+ function (file) {
+var path = this.getDocumentBase ().toString ();
+var pt = path.indexOf ("/bin/");
+if (pt > 0) path = path.substring (0, pt) + "/html/" + path.substring (pt + 5);
+path = path.substring (0, path.lastIndexOf ("/") + 1) + file;
+if (path.startsWith ("/")) path = "file://" + path;
+return  new java.net.URL (path);
+}, "~S");
+c$.$JumbledImageApplet$1$ = function () {
+Clazz.pu$h(self.c$);
+c$ = Clazz.declareAnonymous (swingjs.test, "JumbledImageApplet$1", null, java.awt.event.ActionListener);
+Clazz.overrideMethod (c$, "actionPerformed", 
+function (e) {
+var b = e.getSource ();
+this.f$.ji.jumble ();
+this.f$.ji.repaint ();
+}, "java.awt.event.ActionEvent");
+c$ = Clazz.p0p ();
+};
+c$.$JumbledImageApplet$2$ = function () {
+Clazz.pu$h(self.c$);
+c$ = Clazz.declareAnonymous (swingjs.test, "JumbledImageApplet$2", java.awt.event.WindowAdapter);
+Clazz.overrideMethod (c$, "windowClosing", 
+function (e) {
+System.exit (0);
+}, "java.awt.event.WindowEvent");
+c$ = Clazz.p0p ();
+};
+Clazz.defineStatics (c$,
+"imageFileName", "examples/duke_skateboard.jpg");
+});