1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-06-04 09:30:48 +00:00
This commit is contained in:
Arnaud Roques 2023-01-13 18:36:46 +01:00
parent 97c7f1ed34
commit eac7a29c67
25 changed files with 272 additions and 271 deletions

View File

@ -61,11 +61,11 @@ public class CommandActivity3 extends SingleLineCommand2<ActivityDiagram3> {
public static final String endingGroup() {
return "(" //
+ ";" //
+ ";(?:[%s]*\\<\\<\\w+\\>\\>)?" //
+ "|" //
+ Matcher.quoteReplacement("\\\\") // that is simply \ character
+ "|" //
+ "(?<![/|<>}\\]])[/<}]" // About /<}
+ "(?<![/|<}\\]])[/<}]" // About /<}
+ "|" //
+ "(?<![/|}\\]])\\]" // About ]
+ "|" //
@ -75,6 +75,22 @@ public class CommandActivity3 extends SingleLineCommand2<ActivityDiagram3> {
+ ")";
}
private static final String endingGroupShort() {
return "(" //
+ ";(?:[%s]*\\<\\<\\w+\\>\\>)?" //
+ "|" //
+ Matcher.quoteReplacement("\\\\") // that is simply \ character
+ "|" //
+ "(?<![/|<}\\]])[/<}]" // About /<}
+ "|" //
+ "(?<![/|}\\]])\\]" // About ]
+ "|" //
+ "(?<!\\</?\\w{1,5})(?<!\\<img[^>]{1,999})(?<!\\<[&$]\\w{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<ActivityDiagram3> {
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<ActivityDiagram3> {
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);
}

View File

@ -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<ActivityDiagram3> {
public class CommandActivityLong3 extends CommandMultilines3<ActivityDiagram3> {
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<ActivityDiagram3> {
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);
}
}

View File

@ -86,15 +86,15 @@ public class CommandBackward3 extends SingleLineCommand2<ActivityDiagram3> {
}
@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<ActivityDiagram3> {
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<ActivityDiagram3> {
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;

View File

@ -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<ActivityDiagram3> {
public class CommandBackwardLong3 extends CommandMultilines3<ActivityDiagram3> {
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<ActivityDiagram3> {
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();
}
}

View File

@ -80,16 +80,16 @@ public class CommandRepeat3 extends SingleLineCommand2<ActivityDiagram3> {
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) {

View File

@ -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<ActivityDiagram3> {
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<ActivityDi
final Rainbow linkColor = Rainbow.none(); // diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR",
// 0));
final Display linkLabel = Display.NULL; // Display.getWithNewlines("arg.get(\"LABEL\", 0)");
final List<Display> splitted = testDisplay
.splitMultiline(MyPattern.cmpile("\\)[%s]*(is|equals?)[%s]*\\("));
final List<Display> splitted = testDisplay.splitMultiline(MyPattern.cmpile("\\)[%s]*(is|equals?)[%s]*\\("));
if (splitted.size() == 2) {
testDisplay = splitted.get(0);
yes = splitted.get(1);

View File

@ -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;
}

View File

@ -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;

View File

@ -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<VisibilityModifier> hides, String namespaceSeparator) {
public ILeaf createLeaf(Together together, Ident ident, Code code, Display display, LeafType entityType,
IGroup parentContainer, Set<VisibilityModifier> 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;
}

View File

@ -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;
}

View File

@ -83,6 +83,6 @@ public interface ILeaf extends IEntity {
public Together getTogether();
public void getTogether(Together together);
public void setTogether(Together together);
}

View File

@ -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();

View File

@ -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<S extends Diagram> implements Command<S
private final MultilinesStrategy strategy;
public CommandMultilines3(IRegex patternStart, MultilinesStrategy strategy) {
private final Trim trimEnd;
public CommandMultilines3(IRegex patternStart, MultilinesStrategy strategy, Trim trimEnd) {
if (patternStart.getPattern().startsWith("^") == false || patternStart.getPattern().endsWith("$") == false)
throw new IllegalArgumentException("Bad pattern " + patternStart.getPattern());
this.strategy = strategy;
this.starting = patternStart;
this.trimEnd = trimEnd;
}
public abstract RegexConcat getPatternEnd2();
@ -77,7 +81,14 @@ public abstract class CommandMultilines3<S extends Diagram> implements Command<S
if (lines.size() == 1)
return CommandControl.OK_PARTIAL;
final StringLocated potentialLast = lines.getLast().getTrimmed();
final StringLocated potentialLast;
if (trimEnd == Trim.NONE)
potentialLast = lines.getLast();
else if (trimEnd == Trim.BOTH)
potentialLast = lines.getLast().getTrimmed();
else
throw new IllegalStateException();
final boolean m1 = getPatternEnd2().match(potentialLast);
if (m1 == false)
return CommandControl.OK_PARTIAL;
@ -85,12 +96,12 @@ public abstract class CommandMultilines3<S extends Diagram> implements Command<S
return finalVerification();
}
public final CommandExecutionResult execute(S system, BlocLines lines) {
public final CommandExecutionResult execute(S system, BlocLines lines) throws NoSuchColorException {
lines = lines.cleanList(strategy);
return executeNow(system, lines);
}
protected abstract CommandExecutionResult executeNow(S system, BlocLines lines);
protected abstract CommandExecutionResult executeNow(S system, BlocLines lines) throws NoSuchColorException;
protected boolean isCommandForbidden() {
return false;

View File

@ -40,13 +40,15 @@ import java.util.regex.Pattern;
import net.sourceforge.plantuml.utils.StringLocated;
public enum Trim {
BOTH, LEFT_ONLY;
BOTH, LEFT_ONLY, NONE;
private String ltrim(final String tmp1) {
return LTRIM.matcher(tmp1).replaceAll("");
}
public String trim(StringLocated s) {
if (this == NONE)
return s.getString();
if (this == BOTH)
return s.getTrimmed().getString();
return ltrim(s.getString());

View File

@ -37,6 +37,6 @@ package net.sourceforge.plantuml.cucadiagram;
public enum GroupType {
PACKAGE, TOGETHER, STATE, CONCURRENT_STATE, INNER_ACTIVITY, CONCURRENT_ACTIVITY, DOMAIN, REQUIREMENT
PACKAGE, STATE, CONCURRENT_STATE, INNER_ACTIVITY, CONCURRENT_ACTIVITY, DOMAIN, REQUIREMENT
}

View File

@ -35,8 +35,6 @@
*/
package net.sourceforge.plantuml.descdiagram.command;
import net.sourceforge.plantuml.baraye.IEntity;
import net.sourceforge.plantuml.baraye.IGroup;
import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
@ -44,9 +42,6 @@ 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.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.graphic.USymbols;
import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
import net.sourceforge.plantuml.utils.LineLocation;
@ -66,17 +61,7 @@ public class CommandTogether extends SingleLineCommand2<AbstractEntityDiagram> {
@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;
}
}

View File

@ -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);
}
};
}
}

View File

@ -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) {

View File

@ -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;
}
}

View File

@ -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<Link> 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<Association> getExistingAssociatedPoints(final IEntity entity1, final IEntity entity2) {
final List<Association> 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;
}
}

View File

@ -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());

View File

@ -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<SvekNode> getNodesOrderedWithoutTop(Collection<SvekLine> lines) {
final List<SvekNode> all = new ArrayList<>(nodes);
final Map<String, SvekNode> shs = new HashMap<String, SvekNode>();
for (final Iterator<SvekNode> 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<ClusterPosition> insides = new ArrayList<>();
final List<XPoint2D> 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<Together, List<SvekNode>> 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<SvekNode> list = togethers.get(together);
if (list == null) {
list = new ArrayList<>();
togethers.put(together, list);
}
list.add(node);
}
added = node;
}
int t = 0;
for (List<SvekNode> 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);

View File

@ -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);

View File

@ -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;
}
}

View File

@ -81,7 +81,7 @@ public class Version {
}
public static int beta() {
final int beta = 2;
final int beta = 3;
return beta;
}