private Map<PhylogenyNode, SequenceI> nodesBoundToSequences;
+ private float rootX;
+
+ private float furthestNodeX;
+
/**
*
* @param archaeopteryx
if (matchingNode != null)
{
treeView.getFoundNodes0().add(matchingNode.getId());
+
+
+ if (!matchingNode.getBranchData().isHasBranchColor())
+ {
+ Color foundNodesColour = treeView.getTreeColorSet()
+ .getFoundColor0();
+ matchingNode.getBranchData()
+ .setBranchColor(new BranchColor(foundNodesColour));
+
+ }
+
}
}
-
treeView.repaint();
}
if (!tree.isEmpty())
{
- double longestBranch = tree.calculateHeight(true);
- if (longestBranch != 0)
+ // should be calculated on each partition as the tree can theoretically
+ // change in the meantime
+ PhylogenyNode furthestNode = PhylogenyMethods
+ .calculateNodeWithMaxDistanceToRoot(tree);
+ furthestNodeX = furthestNode.getXcoord();
+ rootX = tree.getRoot().getXcoord();
+
+ if (furthestNodeX != rootX && x < furthestNodeX) // don't bother if 0
+ // distance tree or
+ // clicked x lies outside
+ // of tree
{
-
- // double relativeTreeWidth = longestBranch / viewWidth;
- // MOVE
Graphics g = treeView.getGraphics();
int panelHeight = treeView.getHeight();
g.drawLine(x, 0, x, panelHeight);
- float rootX = tree.getRoot().getXcoord();
- double threshold = ((double) x - rootX) / longestBranch;
+ float threshold = (x - rootX) / (furthestNodeX - rootX);
List<PhylogenyNode> foundNodes = getNodesAboveThreshold(threshold,
- longestBranch, tree.getRoot());
+ tree.getRoot());
}
}
}
public List<PhylogenyNode> getNodesAboveThreshold(double threshold,
- double treeLength, PhylogenyNode node)
+ PhylogenyNode node)
{
List<PhylogenyNode> nodesAboveThreshold = new ArrayList<>();
}
- colourNodesAboveThreshold(nodesAboveThreshold, threshold, treeLength,
+ colourNodesAboveThreshold(nodesAboveThreshold, threshold,
node);
return nodesAboveThreshold;
*/
private List<PhylogenyNode> colourNodesAboveThreshold(
List<PhylogenyNode> nodeList, double threshold,
- double treeLength, PhylogenyNode node)
+ PhylogenyNode node)
{
// could also use PhylogenyMethods.getAllDescendants
for (PhylogenyNode childNode : node.getDescendants())
{
childNode.getBranchData()
.setBranchColor(new BranchColor(Color.black));
- double nodeCutoff = childNode.calculateDistanceToRoot() / treeLength;
+ float nodeCutoff = (childNode.getXcoord() - rootX)
+ / (furthestNodeX - rootX);
if (nodeCutoff > threshold)
{
(int) (Math.random() * 255), (int) (Math.random() * 255));
TreePanelUtil.colorizeSubtree(childNode,
new BranchColor(randomColor));
-
List<PhylogenyNode> descendantNodes = childNode
.getAllExternalDescendants();
- List<SequenceI> descendantSeqs = new ArrayList<>();
+ List<SequenceI> descendantSeqs = new ArrayList<>(); // .forEach instead?
for (PhylogenyNode descNode : descendantNodes)
{
descendantSeqs.add(nodesBoundToSequences.get(descNode));
}
-
SequenceGroup sg = new SequenceGroup(descendantSeqs, null, null,
true, true, false, 0,
parentAvport.getAlignment().getWidth() - 1);
cs = new UserColourScheme(
((UserColourScheme) parentAvport.getGlobalColourScheme())
.getColours());
-
}
else
{
}
+
else
{
- colourNodesAboveThreshold(nodeList, threshold, treeLength,
+ colourNodesAboveThreshold(nodeList, threshold,
childNode);
}
-
}
+
// GROSS
((AlignViewport) parentAvport).getAlignPanel().updateAnnotation();
((AlignViewport) codingComplement).getAlignPanel().updateAnnotation();
}
-
return nodeList;
}