From eac7a29c67d8810ffa2323ce66d5e00271e4586d Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Fri, 13 Jan 2023 18:36:46 +0100 Subject: [PATCH] wip --- .../command/CommandActivity3.java | 26 +++++-- .../command/CommandActivityLong3.java | 20 ++++-- .../command/CommandBackward3.java | 16 +++-- .../command/CommandBackwardLong3.java | 37 +++++----- .../command/CommandRepeat3.java | 12 ++-- .../CommandRepeatWhile3Multilines.java | 6 +- .../activitydiagram3/ftile/BoxStyle.java | 36 ++++++---- .../plantuml/baraye/CucaDiagram.java | 42 +++++------ .../plantuml/baraye/EntityFactory.java | 8 ++- .../plantuml/baraye/EntityImp.java | 2 +- .../sourceforge/plantuml/baraye/ILeaf.java | 2 +- .../plantuml/classdiagram/ClassDiagram.java | 55 +++++++-------- .../plantuml/command/CommandMultilines3.java | 19 +++-- .../sourceforge/plantuml/command/Trim.java | 4 +- .../plantuml/cucadiagram/GroupType.java | 2 +- .../descdiagram/command/CommandTogether.java | 19 +---- .../plantuml/graphic/USymbolTogether.java | 70 ------------------- .../plantuml/graphic/USymbols.java | 7 +- .../sourceforge/plantuml/json/JsonParser.java | 25 +++++-- .../AbstractClassOrObjectDiagram.java | 63 ++++++++--------- .../statediagram/StateDiagramFactory.java | 7 ++ .../sourceforge/plantuml/svek/Cluster.java | 47 ++++++++++--- .../plantuml/svek/GeneralImageBuilder.java | 3 +- .../sourceforge/plantuml/svek/SvekNode.java | 13 +++- .../sourceforge/plantuml/version/Version.java | 2 +- 25 files changed, 272 insertions(+), 271 deletions(-) delete mode 100644 src/net/sourceforge/plantuml/graphic/USymbolTogether.java diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java index 42328eb3b..ae1f421ed 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java @@ -61,11 +61,11 @@ public class CommandActivity3 extends SingleLineCommand2 { public static final String endingGroup() { return "(" // - + ";" // + + ";(?:[%s]*\\<\\<\\w+\\>\\>)?" // + "|" // + Matcher.quoteReplacement("\\\\") // that is simply \ character + "|" // - + "(?}\\]])[/<}]" // About /<} + + "(? { + ")"; } + private static final String endingGroupShort() { + return "(" // + + ";(?:[%s]*\\<\\<\\w+\\>\\>)?" // + + "|" // + + Matcher.quoteReplacement("\\\\") // that is simply \ character + + "|" // + + "(?]{1,999})(?)\\>" // About > + + "|" // + + "\\|" // About | + + ")"; + } + public static void main(String[] args) { System.err.println(Matcher.quoteReplacement("\\\\")); System.err.println(Matcher.quoteReplacement("\\\\").equals("\\\\\\\\")); @@ -92,8 +108,8 @@ public class CommandActivity3 extends SingleLineCommand2 { new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf(":"), // - new RegexLeaf("LABEL", "(.*)"), // - new RegexLeaf("STYLE", endingGroup()), // + new RegexLeaf("LABEL", "(.*?)"), // + new RegexLeaf("STYLE", endingGroupShort()), // RegexLeaf.end()); } @@ -120,7 +136,7 @@ public class CommandActivity3 extends SingleLineCommand2 { stereotype = Stereotype.build(stereo); colors = colors.applyStereotype(stereotype, diagram.getSkinParam(), ColorParam.activityBackground); } - final BoxStyle style = BoxStyle.fromChar(arg.get("STYLE", 0).charAt(0)); + final BoxStyle style = BoxStyle.fromString(arg.get("STYLE", 0)); final Display display = Display.getWithNewlines2(arg.get("LABEL", 0)); return diagram.addActivity(display, style, url, colors, stereotype); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLong3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLong3.java index 050886d5e..bae1a6d4c 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLong3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLong3.java @@ -38,7 +38,7 @@ package net.sourceforge.plantuml.activitydiagram3.command; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle; import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.CommandMultilines2; +import net.sourceforge.plantuml.command.CommandMultilines3; import net.sourceforge.plantuml.command.MultilinesStrategy; import net.sourceforge.plantuml.command.Trim; import net.sourceforge.plantuml.command.regex.IRegex; @@ -51,15 +51,18 @@ import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; import net.sourceforge.plantuml.utils.BlocLines; -public class CommandActivityLong3 extends CommandMultilines2 { +public class CommandActivityLong3 extends CommandMultilines3 { public CommandActivityLong3() { - super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE, Trim.LEFT_ONLY); + super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE, Trim.NONE); } @Override - public String getPatternEnd() { - return "^(.*)" + CommandActivity3.endingGroup() + "$"; + public RegexConcat getPatternEnd2() { + return new RegexConcat(// + new RegexLeaf("TEXT", "(.*)"), // + new RegexLeaf("END", CommandActivity3.endingGroup()), // + RegexLeaf.end()); } private static ColorParser color() { @@ -80,8 +83,11 @@ public class CommandActivityLong3 extends CommandMultilines2 { final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); final Colors colors = color().getColor(line0, diagram.getSkinParam().getIHtmlColorSet()); - final BoxStyle style = BoxStyle.fromChar(lines.getLastChar()); - lines = lines.removeStartingAndEnding(line0.get("DATA", 0), 1); + final RegexResult lineLast = getPatternEnd2().matcher(lines.getLast().getString()); + final String end = lineLast.get("END", 0); + + final BoxStyle style = BoxStyle.fromString(end); + lines = lines.removeStartingAndEnding(line0.get("DATA", 0), end.length()); return diagram.addActivity(lines.toDisplay(), style, null, colors, null); } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandBackward3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandBackward3.java index 1ed396009..87993196b 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandBackward3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandBackward3.java @@ -86,15 +86,15 @@ public class CommandBackward3 extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { + protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) + throws NoSuchColorException { final BoxStyle boxStyle; final String styleString = arg.get("STYLE", 0); - if (styleString == null) { + if (styleString == null) boxStyle = BoxStyle.PLAIN; - } else { - boxStyle = BoxStyle.fromChar(styleString.charAt(0)); - } + else + boxStyle = BoxStyle.fromString(styleString); final Display label = Display.getWithNewlines(arg.get("LABEL", 0)); @@ -104,7 +104,8 @@ public class CommandBackward3 extends SingleLineCommand2 { return diagram.backward(label, boxStyle, in, out); } - static public LinkRendering getBackRendering(ActivityDiagram3 diagram, RegexResult arg, String name) throws NoSuchColorException { + static public LinkRendering getBackRendering(ActivityDiagram3 diagram, RegexResult arg, String name) + throws NoSuchColorException { final LinkRendering in; final Rainbow incomingColor = getRainbow(name + "_COLOR", diagram, arg); if (incomingColor == null) @@ -115,7 +116,8 @@ public class CommandBackward3 extends SingleLineCommand2 { return in.withDisplay(Display.getWithNewlines(label)); } - static private Rainbow getRainbow(String key, ActivityDiagram3 diagram, RegexResult arg) throws NoSuchColorException { + static private Rainbow getRainbow(String key, ActivityDiagram3 diagram, RegexResult arg) + throws NoSuchColorException { final String colorString = arg.get(key, 0); if (colorString == null) { return null; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandBackwardLong3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandBackwardLong3.java index d1309df82..e7cf488b2 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandBackwardLong3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandBackwardLong3.java @@ -39,32 +39,35 @@ import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.activitydiagram3.LinkRendering; import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle; import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.CommandMultilines2; +import net.sourceforge.plantuml.command.CommandMultilines3; import net.sourceforge.plantuml.command.MultilinesStrategy; import net.sourceforge.plantuml.command.Trim; import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; -import net.sourceforge.plantuml.graphic.color.ColorParser; -import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; import net.sourceforge.plantuml.utils.BlocLines; -public class CommandBackwardLong3 extends CommandMultilines2 { +public class CommandBackwardLong3 extends CommandMultilines3 { public CommandBackwardLong3() { super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE, Trim.BOTH); } @Override - public String getPatternEnd() { - return "^(.*)" + CommandActivity3.endingGroup() + "$"; + public RegexConcat getPatternEnd2() { + return new RegexConcat(// + new RegexLeaf("TEXT", "(.*)"), // + new RegexLeaf("END", CommandActivity3.endingGroup()), // + RegexLeaf.end()); } - private static ColorParser color() { - return ColorParser.simpleColor(ColorType.BACK); - } +// +// @Override +// public String getPatternEnd() { +// return "^(.*)" + CommandActivity3.endingGroup() + "$"; +// } static IRegex getRegexConcat() { return RegexConcat.build(CommandBackwardLong3.class.getName(), RegexLeaf.start(), // @@ -81,19 +84,15 @@ public class CommandBackwardLong3 extends CommandMultilines2 { protected CommandExecutionResult executeNow(ActivityDiagram3 diagram, BlocLines lines) throws NoSuchColorException { lines = lines.removeEmptyColumns(); final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); -// final Colors colors = color().getColor(diagram.getSkinParam().getThemeStyle(), line0, -// diagram.getSkinParam().getIHtmlColorSet()); -// - final BoxStyle style = BoxStyle.fromChar(lines.getLastChar()); - lines = lines.removeStartingAndEnding(line0.get("DATA", 0), 1); - + final RegexResult lineLast = getPatternEnd2().matcher(lines.getLast().getString()); + final String end = lineLast.get("END", 0); + + final BoxStyle style = BoxStyle.fromString(end); + lines = lines.removeStartingAndEnding(line0.get("DATA", 0), end.length()); + final LinkRendering in = LinkRendering.none(); final LinkRendering out = LinkRendering.none(); -// return diagram.addActivity(lines.toDisplay(), style, null, colors, null); - return diagram.backward(lines.toDisplay(), style, in, out); - -// return CommandExecutionResult.ok(); } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeat3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeat3.java index 682a9c7ff..33832bb3f 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeat3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeat3.java @@ -80,16 +80,16 @@ public class CommandRepeat3 extends SingleLineCommand2 { protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final String s = arg.get("COLOR", 0); - final HColor color = s == null ? null - : diagram.getSkinParam().getIHtmlColorSet().getColor(s); + final HColor color = s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s); final Display label = Display.getWithNewlines(arg.get("LABEL", 0)); final BoxStyle boxStyle; final String styleString = arg.get("STYLE", 0); - if (styleString == null) { + + if (styleString == null) boxStyle = BoxStyle.PLAIN; - } else { - boxStyle = BoxStyle.fromChar(styleString.charAt(0)); - } + else + boxStyle = BoxStyle.fromString(styleString); + Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet()); final String stereo = arg.get("STEREO", 0); if (stereo != null) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeatWhile3Multilines.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeatWhile3Multilines.java index 945b25301..173c2ac55 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeatWhile3Multilines.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeatWhile3Multilines.java @@ -42,6 +42,7 @@ import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandMultilines3; import net.sourceforge.plantuml.command.MultilinesStrategy; +import net.sourceforge.plantuml.command.Trim; import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.MyPattern; import net.sourceforge.plantuml.command.regex.RegexConcat; @@ -55,7 +56,7 @@ import net.sourceforge.plantuml.utils.StringLocated; public class CommandRepeatWhile3Multilines extends CommandMultilines3 { public CommandRepeatWhile3Multilines() { - super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE); + super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE, Trim.BOTH); } @Override @@ -106,8 +107,7 @@ public class CommandRepeatWhile3Multilines extends CommandMultilines3 splitted = testDisplay - .splitMultiline(MyPattern.cmpile("\\)[%s]*(is|equals?)[%s]*\\(")); + final List splitted = testDisplay.splitMultiline(MyPattern.cmpile("\\)[%s]*(is|equals?)[%s]*\\(")); if (splitted.size() == 2) { testDisplay = splitted.get(0); yes = splitted.get(1); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/BoxStyle.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/BoxStyle.java index c60b46d03..30c5e1e47 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/BoxStyle.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/BoxStyle.java @@ -47,13 +47,13 @@ import net.sourceforge.plantuml.ugraphic.UTranslate; // Created from Luc Trudeau original work public enum BoxStyle { - PLAIN('\0', 0) { + PLAIN(null, '\0', 0) { @Override protected Shadowable getShape(double width, double height, double roundCorner) { return new URectangle(width, height).rounded(roundCorner); } }, - SDL_INPUT('<', 10) { + SDL_INPUT("input", '<', 10) { @Override protected Shadowable getShape(double width, double height, double roundCorner) { final UPolygon result = new UPolygon(); @@ -65,7 +65,7 @@ public enum BoxStyle { return result; } }, - SDL_OUTPUT('>', 10) { + SDL_OUTPUT("output", '>', 10) { @Override protected Shadowable getShape(double width, double height, double roundCorner) { final UPolygon result = new UPolygon(); @@ -77,7 +77,7 @@ public enum BoxStyle { return result; } }, - SDL_PROCEDURE('|', 0) { + SDL_PROCEDURE("procedure", '|', 0) { @Override protected void drawInternal(UGraphic ug, double width, double height, double shadowing, double roundCorner) { final URectangle rect = new URectangle(width, height); @@ -88,7 +88,7 @@ public enum BoxStyle { ug.apply(UTranslate.dx(width - PADDING)).draw(vline); } }, - SDL_SAVE('\\', 0) { + SDL_SAVE("save", '\\', 0) { @Override protected Shadowable getShape(double width, double height, double roundCorner) { final UPolygon result = new UPolygon(); @@ -99,7 +99,7 @@ public enum BoxStyle { return result; } }, - SDL_ANTISAVE('/', 0) { + SDL_ANTISAVE("load", '/', 0) { @Override protected Shadowable getShape(double width, double height, double roundCorner) { final UPolygon result = new UPolygon(); @@ -110,7 +110,7 @@ public enum BoxStyle { return result; } }, - SDL_CONTINUOUS('}', 0) { + SDL_CONTINUOUS("continuous", '}', 0) { @Override protected Shadowable getShape(double width, double height, double roundCorner) { final UPath result = new UPath(); @@ -132,13 +132,14 @@ public enum BoxStyle { return result; } }, - SDL_TASK(']', 0) { + SDL_TASK("task", ']', 0) { @Override protected Shadowable getShape(double width, double height, double roundCorner) { return new URectangle(width, height); } }; + private final String stereotype; private final char style; private final double shield; @@ -146,17 +147,24 @@ public enum BoxStyle { private static double DELTA_CONTINUOUS = 5.0; private static int PADDING = 5; - private BoxStyle(char style, double shield) { + private BoxStyle(String stereotype, char style, double shield) { + this.stereotype = stereotype; this.style = style; this.shield = shield; } - public static BoxStyle fromChar(char style) { - for (BoxStyle bs : BoxStyle.values()) { - if (bs.style == style) { + public static BoxStyle fromString(String style) { + if (style.length() == 1) + for (BoxStyle bs : BoxStyle.values()) + if (bs.style == style.charAt(0)) + return bs; + + style = style.replaceAll("\\W", ""); + + for (BoxStyle bs : BoxStyle.values()) + if (style.equalsIgnoreCase(bs.stereotype)) return bs; - } - } + return PLAIN; } diff --git a/src/net/sourceforge/plantuml/baraye/CucaDiagram.java b/src/net/sourceforge/plantuml/baraye/CucaDiagram.java index 0590a3d0b..382e7cae7 100644 --- a/src/net/sourceforge/plantuml/baraye/CucaDiagram.java +++ b/src/net/sourceforge/plantuml/baraye/CucaDiagram.java @@ -116,6 +116,9 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, private boolean visibilityModifierPresent; + private NamespaceStrategy lastNamespaceStrategy; + private Together currentTogether; + public abstract IEntity getOrCreateLeaf(Ident ident, Code code, LeafType type, USymbol symbol); public Ident cleanIdent(Ident ident) { @@ -206,8 +209,8 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, if (Display.isNull(display)) display = Display.getWithNewlines(code).withCreoleMode(CreoleMode.SIMPLE_LINE); - final ILeaf leaf = entityFactory.createLeaf(newIdent, code, display, type, getCurrentGroup(), getHides(), - getNamespaceSeparator()); + final ILeaf leaf = entityFactory.createLeaf(currentTogether, newIdent, code, display, type, getCurrentGroup(), + getHides(), getNamespaceSeparator()); entityFactory.addLeaf(leaf); this.lastEntity = leaf; leaf.setUSymbol(symbol); @@ -226,15 +229,6 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, return buildFullyQualified(id); } - private Ident buildLeafIdentSpecialUnused(String id) { -// if (namespaceSeparator != null) { -// if (id.contains(namespaceSeparator)) { - return Ident.empty().add(id, "."); -// } -// } -// return getLastID().add(id, namespaceSeparator); - } - final public Ident buildFullyQualified(String id) { return entityFactory.buildFullyQualified(getLastID(), Ident.empty().add(id, getNamespaceSeparator())); } @@ -260,22 +254,19 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, return Collections.unmodifiableCollection(result); } - private NamespaceStrategy lastNamespaceStrategy; - private Together currentTogether; - - final public CommandExecutionResult gotoTogether(Ident ident, Code code, IGroup parent) { - IGroup result = entityFactory.createGroup(ident, code, Display.NULL, null, GroupType.TOGETHER, parent, - getHides(), getNamespaceSeparator()); + final public CommandExecutionResult gotoTogether() { if (currentTogether != null) return CommandExecutionResult.error("Cannot nest together"); - entityFactory.addGroup(result); - currentGroup = result; + this.currentTogether = new Together(); return CommandExecutionResult.ok(); } final public CommandExecutionResult gotoGroup(Ident ident, Code code, Display display, GroupType type, IGroup parent, NamespaceStrategy strategy) { + if (currentTogether != null) + return CommandExecutionResult.error("Cannot be done inside 'together'"); + if (this.lastNamespaceStrategy != null && strategy != this.lastNamespaceStrategy) return CommandExecutionResult.error("Cannot mix packages and namespaces"); this.lastNamespaceStrategy = strategy; @@ -341,13 +332,14 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, if (this.currentTogether != null) { this.currentTogether = null; - } - - if (currentGroup.getGroupType() == GroupType.TOGETHER) { - currentGroup = currentGroup.getParentContainer(); return true; } +// if (currentGroup.getGroupType() == GroupType.TOGETHER) { +// currentGroup = currentGroup.getParentContainer(); +// return true; +// } + if (stacks2.size() > 0) { // Thread.dumpStack(); stacks2.remove(stacks2.size() - 1); @@ -599,8 +591,8 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, } public boolean isAutarkic(IGroup g) { - if (g.getGroupType() == GroupType.TOGETHER) - return false; +// if (g.getGroupType() == GroupType.TOGETHER) +// return false; if (g.getGroupType() == GroupType.PACKAGE) return false; diff --git a/src/net/sourceforge/plantuml/baraye/EntityFactory.java b/src/net/sourceforge/plantuml/baraye/EntityFactory.java index 5148f0627..7e8a774da 100644 --- a/src/net/sourceforge/plantuml/baraye/EntityFactory.java +++ b/src/net/sourceforge/plantuml/baraye/EntityFactory.java @@ -61,6 +61,7 @@ import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Stereotag; import net.sourceforge.plantuml.cucadiagram.Stereotype; +import net.sourceforge.plantuml.cucadiagram.Together; import net.sourceforge.plantuml.cucadiagram.entity.IEntityFactory; import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.skin.VisibilityModifier; @@ -89,7 +90,7 @@ public final class EntityFactory implements IEntityFactory { } public ILeaf createLeafForEmptyGroup(IGroup g, ISkinParam skinParam) { - final ILeaf folder = this.createLeaf(g.getIdent(), g.getCode(), g.getDisplay(), LeafType.EMPTY_PACKAGE, + final ILeaf folder = this.createLeaf(null, g.getIdent(), g.getCode(), g.getDisplay(), LeafType.EMPTY_PACKAGE, g.getParentContainer(), null, this.namespaceSeparator.getNamespaceSeparator()); ((EntityImp) folder).setOriginalGroup(g); final USymbol symbol = g.getUSymbol(); @@ -175,8 +176,8 @@ public final class EntityFactory implements IEntityFactory { return result; } - public ILeaf createLeaf(Ident ident, Code code, Display display, LeafType entityType, IGroup parentContainer, - Set hides, String namespaceSeparator) { + public ILeaf createLeaf(Together together, Ident ident, Code code, Display display, LeafType entityType, + IGroup parentContainer, Set hides, String namespaceSeparator) { final Bodier bodier; if (Objects.requireNonNull(entityType) == LeafType.MAP) bodier = new BodierMap(); @@ -189,6 +190,7 @@ public final class EntityFactory implements IEntityFactory { namespaceSeparator, rawLayout); bodier.setLeaf(result); result.setDisplay(display); + result.setTogether(together); return result; } diff --git a/src/net/sourceforge/plantuml/baraye/EntityImp.java b/src/net/sourceforge/plantuml/baraye/EntityImp.java index 7caab7982..cbe47fca5 100644 --- a/src/net/sourceforge/plantuml/baraye/EntityImp.java +++ b/src/net/sourceforge/plantuml/baraye/EntityImp.java @@ -841,7 +841,7 @@ final public class EntityImp implements ILeaf, IGroup { } @Override - public void getTogether(Together together) { + public void setTogether(Together together) { this.together = together; } diff --git a/src/net/sourceforge/plantuml/baraye/ILeaf.java b/src/net/sourceforge/plantuml/baraye/ILeaf.java index c2b1d361d..20cd97db8 100644 --- a/src/net/sourceforge/plantuml/baraye/ILeaf.java +++ b/src/net/sourceforge/plantuml/baraye/ILeaf.java @@ -83,6 +83,6 @@ public interface ILeaf extends IEntity { public Together getTogether(); - public void getTogether(Together together); + public void setTogether(Together together); } diff --git a/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java b/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java index 974d88367..59a992d9d 100644 --- a/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java +++ b/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java @@ -69,9 +69,9 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram { final String separator = Objects.requireNonNull(getNamespaceSeparator()); final String codeString = code.getName(); final String namespace = getNamespace1972(code, getNamespaceSeparator()); - if (namespace == null) { + if (namespace == null) return buildCode(codeString); - } + return buildCode(codeString.substring(namespace.length() + separator.length())); } @@ -80,23 +80,23 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram { Objects.requireNonNull(ident); if (type == null) { code = code.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:"); - if (getNamespaceSeparator() == null) { + if (getNamespaceSeparator() == null) return getOrCreateLeafDefault(ident, code, LeafType.CLASS, symbol); - } + code = getFullyQualifiedCode1972(code); - if (super.leafExist(code)) { + if (super.leafExist(code)) return getOrCreateLeafDefault(ident, code, LeafType.CLASS, symbol); - } + return createEntityWithNamespace1972(ident, code, Display.getWithNewlines(ident.getLast()), LeafType.CLASS, symbol); } - if (getNamespaceSeparator() == null) { + if (getNamespaceSeparator() == null) return getOrCreateLeafDefault(ident, code, type, symbol); - } + code = getFullyQualifiedCode1972(code); - if (super.leafExist(code)) { + if (super.leafExist(code)) return getOrCreateLeafDefault(ident, code, type, symbol); - } + return createEntityWithNamespace1972(ident, code, Display.getWithNewlines(ident.getLast()), type, symbol); } @@ -105,9 +105,9 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram { Objects.requireNonNull(idNewLong); if (type != LeafType.ABSTRACT_CLASS && type != LeafType.ANNOTATION && type != LeafType.CLASS && type != LeafType.INTERFACE && type != LeafType.ENUM && type != LeafType.LOLLIPOP_FULL - && type != LeafType.LOLLIPOP_HALF && type != LeafType.NOTE) { + && type != LeafType.LOLLIPOP_HALF && type != LeafType.NOTE) return super.createLeaf(idNewLong, code, display, type, symbol); - } + if (getNamespaceSeparator() == null) return super.createLeaf(idNewLong, code, display, type, symbol); @@ -133,11 +133,11 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram { gotoGroupExternal(newIdLong, namespace, tmp, namespace, GroupType.PACKAGE, getRootGroup()); } final Display tmpDisplay; - if (Display.isNull(display)) { + if (Display.isNull(display)) tmpDisplay = Display.getWithNewlines(getShortName1972(fullyCode)).withCreoleMode(CreoleMode.SIMPLE_LINE); - } else { + else tmpDisplay = display; - } + final ILeaf result = createLeafInternal(id, fullyCode, tmpDisplay, type, symbol); gotoThisGroup(backupCurrentGroup); return result; @@ -145,9 +145,9 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram { @Override public final boolean leafExist(Code code) { - if (getNamespaceSeparator() == null) { + if (getNamespaceSeparator() == null) return super.leafExist(code); - } + return super.leafExist(getFullyQualifiedCode1972(code)); } @@ -171,9 +171,9 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram { @Override final protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) throws IOException { - if (useLayoutExplicit != 0) { + if (useLayoutExplicit != 0) return exportLayoutExplicit(os, index, fileFormatOption); - } + return super.exportDiagramInternal(os, index, fileFormatOption); } @@ -191,11 +191,10 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram { private RowLayout getRawLayout(int raw) { final RowLayout rawLayout = new RowLayout(); - for (ILeaf leaf : entityFactory.leafs()) { - if (leaf.getRawLayout() == raw) { + for (ILeaf leaf : entityFactory.leafs()) + if (leaf.getRawLayout() == raw) rawLayout.addLeaf(getEntityImageClass(leaf)); - } - } + return rawLayout; } @@ -207,13 +206,11 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram { public String checkFinalError() { for (Link link : this.getLinks()) { final int len = link.getLength(); - if (len == 1) { - for (Link link2 : this.getLinks()) { - if (link2.sameConnections(link) && link2.getLength() != 1) { + if (len == 1) + for (Link link2 : this.getLinks()) + if (link2.sameConnections(link) && link2.getLength() != 1) link2.setLength(1); - } - } - } + } this.applySingleStrategy(); return super.checkFinalError(); diff --git a/src/net/sourceforge/plantuml/command/CommandMultilines3.java b/src/net/sourceforge/plantuml/command/CommandMultilines3.java index 2387a6e6b..8d7392e33 100644 --- a/src/net/sourceforge/plantuml/command/CommandMultilines3.java +++ b/src/net/sourceforge/plantuml/command/CommandMultilines3.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.command; import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.core.Diagram; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; import net.sourceforge.plantuml.utils.BlocLines; import net.sourceforge.plantuml.utils.StringLocated; @@ -47,12 +48,15 @@ public abstract class CommandMultilines3 implements Command implements Command implements Command { @Override protected CommandExecutionResult executeArg(AbstractEntityDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { - final String idShort = diagram.getUniqueSequence("##"); - final Ident ident = diagram.buildLeafIdent(idShort); - final Code code = diagram.buildCode(idShort); - - final IGroup currentPackage = diagram.getCurrentGroup(); - final CommandExecutionResult status = diagram.gotoTogether(ident, code, currentPackage); - if (status.isOk() == false) - return status; - final IEntity p = diagram.getCurrentGroup(); - p.setUSymbol(USymbols.TOGETHER); - - return CommandExecutionResult.ok(); + final CommandExecutionResult status = diagram.gotoTogether(); + return status; } } diff --git a/src/net/sourceforge/plantuml/graphic/USymbolTogether.java b/src/net/sourceforge/plantuml/graphic/USymbolTogether.java deleted file mode 100644 index dd92c109b..000000000 --- a/src/net/sourceforge/plantuml/graphic/USymbolTogether.java +++ /dev/null @@ -1,70 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2023, 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.graphic; - -import net.sourceforge.plantuml.awt.geom.XDimension2D; -import net.sourceforge.plantuml.style.SName; -import net.sourceforge.plantuml.ugraphic.UGraphic; - -class USymbolTogether extends USymbol { - - @Override - public SName getSName() { - return SName.storage; - } - - @Override - public TextBlock asSmall(TextBlock name, final TextBlock label, final TextBlock stereotype, - final SymbolContext symbolContext, final HorizontalAlignment stereoAlignment) { - return TextBlockUtils.empty(10, 10); - } - - @Override - public TextBlock asBig(final TextBlock title, HorizontalAlignment labelAlignment, final TextBlock stereotype, - final double width, final double height, final SymbolContext symbolContext, - final HorizontalAlignment stereoAlignment) { - return new AbstractTextBlock() { - - public void drawU(UGraphic ug) { - } - - public XDimension2D calculateDimension(StringBounder stringBounder) { - return new XDimension2D(width, height); - } - }; - } - -} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/graphic/USymbols.java b/src/net/sourceforge/plantuml/graphic/USymbols.java index d314e24bf..36e5e7e65 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbols.java +++ b/src/net/sourceforge/plantuml/graphic/USymbols.java @@ -77,20 +77,21 @@ public abstract class USymbols { public final static USymbol COLLECTIONS = record("COLLECTIONS", new USymbolCollections()); public final static USymbol AGENT = record("AGENT", new USymbolRectangle(SName.agent)); public final static USymbol ACTOR_STICKMAN = record("ACTOR_STICKMAN", new USymbolActor(ActorStyle.STICKMAN)); - public final static USymbol ACTOR_STICKMAN_BUSINESS = record("ACTOR_STICKMAN_BUSINESS", new USymbolActor(ActorStyle.STICKMAN_BUSINESS)); + public final static USymbol ACTOR_STICKMAN_BUSINESS = record("ACTOR_STICKMAN_BUSINESS", + new USymbolActor(ActorStyle.STICKMAN_BUSINESS)); public final static USymbol ACTOR_AWESOME = record("ACTOR_AWESOME", new USymbolActor(ActorStyle.AWESOME)); public final static USymbol ACTOR_HOLLOW = record("ACTOR_HOLLOW", new USymbolActor(ActorStyle.HOLLOW)); public final static USymbol USECASE = null; public final static USymbol COMPONENT1 = record("COMPONENT1", new USymbolComponent1()); public final static USymbol COMPONENT2 = record("COMPONENT2", new USymbolComponent2()); - public final static USymbol COMPONENT_RECTANGLE = record("COMPONENT_RECTANGLE", new USymbolRectangle(SName.component)); + public final static USymbol COMPONENT_RECTANGLE = record("COMPONENT_RECTANGLE", + new USymbolRectangle(SName.component)); public final static USymbol BOUNDARY = record("BOUNDARY", new USymbolBoundary()); public final static USymbol ENTITY_DOMAIN = record("ENTITY_DOMAIN", new USymbolEntityDomain()); public final static USymbol CONTROL = record("CONTROL", new USymbolControl()); public final static USymbol INTERFACE = record("INTERFACE", new USymbolInterface()); public final static USymbol QUEUE = record("QUEUE", new USymbolQueue()); public final static USymbol STACK = record("STACK", new USymbolStack()); - public final static USymbol TOGETHER = record("TOGETHER", new USymbolTogether()); public static USymbol fromString(String s, ActorStyle actorStyle, ComponentStyle componentStyle, PackageStyle packageStyle) { diff --git a/src/net/sourceforge/plantuml/json/JsonParser.java b/src/net/sourceforge/plantuml/json/JsonParser.java index 1ac6ab71e..f43936576 100644 --- a/src/net/sourceforge/plantuml/json/JsonParser.java +++ b/src/net/sourceforge/plantuml/json/JsonParser.java @@ -34,6 +34,8 @@ import java.io.StringReader; */ public class JsonParser { + private static final char END_OF_TEXT = '\u0003'; + private static final int MAX_NESTING_LEVEL = 1000; private static final int MIN_BUFFER_SIZE = 10; private static final int DEFAULT_BUFFER_SIZE = 1024; @@ -46,7 +48,7 @@ public class JsonParser { private int fill; private int line; private int lineOffset; - private int current; + private char current; private StringBuilder captureBuffer; private int captureStart; private int nestingLevel; @@ -237,6 +239,9 @@ public class JsonParser { } do { skipWhiteSpace(); + if (readChar('/')) { + skipComment(); + } handler.startObjectName(object); String name = readName(); handler.endObjectName(object, name); @@ -249,6 +254,9 @@ public class JsonParser { readValue(); handler.endObjectValue(object, name); skipWhiteSpace(); + if (readChar('/')) { + skipComment(); + } } while (readChar(',')); if (!readChar('}')) { throw expected("',' or '}'"); @@ -257,6 +265,15 @@ public class JsonParser { handler.endObject(object); } + private void skipComment() throws IOException { + if (!readChar('/')) + throw expected("Error in comment"); + while (current != '\n' && current != '\r') { + read(); + } + skipWhiteSpace(); + } + private String readName() throws IOException { if (current != '"') { throw expected("name"); @@ -438,7 +455,7 @@ public class JsonParser { fill = reader.read(buffer, 0, buffer.length); index = 0; if (fill == -1) { - current = -1; + current = END_OF_TEXT; index++; return; } @@ -458,7 +475,7 @@ public class JsonParser { } private void pauseCapture() { - int end = current == -1 ? index : index - 1; + int end = current == END_OF_TEXT ? index : index - 1; captureBuffer.append(buffer, captureStart, end - captureStart); captureStart = -1; } @@ -508,7 +525,7 @@ public class JsonParser { } private boolean isEndOfText() { - return current == -1; + return current == END_OF_TEXT; } } diff --git a/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java b/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java index b189bbc14..8ca3c2575 100644 --- a/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java +++ b/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java @@ -66,17 +66,17 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram @Override public Ident cleanIdent(Ident ident) { String codeString = ident.getName(); - if (codeString.startsWith("\"") && codeString.endsWith("\"")) { + if (codeString.startsWith("\"") && codeString.endsWith("\"")) return ident.eventuallyRemoveStartingAndEndingDoubleQuote("\""); - } + return ident; } final public boolean insertBetween(IEntity entity1, IEntity entity2, IEntity node) { final Link link = foundLink(entity1, entity2); - if (link == null) { + if (link == null) return false; - } + final Link l1 = new Link(getIEntityFactory(), getSkinParam().getCurrentStyleBuilder(), entity1, node, link.getType(), LinkArg.build(link.getLabel(), link.getLength(), getSkinParam().classAttributeIconSize() > 0) @@ -97,23 +97,22 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram final List links = getLinks(); for (int i = links.size() - 1; i >= 0; i--) { final Link l = links.get(i); - if (l.isBetween(entity1, entity2)) { + if (l.isBetween(entity1, entity2)) return l; - } + } return null; } public int getNbOfHozizontalLollipop(IEntity entity) { - if (entity.getLeafType() == LeafType.LOLLIPOP_FULL || entity.getLeafType() == LeafType.LOLLIPOP_HALF) { + if (entity.getLeafType() == LeafType.LOLLIPOP_FULL || entity.getLeafType() == LeafType.LOLLIPOP_HALF) throw new IllegalArgumentException(); - } + int result = 0; for (Link link : getLinks()) { if (link.getLength() == 1 && link.contains(entity) - && (link.containsType(LeafType.LOLLIPOP_FULL) || link.containsType(LeafType.LOLLIPOP_HALF))) { + && (link.containsType(LeafType.LOLLIPOP_FULL) || link.containsType(LeafType.LOLLIPOP_HALF))) result++; - } } return result; @@ -162,12 +161,11 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram private void insertPointBetween(final IEntity entity1A, final IEntity entity1B, final IEntity point1) { Link existingLink1 = foundLink(entity1A, entity1B); - if (existingLink1 == null) { + if (existingLink1 == null) existingLink1 = new Link(getIEntityFactory(), getSkinParam().getCurrentStyleBuilder(), entity1A, entity1B, new LinkType(LinkDecor.NONE, LinkDecor.NONE), LinkArg.noDisplay(2)); - } else { + else removeLink(existingLink1); - } final IEntity entity1real = existingLink1.isInverted() ? existingLink1.getEntity2() : existingLink1.getEntity1(); @@ -225,11 +223,10 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram private List getExistingAssociatedPoints(final IEntity entity1, final IEntity entity2) { final List same = new ArrayList<>(); - for (Association existing : associations) { - if (existing.sameCouple(entity1, entity2)) { + for (Association existing : associations) + if (existing.sameCouple(entity1, entity2)) same.add(existing); - } - } + return same; } @@ -273,12 +270,11 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram void createNew(int mode, LinkType linkType, Display label) { existingLink = foundLink(entity1, entity2); - if (existingLink == null) { + if (existingLink == null) existingLink = new Link(getIEntityFactory(), getSkinParam().getCurrentStyleBuilder(), entity1, entity2, new LinkType(LinkDecor.NONE, LinkDecor.NONE), LinkArg.noDisplay(2)); - } else { + else removeLink(existingLink); - } final IEntity entity1real = existingLink.isInverted() ? existingLink.getEntity2() : existingLink.getEntity1(); @@ -297,12 +293,12 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram .withDistanceAngle(existingLink.getLabeldistance(), existingLink.getLabelangle())); int length = 1; - if (existingLink.getLength() == 1 && entity1 != entity2) { + if (existingLink.getLength() == 1 && entity1 != entity2) length = 2; - } - if (existingLink.getLength() == 2 && entity1 == entity2) { + + if (existingLink.getLength() == 2 && entity1 == entity2) length = 2; - } + if (length == 1) { entity1ToPoint.addNoteFrom(existingLink, NoteLinkStrategy.NORMAL); } else { @@ -312,24 +308,23 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram addLink(entity1ToPoint); addLink(pointToEntity2); - if (mode == 1) { + if (mode == 1) pointToAssocied = new Link(getIEntityFactory(), getSkinParam().getCurrentStyleBuilder(), point, associed, linkType, LinkArg.build(label, length)); - } else { + else pointToAssocied = new Link(getIEntityFactory(), getSkinParam().getCurrentStyleBuilder(), associed, point, linkType, LinkArg.build(label, length)); - } + addLink(pointToAssocied); } void createInSecond(LinkType linkType, Display label) { existingLink = foundLink(entity1, entity2); - if (existingLink == null) { + if (existingLink == null) existingLink = new Link(getIEntityFactory(), getSkinParam().getCurrentStyleBuilder(), entity1, entity2, new LinkType(LinkDecor.NONE, LinkDecor.NONE), LinkArg.noDisplay(2)); - } else { + else removeLink(existingLink); - } entity1ToPoint = new Link(getIEntityFactory(), getSkinParam().getCurrentStyleBuilder(), entity1, point, existingLink.getType().getPart2(), @@ -362,12 +357,12 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram } boolean sameCouple(IEntity entity1, IEntity entity2) { - if (this.entity1 == entity1 && this.entity2 == entity2) { + if (this.entity1 == entity1 && this.entity2 == entity2) return true; - } - if (this.entity1 == entity2 && this.entity2 == entity1) { + + if (this.entity1 == entity2 && this.entity2 == entity1) return true; - } + return false; } } diff --git a/src/net/sourceforge/plantuml/statediagram/StateDiagramFactory.java b/src/net/sourceforge/plantuml/statediagram/StateDiagramFactory.java index 4dc0c7902..7fc99939c 100644 --- a/src/net/sourceforge/plantuml/statediagram/StateDiagramFactory.java +++ b/src/net/sourceforge/plantuml/statediagram/StateDiagramFactory.java @@ -53,6 +53,9 @@ import net.sourceforge.plantuml.command.note.CommandFactoryNoteOnLink; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.core.UmlSource; +import net.sourceforge.plantuml.objectdiagram.command.CommandCreateJson; +import net.sourceforge.plantuml.objectdiagram.command.CommandCreateJsonSingleLine; +import net.sourceforge.plantuml.objectdiagram.command.CommandCreateMap; import net.sourceforge.plantuml.statediagram.command.CommandAddField; import net.sourceforge.plantuml.statediagram.command.CommandConcurrentState; import net.sourceforge.plantuml.statediagram.command.CommandCreatePackage2; @@ -100,6 +103,10 @@ public class StateDiagramFactory extends PSystemCommandFactory { cmds.add(factoryNoteCommand.createSingleLine()); cmds.add(factoryNoteCommand.createMultiLine(false)); + cmds.add(new CommandCreateMap()); + cmds.add(new CommandCreateJson()); + cmds.add(new CommandCreateJsonSingleLine()); + CommonCommands.addCommonCommands1(cmds); cmds.add(new CommandHideShow2()); cmds.add(new CommandNamespaceSeparator()); diff --git a/src/net/sourceforge/plantuml/svek/Cluster.java b/src/net/sourceforge/plantuml/svek/Cluster.java index d76079ce6..028e8a053 100644 --- a/src/net/sourceforge/plantuml/svek/Cluster.java +++ b/src/net/sourceforge/plantuml/svek/Cluster.java @@ -43,6 +43,7 @@ import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Objects; @@ -63,6 +64,7 @@ import net.sourceforge.plantuml.cucadiagram.CucaNote; import net.sourceforge.plantuml.cucadiagram.EntityPosition; import net.sourceforge.plantuml.cucadiagram.ICucaDiagram; import net.sourceforge.plantuml.cucadiagram.Stereotype; +import net.sourceforge.plantuml.cucadiagram.Together; import net.sourceforge.plantuml.cucadiagram.dot.GraphvizVersion; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; @@ -192,37 +194,39 @@ public class Cluster implements Moveable { shs.put(node.getUid(), node); } - for (SvekLine l : lines) { + for (SvekLine l : lines) if (l.isInverted()) { final SvekNode sh = shs.get(l.getStartUidPrefix()); - if (sh != null && sh.getEntityPosition() == EntityPosition.NORMAL) + if (sh != null && isNormalPosition(sh)) firsts.add(0, sh); } - } return firsts; } + private boolean isNormalPosition(final SvekNode sh) { + return sh.getEntityPosition() == EntityPosition.NORMAL; + } + private List getNodesOrderedWithoutTop(Collection lines) { final List all = new ArrayList<>(nodes); final Map shs = new HashMap(); for (final Iterator it = all.iterator(); it.hasNext();) { final SvekNode sh = it.next(); - if (sh.getEntityPosition() != EntityPosition.NORMAL) { + if (isNormalPosition(sh) == false) { it.remove(); continue; } shs.put(sh.getUid(), sh); } - for (SvekLine l : lines) { + for (SvekLine l : lines) if (l.isInverted()) { final SvekNode sh = shs.get(l.getStartUidPrefix()); if (sh != null) all.remove(sh); } - } return all; } @@ -372,7 +376,7 @@ public class Cluster implements Moveable { final Collection insides = new ArrayList<>(); final List points = new ArrayList<>(); for (SvekNode sh : nodes) - if (sh.getEntityPosition() == EntityPosition.NORMAL) + if (isNormalPosition(sh)) insides.add(sh.getClusterPosition()); else points.add(sh.getClusterPosition().getPointCenter()); @@ -461,6 +465,7 @@ public class Cluster implements Moveable { return false; for (SvekNode node : tmp) node.appendShape(sb, stringBounder); + return true; } @@ -469,11 +474,31 @@ public class Cluster implements Moveable { DotMode dotMode, GraphvizVersion graphvizVersion, UmlDiagramType type) { SvekNode added = null; + final Map> togethers = new LinkedHashMap<>(); for (SvekNode node : getNodesOrderedWithoutTop(lines)) { - node.appendShape(sb, stringBounder); + final Together together = node.getTogether(); + if (together == null) { + node.appendShape(sb, stringBounder); + } else { + List list = togethers.get(together); + if (list == null) { + list = new ArrayList<>(); + togethers.put(together, list); + } + list.add(node); + } added = node; } + int t = 0; + for (List list : togethers.values()) { + sb.append("subgraph " + getClusterId() + "t" + t + " {\n"); + for (SvekNode node : list) + node.appendShape(sb, stringBounder); + sb.append("}\n"); + t++; + } + if (skinParam.useRankSame() && dotMode != DotMode.NO_LEFT_RIGHT_AND_XLABEL && graphvizVersion.ignoreHorizontalLinks() == false) appendRankSame(sb, lines); @@ -491,10 +516,10 @@ public class Cluster implements Moveable { if (tmp.size() == 0) { sb.append(getClusterId() + "empty [shape=point,label=\"\"];"); SvekUtils.println(sb); - } else - for (SvekNode node : tmp) { + } else { + for (SvekNode node : tmp) node.appendShape(sb, stringBounder); - } + } for (Cluster child : getChildren()) child.printInternal(sb, lines, stringBounder, dotMode, graphvizVersion, type); diff --git a/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java b/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java index 4f3e0279e..ef5aef824 100644 --- a/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java +++ b/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java @@ -591,8 +591,7 @@ public final class GeneralImageBuilder { if (g.isRemoved()) continue; - if (dotData.isEmpty(g) - && (g.getGroupType() == GroupType.PACKAGE || g.getGroupType() == GroupType.TOGETHER)) { + if (dotData.isEmpty(g) && g.getGroupType() == GroupType.PACKAGE) { final ISkinParam skinParam = dotData.getSkinParam(); final ILeaf folder = entityFactory.createLeafForEmptyGroup(g, skinParam); printEntity(dotStringFactory, folder); diff --git a/src/net/sourceforge/plantuml/svek/SvekNode.java b/src/net/sourceforge/plantuml/svek/SvekNode.java index a036da844..5a28bfa12 100644 --- a/src/net/sourceforge/plantuml/svek/SvekNode.java +++ b/src/net/sourceforge/plantuml/svek/SvekNode.java @@ -45,6 +45,7 @@ import net.sourceforge.plantuml.baraye.EntityImp; import net.sourceforge.plantuml.baraye.IGroup; import net.sourceforge.plantuml.baraye.ILeaf; import net.sourceforge.plantuml.cucadiagram.EntityPosition; +import net.sourceforge.plantuml.cucadiagram.Together; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.posimo.Positionable; import net.sourceforge.plantuml.svek.image.EntityImageDescription; @@ -92,7 +93,13 @@ public class SvekNode implements Positionable, Hideable { } private final ILeaf leaf; - private final IGroup group; + // private final IGroup group; + + public final Together getTogether() { + if (leaf == null) + return null; + return leaf.getTogether(); + } SvekNode(ILeaf ent, IEntityImage image, ColorSequence colorSequence, StringBounder stringBounder) { this.stringBounder = stringBounder; @@ -104,10 +111,10 @@ public class SvekNode implements Positionable, Hideable { this.uid = String.format("sh%04d", color); if (((EntityImp) ent).getOriginalGroup() == null) { - this.group = null; + // this.group = null; this.leaf = ent; } else { - this.group = ((EntityImp) ent).getOriginalGroup(); + // this.group = ((EntityImp) ent).getOriginalGroup(); this.leaf = null; } } diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index 5a1b0c65f..84d0133d6 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -81,7 +81,7 @@ public class Version { } public static int beta() { - final int beta = 2; + final int beta = 3; return beta; }