Example #1
0
 /**
  * Clip nodes height above limit.
  *
  * @param tree to clip
  * @param limit height limit
  */
 private void limitNodes(MutableTree tree, double limit) {
   for (int i = 0; i < tree.getInternalNodeCount(); i++) {
     final NodeRef n = tree.getInternalNode(i);
     if (tree.getNodeHeight(n) > limit) {
       tree.setNodeHeight(n, limit);
     }
   }
   MutableTree.Utils.correctHeightsForTips(tree);
 }
Example #2
0
  public void attemptToScaleTree(MutableTree tree, double rootHeight) {
    // avoid empty tree
    if (tree.getRoot() == null) return;

    double scale = rootHeight / tree.getNodeHeight(tree.getRoot());
    for (int i = 0; i < tree.getInternalNodeCount(); i++) {
      NodeRef n = tree.getInternalNode(i);
      tree.setNodeHeight(n, tree.getNodeHeight(n) * scale);
    }
    MutableTree.Utils.correctHeightsForTips(tree);
  }