Fix tree branch overlap (#7641)

This commit is contained in:
MEEPofFaith
2022-09-30 12:04:36 -07:00
committed by GitHub
parent ce23fe9d24
commit f90bb5b542
2 changed files with 11 additions and 1 deletions

View File

@@ -26,7 +26,7 @@ public class BranchTreeLayout implements TreeLayout{
}
private float getWidthOrHeightOfNode(TreeNode treeNode, boolean returnWidth){
return returnWidth ? treeNode.width : treeNode.height;
return returnWidth ? treeNode.calcWidth() : treeNode.height;
}
private float getNodeThickness(TreeNode treeNode){

View File

@@ -18,5 +18,15 @@ public interface TreeLayout{
public boolean isLeaf(){
return children == null || children.length == 0;
}
public float calcWidth(){
if(children == null) return width;
float cWidth = 0;
for(T node : children){
cWidth += node.calcWidth();
}
return Math.max(width, cWidth);
}
}
}