creates new groups when selecting branches of the tree
authoramwaterhouse <Andrew Waterhouse>
Mon, 24 Jan 2005 17:26:15 +0000 (17:26 +0000)
committeramwaterhouse <Andrew Waterhouse>
Mon, 24 Jan 2005 17:26:15 +0000 (17:26 +0000)
src/jalview/gui/TreeCanvas.java

index 484e05a..c39e407 100755 (executable)
@@ -4,11 +4,11 @@ package jalview.gui;
 import jalview.analysis.*;\r
 import jalview.datamodel.*;\r
 import jalview.util.*;\r
+import jalview.schemes.*;\r
 import javax.swing.*;\r
 import java.awt.*;\r
 import java.awt.event.*;\r
 import java.util.*;\r
-import java.io.*;\r
 \r
 public class TreeCanvas extends JPanel implements MouseListener\r
 {\r
@@ -247,18 +247,19 @@ public class TreeCanvas extends JPanel implements MouseListener
     }\r
   }\r
 \r
-  public void setColor(SequenceNode node, Color c) {\r
-    if (node == null) {\r
+  public void setColor(SequenceNode node, Color c)\r
+  {\r
+    if (node == null)\r
       return;\r
-    }\r
 \r
-    if (node.left() == null && node.right() == null) {\r
+    if (node.left() == null && node.right() == null)\r
+    {\r
       node.color = c;\r
 \r
-      if (node.element() instanceof SequenceI) {\r
+      if (node.element() instanceof SequenceI)\r
           ((SequenceI)node.element()).setColor(c);\r
-      }\r
-    } else {\r
+    } else\r
+    {\r
       node.color = c;\r
       setColor((SequenceNode)node.left(),c);\r
       setColor((SequenceNode)node.right(),c);\r
@@ -357,15 +358,47 @@ public class TreeCanvas extends JPanel implements MouseListener
               tree.groupNodes(tree.getTopNode(),fthreshold);\r
               setColor(tree.getTopNode(),Color.black);\r
 \r
-              for (int i=0; i < tree.getGroups().size(); i++) {\r
+              av.sel.clear();\r
+              av.alignment.deleteAllGroups();\r
+\r
+              for (int i=0; i < tree.getGroups().size(); i++)\r
+              {\r
 \r
                   Color col = new Color((int)(Math.random()*255),\r
                                         (int)(Math.random()*255),\r
                                         (int)(Math.random()*255));\r
                   setColor((SequenceNode)tree.getGroups().elementAt(i),col.brighter());\r
 \r
-                  // l is vector of Objects\r
-                 // Vector l = tree.findLeaves((SequenceNode)tree.getGroups().elementAt(i),new Vector());\r
+                  Vector l = tree.findLeaves((SequenceNode)tree.getGroups().elementAt(i),new Vector());\r
+                  SequenceGroup sg = null;\r
+                  for (int j = 0; j < l.size(); j++)\r
+                  {\r
+                    SequenceNode sn = (SequenceNode) l.elementAt(j);\r
+                    if(sg==null)\r
+                       sg  = new SequenceGroup("TreeGroup", av.getGlobalColourScheme(), true, true,false,0,av.alignment.getWidth());\r
+\r
+                    sg.addSequence( (Sequence) sn.element());\r
+                  }\r
+\r
+                  if (av.getGlobalColourScheme() instanceof ConservationColourScheme)\r
+                  {\r
+                    ConservationColourScheme ccs = (ConservationColourScheme) av.getGlobalColourScheme();\r
+                    Conservation c = new Conservation("Group",\r
+                                                      ResidueProperties.propHash, 3,\r
+                                                      sg.sequences, sg.getStartRes(),\r
+                                                      sg.getEndRes());\r
+\r
+                    c.calculate();\r
+                    c.verdict(false, 100);\r
+                    ccs = new ConservationColourScheme(c, ccs.cs);\r
+\r
+                    sg.cs = ccs;\r
+\r
+                  }\r
+\r
+\r
+\r
+                  av.alignment.addGroup(sg);\r
 \r
               }\r
           }\r