コード例 #1
0
 public void layoutUp() {
   float off = offset;
   if (father != null) {
     father.offset = off;
     father.layoutUp();
     off += father.getWidthUp();
   }
   if (mother != null) {
     mother.offset = off;
     mother.layoutUp();
     off += mother.getWidthUp();
   }
   if (generation != 0) x = offset + (getWidthUp() - 1) / 2;
 }
コード例 #2
0
    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();
    }
コード例 #3
0
 public void layoutDown() {
   float off = offset;
   for (FamilyMember c : children().collect(Collectors.toList())) {
     c.offset = off;
     c.layoutDown();
     off += c.getWidthDown();
   }
   if (spouse == null) {
     x = offset + (getWidthDown() - 1) / 2;
   } else {
     x = offset - 0.5f + (getWidthDown() - 1) / 2;
     spouse.x = offset + 0.5f + (getWidthDown() - 1) / 2;
   }
 }