diff --git a/pom.xml b/pom.xml index 3f8e00d64..6ce0cfb4e 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ net.sourceforge.plantuml plantuml - 1.2020.23-SNAPSHOT + 1.2020.24-SNAPSHOT jar PlantUML diff --git a/src/net/sourceforge/plantuml/BackSlash.java b/src/net/sourceforge/plantuml/BackSlash.java index 805161670..19f5a48db 100644 --- a/src/net/sourceforge/plantuml/BackSlash.java +++ b/src/net/sourceforge/plantuml/BackSlash.java @@ -42,13 +42,12 @@ import java.util.List; public class BackSlash { - private static final char PRIVATE_BLOCK = '\uE000'; public static final String BS_BS_N = "\\n"; public static final String NEWLINE = "\n"; public static final char CHAR_NEWLINE = '\n'; public static char hiddenNewLine() { - return PRIVATE_BLOCK + BackSlash.CHAR_NEWLINE; + return StringUtils.PRIVATE_BLOCK + BackSlash.CHAR_NEWLINE; } public static String convertHiddenNewLine(String s) { @@ -126,8 +125,8 @@ public class BackSlash { final StringBuilder result = new StringBuilder(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); - if (c > PRIVATE_BLOCK && c < '\uE07F') { - c = (char) (c - PRIVATE_BLOCK); + if (c > StringUtils.PRIVATE_BLOCK && c < '\uE07F') { + c = (char) (c - StringUtils.PRIVATE_BLOCK); } result.append(c); } @@ -138,7 +137,7 @@ public class BackSlash { if (c > 128) { throw new IllegalArgumentException(); } - return (char) (PRIVATE_BLOCK + c); + return (char) (StringUtils.PRIVATE_BLOCK + c); } } diff --git a/src/net/sourceforge/plantuml/EmbeddedDiagram.java b/src/net/sourceforge/plantuml/EmbeddedDiagram.java index 336174046..39f21a250 100644 --- a/src/net/sourceforge/plantuml/EmbeddedDiagram.java +++ b/src/net/sourceforge/plantuml/EmbeddedDiagram.java @@ -80,6 +80,9 @@ public class EmbeddedDiagram implements CharSequence { if (s.equals("{{gantt")) { return "gantt"; } + if (s.equals("{{json")) { + return "json"; + } return null; } diff --git a/src/net/sourceforge/plantuml/StringUtils.java b/src/net/sourceforge/plantuml/StringUtils.java index 22554c094..cbcb4b4d7 100644 --- a/src/net/sourceforge/plantuml/StringUtils.java +++ b/src/net/sourceforge/plantuml/StringUtils.java @@ -51,6 +51,59 @@ import net.sourceforge.plantuml.cucadiagram.Display; // Do not move public class StringUtils { + public static final char USER_NEWLINE = '\uEE00'; + public static final char USER_TAB = '\uEE01'; + + public static final char HR_SIMPLE = '\uEEFF'; + public static final char HR_DOUBLE = '\uEEFE'; + public static final char HR_DOTTED = '\uEEFD'; + public static final char HR_BOLD = '\uEEFC'; + + public static final char PRIVATE_FIELD = '\uEEFB'; + public static final char PROTECTED_FIELD = '\uEEFA'; + public static final char PACKAGE_PRIVATE_FIELD = '\uEEF9'; + public static final char PUBLIC_FIELD = '\uEEF8'; + public static final char PRIVATE_METHOD = '\uEEF7'; + public static final char PROTECTED_METHOD = '\uEEF6'; + public static final char PACKAGE_PRIVATE_METHOD = '\uEEF5'; + public static final char PUBLIC_METHOD = '\uEEF4'; + public static final char IE_MANDATORY = '\uEEF3'; + + // Used in BackSlash + public static final char PRIVATE_BLOCK = '\uE000'; + + public static final char INTERNAL_BOLD = '\uE100'; + + public static String toInternalBoldNumber(String s) { + final StringBuilder sb = new StringBuilder(); + for (int i = 0; i < s.length(); i++) { + final char c = s.charAt(i); + if (c >= '0' && c <= '9') { + sb.append(Character.toChars('\uE100' + c - '0')); + } else { + sb.append(c); + } + + } + return sb.toString(); + } + + public static void appendInternalToRealBoldNumber(StringBuilder sb, char c) { + if (c >= '\uE100' && c <= ('\uE100' + 9)) { + sb.append(Character.toChars(0x1d7ce + c - '\uE100')); + } else { + sb.append(c); + } + } + + public static void appendInternalToPlainNumber(StringBuilder sb, char c) { + if (c >= '\uE100' && c <= ('\uE100' + 9)) { + sb.append(Character.toChars('0' + c - '\uE100')); + } else { + sb.append(c); + } + } + final static public List getSplit(Pattern2 pattern, String line) { final Matcher2 m = pattern.matcher(line); if (m.find() == false) { diff --git a/src/net/sourceforge/plantuml/asciiart/BasicCharAreaImpl.java b/src/net/sourceforge/plantuml/asciiart/BasicCharAreaImpl.java index a44a2f5d6..f1ae23504 100644 --- a/src/net/sourceforge/plantuml/asciiart/BasicCharAreaImpl.java +++ b/src/net/sourceforge/plantuml/asciiart/BasicCharAreaImpl.java @@ -40,6 +40,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import net.sourceforge.plantuml.StringUtils; + public class BasicCharAreaImpl implements BasicCharArea { private int charSize1 = 160; @@ -141,7 +143,7 @@ public class BasicCharAreaImpl implements BasicCharArea { for (int x = 0; x < width; x++) { final char c = chars[x][line]; if (c != '\0') { - sb.append(c); + StringUtils.appendInternalToRealBoldNumber(sb, c); } } return sb.toString(); diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextActor.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextActor.java index 33b3ccbc3..4f4253007 100644 --- a/src/net/sourceforge/plantuml/asciiart/ComponentTextActor.java +++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextActor.java @@ -70,17 +70,19 @@ public class ComponentTextActor extends AbstractComponentText { final int xman = width / 2 - 1; if (type == ComponentType.ACTOR_HEAD) { - charArea.drawStringsLR(stringsToDisplay.as(), 1, getHeight()); if (fileFormat == FileFormat.UTXT) { + charArea.drawStringsLRUnicode(stringsToDisplay.as(), 1, getHeight()); charArea.drawShape(AsciiShape.STICKMAN_UNICODE, xman, 0); } else { + charArea.drawStringsLRSimple(stringsToDisplay.as(), 1, getHeight()); charArea.drawShape(AsciiShape.STICKMAN, xman, 0); } } else if (type == ComponentType.ACTOR_TAIL) { - charArea.drawStringsLR(stringsToDisplay.as(), 1, 0); if (fileFormat == FileFormat.UTXT) { + charArea.drawStringsLRUnicode(stringsToDisplay.as(), 1, 0); charArea.drawShape(AsciiShape.STICKMAN_UNICODE, xman, 1); } else { + charArea.drawStringsLRSimple(stringsToDisplay.as(), 1, 0); charArea.drawShape(AsciiShape.STICKMAN, xman, 1); } } else { diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextArrow.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextArrow.java index e436d584b..ee9a12975 100644 --- a/src/net/sourceforge/plantuml/asciiart/ComponentTextArrow.java +++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextArrow.java @@ -37,6 +37,8 @@ package net.sourceforge.plantuml.asciiart; import java.awt.geom.Dimension2D; import java.awt.geom.Point2D; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.StringUtils; @@ -62,14 +64,14 @@ public class ComponentTextArrow extends AbstractComponentText implements ArrowCo public ComponentTextArrow(ComponentType type, ArrowConfiguration config, Display stringsToDisplay, FileFormat fileFormat, int maxAsciiMessageLength) { + this.fileFormat = fileFormat; this.maxAsciiMessageLength = maxAsciiMessageLength; this.type = type; this.config = config; this.stringsToDisplay = clean(stringsToDisplay); - this.fileFormat = fileFormat; } - private static Display clean(Display orig) { + private Display clean(Display orig) { if (orig.size() == 0 || orig.get(0) instanceof MessageNumber == false) { return orig; } @@ -86,7 +88,19 @@ public class ComponentTextArrow extends AbstractComponentText implements ArrowCo return result; } - private static String removeTag(String s) { + private String removeTag(String s) { + if (fileFormat == FileFormat.UTXT) { + final Pattern pattern = Pattern.compile("\\([0-9]+)\\"); + final Matcher matcher = pattern.matcher(s); + final StringBuffer result = new StringBuffer(); + while (matcher.find()) { + final String num = matcher.group(1); + final String replace = StringUtils.toInternalBoldNumber(num); + matcher.appendReplacement(result, Matcher.quoteReplacement(replace)); + } + matcher.appendTail(result); + s = result.toString(); + } return s.replaceAll("\\<[^<>]+\\>", ""); } @@ -119,7 +133,12 @@ public class ComponentTextArrow extends AbstractComponentText implements ArrowCo throw new UnsupportedOperationException(); } // final int position = Math.max(0, (width - textWidth) / 2); - charArea.drawStringsLR(stringsToDisplay.as(), (width - textWidth) / 2, 0); + + if (fileFormat == FileFormat.UTXT) { + charArea.drawStringsLRUnicode(stringsToDisplay.as(), (width - textWidth) / 2, 0); + } else { + charArea.drawStringsLRSimple(stringsToDisplay.as(), (width - textWidth) / 2, 0); + } } public double getPreferredHeight(StringBounder stringBounder) { diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextNote.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextNote.java index a09c42462..c8119a709 100644 --- a/src/net/sourceforge/plantuml/asciiart/ComponentTextNote.java +++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextNote.java @@ -78,7 +78,11 @@ public class ComponentTextNote extends AbstractComponentText { charArea.drawBoxSimple(2, 0, width - 2, height); } } - charArea.drawStringsLR(stringsToDisplay.as(), 3, 1); + if (fileFormat == FileFormat.UTXT) { + charArea.drawStringsLRUnicode(stringsToDisplay.as(), 3, 1); + } else { + charArea.drawStringsLRSimple(stringsToDisplay.as(), 3, 1); + } } public double getPreferredHeight(StringBounder stringBounder) { diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextParticipant.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextParticipant.java index bdc034048..63998a3e8 100644 --- a/src/net/sourceforge/plantuml/asciiart/ComponentTextParticipant.java +++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextParticipant.java @@ -53,8 +53,7 @@ public class ComponentTextParticipant extends AbstractComponentText { private final Display stringsToDisplay; private final FileFormat fileFormat; - public ComponentTextParticipant(ComponentType type, Display stringsToDisplay, - FileFormat fileFormat) { + public ComponentTextParticipant(ComponentType type, Display stringsToDisplay, FileFormat fileFormat) { this.type = type; this.stringsToDisplay = stringsToDisplay; this.fileFormat = fileFormat; @@ -83,7 +82,11 @@ public class ComponentTextParticipant extends AbstractComponentText { charArea.drawChar('+', (width - 1) / 2, height - 1); } } - charArea.drawStringsLR(stringsToDisplay.as(), 1, 1); + if (fileFormat == FileFormat.UTXT) { + charArea.drawStringsLRUnicode(stringsToDisplay.as(), 1, 1); + } else { + charArea.drawStringsLRSimple(stringsToDisplay.as(), 1, 1); + } } public double getPreferredHeight(StringBounder stringBounder) { diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextSelfArrow.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextSelfArrow.java index c4325415d..78a77ef1c 100644 --- a/src/net/sourceforge/plantuml/asciiart/ComponentTextSelfArrow.java +++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextSelfArrow.java @@ -57,8 +57,8 @@ public class ComponentTextSelfArrow extends AbstractComponentText implements Arr private final FileFormat fileFormat; private final ArrowConfiguration config; - public ComponentTextSelfArrow(ComponentType type, ArrowConfiguration config, - Display stringsToDisplay, FileFormat fileFormat) { + public ComponentTextSelfArrow(ComponentType type, ArrowConfiguration config, Display stringsToDisplay, + FileFormat fileFormat) { this.type = type; this.stringsToDisplay = stringsToDisplay; this.fileFormat = fileFormat; @@ -96,7 +96,11 @@ public class ComponentTextSelfArrow extends AbstractComponentText implements Arr charArea.drawStringLR("<---'", 0, 2); } - charArea.drawStringsLR(stringsToDisplay.as(), 6, 1); + if (fileFormat == FileFormat.UTXT) { + charArea.drawStringsLRUnicode(stringsToDisplay.as(), 6, 1); + } else { + charArea.drawStringsLRSimple(stringsToDisplay.as(), 6, 1); + } } public double getPreferredHeight(StringBounder stringBounder) { @@ -114,7 +118,7 @@ public class ComponentTextSelfArrow extends AbstractComponentText implements Arr public Point2D getEndPoint(StringBounder stringBounder, Dimension2D dimensionToUse) { return new Point2D.Double(0, 0); } - + public double getPaddingY() { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextShape.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextShape.java index 281136a55..faf903bb1 100644 --- a/src/net/sourceforge/plantuml/asciiart/ComponentTextShape.java +++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextShape.java @@ -67,10 +67,10 @@ public class ComponentTextShape extends AbstractComponentText { final int xman = width / 2 - shape.getWidth() / 2 + 1; if (type.name().endsWith("_HEAD")) { - charArea.drawStringsLR(stringsToDisplay.as(), 1, getHeight()); + charArea.drawStringsLRSimple(stringsToDisplay.as(), 1, getHeight()); charArea.drawShape(shape, xman, 0); } else { - charArea.drawStringsLR(stringsToDisplay.as(), 1, 0); + charArea.drawStringsLRSimple(stringsToDisplay.as(), 1, 0); charArea.drawShape(shape, xman, 1); } } diff --git a/src/net/sourceforge/plantuml/asciiart/TextStringBounder.java b/src/net/sourceforge/plantuml/asciiart/TextStringBounder.java index e44c7a1bb..9bd92799f 100644 --- a/src/net/sourceforge/plantuml/asciiart/TextStringBounder.java +++ b/src/net/sourceforge/plantuml/asciiart/TextStringBounder.java @@ -44,7 +44,10 @@ import net.sourceforge.plantuml.ugraphic.UFont; public class TextStringBounder implements StringBounder { public Dimension2D calculateDimension(UFont font, String text) { - return new Dimension2DDouble(text.length(), 1); + final int length1 = text.codePointCount(0, text.length()); + final int length2 = text.length(); + final int length3 = Wcwidth.length(text); + return new Dimension2DDouble(length2, 1); } } diff --git a/src/net/sourceforge/plantuml/asciiart/TranslatedCharArea.java b/src/net/sourceforge/plantuml/asciiart/TranslatedCharArea.java index 4bea2a471..fa1601c47 100644 --- a/src/net/sourceforge/plantuml/asciiart/TranslatedCharArea.java +++ b/src/net/sourceforge/plantuml/asciiart/TranslatedCharArea.java @@ -116,8 +116,12 @@ public class TranslatedCharArea implements UmlCharArea { charArea.print(ps); } - public void drawStringsLR(Collection strings, int x, int y) { - charArea.drawStringsLR(strings, x + dx, y + dy); + public void drawStringsLRSimple(Collection strings, int x, int y) { + charArea.drawStringsLRSimple(strings, x + dx, y + dy); + } + + public void drawStringsLRUnicode(Collection strings, int x, int y) { + charArea.drawStringsLRUnicode(strings, x + dx, y + dy); } public void fillRect(char c, int x, int y, int width, int height) { diff --git a/src/net/sourceforge/plantuml/asciiart/UmlCharArea.java b/src/net/sourceforge/plantuml/asciiart/UmlCharArea.java index 86a1d95a1..c884100ca 100644 --- a/src/net/sourceforge/plantuml/asciiart/UmlCharArea.java +++ b/src/net/sourceforge/plantuml/asciiart/UmlCharArea.java @@ -49,6 +49,8 @@ public interface UmlCharArea extends BasicCharArea { void drawShape(AsciiShape shape, int x, int y); - void drawStringsLR(Collection strings, int x, int y); + void drawStringsLRSimple(Collection strings, int x, int y); + + void drawStringsLRUnicode(Collection strings, int x, int y); } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/asciiart/UmlCharAreaImpl.java b/src/net/sourceforge/plantuml/asciiart/UmlCharAreaImpl.java index 56466144d..3ec562326 100644 --- a/src/net/sourceforge/plantuml/asciiart/UmlCharAreaImpl.java +++ b/src/net/sourceforge/plantuml/asciiart/UmlCharAreaImpl.java @@ -37,6 +37,9 @@ package net.sourceforge.plantuml.asciiart; import java.util.Collection; +import net.sourceforge.plantuml.StringUtils; +import net.sourceforge.plantuml.sequencediagram.MessageNumber; + public class UmlCharAreaImpl extends BasicCharAreaImpl implements UmlCharArea { public void drawBoxSimple(int x, int y, int width, int height) { @@ -69,16 +72,32 @@ public class UmlCharAreaImpl extends BasicCharAreaImpl implements UmlCharArea { shape.draw(this, x, y); } - public void drawStringsLR(Collection strings, int x, int y) { + public void drawStringsLRSimple(Collection strings, int x, int y) { int i = 0; if (x < 0) { x = 0; } for (CharSequence s : strings) { + if (s instanceof MessageNumber) { + s = ((MessageNumber) s).getNumberRaw(); + } this.drawStringLR(s.toString(), x, y + i); i++; } + } + public void drawStringsLRUnicode(Collection strings, int x, int y) { + int i = 0; + if (x < 0) { + x = 0; + } + for (CharSequence s : strings) { + if (s instanceof MessageNumber) { + s = StringUtils.toInternalBoldNumber((((MessageNumber) s).getNumberRaw())); + } + this.drawStringLR(s.toString(), x, y + i); + i++; + } } public void drawNoteSimple(int x, int y, int width, int height) { diff --git a/src/net/sourceforge/plantuml/creole/atom/AtomImg.java b/src/net/sourceforge/plantuml/creole/atom/AtomImg.java index 435dbe4df..a611eeae4 100644 --- a/src/net/sourceforge/plantuml/creole/atom/AtomImg.java +++ b/src/net/sourceforge/plantuml/creole/atom/AtomImg.java @@ -67,6 +67,7 @@ import net.sourceforge.plantuml.ugraphic.UImage; public class AtomImg extends AbstractAtom implements Atom { private static final String DATA_IMAGE_PNG_BASE64 = "data:image/png;base64,"; + private static final String DATA_IMAGE_SVG_BASE64 = "data:image/svg+xml;base64,"; private final BufferedImage image; private final double scale; private final Url url; @@ -102,8 +103,19 @@ public class AtomImg extends AbstractAtom implements Atom { } catch (Exception e) { return AtomTextUtils.createLegacy("ERROR " + e.toString(), fc); } - } + + if (src.startsWith(DATA_IMAGE_SVG_BASE64)) { + final String data = src.substring(DATA_IMAGE_SVG_BASE64.length(), src.length()); + try { + final byte bytes[] = Base64Coder.decode(data); + final String tmp = new String(bytes); + return new AtomImgSvg(new TileImageSvg(tmp)); + } catch (Exception e) { + return AtomTextUtils.createLegacy("ERROR " + e.toString(), fc); + } + } + try { // Check if valid URL if (src.startsWith("http:") || src.startsWith("https:")) { diff --git a/src/net/sourceforge/plantuml/creole/legacy/AtomText.java b/src/net/sourceforge/plantuml/creole/legacy/AtomText.java index de46391b8..2ab88371f 100644 --- a/src/net/sourceforge/plantuml/creole/legacy/AtomText.java +++ b/src/net/sourceforge/plantuml/creole/legacy/AtomText.java @@ -54,13 +54,16 @@ import net.sourceforge.plantuml.creole.atom.AbstractAtom; import net.sourceforge.plantuml.creole.atom.Atom; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockUtils; +import net.sourceforge.plantuml.skin.VisibilityModifier; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UText; import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorAutomatic; import net.sourceforge.plantuml.ugraphic.color.HColorSimple; +import net.sourceforge.plantuml.ugraphic.color.HColorUtils; import net.sourceforge.plantuml.utils.CharHidder; public final class AtomText extends AbstractAtom implements Atom { @@ -75,12 +78,24 @@ public final class AtomText extends AbstractAtom implements Atom { private final DelayedDouble marginRight; private final Url url; private final boolean manageSpecialChars; + private TextBlock visibility; protected AtomText(String text, FontConfiguration style, Url url, DelayedDouble marginLeft, DelayedDouble marginRight, boolean manageSpecialChars) { if (text.contains("" + BackSlash.hiddenNewLine())) { throw new IllegalArgumentException(text); } + +// if (text.length() > 0) { +// final VisibilityModifier visibilityModifier = VisibilityModifier.getByUnicode(text.charAt(0)); +// if (visibilityModifier != null) { +// final HColor back = HColorUtils.GREEN; +// final HColor fore = HColorUtils.RED; +// visibility = visibilityModifier.getUBlock(11, fore, back, url != null); +// text = text.substring(1); +// } +// } + this.marginLeft = marginLeft; this.marginRight = marginRight; String s = CharHidder.unhide(text); @@ -109,9 +124,12 @@ public final class AtomText extends AbstractAtom implements Atom { if (h < 10) { h = 10; } - final double width = text.indexOf("\t") == -1 ? rect.getWidth() : getWidth(stringBounder, text); + double width = text.indexOf("\t") == -1 ? rect.getWidth() : getWidth(stringBounder, text); final double left = marginLeft.getDouble(stringBounder); final double right = marginRight.getDouble(stringBounder); + if (visibility != null) { + width += visibility.calculateDimension(stringBounder).getWidth(); + } return new Dimension2DDouble(width + left + right, h); } @@ -123,6 +141,11 @@ public final class AtomText extends AbstractAtom implements Atom { if (ug.matchesProperty("SPECIALTXT")) { ug.draw(this); } else { + if (visibility != null) { + visibility.drawU(ug.apply(UTranslate.dy(2))); + final double width = visibility.calculateDimension(ug.getStringBounder()).getWidth(); + ug = ug.apply(UTranslate.dx(width)); + } HColor textColor = fontConfiguration.getColor(); FontConfiguration useFontConfiguration = fontConfiguration; if (textColor instanceof HColorAutomatic && ug.getParam().getBackcolor() != null) { @@ -261,7 +284,7 @@ public final class AtomText extends AbstractAtom implements Atom { } return Collections.singletonList((Atom) this); } - + private boolean isOfWord(char ch) { return Character.isWhitespace(ch) == false; } @@ -269,7 +292,7 @@ public final class AtomText extends AbstractAtom implements Atom { public final String getText() { return text; } - + public double getStartingAltitude(StringBounder stringBounder) { return fontConfiguration.getSpace(); } diff --git a/src/net/sourceforge/plantuml/creole/legacy/CreoleParser.java b/src/net/sourceforge/plantuml/creole/legacy/CreoleParser.java index 28c62c8ec..081770455 100644 --- a/src/net/sourceforge/plantuml/creole/legacy/CreoleParser.java +++ b/src/net/sourceforge/plantuml/creole/legacy/CreoleParser.java @@ -104,7 +104,7 @@ public class CreoleParser implements SheetBuilder { .createStripe(context); } - private static boolean isTableLine(String line) { + public static boolean isTableLine(String line) { return line.matches("^(\\<#\\w+(,#?\\w+)?\\>)?\\|(\\=)?.*\\|$"); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/Bodier.java b/src/net/sourceforge/plantuml/cucadiagram/Bodier.java index 0d396bc95..30e7cfce7 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Bodier.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Bodier.java @@ -46,16 +46,16 @@ public interface Bodier { public void setLeaf(ILeaf leaf); - public List getFieldsToDisplay(); + public Display getFieldsToDisplay(); - public List getMethodsToDisplay(); + public Display getMethodsToDisplay(); public void addFieldOrMethod(String s); public TextBlock getBody(FontParam fontParam, ISkinParam skinParam, boolean showMethods, boolean showFields, Stereotype stereotype, Style style); - public List getRawBody(); + public List getRawBody(); public void muteClassToObject(); diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodierImpl.java b/src/net/sourceforge/plantuml/cucadiagram/BodierLikeClassOrObject.java similarity index 72% rename from src/net/sourceforge/plantuml/cucadiagram/BodierImpl.java rename to src/net/sourceforge/plantuml/cucadiagram/BodierLikeClassOrObject.java index d8482ddf6..8c30400f2 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodierImpl.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodierLikeClassOrObject.java @@ -43,6 +43,8 @@ import java.util.Set; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.StringUtils; +import net.sourceforge.plantuml.UrlBuilder; +import net.sourceforge.plantuml.creole.legacy.CreoleParser; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockLineBefore; @@ -50,14 +52,13 @@ import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.skin.VisibilityModifier; import net.sourceforge.plantuml.style.Style; -public class BodierImpl implements Bodier { +public class BodierLikeClassOrObject implements Bodier { - private final List rawBody = new ArrayList(); + private final List rawBody = new ArrayList(); private final Set hides; private LeafType type; private List methodsToDisplay; private List fieldsToDisplay; - private final boolean manageModifier; private ILeaf leaf; public void muteClassToObject() { @@ -66,13 +67,16 @@ public class BodierImpl implements Bodier { type = LeafType.OBJECT; } - public BodierImpl(LeafType type, Set hides) { + BodierLikeClassOrObject(LeafType type, Set hides) { if (type == LeafType.MAP) { throw new IllegalArgumentException(); } + if (type == null) { + throw new IllegalArgumentException(); + } + assert type.isLikeClass() || type == LeafType.OBJECT; this.hides = hides; this.type = type; - this.manageModifier = type == null ? false : type.manageModifier(); } public void setLeaf(ILeaf leaf) { @@ -91,44 +95,47 @@ public class BodierImpl implements Bodier { } private boolean isBodyEnhanced() { - for (String s : rawBody) { - if (BodyEnhanced.isBlockSeparator(s)) { + for (CharSequence s : rawBody) { + if (BodyEnhanced1.isBlockSeparator(s) || CreoleParser.isTableLine(s.toString())) { return true; } } return false; } - private boolean isMethod(String s) { - if (type == LeafType.ANNOTATION || type == LeafType.ABSTRACT_CLASS || type == LeafType.CLASS - || type == LeafType.INTERFACE || type == LeafType.ENUM) { - return Member.isMethod(s); + private boolean isMethod(CharSequence s) { + final String purged = s.toString().replaceAll(UrlBuilder.getRegexp(), ""); + if (purged.contains("{method}")) { + return true; } - return false; + if (purged.contains("{field}")) { + return false; + } + return purged.contains("(") || purged.contains(")"); } - public List getMethodsToDisplay() { + public Display getMethodsToDisplay() { if (methodsToDisplay == null) { methodsToDisplay = new ArrayList(); for (int i = 0; i < rawBody.size(); i++) { - final String s = rawBody.get(i); + final CharSequence s = rawBody.get(i); if (isMethod(i, rawBody) == false) { continue; } if (s.length() == 0 && methodsToDisplay.size() == 0) { continue; } - final Member m = new Member(s, true, manageModifier); + final Member m = Member.method(s); if (hides == null || hides.contains(m.getVisibilityModifier()) == false) { methodsToDisplay.add(m); } } removeFinalEmptyMembers(methodsToDisplay); } - return Collections.unmodifiableList(methodsToDisplay); + return Display.create(methodsToDisplay); } - private boolean isMethod(int i, List rawBody) { + private boolean isMethod(int i, List rawBody) { if (i > 0 && i < rawBody.size() - 1 && rawBody.get(i).length() == 0 && isMethod(rawBody.get(i - 1)) && isMethod(rawBody.get(i + 1))) { return true; @@ -136,24 +143,24 @@ public class BodierImpl implements Bodier { return isMethod(rawBody.get(i)); } - public List getFieldsToDisplay() { + public Display getFieldsToDisplay() { if (fieldsToDisplay == null) { fieldsToDisplay = new ArrayList(); - for (String s : rawBody) { + for (CharSequence s : rawBody) { if (isMethod(s) == true) { continue; } if (s.length() == 0 && fieldsToDisplay.size() == 0) { continue; } - final Member m = new Member(s, false, manageModifier); + final Member m = Member.field(s); if (hides == null || hides.contains(m.getVisibilityModifier()) == false) { fieldsToDisplay.add(m); } } removeFinalEmptyMembers(fieldsToDisplay); } - return Collections.unmodifiableList(fieldsToDisplay); + return Display.create(fieldsToDisplay); } private void removeFinalEmptyMembers(List result) { @@ -163,12 +170,14 @@ public class BodierImpl implements Bodier { } public boolean hasUrl() { - for (Member m : getFieldsToDisplay()) { + for (CharSequence cs : getFieldsToDisplay()) { + final Member m = (Member) cs; if (m.hasUrl()) { return true; } } - for (Member m : getMethodsToDisplay()) { + for (CharSequence cs : getMethodsToDisplay()) { + final Member m = (Member) cs; if (m.hasUrl()) { return true; } @@ -176,15 +185,17 @@ public class BodierImpl implements Bodier { return false; } - private List rawBodyWithoutHidden() { - if (hides == null || hides.size() == 0) { - return rawBody; - } - final List result = new ArrayList(); - for (String s : rawBody) { - final Member m = new Member(s, isMethod(s), manageModifier); + private List rawBodyWithoutHidden() { + final List result = new ArrayList(); + for (CharSequence s : rawBody) { + final Member m; + if (isMethod(s)) { + m = Member.method(s); + } else { + m = Member.field(s); + } if (hides.contains(m.getVisibilityModifier()) == false) { - result.add(s); + result.add(m); } } @@ -193,28 +204,31 @@ public class BodierImpl implements Bodier { public TextBlock getBody(FontParam fontParam, ISkinParam skinParam, boolean showMethods, boolean showFields, Stereotype stereotype, Style style) { + + if (BodyFactory.BODY3) { + return new Body3(rawBody, fontParam, skinParam, stereotype, style); + } + if (type.isLikeClass() && isBodyEnhanced()) { if (showMethods || showFields) { - return new BodyEnhanced(rawBodyWithoutHidden(), fontParam, skinParam, manageModifier, stereotype, leaf, - style); + return BodyFactory.create1(rawBodyWithoutHidden(), fontParam, skinParam, stereotype, leaf, style); } return null; } if (leaf == null) { throw new IllegalStateException(); } - final MethodsOrFieldsArea fields = new MethodsOrFieldsArea(getFieldsToDisplay(), fontParam, skinParam, - stereotype, leaf, style); if (type == LeafType.OBJECT) { if (showFields == false) { return new TextBlockLineBefore(TextBlockUtils.empty(0, 0)); } - return new BodyEnhanced(rawBodyWithoutHidden(), fontParam, skinParam, manageModifier, stereotype, leaf, - style); - } - if (type.isLikeClass() == false) { - throw new UnsupportedOperationException(); + return BodyFactory.create1(rawBodyWithoutHidden(), fontParam, skinParam, stereotype, leaf, style); } + assert type.isLikeClass(); + + final MethodsOrFieldsArea fields = new MethodsOrFieldsArea(getFieldsToDisplay(), fontParam, skinParam, + stereotype, leaf, style); + final MethodsOrFieldsArea methods = new MethodsOrFieldsArea(getMethodsToDisplay(), fontParam, skinParam, stereotype, leaf, style); if (showFields && showMethods == false) { @@ -230,7 +244,7 @@ public class BodierImpl implements Bodier { return TextBlockUtils.mergeTB(bb1, bb2, HorizontalAlignment.LEFT); } - public List getRawBody() { + public List getRawBody() { return Collections.unmodifiableList(rawBody); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodierMap.java b/src/net/sourceforge/plantuml/cucadiagram/BodierMap.java index d9bd3f49b..f8387108c 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodierMap.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodierMap.java @@ -50,7 +50,7 @@ import net.sourceforge.plantuml.style.Style; public class BodierMap implements Bodier { - private final List rawBody = new ArrayList(); + private final List rawBody = new ArrayList(); private final Map map = new LinkedHashMap(); private ILeaf leaf; @@ -89,11 +89,11 @@ public class BodierMap implements Bodier { } } - public List getMethodsToDisplay() { + public Display getMethodsToDisplay() { throw new UnsupportedOperationException(); } - public List getFieldsToDisplay() { + public Display getFieldsToDisplay() { throw new UnsupportedOperationException(); } @@ -106,7 +106,7 @@ public class BodierMap implements Bodier { return new TextBlockMap(fontParam, skinParam, map); } - public List getRawBody() { + public List getRawBody() { return Collections.unmodifiableList(rawBody); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodierSimple.java b/src/net/sourceforge/plantuml/cucadiagram/BodierSimple.java new file mode 100644 index 000000000..36a364ad9 --- /dev/null +++ b/src/net/sourceforge/plantuml/cucadiagram/BodierSimple.java @@ -0,0 +1,91 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.cucadiagram; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import net.sourceforge.plantuml.FontParam; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.style.Style; + +public class BodierSimple implements Bodier { + + private final List rawBody = new ArrayList(); + private ILeaf leaf; + + public void muteClassToObject() { + throw new UnsupportedOperationException(); + } + + BodierSimple() { + } + + public void setLeaf(ILeaf leaf) { + if (leaf == null) { + throw new IllegalArgumentException(); + } + this.leaf = leaf; + } + + public void addFieldOrMethod(String s) { + rawBody.add(s); + } + + public Display getMethodsToDisplay() { + throw new UnsupportedOperationException(); + } + + public Display getFieldsToDisplay() { + throw new UnsupportedOperationException(); + } + + public boolean hasUrl() { + throw new UnsupportedOperationException(); + } + + public List getRawBody() { + return Collections.unmodifiableList(rawBody); + } + + public TextBlock getBody(FontParam fontParam, ISkinParam skinParam, boolean showMethods, boolean showFields, + Stereotype stereotype, Style style) { + return BodyFactory.create1(rawBody, fontParam, skinParam, stereotype, leaf, style); + } + +} diff --git a/src/net/sourceforge/plantuml/cucadiagram/Body3.java b/src/net/sourceforge/plantuml/cucadiagram/Body3.java new file mode 100644 index 000000000..658b8054d --- /dev/null +++ b/src/net/sourceforge/plantuml/cucadiagram/Body3.java @@ -0,0 +1,101 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.cucadiagram; + +import java.awt.geom.Dimension2D; +import java.util.ArrayList; +import java.util.List; + +import net.sourceforge.plantuml.FontParam; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.graphic.AbstractTextBlock; +import net.sourceforge.plantuml.graphic.FontConfiguration; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.skin.VisibilityModifier; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.svek.Ports; +import net.sourceforge.plantuml.svek.WithPorts; +import net.sourceforge.plantuml.ugraphic.UGraphic; + +public class Body3 extends AbstractTextBlock implements TextBlock, WithPorts { + + private final List rawBody = new ArrayList(); + private final FontParam fontParam; + private final ISkinParam skinParam; + private final Stereotype stereotype; + private final Style style; + + public Body3(List rawBody_, FontParam fontParam, ISkinParam skinParam, Stereotype stereotype, + Style style) { + for (CharSequence s : rawBody_) { + this.rawBody.add(VisibilityModifier.replaceVisibilityModifierByUnicodeChar(s.toString(), true)); + } + this.fontParam = fontParam; + this.skinParam = skinParam; + this.stereotype = stereotype; + this.style = style; + } + + public void drawU(UGraphic ug) { + getTextBlock().drawU(ug); + + } + + private TextBlock getTextBlock() { + Display display = Display.create(rawBody); + + FontConfiguration config; + if (style != null) { + config = new FontConfiguration(skinParam, style); + } else { + config = new FontConfiguration(skinParam, fontParam, stereotype); + } + + TextBlock foo = display.create(config, HorizontalAlignment.LEFT, skinParam); + return foo; + } + + public Ports getPorts(StringBounder stringBounder) { + return new Ports(); + } + + public Dimension2D calculateDimension(StringBounder stringBounder) { + return getTextBlock().calculateDimension(stringBounder); + } + +} diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced.java b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced.java deleted file mode 100644 index 6f7237ee3..000000000 --- a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced.java +++ /dev/null @@ -1,289 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2020, Arnaud Roques - * - * Project Info: http://plantuml.com - * - * If you like this project or if you find it useful, you can support us at: - * - * http://plantuml.com/patreon (only 1$ per month!) - * http://plantuml.com/paypal - * - * This file is part of PlantUML. - * - * PlantUML is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PlantUML distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - * License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - * - * - * Original Author: Arnaud Roques - * - * - */ -package net.sourceforge.plantuml.cucadiagram; - -import java.awt.geom.Dimension2D; -import java.awt.geom.Rectangle2D; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.ListIterator; - -import net.sourceforge.plantuml.EmbeddedDiagram; -import net.sourceforge.plantuml.FontParam; -import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.ISkinSimple; -import net.sourceforge.plantuml.StringUtils; -import net.sourceforge.plantuml.Url; -import net.sourceforge.plantuml.creole.CreoleMode; -import net.sourceforge.plantuml.creole.Parser; -import net.sourceforge.plantuml.graphic.AbstractTextBlock; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.InnerStrategy; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.graphic.TextBlockLineBefore; -import net.sourceforge.plantuml.graphic.TextBlockUtils; -import net.sourceforge.plantuml.graphic.TextBlockVertical2; -import net.sourceforge.plantuml.style.Style; -import net.sourceforge.plantuml.svek.Ports; -import net.sourceforge.plantuml.svek.WithPorts; -import net.sourceforge.plantuml.ugraphic.UGraphic; - -public class BodyEnhanced extends AbstractTextBlock implements TextBlock, WithPorts { - - private TextBlock area; - private final FontConfiguration titleConfig; - private final List rawBody; - private final FontParam fontParam; - private final ISkinParam skinParam; - private final boolean lineFirst; - private final HorizontalAlignment align; - private final boolean manageHorizontalLine; - private final boolean manageModifier; - private final List urls = new ArrayList(); - private final Stereotype stereotype; - private final ILeaf entity; - private final boolean inEllipse; - private final double minClassWidth; - private final Style style; - - public BodyEnhanced(List rawBody, FontParam fontParam, ISkinParam skinParam, boolean manageModifier, - Stereotype stereotype, ILeaf entity, Style style) { - this.style = style; - this.rawBody = new ArrayList(rawBody); - this.stereotype = stereotype; - this.fontParam = fontParam; - this.skinParam = skinParam; - - this.titleConfig = new FontConfiguration(skinParam, fontParam, stereotype); - this.lineFirst = true; - this.align = skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT); - this.manageHorizontalLine = true; - this.manageModifier = manageModifier; - this.entity = entity; - this.inEllipse = false; - this.minClassWidth = 0; - } - - public BodyEnhanced(Display display, FontParam fontParam, ISkinParam skinParam, HorizontalAlignment align, - Stereotype stereotype, boolean manageHorizontalLine, boolean manageModifier, ILeaf entity, Style style) { - this(display, fontParam, skinParam, align, stereotype, manageHorizontalLine, manageHorizontalLine, entity, 0, - style); - } - - private BodyEnhanced(Display display, FontParam fontParam, ISkinParam skinParam, HorizontalAlignment align, - Stereotype stereotype, boolean manageHorizontalLine, boolean manageModifier, ILeaf entity, - double minClassWidth, Style style) { - this.style = style; - this.minClassWidth = minClassWidth; - this.entity = entity; - this.stereotype = stereotype; - this.rawBody = new ArrayList(); - this.fontParam = fontParam; - this.skinParam = skinParam; - - if (style == null) { - this.titleConfig = new FontConfiguration(skinParam, fontParam, stereotype); - } else { - this.titleConfig = style.getFontConfiguration(skinParam.getIHtmlColorSet()); - } - this.lineFirst = false; - this.align = skinParam.getDefaultTextAlignment(align); - this.manageHorizontalLine = manageHorizontalLine; - this.manageModifier = manageModifier; - this.inEllipse = fontParam == FontParam.USECASE; - - if (manageHorizontalLine && inEllipse && display.size() > 0 && isBlockSeparator(display.get(0).toString())) { - this.rawBody.add(""); - } - for (CharSequence s : display) { - this.rawBody.add(s); - } - - } - - private TextBlock decorate(StringBounder stringBounder, TextBlock b, char separator, TextBlock title) { - if (separator == 0) { - return b; - } - if (title == null) { - return new TextBlockLineBefore(TextBlockUtils.withMargin(b, 6, 4), separator); - } - final Dimension2D dimTitle = title.calculateDimension(stringBounder); - final TextBlock raw = new TextBlockLineBefore(TextBlockUtils.withMargin(b, 6, 6, dimTitle.getHeight() / 2, 4), - separator, title); - return TextBlockUtils.withMargin(raw, 0, 0, dimTitle.getHeight() / 2, 0); - } - - public Dimension2D calculateDimension(StringBounder stringBounder) { - return getArea(stringBounder).calculateDimension(stringBounder); - } - - private TextBlock getArea(StringBounder stringBounder) { - if (area != null) { - return area; - } - urls.clear(); - final List blocks = new ArrayList(); - - char separator = lineFirst ? '_' : 0; - TextBlock title = null; - List members = new ArrayList(); - for (ListIterator it = rawBody.listIterator(); it.hasNext();) { - final CharSequence s2 = it.next(); - if (s2 instanceof EmbeddedDiagram) { - if (members.size() > 0 || separator != 0) { - blocks.add(decorate(stringBounder, - new MethodsOrFieldsArea(members, fontParam, skinParam, align, stereotype, entity, style), - separator, title)); - separator = 0; - title = null; - members = new ArrayList(); - } - blocks.add(((EmbeddedDiagram) s2).asDraw(skinParam)); - } else { - final String s = s2.toString(); - if (manageHorizontalLine && isBlockSeparator(s)) { - blocks.add(decorate(stringBounder, - new MethodsOrFieldsArea(members, fontParam, skinParam, align, stereotype, entity, style), - separator, title)); - separator = s.charAt(0); - title = getTitle(s, skinParam); - members = new ArrayList(); - } else if (Parser.isTreeStart(s)) { - if (members.size() > 0) { - blocks.add(decorate(stringBounder, new MethodsOrFieldsArea(members, fontParam, skinParam, align, - stereotype, entity, style), separator, title)); - } - separator = 0; - title = null; - members = new ArrayList(); - final List allTree = buildAllTree(s, it); - final TextBlock bloc = Display.create(allTree).create7(fontParam.getFontConfiguration(skinParam), - align, skinParam, CreoleMode.FULL); - blocks.add(bloc); - } else { - final Member m = new Member(s, Member.isMethod(s), manageModifier); - members.add(m); - if (m.getUrl() != null) { - urls.add(m.getUrl()); - } - } - } - } - if (inEllipse && members.size() == 0) { - members.add(new Member("", false, false)); - } - blocks.add(decorate(stringBounder, - new MethodsOrFieldsArea(members, fontParam, skinParam, align, stereotype, entity, style), separator, - title)); - - if (blocks.size() == 1) { - this.area = blocks.get(0); - } else { - this.area = new TextBlockVertical2(blocks, align); - } - if (minClassWidth > 0) { - this.area = TextBlockUtils.withMinWidth(this.area, minClassWidth, - skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT)); - } - - return area; - } - - private static List buildAllTree(String init, ListIterator it) { - final List result = new ArrayList(); - result.add(init); - while (it.hasNext()) { - final CharSequence s = it.next(); - if (Parser.isTreeStart(StringUtils.trinNoTrace(s))) { - result.add(s); - } else { - it.previous(); - return result; - } - - } - return result; - } - - public static boolean isBlockSeparator(String s) { - if (s.startsWith("--") && s.endsWith("--")) { - return true; - } - if (s.startsWith("==") && s.endsWith("==")) { - return true; - } - if (s.startsWith("..") && s.endsWith("..") && s.equals("...") == false) { - return true; - } - if (s.startsWith("__") && s.endsWith("__")) { - return true; - } - return false; - } - - private TextBlock getTitle(String s, ISkinSimple spriteContainer) { - if (s.length() <= 4) { - return null; - } - s = StringUtils.trin(s.substring(2, s.length() - 2)); - return Display.getWithNewlines(s).create(titleConfig, HorizontalAlignment.LEFT, spriteContainer); - } - - public Ports getPorts(StringBounder stringBounder) { - final TextBlock area = getArea(stringBounder); - if (area instanceof WithPorts) { - return ((WithPorts) area).getPorts(stringBounder); - } - return new Ports(); - } - - public void drawU(UGraphic ug) { - getArea(ug.getStringBounder()).drawU(ug); - } - - public List getUrls() { - return Collections.unmodifiableList(urls); - } - - public Rectangle2D getInnerPosition(String member, StringBounder stringBounder, InnerStrategy strategy) { - return getArea(stringBounder).getInnerPosition(member, stringBounder, strategy); - } - -} diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced1.java b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced1.java new file mode 100644 index 000000000..f26b346b6 --- /dev/null +++ b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced1.java @@ -0,0 +1,232 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.cucadiagram; + +import java.awt.geom.Rectangle2D; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.ListIterator; + +import net.sourceforge.plantuml.EmbeddedDiagram; +import net.sourceforge.plantuml.FontParam; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.StringUtils; +import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.creole.CreoleMode; +import net.sourceforge.plantuml.creole.Parser; +import net.sourceforge.plantuml.creole.legacy.CreoleParser; +import net.sourceforge.plantuml.graphic.FontConfiguration; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.InnerStrategy; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.graphic.TextBlockUtils; +import net.sourceforge.plantuml.graphic.TextBlockVertical2; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.svek.Ports; +import net.sourceforge.plantuml.svek.WithPorts; + +public class BodyEnhanced1 extends BodyEnhancedAbstract implements TextBlock, WithPorts { + + private final Display rawBody2; + private final FontParam fontParam; + private final ISkinParam skinParam; + private final boolean lineFirst; + private final List urls = new ArrayList(); + private final Stereotype stereotype; + private final ILeaf entity; + private final boolean inEllipse; + private final Style style; + + BodyEnhanced1(List rawBody, FontParam fontParam, ISkinParam skinParam, Stereotype stereotype, + ILeaf entity, Style style) { + super(skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), + new FontConfiguration(skinParam, fontParam, stereotype)); + + this.style = style; + this.rawBody2 = Display.create(rawBody); + this.stereotype = stereotype; + this.fontParam = fontParam; + this.skinParam = skinParam; + + this.lineFirst = true; + + this.entity = entity; + this.inEllipse = false; + } + + BodyEnhanced1(Display display, FontParam fontParam, ISkinParam skinParam, HorizontalAlignment align, + Stereotype stereotype, ILeaf entity, Style style) { + super(skinParam.getDefaultTextAlignment(align), + style == null ? new FontConfiguration(skinParam, fontParam, stereotype) + : style.getFontConfiguration(skinParam.getIHtmlColorSet())); + + this.style = style; + this.entity = entity; + this.stereotype = stereotype; + this.fontParam = fontParam; + this.skinParam = skinParam; + + this.lineFirst = false; + + this.inEllipse = fontParam == FontParam.USECASE; + + if (inEllipse && display.size() > 0 && isBlockSeparator(display.get(0).toString())) { + display = display.add(""); + } + this.rawBody2 = display; + + } + + @Override + protected double getMarginX() { + return 6; + } + + private static boolean isTreeOrTable(String s) { + return Parser.isTreeStart(s) || CreoleParser.isTableLine(s); + } + + @Override + protected TextBlock getArea(StringBounder stringBounder) { + if (area != null) { + return area; + } + urls.clear(); + final List blocks = new ArrayList(); + + char separator = lineFirst ? '_' : 0; + TextBlock title = null; + Display display = Display.empty(); + for (ListIterator it = rawBody2.iterator(); it.hasNext();) { + final CharSequence cs = it.next(); + if (cs instanceof EmbeddedDiagram) { + if (display.size() > 0 || separator != 0) { + blocks.add(decorate(stringBounder, + new MethodsOrFieldsArea(display, fontParam, skinParam, align, stereotype, entity, style), + separator, title)); + separator = 0; + title = null; + display = Display.empty(); + } + blocks.add(((EmbeddedDiagram) cs).asDraw(skinParam)); + } else { + final String s = cs.toString(); + if (isBlockSeparator(s)) { + blocks.add(decorate(stringBounder, + new MethodsOrFieldsArea(display, fontParam, skinParam, align, stereotype, entity, style), + separator, title)); + separator = s.charAt(0); + title = getTitle(s, skinParam); + display = Display.empty(); + } else if (isTreeOrTable(s)) { + final boolean isTable = CreoleParser.isTableLine(s); + if (display.size() > 0) { + blocks.add(decorate(stringBounder, new MethodsOrFieldsArea(display, fontParam, skinParam, align, + stereotype, entity, style), separator, title)); + } + separator = 0; + title = null; + display = Display.empty(); + final List allTree = buildTreeOrTable(s, it); + TextBlock bloc = Display.create(allTree).create7(fontParam.getFontConfiguration(skinParam), align, + skinParam, CreoleMode.FULL); + if (isTable) { + bloc = TextBlockUtils.withMargin(bloc, 10, 10, 0, 5); + } + blocks.add(bloc); + } else { + display = display.add(cs); + if (cs instanceof Member && ((Member) cs).getUrl() != null) { + urls.add(((Member) cs).getUrl()); + } + } + } + } + if (inEllipse && display.size() == 0) { + display = display.add(""); + } + blocks.add(decorate(stringBounder, + new MethodsOrFieldsArea(display, fontParam, skinParam, align, stereotype, entity, style), separator, + title)); + + if (blocks.size() == 1) { + this.area = blocks.get(0); + } else { + this.area = new TextBlockVertical2(blocks, align); + } + + if (skinParam.minClassWidth() > 0) { + this.area = TextBlockUtils.withMinWidth(this.area, skinParam.minClassWidth(), align); + } + + return area; + } + + private static List buildTreeOrTable(String init, ListIterator it) { + final List result = new ArrayList(); + result.add(init); + while (it.hasNext()) { + final CharSequence s = it.next(); + if (isTreeOrTable(StringUtils.trinNoTrace(s))) { + result.add(s); + } else { + it.previous(); + return result; + } + + } + return result; + } + + public Ports getPorts(StringBounder stringBounder) { + final TextBlock area = getArea(stringBounder); + if (area instanceof WithPorts) { + return ((WithPorts) area).getPorts(stringBounder); + } + return new Ports(); + } + + public List getUrls() { + return Collections.unmodifiableList(urls); + } + + public Rectangle2D getInnerPosition(String member, StringBounder stringBounder, InnerStrategy strategy) { + return getArea(stringBounder).getInnerPosition(member, stringBounder, strategy); + } + +} diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced2.java b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced2.java index adfa7f8ab..38e73facb 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced2.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced2.java @@ -35,7 +35,6 @@ */ package net.sourceforge.plantuml.cucadiagram; -import java.awt.geom.Dimension2D; import java.util.ArrayList; import java.util.List; @@ -43,59 +42,37 @@ import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.Guillemet; import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.LineBreakStrategy; -import net.sourceforge.plantuml.StringUtils; -import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.graphic.TextBlockLineBefore; import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.graphic.TextBlockVertical2; -import net.sourceforge.plantuml.ugraphic.UGraphic; -public class BodyEnhanced2 extends AbstractTextBlock implements TextBlock { +public class BodyEnhanced2 extends BodyEnhancedAbstract { - private TextBlock area; - private final FontConfiguration titleConfig; private final Display rawBody; - private final ISkinSimple spriteContainer; + private final ISkinSimple skinParam; - private final HorizontalAlignment align; private final LineBreakStrategy lineBreakStrategy; - private final double minClassWidth; - // private final List urls = new ArrayList(); + BodyEnhanced2(Display rawBody, FontParam fontParam, ISkinSimple skinParam, HorizontalAlignment align, + FontConfiguration titleConfig, LineBreakStrategy lineBreakStrategy) { + super(align, titleConfig); - public BodyEnhanced2(Display rawBody, FontParam fontParam, ISkinSimple spriteContainer, HorizontalAlignment align, - FontConfiguration titleConfig, LineBreakStrategy lineBreakStrategy, double minClassWidth) { this.rawBody = rawBody; this.lineBreakStrategy = lineBreakStrategy; - this.spriteContainer = spriteContainer; - this.minClassWidth = minClassWidth; + this.skinParam = skinParam; - this.titleConfig = titleConfig; - this.align = align; } - private TextBlock decorate(StringBounder stringBounder, TextBlock b, char separator, TextBlock title) { - if (separator == 0) { - return b; - } - if (title == null) { - return new TextBlockLineBefore(TextBlockUtils.withMargin(b, 0, 4), separator); - } - final Dimension2D dimTitle = title.calculateDimension(stringBounder); - final TextBlock raw = new TextBlockLineBefore(TextBlockUtils.withMargin(b, 0, 6, dimTitle.getHeight() / 2, 4), - separator, title); - return TextBlockUtils.withMargin(raw, 0, 0, dimTitle.getHeight() / 2, 0); + @Override + protected double getMarginX() { + return 0; } - public Dimension2D calculateDimension(StringBounder stringBounder) { - return getArea(stringBounder).calculateDimension(stringBounder); - } - - private TextBlock getArea(StringBounder stringBounder) { + @Override + protected TextBlock getArea(StringBounder stringBounder) { if (area != null) { return area; } @@ -107,9 +84,9 @@ public class BodyEnhanced2 extends AbstractTextBlock implements TextBlock { Display display = Display.empty(); for (CharSequence s : rawBody) { if (isBlockSeparator(s.toString())) { - blocks.add(decorate(stringBounder, getTextBlock(display, stringBounder), separator, title)); + blocks.add(decorate(stringBounder, getTextBlock(display), separator, title)); separator = s.charAt(0); - title = getTitle(s.toString(), spriteContainer); + title = getTitle(s.toString(), skinParam); display = Display.empty(); } else { if (s instanceof String) { @@ -118,7 +95,7 @@ public class BodyEnhanced2 extends AbstractTextBlock implements TextBlock { display = display.add(s); } } - blocks.add(decorate(stringBounder, getTextBlock(display, stringBounder), separator, title)); + blocks.add(decorate(stringBounder, getTextBlock(display), separator, title)); if (blocks.size() == 1) { this.area = blocks.get(0); @@ -126,44 +103,16 @@ public class BodyEnhanced2 extends AbstractTextBlock implements TextBlock { this.area = new TextBlockVertical2(blocks, align); } - if (minClassWidth > 0) { - this.area = TextBlockUtils.withMinWidth(this.area, minClassWidth, align); + if (skinParam.minClassWidth() > 0) { + this.area = TextBlockUtils.withMinWidth(this.area, skinParam.minClassWidth(), align); } return area; } - private TextBlock getTextBlock(Display display, StringBounder stringBounder) { - final TextBlock result = display.create9(titleConfig, align, spriteContainer, lineBreakStrategy); + private TextBlock getTextBlock(Display display) { + final TextBlock result = display.create9(titleConfig, align, skinParam, lineBreakStrategy); return result; } - public static boolean isBlockSeparator(String s) { - if (s.startsWith("--") && s.endsWith("--")) { - return true; - } - if (s.startsWith("==") && s.endsWith("==")) { - return true; - } - if (s.startsWith("..") && s.endsWith("..")) { - return true; - } - if (s.startsWith("__") && s.endsWith("__")) { - return true; - } - return false; - } - - private TextBlock getTitle(String s, ISkinSimple spriteContainer) { - if (s.length() <= 4) { - return null; - } - s = StringUtils.trin(s.substring(2, s.length() - 2)); - return Display.getWithNewlines(s).create(titleConfig, HorizontalAlignment.LEFT, spriteContainer); - } - - public void drawU(UGraphic ug) { - getArea(ug.getStringBounder()).drawU(ug); - } - } diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhancedAbstract.java b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhancedAbstract.java new file mode 100644 index 000000000..419145d31 --- /dev/null +++ b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhancedAbstract.java @@ -0,0 +1,113 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.cucadiagram; + +import java.awt.geom.Dimension2D; + +import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.StringUtils; +import net.sourceforge.plantuml.graphic.AbstractTextBlock; +import net.sourceforge.plantuml.graphic.FontConfiguration; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.graphic.TextBlockLineBefore; +import net.sourceforge.plantuml.graphic.TextBlockUtils; +import net.sourceforge.plantuml.ugraphic.UGraphic; + +public abstract class BodyEnhancedAbstract extends AbstractTextBlock implements TextBlock { + + protected final HorizontalAlignment align; + protected final FontConfiguration titleConfig; + protected TextBlock area; + + BodyEnhancedAbstract(HorizontalAlignment align, FontConfiguration titleConfig) { + this.align = align; + this.titleConfig = titleConfig; + } + + public static boolean isBlockSeparator(CharSequence cs) { + final String s = cs.toString(); + if (s.startsWith("--") && s.endsWith("--")) { + return true; + } + if (s.startsWith("==") && s.endsWith("==")) { + return true; + } + if (s.startsWith("..") && s.endsWith("..") && s.equals("...") == false) { + return true; + } + if (s.startsWith("__") && s.endsWith("__")) { + return true; + } + return false; + } + + public final Dimension2D calculateDimension(StringBounder stringBounder) { + return getArea(stringBounder).calculateDimension(stringBounder); + } + + final public void drawU(UGraphic ug) { + getArea(ug.getStringBounder()).drawU(ug); + } + + final protected TextBlock getTitle(String s, ISkinSimple spriteContainer) { + if (s.length() <= 4) { + return null; + } + s = StringUtils.trin(s.substring(2, s.length() - 2)); + return Display.getWithNewlines(s).create(titleConfig, HorizontalAlignment.LEFT, spriteContainer); + } + + abstract protected TextBlock getArea(StringBounder stringBounder); + + abstract protected double getMarginX(); + + final protected TextBlock decorate(StringBounder stringBounder, TextBlock b, char separator, TextBlock title) { + final double marginX = getMarginX(); + if (separator == 0) { + return TextBlockUtils.withMargin(b, marginX, 0); + } + if (title == null) { + return new TextBlockLineBefore(TextBlockUtils.withMargin(b, marginX, 4), separator); + } + final Dimension2D dimTitle = title.calculateDimension(stringBounder); + final TextBlock raw = new TextBlockLineBefore( + TextBlockUtils.withMargin(b, marginX, 6, dimTitle.getHeight() / 2, 4), separator, title); + return TextBlockUtils.withMargin(raw, 0, 0, dimTitle.getHeight() / 2, 0); + } + +} diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodyFactory.java b/src/net/sourceforge/plantuml/cucadiagram/BodyFactory.java new file mode 100644 index 000000000..aabb8a95b --- /dev/null +++ b/src/net/sourceforge/plantuml/cucadiagram/BodyFactory.java @@ -0,0 +1,81 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.cucadiagram; + +import java.util.List; +import java.util.Set; + +import net.sourceforge.plantuml.FontParam; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.LineBreakStrategy; +import net.sourceforge.plantuml.graphic.FontConfiguration; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.skin.VisibilityModifier; +import net.sourceforge.plantuml.style.Style; + +public class BodyFactory { + + public final static boolean BODY3 = false; + + public static Bodier createLeaf(LeafType type, Set hides) { + if (type.isLikeClass() || type == LeafType.OBJECT) { + return new BodierLikeClassOrObject(type, hides); + } + return new BodierSimple(); + } + + public static Bodier createGroup(Set hides) { + return new BodierSimple(); + } + + public static TextBlock create1(List rawBody, FontParam fontParam, ISkinParam skinParam, + Stereotype stereotype, ILeaf entity, Style style) { + return new BodyEnhanced1(rawBody, fontParam, skinParam, stereotype, entity, style); + } + + public static TextBlock create2(Display display, FontParam fontParam, ISkinParam skinParam, + HorizontalAlignment align, Stereotype stereotype, ILeaf entity, Style style) { + return new BodyEnhanced1(display, fontParam, skinParam, align, stereotype, entity, style); + } + + public static TextBlock create3(Display rawBody, FontParam fontParam, ISkinSimple skinParam, + HorizontalAlignment align, FontConfiguration titleConfig, LineBreakStrategy lineBreakStrategy) { + return new BodyEnhanced2(rawBody, fontParam, skinParam, align, titleConfig, lineBreakStrategy); + } + +} diff --git a/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java b/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java index 110f6288c..56d1afe16 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java +++ b/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java @@ -225,7 +225,7 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, private Ident buildLeafIdentSpecialUnused(String id) { // if (namespaceSeparator != null) { // if (id.contains(namespaceSeparator)) { - return Ident.empty().add(id, "."); + return Ident.empty().add(id, "."); // } // } // return getLastID().add(id, namespaceSeparator); @@ -597,8 +597,9 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, result.add(s); } } - final String aspect = getPragma().getValue("aspect"); + String aspect = getPragma().getValue("aspect"); if (aspect != null) { + aspect = aspect.replace(',', '.'); result.add("aspect=" + aspect + ";"); } final String ratio = getPragma().getValue("ratio"); diff --git a/src/net/sourceforge/plantuml/cucadiagram/Display.java b/src/net/sourceforge/plantuml/cucadiagram/Display.java index d26955344..c73b0b0fe 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Display.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Display.java @@ -41,6 +41,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.List; +import java.util.ListIterator; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -242,7 +243,7 @@ public class Display implements Iterable { final List other = new ArrayList(); other.add("@start" + type); while (it.hasNext()) { - CharSequence s2 = it.next(); + final CharSequence s2 = it.next(); if (s2 != null && StringUtils.trin(s2.toString()).equals("}}")) { break; } @@ -398,8 +399,8 @@ public class Display implements Iterable { return displayData.get(i); } - public Iterator iterator() { - return Collections.unmodifiableList(displayData).iterator(); + public ListIterator iterator() { + return Collections.unmodifiableList(displayData).listIterator(); } public Display subList(int i, int size) { diff --git a/src/net/sourceforge/plantuml/cucadiagram/Election.java b/src/net/sourceforge/plantuml/cucadiagram/Election.java index 01b1e39ab..22fa97606 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Election.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Election.java @@ -45,15 +45,15 @@ import java.util.Map; class Election { - private final Map all = new HashMap(); + private final Map all = new HashMap(); - public void addCandidate(String display, Member candidate) { + public void addCandidate(String display, CharSequence candidate) { all.put(display, candidate); } - private Member getCandidate(String shortName) { - List list = getAllCandidateContains(shortName); + private CharSequence getCandidate(String shortName) { + List list = getAllCandidateContains(shortName); if (list.size() == 1) { return list.get(0); } @@ -64,9 +64,9 @@ class Election { return null; } - private List getAllCandidateContains(String shortName) { - final List result = new ArrayList(); - for (Map.Entry ent : all.entrySet()) { + private List getAllCandidateContains(String shortName) { + final List result = new ArrayList(); + for (Map.Entry ent : all.entrySet()) { if (ent.getKey().contains(shortName)) { result.add(ent.getValue()); } @@ -74,9 +74,9 @@ class Election { return result; } - private List getAllCandidateContainsStrict(String shortName) { - final List result = new ArrayList(); - for (Map.Entry ent : all.entrySet()) { + private List getAllCandidateContainsStrict(String shortName) { + final List result = new ArrayList(); + for (Map.Entry ent : all.entrySet()) { final String key = ent.getKey(); if (key.matches(".*\\b" + shortName + "\\b.*")) { result.add(ent.getValue()); @@ -85,10 +85,10 @@ class Election { return result; } - public Map getAllElected(Collection shortNames) { - final Map memberWithPort = new HashMap(); + public Map getAllElected(Collection shortNames) { + final Map memberWithPort = new HashMap(); for (String shortName : new HashSet(shortNames)) { - final Member m = getCandidate(shortName); + final CharSequence m = getCandidate(shortName); if (m != null) { memberWithPort.put(m, shortName); shortNames.remove(shortName); diff --git a/src/net/sourceforge/plantuml/cucadiagram/LeafType.java b/src/net/sourceforge/plantuml/cucadiagram/LeafType.java index 7b0f7395c..ef3488304 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/LeafType.java +++ b/src/net/sourceforge/plantuml/cucadiagram/LeafType.java @@ -42,8 +42,9 @@ public enum LeafType { EMPTY_PACKAGE, - ABSTRACT_CLASS, CLASS, INTERFACE, ANNOTATION, LOLLIPOP_FULL, LOLLIPOP_HALF, NOTE, TIPS, OBJECT, MAP, ASSOCIATION, ENUM, CIRCLE, - + ABSTRACT_CLASS, CLASS, INTERFACE, ANNOTATION, LOLLIPOP_FULL, LOLLIPOP_HALF, NOTE, TIPS, OBJECT, MAP, ASSOCIATION, + ENUM, CIRCLE, + USECASE, USECASE_BUSINESS, DESCRIPTION, @@ -55,9 +56,9 @@ public enum LeafType { STATE, STATE_CONCURRENT, PSEUDO_STATE, DEEP_HISTORY, STATE_CHOICE, STATE_FORK_JOIN, BLOCK, ENTITY, - + DOMAIN, REQUIREMENT, - + PORT, PORTIN, PORTOUT, STILL_UNKNOWN; @@ -83,11 +84,11 @@ public enum LeafType { return StringUtils.capitalize(html); } - public boolean manageModifier() { - if (this == ANNOTATION || this == ABSTRACT_CLASS || this == CLASS || this == INTERFACE || this == ENUM - || this == OBJECT || this == ENTITY) { - return true; - } - return false; - } +// public boolean manageModifier() { +// if (this == ANNOTATION || this == ABSTRACT_CLASS || this == CLASS || this == INTERFACE || this == ENUM +// || this == OBJECT || this == ENTITY) { +// return true; +// } +// return false; +// } } diff --git a/src/net/sourceforge/plantuml/cucadiagram/Member.java b/src/net/sourceforge/plantuml/cucadiagram/Member.java index 83f08b444..233831454 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Member.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Member.java @@ -45,9 +45,10 @@ import net.sourceforge.plantuml.command.regex.MyPattern; import net.sourceforge.plantuml.command.regex.Pattern2; import net.sourceforge.plantuml.skin.VisibilityModifier; -public class Member { +public class Member implements CharSequence { private final String display; + private final CharSequence raw; private final boolean staticModifier; private final boolean abstractModifier; private final Url url; @@ -57,11 +58,40 @@ public class Member { @Override public String toString() { - return super.toString() + " " + display; + return raw.toString(); } - public Member(String tmpDisplay, boolean isMethod, boolean manageModifier) { - tmpDisplay = tmpDisplay.replaceAll("(?i)\\{(method|field)\\}\\s*", ""); + public char charAt(int index) { + return raw.charAt(index); + } + + public int length() { + return raw.length(); + } + + public CharSequence subSequence(int start, int end) { + return raw.subSequence(start, end); + } + + public static Member method(CharSequence tmpDisplay) { + return new Member(true, tmpDisplay, true); + } + + public static Member field(CharSequence tmpDisplay) { + return new Member(true, tmpDisplay, false); + } + + public static Member method(CharSequence tmpDisplay, boolean manageModifier) { + return new Member(manageModifier, tmpDisplay, true); + } + + public static Member field(CharSequence tmpDisplay, boolean manageModifier) { + return new Member(manageModifier, tmpDisplay, false); + } + + private Member(boolean manageModifier, CharSequence tmpDisplay, boolean isMethod) { + this.raw = tmpDisplay; + tmpDisplay = tmpDisplay.toString().replaceAll("(?i)\\{(method|field)\\}\\s*", ""); if (manageModifier) { final Pattern2 finalUrl = MyPattern.cmpile("^(.*?)(?:\\[(" + UrlBuilder.getRegexp() + ")\\])?$"); final Matcher2 matcher = finalUrl.matcher(tmpDisplay); @@ -79,12 +109,13 @@ public class Member { this.url = null; } this.hasUrl = this.url != null; - final String lower = StringUtils.goLowerCase(tmpDisplay); + final String lower = StringUtils.goLowerCase(tmpDisplay.toString()); if (manageModifier) { this.staticModifier = lower.contains("{static}") || lower.contains("{classifier}"); this.abstractModifier = lower.contains("{abstract}"); - String displayClean = tmpDisplay.replaceAll("(?i)\\{(static|classifier|abstract)\\}\\s*", "").trim(); + String displayClean = tmpDisplay.toString().replaceAll("(?i)\\{(static|classifier|abstract)\\}\\s*", "") + .trim(); if (displayClean.length() == 0) { displayClean = " "; } @@ -100,9 +131,9 @@ public class Member { this.staticModifier = false; this.visibilityModifier = null; this.abstractModifier = false; - tmpDisplay = StringUtils.trin(tmpDisplay); + tmpDisplay = StringUtils.trin(tmpDisplay.toString()); this.display = tmpDisplay.length() == 0 ? " " - : Guillemet.GUILLEMET.manageGuillemet(StringUtils.trin(tmpDisplay)); + : Guillemet.GUILLEMET.manageGuillemet(StringUtils.trin(tmpDisplay.toString())); } } @@ -114,8 +145,6 @@ public class Member { } private String getDisplayWithoutVisibilityChar() { - // assert display.length() == 0 || - // VisibilityModifier.isVisibilityCharacter(display.charAt(0)) == false; return display; } @@ -193,14 +222,6 @@ public class Member { return hasUrl; } - public static boolean isMethod(String s) { - final String purged = s.replaceAll(UrlBuilder.getRegexp(), ""); - if (purged.contains("{method}")) { - return true; - } - if (purged.contains("{field}")) { - return false; - } - return purged.contains("(") || purged.contains(")"); - } + + } diff --git a/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java b/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java index d65a696e4..a72e56b24 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java +++ b/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java @@ -37,14 +37,11 @@ package net.sourceforge.plantuml.cucadiagram; import java.awt.geom.Dimension2D; import java.awt.geom.Rectangle2D; -import java.util.ArrayList; -import java.util.List; import java.util.Map; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.graphic.AbstractTextBlock; @@ -55,11 +52,9 @@ import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockLineBefore; import net.sourceforge.plantuml.graphic.TextBlockUtils; -import net.sourceforge.plantuml.graphic.TextBlockWidth; import net.sourceforge.plantuml.graphic.TextBlockWithUrl; import net.sourceforge.plantuml.skin.VisibilityModifier; import net.sourceforge.plantuml.skin.rose.Rose; -import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.svek.Ports; import net.sourceforge.plantuml.svek.WithPorts; @@ -72,7 +67,7 @@ import net.sourceforge.plantuml.ugraphic.ULayoutGroup; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.utils.CharHidder; -public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlockWidth, TextBlock, WithPorts { +public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlock, WithPorts { public TextBlock asBlockMemberImpl() { return new TextBlockLineBefore(TextBlockUtils.withMargin(this, 6, 4)); @@ -81,33 +76,36 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlockW private final FontParam fontParam; private final ISkinParam skinParam; private final Rose rose = new Rose(); - private final List members = new ArrayList(); + private final Display members; private final HorizontalAlignment align; private final Stereotype stereotype; private final ILeaf leaf; private final Style style; - public MethodsOrFieldsArea(List members, FontParam fontParam, ISkinParam skinParam, Stereotype stereotype, + public MethodsOrFieldsArea(Display members, FontParam fontParam, ISkinParam skinParam, Stereotype stereotype, ILeaf leaf, Style style) { this(members, fontParam, skinParam, HorizontalAlignment.LEFT, stereotype, leaf, style); } - public MethodsOrFieldsArea(List members, FontParam fontParam, ISkinParam skinParam, - HorizontalAlignment align, Stereotype stereotype, ILeaf leaf, Style style) { + public MethodsOrFieldsArea(Display members, FontParam fontParam, ISkinParam skinParam, HorizontalAlignment align, + Stereotype stereotype, ILeaf leaf, Style style) { this.style = style; this.leaf = leaf; this.stereotype = stereotype; this.align = align; this.skinParam = skinParam; this.fontParam = fontParam; - this.members.addAll(members); + this.members = members; } private boolean hasSmallIcon() { if (skinParam.classAttributeIconSize() == 0) { return false; } - for (Member m : members) { + for (CharSequence cs : members) { + if (cs instanceof Member == false) + continue; + final Member m = (Member) cs; if (m.getVisibilityModifier() != null) { return true; } @@ -122,8 +120,8 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlockW } double x = 0; double y = 0; - for (Member m : members) { - final TextBlock bloc = createTextBlock(m); + for (CharSequence cs : members) { + final TextBlock bloc = createTextBlock(cs); final Dimension2D dim = bloc.calculateDimension(stringBounder); x = Math.max(dim.getWidth(), x); y += dim.getHeight(); @@ -136,14 +134,19 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlockW final Ports result = new Ports(); double y = 0; final Election election = new Election(); - for (Member m : members) { - election.addCandidate(m.getDisplay(false), m); + for (CharSequence cs : members) { + if (cs instanceof Member) { + final Member m = (Member) cs; + election.addCandidate(m.getDisplay(false), m); + } else { + election.addCandidate(cs.toString(), cs); + } } - final Map memberWithPort = election.getAllElected(leaf.getPortShortNames()); - for (Member m : members) { - final TextBlock bloc = createTextBlock(m); + final Map memberWithPort = election.getAllElected(leaf.getPortShortNames()); + for (CharSequence cs : members) { + final TextBlock bloc = createTextBlock(cs); final Dimension2D dim = bloc.calculateDimension(stringBounder); - final String port = memberWithPort.get(m); + final String port = memberWithPort.get(cs); if (port != null) { result.add(port, y, dim.getHeight()); } @@ -152,29 +155,39 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlockW return result; } - private TextBlock createTextBlock(Member m) { - final boolean withVisibilityChar = skinParam.classAttributeIconSize() == 0; - String s = m.getDisplay(withVisibilityChar); - if (withVisibilityChar && s.startsWith("#")) { - s = CharHidder.addTileAtBegin(s); - } + private TextBlock createTextBlock(CharSequence cs) { + FontConfiguration config; if (style != null) { config = new FontConfiguration(skinParam, style); } else { config = new FontConfiguration(skinParam, fontParam, stereotype); } - if (m.isAbstract()) { - config = config.italic(); - } - if (m.isStatic()) { - config = config.underline(); + + if (cs instanceof Member) { + final Member m = (Member) cs; + final boolean withVisibilityChar = skinParam.classAttributeIconSize() == 0; + String s = m.getDisplay(withVisibilityChar); + if (withVisibilityChar && s.startsWith("#")) { + s = CharHidder.addTileAtBegin(s); + } + if (m.isAbstract()) { + config = config.italic(); + } + if (m.isStatic()) { + config = config.underline(); + } + + TextBlock bloc = Display.getWithNewlines(s).create8(config, align, skinParam, CreoleMode.SIMPLE_LINE, + skinParam.wrapWidth()); + bloc = TextBlockUtils.fullInnerPosition(bloc, m.getDisplay(false)); + return new TextBlockTracer(m, bloc); } - TextBlock bloc = Display.getWithNewlines(s).create8(config, align, skinParam, CreoleMode.SIMPLE_LINE, - skinParam.wrapWidth()); - bloc = TextBlockUtils.fullInnerPosition(bloc, m.getDisplay(false)); - return new TextBlockTracer(m, bloc); + TextBlock bloc = Display.getWithNewlines(cs.toString()).create8(config, align, skinParam, + CreoleMode.SIMPLE_LINE, skinParam.wrapWidth()); + return bloc; + } static class TextBlockTracer extends AbstractTextBlock implements TextBlock { @@ -235,12 +248,9 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlockW return TextBlockWithUrl.withUrl(uBlock, url); } - public TextBlock asTextBlock(final double widthToUse) { - return this; - } - public boolean contains(String member) { - for (Member att : members) { + for (CharSequence cs : members) { + final Member att = (Member) cs; if (att.getDisplay(false).startsWith(member)) { return true; } @@ -260,7 +270,8 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlockW if (hasSmallIcon()) { group = new ULayoutGroup( new PlacementStrategyVisibility(stringBounder, skinParam.getCircledCharacterRadius() + 3)); - for (Member att : members) { + for (CharSequence cs : members) { + final Member att = (Member) cs; final TextBlock bloc = createTextBlock(att); final VisibilityModifier modifier = att.getVisibilityModifier(); group.add(getUBlock(modifier, att.getUrl())); @@ -276,8 +287,8 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlockW placementStrategy = new PlacementStrategyY1Y2Left(stringBounder); } group = new ULayoutGroup(placementStrategy); - for (Member att : members) { - final TextBlock bloc = createTextBlock(att); + for (CharSequence cs : members) { + final TextBlock bloc = createTextBlock(cs); group.add(bloc); } } diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/AbstractGraphviz.java b/src/net/sourceforge/plantuml/cucadiagram/dot/AbstractGraphviz.java index 310cad28d..095a8d319 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/AbstractGraphviz.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/AbstractGraphviz.java @@ -78,7 +78,7 @@ abstract class AbstractGraphviz implements Graphviz { this.type = type; } - private File searchDotExe() { + protected File searchDotExe() { String getenv = GraphvizUtils.getenvGraphvizDot(); if (getenv == null) { getenv = findExecutableOnPath(getExeName()); diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramTxtMaker.java b/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramTxtMaker.java index abfef0ab9..66e749b0a 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramTxtMaker.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramTxtMaker.java @@ -132,23 +132,28 @@ public final class CucaDiagramTxtMaker { final int w = getWidth(ent); final int h = getHeight(ent); ug.getCharArea().drawBoxSimple(0, 0, w, h); - ug.getCharArea().drawStringsLR(ent.getDisplay().as(), 1, 1); + ug.getCharArea().drawStringsLRSimple(ent.getDisplay().as(), 1, 1); if (showMember(ent)) { int y = 2; ug.getCharArea().drawHLine('-', y, 1, w - 1); y++; - for (Member att : ent.getBodier().getFieldsToDisplay()) { - final List disp = BackSlash.getWithNewlines(att.getDisplay(true)); - ug.getCharArea().drawStringsLR(disp, 1, y); - y += StringUtils.getHeight(disp); - } - ug.getCharArea().drawHLine('-', y, 1, w - 1); - y++; - for (Member att : ent.getBodier().getMethodsToDisplay()) { - final List disp = BackSlash.getWithNewlines(att.getDisplay(true)); - ug.getCharArea().drawStringsLR(disp, 1, y); + for (CharSequence att : ent.getBodier().getRawBody()) { + final List disp = BackSlash.getWithNewlines(att.toString()); + ug.getCharArea().drawStringsLRSimple(disp, 1, y); y += StringUtils.getHeight(disp); } +// for (Member att : ent.getBodier().getFieldsToDisplay()) { +// final List disp = BackSlash.getWithNewlines(att.getDisplay(true)); +// ug.getCharArea().drawStringsLR(disp, 1, y); +// y += StringUtils.getHeight(disp); +// } +// ug.getCharArea().drawHLine('-', y, 1, w - 1); +// y++; +// for (Member att : ent.getBodier().getMethodsToDisplay()) { +// final List disp = BackSlash.getWithNewlines(att.getDisplay(true)); +// ug.getCharArea().drawStringsLR(disp, 1, y); +// y += StringUtils.getHeight(disp); +// } } } @@ -164,33 +169,42 @@ public final class CucaDiagramTxtMaker { private int getHeight(IEntity entity) { int result = StringUtils.getHeight(entity.getDisplay()); if (showMember(entity)) { - for (Member att : entity.getBodier().getMethodsToDisplay()) { - result += StringUtils.getHeight(Display.getWithNewlines(att.getDisplay(true))); + for (CharSequence att : entity.getBodier().getRawBody()) { + result += StringUtils.getHeight(Display.getWithNewlines(att.toString())); } - result++; - for (Member att : entity.getBodier().getFieldsToDisplay()) { - result += StringUtils.getHeight(Display.getWithNewlines(att.getDisplay(true))); - } - result++; +// for (Member att : entity.getBodier().getMethodsToDisplay()) { +// result += StringUtils.getHeight(Display.getWithNewlines(att.getDisplay(true))); +// } +// result++; +// for (Member att : entity.getBodier().getFieldsToDisplay()) { +// result += StringUtils.getHeight(Display.getWithNewlines(att.getDisplay(true))); +// } +// result++; } - return result + 2; + return result + 3; } private int getWidth(IEntity entity) { int result = StringUtils.getWcWidth(entity.getDisplay()); if (showMember(entity)) { - for (Member att : entity.getBodier().getMethodsToDisplay()) { - final int w = StringUtils.getWcWidth(Display.getWithNewlines(att.getDisplay(true))); - if (w > result) { - result = w; - } - } - for (Member att : entity.getBodier().getFieldsToDisplay()) { - final int w = StringUtils.getWcWidth(Display.getWithNewlines(att.getDisplay(true))); + for (CharSequence att : entity.getBodier().getRawBody()) { + final int w = StringUtils.getWcWidth(Display.getWithNewlines(att.toString())); if (w > result) { result = w; } } +// for (Member att : entity.getBodier().getMethodsToDisplay()) { +// final int w = StringUtils.getWcWidth(Display.getWithNewlines(att.getDisplay(true))); +// if (w > result) { +// result = w; +// } +// } +// for (Member att : entity.getBodier().getFieldsToDisplay()) { +// final int w = StringUtils.getWcWidth(Display.getWithNewlines(att.getDisplay(true))); +// if (w > result) { +// result = w; +// } +// } } return result + 2; } diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizWindows.java b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizWindows.java index 056798400..8314339af 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizWindows.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizWindows.java @@ -36,26 +36,23 @@ package net.sourceforge.plantuml.cucadiagram.dot; import java.io.File; -import java.io.FileFilter; import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.windowsdot.WindowsDotArchive; class GraphvizWindows extends AbstractGraphviz { static private File specificDotExe; + @Override + protected File searchDotExe() { + return specificDotExe(); + } + @Override protected File specificDotExe() { synchronized (GraphvizWindows.class) { - if (specificDotExe == null) { - specificDotExe = specificDotExeSlow(); - } if (specificDotExe == null) try { specificDotExe = new WindowsDotArchive().getWindowsExeLite(); @@ -68,60 +65,7 @@ class GraphvizWindows extends AbstractGraphviz { } public boolean graphviz244onWindows() { - try { - return GraphvizUtils.getDotVersion() == 244; - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - private File specificDotExeSlow() { - for (File tmp : new File("c:/").listFiles(new FileFilter() { - public boolean accept(java.io.File pathname) { - return pathname.isDirectory() && pathname.canRead(); - } - })) { - final File result = searchInDir(tmp); - if (result != null) { - return result; - } - } - return null; - } - - private static File searchInDir(final File dir) { - if (dir.exists() == false || dir.isDirectory() == false) { - return null; - } - final List dots = new ArrayList(); - final File[] files = dir.listFiles(new FileFilter() { - public boolean accept(java.io.File pathname) { - return pathname.isDirectory() && StringUtils.goLowerCase(pathname.getName()).startsWith("graphviz"); - } - }); - if (files == null) { - return null; - } - for (File f : files) { - final File result = new File(new File(f, "bin"), "dot.exe"); - if (result.exists() && result.canRead()) { - dots.add(result.getAbsoluteFile()); - } - final File result2 = new File(new File(f, "release/bin"), "dot.exe"); - if (result2.exists() && result2.canRead()) { - dots.add(result2.getAbsoluteFile()); - } - } - return higherVersion(dots); - } - - static File higherVersion(List dots) { - if (dots.size() == 0) { - return null; - } - Collections.sort(dots, Collections.reverseOrder()); - return dots.get(0); + return false; } GraphvizWindows(ISkinParam skinParam, String dotString, String... type) { diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizWindowsOld.java b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizWindowsOld.java new file mode 100644 index 000000000..b53c6f84f --- /dev/null +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizWindowsOld.java @@ -0,0 +1,136 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.cucadiagram.dot; + +import java.io.File; +import java.io.FileFilter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.StringUtils; +import net.sourceforge.plantuml.windowsdot.WindowsDotArchive; + +class GraphvizWindowsOld extends AbstractGraphviz { + + static private File specificDotExe; + + @Override + protected File specificDotExe() { + synchronized (GraphvizWindowsOld.class) { + if (specificDotExe == null) { + specificDotExe = specificDotExeSlow(); + } + if (specificDotExe == null) + try { + specificDotExe = new WindowsDotArchive().getWindowsExeLite(); + } catch (IOException e) { + e.printStackTrace(); + } + + return specificDotExe; + } + } + + public boolean graphviz244onWindows() { + try { + return GraphvizUtils.getDotVersion() == 244; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + private File specificDotExeSlow() { + for (File tmp : new File("c:/").listFiles(new FileFilter() { + public boolean accept(java.io.File pathname) { + return pathname.isDirectory() && pathname.canRead(); + } + })) { + final File result = searchInDir(tmp); + if (result != null) { + return result; + } + } + return null; + } + + private static File searchInDir(final File dir) { + if (dir.exists() == false || dir.isDirectory() == false) { + return null; + } + final List dots = new ArrayList(); + final File[] files = dir.listFiles(new FileFilter() { + public boolean accept(java.io.File pathname) { + return pathname.isDirectory() && StringUtils.goLowerCase(pathname.getName()).startsWith("graphviz"); + } + }); + if (files == null) { + return null; + } + for (File f : files) { + final File result = new File(new File(f, "bin"), "dot.exe"); + if (result.exists() && result.canRead()) { + dots.add(result.getAbsoluteFile()); + } + final File result2 = new File(new File(f, "release/bin"), "dot.exe"); + if (result2.exists() && result2.canRead()) { + dots.add(result2.getAbsoluteFile()); + } + } + return higherVersion(dots); + } + + static File higherVersion(List dots) { + if (dots.size() == 0) { + return null; + } + Collections.sort(dots, Collections.reverseOrder()); + return dots.get(0); + } + + GraphvizWindowsOld(ISkinParam skinParam, String dotString, String... type) { + super(skinParam, dotString, type); + } + + @Override + protected String getExeName() { + return "dot.exe"; + } + +} diff --git a/src/net/sourceforge/plantuml/cucadiagram/entity/EntityFactory.java b/src/net/sourceforge/plantuml/cucadiagram/entity/EntityFactory.java index f6ffa2fb1..7d0cae234 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/entity/EntityFactory.java +++ b/src/net/sourceforge/plantuml/cucadiagram/entity/EntityFactory.java @@ -51,8 +51,8 @@ import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.UseStyle; import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.cucadiagram.Bodier; -import net.sourceforge.plantuml.cucadiagram.BodierImpl; import net.sourceforge.plantuml.cucadiagram.BodierMap; +import net.sourceforge.plantuml.cucadiagram.BodyFactory; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.CucaDiagram; import net.sourceforge.plantuml.cucadiagram.Display; @@ -224,7 +224,7 @@ public final class EntityFactory { if (entityType == null) { throw new IllegalArgumentException(); } - final Bodier bodier = entityType == LeafType.MAP ? new BodierMap() : new BodierImpl(entityType, hides); + final Bodier bodier = entityType == LeafType.MAP ? new BodierMap() : BodyFactory.createLeaf(entityType, hides); final EntityImpl result = new EntityImpl(ident, code, this, bodier, parentContainer, entityType, namespaceSeparator, rawLayout); bodier.setLeaf(result); @@ -242,7 +242,7 @@ public final class EntityFactory { return ent.getValue(); } } - final Bodier bodier = new BodierImpl(null, hides); + final Bodier bodier = BodyFactory.createGroup(hides); final EntityImpl result = new EntityImpl(ident, code, this, bodier, parentContainer, groupType, namespace, namespaceSeparator, rawLayout); if (Display.isNull(display) == false) { diff --git a/src/net/sourceforge/plantuml/descdiagram/EntityImageRequirement.java b/src/net/sourceforge/plantuml/descdiagram/EntityImageRequirement.java index 539e2a220..04f5cd4e0 100644 --- a/src/net/sourceforge/plantuml/descdiagram/EntityImageRequirement.java +++ b/src/net/sourceforge/plantuml/descdiagram/EntityImageRequirement.java @@ -45,7 +45,7 @@ import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.creole.Stencil; -import net.sourceforge.plantuml.cucadiagram.BodyEnhanced; +import net.sourceforge.plantuml.cucadiagram.BodyFactory; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Stereotype; @@ -56,7 +56,6 @@ import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.graphic.color.ColorType; -import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.svek.AbstractEntityImage; import net.sourceforge.plantuml.svek.ShapeType; import net.sourceforge.plantuml.ugraphic.AbstractUGraphicHorizontalLine; @@ -78,8 +77,8 @@ public class EntityImageRequirement extends AbstractEntityImage { super(entity, skinParam); final Stereotype stereotype = entity.getStereotype(); - final TextBlock tmp = new BodyEnhanced(entity.getDisplay(), FontParam.REQUIREMENT, skinParam, - HorizontalAlignment.CENTER, stereotype, true, false, entity, null); + final TextBlock tmp = BodyFactory.create2(entity.getDisplay(), FontParam.REQUIREMENT, skinParam, + HorizontalAlignment.CENTER, stereotype, entity, null); if (stereotype == null || stereotype.getLabel(Guillemet.DOUBLE_COMPARATOR) == null) { this.desc = tmp; diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementMultilines.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementMultilines.java index f281c8305..8bfa6506a 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementMultilines.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementMultilines.java @@ -82,7 +82,7 @@ public class CommandCreateElementMultilines extends CommandMultilines2Fields:"); pw.println("
    "); - for (Member m : entity.getBodier().getFieldsToDisplay()) { + for (CharSequence m : entity.getBodier().getFieldsToDisplay()) { pw.println("
  • "); - pw.println(StringUtils.unicodeForHtml(m.getDisplay(true))); + pw.println(StringUtils.unicodeForHtml(m.toString())); pw.println("
  • "); } pw.println("
"); @@ -154,9 +153,9 @@ public final class CucaDiagramHtmlMaker { } else { pw.println("

Methods:

"); pw.println("
    "); - for (Member m : entity.getBodier().getMethodsToDisplay()) { + for (CharSequence m : entity.getBodier().getMethodsToDisplay()) { pw.println("
  • "); - pw.println(StringUtils.unicodeForHtml(m.getDisplay(true))); + pw.println(StringUtils.unicodeForHtml(m.toString())); pw.println("
  • "); } pw.println("
"); diff --git a/src/net/sourceforge/plantuml/jdot/CucaDiagramFileMakerJDot.java b/src/net/sourceforge/plantuml/jdot/CucaDiagramFileMakerJDot.java index 19ddb6958..bf5aba43d 100644 --- a/src/net/sourceforge/plantuml/jdot/CucaDiagramFileMakerJDot.java +++ b/src/net/sourceforge/plantuml/jdot/CucaDiagramFileMakerJDot.java @@ -92,7 +92,6 @@ import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockEmpty; import net.sourceforge.plantuml.graphic.TextBlockUtils; -import net.sourceforge.plantuml.graphic.TextBlockWidth; import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft; import net.sourceforge.plantuml.style.SName; @@ -259,14 +258,9 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker { final TextBlock stereoAndTitle = TextBlockUtils.mergeTB(stereo, title, HorizontalAlignment.CENTER); final Dimension2D dimLabel = stereoAndTitle.calculateDimension(stringBounder); if (dimLabel.getWidth() > 0) { - final List members = ((IEntity) g).getBodier().getFieldsToDisplay(); - final TextBlockWidth attribute; - if (members.size() == 0) { - attribute = new TextBlockEmpty(); - } else { - attribute = new MethodsOrFieldsArea(members, FontParam.STATE_ATTRIBUTE, diagram.getSkinParam(), - g.getStereotype(), null, getStyle(FontParam.STATE_ATTRIBUTE)); - } + + final TextBlock attribute = GeneralImageBuilder.stateHeader(g, null, diagram.getSkinParam()); + final Dimension2D dimAttribute = attribute.calculateDimension(stringBounder); final double attributeHeight = dimAttribute.getHeight(); final double attributeWidth = dimAttribute.getWidth(); diff --git a/src/net/sourceforge/plantuml/jsondiagram/JsonDiagram.java b/src/net/sourceforge/plantuml/jsondiagram/JsonDiagram.java index a69cad940..e917257b2 100644 --- a/src/net/sourceforge/plantuml/jsondiagram/JsonDiagram.java +++ b/src/net/sourceforge/plantuml/jsondiagram/JsonDiagram.java @@ -75,7 +75,7 @@ public class JsonDiagram extends UmlDiagram { private final List highlighted; public JsonDiagram(JsonValue json, List highlighted) { - if (json.isString() || json.isBoolean() || json.isNumber()) { + if (json != null && (json.isString() || json.isBoolean() || json.isNumber())) { this.root = new JsonArray(); ((JsonArray) this.root).add(json); } else { @@ -110,8 +110,9 @@ public class JsonDiagram extends UmlDiagram { margin2 = 10; } final ClockwiseTopRightBottomLeft margins = ClockwiseTopRightBottomLeft.margin1margin2(margin1, margin2); - final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null, dpiFactor, "", - "", margins, null); + final String metadata = fileFormatOption.isWithMetadata() ? getMetadata() : null; + final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null, dpiFactor, + metadata, "", margins, null); final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter); TextBlock result = getTextBlock(); result = new AnnotatedWorker(this, skinParam, fileFormatOption.getDefaultStringBounder(getSkinParam())) diff --git a/src/net/sourceforge/plantuml/jsondiagram/TextBlockJson.java b/src/net/sourceforge/plantuml/jsondiagram/TextBlockJson.java index 8d3294f19..4eba8ea81 100644 --- a/src/net/sourceforge/plantuml/jsondiagram/TextBlockJson.java +++ b/src/net/sourceforge/plantuml/jsondiagram/TextBlockJson.java @@ -148,9 +148,20 @@ public class TextBlockJson extends AbstractTextBlock implements TextBlockBackcol if (value.isString()) { return value.asString(); } - if (value.isNumber() || value.isBoolean()) { + if (value.isNull()) { + return ""; + // return " null"; + } + if (value.isNumber()) { return value.toString(); } + if (value.isBoolean()) { + if (value.isTrue()) { + return " true"; + } else { + return " false"; + } + } return " "; } diff --git a/src/net/sourceforge/plantuml/sequencediagram/MessageNumber.java b/src/net/sourceforge/plantuml/sequencediagram/MessageNumber.java index 9022c232b..830a41fc0 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/MessageNumber.java +++ b/src/net/sourceforge/plantuml/sequencediagram/MessageNumber.java @@ -48,8 +48,8 @@ public class MessageNumber implements CharSequence { this.representation = s; } - public String getNumber() { - return representation; + public String getNumberRaw() { + return representation.replaceAll("\\", ""); } public char charAt(int arg0) { diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramTxtMaker.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramTxtMaker.java index 0f89b1369..df18bb5eb 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramTxtMaker.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramTxtMaker.java @@ -119,7 +119,7 @@ public class SequenceDiagramTxtMaker implements FileMaker { if (title.isWhite() == false) { final int widthTitle = StringUtils.getWcWidth(title); final UmlCharArea charArea = ug.getCharArea(); - charArea.drawStringsLR(title.as(), (int) ((fullDimension.getWidth() - widthTitle) / 2), 0); + charArea.drawStringsLRSimple(title.as(), (int) ((fullDimension.getWidth() - widthTitle) / 2), 0); } } diff --git a/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java b/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java index 59324ae8e..40a5fb804 100644 --- a/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java +++ b/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java @@ -43,7 +43,7 @@ import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.UseStyle; import net.sourceforge.plantuml.creole.CreoleMode; -import net.sourceforge.plantuml.cucadiagram.BodyEnhanced2; +import net.sourceforge.plantuml.cucadiagram.BodyFactory; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -111,8 +111,8 @@ public abstract class AbstractTextualComponent extends AbstractComponent { if (this.display.size() == 1 && this.display.get(0).length() == 0) { textBlock = new TextBlockEmpty(); } else if (enhanced) { - textBlock = new BodyEnhanced2(this.display, FontParam.NOTE, spriteContainer, horizontalAlignment, fc, - maxMessageSize, spriteContainer.minClassWidth()); + textBlock = BodyFactory.create3(this.display, FontParam.NOTE, spriteContainer, horizontalAlignment, fc, + maxMessageSize); } else { textBlock = this.display.create0(fc, horizontalAlignment, spriteContainer, maxMessageSize, CreoleMode.FULL, fontForStereotype, htmlColorForStereotype); diff --git a/src/net/sourceforge/plantuml/skin/VisibilityModifier.java b/src/net/sourceforge/plantuml/skin/VisibilityModifier.java index 3cfd8569e..901f34afe 100644 --- a/src/net/sourceforge/plantuml/skin/VisibilityModifier.java +++ b/src/net/sourceforge/plantuml/skin/VisibilityModifier.java @@ -40,6 +40,7 @@ import java.awt.geom.Rectangle2D; import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.InnerStrategy; import net.sourceforge.plantuml.graphic.StringBounder; @@ -54,26 +55,31 @@ import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorNone; public enum VisibilityModifier { - PRIVATE_FIELD(ColorParam.iconPrivate, null), PROTECTED_FIELD(ColorParam.iconProtected, null), - PACKAGE_PRIVATE_FIELD(ColorParam.iconPackage, null), PUBLIC_FIELD(ColorParam.iconPublic, null), + PRIVATE_FIELD(StringUtils.PRIVATE_FIELD, ColorParam.iconPrivate, null), + PROTECTED_FIELD(StringUtils.PROTECTED_FIELD, ColorParam.iconProtected, null), + PACKAGE_PRIVATE_FIELD(StringUtils.PACKAGE_PRIVATE_FIELD, ColorParam.iconPackage, null), + PUBLIC_FIELD(StringUtils.PUBLIC_FIELD, ColorParam.iconPublic, null), - PRIVATE_METHOD(ColorParam.iconPrivate, ColorParam.iconPrivateBackground), - PROTECTED_METHOD(ColorParam.iconProtected, ColorParam.iconProtectedBackground), - PACKAGE_PRIVATE_METHOD(ColorParam.iconPackage, ColorParam.iconPackageBackground), - PUBLIC_METHOD(ColorParam.iconPublic, ColorParam.iconPublicBackground), + PRIVATE_METHOD(StringUtils.PRIVATE_METHOD, ColorParam.iconPrivate, ColorParam.iconPrivateBackground), + PROTECTED_METHOD(StringUtils.PROTECTED_METHOD, ColorParam.iconProtected, ColorParam.iconProtectedBackground), + PACKAGE_PRIVATE_METHOD(StringUtils.PACKAGE_PRIVATE_METHOD, ColorParam.iconPackage, + ColorParam.iconPackageBackground), + PUBLIC_METHOD(StringUtils.PUBLIC_METHOD, ColorParam.iconPublic, ColorParam.iconPublicBackground), - IE_MANDATORY(ColorParam.iconIEMandatory, ColorParam.iconIEMandatory); + IE_MANDATORY(StringUtils.IE_MANDATORY, ColorParam.iconIEMandatory, ColorParam.iconIEMandatory); private final ColorParam foregroundParam; private final ColorParam backgroundParam; + private final char unicode; public static String regexForVisibilityCharacterInClassName() { return "[-#+~]"; } - private VisibilityModifier(ColorParam foreground, ColorParam background) { + private VisibilityModifier(char unicode, ColorParam foreground, ColorParam background) { this.foregroundParam = foreground; this.backgroundParam = background; + this.unicode = unicode; } public UDrawable getUDrawable(final int size, final HColor foregroundColor, final HColor backgoundColor) { @@ -218,6 +224,23 @@ public enum VisibilityModifier { return false; } + public static VisibilityModifier getByUnicode(char c) { + for (VisibilityModifier modifier : VisibilityModifier.values()) { + if (modifier.unicode == c) { + return modifier; + } + } + return null; + } + + public static String replaceVisibilityModifierByUnicodeChar(String s, boolean isField) { + final VisibilityModifier modifier = getVisibilityModifier(s, isField); + if (modifier == null) { + return s; + } + return "" + modifier.unicode + s.substring(1); + } + public static VisibilityModifier getVisibilityModifier(CharSequence s, boolean isField) { if (s.length() <= 2) { return null; diff --git a/src/net/sourceforge/plantuml/svek/Cluster.java b/src/net/sourceforge/plantuml/svek/Cluster.java index afcaa3c2b..55adf81dd 100644 --- a/src/net/sourceforge/plantuml/svek/Cluster.java +++ b/src/net/sourceforge/plantuml/svek/Cluster.java @@ -62,15 +62,11 @@ import net.sourceforge.plantuml.cucadiagram.EntityPosition; import net.sourceforge.plantuml.cucadiagram.EntityUtils; import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.IGroup; -import net.sourceforge.plantuml.cucadiagram.Member; -import net.sourceforge.plantuml.cucadiagram.MethodsOrFieldsArea; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.cucadiagram.dot.GraphvizVersion; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.graphic.TextBlockEmpty; -import net.sourceforge.plantuml.graphic.TextBlockWidth; import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.Colors; @@ -481,7 +477,8 @@ public class Cluster implements Moveable { stateBack = getColor(skinParam2, ColorParam.stateBackground, group.getStereotype()); } final HColor background = getColor(skinParam2, ColorParam.background, null); - final TextBlockWidth attribute = getTextBlockAttribute(skinParam2); + final Style style = getStyle(FontParam.STATE_ATTRIBUTE, skinParam2); + final TextBlock attribute = GeneralImageBuilder.stateHeader(group, style, skinParam2); final double attributeHeight = attribute.calculateDimension(ug.getStringBounder()).getHeight(); if (total.getWidth() == 0) { System.err.println("Cluster::drawUState issue"); @@ -497,7 +494,7 @@ public class Cluster implements Moveable { } if (attributeHeight > 0) { - attribute.asTextBlock(total.getWidth()).drawU( + attribute.drawU( ug.apply(new UTranslate(minX + IEntityImage.MARGIN, minY + suppY + IEntityImage.MARGIN / 2.0))); } @@ -509,18 +506,6 @@ public class Cluster implements Moveable { } - private TextBlockWidth getTextBlockAttribute(ISkinParam skinParam) { - final TextBlockWidth attribute; - final List members = group.getBodier().getFieldsToDisplay(); - if (members.size() == 0) { - attribute = new TextBlockEmpty(); - } else { - attribute = new MethodsOrFieldsArea(members, FontParam.STATE_ATTRIBUTE, skinParam, group.getStereotype(), - null, getStyle(FontParam.STATE_ATTRIBUTE, skinParam)); - } - return attribute; - } - public void setPosition(double minX, double minY, double maxX, double maxY) { this.minX = minX; this.maxX = maxX; diff --git a/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java b/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java index 7f24b606a..3225829f8 100644 --- a/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java +++ b/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java @@ -100,7 +100,6 @@ import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockEmpty; import net.sourceforge.plantuml.graphic.TextBlockUtils; -import net.sourceforge.plantuml.graphic.TextBlockWidth; import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.graphic.USymbolInterface; import net.sourceforge.plantuml.style.PName; @@ -172,7 +171,7 @@ public final class GeneralImageBuilder { final Cluster stateParent = bibliotekon.getCluster(leaf.getParentContainer()); return new EntityImageStateBorder(leaf, skinParam, stateParent, bibliotekon); } - if (isHideEmptyDescriptionForState && leaf.getBodier().getFieldsToDisplay().size() == 0) { + if (isHideEmptyDescriptionForState && leaf.getBodier().getRawBody().size() == 0) { return new EntityImageStateEmptyDescription(leaf, skinParam); } if (leaf.getStereotype() != null @@ -463,10 +462,11 @@ public final class GeneralImageBuilder { try { svg = dotStringFactory.getSvg(basefile, dotStrings); } catch (IOException e) { - return new GraphvizCrash(source.getPlainString(), GraphvizUtils.graphviz244onWindows()); + return new GraphvizCrash(source.getPlainString(), GraphvizUtils.graphviz244onWindows(), e); } if (svg.length() == 0) { - return new GraphvizCrash(source.getPlainString(), GraphvizUtils.graphviz244onWindows()); + return new GraphvizCrash(source.getPlainString(), GraphvizUtils.graphviz244onWindows(), + new EmptySvgException()); } final String graphvizVersion = extractGraphvizVersion(svg); try { @@ -629,15 +629,8 @@ public final class GeneralImageBuilder { final TextBlock stereoAndTitle = TextBlockUtils.mergeTB(stereo, title, HorizontalAlignment.CENTER); final Dimension2D dimLabel = stereoAndTitle.calculateDimension(stringBounder); if (dimLabel.getWidth() > 0) { - final List members = ((IEntity) g).getBodier().getFieldsToDisplay(); - final TextBlockWidth attribute; - if (members.size() == 0) { - attribute = new TextBlockEmpty(); - } else { - attribute = new MethodsOrFieldsArea(members, FontParam.STATE_ATTRIBUTE, dotData.getSkinParam(), - g.getStereotype(), null, getStyle(FontParam.STATE_ATTRIBUTE)); - } - final Dimension2D dimAttribute = attribute.calculateDimension(stringBounder); + final Dimension2D dimAttribute = stateHeader((IEntity) g, getStyle(FontParam.STATE_ATTRIBUTE), + dotData.getSkinParam()).calculateDimension(stringBounder); final double attributeHeight = dimAttribute.getHeight(); final double attributeWidth = dimAttribute.getWidth(); final double marginForFields = attributeHeight > 0 ? IEntityImage.MARGIN : 0; @@ -658,6 +651,31 @@ public final class GeneralImageBuilder { dotStringFactory.closeCluster(); } + public static TextBlock stateHeader(IEntity group, Style style, ISkinParam skinParam) { + final List details = group.getBodier().getRawBody(); + + if (details.size() == 0) { + return new TextBlockEmpty(); + } + final FontConfiguration fontConfiguration; + if (style == null) { + fontConfiguration = new FontConfiguration(skinParam, FontParam.STATE_ATTRIBUTE, null); + } else { + fontConfiguration = new FontConfiguration(skinParam, style); + } + Display display = null; + for (CharSequence s : details) { + if (display == null) { + display = Display.getWithNewlines(s.toString()); + } else { + display = display.addAll(Display.getWithNewlines(s.toString())); + } + } + + return display.create(fontConfiguration, HorizontalAlignment.LEFT, skinParam); + + } + private Style getStyle(FontParam fontParam) { return fontParam.getStyleDefinition(SName.stateDiagram) .getMergedStyle(dotData.getSkinParam().getCurrentStyleBuilder()); diff --git a/src/net/sourceforge/plantuml/svek/GraphvizCrash.java b/src/net/sourceforge/plantuml/svek/GraphvizCrash.java index c46443c96..2845d8713 100644 --- a/src/net/sourceforge/plantuml/svek/GraphvizCrash.java +++ b/src/net/sourceforge/plantuml/svek/GraphvizCrash.java @@ -44,6 +44,7 @@ import java.util.List; import net.sourceforge.plantuml.BackSlash; import net.sourceforge.plantuml.OptionPrint; import net.sourceforge.plantuml.StringUtils; +import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils; import net.sourceforge.plantuml.flashcode.FlashCodeFactory; import net.sourceforge.plantuml.flashcode.FlashCodeUtils; @@ -72,12 +73,12 @@ public class GraphvizCrash extends AbstractTextBlock implements IEntityImage { private final String text; private final boolean graphviz244onWindows; - public GraphvizCrash(String text, boolean graphviz244onWindows) { + public GraphvizCrash(String text, boolean graphviz244onWindows, Throwable rootCause) { this.text = text; this.graphviz244onWindows = graphviz244onWindows; final FlashCodeUtils utils = FlashCodeFactory.getFlashCodeUtils(); this.flashCode = utils.exportFlashcode(text, Color.BLACK, Color.WHITE); - this.text1 = GraphicStrings.createBlackOnWhite(init(), IconLoader.getRandom(), + this.text1 = GraphicStrings.createBlackOnWhite(init(rootCause), IconLoader.getRandom(), GraphicPosition.BACKGROUND_CORNER_TOP_RIGHT); } @@ -132,9 +133,15 @@ public class GraphvizCrash extends AbstractTextBlock implements IEntityImage { strings.add(" - a problem in GraphViz"); } - private List init() { + private List init(Throwable rootCause) { final List strings = anErrorHasOccured(null, text); strings.add("For some reason, dot/GraphViz has crashed."); + strings.add(""); + strings.add("RootCause " + rootCause); + if (rootCause != null) { + strings.addAll(CommandExecutionResult.getStackTrace(rootCause)); + } + strings.add(""); strings.add("This has been generated with PlantUML (" + Version.versionString() + ")."); checkOldVersionWarning(strings); strings.add(" "); @@ -217,7 +224,7 @@ public class GraphvizCrash extends AbstractTextBlock implements IEntityImage { final UImage dotd = new UImage(new PixelImage(PSystemVersion.getDotd(), AffineTransformType.TYPE_BILINEAR)); result = TextBlockUtils.mergeTB(result, dotd, HorizontalAlignment.LEFT); -} + } return result; } diff --git a/src/net/sourceforge/plantuml/svek/GroupPngMakerState.java b/src/net/sourceforge/plantuml/svek/GroupPngMakerState.java index ff99248c5..a6fd71aa7 100644 --- a/src/net/sourceforge/plantuml/svek/GroupPngMakerState.java +++ b/src/net/sourceforge/plantuml/svek/GroupPngMakerState.java @@ -60,9 +60,6 @@ import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.graphic.TextBlockEmpty; -import net.sourceforge.plantuml.graphic.TextBlockWidth; -import net.sourceforge.plantuml.graphic.TextBlockWidthAdapter; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.style.SName; @@ -158,7 +155,7 @@ public final class GroupPngMakerState { final HColor backColor = group.getColors(skinParam).getColor(ColorType.BACK) == null ? getColor(ColorParam.stateBackground, stereo) : group.getColors(skinParam).getColor(ColorType.BACK); - final TextBlockWidth attribute = getAttributes(skinParam); + final TextBlock attribute = GeneralImageBuilder.stateHeader((IEntity) group, null, skinParam); final Stereotype stereotype = group.getStereotype(); final boolean withSymbol = stereotype != null && stereotype.isWithOOSymbol(); @@ -175,27 +172,6 @@ public final class GroupPngMakerState { } - private TextBlockWidth getAttributes(final ISkinParam skinParam) { - final List details = ((IEntity) group).getBodier().getRawBody(); - - if (details.size() == 0) { - return new TextBlockEmpty(); - } - final FontConfiguration fontConfiguration = new FontConfiguration(skinParam, FontParam.STATE_ATTRIBUTE, null); - Display display = null; - for (String s : details) { - if (display == null) { - display = Display.getWithNewlines(s); - } else { - display = display.addAll(Display.getWithNewlines(s)); - } - } - - final TextBlock result = display.create(fontConfiguration, HorizontalAlignment.LEFT, skinParam); - return new TextBlockWidthAdapter(result, 0); - - } - private IEntityImage buildImageForConcurrentState(DotData dotData) { final List inners = new ArrayList(); for (ILeaf inner : dotData.getLeafs()) { diff --git a/src/net/sourceforge/plantuml/svek/InnerStateAutonom.java b/src/net/sourceforge/plantuml/svek/InnerStateAutonom.java index 554ddf7c9..ce53c7577 100644 --- a/src/net/sourceforge/plantuml/svek/InnerStateAutonom.java +++ b/src/net/sourceforge/plantuml/svek/InnerStateAutonom.java @@ -42,7 +42,6 @@ import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.graphic.TextBlockWidth; import net.sourceforge.plantuml.svek.image.EntityImageState; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UStroke; @@ -53,7 +52,7 @@ public final class InnerStateAutonom extends AbstractTextBlock implements IEntit private final IEntityImage im; private final TextBlock title; - private final TextBlockWidth attribute; + private final TextBlock attribute; private final HColor borderColor; private final HColor backColor; private final boolean shadowing; @@ -61,8 +60,8 @@ public final class InnerStateAutonom extends AbstractTextBlock implements IEntit private final boolean withSymbol; private final UStroke stroke; - public InnerStateAutonom(final IEntityImage im, final TextBlock title, TextBlockWidth attribute, - HColor borderColor, HColor backColor, boolean shadowing, Url url, boolean withSymbol, UStroke stroke) { + public InnerStateAutonom(final IEntityImage im, final TextBlock title, TextBlock attribute, HColor borderColor, + HColor backColor, boolean shadowing, Url url, boolean withSymbol, UStroke stroke) { this.im = im; this.withSymbol = withSymbol; this.title = title; @@ -90,9 +89,8 @@ public final class InnerStateAutonom extends AbstractTextBlock implements IEntit r.drawU(ug, shadowing); title.drawU(ug.apply(new UTranslate((total.getWidth() - text.getWidth()) / 2, IEntityImage.MARGIN))); - attribute.asTextBlock(total.getWidth()).drawU( - ug.apply(new UTranslate(0 + IEntityImage.MARGIN, IEntityImage.MARGIN + text.getHeight() - + IEntityImage.MARGIN))); + attribute.drawU(ug.apply( + new UTranslate(0 + IEntityImage.MARGIN, IEntityImage.MARGIN + text.getHeight() + IEntityImage.MARGIN))); final double spaceYforURL = getSpaceYforURL(ug.getStringBounder()); im.drawU(ug.apply(new UTranslate(IEntityImage.MARGIN, spaceYforURL))); @@ -128,8 +126,8 @@ public final class InnerStateAutonom extends AbstractTextBlock implements IEntit final Dimension2D dim = Dimension2DDouble.mergeTB(text, attr, img); final double marginForFields = attr.getHeight() > 0 ? IEntityImage.MARGIN : 0; - final Dimension2D result = Dimension2DDouble.delta(dim, IEntityImage.MARGIN * 2 + 2 * IEntityImage.MARGIN_LINE - + marginForFields); + final Dimension2D result = Dimension2DDouble.delta(dim, + IEntityImage.MARGIN * 2 + 2 * IEntityImage.MARGIN_LINE + marginForFields); return result; } @@ -145,10 +143,9 @@ public final class InnerStateAutonom extends AbstractTextBlock implements IEntit public boolean isHidden() { return im.isHidden(); } - + public double getOverscanX(StringBounder stringBounder) { return 0; } - } diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageDescription.java b/src/net/sourceforge/plantuml/svek/image/EntityImageDescription.java index f9a39bd49..c5cb97d8c 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageDescription.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageDescription.java @@ -47,8 +47,7 @@ import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UseStyle; -import net.sourceforge.plantuml.cucadiagram.BodyEnhanced; -import net.sourceforge.plantuml.cucadiagram.BodyEnhanced2; +import net.sourceforge.plantuml.cucadiagram.BodyFactory; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.EntityPortion; import net.sourceforge.plantuml.cucadiagram.IEntity; @@ -175,9 +174,9 @@ public class EntityImageDescription extends AbstractEntityImage { desc = TextBlockUtils.empty(getSkinParam().minClassWidth(), 0); } else { - desc = new BodyEnhanced2(entity.getDisplay(), symbol.getFontParam(), getSkinParam(), + desc = BodyFactory.create3(entity.getDisplay(), symbol.getFontParam(), getSkinParam(), getSkinParam().getDefaultTextAlignment(HorizontalAlignment.LEFT), fcTitle, - getSkinParam().wrapWidth(), getSkinParam().minClassWidth()); + getSkinParam().wrapWidth()); } stereo = TextBlockUtils.empty(0, 0); @@ -191,8 +190,8 @@ public class EntityImageDescription extends AbstractEntityImage { HorizontalAlignment.CENTER, getSkinParam()); } - name = new BodyEnhanced(codeDisplay, symbol.getFontParam(), getSkinParam(), HorizontalAlignment.CENTER, - stereotype, symbol.manageHorizontalLine(), false, entity, style); + name = BodyFactory.create2(codeDisplay, symbol.getFontParam(), getSkinParam(), HorizontalAlignment.CENTER, + stereotype, entity, style); if (hideText) { asSmall = symbol.asSmall(TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0), diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye2.java b/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye2.java index 819d246ae..b26e27463 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye2.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye2.java @@ -43,7 +43,7 @@ import net.sourceforge.plantuml.Guillemet; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.Url; -import net.sourceforge.plantuml.cucadiagram.BodyEnhanced; +import net.sourceforge.plantuml.cucadiagram.BodyFactory; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.EntityPortion; import net.sourceforge.plantuml.cucadiagram.ILeaf; @@ -85,8 +85,8 @@ public class EntityImageLollipopInterfaceEye2 extends AbstractEntityImage { throw new IllegalArgumentException(); } - this.desc = new BodyEnhanced(entity.getDisplay(), symbol.getFontParam(), skinParam, HorizontalAlignment.CENTER, - stereotype, symbol.manageHorizontalLine(), false, entity, getStyle(symbol.getFontParam())); + this.desc = BodyFactory.create2(entity.getDisplay(), symbol.getFontParam(), skinParam, + HorizontalAlignment.CENTER, stereotype, entity, getStyle(symbol.getFontParam())); this.url = entity.getUrl99(); diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageNote.java b/src/net/sourceforge/plantuml/svek/image/EntityImageNote.java index 80d645db7..1cb1c5eb2 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageNote.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageNote.java @@ -51,7 +51,7 @@ import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UseStyle; import net.sourceforge.plantuml.creole.Stencil; -import net.sourceforge.plantuml.cucadiagram.BodyEnhanced2; +import net.sourceforge.plantuml.cucadiagram.BodyFactory; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.ILeaf; @@ -125,9 +125,9 @@ public class EntityImageNote extends AbstractEntityImage implements Stencil { if (strings.size() == 1 && strings.get(0).length() == 0) { textBlock = new TextBlockEmpty(); } else { - textBlock = new BodyEnhanced2(strings, FontParam.NOTE, getSkinParam(), HorizontalAlignment.LEFT, - new FontConfiguration(getSkinParam(), FontParam.NOTE, null), getSkinParam().wrapWidth(), - getSkinParam().minClassWidth()); + final FontConfiguration fc = new FontConfiguration(getSkinParam(), FontParam.NOTE, null); + textBlock = BodyFactory.create3(strings, FontParam.NOTE, getSkinParam(), HorizontalAlignment.LEFT, fc, + getSkinParam().wrapWidth()); } } diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageState.java b/src/net/sourceforge/plantuml/svek/image/EntityImageState.java index 240f5a101..9f2abd9c2 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageState.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageState.java @@ -92,10 +92,11 @@ public class EntityImageState extends AbstractEntityImage { this.desc = entity.getDisplay().create8(new FontConfiguration(getSkinParam(), FontParam.STATE, stereotype), HorizontalAlignment.CENTER, skinParam, CreoleMode.FULL, skinParam.wrapWidth()); - Display list = Display.empty(); - for (Member att : entity.getBodier().getFieldsToDisplay()) { - list = list.addAll(Display.getWithNewlines(att.getDisplay(true))); - } +// Display list = Display.empty(); +// for (Member att : entity.getBodier().getFieldsToDisplay()) { +// list = list.addAll(Display.getWithNewlines(att.getDisplay(true))); +// } + final Display list = Display.create(entity.getBodier().getRawBody()); this.url = entity.getUrl99(); diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageState2.java b/src/net/sourceforge/plantuml/svek/image/EntityImageState2.java index 502120e0a..04ffbfda4 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageState2.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageState2.java @@ -42,10 +42,8 @@ import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineConfigurable; import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.Url; -import net.sourceforge.plantuml.cucadiagram.BodyEnhanced; -import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.BodyFactory; import net.sourceforge.plantuml.cucadiagram.ILeaf; -import net.sourceforge.plantuml.cucadiagram.Member; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.StringBounder; @@ -75,10 +73,11 @@ public class EntityImageState2 extends AbstractEntityImage { this.lineConfig = entity; final Stereotype stereotype = entity.getStereotype(); - Display list = Display.empty(); - for (Member att : entity.getBodier().getFieldsToDisplay()) { - list = list.addAll(Display.getWithNewlines(att.getDisplay(true))); - } +// Display list = Display.empty(); +// for (Member att : entity.getBodier().getFieldsToDisplay()) { +// list = list.addAll(Display.getWithNewlines(att.getDisplay(true))); +// } + // final Display list = Display.create(entity.getBodier().getRawBody()); final USymbol symbol = USymbol.FRAME; @@ -95,9 +94,8 @@ public class EntityImageState2 extends AbstractEntityImage { this.url = entity.getUrl99(); TextBlock stereo = TextBlockUtils.empty(0, 0); - final TextBlock desc = new BodyEnhanced(entity.getDisplay(), symbol.getFontParam(), skinParam, - HorizontalAlignment.CENTER, stereotype, symbol.manageHorizontalLine(), false, entity, - getStyle(symbol.getFontParam())); + final TextBlock desc = BodyFactory.create2(entity.getDisplay(), symbol.getFontParam(), skinParam, + HorizontalAlignment.CENTER, stereotype, entity, getStyle(symbol.getFontParam())); asSmall = symbol.asSmall(null, desc, stereo, ctx, skinParam.getStereotypeAlignment()); diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageStateEmptyDescription.java b/src/net/sourceforge/plantuml/svek/image/EntityImageStateEmptyDescription.java index 17156432f..0ad6f0875 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageStateEmptyDescription.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageStateEmptyDescription.java @@ -77,10 +77,11 @@ public class EntityImageStateEmptyDescription extends AbstractEntityImage { this.desc = entity.getDisplay().create8(new FontConfiguration(getSkinParam(), FontParam.STATE, stereotype), HorizontalAlignment.CENTER, skinParam, CreoleMode.FULL, skinParam.wrapWidth()); - Display list = Display.empty(); - for (Member att : entity.getBodier().getFieldsToDisplay()) { - list = list.addAll(Display.getWithNewlines(att.getDisplay(true))); - } +// Display list = Display.empty(); +// for (Member att : entity.getBodier().getFieldsToDisplay()) { +// list = list.addAll(Display.getWithNewlines(att.getDisplay(true))); +// } +// final Display list = Display.create(entity.getBodier().getRawBody()); this.url = entity.getUrl99(); diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageTips.java b/src/net/sourceforge/plantuml/svek/image/EntityImageTips.java index 57c24541c..9648ffb01 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageTips.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageTips.java @@ -47,7 +47,7 @@ import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.command.Position; -import net.sourceforge.plantuml.cucadiagram.BodyEnhanced2; +import net.sourceforge.plantuml.cucadiagram.BodyFactory; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.ILeaf; @@ -163,11 +163,9 @@ public class EntityImageTips extends AbstractEntityImage { } private Opale getOpale(final Display display) { - // final HtmlColor fontColor = rose.getFontColor(skinParam, FontParam.NOTE); - // final UFont fontNote = skinParam.getFont(FontParam.NOTE, null, false); - final TextBlock textBlock = new BodyEnhanced2(display, FontParam.NOTE, skinParam, HorizontalAlignment.LEFT, - new FontConfiguration(skinParam, FontParam.NOTE, null), LineBreakStrategy.NONE, - skinParam.minClassWidth()); + final FontConfiguration fc = new FontConfiguration(skinParam, FontParam.NOTE, null); + final TextBlock textBlock = BodyFactory.create3(display, FontParam.NOTE, skinParam, HorizontalAlignment.LEFT, + fc, LineBreakStrategy.NONE); final double shadowing = skinParam.shadowing(getEntity().getStereotype()) ? 4 : 0; final Opale opale = new Opale(shadowing, borderColor, noteBackgroundColor, textBlock, true); return opale; diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageUseCase.java b/src/net/sourceforge/plantuml/svek/image/EntityImageUseCase.java index f26c937f8..8c8f5f7cd 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageUseCase.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageUseCase.java @@ -47,7 +47,7 @@ import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UseStyle; import net.sourceforge.plantuml.creole.Stencil; -import net.sourceforge.plantuml.cucadiagram.BodyEnhanced; +import net.sourceforge.plantuml.cucadiagram.BodyFactory; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.EntityPortion; import net.sourceforge.plantuml.cucadiagram.ILeaf; @@ -87,8 +87,8 @@ public class EntityImageUseCase extends AbstractEntityImage { super(entity, skinParam); final Stereotype stereotype = entity.getStereotype(); - final TextBlock tmp = new BodyEnhanced(entity.getDisplay(), FontParam.USECASE, skinParam, - HorizontalAlignment.CENTER, stereotype, true, false, entity, getStyle()); + final TextBlock tmp = BodyFactory.create2(entity.getDisplay(), FontParam.USECASE, skinParam, + HorizontalAlignment.CENTER, stereotype, entity, getStyle()); if (stereotype == null || stereotype.getLabel(Guillemet.DOUBLE_COMPARATOR) == null || portionShower.showPortion(EntityPortion.STEREOTYPE, entity) == false) { diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index 4447dd06d..84f14b6ed 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -44,7 +44,7 @@ public class Version { private static final int MAJOR_SEPARATOR = 1000000; public static int version() { - return 1202022; + return 1202023; } public static int versionPatched() { @@ -93,7 +93,7 @@ public class Version { } public static long compileTime() { - return 1607247387732L; + return 1607886898413L; } public static String compileTimeString() { diff --git a/src/net/sourceforge/plantuml/xmi/XmiClassDiagramAbstract.java b/src/net/sourceforge/plantuml/xmi/XmiClassDiagramAbstract.java index 52bd44411..159ff1b9b 100644 --- a/src/net/sourceforge/plantuml/xmi/XmiClassDiagramAbstract.java +++ b/src/net/sourceforge/plantuml/xmi/XmiClassDiagramAbstract.java @@ -180,7 +180,8 @@ abstract class XmiClassDiagramAbstract implements IXmiClassDiagram { final Element feature = document.createElement("UML:Classifier.feature"); cla.appendChild(feature); - for (Member m : entity.getBodier().getFieldsToDisplay()) { + for (CharSequence cs : entity.getBodier().getFieldsToDisplay()) { + final Member m = (Member) cs; // - final Element attribute = document.createElement("UML:Attribute"); - attribute.setAttribute("xmi.id", "att" + UniqueSequence.getValue()); - attribute.setAttribute("name", m.getDisplay(false)); - feature.appendChild(attribute); - } - - for (Member m : entity.getBodier().getMethodsToDisplay()) { - // - final Element operation = document.createElement("UML:Operation"); - operation.setAttribute("xmi.id", "att" + UniqueSequence.getValue()); - operation.setAttribute("name", m.getDisplay(false)); - feature.appendChild(operation); - } +// for (Member m : entity.getBodier().getFieldsToDisplay()) { +// // +// final Element attribute = document.createElement("UML:Attribute"); +// attribute.setAttribute("xmi.id", "att" + UniqueSequence.getValue()); +// attribute.setAttribute("name", m.getDisplay(false)); +// feature.appendChild(attribute); +// } +// +// for (Member m : entity.getBodier().getMethodsToDisplay()) { +// // +// final Element operation = document.createElement("UML:Operation"); +// operation.setAttribute("xmi.id", "att" + UniqueSequence.getValue()); +// operation.setAttribute("name", m.getDisplay(false)); +// feature.appendChild(operation); +// } return cla; }