Skip to content

Commit

Permalink
WIP: Big refactoring - simplifying both views
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiri Ambroz authored and Jiri Ambroz committed Dec 2, 2022
1 parent 90f19d0 commit 40ba6e4
Show file tree
Hide file tree
Showing 28 changed files with 1,114 additions and 1,505 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package org.ambrogenea.familyview.configuration;

import java.util.Locale;

import org.ambrogenea.familyview.constant.Spaces;
import org.ambrogenea.familyview.domain.FamilyData;
import org.ambrogenea.familyview.enums.Diagrams;
import org.ambrogenea.familyview.enums.LabelShape;

import java.util.Locale;

/**
* @author Jiri Ambroz <[email protected]>
*/
Expand All @@ -20,21 +19,14 @@ public class PersonConfiguration {
private int adultVerticalShift;
private int adultFontSize;

private int wideMarriageLabel;
private int marriageLabelWidth;

private int siblingImageWidth;
private int siblingImageHeight;
private int siblingVerticalShift;
private int siblingFontSize;

private Diagrams adultDiagram;
private Diagrams siblingDiagram;
private LabelShape labelShape;
private String adultManImagePath;
private String adultWomanImagePath;
private String siblingManImagePath;
private String siblingWomanImagePath;

private boolean showMarriage;

Expand All @@ -48,25 +40,19 @@ public class PersonConfiguration {
public PersonConfiguration() {
adultImageWidth = 190;
adultImageHeight = 130;
marriageLabelWidth = Spaces.MIN_MARRIAGE_LABEL_WIDTH;
wideMarriageLabel = 3 * (adultImageWidth + marriageLabelWidth) / 2;
adultVerticalShift = 0;
siblingImageWidth = 170;
siblingImageHeight = 120;
siblingVerticalShift = 0;
adultFontSize = 12;
siblingFontSize = 11;

adultDiagram = Diagrams.SCROLL;
siblingDiagram = Diagrams.SCROLL;
labelShape = LabelShape.OVAL;
adultManImagePath = "diagrams/" + adultDiagram + "_man.png";
adultWomanImagePath = "diagrams/" + adultDiagram + "_woman.png";
siblingManImagePath = "diagrams/" + siblingDiagram + "_man.png";
siblingWomanImagePath = "diagrams/" + siblingDiagram + "_woman.png";

showAge = true;
showPlaces = false;
showPlaces = true;
shortenPlaces = false;
showOccupation = true;
showMarriage = true;
Expand Down Expand Up @@ -108,22 +94,6 @@ public void setAdultImageHeight(int adultImageHeight) {
this.adultImageHeight = adultImageHeight;
}

public int getWideMarriageLabel() {
return wideMarriageLabel;
}

public void setWideMarriageLabel(int wideMarriageLabel) {
this.wideMarriageLabel = wideMarriageLabel;
}

public int getMarriageLabelWidth() {
return marriageLabelWidth;
}

public void setMarriageLabelWidth(int marriageLabelWidth) {
this.marriageLabelWidth = marriageLabelWidth;
}

public int getAdultVerticalShift() {
return adultVerticalShift;
}
Expand All @@ -148,14 +118,6 @@ public void setSiblingImageHeight(int siblingImageHeight) {
this.siblingImageHeight = siblingImageHeight;
}

public int getSiblingVerticalShift() {
return siblingVerticalShift;
}

public void setSiblingVerticalShift(int siblingVerticalShift) {
this.siblingVerticalShift = siblingVerticalShift;
}

public int getAdultFontSize() {
return adultFontSize;
}
Expand All @@ -180,14 +142,6 @@ public void setAdultDiagram(Diagrams adultDiagram) {
this.adultDiagram = adultDiagram;
}

public Diagrams getSiblingDiagram() {
return siblingDiagram;
}

public void setSiblingDiagram(Diagrams siblingDiagram) {
this.siblingDiagram = siblingDiagram;
}

public LabelShape getLabelShape() {
return labelShape;
}
Expand All @@ -212,22 +166,6 @@ public void setAdultWomanImagePath(String adultWomanImagePath) {
this.adultWomanImagePath = adultWomanImagePath;
}

public String getSiblingManImagePath() {
return siblingManImagePath;
}

public void setSiblingManImagePath(String siblingManImagePath) {
this.siblingManImagePath = siblingManImagePath;
}

public String getSiblingWomanImagePath() {
return siblingWomanImagePath;
}

public void setSiblingWomanImagePath(String siblingWomanImagePath) {
this.siblingWomanImagePath = siblingWomanImagePath;
}

public boolean isShowMarriage() {
return showMarriage;
}
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/ambrogenea/familyview/constant/Dimensions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.ambrogenea.familyview.constant;

public class Dimensions {
public static int SCROLL_IMAGE_WIDTH = 190;
public static int SCROLL_IMAGE_HEIGHT = 130;
public static int DOUBLE_WAVE_IMAGE_HEIGHT = 110;
public static int DOUBLE_WAVE_IMAGE_WIDTH = 160;
public static int PORTRAIT_IMAGE_WIDTH = 130;
public static int PORTRAIT_IMAGE_HEIGHT = 130;
public static int DEFAULT_IMAGE_HEIGHT = 120;
public static int DEFAULT_IMAGE_WIDTH = 160;
}
6 changes: 4 additions & 2 deletions src/main/java/org/ambrogenea/familyview/constant/Spaces.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ public abstract class Spaces {
public static final int SIBLINGS_GAP = HORIZONTAL_GAP;
public static final int VERTICAL_GAP = 80;
public static final int RESIDENCE_SIZE = 25;
public static final int MIN_MARRIAGE_LABEL_HEIGHT = 25;
public static final int MIN_MARRIAGE_LABEL_WIDTH = 100;
public static final int HORIZ_MARRIAGE_LABEL_HEIGHT = 40;
public static final int HORIZ_MARRIAGE_LABEL_WIDTH = 50;
public static final int VERT_MARRIAGE_LABEL_HEIGHT = 25;
public static final int MIN_VERT_MARRIAGE_LABEL_WIDTH = 100;
public static final int LABEL_GAP = 2;
public final static int TITLE_HEIGHT = 120;

Expand Down
39 changes: 39 additions & 0 deletions src/main/java/org/ambrogenea/familyview/dto/ParentsDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.ambrogenea.familyview.dto;

import org.ambrogenea.familyview.dto.tree.Position;

public class ParentsDto {
private Position husbandPosition;
private Position wifePosition;
private int nextHeraldryY;

public ParentsDto(Position husbandPosition, Position wifePosition, int nextHeraldryY) {
this.husbandPosition = husbandPosition;
this.wifePosition = wifePosition;
this.nextHeraldryY = nextHeraldryY;
}

public Position getHusbandPosition() {
return husbandPosition;
}

public void setHusbandPosition(Position husbandPosition) {
this.husbandPosition = husbandPosition;
}

public Position getWifePosition() {
return wifePosition;
}

public void setWifePosition(Position wifePosition) {
this.wifePosition = wifePosition;
}

public int getNextHeraldryY() {
return nextHeraldryY;
}

public void setNextHeraldryY(int nextHeraldryY) {
this.nextHeraldryY = nextHeraldryY;
}
}
39 changes: 4 additions & 35 deletions src/main/java/org/ambrogenea/familyview/dto/tree/TreeModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,8 @@ public Set<PersonRecord> getPersons() {
return persons;
}

public void addPersonWithResidence(PersonRecord person, ConfigurationService service) {
public void addPerson(PersonRecord person) {
persons.add(person);
if (service.isShowResidence()) {
addResidence(person, service);
}
}

public Set<Marriage> getMarriages() {
Expand Down Expand Up @@ -95,39 +92,11 @@ public ArrayList<String> getCityRegister() {
return cityRegister;
}

private void addResidence(final PersonRecord person, ConfigurationService configuration) {
Residence residence;
int yShift;
Position position;
for (int i = 0; i < person.getResidences().size(); i++) {

residence = person.getResidences().get(i);
if (!residence.getCity().isEmpty()) {

if (person.isDirectLineage()) {
yShift = -configuration.getAdultImageHeight() / 2 + i * (Spaces.RESIDENCE_SIZE + 5);

if (person.getSex().equals(Sex.FEMALE)) {
position = person.getPosition().addXAndY(
(configuration.getAdultImageWidth() + Spaces.HORIZONTAL_GAP) / 2, yShift);
} else {
position = person.getPosition().addXAndY(
-(configuration.getAdultImageWidth() + Spaces.HORIZONTAL_GAP) / 2 - Spaces.RESIDENCE_SIZE, yShift);
}
} else {
position = person.getPosition().addXAndY(
-(configuration.getSiblingImageWidth() + Spaces.HORIZONTAL_GAP) / 2 - Spaces.RESIDENCE_SIZE,
-configuration.getSiblingImageHeight() / 2 + i * (Spaces.RESIDENCE_SIZE + 5)
);
}

residences.add(new ResidenceDto(position, residence));
addCityToRegister(residence.getCity());
}
}
public void addResidence(Position position, Residence residence) {
residences.add(new ResidenceDto(position, residence));
}

private void addCityToRegister(String city) {
public void addCityToRegister(String city) {
if (!cityRegister.contains(city)) {
cityRegister.add(city);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.ambrogenea.familyview.dto.AncestorCouple;
import org.ambrogenea.familyview.dto.AncestorPerson;
import org.ambrogenea.familyview.dto.ParentsDto;
import org.ambrogenea.familyview.dto.tree.Position;
import org.ambrogenea.familyview.dto.tree.TreeModel;
import org.ambrogenea.familyview.enums.Relation;
Expand Down Expand Up @@ -35,4 +36,6 @@ public interface CommonAncestorService {
void addStraightChildrenLine(Position childPosition);

TreeModel getTreeModel();

ParentsDto generateParents(Position heraldryPosition, AncestorPerson child);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.ambrogenea.familyview.service;

import org.ambrogenea.familyview.dto.AncestorPerson;

/**
*
* @author Jiri Ambroz <[email protected]>
*/
public interface ConfigurationExtensionService {
int getMarriageLabelWidth();
int getMarriageLabelHeight();
int getCoupleWidth();
int getHalfSpouseLabelSpace();
int getGapBetweenCouples();
int getAllAncestorsCoupleIncrease();
int getSpouseDistance();
int getFatherHorizontalDistance();
int getMotherHorizontalDistance();
int getCoupleVerticalDifference();
int getFatherVerticalDistance();
int getMotherVerticalDistance();
int getMarriageLabelVerticalDistance();
int getMarriageLabelHorizontalDistance();
int getGenerationsVerticalDistance();
int getParentGenerationWidth(AncestorPerson person);
}
Loading

0 comments on commit 40ba6e4

Please sign in to comment.