JAL-2844 start on colouring back onto the alignment
authorkjvdheide <kjvanderheide@dundee.ac.uk>
Wed, 29 Nov 2017 03:02:14 +0000 (03:02 +0000)
committerkjvdheide <kjvanderheide@dundee.ac.uk>
Wed, 29 Nov 2017 03:02:14 +0000 (03:02 +0000)
src/jalview/ext/archaeopteryx/JalviewBinding.java

index 0e77243..66c348f 100644 (file)
@@ -237,27 +237,17 @@ public final class JalviewBinding
       {
         Graphics g = treeView.getGraphics();
         int panelHeight = treeView.getHeight();
-        int viewWidth = treeView.getWidth();
         g.drawLine(x, 0, x, panelHeight);
 
         // double relativeTreeWidth = treeDepth / viewWidth;
-        //
-        // System.out.println(relativeTreeWidth);
 
         float rootX = tree.getRoot().getXcoord();
         double threshold = ((double) x - rootX) / longestBranch;
         List<PhylogenyNode> foundNodes = getNodesAboveThreshold(threshold,
                 longestBranch, tree.getRoot());
-        for (PhylogenyNode foundNode : foundNodes)
-        {
-          Color randomColor = new Color((int) (Math.random() * 255),
-                  (int) (Math.random() * 255), (int) (Math.random() * 255));
-          TreePanelUtil.colorizeSubtree(foundNode,
-                  new BranchColor(randomColor));
-        }
 
 
-        // groupNodes(threshold, tree.getRoot(), longestBranch);
+
 
 
 
@@ -274,13 +264,14 @@ public final class JalviewBinding
 
     List<PhylogenyNode> nodesAboveThreshold = new ArrayList<>();
 
-    iterateNodesAboveThreshold(nodesAboveThreshold, threshold, treeLength,
+    // could also use PhylogenyMethods.getAllDescendants
+    colourNodesAboveThreshold(nodesAboveThreshold, threshold, treeLength,
             node);
     return nodesAboveThreshold;
 
   }
 
-  private List<PhylogenyNode> iterateNodesAboveThreshold(
+  private List<PhylogenyNode> colourNodesAboveThreshold(
           List<PhylogenyNode> nodeList, double threshold,
           double treeLength, PhylogenyNode node)
   {
@@ -291,11 +282,29 @@ public final class JalviewBinding
       if (nodeCutoff > threshold)
       {
         nodeList.add(childNode);
+
+        Color randomColor = new Color((int) (Math.random() * 255),
+                (int) (Math.random() * 255), (int) (Math.random() * 255));
+        TreePanelUtil.colorizeSubtree(childNode,
+                new BranchColor(randomColor));
+        List<PhylogenyNode> descendantNodes = childNode
+                .getAllExternalDescendants();
+        List<SequenceI> descendantSeqs = new ArrayList<>();
+        for (PhylogenyNode descNode : descendantNodes)
+        {
+          descendantSeqs.add(nodesBoundToSequences.get(descNode));
+        }
+
+        SequenceGroup sg = new SequenceGroup(descendantSeqs, null, null,
+                true, true, false, 0,
+                parentAvport.getAlignment().getWidth() - 1);
+        sg.setIdColour(randomColor);
+
       }
 
       else
       {
-      iterateNodesAboveThreshold(nodeList, threshold, treeLength,
+      colourNodesAboveThreshold(nodeList, threshold, treeLength,
                 childNode);
       }
 
@@ -305,6 +314,7 @@ public final class JalviewBinding
 
 
 
+
   // public List<PhylogenyNode> groupNodes(float threshold, PhylogenyNode root,
   // double treeHeight)
   // {