diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextActor.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextActor.java index 12ad3441d28..82b0a5c69ea 100644 --- a/src/net/sourceforge/plantuml/asciiart/ComponentTextActor.java +++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextActor.java @@ -101,7 +101,9 @@ public double getPreferredHeight(StringBounder stringBounder) { } public double getPreferredWidth(StringBounder stringBounder) { - return StringUtils.getWcWidth(stringsToDisplay) + 2; + // make all widths odd sized by converting the string widths to even, + // adding 3 to make it both odd and padded by 1 on each side, then return the result + // as a double. + return (double) ((StringUtils.getWcWidth(stringsToDisplay) / 2 * 2) + 3); } - } diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextParticipant.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextParticipant.java index 85cbcbd415d..fb5553fc7b4 100644 --- a/src/net/sourceforge/plantuml/asciiart/ComponentTextParticipant.java +++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextParticipant.java @@ -63,9 +63,12 @@ public void drawU(UGraphic ug, Area area, Context2D context) { final UmlCharArea charArea = ((UGraphicTxt) ug).getCharArea(); final int width = (int) dimensionToUse.getWidth(); final int height = (int) dimensionToUse.getHeight(); - charArea.fillRect(' ', 0, 0, width, height); + int textWidth = StringUtils.getWcWidth(stringsToDisplay); + int boxWidth = textWidth+2; + + charArea.fillRect(' ', 0, 0, boxWidth, height); if (fileFormat == FileFormat.UTXT) { - charArea.drawBoxSimpleUnicode(0, 0, width, height); + charArea.drawBoxSimpleUnicode(0, 0, boxWidth, height); if (type == ComponentType.PARTICIPANT_TAIL) { charArea.drawChar('\u2534', (width - 1) / 2, 0); } @@ -73,7 +76,7 @@ public void drawU(UGraphic ug, Area area, Context2D context) { charArea.drawChar('\u252c', (width - 1) / 2, height - 1); } } else { - charArea.drawBoxSimple(0, 0, width, height); + charArea.drawBoxSimple(0, 0, boxWidth, height); if (type == ComponentType.PARTICIPANT_TAIL) { charArea.drawChar('+', (width - 1) / 2, 0); } @@ -93,7 +96,10 @@ public double getPreferredHeight(StringBounder stringBounder) { } public double getPreferredWidth(StringBounder stringBounder) { - return StringUtils.getWcWidth(stringsToDisplay) + 2; + // make all widths odd sized by converting the string widths to even, + // adding 3 to make it both odd and padded by 1 on each side, then return the result + // as a double. + return (double) ((StringUtils.getWcWidth(stringsToDisplay) / 2 * 2) + 3); } } diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextSelfArrow.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextSelfArrow.java index 2a0e94b7028..00782cd4b92 100644 --- a/src/net/sourceforge/plantuml/asciiart/ComponentTextSelfArrow.java +++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextSelfArrow.java @@ -73,32 +73,32 @@ public void drawU(UGraphic ug, Area area, Context2D context) { final int width = (int) dimensionToUse.getWidth(); final int height = (int) dimensionToUse.getHeight() - 1; - charArea.fillRect(' ', 0, 0, width, height); + charArea.fillRect(' ', 1, 0, width-2, height); if (fileFormat == FileFormat.UTXT) { if (config.isDotted()) { - charArea.drawStringLR("\u2500 \u2500 \u2510", 0, 0); - charArea.drawStringLR("|", 4, 1); - charArea.drawStringLR("< \u2500 \u2518", 0, 2); + charArea.drawStringLR("\u2500 \u2500 \u2510", 1, 0); + charArea.drawStringLR("|", 5, 1); + charArea.drawStringLR("< \u2500 \u2518", 1, 2); } else { - charArea.drawStringLR("\u2500\u2500\u2500\u2500\u2510", 0, 0); - charArea.drawStringLR("\u2502", 4, 1); - charArea.drawStringLR("<\u2500\u2500\u2500\u2518", 0, 2); + charArea.drawStringLR("\u2500\u2500\u2500\u2500\u2510", 1, 0); + charArea.drawStringLR("\u2502", 5, 1); + charArea.drawStringLR("<\u2500\u2500\u2500\u2518", 1, 2); } } else if (config.isDotted()) { - charArea.drawStringLR("- - .", 0, 0); - charArea.drawStringLR("|", 4, 1); - charArea.drawStringLR("< - '", 0, 2); + charArea.drawStringLR("- - .", 1, 0); + charArea.drawStringLR("|", 5, 1); + charArea.drawStringLR("< - '", 1, 2); } else { - charArea.drawStringLR("----.", 0, 0); - charArea.drawStringLR("|", 4, 1); - charArea.drawStringLR("<---'", 0, 2); + charArea.drawStringLR("----.", 1, 0); + charArea.drawStringLR("|", 5, 1); + charArea.drawStringLR("<---'", 1, 2); } if (fileFormat == FileFormat.UTXT) { - charArea.drawStringsLRUnicode(stringsToDisplay.asList(), 6, 1); + charArea.drawStringsLRUnicode(stringsToDisplay.asList(), 7, 1); } else { - charArea.drawStringsLRSimple(stringsToDisplay.asList(), 6, 1); + charArea.drawStringsLRSimple(stringsToDisplay.asList(), 7, 1); } } @@ -107,7 +107,7 @@ public double getPreferredHeight(StringBounder stringBounder) { } public double getPreferredWidth(StringBounder stringBounder) { - return StringUtils.getWcWidth(stringsToDisplay) + 6; + return StringUtils.getWcWidth(stringsToDisplay) + 8; } public XPoint2D getStartPoint(StringBounder stringBounder, XDimension2D dimensionToUse) { diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextShape.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextShape.java index 7f94b21dd08..960353a6574 100644 --- a/src/net/sourceforge/plantuml/asciiart/ComponentTextShape.java +++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextShape.java @@ -83,7 +83,9 @@ public double getPreferredHeight(StringBounder stringBounder) { } public double getPreferredWidth(StringBounder stringBounder) { - return StringUtils.getWcWidth(stringsToDisplay) + 2; + // make all widths odd sized by converting the string widths to even, + // adding 3 to make it both odd and padded by 1 on each side, then return the result + // as a double. + return (double) ((StringUtils.getWcWidth(stringsToDisplay) / 2 * 2) + 3); } - }