diff -Nur tree.old/DetermineIndiboxSize.java tree/DetermineIndiboxSize.java --- tree.old/DetermineIndiboxSize.java 2008-02-01 10:28:29.000000000 +0800 +++ tree/DetermineIndiboxSize.java 2008-02-04 10:27:04.000000000 +0800 @@ -15,6 +15,8 @@ import genj.util.Registry; import genj.util.swing.ImageIcon; +import java.util.ArrayList; + import java.awt.Font; import java.awt.font.FontRenderContext; @@ -55,6 +57,7 @@ private boolean drawDates; private boolean drawOccupation; private int maxNames; + private int maxNamesPerLine; private boolean drawSexSymbols; private boolean drawIndiIds; @@ -67,6 +70,7 @@ drawDates = properties.get("drawDates", true); drawOccupation = properties.get("drawOccupation", true); maxNames = properties.get("maxNames", -1); + maxNamesPerLine = properties.get("maxNamesPerLine", 2); drawSexSymbols = properties.get("drawSexSymbols", true); drawIndiIds = properties.get("drawIndiIds", false); } @@ -96,8 +100,16 @@ if (lines - DEFAULT_LINES > 0) indibox.height += (lines - DEFAULT_LINES) * LINE_HEIGHT; + /* generalize height and width computations for first names */ + int width = 0; + String[] temp = getFirstNames(i); + for (int j = 0; j < temp.length; j++) { + int w2 = getTextWidth(temp[j], NAME_FONT); + width = width>w2?width:w2; + } + indibox.height += temp.length - 1; + // Text data width - int width = getTextWidth(getFirstNames(i), NAME_FONT); if (width + 2*TEXT_MARGIN > indibox.width) indibox.width = width + 2*TEXT_MARGIN; width = getTextWidth(i.getLastName(), NAME_FONT); @@ -171,15 +183,39 @@ * individual. If maxNames is 0, this method returns all * given names. */ - private String getFirstNames(Indi indi) { - String firstName = indi.getFirstName(); - if (maxNames <= 0) - return firstName; - - String[] names = firstName.split(" *"); - firstName = ""; - for (int j = 0; j < maxNames && j < names.length; j++) - firstName += names[j] + " "; - return firstName.trim(); + private String[] getFirstNames(Indi indi) { + ArrayList firstName = new ArrayList(); + + /* display all names */ + if ((maxNames <= 0) && (maxNamesPerLine == 0)) { + firstName.add(indi.getFirstName()); + } else if (maxNamesPerLine == 0) { + String[] names = indi.getFirstName().split(" *"); + String temp = ""; + for (int j = 0; j < maxNames && j < names.length; j++) { + temp += names[j] + " "; + } + temp.trim(); + firstName.add(temp); + } else { + /* we ignore maxNames when maxNamesPerLine is set */ + String[] names = indi.getFirstName().split(" *"); + int j = 0, k = 0; + String temp = ""; + for (int i = 0; i < names.length; i++) { + if (k >= maxNamesPerLine) { + temp.trim(); + firstName.add(temp); + j++; temp = ""; k=0; + } + temp += names[i] + " "; + k++; + } + + temp.trim(); + firstName.add(temp); + } + + return (String[]) firstName.toArray(new String[firstName.size()]); } } diff -Nur tree.old/output/GraphicsTreeElements.java tree/output/GraphicsTreeElements.java --- tree.old/output/GraphicsTreeElements.java 2008-02-01 10:28:29.000000000 +0800 +++ tree/output/GraphicsTreeElements.java 2008-02-04 10:17:32.000000000 +0800 @@ -27,6 +27,8 @@ import java.awt.geom.Rectangle2D; import java.awt.geom.RoundRectangle2D; +import java.util.ArrayList; + import tree.FamBox; import tree.IndiBox; @@ -157,6 +159,8 @@ private int maxNames; + private int maxNamesPerLine; + private boolean useColors; private boolean drawPlaces; @@ -184,6 +188,7 @@ drawIndiIds = properties.get("drawIndiIds", false); drawFamIds = properties.get("drawFamIds", false); maxNames = properties.get("maxNames", -1); + maxNamesPerLine = properties.get("maxNamesPerLine", 2); useColors = properties.get("useColors", true); maxImageWidth = properties.get("maxImageWidth", 0); drawPlaces = properties.get("drawPlaces", true); @@ -241,16 +246,37 @@ // Name graphics.setFont(NAME_FONT); - int firstNameY = 14; - int lastNameY = 26; - if (swapNames) { - firstNameY = 26; - lastNameY = 14; - } - centerString(graphics, getFirstNames(i), x + dataWidth/2, y + firstNameY); - centerString(graphics, i.getLastName(), x + dataWidth/2, y + lastNameY); + /* generalized vertical placement rules */ + int currentY = 0; + String[] firstNames = getFirstNames(i); + + if (swapNames) { + int firstNameY = 26; + int lastNameY = 14; + for (int j = 0; j < firstNames.length; j++) { + centerString(graphics, firstNames[j], x + dataWidth/2, + y + firstNameY); + firstNameY += 12; + } + + centerString(graphics, i.getLastName(), x + dataWidth/2, + y + lastNameY); + + currentY = y + firstNameY - 12; + } else { + int firstNameY = 14; + int lastNameY = 26; + for (int j = firstNames.length; j > 0; j--) { + centerString(graphics, firstNames[j-1], x + dataWidth/2, + y + firstNameY); + firstNameY += 12; + } + + centerString(graphics, i.getLastName(), x + dataWidth/2, + y + lastNameY); - int currentY = y + 38; + currentY = y + firstNameY; + } graphics.setFont(DETAILS_FONT); @@ -500,15 +526,39 @@ * individual. If maxNames is 0, this method returns all * given names. */ - private String getFirstNames(Indi indi) { - String firstName = indi.getFirstName(); - if (maxNames <= 0) - return firstName; - - String[] names = firstName.split(" *"); - firstName = ""; - for (int j = 0; j < maxNames && j < names.length; j++) - firstName += names[j] + " "; - return firstName.trim(); + private String[] getFirstNames(Indi indi) { + ArrayList firstName = new ArrayList(); + + /* display all names */ + if ((maxNames <= 0) && (maxNamesPerLine == 0)) { + firstName.add(indi.getFirstName()); + } else if (maxNamesPerLine == 0) { + String[] names = indi.getFirstName().split(" *"); + String temp = ""; + for (int j = 0; j < maxNames && j < names.length; j++) { + temp += names[j] + " "; + } + temp.trim(); + firstName.add(temp); + } else { + /* we ignore maxNames when maxNamesPerLine is set */ + String[] names = indi.getFirstName().split(" *"); + int j = 0, k = 0; + String temp = ""; + for (int i = 0; i < names.length; i++) { + if (k >= maxNamesPerLine) { + temp.trim(); + firstName.add(temp); + j++; temp = ""; k=0; + } + temp += names[i] + " "; + k++; + } + + temp.trim(); + firstName.add(temp); + } + + return (String[]) firstName.toArray(new String[firstName.size()]); } } diff -Nur tree.old/ReportGraphicalTree.java tree/ReportGraphicalTree.java --- tree.old/ReportGraphicalTree.java 2008-02-01 10:28:29.000000000 +0800 +++ tree/ReportGraphicalTree.java 2008-02-04 08:39:53.000000000 +0800 @@ -124,6 +124,11 @@ public String[] max_namess = { translate("nolimit"), "1", "2", "3" }; /** + * Maximal number of first names to display per line. + */ + public int max_names_per_line = 2; + + /** * Whether to display places of birth and death. */ public boolean draw_places = true; @@ -225,6 +230,7 @@ properties.put("genAncestorDescendants", gen_ancestor_descendants - 1); properties.put("genDescendants", gen_descendants - 1); properties.put("maxNames", max_names); + properties.put("maxNamesPerLine", max_names_per_line); properties.put("defaultIndiboxHeight", DEFAULT_INDIBOX_HEIGHT); properties.put("defaultIndiboxWidth", shrink_boxes ? SHRINKED_INDIBOX_WIDTH : DEFAULT_INDIBOX_WIDTH); properties.put("spacing", SPACING); diff -Nur tree.old/ReportGraphicalTree.properties tree/ReportGraphicalTree.properties --- tree.old/ReportGraphicalTree.properties 2008-02-01 10:28:29.000000000 +0800 +++ tree/ReportGraphicalTree.properties 2008-02-04 08:39:04.000000000 +0800 @@ -181,6 +181,11 @@ max_names.fr = Nombre maximum de prénoms devant être affichés max_names.de = Maximale Anzahl von angezeigten Vornamen +max_names_per_line = Maximum number of given names per line +max_names_per_line.pl = Maximum number of given names per line +max_names_per_line.fr = Maximum number of given names per line +max_names_per_line.de = Maximum number of given names per line + draw_places = Display places of birth and death draw_places.pl = Pokazuj miejsca urodzenia i śmierci draw_places.fr = Afficher les lieux de naissance et de décès