From 7c576ed4aca0e1b0c2b765c372eba44df539569e Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Wed, 24 Aug 2022 18:46:33 +0200 Subject: [PATCH] wip --- src/net/sourceforge/plantuml/Option.java | 162 +++++++++--------- src/net/sourceforge/plantuml/Run.java | 2 +- .../sourceforge/plantuml/TitledDiagram.java | 6 - .../activitydiagram/command/CommandIf.java | 20 ++- .../command/CommandLinkActivity.java | 76 ++++---- .../command/CommandLinkLongActivity.java | 47 +++-- .../command/CommandAddMethod.java | 3 +- .../command/CommandCreateClassMultilines.java | 8 +- .../command/CommandHideShowByVisibility.java | 2 +- .../command/CommandHideShowSpecificClass.java | 9 +- .../command/CommandLinkClass.java | 18 +- .../command/CommandLinkLollipop.java | 73 +++----- .../command/CommandStereotype.java | 9 +- .../command/GenericRegexProducer.java | 1 - .../note/CommandConstraintOnLinks.java | 3 +- .../note/CommandFactoryNoteActivity.java | 13 +- .../note/CommandFactoryNoteOnEntity.java | 13 +- .../note/CommandFactoryTipOnEntity.java | 20 ++- .../command/CommandLinkBlock.java | 16 +- .../cucadiagram/BodierLikeClassOrObject.java | 3 +- .../plantuml/cucadiagram/CucaDiagram.java | 26 +++ .../plantuml/cucadiagram/Display.java | 4 +- .../cucadiagram/DisplayPositionned.java | 8 +- .../cucadiagram/EntityGenderUtils.java | 1 - .../plantuml/cucadiagram/EntityPortion.java | 4 +- .../plantuml/cucadiagram/EntityUtils.java | 1 - .../plantuml/cucadiagram/ILeaf.java | 5 +- .../plantuml/cucadiagram/LeafType.java | 11 +- .../plantuml/cucadiagram/Link.java | 106 +++++------- .../plantuml/cucadiagram/LinkArg.java | 87 +++++++--- .../plantuml/cucadiagram/LinkHat.java | 20 +-- .../plantuml/cucadiagram/Magma.java | 16 +- .../plantuml/cucadiagram/Member.java | 2 - .../plantuml/cucadiagram/PortionShower.java | 1 - .../plantuml/cucadiagram/dot/DotData.java | 14 +- .../cucadiagram/dot/GraphvizVersions.java | 8 +- .../cucadiagram/entity/EntityImpl.java | 12 +- .../CommandCreateElementParenthesis.java | 1 - .../command/CommandLinkElement.java | 9 +- .../plantuml/descdiagram/command/Labels.java | 3 +- .../descdiagram/command/StringWithArrow.java | 38 +--- .../AbstractClassOrObjectDiagram.java | 88 ++++++---- .../objectdiagram/command/CommandAddData.java | 4 +- .../command/CommandCreateMap.java | 5 +- .../plantuml/picoweb/PicoWebServer.java | 44 ++++- .../plantuml/project/core/AbstractTask.java | 5 +- .../project/draw/AbstractTaskDraw.java | 14 +- .../lang/SentenceDisplayOnSameRowAs.java | 4 +- .../command/CommandExoArrowAny.java | 77 ++++----- .../command/CommandExoArrowLeft.java | 16 +- .../command/CommandExoArrowRight.java | 16 +- .../graphic/Step1MessageExo.java | 10 +- .../skin/rose/ComponentRoseArrow.java | 25 +-- .../sourceforge/plantuml/skin/rose/Rose.java | 1 - .../statediagram/command/CommandAddField.java | 3 +- .../command/CommandLinkStateCommon.java | 62 +++---- .../svek/CucaDiagramFileMakerSvek.java | 2 +- .../plantuml/svek/DecorateEntityImage3.java | 2 +- .../plantuml/svek/DotStringFactory.java | 31 +--- .../plantuml/svek/GeneralImageBuilder.java | 14 +- .../plantuml/svek/GroupPngMakerActivity.java | 2 +- .../plantuml/svek/GroupPngMakerState.java | 2 +- .../sourceforge/plantuml/svek/Margins.java | 8 + .../sourceforge/plantuml/svek/SvekLine.java | 23 ++- .../sourceforge/plantuml/svek/SvekNode.java | 49 +++--- .../plantuml/svek/image/EntityImageClass.java | 11 +- .../plantuml/svek/image/EntityImageTips.java | 2 +- .../sourceforge/plantuml/version/Version.java | 2 +- 68 files changed, 736 insertions(+), 667 deletions(-) diff --git a/src/net/sourceforge/plantuml/Option.java b/src/net/sourceforge/plantuml/Option.java index 2cf81cbd7..19b96a7fe 100644 --- a/src/net/sourceforge/plantuml/Option.java +++ b/src/net/sourceforge/plantuml/Option.java @@ -85,6 +85,7 @@ public class Option { private int ftpPort = -1; private String picowebBindAddress = null; private int picowebPort = -1; + private boolean picowebEnableStop = false; private boolean hideMetadata = false; private boolean checkMetadata = false; private int stdrpt = 0; @@ -113,17 +114,17 @@ public class Option { } public Option(String... arg) throws InterruptedException, IOException { - if (arg.length == 0) { + if (arg.length == 0) OptionFlags.getInstance().setGui(true); - } + initInclude(GraphvizUtils.getenvDefaultConfigFilename()); for (int i = 0; i < arg.length; i++) { String s = arg[i]; if (s.equalsIgnoreCase("-headless")) { // Useless because done in Run.java - if (i != 0) { + if (i != 0) Log.error("Warning: -headless flag must be the first one in the command line"); - } + System.setProperty("java.awt.headless", "true"); } else if (s.equalsIgnoreCase("-tsvg") || s.equalsIgnoreCase("-svg")) { setFileFormatOption(new FileFormatOption(FileFormat.SVG)); @@ -165,69 +166,69 @@ public class Option { OptionFlags.getInstance().setOverwrite(true); } else if (s.equalsIgnoreCase("-output") || s.equalsIgnoreCase("-o")) { i++; - if (i == arg.length) { + if (i == arg.length) continue; - } + outputDir = new File(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i])); } else if (s.equalsIgnoreCase("-ofile")) { i++; - if (i == arg.length) { + if (i == arg.length) continue; - } + outputFile = new File(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i])); } else if (s.equalsIgnoreCase("-graphvizdot") || s.equalsIgnoreCase("-graphviz_dot")) { i++; - if (i == arg.length) { + if (i == arg.length) continue; - } + GraphvizUtils.setDotExecutable(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i])); } else if (s.equalsIgnoreCase("-charset")) { i++; - if (i == arg.length) { + if (i == arg.length) continue; - } + charset = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]); } else if (s.equalsIgnoreCase("-filename")) { i++; - if (i == arg.length) { + if (i == arg.length) continue; - } + filename = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]); } else if (s.equalsIgnoreCase("-filedir")) { i++; - if (i == arg.length) { + if (i == arg.length) continue; - } + fileDir = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]); } else if (s.startsWith("-o") && s.length() > 3) { s = s.substring(2); outputDir = new File(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(s)); } else if (s.equalsIgnoreCase("-exclude") || s.equalsIgnoreCase("-x")) { i++; - if (i == arg.length) { + if (i == arg.length) continue; - } + excludes.add(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i])); } else if (s.equalsIgnoreCase("-nbthread") || s.equalsIgnoreCase("-nbthreads")) { i++; - if (i == arg.length) { + if (i == arg.length) continue; - } + final String nb = arg[i]; - if ("auto".equalsIgnoreCase(nb)) { + if ("auto".equalsIgnoreCase(nb)) this.nbThreads = defaultNbThreads(); - } else if (nb.matches("\\d+")) { + else if (nb.matches("\\d+")) this.nbThreads = Integer.parseInt(nb); - } + } else if (s.equalsIgnoreCase("-timeout")) { i++; - if (i == arg.length) { + if (i == arg.length) continue; - } + final String timeSeconds = arg[i]; - if (timeSeconds.matches("\\d+")) { + if (timeSeconds.matches("\\d+")) OptionFlags.getInstance().setTimeoutMs(Integer.parseInt(timeSeconds) * 1000L); - } + } else if (s.equalsIgnoreCase("-failfast")) { this.failfast = true; } else if (s.equalsIgnoreCase("-failfast2")) { @@ -238,15 +239,15 @@ public class Option { this.checkOnly = true; } else if (s.equalsIgnoreCase("-theme")) { i++; - if (i == arg.length) { + if (i == arg.length) continue; - } + this.config.add(0, "!theme " + arg[i]); } else if (s.equalsIgnoreCase("-config")) { i++; - if (i == arg.length) { + if (i == arg.length) continue; - } + initConfig(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i])); } else if (s.startsWith("-I")) { initInclude(s.substring(2)); @@ -261,9 +262,9 @@ public class Option { pipe = true; } else if (s.equalsIgnoreCase("-pipedelimitor")) { i++; - if (i == arg.length) { + if (i == arg.length) continue; - } + pipeDelimitor = arg[i]; } else if (s.equalsIgnoreCase("-pipemap")) { pipeMap = true; @@ -282,9 +283,9 @@ public class Option { OptionFlags.getInstance().setExtractFromMetadata(true); } else if (s.equalsIgnoreCase("-logdata")) { i++; - if (i == arg.length) { + if (i == arg.length) continue; - } + OptionFlags.getInstance() .setLogData(new SFile(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]))); } else if (s.equalsIgnoreCase("-word")) { @@ -301,9 +302,9 @@ public class Option { OptionPrint.printLicense(); } else if (s.startsWith("-DPLANTUML_LIMIT_SIZE=")) { final String v = s.substring("-DPLANTUML_LIMIT_SIZE=".length()); - if (v.matches("\\d+")) { + if (v.matches("\\d+")) System.setProperty("PLANTUML_LIMIT_SIZE", v); - } + } else if (s.startsWith("-D")) { manageDefine(s.substring(2)); } else if (s.startsWith("-S")) { @@ -371,24 +372,25 @@ public class Option { stdrpt = 2; } else if (s.equalsIgnoreCase("-pipeimageindex")) { i++; - if (i == arg.length) { + if (i == arg.length) continue; - } + final String nb = arg[i]; - if (nb.matches("\\d+")) { + if (nb.matches("\\d+")) this.imageIndex = Integer.parseInt(nb); - } + } else if (StringUtils.goLowerCase(s).startsWith("-ftp")) { final int x = s.indexOf(':'); - if (x == -1) { + if (x == -1) this.ftpPort = 4242; - } else { + else this.ftpPort = Integer.parseInt(s.substring(x + 1)); - } + } else if (StringUtils.goLowerCase(s).startsWith("-picoweb")) { final String[] parts = s.split(":"); this.picowebPort = parts.length > 1 ? Integer.parseInt(parts[1]) : 8080; this.picowebBindAddress = parts.length > 2 ? parts[2] : null; + this.picowebEnableStop = StringUtils.goLowerCase(s).contains("stop"); } else if (s.startsWith("-c")) { s = s.substring(2); config.add(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(s)); @@ -399,16 +401,16 @@ public class Option { } public Stdrpt getStdrpt() { - if (stdrpt == 1) { + if (stdrpt == 1) return new StdrptV1(); - } - if (stdrpt == 2) { + + if (stdrpt == 2) return new StdrptV2(); - } + // Legacy case - if (isPipe() || isPipeMap() || isSyntax()) { + if (isPipe() || isPipeMap() || isSyntax()) return new StdrptPipe0(); - } + return new StdrptNull(); } @@ -424,15 +426,19 @@ public class Option { return picowebPort; } + public boolean getPicowebEnableStop() { + return picowebEnableStop; + } + private void addInConfig(BufferedReader br) throws IOException { - if (br == null) { + if (br == null) return; - } + try { String s = null; - while ((s = br.readLine()) != null) { + while ((s = br.readLine()) != null) config.add(s); - } + } finally { br.close(); } @@ -444,30 +450,29 @@ public class Option { } private void initInclude(String filename) throws IOException { - if (filename == null) { + if (filename == null) return; - } + if (filename.contains("*")) { final FileGroup group = new FileGroup(filename, Collections.emptyList(), null); - for (File f : group.getFiles()) { - if (f.exists() && f.canRead()) { + for (File f : group.getFiles()) + if (f.exists() && f.canRead()) addInConfig(new BufferedReader(new FileReader(f))); - } - } + } else { final File f = new File(filename); - if (f.exists() && f.canRead()) { + if (f.exists() && f.canRead()) addInConfig(new BufferedReader(new FileReader(f))); - } + } } private void manageDefine(String s) { final Pattern2 p = MyPattern.cmpile("^(\\w+)(?:=(.*))?$"); final Matcher2 m = p.matcher(s); - if (m.find()) { + if (m.find()) define(m.group(1), m.group(2)); - } + } private void managePragma(String s) { @@ -476,9 +481,9 @@ public class Option { if (m.find()) { final String var = m.group(1); final String value = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m.group(2)); - if (var != null && value != null) { + if (var != null && value != null) config.add("!pragma " + var + " " + value); - } + } } @@ -488,9 +493,9 @@ public class Option { if (m.find()) { final String var = m.group(1); final String value = m.group(2); - if (var != null && value != null) { + if (var != null && value != null) config.add("skinparamlocked " + var + " " + value); - } + } } @@ -514,9 +519,9 @@ public class Option { final Defines result = Defines.createWithFileName(f); for (Map.Entry ent : defines.entrySet()) { String value = ent.getValue(); - if (value == null) { + if (value == null) value = ""; - } + result.define(ent.getKey(), Arrays.asList(value), false, null); } return result; @@ -537,9 +542,9 @@ public class Option { public Defines getDefaultDefines() { final Defines result = Defines.createEmpty(); result.overrideFilename(filename); - for (Map.Entry ent : defines.entrySet()) { + for (Map.Entry ent : defines.entrySet()) result.define(ent.getKey(), Arrays.asList(ent.getValue()), false, null); - } + return result; } @@ -585,12 +590,12 @@ public class Option { } public FileFormatOption getFileFormatOption() { - if (debugsvek) { + if (debugsvek) fileFormatOption.setDebugSvek(true); - } - if (hideMetadata) { + + if (hideMetadata) fileFormatOption.hideMetadata(); - } + return fileFormatOption; } @@ -690,11 +695,8 @@ public class Option { return preprocessorOutput; } - // public final void setPreprocessorOutput(boolean preprocessorOutput) { - // this.preprocessorOutput = preprocessorOutput; - // } - public String getFileDir() { return fileDir; } + } diff --git a/src/net/sourceforge/plantuml/Run.java b/src/net/sourceforge/plantuml/Run.java index 33c056623..d167ff25d 100644 --- a/src/net/sourceforge/plantuml/Run.java +++ b/src/net/sourceforge/plantuml/Run.java @@ -334,7 +334,7 @@ public class Run { } private static void goPicoweb(Option option) throws IOException { - PicoWebServer.startServer(option.getPicowebPort(), option.getPicowebBindAddress()); + PicoWebServer.startServer(option.getPicowebPort(), option.getPicowebBindAddress(), option.getPicowebEnableStop()); } public static void printFonts() { diff --git a/src/net/sourceforge/plantuml/TitledDiagram.java b/src/net/sourceforge/plantuml/TitledDiagram.java index 53ad0fd2c..9838ccec9 100644 --- a/src/net/sourceforge/plantuml/TitledDiagram.java +++ b/src/net/sourceforge/plantuml/TitledDiagram.java @@ -87,12 +87,6 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram, return pragma; } -// public TitledDiagram(ThemeStyle style, UmlSource source, UmlDiagramType type) { -// super(source); -// this.type = type; -// this.skinParam = SkinParam.create(type, style); -// } - public TitledDiagram(ThemeStyle style, UmlSource source, UmlDiagramType type, ISkinSimple orig) { super(source); this.type = type; diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java index 5e644b133..b363944b2 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java @@ -51,6 +51,7 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.Link; +import net.sourceforge.plantuml.cucadiagram.LinkArg; import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.cucadiagram.LinkType; import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement; @@ -70,15 +71,16 @@ public class CommandIf extends SingleLineCommand2 { new RegexLeaf("BAR", "(?:==+)[%s]*([%pLN_.]+)[%s]*(?:==+)"), // new RegexLeaf("QUOTED", "[%g]([^%g]+)[%g](?:[%s]+as[%s]+([%pLN_.]+))?"))), // RegexLeaf.spaceZeroOrMore(), // - //new RegexOptional(new RegexLeaf("ARROW", "([=-]+(?:(left|right|up|down|le?|ri?|up?|do?)(?=[-=.]))?[=-]*\\>)")), // - new RegexOptional(new RegexConcat( // + // new RegexOptional(new RegexLeaf("ARROW", + // "([=-]+(?:(left|right|up|down|le?|ri?|up?|do?)(?=[-=.]))?[=-]*\\>)")), // + new RegexOptional(new RegexConcat( // new RegexLeaf("ARROW_BODY1", "([-.]+)"), // new RegexLeaf("ARROW_STYLE1", "(?:\\[(" + CommandLinkElement.LINE_STYLE + ")\\])?"), // new RegexLeaf("ARROW_DIRECTION", "(\\*|left|right|up|down|le?|ri?|up?|do?)?"), // new RegexLeaf("ARROW_STYLE2", "(?:\\[(" + CommandLinkElement.LINE_STYLE + ")\\])?"), // new RegexLeaf("ARROW_BODY2", "([-.]*)"), // new RegexLeaf("\\>") // - )), // + )), // RegexLeaf.spaceZeroOrMore(), // new RegexOptional(new RegexLeaf("BRACKET", "\\[([^\\]*]+[^\\]]*)\\]")), // RegexLeaf.spaceZeroOrMore(), // @@ -93,9 +95,8 @@ public class CommandIf extends SingleLineCommand2 { @Override protected CommandExecutionResult executeArg(ActivityDiagram diagram, LineLocation location, RegexResult arg) { final IEntity entity1 = CommandLinkActivity.getEntity(diagram, arg, true); - if (entity1 == null) { + if (entity1 == null) return CommandExecutionResult.error("No if possible at this point"); - } final String ifCode; final String ifLabel; @@ -123,14 +124,15 @@ public class CommandIf extends SingleLineCommand2 { final IEntity branch = diagram.getCurrentContext().getBranch(); + final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(arg.get("BRACKET", 0)), lenght); Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), entity1, branch, - new LinkType(LinkDecor.ARROW, LinkDecor.NONE), Display.getWithNewlines(arg.get("BRACKET", 0)), lenght, null, ifLabel, - diagram.getLabeldistance(), diagram.getLabelangle()); + new LinkType(LinkDecor.ARROW, LinkDecor.NONE), linkArg.withQualifier(null, ifLabel) + .withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle())); if (arg.get("ARROW", 0) != null) { final Direction direction = StringUtils.getArrowDirection(arg.get("ARROW", 0)); - if (direction == Direction.LEFT || direction == Direction.UP) { + if (direction == Direction.LEFT || direction == Direction.UP) link = link.getInv(); - } + } link.applyStyle(diagram.getSkinParam().getThemeStyle(), arg.getLazzy("ARROW_STYLE", 0)); diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java index 45ba50399..4e53cbf09 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java @@ -60,6 +60,7 @@ import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; +import net.sourceforge.plantuml.cucadiagram.LinkArg; import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.cucadiagram.LinkType; import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; @@ -125,12 +126,12 @@ public class CommandLinkActivity extends SingleLineCommand2 { protected CommandExecutionResult executeArg(ActivityDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final IEntity entity1 = getEntity(diagram, arg, true); - if (entity1 == null) { + if (entity1 == null) return CommandExecutionResult.error("No such activity"); - } - if (arg.get("STEREOTYPE", 0) != null) { + + if (arg.get("STEREOTYPE", 0) != null) entity1.setStereotype(Stereotype.build(arg.get("STEREOTYPE", 0))); - } + if (arg.get("BACKCOLOR", 0) != null) { String s = arg.get("BACKCOLOR", 0); entity1.setSpecificColorTOBEREMOVED(ColorType.BACK, @@ -138,17 +139,16 @@ public class CommandLinkActivity extends SingleLineCommand2 { } final IEntity entity2 = getEntity(diagram, arg, false); - if (entity2 == null) { + if (entity2 == null) return CommandExecutionResult.error("No such activity"); - } + if (arg.get("BACKCOLOR2", 0) != null) { String s = arg.get("BACKCOLOR2", 0); entity2.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet().getColor(diagram.getSkinParam().getThemeStyle(), s)); } - if (arg.get("STEREOTYPE2", 0) != null) { + if (arg.get("STEREOTYPE2", 0) != null) entity2.setStereotype(Stereotype.build(arg.get("STEREOTYPE2", 0))); - } final Display linkLabel = Display.getWithNewlines(arg.get("BRACKET", 0)); @@ -158,24 +158,22 @@ public class CommandLinkActivity extends SingleLineCommand2 { final String arrow = StringUtils.manageArrowForCuca(arrowBody1 + arrowDirection + arrowBody2 + ">"); int lenght = arrow.length() - 1; - if (arrowDirection.contains("*")) { + if (arrowDirection.contains("*")) lenght = 2; - } LinkType type = new LinkType(LinkDecor.ARROW, LinkDecor.NONE); - if ((arrowBody1 + arrowBody2).contains(".")) { + if ((arrowBody1 + arrowBody2).contains(".")) type = type.goDotted(); - } - Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), entity1, entity2, type, linkLabel, - lenght); - if (arrowDirection.contains("*")) { + final LinkArg linkArg = LinkArg.build(linkLabel, lenght, diagram.getSkinParam().classAttributeIconSize() > 0); + Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), entity1, entity2, type, linkArg); + if (arrowDirection.contains("*")) link.setConstraint(false); - } + final Direction direction = StringUtils.getArrowDirection(arrowBody1 + arrowDirection + arrowBody2 + ">"); - if (direction == Direction.LEFT || direction == Direction.UP) { + if (direction == Direction.LEFT || direction == Direction.UP) link = link.getInv(); - } + if (arg.get("URL", 0) != null) { final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), UrlMode.STRICT); final Url urlLink = urlBuilder.getUrl(arg.get("URL", 0)); @@ -193,23 +191,23 @@ public class CommandLinkActivity extends SingleLineCommand2 { final String suf = start ? "" : "2"; final String openBracket2 = arg.get("OPENBRACKET" + suf, 0); - if (openBracket2 != null) { + if (openBracket2 != null) return diagram.createInnerActivity(); - } + if (arg.get("STAR" + suf, 0) != null) { final String suppId = arg.get("STAR" + suf, 1); if (start) { - if (suppId != null) { + if (suppId != null) diagram.getStart().setTop(true); - } + return diagram.getStart(); } return diagram.getEnd(suppId); } String partition = arg.get("PARTITION" + suf, 0); - if (partition != null) { + if (partition != null) partition = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(partition); - } + final String idShort = arg.get("CODE" + suf, 0); if (idShort != null) { if (partition != null) { @@ -229,9 +227,9 @@ public class CommandLinkActivity extends SingleLineCommand2 { result = diagram.getOrCreate(ident, code, Display.getWithNewlines(code), type); } else result = diagram.getOrCreate(ident, code, Display.getWithNewlines(code), type); - if (partition != null) { + if (partition != null) diagram.endGroup(); - } + return result; } final String bar = arg.get("BAR" + suf, 0); @@ -240,9 +238,9 @@ public class CommandLinkActivity extends SingleLineCommand2 { final Code codeBar = diagram.V1972() ? identBar : diagram.buildCode(bar); if (diagram.V1972()) { final ILeaf result = diagram.getLeafVerySmart(identBar); - if (result != null) { + if (result != null) return result; - } + } return diagram.getOrCreate(identBar, codeBar, Display.getWithNewlines(bar), LeafType.SYNCHRO_BAR); } @@ -261,9 +259,9 @@ public class CommandLinkActivity extends SingleLineCommand2 { : getTypeIfExisting(diagram, quotedCode); final IEntity result = diagram.getOrCreate(quotedIdent, quotedCode, Display.getWithNewlines(quoted.get(0)), type); - if (partition != null) { + if (partition != null) diagram.endGroup(); - } + return result; } final String quoteInvisibleString = arg.get("QUOTED_INVISIBLE" + suf, 0); @@ -278,35 +276,33 @@ public class CommandLinkActivity extends SingleLineCommand2 { final Code quotedInvisible = diagram.V1972() ? identInvisible : diagram.buildCode(quoteInvisibleString); final IEntity result = diagram.getOrCreate(identInvisible, quotedInvisible, Display.getWithNewlines(quotedInvisible), LeafType.ACTIVITY); - if (partition != null) { + if (partition != null) diagram.endGroup(); - } + return result; } final String first = arg.get("FIRST" + suf, 0); - if (first == null) { + if (first == null) return diagram.getLastEntityConsulted(); - } return null; } private static LeafType getTypeIfExistingSmart(ActivityDiagram system, Ident ident) { final IEntity ent = system.getLeafSmart(ident); - if (ent != null) { - if (ent.getLeafType() == LeafType.BRANCH) { + if (ent != null) + if (ent.getLeafType() == LeafType.BRANCH) return LeafType.BRANCH; - } - } + return LeafType.ACTIVITY; } private static LeafType getTypeIfExisting(ActivityDiagram system, Code code) { if (system.leafExist(code)) { final IEntity ent = system.getLeaf(code); - if (ent.getLeafType() == LeafType.BRANCH) { + if (ent.getLeafType() == LeafType.BRANCH) return LeafType.BRANCH; - } + } return LeafType.ACTIVITY; } diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java index c46f411c1..fb8fdfa88 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java @@ -64,6 +64,7 @@ import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; +import net.sourceforge.plantuml.cucadiagram.LinkArg; import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.cucadiagram.LinkType; import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; @@ -121,13 +122,12 @@ public class CommandLinkLongActivity extends CommandMultilines2 final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); final IEntity entity1 = CommandLinkActivity.getEntity(diagram, line0, true); - if (entity1 == null) { + if (entity1 == null) return CommandExecutionResult.error("No such entity"); - } - if (line0.get("STEREOTYPE", 0) != null) { + if (line0.get("STEREOTYPE", 0) != null) entity1.setStereotype(Stereotype.build(line0.get("STEREOTYPE", 0))); - } + final String stringColor = line0.get("BACKCOLOR", 0); if (stringColor != null) { entity1.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet() @@ -149,22 +149,22 @@ public class CommandLinkLongActivity extends CommandMultilines2 i++; if (i == 1 && urlActivity == null) { urlActivity = extractUrl(diagram, cs); - if (urlActivity != null) { + if (urlActivity != null) continue; - } + } sb.append(cs.getString()); - if (i < lines.size() - 2) { + if (i < lines.size() - 2) sb.append(BackSlash.BS_BS_N); - } + } final List lineLast = StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()), lines.getLast().getString()); if (StringUtils.isNotEmpty(lineLast.get(0))) { - if (sb.length() > 0 && sb.toString().endsWith(BackSlash.BS_BS_N) == false) { + if (sb.length() > 0 && sb.toString().endsWith(BackSlash.BS_BS_N) == false) sb.append(BackSlash.BS_BS_N); - } + sb.append(lineLast.get(0)); } @@ -184,20 +184,18 @@ public class CommandLinkLongActivity extends CommandMultilines2 final Ident ident = diagram.buildLeafIdent(idShort); final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort); final IEntity entity2 = diagram.getOrCreate(ident, code, Display.getWithNewlines(display), LeafType.ACTIVITY); - if (entity2 == null) { + if (entity2 == null) return CommandExecutionResult.error("No such entity"); - } - if (partition != null) { + if (partition != null) diagram.endGroup(); - } - if (urlActivity != null) { - entity2.addUrl(urlActivity); - } - if (lineLast.get(2) != null) { + if (urlActivity != null) + entity2.addUrl(urlActivity); + + if (lineLast.get(2) != null) entity2.setStereotype(Stereotype.build(lineLast.get(2))); - } + if (lineLast.get(4) != null) { String s = lineLast.get(4); entity2.setSpecificColorTOBEREMOVED(ColorType.BACK, @@ -215,15 +213,14 @@ public class CommandLinkLongActivity extends CommandMultilines2 final Display linkLabel = Display.getWithNewlines(line0.get("BRACKET", 0)); LinkType type = new LinkType(LinkDecor.ARROW, LinkDecor.NONE); - if (arrow.contains(".")) { + if (arrow.contains(".")) type = type.goDotted(); - } - Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), entity1, entity2, type, linkLabel, - lenght); + + final LinkArg linkArg = LinkArg.build(linkLabel, lenght, diagram.getSkinParam().classAttributeIconSize() > 0); + Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), entity1, entity2, type, linkArg); final Direction direction = StringUtils.getArrowDirection(arrowBody1 + arrowDirection + arrowBody2 + ">"); - if (direction == Direction.LEFT || direction == Direction.UP) { + if (direction == Direction.LEFT || direction == Direction.UP) link = link.getInv(); - } if (line0.get("URL", 0) != null) { final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), UrlMode.STRICT); diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandAddMethod.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandAddMethod.java index 3de51d40d..fbd0bec56 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandAddMethod.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandAddMethod.java @@ -66,7 +66,8 @@ public class CommandAddMethod extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { + protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) + throws NoSuchColorException { final String idShort = arg.get("NAME", 0); final Ident ident = diagram.buildLeafIdent(idShort); final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort); diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java index b3d7b42db..f5bcabed7 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java @@ -59,6 +59,7 @@ import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; +import net.sourceforge.plantuml.cucadiagram.LinkArg; import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.cucadiagram.LinkType; import net.sourceforge.plantuml.cucadiagram.Stereotag; @@ -214,9 +215,10 @@ public class CommandCreateClassMultilines extends CommandMultilines2 final EntityPortion portion = getEntityPortion(arg.get("PORTION", 0)); - final Set visibilities = EnumSet. noneOf(VisibilityModifier.class); + final Set visibilities = EnumSet.noneOf(VisibilityModifier.class); final StringTokenizer st = new StringTokenizer(StringUtils.goLowerCase(arg.get("VISIBILITY", 0)), " ,"); while (st.hasMoreTokens()) { addVisibilities(st.nextToken(), portion, visibilities); diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowSpecificClass.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowSpecificClass.java index 983ccd848..18f85eb33 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowSpecificClass.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowSpecificClass.java @@ -62,9 +62,11 @@ public class CommandHideShowSpecificClass extends SingleLineCommand2