Open Sternbach-Software opened 1 year ago
This looks like a good, short function on stackoverflow to determine whether the groups overlap. Was written for View
s, so may need to be adjusted for Group
s.
Some pseudo code that may help:
int initialPosition = node.y + node.height + PROGENY_DISTANCE;
int finalPosition = initialPosition;
while(isOverlapWithOthers(finalPosition)) {
finalPosition += findNextOverlappingView(finalPosition).bottom + PROGENY_DISTANCE;
}
youth.setY(finalPosition);
For ancestor bonds, instead of findNextOverlappingView(finalPosition).bottom
you would use .top + ANCESTRY_DISTANCE
, and -=
instead of +=
.
To optimize that, you could return null
from findNextOverlappingView
, and use
View overlappingView;
do {
overlappingView = findNextOverlappingView(finalPosition);
if(overlappingView != null) finalPosition = overlappingView.bottom + PROGENY_DISTANCE;
} while(overlappingView != null);
(or while(true) { ...if(overlappingView != null) {...}else break; }
Thank you for reporting that. I absolutely agree this overlap is unpleasant.
Just a clarification: inside GedcomGraph "bond" refers to the horizontal link between two partners. The little cards below are called "progeny" or "mini children/youth". The little cards above are "ancestry" or "mini origin".
A vertical adjustment risks to produce this:
IMHO there is an easier (and more effective) solution: let the Y as is, and shift the X until the progenies don't overlap.
Progenies width is now ignored, it's because of that they overlap.
So the width of each node should be simply Max(Node.width, Progeny.width)
:
Attached is a picture of my family tree. Notice the horrible pile up at the center of the screen with the Bond mini cards. It happens when the bond mini cards are above the people too. The horizontal
line.x
seems to be ok, but theline.y
is off. This seems to be a tricky case, because how do you determine which bonds should go on top, and which on bottom?