From ebf33c3e8faceeba628466f69b39e6de7e102a9d Mon Sep 17 00:00:00 2001 From: kjvdheide Date: Wed, 29 Nov 2017 03:02:14 +0000 Subject: [PATCH] JAL-2844 start on colouring back onto the alignment --- src/jalview/ext/archaeopteryx/JalviewBinding.java | 38 +++++++++++++-------- 1 file changed, 24 insertions(+), 14 deletions(-) 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) // { -- 1.7.10.2