From: kjvdheide Date: Wed, 29 Nov 2017 03:02:14 +0000 (+0000) Subject: JAL-2844 start on colouring back onto the alignment X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=ebf33c3e8faceeba628466f69b39e6de7e102a9d JAL-2844 start on colouring back onto the alignment --- diff --git a/src/jalview/ext/archaeopteryx/JalviewBinding.java b/src/jalview/ext/archaeopteryx/JalviewBinding.java index 0e77243..66c348f 100644 --- a/src/jalview/ext/archaeopteryx/JalviewBinding.java +++ b/src/jalview/ext/archaeopteryx/JalviewBinding.java @@ -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 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 nodesAboveThreshold = new ArrayList<>(); - iterateNodesAboveThreshold(nodesAboveThreshold, threshold, treeLength, + // could also use PhylogenyMethods.getAllDescendants + colourNodesAboveThreshold(nodesAboveThreshold, threshold, treeLength, node); return nodesAboveThreshold; } - private List iterateNodesAboveThreshold( + private List colourNodesAboveThreshold( List 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 descendantNodes = childNode + .getAllExternalDescendants(); + List 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 groupNodes(float threshold, PhylogenyNode root, // double treeHeight) // {