import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
+import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
treeView.addMouseListener(this);
PaintRefresher.Register(treeView, parentAvport.getSequenceSetId());
+
treeTabs.addChangeListener(new ChangeListener()
{
else
{
partitionTree(e.getX());
-
}
-
PaintRefresher.Refresh(treeView, parentAvport.getSequenceSetId());
}
});
if (!tree.isEmpty())
{
- double treeDepth = tree.calculateHeight(true);
- if (treeDepth != 0)
+ double longestBranch = tree.calculateHeight(true);
+ if (longestBranch != 0)
{
Graphics g = treeView.getGraphics();
int panelHeight = treeView.getHeight();
+ int viewWidth = treeView.getWidth();
g.drawLine(x, 0, x, panelHeight);
- int viewWidth = treeView.getWidth();
- float threshold = (float) x / (float) viewWidth;
+ // double relativeTreeWidth = treeDepth / viewWidth;
+ //
+ // System.out.println(relativeTreeWidth);
+
+ double threshold = x / longestBranch;
+ System.out.println(threshold);
+ List<PhylogenyNode> foundNodes = getNodesAboveThreshold(threshold,
+ longestBranch, tree.getRoot());
+ for (PhylogenyNode foundNode : foundNodes)
+ {
+ System.out.println(foundNode);
+ }
+
+ // groupNodes(threshold, tree.getRoot(), longestBranch);
+
+
+
}
}
}
-
+
+ public List<PhylogenyNode> getNodesAboveThreshold(double threshold,
+ double treeLength, PhylogenyNode node)
+ {
+
+ List<PhylogenyNode> nodesAboveThreshold = new ArrayList<>();
+
+ iterateNodesAboveThreshold(nodesAboveThreshold, threshold, treeLength,
+ node);
+ return nodesAboveThreshold;
+
+ }
+
+ private List<PhylogenyNode> iterateNodesAboveThreshold(
+ List<PhylogenyNode> nodeList, double threshold,
+ double treeLength, PhylogenyNode node)
+ {
+ for (PhylogenyNode childNode : node.getDescendants())
+ {
+ double nodeCutoff = childNode.calculateDistanceToRoot() / treeLength;
+
+ if (nodeCutoff > threshold)
+ {
+ nodeList.add(node);
+ }
+
+ else
+ {
+ iterateNodesAboveThreshold(nodeList, threshold, treeLength,
+ childNode);
+ }
+
+ }
+ return nodeList;
+ }
+
+
+
+ // public List<PhylogenyNode> groupNodes(float threshold, PhylogenyNode root,
+ // double treeHeight)
+ // {
+ // List<PhylogenyNode> groups = new ArrayList<>();
+ // _groupNodes(groups, root, threshold, treeHeight);
+ // System.out.println(groups);
+ // return groups;
+ // }
+ //
+ // protected void _groupNodes(List<PhylogenyNode> groups, PhylogenyNode nd,
+ // float threshold, double treeHeight)
+ // {
+ // if (nd == null)
+ // {
+ // return;
+ // }
+ //
+ // if ((nd.calculateDistanceToRoot() / treeHeight) > threshold)
+ // {
+ // groups.add(nd);
+ // }
+ // else
+ // {
+ // for (PhylogenyNode childNode : nd.getDescendants())
+ // {
+ // _groupNodes(groups, childNode, threshold, treeHeight);
+ // }
+ // }
+ // }
+ //
+
/**
* may or may not need an extra repaint on the alignment view (check what kira