JAL-1807 still testing
[jalviewjs.git] / bin / jalview / appletgui / TreeCanvas.js
index 69da9f2..da76a3e 100644 (file)
-Clazz.declarePackage ("jalview.appletgui");
-Clazz.load (["awt2swing.Panel", "java.awt.event.MouseListener", "$.MouseMotionListener", "java.util.Hashtable"], "jalview.appletgui.TreeCanvas", ["jalview.analysis.Conservation", "jalview.appletgui.PaintRefresher", "jalview.datamodel.SequenceGroup", "$.SequenceI", "$.SequenceNode", "jalview.schemes.ColourSchemeProperty", "$.ResidueProperties", "$.UserColourScheme", "jalview.util.Format", "$.MappingUtils", "java.awt.Color", "$.Dimension", "$.Point", "$.Rectangle", "java.util.Vector"], function () {
-c$ = Clazz.decorateAsClass (function () {
-this.tree = null;
-this.scrollPane = null;
-this.av = null;
-this.$font = null;
-this.fitToWindow = true;
-this.showDistances = false;
-this.showBootstrap = false;
-this.markPlaceholders = false;
-this.offx = 20;
-this.offy = 0;
-this.threshold = 0;
-this.longestName = null;
-this.labelLength = -1;
-this.nameHash = null;
-this.nodeHash = null;
-this.highlightNode = null;
-this.ap = null;
-Clazz.instantialize (this, arguments);
-}, jalview.appletgui, "TreeCanvas", awt2swing.Panel, [java.awt.event.MouseListener, java.awt.event.MouseMotionListener]);
-Clazz.prepareFields (c$, function () {
-this.nameHash =  new java.util.Hashtable ();
-this.nodeHash =  new java.util.Hashtable ();
-});
-Clazz.makeConstructor (c$, 
-function (ap, scroller) {
-Clazz.superConstructor (this, jalview.appletgui.TreeCanvas, []);
-this.ap = ap;
-this.av = ap.av;
-this.$font = this.av.getFont ();
-this.scrollPane = scroller;
-this.addMouseListener (this);
-this.addMouseMotionListener (this);
-this.setLayout (null);
-jalview.appletgui.PaintRefresher.Register (this, this.av.getSequenceSetId ());
-}, "jalview.appletgui.AlignmentPanel,awt2swing.ScrollPane");
-Clazz.defineMethod (c$, "treeSelectionChanged", 
-function (sequence) {
-var selected = this.av.getSelectionGroup ();
-if (selected == null) {
-selected =  new jalview.datamodel.SequenceGroup ();
-this.av.setSelectionGroup (selected);
-}selected.setEndRes (this.av.getAlignment ().getWidth () - 1);
-selected.addOrRemove (sequence, true);
-}, "jalview.datamodel.SequenceI");
-Clazz.defineMethod (c$, "setTree", 
-function (tree) {
-this.tree = tree;
-tree.findHeight (tree.getTopNode ());
-var leaves = tree.findLeaves (tree.getTopNode (),  new java.util.Vector ());
-var has_placeholders = false;
-this.longestName = "";
-for (var i = 0; i < leaves.size (); i++) {
-var lf = leaves.elementAt (i);
-if (lf.isPlaceholder ()) {
-has_placeholders = true;
-}if (this.longestName.length < (lf.element ()).getName ().length) {
-this.longestName = " * " + (lf.element ()).getName ();
-}}
-this.setMarkPlaceholders (has_placeholders);
-}, "jalview.analysis.NJTree");
-Clazz.defineMethod (c$, "drawNode", 
-function (g, node, chunk, scale, width, offx, offy) {
-if (node == null) {
-return;
-}if (node.left () == null && node.right () == null) {
-var height = node.height;
-var dist = node.dist;
-var xstart = Clazz.floatToInt ((height - dist) * scale) + offx;
-var xend = Clazz.floatToInt (height * scale) + offx;
-var ypos = Clazz.floatToInt (node.ycount * chunk) + offy;
-if (Clazz.instanceOf (node.element (), jalview.datamodel.SequenceI)) {
-var seq = node.element ();
-if (this.av.getSequenceColour (seq) === java.awt.Color.white) {
-g.setColor (java.awt.Color.black);
-} else {
-g.setColor (this.av.getSequenceColour (seq).darker ());
-}} else {
-g.setColor (java.awt.Color.black);
-}g.drawLine (xstart, ypos, xend, ypos);
-var nodeLabel = "";
-if (this.showDistances && node.dist > 0) {
-nodeLabel =  new jalview.util.Format ("%-.2f").formDouble (node.dist);
-}if (this.showBootstrap) {
-var btstrap = node.getBootstrap ();
-if (btstrap > -1) {
-if (this.showDistances) {
-nodeLabel = nodeLabel + " : ";
-}nodeLabel = nodeLabel + String.valueOf (node.getBootstrap ());
-}}if (!nodeLabel.equals ("")) {
-g.drawString (nodeLabel, xstart + 2, ypos - 2);
-}var name = (this.markPlaceholders && node.isPlaceholder ()) ? (" * " + node.getName ()) : node.getName ();
-var fm = g.getFontMetrics (this.$font);
-var charWidth = fm.stringWidth (name) + 3;
-var charHeight = fm.getHeight ();
-var rect =  new java.awt.Rectangle (xend + 10, ypos - charHeight, charWidth, charHeight);
-this.nameHash.put (node.element (), rect);
-var selected = this.av.getSelectionGroup ();
-if (selected != null && selected.getSequences (null).contains (node.element ())) {
-g.setColor (java.awt.Color.gray);
-g.fillRect (xend + 10, ypos - charHeight + 3, charWidth, charHeight);
-g.setColor (java.awt.Color.white);
-}g.drawString (name, xend + 10, ypos);
-g.setColor (java.awt.Color.black);
-} else {
-this.drawNode (g, node.left (), chunk, scale, width, offx, offy);
-this.drawNode (g, node.right (), chunk, scale, width, offx, offy);
-var height = node.height;
-var dist = node.dist;
-var xstart = Clazz.floatToInt ((height - dist) * scale) + offx;
-var xend = Clazz.floatToInt (height * scale) + offx;
-var ypos = Clazz.floatToInt (node.ycount * chunk) + offy;
-g.setColor (node.color.darker ());
-g.drawLine (xstart, ypos, xend, ypos);
-if (node === this.highlightNode) {
-g.fillRect (xend - 3, ypos - 3, 6, 6);
-} else {
-g.fillRect (xend - 2, ypos - 2, 4, 4);
-}var ystart = Clazz.floatToInt ((node.left ()).ycount * chunk) + offy;
-var yend = Clazz.floatToInt ((node.right ()).ycount * chunk) + offy;
-var pos =  new java.awt.Rectangle (xend - 2, ypos - 2, 5, 5);
-this.nodeHash.put (node, pos);
-g.drawLine (Clazz.floatToInt (height * scale) + offx, ystart, Clazz.floatToInt (height * scale) + offx, yend);
-var nodeLabel = "";
-if (this.showDistances && (node.dist > 0)) {
-nodeLabel =  new jalview.util.Format ("%-.2f").formDouble (node.dist);
-}if (this.showBootstrap) {
-var btstrap = node.getBootstrap ();
-if (btstrap > -1) {
-if (this.showDistances) {
-nodeLabel = nodeLabel + " : ";
-}nodeLabel = nodeLabel + String.valueOf (node.getBootstrap ());
-}}if (!nodeLabel.equals ("")) {
-g.drawString (nodeLabel, xstart + 2, ypos - 2);
-}}}, "java.awt.Graphics,jalview.datamodel.SequenceNode,~N,~N,~N,~N,~N");
-Clazz.defineMethod (c$, "findElement", 
-function (x, y) {
-var keys = this.nameHash.keys ();
-while (keys.hasMoreElements ()) {
-var ob = keys.nextElement ();
-var rect = this.nameHash.get (ob);
-if (x >= rect.x && x <= (rect.x + rect.width) && y >= rect.y && y <= (rect.y + rect.height)) {
-return ob;
-}}
-keys = this.nodeHash.keys ();
-while (keys.hasMoreElements ()) {
-var ob = keys.nextElement ();
-var rect = this.nodeHash.get (ob);
-if (x >= rect.x && x <= (rect.x + rect.width) && y >= rect.y && y <= (rect.y + rect.height)) {
-return ob;
-}}
-return null;
-}, "~N,~N");
-Clazz.defineMethod (c$, "pickNodes", 
-function (pickBox) {
-var width = this.getSize ().width;
-var height = this.getSize ().height;
-var top = this.tree.getTopNode ();
-var wscale = (width * .8 - this.offx * 2) / this.tree.getMaxHeight ();
-if (top.count == 0) {
-top.count = (top.left ()).count + (top.right ()).count;
-}var chunk = (height - this.offy) / top.count;
-this.pickNode (pickBox, top, chunk, wscale, width, this.offx, this.offy);
-}, "java.awt.Rectangle");
-Clazz.defineMethod (c$, "pickNode", 
-function (pickBox, node, chunk, scale, width, offx, offy) {
-if (node == null) {
-return;
-}if (node.left () == null && node.right () == null) {
-var height = node.height;
-var xend = Clazz.floatToInt (height * scale) + offx;
-var ypos = Clazz.floatToInt (node.ycount * chunk) + offy;
-if (pickBox.contains ( new java.awt.Point (xend, ypos))) {
-if (Clazz.instanceOf (node.element (), jalview.datamodel.SequenceI)) {
-var seq = node.element ();
-var sg = this.av.getSelectionGroup ();
-if (sg != null) {
-sg.addOrRemove (seq, true);
-}}}} else {
-this.pickNode (pickBox, node.left (), chunk, scale, width, offx, offy);
-this.pickNode (pickBox, node.right (), chunk, scale, width, offx, offy);
-}}, "java.awt.Rectangle,jalview.datamodel.SequenceNode,~N,~N,~N,~N,~N");
-Clazz.defineMethod (c$, "setColor", 
-function (node, c) {
-if (node == null) {
-return;
-}if (node.left () == null && node.right () == null) {
-node.color = c;
-if (Clazz.instanceOf (node.element (), jalview.datamodel.SequenceI)) {
-this.av.setSequenceColour (node.element (), c);
-}} else {
-node.color = c;
-this.setColor (node.left (), c);
-this.setColor (node.right (), c);
-}}, "jalview.datamodel.SequenceNode,java.awt.Color");
-Clazz.overrideMethod (c$, "update", 
-function (g) {
-this.paint (g);
-}, "java.awt.Graphics");
-Clazz.overrideMethod (c$, "paintComponent", 
-function (g) {
-if (this.tree == null) {
-return;
-}if (this.nameHash.size () == 0) {
-this.repaint ();
-}var width = this.scrollPane.getSize ().width;
-var height = this.scrollPane.getSize ().height;
-if (!this.fitToWindow) {
-height = g.getFontMetrics (this.$font).getHeight () * this.nameHash.size ();
-}if (this.getSize ().width > width) {
-this.setSize ( new java.awt.Dimension (width, height));
-this.scrollPane.validate ();
-return;
-}this.setSize ( new java.awt.Dimension (width, height));
-g.setFont (this.$font);
-this.draw (g, width, height);
-this.validate ();
-}, "java.awt.Graphics");
-Clazz.defineMethod (c$, "draw", 
-function (g, width, height) {
-this.offy = this.$font.getSize () + 10;
-g.setColor (java.awt.Color.white);
-g.fillRect (0, 0, width, height);
-this.labelLength = g.getFontMetrics (this.$font).stringWidth (this.longestName) + 20;
-var wscale = (width - this.labelLength - this.offx * 2) / this.tree.getMaxHeight ();
-var top = this.tree.getTopNode ();
-if (top.count == 0) {
-top.count = (top.left ()).count + (top.right ()).count;
-}var chunk = (height - this.offy) / top.count;
-this.drawNode (g, this.tree.getTopNode (), chunk, wscale, width, this.offx, this.offy);
-if (this.threshold != 0) {
-if (this.av.getCurrentTree () === this.tree) {
-g.setColor (java.awt.Color.red);
-} else {
-g.setColor (java.awt.Color.gray);
-}var x = Clazz.floatToInt (this.threshold * (this.getSize ().width - this.labelLength - 2 * this.offx) + this.offx);
-g.drawLine (x, 0, x, this.getSize ().height);
-}}, "java.awt.Graphics,~N,~N");
-Clazz.overrideMethod (c$, "mouseReleased", 
-function (e) {
-}, "java.awt.event.MouseEvent");
-Clazz.overrideMethod (c$, "mouseEntered", 
-function (e) {
-}, "java.awt.event.MouseEvent");
-Clazz.overrideMethod (c$, "mouseExited", 
-function (e) {
-}, "java.awt.event.MouseEvent");
-Clazz.overrideMethod (c$, "mouseClicked", 
-function (evt) {
-if (this.highlightNode != null) {
-if (evt.getClickCount () > 1) {
-this.tree.swapNodes (this.highlightNode);
-this.tree.reCount (this.tree.getTopNode ());
-this.tree.findHeight (this.tree.getTopNode ());
-} else {
-var leaves =  new java.util.Vector ();
-this.tree.findLeaves (this.highlightNode, leaves);
-for (var i = 0; i < leaves.size (); i++) {
-var seq = (leaves.elementAt (i)).element ();
-this.treeSelectionChanged (seq);
-}
-}jalview.appletgui.PaintRefresher.Refresh (this, this.av.getSequenceSetId ());
-this.repaint ();
-this.av.sendSelection ();
-}}, "java.awt.event.MouseEvent");
-Clazz.overrideMethod (c$, "mouseDragged", 
-function (ect) {
-}, "java.awt.event.MouseEvent");
-Clazz.overrideMethod (c$, "mouseMoved", 
-function (evt) {
-this.av.setCurrentTree (this.tree);
-var ob = this.findElement (evt.getX (), evt.getY ());
-if (Clazz.instanceOf (ob, jalview.datamodel.SequenceNode)) {
-this.highlightNode = ob;
-this.repaint ();
-} else {
-if (this.highlightNode != null) {
-this.highlightNode = null;
-this.repaint ();
-}}}, "java.awt.event.MouseEvent");
-Clazz.overrideMethod (c$, "mousePressed", 
-function (e) {
-this.av.setCurrentTree (this.tree);
-var x = e.getX ();
-var y = e.getY ();
-var ob = this.findElement (x, y);
-if (Clazz.instanceOf (ob, jalview.datamodel.SequenceI)) {
-this.treeSelectionChanged (ob);
-jalview.appletgui.PaintRefresher.Refresh (this, this.av.getSequenceSetId ());
-this.repaint ();
-this.av.sendSelection ();
-return;
-} else if (!(Clazz.instanceOf (ob, jalview.datamodel.SequenceNode))) {
-if (this.tree.getMaxHeight () != 0) {
-this.threshold = (x - this.offx) / (this.getSize ().width - this.labelLength - 2 * this.offx);
-this.tree.getGroups ().removeAllElements ();
-this.tree.groupNodes (this.tree.getTopNode (), this.threshold);
-this.setColor (this.tree.getTopNode (), java.awt.Color.black);
-this.av.setSelectionGroup (null);
-this.av.getAlignment ().deleteAllGroups ();
-this.av.clearSequenceColours ();
-var codingComplement = this.av.getCodingComplement ();
-if (codingComplement != null) {
-codingComplement.setSelectionGroup (null);
-codingComplement.getAlignment ().deleteAllGroups ();
-codingComplement.clearSequenceColours ();
-}this.colourGroups ();
-}}jalview.appletgui.PaintRefresher.Refresh (this, this.av.getSequenceSetId ());
-this.repaint ();
-}, "java.awt.event.MouseEvent");
-Clazz.defineMethod (c$, "colourGroups", 
-function () {
-for (var i = 0; i < this.tree.getGroups ().size (); i++) {
-var col =  new java.awt.Color (Clazz.doubleToInt (Math.random () * 255), Clazz.doubleToInt (Math.random () * 255), Clazz.doubleToInt (Math.random () * 255));
-this.setColor (this.tree.getGroups ().elementAt (i), col.brighter ());
-var l = this.tree.findLeaves (this.tree.getGroups ().elementAt (i),  new java.util.Vector ());
-var sequences =  new java.util.Vector ();
-for (var j = 0; j < l.size (); j++) {
-var s1 = (l.elementAt (j)).element ();
-if (!sequences.contains (s1)) {
-sequences.addElement (s1);
-}}
-var cs = null;
-var sg =  new jalview.datamodel.SequenceGroup (sequences, "", cs, true, true, false, 0, this.av.getAlignment ().getWidth () - 1);
-if (this.av.getGlobalColourScheme () != null) {
-if (Clazz.instanceOf (this.av.getGlobalColourScheme (), jalview.schemes.UserColourScheme)) {
-cs =  new jalview.schemes.UserColourScheme ((this.av.getGlobalColourScheme ()).getColours ());
-} else {
-cs = jalview.schemes.ColourSchemeProperty.getColour (sg, jalview.schemes.ColourSchemeProperty.getColourName (this.av.getGlobalColourScheme ()));
-}if (cs != null) {
-cs.setThreshold (this.av.getGlobalColourScheme ().getThreshold (), this.av.isIgnoreGapsConsensus ());
-}}sg.cs = cs;
-sg.setName ("JTreeGroup:" + sg.hashCode ());
-sg.setIdColour (col);
-if (this.av.getGlobalColourScheme () != null && this.av.getGlobalColourScheme ().conservationApplied ()) {
-var c =  new jalview.analysis.Conservation ("Group", jalview.schemes.ResidueProperties.propHash, 3, sg.getSequences (null), sg.getStartRes (), sg.getEndRes ());
-c.calculate ();
-c.verdict (false, this.av.getConsPercGaps ());
-cs.setConservation (c);
-sg.cs = cs;
-}this.av.getAlignment ().addGroup (sg);
-this.av.getAlignment ().addGroup (sg);
-var codingComplement = this.av.getCodingComplement ();
-if (codingComplement != null) {
-var mappedGroup = jalview.util.MappingUtils.mapSequenceGroup (sg, this.av, codingComplement);
-if (mappedGroup.getSequences ().size () > 0) {
-codingComplement.getAlignment ().addGroup (mappedGroup);
-for (var seq, $seq = mappedGroup.getSequences ().iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) {
-codingComplement.setSequenceColour (seq, col);
-}
-}}}
-this.ap.updateAnnotation ();
-if (this.av.getCodingComplement () != null) {
-(this.av.getCodingComplement ()).firePropertyChange ("alignment", null, this.ap.av.getAlignment ().getSequences ());
-}});
-Clazz.defineMethod (c$, "setShowDistances", 
-function (state) {
-this.showDistances = state;
-this.repaint ();
-}, "~B");
-Clazz.defineMethod (c$, "setShowBootstrap", 
-function (state) {
-this.showBootstrap = state;
-this.repaint ();
-}, "~B");
-Clazz.defineMethod (c$, "setMarkPlaceholders", 
-function (state) {
-this.markPlaceholders = state;
-this.repaint ();
-}, "~B");
-Clazz.defineStatics (c$,
-"PLACEHOLDER", " * ");
-});
+Clazz.declarePackage ("jalview.appletgui");\r
+Clazz.load (["awt2swing.Panel", "java.awt.event.MouseListener", "$.MouseMotionListener", "java.util.Hashtable"], "jalview.appletgui.TreeCanvas", ["jalview.analysis.Conservation", "jalview.appletgui.PaintRefresher", "jalview.datamodel.SequenceGroup", "$.SequenceI", "$.SequenceNode", "jalview.schemes.ColourSchemeProperty", "$.ResidueProperties", "$.UserColourScheme", "jalview.util.Format", "$.MappingUtils", "java.awt.Color", "$.Dimension", "$.Point", "$.Rectangle", "java.util.Vector"], function () {\r
+c$ = Clazz.decorateAsClass (function () {\r
+this.tree = null;\r
+this.scrollPane = null;\r
+this.av = null;\r
+this.$font = null;\r
+this.fitToWindow = true;\r
+this.showDistances = false;\r
+this.showBootstrap = false;\r
+this.markPlaceholders = false;\r
+this.offx = 20;\r
+this.offy = 0;\r
+this.threshold = 0;\r
+this.longestName = null;\r
+this.labelLength = -1;\r
+this.nameHash = null;\r
+this.nodeHash = null;\r
+this.highlightNode = null;\r
+this.ap = null;\r
+Clazz.instantialize (this, arguments);\r
+}, jalview.appletgui, "TreeCanvas", awt2swing.Panel, [java.awt.event.MouseListener, java.awt.event.MouseMotionListener]);\r
+Clazz.prepareFields (c$, function () {\r
+this.nameHash =  new java.util.Hashtable ();\r
+this.nodeHash =  new java.util.Hashtable ();\r
+});\r
+Clazz.makeConstructor (c$, \r
+function (ap, scroller) {\r
+Clazz.superConstructor (this, jalview.appletgui.TreeCanvas, []);\r
+this.ap = ap;\r
+this.av = ap.av;\r
+this.$font = this.av.getFont ();\r
+this.scrollPane = scroller;\r
+this.addMouseListener (this);\r
+this.addMouseMotionListener (this);\r
+this.setLayout (null);\r
+jalview.appletgui.PaintRefresher.Register (this, this.av.getSequenceSetId ());\r
+}, "jalview.appletgui.AlignmentPanel,awt2swing.ScrollPane");\r
+Clazz.defineMethod (c$, "treeSelectionChanged", \r
+function (sequence) {\r
+var selected = this.av.getSelectionGroup ();\r
+if (selected == null) {\r
+selected =  new jalview.datamodel.SequenceGroup ();\r
+this.av.setSelectionGroup (selected);\r
+}selected.setEndRes (this.av.getAlignment ().getWidth () - 1);\r
+selected.addOrRemove (sequence, true);\r
+}, "jalview.datamodel.SequenceI");\r
+Clazz.defineMethod (c$, "setTree", \r
+function (tree) {\r
+this.tree = tree;\r
+tree.findHeight (tree.getTopNode ());\r
+var leaves = tree.findLeaves (tree.getTopNode (),  new java.util.Vector ());\r
+var has_placeholders = false;\r
+this.longestName = "";\r
+for (var i = 0; i < leaves.size (); i++) {\r
+var lf = leaves.elementAt (i);\r
+if (lf.isPlaceholder ()) {\r
+has_placeholders = true;\r
+}if (this.longestName.length < (lf.element ()).getName ().length) {\r
+this.longestName = " * " + (lf.element ()).getName ();\r
+}}\r
+this.setMarkPlaceholders (has_placeholders);\r
+}, "jalview.analysis.NJTree");\r
+Clazz.defineMethod (c$, "drawNode", \r
+function (g, node, chunk, scale, width, offx, offy) {\r
+if (node == null) {\r
+return;\r
+}if (node.left () == null && node.right () == null) {\r
+var height = node.height;\r
+var dist = node.dist;\r
+var xstart = Clazz.floatToInt ((height - dist) * scale) + offx;\r
+var xend = Clazz.floatToInt (height * scale) + offx;\r
+var ypos = Clazz.floatToInt (node.ycount * chunk) + offy;\r
+if (Clazz.instanceOf (node.element (), jalview.datamodel.SequenceI)) {\r
+var seq = node.element ();\r
+if (this.av.getSequenceColour (seq) === java.awt.Color.white) {\r
+g.setColor (java.awt.Color.black);\r
+} else {\r
+g.setColor (this.av.getSequenceColour (seq).darker ());\r
+}} else {\r
+g.setColor (java.awt.Color.black);\r
+}g.drawLine (xstart, ypos, xend, ypos);\r
+var nodeLabel = "";\r
+if (this.showDistances && node.dist > 0) {\r
+nodeLabel =  new jalview.util.Format ("%-.2f").formDouble (node.dist);\r
+}if (this.showBootstrap) {\r
+var btstrap = node.getBootstrap ();\r
+if (btstrap > -1) {\r
+if (this.showDistances) {\r
+nodeLabel = nodeLabel + " : ";\r
+}nodeLabel = nodeLabel + String.valueOf (node.getBootstrap ());\r
+}}if (!nodeLabel.equals ("")) {\r
+g.drawString (nodeLabel, xstart + 2, ypos - 2);\r
+}var name = (this.markPlaceholders && node.isPlaceholder ()) ? (" * " + node.getName ()) : node.getName ();\r
+var fm = g.getFontMetrics (this.$font);\r
+var charWidth = fm.stringWidth (name) + 3;\r
+var charHeight = fm.getHeight ();\r
+var rect =  new java.awt.Rectangle (xend + 10, ypos - charHeight, charWidth, charHeight);\r
+this.nameHash.put (node.element (), rect);\r
+var selected = this.av.getSelectionGroup ();\r
+if (selected != null && selected.getSequences (null).contains (node.element ())) {\r
+g.setColor (java.awt.Color.gray);\r
+g.fillRect (xend + 10, ypos - charHeight + 3, charWidth, charHeight);\r
+g.setColor (java.awt.Color.white);\r
+}g.drawString (name, xend + 10, ypos);\r
+g.setColor (java.awt.Color.black);\r
+} else {\r
+this.drawNode (g, node.left (), chunk, scale, width, offx, offy);\r
+this.drawNode (g, node.right (), chunk, scale, width, offx, offy);\r
+var height = node.height;\r
+var dist = node.dist;\r
+var xstart = Clazz.floatToInt ((height - dist) * scale) + offx;\r
+var xend = Clazz.floatToInt (height * scale) + offx;\r
+var ypos = Clazz.floatToInt (node.ycount * chunk) + offy;\r
+g.setColor (node.color.darker ());\r
+g.drawLine (xstart, ypos, xend, ypos);\r
+if (node === this.highlightNode) {\r
+g.fillRect (xend - 3, ypos - 3, 6, 6);\r
+} else {\r
+g.fillRect (xend - 2, ypos - 2, 4, 4);\r
+}var ystart = Clazz.floatToInt ((node.left ()).ycount * chunk) + offy;\r
+var yend = Clazz.floatToInt ((node.right ()).ycount * chunk) + offy;\r
+var pos =  new java.awt.Rectangle (xend - 2, ypos - 2, 5, 5);\r
+this.nodeHash.put (node, pos);\r
+g.drawLine (Clazz.floatToInt (height * scale) + offx, ystart, Clazz.floatToInt (height * scale) + offx, yend);\r
+var nodeLabel = "";\r
+if (this.showDistances && (node.dist > 0)) {\r
+nodeLabel =  new jalview.util.Format ("%-.2f").formDouble (node.dist);\r
+}if (this.showBootstrap) {\r
+var btstrap = node.getBootstrap ();\r
+if (btstrap > -1) {\r
+if (this.showDistances) {\r
+nodeLabel = nodeLabel + " : ";\r
+}nodeLabel = nodeLabel + String.valueOf (node.getBootstrap ());\r
+}}if (!nodeLabel.equals ("")) {\r
+g.drawString (nodeLabel, xstart + 2, ypos - 2);\r
+}}}, "java.awt.Graphics,jalview.datamodel.SequenceNode,~N,~N,~N,~N,~N");\r
+Clazz.defineMethod (c$, "findElement", \r
+function (x, y) {\r
+var keys = this.nameHash.keys ();\r
+while (keys.hasMoreElements ()) {\r
+var ob = keys.nextElement ();\r
+var rect = this.nameHash.get (ob);\r
+if (x >= rect.x && x <= (rect.x + rect.width) && y >= rect.y && y <= (rect.y + rect.height)) {\r
+return ob;\r
+}}\r
+keys = this.nodeHash.keys ();\r
+while (keys.hasMoreElements ()) {\r
+var ob = keys.nextElement ();\r
+var rect = this.nodeHash.get (ob);\r
+if (x >= rect.x && x <= (rect.x + rect.width) && y >= rect.y && y <= (rect.y + rect.height)) {\r
+return ob;\r
+}}\r
+return null;\r
+}, "~N,~N");\r
+Clazz.defineMethod (c$, "pickNodes", \r
+function (pickBox) {\r
+var width = this.getSize ().width;\r
+var height = this.getSize ().height;\r
+var top = this.tree.getTopNode ();\r
+var wscale = (width * .8 - this.offx * 2) / this.tree.getMaxHeight ();\r
+if (top.count == 0) {\r
+top.count = (top.left ()).count + (top.right ()).count;\r
+}var chunk = (height - this.offy) / top.count;\r
+this.pickNode (pickBox, top, chunk, wscale, width, this.offx, this.offy);\r
+}, "java.awt.Rectangle");\r
+Clazz.defineMethod (c$, "pickNode", \r
+function (pickBox, node, chunk, scale, width, offx, offy) {\r
+if (node == null) {\r
+return;\r
+}if (node.left () == null && node.right () == null) {\r
+var height = node.height;\r
+var xend = Clazz.floatToInt (height * scale) + offx;\r
+var ypos = Clazz.floatToInt (node.ycount * chunk) + offy;\r
+if (pickBox.contains ( new java.awt.Point (xend, ypos))) {\r
+if (Clazz.instanceOf (node.element (), jalview.datamodel.SequenceI)) {\r
+var seq = node.element ();\r
+var sg = this.av.getSelectionGroup ();\r
+if (sg != null) {\r
+sg.addOrRemove (seq, true);\r
+}}}} else {\r
+this.pickNode (pickBox, node.left (), chunk, scale, width, offx, offy);\r
+this.pickNode (pickBox, node.right (), chunk, scale, width, offx, offy);\r
+}}, "java.awt.Rectangle,jalview.datamodel.SequenceNode,~N,~N,~N,~N,~N");\r
+Clazz.defineMethod (c$, "setColor", \r
+function (node, c) {\r
+if (node == null) {\r
+return;\r
+}if (node.left () == null && node.right () == null) {\r
+node.color = c;\r
+if (Clazz.instanceOf (node.element (), jalview.datamodel.SequenceI)) {\r
+this.av.setSequenceColour (node.element (), c);\r
+}} else {\r
+node.color = c;\r
+this.setColor (node.left (), c);\r
+this.setColor (node.right (), c);\r
+}}, "jalview.datamodel.SequenceNode,java.awt.Color");\r
+Clazz.overrideMethod (c$, "update", \r
+function (g) {\r
+this.paint (g);\r
+}, "java.awt.Graphics");\r
+Clazz.overrideMethod (c$, "paintComponent", \r
+function (g) {\r
+if (this.tree == null) {\r
+return;\r
+}if (this.nameHash.size () == 0) {\r
+this.repaint ();\r
+}var width = this.scrollPane.getSize ().width;\r
+var height = this.scrollPane.getSize ().height;\r
+if (!this.fitToWindow) {\r
+height = g.getFontMetrics (this.$font).getHeight () * this.nameHash.size ();\r
+}if (this.getSize ().width > width) {\r
+this.setSize ( new java.awt.Dimension (width, height));\r
+this.scrollPane.validate ();\r
+return;\r
+}this.setSize ( new java.awt.Dimension (width, height));\r
+g.setFont (this.$font);\r
+this.draw (g, width, height);\r
+this.validate ();\r
+}, "java.awt.Graphics");\r
+Clazz.defineMethod (c$, "draw", \r
+function (g, width, height) {\r
+this.offy = this.$font.getSize () + 10;\r
+g.setColor (java.awt.Color.white);\r
+g.fillRect (0, 0, width, height);\r
+this.labelLength = g.getFontMetrics (this.$font).stringWidth (this.longestName) + 20;\r
+var wscale = (width - this.labelLength - this.offx * 2) / this.tree.getMaxHeight ();\r
+var top = this.tree.getTopNode ();\r
+if (top.count == 0) {\r
+top.count = (top.left ()).count + (top.right ()).count;\r
+}var chunk = (height - this.offy) / top.count;\r
+this.drawNode (g, this.tree.getTopNode (), chunk, wscale, width, this.offx, this.offy);\r
+if (this.threshold != 0) {\r
+if (this.av.getCurrentTree () === this.tree) {\r
+g.setColor (java.awt.Color.red);\r
+} else {\r
+g.setColor (java.awt.Color.gray);\r
+}var x = Clazz.floatToInt (this.threshold * (this.getSize ().width - this.labelLength - 2 * this.offx) + this.offx);\r
+g.drawLine (x, 0, x, this.getSize ().height);\r
+}}, "java.awt.Graphics,~N,~N");\r
+Clazz.overrideMethod (c$, "mouseReleased", \r
+function (e) {\r
+}, "java.awt.event.MouseEvent");\r
+Clazz.overrideMethod (c$, "mouseEntered", \r
+function (e) {\r
+}, "java.awt.event.MouseEvent");\r
+Clazz.overrideMethod (c$, "mouseExited", \r
+function (e) {\r
+}, "java.awt.event.MouseEvent");\r
+Clazz.overrideMethod (c$, "mouseClicked", \r
+function (evt) {\r
+if (this.highlightNode != null) {\r
+if (evt.getClickCount () > 1) {\r
+this.tree.swapNodes (this.highlightNode);\r
+this.tree.reCount (this.tree.getTopNode ());\r
+this.tree.findHeight (this.tree.getTopNode ());\r
+} else {\r
+var leaves =  new java.util.Vector ();\r
+this.tree.findLeaves (this.highlightNode, leaves);\r
+for (var i = 0; i < leaves.size (); i++) {\r
+var seq = (leaves.elementAt (i)).element ();\r
+this.treeSelectionChanged (seq);\r
+}\r
+}jalview.appletgui.PaintRefresher.Refresh (this, this.av.getSequenceSetId ());\r
+this.repaint ();\r
+this.av.sendSelection ();\r
+}}, "java.awt.event.MouseEvent");\r
+Clazz.overrideMethod (c$, "mouseDragged", \r
+function (ect) {\r
+}, "java.awt.event.MouseEvent");\r
+Clazz.overrideMethod (c$, "mouseMoved", \r
+function (evt) {\r
+this.av.setCurrentTree (this.tree);\r
+var ob = this.findElement (evt.getX (), evt.getY ());\r
+if (Clazz.instanceOf (ob, jalview.datamodel.SequenceNode)) {\r
+this.highlightNode = ob;\r
+this.repaint ();\r
+} else {\r
+if (this.highlightNode != null) {\r
+this.highlightNode = null;\r
+this.repaint ();\r
+}}}, "java.awt.event.MouseEvent");\r
+Clazz.overrideMethod (c$, "mousePressed", \r
+function (e) {\r
+this.av.setCurrentTree (this.tree);\r
+var x = e.getX ();\r
+var y = e.getY ();\r
+var ob = this.findElement (x, y);\r
+if (Clazz.instanceOf (ob, jalview.datamodel.SequenceI)) {\r
+this.treeSelectionChanged (ob);\r
+jalview.appletgui.PaintRefresher.Refresh (this, this.av.getSequenceSetId ());\r
+this.repaint ();\r
+this.av.sendSelection ();\r
+return;\r
+} else if (!(Clazz.instanceOf (ob, jalview.datamodel.SequenceNode))) {\r
+if (this.tree.getMaxHeight () != 0) {\r
+this.threshold = (x - this.offx) / (this.getSize ().width - this.labelLength - 2 * this.offx);\r
+this.tree.getGroups ().removeAllElements ();\r
+this.tree.groupNodes (this.tree.getTopNode (), this.threshold);\r
+this.setColor (this.tree.getTopNode (), java.awt.Color.black);\r
+this.av.setSelectionGroup (null);\r
+this.av.getAlignment ().deleteAllGroups ();\r
+this.av.clearSequenceColours ();\r
+var codingComplement = this.av.getCodingComplement ();\r
+if (codingComplement != null) {\r
+codingComplement.setSelectionGroup (null);\r
+codingComplement.getAlignment ().deleteAllGroups ();\r
+codingComplement.clearSequenceColours ();\r
+}this.colourGroups ();\r
+}}jalview.appletgui.PaintRefresher.Refresh (this, this.av.getSequenceSetId ());\r
+this.repaint ();\r
+}, "java.awt.event.MouseEvent");\r
+Clazz.defineMethod (c$, "colourGroups", \r
+function () {\r
+for (var i = 0; i < this.tree.getGroups ().size (); i++) {\r
+var col =  new java.awt.Color (Clazz.doubleToInt (Math.random () * 255), Clazz.doubleToInt (Math.random () * 255), Clazz.doubleToInt (Math.random () * 255));\r
+this.setColor (this.tree.getGroups ().elementAt (i), col.brighter ());\r
+var l = this.tree.findLeaves (this.tree.getGroups ().elementAt (i),  new java.util.Vector ());\r
+var sequences =  new java.util.Vector ();\r
+for (var j = 0; j < l.size (); j++) {\r
+var s1 = (l.elementAt (j)).element ();\r
+if (!sequences.contains (s1)) {\r
+sequences.addElement (s1);\r
+}}\r
+var cs = null;\r
+var sg =  new jalview.datamodel.SequenceGroup (sequences, "", cs, true, true, false, 0, this.av.getAlignment ().getWidth () - 1);\r
+if (this.av.getGlobalColourScheme () != null) {\r
+if (Clazz.instanceOf (this.av.getGlobalColourScheme (), jalview.schemes.UserColourScheme)) {\r
+cs =  new jalview.schemes.UserColourScheme ((this.av.getGlobalColourScheme ()).getColours ());\r
+} else {\r
+cs = jalview.schemes.ColourSchemeProperty.getColour (sg, jalview.schemes.ColourSchemeProperty.getColourName (this.av.getGlobalColourScheme ()));\r
+}if (cs != null) {\r
+cs.setThreshold (this.av.getGlobalColourScheme ().getThreshold (), this.av.isIgnoreGapsConsensus ());\r
+}}sg.cs = cs;\r
+sg.setName ("JTreeGroup:" + sg.hashCode ());\r
+sg.setIdColour (col);\r
+if (this.av.getGlobalColourScheme () != null && this.av.getGlobalColourScheme ().conservationApplied ()) {\r
+var c =  new jalview.analysis.Conservation ("Group", jalview.schemes.ResidueProperties.propHash, 3, sg.getSequences (null), sg.getStartRes (), sg.getEndRes ());\r
+c.calculate ();\r
+c.verdict (false, this.av.getConsPercGaps ());\r
+cs.setConservation (c);\r
+sg.cs = cs;\r
+}this.av.getAlignment ().addGroup (sg);\r
+this.av.getAlignment ().addGroup (sg);\r
+var codingComplement = this.av.getCodingComplement ();\r
+if (codingComplement != null) {\r
+var mappedGroup = jalview.util.MappingUtils.mapSequenceGroup (sg, this.av, codingComplement);\r
+if (mappedGroup.getSequences ().size () > 0) {\r
+codingComplement.getAlignment ().addGroup (mappedGroup);\r
+for (var seq, $seq = mappedGroup.getSequences ().iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) {\r
+codingComplement.setSequenceColour (seq, col);\r
+}\r
+}}}\r
+this.ap.updateAnnotation ();\r
+if (this.av.getCodingComplement () != null) {\r
+(this.av.getCodingComplement ()).firePropertyChange ("alignment", null, this.ap.av.getAlignment ().getSequences ());\r
+}});\r
+Clazz.defineMethod (c$, "setShowDistances", \r
+function (state) {\r
+this.showDistances = state;\r
+this.repaint ();\r
+}, "~B");\r
+Clazz.defineMethod (c$, "setShowBootstrap", \r
+function (state) {\r
+this.showBootstrap = state;\r
+this.repaint ();\r
+}, "~B");\r
+Clazz.defineMethod (c$, "setMarkPlaceholders", \r
+function (state) {\r
+this.markPlaceholders = state;\r
+this.repaint ();\r
+}, "~B");\r
+Clazz.defineStatics (c$,\r
+"PLACEHOLDER", " * ");\r
+});\r