Skip to content

Commit

Permalink
add configuration for showing children counts
Browse files Browse the repository at this point in the history
- spouses of last generation of descendents can be turned on
  • Loading branch information
Jiri Ambroz authored and Jiri Ambroz committed Feb 24, 2023
1 parent cd5bcd3 commit 784227f
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class VisualConfiguration {
private boolean showPlaces;
private boolean shortenPlaces;
private boolean showOrdinances;
private boolean showChildrenCount;

private Locale locale;
private boolean resetMode;
Expand All @@ -53,6 +54,7 @@ public VisualConfiguration() {
showPlaces = true;
shortenPlaces = true;
showOrdinances = false;
showChildrenCount = false;

locale = new Locale("cs", "CZ");
resetMode = false;
Expand Down Expand Up @@ -214,6 +216,14 @@ public void setShowOrdinances(boolean showOrdinances) {
this.showOrdinances = showOrdinances;
}

public boolean isShowChildrenCount() {
return showChildrenCount;
}

public void setShowChildrenCount(boolean showChildrenCount) {
this.showChildrenCount = showChildrenCount;
}

public Locale getLocale() {
return locale;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static VisualConfigurationCommand map(VisualConfigurationRequest configur
configurationRequest.showPlaces(),
configurationRequest.shortenPlaces(),
configurationRequest.showOrdinances(),
configurationRequest.showChildrenCount(),
configurationRequest.locale(),
configurationRequest.resetMode()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static VisualConfiguration map(VisualConfigurationCommand configurationCo
visualConfiguration.setShowPlaces(configurationCommand.showPlaces());
visualConfiguration.setShortenPlaces(configurationCommand.shortenPlaces());
visualConfiguration.setShowOrdinances(configurationCommand.showOrdinances());
visualConfiguration.setShowChildrenCount(configurationCommand.showChildrenCount());
visualConfiguration.setLocale(configurationCommand.locale());
visualConfiguration.setResetMode(configurationCommand.resetMode());
return visualConfiguration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static VisualConfigurationResponse map(VisualConfiguration visualConfigur
visualConfiguration.isShowPlaces(),
visualConfiguration.isShortenPlaces(),
visualConfiguration.isShowOrdinances(),
visualConfiguration.isShowChildrenCount(),
visualConfiguration.getLocale(),
visualConfiguration.isResetMode()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public record VisualConfigurationCommand(
boolean showPlaces,
boolean shortenPlaces,
boolean showOrdinances,
boolean showChildrenCount,
Locale locale,
boolean resetMode
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public record VisualConfigurationRequest(
boolean showPlaces,
boolean shortenPlaces,
boolean showOrdinances,
boolean showChildrenCount,
Locale locale,
boolean resetMode
) {
Expand All @@ -49,6 +50,7 @@ public String toString() {
", showPlaces=" + showPlaces +
", shortenPlaces=" + shortenPlaces +
", showOrdinances=" + showOrdinances +
", showChildrenCount=" + showChildrenCount +
", locale=" + locale +
", resetMode=" + resetMode +
'}';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public record VisualConfigurationResponse(
boolean showPlaces,
boolean shortenPlaces,
boolean showOrdinances,
boolean showChildrenCount,
Locale locale,
boolean resetMode
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public AncestorPerson select(String personId) {
public AncestorPerson fromPersonWithParents(Person person, int generation) {
AncestorPerson newPerson = AncestorPersonMapper.map(person);
newPerson.setDirectLineage(true);
if (generation < 3) {
if (generation < 2) {
addSiblings(newPerson, person.getParentId());
}
if (generation <= Config.treeShape().getAncestorGenerations()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected AncestorPerson fromRootPersonWithAllDescendents(Person person) {
ancestorPerson.setSpouses(addSpouse(person.getSpouseId(), true));
if (1 <= configuration.getDescendentGenerations()) {
ancestorPerson.getSpouseCouples()
.forEach(spouseCouple -> addChildrenToCouple(spouseCouple, 2));
.forEach(spouseCouple -> addChildrenToCouple(spouseCouple, 1));
}
}
return ancestorPerson;
Expand All @@ -141,10 +141,15 @@ private AncestorPerson fromPersonWithAllDescendents(Person person, int generatio
if (person != null) {
AncestorPerson ancestorPerson = AncestorPersonMapper.map(person);
ancestorPerson.setDirectLineage(true);
ancestorPerson.setSpouses(addSpouse(person.getSpouseId(), true));
if (generation <= configuration.getDescendentGenerations()) {
ancestorPerson.getSpouseCouples()
.forEach(spouseCouple -> addChildrenToCouple(spouseCouple, generation + 1));
List<AncestorCouple> spouses = addSpouse(person.getSpouseId(), true);
if (generation < configuration.getDescendentGenerations() ||
(generation == configuration.getDescendentGenerations() && configuration.isShowSiblingSpouses())
) {
ancestorPerson.setSpouses(spouses);
if (generation < configuration.getDescendentGenerations()) {
ancestorPerson.getSpouseCouples()
.forEach(spouseCouple -> addChildrenToCouple(spouseCouple, generation + 1));
}
}
return ancestorPerson;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ private FamilyDto addChildren(FamilyDto prevFamilyDto, AncestorCouple spouseCoup
treeModelService.addLine(childrenSpouse, new Position(childrenSpouse.x(), heraldryPosition.y()));
}
} else {
childrenPosition = childrenPosition.addXAndY(configService.nextChildrenX(), 0);
if (childrenCount == 1) {
childrenPosition = new Position(coupleCenterPosition.x(), childrenPosition.y());
} else {
childrenPosition = childrenPosition.addXAndY(configService.nextChildrenX(), 0);
}
maxX = Math.max(maxX, childrenPosition.x());

treeModelService.addPerson(childrenPosition, child);
Expand Down

0 comments on commit 784227f

Please sign in to comment.