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-01 12:40:24.000000000 +0800 @@ -97,7 +97,12 @@ indibox.height += (lines - DEFAULT_LINES) * LINE_HEIGHT; // Text data width - int width = getTextWidth(getFirstNames(i), NAME_FONT); + int width = getTextWidth(getFirstNames(i)[0], NAME_FONT); + if (getFirstNames(i).length > 1) { + int w2 = getTextWidth(getFirstNames(i)[1], NAME_FONT); + width = width>w2?width:w2; + } + if (width + 2*TEXT_MARGIN > indibox.width) indibox.width = width + 2*TEXT_MARGIN; width = getTextWidth(i.getLastName(), NAME_FONT); @@ -171,15 +176,29 @@ * 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) { + String[] firstName = {"",""}; + String[] names = indi.getFirstName().split(" *"); + + maxNames = (names.length>maxNames?names.length:maxNames); + + /* if there are greater than 3 names break it into 2 lines */ + if (maxNames < 3) { + for (int j = 0; j < maxNames && j < names.length; j++) + firstName[0] += names[j] + " "; + firstName[0] = firstName[0].trim(); + } else { + for (int j = 0; j < (maxNames/2) && j < names.length; j++) + firstName[0] += names[j] + " "; + firstName[0] = firstName[0].trim(); + + firstName[1] = ""; + for (int j = (maxNames/2); j < maxNames && + j < names.length; j++) + firstName[1] += names[j] + " "; + firstName[1] = firstName[1].trim(); + } + + return firstName; } } 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-01 12:36:46.000000000 +0800 @@ -32,182 +32,193 @@ /** * Draws tree elements to a Graphics2D object. - * + * * @author Przemek Wiech */ public class GraphicsTreeElements implements TreeElements { - private static final int LINE_HEIGHT = 10; - private static final TagPath PATH_INDIBIRTPLAC = new TagPath("INDI:BIRT:PLAC"); - private static final TagPath PATH_INDIDEATPLAC = new TagPath("INDI:DEAT:PLAC"); - private static final TagPath PATH_INDIOCCU = new TagPath("INDI:OCCU"); - private static final TagPath PATH_FAMMARRPLAC = new TagPath("FAM:MARR:PLAC"); - private static final TagPath PATH_FAMDIVPLAC = new TagPath("FAM:DIV:PLAC"); - - /** - * Box background colors. - */ - private static final Color[] BOX_COLORS = { - new Color(0xff, 0xff, 0xff), // -13 - new Color(0xce, 0xb6, 0xbd), // -12 - new Color(0xde, 0x55, 0xff), // -11 - new Color(0x84, 0x82, 0xff), // -10 - new Color(0xad, 0xae, 0xef), // -9 - new Color(0xad, 0xcf, 0xff), // -8 - new Color(0xe7, 0xdb, 0xe7), // -7 - new Color(0xd6, 0x5d, 0x5a), // -6 - new Color(0xff, 0x82, 0xb5), // -5 - new Color(0xef, 0xae, 0xc6), // -4 - new Color(0xff, 0xdd, 0xdd), // -3 - new Color(0xce, 0xaa, 0x31), // -2 - new Color(0xff, 0xdd, 0x00), // -1 - - new Color(0xff, 0xff, 0x33), // 0 - - new Color(0xff, 0xff, 0xdd), // 1 - new Color(0xde, 0xff, 0xde), // 2 - new Color(0x82, 0xff, 0x82), // 3 - new Color(0x1a, 0xe1, 0x1a), // 4 - new Color(0xa9, 0xd0, 0xa9), // 5 - new Color(0xa9, 0xd0, 0xbf), // 6 - new Color(0xbb, 0xbb, 0xbb), // 7 - new Color(0xaa, 0x95, 0x95), // 8 - new Color(0x9e, 0xa3, 0xb2), // 9 - new Color(0xcd, 0xd3, 0xe9), // 10 - new Color(0xdf, 0xe2, 0xe2), // 11 - new Color(0xfa, 0xfa, 0xfa), // 12 - new Color(0xff, 0xff, 0xff) // 13 - }; - - private static final int COLOR_GENERATIONS = (BOX_COLORS.length - 1) / 2; - - public static final float STROKE_WIDTH = 2.0f; - - /** - * Male sex symbol. - */ - private static final String MALE_SYMBOL = "\u2642"; - - /** - * Female sex symbol. - */ - private static final String FEMALE_SYMBOL = "\u2640"; - - /** - * Unknown sex symbol. - */ - private static final String UNKNOWN_SYMBOL = "?"; - - /** - * Stroke for drawing dashed lines. - */ - private static final Stroke DASHED_STROKE = new BasicStroke(STROKE_WIDTH, - BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, - new float[] { 3.0f, 6.0f }, 0.0f); - - /** - * Font for individual and family details - */ - private static final Font DETAILS_FONT = new Font("verdana", Font.PLAIN, 10); - - /** - * Font for the first and last names. - */ - private static final Font NAME_FONT = new Font("verdana", Font.BOLD, 12); - - /** - * Font for individual and family ID. - */ - private static final Font ID_FONT = new Font("verdana", Font.ITALIC, 10); - - /** - * Font for drawing the sex symbols. - */ - private static Font sexSymbolFont = null; - static { - // Find a font with the MALE_SYMBOL in it - String[] candidateFontNames = { "sansserif", "apple symbol", "symbol" }; - for (int i = 0; i < candidateFontNames.length; i++) { - Font candidateFont = new Font(candidateFontNames[i], Font.PLAIN, 10); - if (candidateFont.canDisplay(MALE_SYMBOL.charAt(0))) { - sexSymbolFont = candidateFont; - break; - } - } - if (sexSymbolFont == null) - sexSymbolFont = new Font("SansSerif", Font.PLAIN, 10); - } + private static final int LINE_HEIGHT = 10; - private int maxImageWidth; + private static final TagPath PATH_INDIBIRTPLAC = new TagPath( + "INDI:BIRT:PLAC"); - /** - * Whether to draw the sex symbol. - */ - private boolean drawSexSymbols; - - /** - * Whether do draw IDs of individuals. - */ - private boolean drawIndiIds; - - /** - * Whether to draw IDs of families. - */ - private boolean drawFamIds; - - private int maxNames; - - private boolean useColors; - - private boolean drawPlaces; - - private boolean drawDates; - - private boolean drawOccupation; - - private boolean drawDivorce; - - private boolean swapNames; - - /** - * The graphics object to paint on. - */ - private Graphics2D graphics = null; - - /** - * Constructs the object. - */ - public GraphicsTreeElements(Graphics2D graphics, Registry properties) { - this.graphics = graphics; - - drawSexSymbols = properties.get("drawSexSymbols", true); - drawIndiIds = properties.get("drawIndiIds", false); - drawFamIds = properties.get("drawFamIds", false); - maxNames = properties.get("maxNames", -1); - useColors = properties.get("useColors", true); - maxImageWidth = properties.get("maxImageWidth", 0); - drawPlaces = properties.get("drawPlaces", true); - drawDates = properties.get("drawDates", true); - drawOccupation = properties.get("drawOccupation", true); - drawDivorce = properties.get("drawDivorce", true); - swapNames = properties.get("swapNames", false); - } + private static final TagPath PATH_INDIDEATPLAC = new TagPath( + "INDI:DEAT:PLAC"); - /** - * Sets the Graphics2D object to draw on. - */ - public void setGraphics(Graphics2D graphics) { - this.graphics = graphics; - } + private static final TagPath PATH_INDIOCCU = new TagPath("INDI:OCCU"); + + private static final TagPath PATH_FAMMARRPLAC = new TagPath("FAM:MARR:PLAC"); + + private static final TagPath PATH_FAMDIVPLAC = new TagPath("FAM:DIV:PLAC"); + + /** + * Box background colors. + */ + private static final Color[] BOX_COLORS = { new Color(0xff, 0xff, 0xff), // -13 + new Color(0xce, 0xb6, 0xbd), // -12 + new Color(0xde, 0x55, 0xff), // -11 + new Color(0x84, 0x82, 0xff), // -10 + new Color(0xad, 0xae, 0xef), // -9 + new Color(0xad, 0xcf, 0xff), // -8 + new Color(0xe7, 0xdb, 0xe7), // -7 + new Color(0xd6, 0x5d, 0x5a), // -6 + new Color(0xff, 0x82, 0xb5), // -5 + new Color(0xef, 0xae, 0xc6), // -4 + new Color(0xff, 0xdd, 0xdd), // -3 + new Color(0xce, 0xaa, 0x31), // -2 + new Color(0xff, 0xdd, 0x00), // -1 + + new Color(0xff, 0xff, 0x33), // 0 + + new Color(0xff, 0xff, 0xdd), // 1 + new Color(0xde, 0xff, 0xde), // 2 + new Color(0x82, 0xff, 0x82), // 3 + new Color(0x1a, 0xe1, 0x1a), // 4 + new Color(0xa9, 0xd0, 0xa9), // 5 + new Color(0xa9, 0xd0, 0xbf), // 6 + new Color(0xbb, 0xbb, 0xbb), // 7 + new Color(0xaa, 0x95, 0x95), // 8 + new Color(0x9e, 0xa3, 0xb2), // 9 + new Color(0xcd, 0xd3, 0xe9), // 10 + new Color(0xdf, 0xe2, 0xe2), // 11 + new Color(0xfa, 0xfa, 0xfa), // 12 + new Color(0xff, 0xff, 0xff) // 13 + }; + + private static final int COLOR_GENERATIONS = (BOX_COLORS.length - 1) / 2; + + public static final float STROKE_WIDTH = 2.0f; + + /** + * Male sex symbol. + */ + private static final String MALE_SYMBOL = "\u2642"; + + /** + * Female sex symbol. + */ + private static final String FEMALE_SYMBOL = "\u2640"; + + /** + * Unknown sex symbol. + */ + private static final String UNKNOWN_SYMBOL = "?"; + + /** + * Stroke for drawing dashed lines. + */ + private static final Stroke DASHED_STROKE = new BasicStroke(STROKE_WIDTH, + BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, new float[] { + 3.0f, 6.0f }, 0.0f); + + /** + * Font for individual and family details + */ + private static final Font DETAILS_FONT = new Font("verdana", Font.PLAIN, 10); + + /** + * Font for the first and last names. + */ + private static final Font NAME_FONT = new Font("verdana", Font.BOLD, 12); + + /** + * Font for individual and family ID. + */ + private static final Font ID_FONT = new Font("verdana", Font.ITALIC, 10); + + /** + * Font for drawing the sex symbols. + */ + private static Font sexSymbolFont = null; + static { + // Find a font with the MALE_SYMBOL in it + String[] candidateFontNames = { "sansserif", "apple symbol", "symbol" }; + for (int i = 0; i < candidateFontNames.length; i++) { + Font candidateFont = new Font(candidateFontNames[i], Font.PLAIN, 10); + if (candidateFont.canDisplay(MALE_SYMBOL.charAt(0))) { + sexSymbolFont = candidateFont; + break; + } + } + if (sexSymbolFont == null) + sexSymbolFont = new Font("SansSerif", Font.PLAIN, 10); + } + + private int maxImageWidth; + + /** + * Whether to draw the sex symbol. + */ + private boolean drawSexSymbols; + + /** + * Whether do draw IDs of individuals. + */ + private boolean drawIndiIds; + + /** + * Whether to draw IDs of families. + */ + private boolean drawFamIds; + + private int maxNames; + + private boolean useColors; + + private boolean drawPlaces; + + private boolean drawDates; + + private boolean drawOccupation; + + private boolean drawDivorce; + + private boolean swapNames; + + /** + * The graphics object to paint on. + */ + private Graphics2D graphics = null; + + /** + * Constructs the object. + */ + public GraphicsTreeElements(Graphics2D graphics, Registry properties) { + this.graphics = graphics; + + drawSexSymbols = properties.get("drawSexSymbols", true); + drawIndiIds = properties.get("drawIndiIds", false); + drawFamIds = properties.get("drawFamIds", false); + maxNames = properties.get("maxNames", -1); + useColors = properties.get("useColors", true); + maxImageWidth = properties.get("maxImageWidth", 0); + drawPlaces = properties.get("drawPlaces", true); + drawDates = properties.get("drawDates", true); + drawOccupation = properties.get("drawOccupation", true); + drawDivorce = properties.get("drawDivorce", true); + swapNames = properties.get("swapNames", false); + } + + /** + * Sets the Graphics2D object to draw on. + */ + public void setGraphics(Graphics2D graphics) { + this.graphics = graphics; + } - /** - * Outputs an individual box. - * @param i individual - * @param x x coordinate - * @param y y coordinate - * @param gen generation number - */ - public void drawIndiBox(IndiBox indibox, int x, int y, int gen) { + /** + * Outputs an individual box. + * + * @param i + * individual + * @param x + * x coordinate + * @param y + * y coordinate + * @param gen + * generation number + */ + public void drawIndiBox(IndiBox indibox, int x, int y, int gen) { Indi i = indibox.individual; // Determine photo size @@ -241,14 +252,29 @@ // 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); + String[] firstName = getFirstNames(i); + if (firstName.length == 1) { + int firstNameY = 14; + int lastNameY = 26; + if (swapNames) { + firstNameY = 26; + lastNameY = 14; + } + centerString(graphics, firstName[0], x + dataWidth/2, y + firstNameY); + centerString(graphics, i.getLastName(), x + dataWidth/2, y + lastNameY); + } else { + int firstNameY = 14; + int firstName2Y = 26; + int lastNameY = 38; + if (swapNames) { + firstNameY = 26; + firstName2Y = 38; + lastNameY = 14; + } + centerString(graphics, firstName[0], x + dataWidth/2, y + firstNameY); + centerString(graphics, firstName[1], x + dataWidth/2, y + firstName2Y); + centerString(graphics, i.getLastName(), x + dataWidth/2, y + lastNameY); + } int currentY = y + 38; @@ -337,178 +363,213 @@ graphics.setClip(oldClip); graphics.draw(box); } - /** - * Outputs a family box. - * @param i individual - * @param x x coordinate - * @param y y coordinate - * @param gen generation number - */ - public void drawFamBox(FamBox fambox, int x, int y, int gen) { - Fam f = fambox.family; - Color color = getBoxColor(gen); - Shape box = new RoundRectangle2D.Double(x, y, fambox.width, fambox.height, 5, 5); - graphics.setColor(color); - graphics.fill(box); - graphics.setColor(Color.BLACK); + /** + * Outputs a family box. + * + * @param i + * individual + * @param x + * x coordinate + * @param y + * y coordinate + * @param gen + * generation number + */ + public void drawFamBox(FamBox fambox, int x, int y, int gen) { + Fam f = fambox.family; + + Color color = getBoxColor(gen); + Shape box = new RoundRectangle2D.Double(x, y, fambox.width, + fambox.height, 5, 5); + graphics.setColor(color); + graphics.fill(box); + graphics.setColor(Color.BLACK); + + Shape oldClip = graphics.getClip(); + graphics.clip(box); + + int currentY = y + 12; + + graphics.setFont(DETAILS_FONT); + + Property marriageDate = null; + Property divorceDate = null; + Property marriagePlace = null; + Property divorcePlace = null; + + if (drawDates) { + marriageDate = f.getMarriageDate(); + if (marriageDate != null && !marriageDate.isValid()) + marriageDate = null; + divorceDate = f.getDivorceDate(); + if (divorceDate != null && !divorceDate.isValid()) + divorceDate = null; + } + + if (drawPlaces) { + marriagePlace = f.getProperty(PATH_FAMMARRPLAC); + if (marriagePlace != null && marriagePlace.toString().equals("")) + marriagePlace = null; + divorcePlace = f.getProperty(PATH_FAMDIVPLAC); + if (divorcePlace != null && divorcePlace.toString().equals("")) + divorcePlace = null; + } + + // Date and place of marriage + if (f.getMarriageDate() != null) { + centerString(graphics, Options.getInstance().getMarriageSymbol(), + x + 13, currentY); + if (marriageDate != null) { + graphics.drawString(marriageDate.toString(), x + 25, currentY); + currentY += LINE_HEIGHT; + } + if (marriagePlace != null) { + graphics.drawString(marriagePlace.toString(), x + 25, currentY); + currentY += LINE_HEIGHT; + } + if (marriageDate == null && marriagePlace == null) + currentY += LINE_HEIGHT; + } + + // Date and place of divorce + if (drawDivorce && f.getDivorceDate() != null) { + centerString(graphics, Options.getInstance().getDivorceSymbol(), + x + 13, currentY); + if (divorceDate != null) { + graphics.drawString(divorceDate.toString(), x + 25, currentY); + currentY += LINE_HEIGHT; + } + if (divorcePlace != null) { + graphics.drawString(divorcePlace.toString(), x + 25, currentY); + currentY += LINE_HEIGHT; + } + if (divorceDate == null && divorcePlace == null) + currentY += LINE_HEIGHT; + } + + // Id + if (drawFamIds) { + graphics.setFont(ID_FONT); + graphics.drawString(f.getId(), x + 8, y + fambox.height - 4); + } - Shape oldClip = graphics.getClip(); - graphics.clip(box); + graphics.setClip(oldClip); + graphics.draw(box); + } - int currentY = y + 12; + /** + * Outputs a line. + * + * @param x1 + * start x + * @param y1 + * start y + * @param x2 + * end x + * @param y2 + * end y + */ + public void drawLine(int x1, int y1, int x2, int y2) { + graphics.drawLine(x1, y1, x2, y2); + } - graphics.setFont(DETAILS_FONT); + /** + * Outputs a dashed line. + * + * @param x1 + * start x + * @param y1 + * start y + * @param x2 + * end x + * @param y2 + * end y + */ + public void drawDashedLine(int x1, int y1, int x2, int y2) { + Stroke oldStroke = graphics.getStroke(); + graphics.setStroke(DASHED_STROKE); + graphics.drawLine(x1, y1, x2, y2); + graphics.setStroke(oldStroke); + } - Property marriageDate = null; - Property divorceDate = null; - Property marriagePlace = null; - Property divorcePlace = null; + /** + * Initializes the graphics. + */ + public void header(int width, int height) { + graphics.setStroke(new BasicStroke(STROKE_WIDTH)); + graphics.setBackground(Color.WHITE); + graphics.clearRect(0, 0, width, height); + } - if (drawDates) { - marriageDate = f.getMarriageDate(); - if (marriageDate != null && !marriageDate.isValid()) - marriageDate = null; - divorceDate = f.getDivorceDate(); - if (divorceDate != null && !divorceDate.isValid()) - divorceDate = null; - } + /** + * Does nothing. + */ + public void footer() { + } - if (drawPlaces) { - marriagePlace = f.getProperty(PATH_FAMMARRPLAC); - if (marriagePlace != null && marriagePlace.toString().equals("")) - marriagePlace = null; - divorcePlace = f.getProperty(PATH_FAMDIVPLAC); - if (divorcePlace != null && divorcePlace.toString().equals("")) - divorcePlace = null; - } + /** + * Outputs a string centered. + */ + public static void centerString(Graphics2D graphics, String text, int x, + int y) { + Rectangle2D rect = graphics.getFont().getStringBounds(text, + graphics.getFontRenderContext()); + int width = (int) rect.getWidth(); + graphics.drawString(text, x - width / 2, y); + } - // Date and place of marriage - if (f.getMarriageDate() != null) { - centerString(graphics, Options.getInstance().getMarriageSymbol(), x + 13, currentY); - if (marriageDate != null) { - graphics.drawString(marriageDate.toString(), x + 25, currentY); - currentY += LINE_HEIGHT; - } - if (marriagePlace != null) { - graphics.drawString(marriagePlace.toString(), x + 25, currentY); - currentY += LINE_HEIGHT; - } - if (marriageDate == null && marriagePlace == null) - currentY += LINE_HEIGHT; - } + private static String getSexSymbol(int sex) { + if (sex == PropertySex.MALE) + return MALE_SYMBOL; + if (sex == PropertySex.FEMALE) + return FEMALE_SYMBOL; + return UNKNOWN_SYMBOL; + } - // Date and place of divorce - if (drawDivorce && f.getDivorceDate() != null) { - centerString(graphics, Options.getInstance().getDivorceSymbol(), x + 13, currentY); - if (divorceDate != null) { - graphics.drawString(divorceDate.toString(), x + 25, currentY); - currentY += LINE_HEIGHT; - } - if (divorcePlace != null) { - graphics.drawString(divorcePlace.toString(), x + 25, currentY); - currentY += LINE_HEIGHT; - } - if (divorceDate == null && divorcePlace == null) - currentY += LINE_HEIGHT; - } + /** + * Returns the box color for the given generation. + */ + private Color getBoxColor(int gen) { + if (!useColors) + return Color.WHITE; + if (gen == 0) + return BOX_COLORS[COLOR_GENERATIONS]; + if (gen < 0) + return BOX_COLORS[-((-gen - 1) % COLOR_GENERATIONS) + + COLOR_GENERATIONS - 1]; + // else (gen > 0) + return BOX_COLORS[(gen - 1) % COLOR_GENERATIONS + COLOR_GENERATIONS + 1]; + } - // Id - if (drawFamIds) { - graphics.setFont(ID_FONT); - graphics.drawString(f.getId(), x + 8, y + fambox.height - 4); + /** + * Returns a maximum of maxNames given names of the given + * individual. If maxNames is 0, this method returns all + * given names. + */ + private String[] getFirstNames(Indi indi) { + String[] firstName = {"",""}; + String[] names = indi.getFirstName().split(" *"); + + maxNames = (names.length>maxNames?names.length:maxNames); + + /* if there are greater than 3 names break it into 2 lines */ + if (maxNames < 3) { + for (int j = 0; j < maxNames && j < names.length; j++) + firstName[0] += names[j] + " "; + firstName[0] = firstName[0].trim(); + } else { + for (int j = 0; j < (maxNames/2) && j < names.length; j++) + firstName[0] += names[j] + " "; + firstName[0] = firstName[0].trim(); + + firstName[1] = ""; + for (int j = (maxNames/2); j < maxNames && + j < names.length; j++) + firstName[1] += names[j] + " "; + firstName[1] = firstName[1].trim(); } - graphics.setClip(oldClip); - graphics.draw(box); - } - - /** - * Outputs a line. - * @param x1 start x - * @param y1 start y - * @param x2 end x - * @param y2 end y - */ - public void drawLine(int x1, int y1, int x2, int y2) { - graphics.drawLine(x1, y1, x2, y2); - } - - /** - * Outputs a dashed line. - * @param x1 start x - * @param y1 start y - * @param x2 end x - * @param y2 end y - */ - public void drawDashedLine(int x1, int y1, int x2, int y2) { - Stroke oldStroke = graphics.getStroke(); - graphics.setStroke(DASHED_STROKE); - graphics.drawLine(x1, y1, x2, y2); - graphics.setStroke(oldStroke); - } - - /** - * Initializes the graphics. - */ - public void header(int width, int height) { - graphics.setStroke(new BasicStroke(STROKE_WIDTH)); - graphics.setBackground(Color.WHITE); - graphics.clearRect(0, 0, width, height); - } - - /** - * Does nothing. - */ - public void footer() { - } - - /** - * Outputs a string centered. - */ - public static void centerString(Graphics2D graphics, String text, int x, int y) { - Rectangle2D rect = graphics.getFont().getStringBounds(text, - graphics.getFontRenderContext()); - int width = (int) rect.getWidth(); - graphics.drawString(text, x - width / 2, y); - } - - private static String getSexSymbol(int sex) { - if (sex == PropertySex.MALE) - return MALE_SYMBOL; - if (sex == PropertySex.FEMALE) - return FEMALE_SYMBOL; - return UNKNOWN_SYMBOL; - } - - /** - * Returns the box color for the given generation. - */ - private Color getBoxColor(int gen) { - if (!useColors) - return Color.WHITE; - if (gen == 0) - return BOX_COLORS[COLOR_GENERATIONS]; - if (gen < 0) - return BOX_COLORS[-((-gen - 1) % COLOR_GENERATIONS) + COLOR_GENERATIONS - 1]; - // else (gen > 0) - return BOX_COLORS[(gen - 1) % COLOR_GENERATIONS + COLOR_GENERATIONS + 1]; - } - - /** - * Returns a maximum of maxNames given names of the given - * 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(); + return firstName; } }