public void layout() { float widthDown; if (father != null) widthDown = (float) father.children().mapToDouble(FamilyMember::getWidthDown).sum(); else if (mother != null) widthDown = (float) father.children().mapToDouble(FamilyMember::getWidthDown).sum(); else widthDown = getWidthDown(); float diff = (getWidthUp() - widthDown) / 2f; if (diff > 0) offset = diff; else offset = 0; if (father != null) { float off = offset; for (FamilyMember m : father.children().collect(Collectors.toList())) { m.offset = off; m.layoutDown(); off += m.getWidthDown(); } } else layoutDown(); if (getWidthUp() < widthDown) offset = Math.max(0, x - (getWidthUp() - 1) / 2); else offset = 0; layoutUp(); }
public float getWidth() { float widthDown; if (father != null) widthDown = (float) father.children().mapToDouble(FamilyMember::getWidthDown).sum(); else if (mother != null) widthDown = (float) father.children().mapToDouble(FamilyMember::getWidthDown).sum(); else widthDown = getWidthDown(); return Math.max(widthDown, getWidthUp()); }