* Do the children first.
*/
List children = tree.getChildrenOf(n);
for (int i = 0; i < children.size(); i++)
{
PhyloNode child = (PhyloNode) children.get(i);
branchPositions(child);
}
Collections.sort(children);
/*
* Now, let's put on our thinking caps and try to lay ourselves out
* correctly.
*/
PhyloNode loChild = (PhyloNode) Collections.min(children);
PhyloNode hiChild = (PhyloNode) Collections.max(children);
/*
* Find the max depth of each child, and project where the "lower" child
* would be in the y axis if it were at that higher depth.
*/
float stepSize = 1f / (leaves.size());
float loLeaves = tree.getNumEnclosedLeaves(loChild);
float hiLeaves = tree.getNumEnclosedLeaves(hiChild);
float mLeaves = Math.max(loLeaves, hiLeaves);
// System.out.println("md:" + mLeaves);
float loChildNewY = loChild.getTargetY() + (mLeaves - loLeaves)
* stepSize / 2;
float hiChildNewY = hiChild.getTargetY() - (mLeaves - hiLeaves)
* stepSize / 2;
float unscaledY = (loChildNewY + hiChildNewY) / 2;
float unscaledX = nodeXPosition(n);
n.setPosition(unscaledX, unscaledY);
return 0;