Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / jalview / appletgui / RotatableCanvas.js
index 0bb0b4a..5e61dea 100644 (file)
-Clazz.declarePackage ("jalview.appletgui");\r
-Clazz.load (["awt2swing.Panel", "jalview.api.RotatableCanvasI", "java.awt.event.KeyListener", "$.MouseListener", "$.MouseMotionListener", "jalview.math.RotatableMatrix"], "jalview.appletgui.RotatableCanvas", ["jalview.appletgui.PaintRefresher", "jalview.datamodel.SequenceGroup", "jalview.util.Format", "$.MessageManager", "java.awt.Color", "$.Dimension", "$.Font"], function () {\r
-c$ = Clazz.decorateAsClass (function () {\r
-this.idmat = null;\r
-this.objmat = null;\r
-this.rotmat = null;\r
-this.tooltip = null;\r
-this.toolx = 0;\r
-this.tooly = 0;\r
-this.$drawAxes = true;\r
-this.omx = 0;\r
-this.mx = 0;\r
-this.omy = 0;\r
-this.my = 0;\r
-this.img = null;\r
-this.ig = null;\r
-this.prefsize = null;\r
-this.centre = null;\r
-this.$width = null;\r
-this.max = null;\r
-this.min = null;\r
-this.maxwidth = 0;\r
-this.scale = 0;\r
-this.npoint = 0;\r
-this.points = null;\r
-this.orig = null;\r
-this.axes = null;\r
-this.startx = 0;\r
-this.starty = 0;\r
-this.lastx = 0;\r
-this.lasty = 0;\r
-this.rectx1 = 0;\r
-this.recty1 = 0;\r
-this.rectx2 = 0;\r
-this.recty2 = 0;\r
-this.scalefactor = 1;\r
-this.av = null;\r
-this.$showLabels = false;\r
-Clazz.instantialize (this, arguments);\r
-}, jalview.appletgui, "RotatableCanvas", awt2swing.Panel, [java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.KeyListener, jalview.api.RotatableCanvasI]);\r
-Clazz.prepareFields (c$, function () {\r
-this.idmat =  new jalview.math.RotatableMatrix (3, 3);\r
-this.objmat =  new jalview.math.RotatableMatrix (3, 3);\r
-this.rotmat =  new jalview.math.RotatableMatrix (3, 3);\r
-this.centre =  Clazz.newFloatArray (3, 0);\r
-this.$width =  Clazz.newFloatArray (3, 0);\r
-this.max =  Clazz.newFloatArray (3, 0);\r
-this.min =  Clazz.newFloatArray (3, 0);\r
-});\r
-Clazz.makeConstructor (c$, \r
-function (av) {\r
-Clazz.superConstructor (this, jalview.appletgui.RotatableCanvas, []);\r
-this.av = av;\r
-}, "jalview.viewmodel.AlignmentViewport");\r
-Clazz.defineMethod (c$, "showLabels", \r
-function (b) {\r
-this.$showLabels = b;\r
-this.repaint ();\r
-}, "~B");\r
-Clazz.overrideMethod (c$, "setPoints", \r
-function (points, npoint) {\r
-this.points = points;\r
-this.npoint = npoint;\r
-jalview.appletgui.PaintRefresher.Register (this, this.av.getSequenceSetId ());\r
-this.prefsize = this.getPreferredSize ();\r
-this.orig =  Clazz.newFloatArray (npoint, 3, 0);\r
-for (var i = 0; i < npoint; i++) {\r
-var sp = points.elementAt (i);\r
-for (var j = 0; j < 3; j++) {\r
-this.orig[i][j] = sp.coord[j];\r
-}\r
-}\r
-for (var i = 0; i < 3; i++) {\r
-for (var j = 0; j < 3; j++) {\r
-if (i != j) {\r
-this.idmat.addElement (i, j, 0);\r
-this.objmat.addElement (i, j, 0);\r
-this.rotmat.addElement (i, j, 0);\r
-} else {\r
-this.idmat.addElement (i, j, 0);\r
-this.objmat.addElement (i, j, 0);\r
-this.rotmat.addElement (i, j, 0);\r
-}}\r
-}\r
-this.axes =  Clazz.newFloatArray (3, 3, 0);\r
-this.initAxes ();\r
-this.findCentre ();\r
-this.findWidth ();\r
-this.scale = this.findScale ();\r
-this.addMouseListener (this);\r
-this.addKeyListener (this);\r
-this.addMouseMotionListener (this);\r
-}, "java.util.Vector,~N");\r
-Clazz.defineMethod (c$, "initAxes", \r
-function () {\r
-for (var i = 0; i < 3; i++) {\r
-for (var j = 0; j < 3; j++) {\r
-if (i != j) {\r
-this.axes[i][j] = 0;\r
-} else {\r
-this.axes[i][j] = 1;\r
-}}\r
-}\r
-});\r
-Clazz.defineMethod (c$, "findWidth", \r
-function () {\r
-this.max =  Clazz.newFloatArray (3, 0);\r
-this.min =  Clazz.newFloatArray (3, 0);\r
-this.max[0] = -1.0E30;\r
-this.max[1] = -1.0E30;\r
-this.max[2] = -1.0E30;\r
-this.min[0] = 1e30;\r
-this.min[1] = 1e30;\r
-this.min[2] = 1e30;\r
-for (var i = 0; i < 3; i++) {\r
-for (var j = 0; j < this.npoint; j++) {\r
-var sp = this.points.elementAt (j);\r
-if (sp.coord[i] >= this.max[i]) {\r
-this.max[i] = sp.coord[i];\r
-}if (sp.coord[i] <= this.min[i]) {\r
-this.min[i] = sp.coord[i];\r
-}}\r
-}\r
-this.$width[0] = Math.abs (this.max[0] - this.min[0]);\r
-this.$width[1] = Math.abs (this.max[1] - this.min[1]);\r
-this.$width[2] = Math.abs (this.max[2] - this.min[2]);\r
-this.maxwidth = this.$width[0];\r
-if (this.$width[1] > this.$width[0]) {\r
-this.maxwidth = this.$width[1];\r
-}if (this.$width[2] > this.$width[1]) {\r
-this.maxwidth = this.$width[2];\r
-}});\r
-Clazz.defineMethod (c$, "findScale", \r
-function () {\r
-var dim;\r
-var width;\r
-var height;\r
-if (this.getSize ().width != 0) {\r
-width = this.getSize ().width;\r
-height = this.getSize ().height;\r
-} else {\r
-width = this.prefsize.width;\r
-height = this.prefsize.height;\r
-}if (width < height) {\r
-dim = width;\r
-} else {\r
-dim = height;\r
-}return dim * this.scalefactor / (2 * this.maxwidth);\r
-});\r
-Clazz.defineMethod (c$, "findCentre", \r
-function () {\r
-this.findWidth ();\r
-this.centre[0] = (this.max[0] + this.min[0]) / 2;\r
-this.centre[1] = (this.max[1] + this.min[1]) / 2;\r
-this.centre[2] = (this.max[2] + this.min[2]) / 2;\r
-});\r
-Clazz.overrideMethod (c$, "getPreferredSize", \r
-function () {\r
-if (this.prefsize != null) {\r
-return this.prefsize;\r
-} else {\r
-return  new java.awt.Dimension (400, 400);\r
-}});\r
-Clazz.overrideMethod (c$, "getMinimumSize", \r
-function () {\r
-return this.getPreferredSize ();\r
-});\r
-Clazz.overrideMethod (c$, "update", \r
-function (g) {\r
-this.paint (g);\r
-}, "java.awt.Graphics");\r
-Clazz.defineMethod (c$, "PaintComponent", \r
-function (g) {\r
-if (this.points == null) {\r
-g.setFont ( new java.awt.Font ("Verdana", 0, 18));\r
-g.drawString (jalview.util.MessageManager.getString ("label.calculating_pca") + "....", 20, Clazz.doubleToInt (this.getSize ().height / 2));\r
-} else {\r
-if ((this.img == null) || (this.prefsize.width != this.getSize ().width) || (this.prefsize.height != this.getSize ().height)) {\r
-this.prefsize.width = this.getSize ().width;\r
-this.prefsize.height = this.getSize ().height;\r
-this.scale = this.findScale ();\r
-this.img = this.createImage (this.getSize ().width, this.getSize ().height);\r
-this.ig = this.img.getGraphics ();\r
-}this.drawBackground (this.ig, java.awt.Color.black);\r
-this.drawScene (this.ig);\r
-if (this.$drawAxes == true) {\r
-this.drawAxes (this.ig);\r
-}if (this.tooltip != null) {\r
-this.ig.setColor (java.awt.Color.red);\r
-this.ig.drawString (this.tooltip, this.toolx, this.tooly);\r
-}g.drawImage (this.img, 0, 0, this);\r
-}}, "java.awt.Graphics");\r
-Clazz.defineMethod (c$, "drawAxes", \r
-function (g) {\r
-g.setColor (java.awt.Color.yellow);\r
-for (var i = 0; i < 3; i++) {\r
-g.drawLine (Clazz.doubleToInt (this.getSize ().width / 2), Clazz.doubleToInt (this.getSize ().height / 2), Clazz.floatToInt (this.axes[i][0] * this.scale * this.max[0] + Clazz.doubleToInt (this.getSize ().width / 2)), Clazz.floatToInt (this.axes[i][1] * this.scale * this.max[1] + Clazz.doubleToInt (this.getSize ().height / 2)));\r
-}\r
-}, "java.awt.Graphics");\r
-Clazz.defineMethod (c$, "drawBackground", \r
-function (g, col) {\r
-g.setColor (col);\r
-g.fillRect (0, 0, this.prefsize.width, this.prefsize.height);\r
-}, "java.awt.Graphics,java.awt.Color");\r
-Clazz.defineMethod (c$, "drawScene", \r
-function (g) {\r
-var halfwidth = Clazz.doubleToInt (this.getSize ().width / 2);\r
-var halfheight = Clazz.doubleToInt (this.getSize ().height / 2);\r
-for (var i = 0; i < this.npoint; i++) {\r
-var sp = this.points.elementAt (i);\r
-var x = Clazz.floatToInt ((sp.coord[0] - this.centre[0]) * this.scale) + halfwidth;\r
-var y = Clazz.floatToInt ((sp.coord[1] - this.centre[1]) * this.scale) + halfheight;\r
-var z = sp.coord[1] - this.centre[2];\r
-if (this.av.getSequenceColour (sp.sequence) === java.awt.Color.black) {\r
-g.setColor (java.awt.Color.white);\r
-} else {\r
-g.setColor (this.av.getSequenceColour (sp.sequence));\r
-}if (this.av.getSelectionGroup () != null) {\r
-if (this.av.getSelectionGroup ().getSequences (null).contains ((this.points.elementAt (i)).sequence)) {\r
-g.setColor (java.awt.Color.gray);\r
-}}if (z < 0) {\r
-g.setColor (g.getColor ().darker ());\r
-}g.fillRect (x - 3, y - 3, 6, 6);\r
-if (this.$showLabels) {\r
-g.setColor (java.awt.Color.red);\r
-g.drawString ((this.points.elementAt (i)).sequence.getName (), x - 3, y - 4);\r
-}}\r
-}, "java.awt.Graphics");\r
-Clazz.defineMethod (c$, "minimumsize", \r
-function () {\r
-return this.prefsize;\r
-});\r
-Clazz.defineMethod (c$, "preferredsize", \r
-function () {\r
-return this.prefsize;\r
-});\r
-Clazz.overrideMethod (c$, "keyTyped", \r
-function (evt) {\r
-}, "java.awt.event.KeyEvent");\r
-Clazz.overrideMethod (c$, "keyReleased", \r
-function (evt) {\r
-}, "java.awt.event.KeyEvent");\r
-Clazz.overrideMethod (c$, "keyPressed", \r
-function (evt) {\r
-if (evt.getKeyCode () == 38) {\r
-this.scalefactor = (this.scalefactor * 1.1);\r
-this.scale = this.findScale ();\r
-} else if (evt.getKeyCode () == 40) {\r
-this.scalefactor = (this.scalefactor * 0.9);\r
-this.scale = this.findScale ();\r
-} else if (evt.getKeyChar () == 's') {\r
-System.err.println ("DEBUG: Rectangle selection");\r
-if (this.rectx2 != -1 && this.recty2 != -1) {\r
-this.rectSelect (this.rectx1, this.recty1, this.rectx2, this.recty2);\r
-}}this.repaint ();\r
-}, "java.awt.event.KeyEvent");\r
-Clazz.defineMethod (c$, "printPoints", \r
-function () {\r
-for (var i = 0; i < this.npoint; i++) {\r
-var sp = this.points.elementAt (i);\r
-jalview.util.Format.printLong (System.out, "%5d ", i);\r
-for (var j = 0; j < 3; j++) {\r
-jalview.util.Format.printDouble (System.out, "%13.3f  ", sp.coord[j]);\r
-}\r
-System.out.println ();\r
-}\r
-});\r
-Clazz.overrideMethod (c$, "mouseClicked", \r
-function (evt) {\r
-}, "java.awt.event.MouseEvent");\r
-Clazz.overrideMethod (c$, "mouseEntered", \r
-function (evt) {\r
-}, "java.awt.event.MouseEvent");\r
-Clazz.overrideMethod (c$, "mouseExited", \r
-function (evt) {\r
-}, "java.awt.event.MouseEvent");\r
-Clazz.overrideMethod (c$, "mouseReleased", \r
-function (evt) {\r
-}, "java.awt.event.MouseEvent");\r
-Clazz.overrideMethod (c$, "mousePressed", \r
-function (evt) {\r
-var x = evt.getX ();\r
-var y = evt.getY ();\r
-this.mx = x;\r
-this.my = y;\r
-this.omx = this.mx;\r
-this.omy = this.my;\r
-this.startx = x;\r
-this.starty = y;\r
-this.rectx1 = x;\r
-this.recty1 = y;\r
-this.rectx2 = -1;\r
-this.recty2 = -1;\r
-var found = this.findPoint (x, y);\r
-if (found != null) {\r
-if (this.av.getSelectionGroup () != null) {\r
-this.av.getSelectionGroup ().addOrRemove (found, true);\r
-this.av.getSelectionGroup ().setEndRes (this.av.getAlignment ().getWidth () - 1);\r
-} else {\r
-this.av.setSelectionGroup ( new jalview.datamodel.SequenceGroup ());\r
-this.av.getSelectionGroup ().addOrRemove (found, true);\r
-this.av.getSelectionGroup ().setEndRes (this.av.getAlignment ().getWidth () - 1);\r
-}jalview.appletgui.PaintRefresher.Refresh (this, this.av.getSequenceSetId ());\r
-this.av.sendSelection ();\r
-}this.repaint ();\r
-}, "java.awt.event.MouseEvent");\r
-Clazz.overrideMethod (c$, "mouseMoved", \r
-function (evt) {\r
-var found = this.findPoint (evt.getX (), evt.getY ());\r
-if (found == null) {\r
-this.tooltip = null;\r
-} else {\r
-this.tooltip = found.getName ();\r
-this.toolx = evt.getX ();\r
-this.tooly = evt.getY ();\r
-}this.repaint ();\r
-}, "java.awt.event.MouseEvent");\r
-Clazz.overrideMethod (c$, "mouseDragged", \r
-function (evt) {\r
-this.mx = evt.getX ();\r
-this.my = evt.getY ();\r
-this.rotmat.setIdentity ();\r
-this.rotmat.rotate (this.my - this.omy, 'x');\r
-this.rotmat.rotate (this.mx - this.omx, 'y');\r
-for (var i = 0; i < this.npoint; i++) {\r
-var sp = this.points.elementAt (i);\r
-sp.coord[0] -= this.centre[0];\r
-sp.coord[1] -= this.centre[1];\r
-sp.coord[2] -= this.centre[2];\r
-sp.coord = this.rotmat.vectorMultiply (sp.coord);\r
-sp.coord[0] += this.centre[0];\r
-sp.coord[1] += this.centre[1];\r
-sp.coord[2] += this.centre[2];\r
-}\r
-for (var i = 0; i < 3; i++) {\r
-this.axes[i] = this.rotmat.vectorMultiply (this.axes[i]);\r
-}\r
-this.omx = this.mx;\r
-this.omy = this.my;\r
-this.paint (this.getGraphics ());\r
-}, "java.awt.event.MouseEvent");\r
-Clazz.defineMethod (c$, "rectSelect", \r
-function (x1, y1, x2, y2) {\r
-for (var i = 0; i < this.npoint; i++) {\r
-var sp = this.points.elementAt (i);\r
-var tmp1 = Clazz.doubleToInt ((sp.coord[0] - this.centre[0]) * this.scale + this.getSize ().width / 2.0);\r
-var tmp2 = Clazz.doubleToInt ((sp.coord[1] - this.centre[1]) * this.scale + this.getSize ().height / 2.0);\r
-if (tmp1 > x1 && tmp1 < x2 && tmp2 > y1 && tmp2 < y2) {\r
-if (this.av != null) {\r
-if (!this.av.getSelectionGroup ().getSequences (null).contains (sp.sequence)) {\r
-this.av.getSelectionGroup ().addSequence (sp.sequence, true);\r
-}}}}\r
-}, "~N,~N,~N,~N");\r
-Clazz.defineMethod (c$, "findPoint", \r
-function (x, y) {\r
-var halfwidth = Clazz.doubleToInt (this.getSize ().width / 2);\r
-var halfheight = Clazz.doubleToInt (this.getSize ().height / 2);\r
-var found = -1;\r
-for (var i = 0; i < this.npoint; i++) {\r
-var sp = this.points.elementAt (i);\r
-var px = Clazz.floatToInt ((sp.coord[0] - this.centre[0]) * this.scale) + halfwidth;\r
-var py = Clazz.floatToInt ((sp.coord[1] - this.centre[1]) * this.scale) + halfheight;\r
-if (Math.abs (px - x) < 3 && Math.abs (py - y) < 3) {\r
-found = i;\r
-}}\r
-if (found != -1) {\r
-return (this.points.elementAt (found)).sequence;\r
-} else {\r
-return null;\r
-}}, "~N,~N");\r
-});\r
+Clazz.declarePackage ("jalview.appletgui");
+Clazz.load (["awt2swing.Panel", "jalview.api.RotatableCanvasI", "java.awt.event.KeyListener", "$.MouseListener", "$.MouseMotionListener", "jalview.math.RotatableMatrix"], "jalview.appletgui.RotatableCanvas", ["jalview.appletgui.PaintRefresher", "jalview.datamodel.SequenceGroup", "jalview.util.Format", "$.MessageManager", "java.awt.Color", "$.Dimension", "$.Font"], function () {
+c$ = Clazz.decorateAsClass (function () {
+this.idmat = null;
+this.objmat = null;
+this.rotmat = null;
+this.tooltip = null;
+this.toolx = 0;
+this.tooly = 0;
+this.$drawAxes = true;
+this.omx = 0;
+this.mx = 0;
+this.omy = 0;
+this.my = 0;
+this.img = null;
+this.ig = null;
+this.prefsize = null;
+this.centre = null;
+this.$width = null;
+this.max = null;
+this.min = null;
+this.maxwidth = 0;
+this.scale = 0;
+this.npoint = 0;
+this.points = null;
+this.orig = null;
+this.axes = null;
+this.startx = 0;
+this.starty = 0;
+this.lastx = 0;
+this.lasty = 0;
+this.rectx1 = 0;
+this.recty1 = 0;
+this.rectx2 = 0;
+this.recty2 = 0;
+this.scalefactor = 1;
+this.av = null;
+this.$showLabels = false;
+Clazz.instantialize (this, arguments);
+}, jalview.appletgui, "RotatableCanvas", awt2swing.Panel, [java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.KeyListener, jalview.api.RotatableCanvasI]);
+Clazz.prepareFields (c$, function () {
+this.idmat =  new jalview.math.RotatableMatrix (3, 3);
+this.objmat =  new jalview.math.RotatableMatrix (3, 3);
+this.rotmat =  new jalview.math.RotatableMatrix (3, 3);
+this.centre =  Clazz.newFloatArray (3, 0);
+this.$width =  Clazz.newFloatArray (3, 0);
+this.max =  Clazz.newFloatArray (3, 0);
+this.min =  Clazz.newFloatArray (3, 0);
+});
+Clazz.makeConstructor (c$, 
+function (av) {
+Clazz.superConstructor (this, jalview.appletgui.RotatableCanvas, []);
+this.av = av;
+}, "jalview.viewmodel.AlignmentViewport");
+Clazz.defineMethod (c$, "showLabels", 
+function (b) {
+this.$showLabels = b;
+this.repaint ();
+}, "~B");
+Clazz.overrideMethod (c$, "setPoints", 
+function (points, npoint) {
+this.points = points;
+this.npoint = npoint;
+jalview.appletgui.PaintRefresher.Register (this, this.av.getSequenceSetId ());
+this.prefsize = this.getPreferredSize ();
+this.orig =  Clazz.newFloatArray (npoint, 3, 0);
+for (var i = 0; i < npoint; i++) {
+var sp = points.elementAt (i);
+for (var j = 0; j < 3; j++) {
+this.orig[i][j] = sp.coord[j];
+}
+}
+for (var i = 0; i < 3; i++) {
+for (var j = 0; j < 3; j++) {
+if (i != j) {
+this.idmat.addElement (i, j, 0);
+this.objmat.addElement (i, j, 0);
+this.rotmat.addElement (i, j, 0);
+} else {
+this.idmat.addElement (i, j, 0);
+this.objmat.addElement (i, j, 0);
+this.rotmat.addElement (i, j, 0);
+}}
+}
+this.axes =  Clazz.newFloatArray (3, 3, 0);
+this.initAxes ();
+this.findCentre ();
+this.findWidth ();
+this.scale = this.findScale ();
+this.addMouseListener (this);
+this.addKeyListener (this);
+this.addMouseMotionListener (this);
+}, "java.util.Vector,~N");
+Clazz.defineMethod (c$, "initAxes", 
+function () {
+for (var i = 0; i < 3; i++) {
+for (var j = 0; j < 3; j++) {
+if (i != j) {
+this.axes[i][j] = 0;
+} else {
+this.axes[i][j] = 1;
+}}
+}
+});
+Clazz.defineMethod (c$, "findWidth", 
+function () {
+this.max =  Clazz.newFloatArray (3, 0);
+this.min =  Clazz.newFloatArray (3, 0);
+this.max[0] = -1.0E30;
+this.max[1] = -1.0E30;
+this.max[2] = -1.0E30;
+this.min[0] = 1e30;
+this.min[1] = 1e30;
+this.min[2] = 1e30;
+for (var i = 0; i < 3; i++) {
+for (var j = 0; j < this.npoint; j++) {
+var sp = this.points.elementAt (j);
+if (sp.coord[i] >= this.max[i]) {
+this.max[i] = sp.coord[i];
+}if (sp.coord[i] <= this.min[i]) {
+this.min[i] = sp.coord[i];
+}}
+}
+this.$width[0] = Math.abs (this.max[0] - this.min[0]);
+this.$width[1] = Math.abs (this.max[1] - this.min[1]);
+this.$width[2] = Math.abs (this.max[2] - this.min[2]);
+this.maxwidth = this.$width[0];
+if (this.$width[1] > this.$width[0]) {
+this.maxwidth = this.$width[1];
+}if (this.$width[2] > this.$width[1]) {
+this.maxwidth = this.$width[2];
+}});
+Clazz.defineMethod (c$, "findScale", 
+function () {
+var dim;
+var width;
+var height;
+if (this.getSize ().width != 0) {
+width = this.getSize ().width;
+height = this.getSize ().height;
+} else {
+width = this.prefsize.width;
+height = this.prefsize.height;
+}if (width < height) {
+dim = width;
+} else {
+dim = height;
+}return dim * this.scalefactor / (2 * this.maxwidth);
+});
+Clazz.defineMethod (c$, "findCentre", 
+function () {
+this.findWidth ();
+this.centre[0] = (this.max[0] + this.min[0]) / 2;
+this.centre[1] = (this.max[1] + this.min[1]) / 2;
+this.centre[2] = (this.max[2] + this.min[2]) / 2;
+});
+Clazz.overrideMethod (c$, "getPreferredSize", 
+function () {
+if (this.prefsize != null) {
+return this.prefsize;
+} else {
+return  new java.awt.Dimension (400, 400);
+}});
+Clazz.overrideMethod (c$, "getMinimumSize", 
+function () {
+return this.getPreferredSize ();
+});
+Clazz.overrideMethod (c$, "update", 
+function (g) {
+this.paint (g);
+}, "java.awt.Graphics");
+Clazz.defineMethod (c$, "PaintComponent", 
+function (g) {
+if (this.points == null) {
+g.setFont ( new java.awt.Font ("Verdana", 0, 18));
+g.drawString (jalview.util.MessageManager.getString ("label.calculating_pca") + "....", 20, Clazz.doubleToInt (this.getSize ().height / 2));
+} else {
+if ((this.img == null) || (this.prefsize.width != this.getSize ().width) || (this.prefsize.height != this.getSize ().height)) {
+this.prefsize.width = this.getSize ().width;
+this.prefsize.height = this.getSize ().height;
+this.scale = this.findScale ();
+this.img = this.createImage (this.getSize ().width, this.getSize ().height);
+this.ig = this.img.getGraphics ();
+}this.drawBackground (this.ig, java.awt.Color.black);
+this.drawScene (this.ig);
+if (this.$drawAxes == true) {
+this.drawAxes (this.ig);
+}if (this.tooltip != null) {
+this.ig.setColor (java.awt.Color.red);
+this.ig.drawString (this.tooltip, this.toolx, this.tooly);
+}g.drawImage (this.img, 0, 0, this);
+}}, "java.awt.Graphics");
+Clazz.defineMethod (c$, "drawAxes", 
+function (g) {
+g.setColor (java.awt.Color.yellow);
+for (var i = 0; i < 3; i++) {
+g.drawLine (Clazz.doubleToInt (this.getSize ().width / 2), Clazz.doubleToInt (this.getSize ().height / 2), Clazz.floatToInt (this.axes[i][0] * this.scale * this.max[0] + Clazz.doubleToInt (this.getSize ().width / 2)), Clazz.floatToInt (this.axes[i][1] * this.scale * this.max[1] + Clazz.doubleToInt (this.getSize ().height / 2)));
+}
+}, "java.awt.Graphics");
+Clazz.defineMethod (c$, "drawBackground", 
+function (g, col) {
+g.setColor (col);
+g.fillRect (0, 0, this.prefsize.width, this.prefsize.height);
+}, "java.awt.Graphics,java.awt.Color");
+Clazz.defineMethod (c$, "drawScene", 
+function (g) {
+var halfwidth = Clazz.doubleToInt (this.getSize ().width / 2);
+var halfheight = Clazz.doubleToInt (this.getSize ().height / 2);
+for (var i = 0; i < this.npoint; i++) {
+var sp = this.points.elementAt (i);
+var x = Clazz.floatToInt ((sp.coord[0] - this.centre[0]) * this.scale) + halfwidth;
+var y = Clazz.floatToInt ((sp.coord[1] - this.centre[1]) * this.scale) + halfheight;
+var z = sp.coord[1] - this.centre[2];
+if (this.av.getSequenceColour (sp.sequence) === java.awt.Color.black) {
+g.setColor (java.awt.Color.white);
+} else {
+g.setColor (this.av.getSequenceColour (sp.sequence));
+}if (this.av.getSelectionGroup () != null) {
+if (this.av.getSelectionGroup ().getSequences (null).contains ((this.points.elementAt (i)).sequence)) {
+g.setColor (java.awt.Color.gray);
+}}if (z < 0) {
+g.setColor (g.getColor ().darker ());
+}g.fillRect (x - 3, y - 3, 6, 6);
+if (this.$showLabels) {
+g.setColor (java.awt.Color.red);
+g.drawString ((this.points.elementAt (i)).sequence.getName (), x - 3, y - 4);
+}}
+}, "java.awt.Graphics");
+Clazz.defineMethod (c$, "minimumsize", 
+function () {
+return this.prefsize;
+});
+Clazz.defineMethod (c$, "preferredsize", 
+function () {
+return this.prefsize;
+});
+Clazz.overrideMethod (c$, "keyTyped", 
+function (evt) {
+}, "java.awt.event.KeyEvent");
+Clazz.overrideMethod (c$, "keyReleased", 
+function (evt) {
+}, "java.awt.event.KeyEvent");
+Clazz.overrideMethod (c$, "keyPressed", 
+function (evt) {
+if (evt.getKeyCode () == 38) {
+this.scalefactor = (this.scalefactor * 1.1);
+this.scale = this.findScale ();
+} else if (evt.getKeyCode () == 40) {
+this.scalefactor = (this.scalefactor * 0.9);
+this.scale = this.findScale ();
+} else if (evt.getKeyChar () == 's') {
+System.err.println ("DEBUG: Rectangle selection");
+if (this.rectx2 != -1 && this.recty2 != -1) {
+this.rectSelect (this.rectx1, this.recty1, this.rectx2, this.recty2);
+}}this.repaint ();
+}, "java.awt.event.KeyEvent");
+Clazz.defineMethod (c$, "printPoints", 
+function () {
+for (var i = 0; i < this.npoint; i++) {
+var sp = this.points.elementAt (i);
+jalview.util.Format.printLong (System.out, "%5d ", i);
+for (var j = 0; j < 3; j++) {
+jalview.util.Format.printDouble (System.out, "%13.3f  ", sp.coord[j]);
+}
+System.out.println ();
+}
+});
+Clazz.overrideMethod (c$, "mouseClicked", 
+function (evt) {
+}, "java.awt.event.MouseEvent");
+Clazz.overrideMethod (c$, "mouseEntered", 
+function (evt) {
+}, "java.awt.event.MouseEvent");
+Clazz.overrideMethod (c$, "mouseExited", 
+function (evt) {
+}, "java.awt.event.MouseEvent");
+Clazz.overrideMethod (c$, "mouseReleased", 
+function (evt) {
+}, "java.awt.event.MouseEvent");
+Clazz.overrideMethod (c$, "mousePressed", 
+function (evt) {
+var x = evt.getX ();
+var y = evt.getY ();
+this.mx = x;
+this.my = y;
+this.omx = this.mx;
+this.omy = this.my;
+this.startx = x;
+this.starty = y;
+this.rectx1 = x;
+this.recty1 = y;
+this.rectx2 = -1;
+this.recty2 = -1;
+var found = this.findPoint (x, y);
+if (found != null) {
+if (this.av.getSelectionGroup () != null) {
+this.av.getSelectionGroup ().addOrRemove (found, true);
+this.av.getSelectionGroup ().setEndRes (this.av.getAlignment ().getWidth () - 1);
+} else {
+this.av.setSelectionGroup ( new jalview.datamodel.SequenceGroup ());
+this.av.getSelectionGroup ().addOrRemove (found, true);
+this.av.getSelectionGroup ().setEndRes (this.av.getAlignment ().getWidth () - 1);
+}jalview.appletgui.PaintRefresher.Refresh (this, this.av.getSequenceSetId ());
+this.av.sendSelection ();
+}this.repaint ();
+}, "java.awt.event.MouseEvent");
+Clazz.overrideMethod (c$, "mouseMoved", 
+function (evt) {
+var found = this.findPoint (evt.getX (), evt.getY ());
+if (found == null) {
+this.tooltip = null;
+} else {
+this.tooltip = found.getName ();
+this.toolx = evt.getX ();
+this.tooly = evt.getY ();
+}this.repaint ();
+}, "java.awt.event.MouseEvent");
+Clazz.overrideMethod (c$, "mouseDragged", 
+function (evt) {
+this.mx = evt.getX ();
+this.my = evt.getY ();
+this.rotmat.setIdentity ();
+this.rotmat.rotate (this.my - this.omy, 'x');
+this.rotmat.rotate (this.mx - this.omx, 'y');
+for (var i = 0; i < this.npoint; i++) {
+var sp = this.points.elementAt (i);
+sp.coord[0] -= this.centre[0];
+sp.coord[1] -= this.centre[1];
+sp.coord[2] -= this.centre[2];
+sp.coord = this.rotmat.vectorMultiply (sp.coord);
+sp.coord[0] += this.centre[0];
+sp.coord[1] += this.centre[1];
+sp.coord[2] += this.centre[2];
+}
+for (var i = 0; i < 3; i++) {
+this.axes[i] = this.rotmat.vectorMultiply (this.axes[i]);
+}
+this.omx = this.mx;
+this.omy = this.my;
+this.paint (this.getGraphics ());
+}, "java.awt.event.MouseEvent");
+Clazz.defineMethod (c$, "rectSelect", 
+function (x1, y1, x2, y2) {
+for (var i = 0; i < this.npoint; i++) {
+var sp = this.points.elementAt (i);
+var tmp1 = Clazz.doubleToInt ((sp.coord[0] - this.centre[0]) * this.scale + this.getSize ().width / 2.0);
+var tmp2 = Clazz.doubleToInt ((sp.coord[1] - this.centre[1]) * this.scale + this.getSize ().height / 2.0);
+if (tmp1 > x1 && tmp1 < x2 && tmp2 > y1 && tmp2 < y2) {
+if (this.av != null) {
+if (!this.av.getSelectionGroup ().getSequences (null).contains (sp.sequence)) {
+this.av.getSelectionGroup ().addSequence (sp.sequence, true);
+}}}}
+}, "~N,~N,~N,~N");
+Clazz.defineMethod (c$, "findPoint", 
+function (x, y) {
+var halfwidth = Clazz.doubleToInt (this.getSize ().width / 2);
+var halfheight = Clazz.doubleToInt (this.getSize ().height / 2);
+var found = -1;
+for (var i = 0; i < this.npoint; i++) {
+var sp = this.points.elementAt (i);
+var px = Clazz.floatToInt ((sp.coord[0] - this.centre[0]) * this.scale) + halfwidth;
+var py = Clazz.floatToInt ((sp.coord[1] - this.centre[1]) * this.scale) + halfheight;
+if (Math.abs (px - x) < 3 && Math.abs (py - y) < 3) {
+found = i;
+}}
+if (found != -1) {
+return (this.points.elementAt (found)).sequence;
+} else {
+return null;
+}}, "~N,~N");
+});