summaryrefslogtreecommitdiff
path: root/src/net/sourceforge/plantuml/sequencediagram/command
diff options
context:
space:
mode:
authorAndrej Shadura <andrew.shadura@collabora.co.uk>2020-03-10 16:38:20 +0100
committerAndrej Shadura <andrew.shadura@collabora.co.uk>2020-03-10 16:38:20 +0100
commit7cc8c823de644a510fcc434f39b53e5fffe66bfd (patch)
tree8f4d027284bb366734f610040c621a0c5dd0a12a /src/net/sourceforge/plantuml/sequencediagram/command
parent567b200b91537405689ae0ca944f121201360a6b (diff)
New upstream version 1.2020.2
Diffstat (limited to 'src/net/sourceforge/plantuml/sequencediagram/command')
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate.java22
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate2.java32
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow.java105
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandAutoNewpage.java26
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandAutoactivate.java26
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumber.java25
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumberIncrement.java19
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumberResume.java25
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumberStop.java27
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxEnd.java28
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxStart.java64
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandDeactivateShort.java18
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandDelay.java29
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandDivider.java30
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowAny.java61
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowLeft.java29
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowRight.java29
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandFootbox.java28
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandFootboxOld.java30
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandGrouping.java26
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandHSpace.java30
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandIgnoreNewpage.java26
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandLinkAnchor.java71
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandNewpage.java32
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipant.java17
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA.java30
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA2.java24
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA3.java25
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA4.java21
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandReferenceMultilinesOverSeveral.java8
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandReferenceOverSeveral.java26
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandReturn.java62
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandSkin.java34
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandUrl.java36
34 files changed, 778 insertions, 343 deletions
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate.java
index 43d28ca..2e225f7 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -35,11 +35,14 @@
*/
package net.sourceforge.plantuml.sequencediagram.command;
+import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
+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.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.sequencediagram.LifeEventType;
@@ -52,19 +55,22 @@ public class CommandActivate extends SingleLineCommand2<SequenceDiagram> {
super(getRegexConcat());
}
- static RegexConcat getRegexConcat() {
- return new RegexConcat(new RegexLeaf("^"), //
+ static IRegex getRegexConcat() {
+ return RegexConcat.build(CommandActivate.class.getName(), RegexLeaf.start(), //
new RegexLeaf("TYPE", "(activate|deactivate|destroy|create)"), //
- new RegexLeaf("[%s]+"), //
+ RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("WHO", "([\\p{L}0-9_.@]+|[%g][^%g]+[%g])"), //
- new RegexLeaf("[%s]*"), //
+ RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("BACK", "(#\\w+)?"), //
- new RegexLeaf("LINE", "(?:[%s]+(#\\w+))?"), //
- new RegexLeaf("$"));
+ new RegexOptional( //
+ new RegexConcat( //
+ RegexLeaf.spaceOneOrMore(), //
+ new RegexLeaf("LINE", "(#\\w+)") //
+ )), RegexLeaf.end());
}
@Override
- protected CommandExecutionResult executeArg(SequenceDiagram diagram, RegexResult arg) {
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) {
final LifeEventType type = LifeEventType.valueOf(StringUtils.goUpperCase(arg.get("TYPE", 0)));
final Participant p = diagram.getOrCreateParticipant(StringUtils
.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("WHO", 0)));
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate2.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate2.java
index 890249b..40e012b 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate2.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate2.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -35,26 +35,38 @@
*/
package net.sourceforge.plantuml.sequencediagram.command;
-import java.util.List;
-
+import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.command.CommandExecutionResult;
-import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+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.sequencediagram.LifeEventType;
import net.sourceforge.plantuml.sequencediagram.Participant;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
-public class CommandActivate2 extends SingleLineCommand<SequenceDiagram> {
+public class CommandActivate2 extends SingleLineCommand2<SequenceDiagram> {
public CommandActivate2() {
- super("(?i)^([\\p{L}0-9_.@]+)[%s]*(\\+\\+|--)[%s]*(#\\w+)?$");
+ super(getRegexConcat());
+ }
+
+ static IRegex getRegexConcat() {
+ return RegexConcat.build(CommandActivate2.class.getName(), RegexLeaf.start(), //
+ new RegexLeaf("NAME", "([\\p{L}0-9_.@]+)"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf("TYPE", "(\\+\\+|--)"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf("COLOR", "(#\\w+)?"), RegexLeaf.end()); //
}
@Override
- protected CommandExecutionResult executeArg(SequenceDiagram diagram, List<String> arg) {
- final LifeEventType type = arg.get(1).equals("++") ? LifeEventType.ACTIVATE : LifeEventType.DEACTIVATE;
- final Participant p = diagram.getOrCreateParticipant(arg.get(0));
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) {
+ final LifeEventType type = arg.get("TYPE", 0).equals("++") ? LifeEventType.ACTIVATE : LifeEventType.DEACTIVATE;
+ final Participant p = diagram.getOrCreateParticipant(arg.get("NAME", 0));
final String error = diagram.activate(p, type,
- diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get(2)));
+ diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)));
if (error == null) {
return CommandExecutionResult.ok();
}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow.java
index 4f8fa0b..7b72b2e 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -37,6 +37,7 @@ package net.sourceforge.plantuml.sequencediagram.command;
import java.util.StringTokenizer;
+import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
@@ -44,6 +45,7 @@ import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
import net.sourceforge.plantuml.classdiagram.command.CommandLinkClass;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
+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.RegexOr;
@@ -64,6 +66,8 @@ import net.sourceforge.plantuml.skin.ArrowPart;
public class CommandArrow extends SingleLineCommand2<SequenceDiagram> {
+ private static final String ANCHOR = "(\\{([\\p{L}0-9_]+)\\}[%s]+)?";
+
public CommandArrow() {
super(getRegexConcat());
}
@@ -72,39 +76,45 @@ public class CommandArrow extends SingleLineCommand2<SequenceDiagram> {
return "(?:\\[(" + CommandLinkElement.LINE_STYLE + ")\\])?";
}
- static RegexConcat getRegexConcat() {
- return new RegexConcat(
- new RegexLeaf("^"), //
- new RegexLeaf("PARALLEL", "(&%s*)?"), //
- new RegexOr("PART1", //
- new RegexLeaf("PART1CODE", "([\\p{L}0-9_.@]+)"), //
- new RegexLeaf("PART1LONG", "[%g]([^%g]+)[%g]"), //
- new RegexLeaf("PART1LONGCODE", "[%g]([^%g]+)[%g][%s]*as[%s]+([\\p{L}0-9_.@]+)"), //
- new RegexLeaf("PART1CODELONG", "([\\p{L}0-9_.@]+)[%s]+as[%s]*[%g]([^%g]+)[%g]")), //
- new RegexLeaf("[%s]*"), //
- new RegexLeaf("ARROW_DRESSING1", "([%s][ox]|(?:[%s][ox])?<<?|(?:[%s][ox])?//?|(?:[%s][ox])?\\\\\\\\?)?"), //
- new RegexOr(new RegexConcat( //
- new RegexLeaf("ARROW_BODYA1", "(-+)"), //
- new RegexLeaf("ARROW_STYLE1", getColorOrStylePattern()), //
- new RegexLeaf("ARROW_BODYB1", "(-*)")), //
- new RegexConcat( //
- new RegexLeaf("ARROW_BODYA2", "(-*)"), //
- new RegexLeaf("ARROW_STYLE2", getColorOrStylePattern()), //
- new RegexLeaf("ARROW_BODYB2", "(-+)"))), //
- new RegexLeaf("ARROW_DRESSING2", "(>>?(?:[ox][%s])?|//?(?:[ox][%s])?|\\\\\\\\?(?:[ox][%s])?|[ox][%s])?"), //
- new RegexLeaf("[%s]*"), //
- new RegexOr("PART2", //
- new RegexLeaf("PART2CODE", "([\\p{L}0-9_.@]+)"), //
- new RegexLeaf("PART2LONG", "[%g]([^%g]+)[%g]"), //
- new RegexLeaf("PART2LONGCODE", "[%g]([^%g]+)[%g][%s]*as[%s]+([\\p{L}0-9_.@]+)"), //
- new RegexLeaf("PART2CODELONG", "([\\p{L}0-9_.@]+)[%s]+as[%s]*[%g]([^%g]+)[%g]")), //
- new RegexLeaf("[%s]*"), //
- new RegexLeaf("ACTIVATION", "(?:([+*!-]+)?)"), //
- new RegexLeaf("[%s]*"), //
- new RegexLeaf("LIFECOLOR", "(?:(#\\w+)?)"), //
- new RegexLeaf("URL", "[%s]*(" + UrlBuilder.getRegexp() + ")?"), //
- new RegexLeaf("[%s]*"), //
- new RegexLeaf("MESSAGE", "(?::[%s]*(.*))?$"));
+ static IRegex getRegexConcat() {
+ return RegexConcat
+ .build(CommandArrow.class.getName(),
+ RegexLeaf.start(), //
+ new RegexLeaf("PARALLEL", "(&[%s]*)?"), //
+ new RegexLeaf("ANCHOR", ANCHOR), //
+ new RegexOr("PART1", //
+ new RegexLeaf("PART1CODE", "([\\p{L}0-9_.@]+)"), //
+ new RegexLeaf("PART1LONG", "[%g]([^%g]+)[%g]"), //
+ new RegexLeaf("PART1LONGCODE", "[%g]([^%g]+)[%g][%s]*as[%s]+([\\p{L}0-9_.@]+)"), //
+ new RegexLeaf("PART1CODELONG", "([\\p{L}0-9_.@]+)[%s]+as[%s]*[%g]([^%g]+)[%g]")), //
+ new RegexLeaf("PART1ANCHOR", ANCHOR), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf("ARROW_DRESSING1",
+ "([%s][ox]|(?:[%s][ox])?<<?|(?:[%s][ox])?//?|(?:[%s][ox])?\\\\\\\\?)?"), //
+ new RegexOr(new RegexConcat( //
+ new RegexLeaf("ARROW_BODYA1", "(-+)"), //
+ new RegexLeaf("ARROW_STYLE1", getColorOrStylePattern()), //
+ new RegexLeaf("ARROW_BODYB1", "(-*)")), //
+ new RegexConcat( //
+ new RegexLeaf("ARROW_BODYA2", "(-*)"), //
+ new RegexLeaf("ARROW_STYLE2", getColorOrStylePattern()), //
+ new RegexLeaf("ARROW_BODYB2", "(-+)"))), //
+ new RegexLeaf("ARROW_DRESSING2",
+ "(>>?(?:[ox][%s])?|//?(?:[ox][%s])?|\\\\\\\\?(?:[ox][%s])?|[ox][%s])?"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexOr("PART2", //
+ new RegexLeaf("PART2CODE", "([\\p{L}0-9_.@]+)"), //
+ new RegexLeaf("PART2LONG", "[%g]([^%g]+)[%g]"), //
+ new RegexLeaf("PART2LONGCODE", "[%g]([^%g]+)[%g][%s]*as[%s]+([\\p{L}0-9_.@]+)"), //
+ new RegexLeaf("PART2CODELONG", "([\\p{L}0-9_.@]+)[%s]+as[%s]*[%g]([^%g]+)[%g]")), //
+ new RegexLeaf("PART2ANCHOR", ANCHOR), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf("ACTIVATION", "(?:([+*!-]+)?)"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf("LIFECOLOR", "(?:(#\\w+)?)"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+ RegexLeaf.spaceZeroOrMore(), new RegexLeaf("MESSAGE", "(?::[%s]*(.*))?"), RegexLeaf.end());
}
private Participant getOrCreateParticipant(SequenceDiagram system, RegexResult arg2, String n) {
@@ -139,7 +149,7 @@ public class CommandArrow extends SingleLineCommand2<SequenceDiagram> {
}
@Override
- protected CommandExecutionResult executeArg(SequenceDiagram diagram, RegexResult arg) {
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) {
Participant p1;
Participant p2;
@@ -203,11 +213,20 @@ public class CommandArrow extends SingleLineCommand2<SequenceDiagram> {
if (circleAtStart) {
config = config.withDecoration1(ArrowDecoration.CIRCLE);
}
- if (dressing1.contains("x")) {
- config = config.withHead2(ArrowHead.CROSSX);
- }
- if (dressing2.contains("x")) {
- config = config.withHead2(ArrowHead.CROSSX);
+ if (reverseDefine) {
+ if (dressing1.contains("x")) {
+ config = config.withHead2(ArrowHead.CROSSX);
+ }
+ if (dressing2.contains("x")) {
+ config = config.withHead1(ArrowHead.CROSSX);
+ }
+ } else {
+ if (dressing1.contains("x")) {
+ config = config.withHead1(ArrowHead.CROSSX);
+ }
+ if (dressing2.contains("x")) {
+ config = config.withHead2(ArrowHead.CROSSX);
+ }
}
if (reverseDefine) {
config = config.reverseDefine();
@@ -222,7 +241,8 @@ public class CommandArrow extends SingleLineCommand2<SequenceDiagram> {
}
final String messageNumber = diagram.getNextMessageNumber();
- final Message msg = new Message(p1, p2, diagram.manageVariable(labels), config, messageNumber);
+ final Message msg = new Message(diagram.getSkinParam().getCurrentStyleBuilder(), p1, p2,
+ diagram.manageVariable(labels), config, messageNumber);
final String url = arg.get("URL", 0);
if (url != null) {
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
@@ -234,6 +254,9 @@ public class CommandArrow extends SingleLineCommand2<SequenceDiagram> {
if (parallel) {
msg.goParallel();
}
+ msg.setAnchor(arg.get("ANCHOR", 1));
+ msg.setPart1Anchor(arg.get("PART1ANCHOR", 1));
+ msg.setPart2Anchor(arg.get("PART2ANCHOR", 1));
final String error = diagram.addMessage(msg);
if (error != null) {
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutoNewpage.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutoNewpage.java
index 2c31860..027d587 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutoNewpage.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutoNewpage.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -35,21 +35,31 @@
*/
package net.sourceforge.plantuml.sequencediagram.command;
-import java.util.List;
-
+import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.command.CommandExecutionResult;
-import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+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.sequencediagram.SequenceDiagram;
-public class CommandAutoNewpage extends SingleLineCommand<SequenceDiagram> {
+public class CommandAutoNewpage extends SingleLineCommand2<SequenceDiagram> {
public CommandAutoNewpage() {
- super("(?i)^autonewpage[%s]+(\\d+)$");
+ super(getRegexConcat());
+ }
+
+ static IRegex getRegexConcat() {
+ return RegexConcat.build(CommandAutoNewpage.class.getName(), RegexLeaf.start(), //
+ new RegexLeaf("autonewpage"), //
+ RegexLeaf.spaceOneOrMore(), //
+ new RegexLeaf("VALUE", "(\\d+)"), RegexLeaf.end()); //
}
@Override
- protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
- sequenceDiagram.setAutonewpage(Integer.parseInt(arg.get(0)));
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) {
+ diagram.setAutonewpage(Integer.parseInt(arg.get("VALUE", 0)));
return CommandExecutionResult.ok();
}
}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutoactivate.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutoactivate.java
index 5c145c8..1e43e34 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutoactivate.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutoactivate.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -35,21 +35,31 @@
*/
package net.sourceforge.plantuml.sequencediagram.command;
-import java.util.List;
-
+import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.command.CommandExecutionResult;
-import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+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.sequencediagram.SequenceDiagram;
-public class CommandAutoactivate extends SingleLineCommand<SequenceDiagram> {
+public class CommandAutoactivate extends SingleLineCommand2<SequenceDiagram> {
public CommandAutoactivate() {
- super("(?i)^autoactivate[%s]+(off|on)*$");
+ super(getRegexConcat());
+ }
+
+ static IRegex getRegexConcat() {
+ return RegexConcat.build(CommandAutoactivate.class.getName(), RegexLeaf.start(), //
+ new RegexLeaf("autoactivate"), //
+ RegexLeaf.spaceOneOrMore(), //
+ new RegexLeaf("ON", "(off|on)"), RegexLeaf.end()); //
}
@Override
- protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
- sequenceDiagram.setAutoactivate("on".equalsIgnoreCase(arg.get(0)));
+ protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, LineLocation location, RegexResult arg) {
+ sequenceDiagram.setAutoactivate("on".equalsIgnoreCase(arg.get("ON", 0)));
return CommandExecutionResult.ok();
}
}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumber.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumber.java
index ca66887..9ec326c 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumber.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumber.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -37,10 +37,12 @@ package net.sourceforge.plantuml.sequencediagram.command;
import java.text.DecimalFormat;
+import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.sequencediagram.DottedNumber;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
@@ -52,18 +54,25 @@ public class CommandAutonumber extends SingleLineCommand2<SequenceDiagram> {
}
private static RegexConcat getConcat() {
- return new RegexConcat(new RegexLeaf("^"), //
+ return RegexConcat.build(CommandAutonumber.class.getName(), RegexLeaf.start(), //
new RegexLeaf("autonumber"), //
- new RegexLeaf("[%s]*"), //
+ RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("START", "(\\d(?:(?:[^\\p{L}0-9%s]+|\\d+)*\\d)?)?"), //
- new RegexLeaf("STEP", "(?:[%s]+(\\d+))?"), //
- new RegexLeaf("FORMAT", "(?:[%s]+[%g]([^%g]+)[%g])?"), //
- new RegexLeaf("[%s]*"), //
- new RegexLeaf("$"));
+ new RegexOptional( //
+ new RegexConcat( //
+ RegexLeaf.spaceOneOrMore(), //
+ new RegexLeaf("STEP", "(\\d+)") //
+ )), //
+ new RegexOptional( //
+ new RegexConcat( //
+ RegexLeaf.spaceOneOrMore(), //
+ new RegexLeaf("FORMAT", "[%g]([^%g]+)[%g]") //
+ )), //
+ RegexLeaf.spaceZeroOrMore(), RegexLeaf.end());
}
@Override
- protected CommandExecutionResult executeArg(SequenceDiagram diagram, RegexResult arg) {
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) {
DottedNumber start = DottedNumber.create("1");
final String arg0 = arg.get("START", 0);
// System.err.println("arg0=" + arg0);
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumberIncrement.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumberIncrement.java
index 4ee28a5..d61edc7 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumberIncrement.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumberIncrement.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -35,11 +35,13 @@
*/
package net.sourceforge.plantuml.sequencediagram.command;
+import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
@@ -50,17 +52,20 @@ public class CommandAutonumberIncrement extends SingleLineCommand2<SequenceDiagr
}
private static RegexConcat getConcat() {
- return new RegexConcat(new RegexLeaf("^"), //
+ return RegexConcat.build(CommandAutonumberIncrement.class.getName(), RegexLeaf.start(), //
new RegexLeaf("autonumber"), //
- new RegexLeaf("[%s]+"), //
+ RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("inc"), //
- new RegexLeaf("POS", "(?:[%s]+([A-Za-z]))?"), //
- new RegexLeaf("[%s]*"), //
- new RegexLeaf("$"));
+ new RegexOptional( //
+ new RegexConcat( //
+ RegexLeaf.spaceOneOrMore(), //
+ new RegexLeaf("POS", "([A-Za-z])") //
+ )), //
+ RegexLeaf.spaceZeroOrMore(), RegexLeaf.end());
}
@Override
- protected CommandExecutionResult executeArg(SequenceDiagram diagram, RegexResult arg) {
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) {
final String position = arg.get("POS", 0);
if (position == null) {
diagram.getAutoNumber().incrementIntermediate();
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumberResume.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumberResume.java
index 2d9d312..7a3c6de 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumberResume.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumberResume.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -37,10 +37,12 @@ package net.sourceforge.plantuml.sequencediagram.command;
import java.text.DecimalFormat;
+import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
@@ -51,18 +53,25 @@ public class CommandAutonumberResume extends SingleLineCommand2<SequenceDiagram>
}
private static RegexConcat getConcat() {
- return new RegexConcat(new RegexLeaf("^"), //
+ return RegexConcat.build(CommandAutonumberResume.class.getName(), RegexLeaf.start(), //
new RegexLeaf("autonumber"), //
- new RegexLeaf("[%s]+"), //
+ RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("resume"), //
- new RegexLeaf("[%s]*"), //
- new RegexLeaf("INC", "(?:[%s]+(\\d+))?"), //
- new RegexLeaf("DF", "(?:[%s]+[%g]([^%g]+)[%g])?"), //
- new RegexLeaf("$"));
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexOptional( //
+ new RegexConcat( //
+ RegexLeaf.spaceOneOrMore(), //
+ new RegexLeaf("INC", "(\\d+)") //
+ )), //
+ new RegexOptional( //
+ new RegexConcat( //
+ RegexLeaf.spaceOneOrMore(), //
+ new RegexLeaf("DF", "[%g]([^%g]+)[%g]") //
+ )), RegexLeaf.end());
}
@Override
- protected CommandExecutionResult executeArg(SequenceDiagram diagram, RegexResult arg) {
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) {
final String df = arg.get("DF", 0);
DecimalFormat decimalFormat = null;
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumberStop.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumberStop.java
index fb1e396..6fb1e4c 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumberStop.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumberStop.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -35,21 +35,32 @@
*/
package net.sourceforge.plantuml.sequencediagram.command;
-import java.util.List;
-
+import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.command.CommandExecutionResult;
-import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+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.sequencediagram.SequenceDiagram;
-public class CommandAutonumberStop extends SingleLineCommand<SequenceDiagram> {
+public class CommandAutonumberStop extends SingleLineCommand2<SequenceDiagram> {
public CommandAutonumberStop() {
- super("(?i)^autonumber[%s]+stop[%s]*$");
+ super(getRegexConcat());
+ }
+
+ static IRegex getRegexConcat() {
+ return RegexConcat.build(CommandAutonumberStop.class.getName(), RegexLeaf.start(), //
+ new RegexLeaf("autonumber"), //
+ RegexLeaf.spaceOneOrMore(), //
+ new RegexLeaf("stop"), //
+ RegexLeaf.spaceZeroOrMore(), RegexLeaf.end()); //
}
@Override
- protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
- sequenceDiagram.autonumberStop();
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) {
+ diagram.autonumberStop();
return CommandExecutionResult.ok();
}
}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxEnd.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxEnd.java
index 28e7432..7c48762 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxEnd.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxEnd.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -35,24 +35,34 @@
*/
package net.sourceforge.plantuml.sequencediagram.command;
-import java.util.List;
-
+import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.command.CommandExecutionResult;
-import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+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.sequencediagram.SequenceDiagram;
-public class CommandBoxEnd extends SingleLineCommand<SequenceDiagram> {
+public class CommandBoxEnd extends SingleLineCommand2<SequenceDiagram> {
public CommandBoxEnd() {
- super("(?i)^end[%s]?box$");
+ super(getRegexConcat());
+ }
+
+ static IRegex getRegexConcat() {
+ return RegexConcat.build(CommandBoxEnd.class.getName(), RegexLeaf.start(), //
+ new RegexLeaf("end"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf("box"), RegexLeaf.end()); //
}
@Override
- protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
- if (sequenceDiagram.isBoxPending() == false) {
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) {
+ if (diagram.isBoxPending() == false) {
return CommandExecutionResult.error("Missing starting box");
}
- sequenceDiagram.endBox();
+ diagram.endBox();
return CommandExecutionResult.ok();
}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxStart.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxStart.java
index 23b4e47..7661249 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxStart.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxStart.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -35,28 +35,70 @@
*/
package net.sourceforge.plantuml.sequencediagram.command;
-import java.util.List;
-
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.command.CommandExecutionResult;
-import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+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.RegexOptional;
+import net.sourceforge.plantuml.command.regex.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Display;
-import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.color.ColorParser;
+import net.sourceforge.plantuml.graphic.color.ColorType;
+import net.sourceforge.plantuml.graphic.color.Colors;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.ugraphic.UFont;
-public class CommandBoxStart extends SingleLineCommand<SequenceDiagram> {
+public class CommandBoxStart extends SingleLineCommand2<SequenceDiagram> {
public CommandBoxStart() {
- super("(?i)^box(?:[%s]+[%g]([^%g]+)[%g])?(?:[%s]+(#\\w+))?$");
+ super(getRegexConcat());
+ }
+
+ static IRegex getRegexConcat() {
+ return RegexConcat.build(CommandBoxStart.class.getName(), RegexLeaf.start(), //
+ new RegexLeaf("box"), //
+ new RegexOptional(new RegexOr( //
+ new RegexConcat( //
+ RegexLeaf.spaceOneOrMore(), //
+ new RegexLeaf("NAME1", "[%g]([^%g]+)[%g]")), //
+ new RegexConcat( //
+ RegexLeaf.spaceOneOrMore(), //
+ new RegexLeaf("NAME2", "([^#]+)")))), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
+ color().getRegex(), //
+ RegexLeaf.end());
+ }
+
+ private static ColorParser color() {
+ return ColorParser.simpleColor(ColorType.BACK);
}
@Override
- protected CommandExecutionResult executeArg(SequenceDiagram diagram, List<String> arg) {
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) {
if (diagram.isBoxPending()) {
return CommandExecutionResult.error("Box cannot be nested");
}
- final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get(1));
- final String title = arg.get(0) == null ? "" : arg.get(0);
- diagram.boxStart(Display.getWithNewlines(title), color);
+ final String argTitle = arg.getLazzy("NAME", 0);
+ final String argColor = arg.get("COLOR", 0);
+
+ final String stereo = arg.get("STEREO", 0);
+ Stereotype stereotype = null;
+ if (stereo != null) {
+ final ISkinParam skinParam = diagram.getSkinParam();
+ stereotype = new Stereotype(stereo);
+ }
+
+ // final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(argColor);
+ Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet());
+ final String title = argTitle == null ? "" : argTitle;
+ diagram.boxStart(Display.getWithNewlines(title), colors.getColor(ColorType.BACK), stereotype);
return CommandExecutionResult.ok();
}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandDeactivateShort.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandDeactivateShort.java
index 1bfd31a..0575441 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandDeactivateShort.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandDeactivateShort.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -35,8 +35,10 @@
*/
package net.sourceforge.plantuml.sequencediagram.command;
+import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
+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;
@@ -50,16 +52,16 @@ public class CommandDeactivateShort extends SingleLineCommand2<SequenceDiagram>
super(getRegexConcat());
}
- static RegexConcat getRegexConcat() {
- return new RegexConcat(new RegexLeaf("^"), //
- new RegexLeaf("TYPE", "(deactivate)"), //
- new RegexLeaf("[%s]*"), //
- new RegexLeaf("$"));
+ static IRegex getRegexConcat() {
+ return RegexConcat.build(CommandDeactivateShort.class.getName(), RegexLeaf.start(), //
+ new RegexLeaf("TYPE", "deactivate"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ RegexLeaf.end());
}
@Override
- protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, RegexResult arg2) {
- Message message = sequenceDiagram.getActivatingMessage();
+ protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, LineLocation location, RegexResult arg2) {
+ Message message = (Message) sequenceDiagram.getActivatingMessage();
if (message == null) {
return CommandExecutionResult.error("Nothing to deactivate.");
}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandDelay.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandDelay.java
index 1529d40..a1ce653 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandDelay.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandDelay.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -35,23 +35,34 @@
*/
package net.sourceforge.plantuml.sequencediagram.command;
-import java.util.List;
-
+import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.command.CommandExecutionResult;
-import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+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.RegexOptional;
+import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
-public class CommandDelay extends SingleLineCommand<SequenceDiagram> {
+public class CommandDelay extends SingleLineCommand2<SequenceDiagram> {
public CommandDelay() {
- super("(?i)^(?:\\.{3}|\u2026)(?:(.*)(?:\\.{3}|\u2026))?$");
+ super(getRegexConcat());
+ }
+
+ static IRegex getRegexConcat() {
+ return RegexConcat.build(CommandDelay.class.getName(), RegexLeaf.start(), //
+ new RegexLeaf("(?:\\.{3}|\u2026)"), //
+ new RegexOptional(new RegexLeaf("LABEL", "(.*)(?:\\.{3}|\u2026)")), RegexLeaf.end()); //
}
@Override
- protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
- final Display strings = arg.get(0) == null ? Display.empty() : Display.getWithNewlines(arg.get(0));
- sequenceDiagram.delay(strings);
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) {
+ final Display strings = arg.get("LABEL", 0) == null ? Display.empty() : Display.getWithNewlines(arg.get(
+ "LABEL", 0));
+ diagram.delay(strings);
return CommandExecutionResult.ok();
}
}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandDivider.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandDivider.java
index f5ea3e7..41ee8d1 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandDivider.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandDivider.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -35,23 +35,35 @@
*/
package net.sourceforge.plantuml.sequencediagram.command;
-import java.util.List;
-
+import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.command.CommandExecutionResult;
-import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+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.Display;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
-public class CommandDivider extends SingleLineCommand<SequenceDiagram> {
+public class CommandDivider extends SingleLineCommand2<SequenceDiagram> {
public CommandDivider() {
- super("(?i)^==[%s]*(.*)[%s]*==$");
+ super(getRegexConcat());
+ }
+
+ static IRegex getRegexConcat() {
+ return RegexConcat.build(CommandDivider.class.getName(), RegexLeaf.start(), //
+ new RegexLeaf("=="), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf("LABEL", "(.*)"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf("=="), RegexLeaf.end()); //
}
@Override
- protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
- final Display strings = Display.getWithNewlines(arg.get(0));
- sequenceDiagram.divider(strings);
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) {
+ final Display strings = Display.getWithNewlines(arg.get("LABEL", 0));
+ diagram.divider(strings);
return CommandExecutionResult.ok();
}
}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowAny.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowAny.java
index 0da387f..235ba8d 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowAny.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowAny.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -35,13 +35,14 @@
*/
package net.sourceforge.plantuml.sequencediagram.command;
+import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
-import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.IRegex;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.HtmlColor;
@@ -58,16 +59,16 @@ import net.sourceforge.plantuml.skin.ArrowPart;
abstract class CommandExoArrowAny extends SingleLineCommand2<SequenceDiagram> {
- public CommandExoArrowAny(RegexConcat pattern) {
+ public CommandExoArrowAny(IRegex pattern) {
super(pattern);
}
@Override
- final protected CommandExecutionResult executeArg(SequenceDiagram diagram, RegexResult arg) {
+ final protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) {
final String body = arg.getLazzy("ARROW_BODYA", 0) + arg.getLazzy("ARROW_BODYB", 0);
final String dressing = arg.getLazzy("ARROW_DRESSING", 0);
- final Participant p = diagram.getOrCreateParticipant(StringUtils
- .eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("PARTICIPANT", 0)));
+ final Participant p = diagram.getOrCreateParticipant(
+ StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("PARTICIPANT", 0)));
final boolean sync = dressing.length() == 2;
final boolean dotted = body.contains("--");
@@ -81,18 +82,25 @@ abstract class CommandExoArrowAny extends SingleLineCommand2<SequenceDiagram> {
final boolean bothDirection = arg.get("ARROW_BOTHDRESSING", 0) != null;
- ArrowConfiguration config = bothDirection ? ArrowConfiguration.withDirectionBoth() : ArrowConfiguration
- .withDirectionNormal();
+ ArrowConfiguration config = bothDirection ? ArrowConfiguration.withDirectionBoth()
+ : ArrowConfiguration.withDirectionNormal();
if (dotted) {
config = config.withBody(ArrowBody.DOTTED);
}
if (sync) {
config = config.withHead(ArrowHead.ASYNC);
}
- config = config.withPart(getArrowPart(dressing));
- config = CommandArrow.applyStyle(arg.getLazzy("ARROW_STYLE", 0), config);
final MessageExoType messageExoType = getMessageExoType(arg);
+ config = config.withPart(getArrowPart(dressing, messageExoType));
+ config = CommandArrow.applyStyle(arg.getLazzy("ARROW_STYLE", 0), config);
+
+ final String activationSpec = arg.get("ACTIVATION", 0);
+
+ if (activationSpec != null && activationSpec.charAt(0) == '*') {
+ diagram.activate(p, LifeEventType.CREATE, null);
+ }
+
if (messageExoType == MessageExoType.TO_RIGHT || messageExoType == MessageExoType.TO_LEFT) {
if (containsSymbolExterior(arg, "o")) {
config = config.withDecoration2(ArrowDecoration.CIRCLE);
@@ -122,8 +130,8 @@ abstract class CommandExoArrowAny extends SingleLineCommand2<SequenceDiagram> {
// }
// }
- final MessageExo msg = new MessageExo(p, messageExoType, labels, config, diagram.getNextMessageNumber(),
- isShortArrow(arg));
+ final MessageExo msg = new MessageExo(diagram.getSkinParam().getCurrentStyleBuilder(), p, messageExoType,
+ labels, config, diagram.getNextMessageNumber(), isShortArrow(arg));
if (arg.get("URL", 0) != null) {
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
final Url urlLink = urlBuilder.getUrl(arg.get("URL", 0));
@@ -143,7 +151,22 @@ abstract class CommandExoArrowAny extends SingleLineCommand2<SequenceDiagram> {
final HtmlColor activationColor = diagram.getSkinParam().getIHtmlColorSet()
.getColorIfValid(arg.get("LIFECOLOR", 0));
- if (diagram.isAutoactivate() && (config.getHead() == ArrowHead.NORMAL || config.getHead() == ArrowHead.ASYNC)) {
+ if (activationSpec != null) {
+ switch (activationSpec.charAt(0)) {
+ case '+':
+ diagram.activate(p, LifeEventType.ACTIVATE, activationColor);
+ break;
+ case '-':
+ diagram.activate(p, LifeEventType.DEACTIVATE, null);
+ break;
+ case '!':
+ diagram.activate(p, LifeEventType.DESTROY, null);
+ break;
+ default:
+ break;
+ }
+ } else if (diagram.isAutoactivate()
+ && (config.getHead() == ArrowHead.NORMAL || config.getHead() == ArrowHead.ASYNC)) {
if (config.isDotted()) {
diagram.activate(p, LifeEventType.DEACTIVATE, null);
} else {
@@ -155,12 +178,18 @@ abstract class CommandExoArrowAny extends SingleLineCommand2<SequenceDiagram> {
return CommandExecutionResult.ok();
}
- private ArrowPart getArrowPart(String dressing) {
+ private ArrowPart getArrowPart(String dressing, MessageExoType messageExoType) {
if (dressing.contains("/")) {
- return ArrowPart.BOTTOM_PART;
+ if (messageExoType.getDirection() == 1) {
+ return ArrowPart.BOTTOM_PART;
+ }
+ return ArrowPart.TOP_PART;
}
if (dressing.contains("\\")) {
- return ArrowPart.TOP_PART;
+ if (messageExoType.getDirection() == 1) {
+ return ArrowPart.TOP_PART;
+ }
+ return ArrowPart.BOTTOM_PART;
}
return ArrowPart.FULL;
}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowLeft.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowLeft.java
index d83e534..1de4230 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowLeft.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowLeft.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -36,8 +36,10 @@
package net.sourceforge.plantuml.sequencediagram.command;
import net.sourceforge.plantuml.UrlBuilder;
+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.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexOr;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.sequencediagram.MessageExoType;
@@ -48,9 +50,9 @@ public class CommandExoArrowLeft extends CommandExoArrowAny {
super(getRegexConcat());
}
- static RegexConcat getRegexConcat() {
- return new RegexConcat(new RegexLeaf("^"), //
- new RegexLeaf("PARALLEL", "(&%s*)?"), //
+ static IRegex getRegexConcat() {
+ return RegexConcat.build(CommandExoArrowLeft.class.getName(), RegexLeaf.start(), //
+ new RegexLeaf("PARALLEL", "(&[%s]*)?"), //
new RegexLeaf("SHORT", "([?\\[\\]][ox]?)?"), //
new RegexOr( //
new RegexConcat( //
@@ -65,12 +67,21 @@ public class CommandExoArrowLeft extends CommandExoArrowAny {
new RegexLeaf("ARROW_STYLE2", CommandArrow.getColorOrStylePattern()), //
new RegexLeaf("ARROW_BODYA2", "(-+)"))), //
new RegexLeaf("ARROW_SUPPCIRCLE", "([ox][%s]+)?"), //
- new RegexLeaf("[%s]*"), //
+ RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("PARTICIPANT", "([\\p{L}0-9_.@]+|[%g][^%g]+[%g])"), //
- new RegexLeaf("URL", "[%s]*(" + UrlBuilder.getRegexp() + ")?"), //
- new RegexLeaf("[%s]*"), //
- new RegexLeaf("LABEL", "(?::[%s]*(.*))?"), //
- new RegexLeaf("$"));
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf("ACTIVATION", "(?:([+*!-]+)?)"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf("LIFECOLOR", "(?:(#\\w+)?)"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexOptional( //
+ new RegexConcat( //
+ new RegexLeaf(":"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf("LABEL", "(.*)") //
+ )), RegexLeaf.end());
}
@Override
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowRight.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowRight.java
index 018810d..791936e 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowRight.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowRight.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -36,8 +36,10 @@
package net.sourceforge.plantuml.sequencediagram.command;
import net.sourceforge.plantuml.UrlBuilder;
+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.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexOr;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.sequencediagram.MessageExoType;
@@ -48,11 +50,11 @@ public class CommandExoArrowRight extends CommandExoArrowAny {
super(getRegexConcat());
}
- static RegexConcat getRegexConcat() {
- return new RegexConcat(new RegexLeaf("^"), //
- new RegexLeaf("PARALLEL", "(&%s*)?"), //
+ static IRegex getRegexConcat() {
+ return RegexConcat.build(CommandExoArrowRight.class.getName(), RegexLeaf.start(), //
+ new RegexLeaf("PARALLEL", "(&[%s]*)?"), //
new RegexLeaf("PARTICIPANT", "([\\p{L}0-9_.@]+|[%g][^%g]+[%g])"), //
- new RegexLeaf("[%s]*"), //
+ RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("ARROW_SUPPCIRCLE", "([%s]+[ox])?"), //
new RegexOr( //
new RegexConcat( //
@@ -67,10 +69,19 @@ public class CommandExoArrowRight extends CommandExoArrowAny {
new RegexLeaf("ARROW_STYLE2", CommandArrow.getColorOrStylePattern()), //
new RegexLeaf("ARROW_BODYA2", "(-+)"))), //
new RegexLeaf("SHORT", "([ox]?[?\\]\\[])?"), //
- new RegexLeaf("URL", "[%s]*(" + UrlBuilder.getRegexp() + ")?"), //
- new RegexLeaf("[%s]*"), //
- new RegexLeaf("LABEL", "(?::[%s]*(.*))?"), //
- new RegexLeaf("$"));
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf("ACTIVATION", "(?:([+*!-]+)?)"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf("LIFECOLOR", "(?:(#\\w+)?)"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexOptional( //
+ new RegexConcat( //
+ new RegexLeaf(":"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf("LABEL", "(.*)") //
+ )), RegexLeaf.end());
}
@Override
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandFootbox.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandFootbox.java
index 9a549b1..881f777 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandFootbox.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandFootbox.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -35,22 +35,32 @@
*/
package net.sourceforge.plantuml.sequencediagram.command;
-import java.util.List;
-
+import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.command.CommandExecutionResult;
-import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+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.sequencediagram.SequenceDiagram;
-public class CommandFootbox extends SingleLineCommand<SequenceDiagram> {
+public class CommandFootbox extends SingleLineCommand2<SequenceDiagram> {
public CommandFootbox() {
- super("(?i)^(hide|show)?[%s]*footbox$");
+ super(getRegexConcat());
+ }
+
+ static IRegex getRegexConcat() {
+ return RegexConcat.build(CommandFootbox.class.getName(), RegexLeaf.start(), //
+ new RegexLeaf("TYPE", "(hide|show)?"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf("footbox"), RegexLeaf.end()); //
}
@Override
- protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
- final boolean footbox = arg.get(0).equalsIgnoreCase("show");
- sequenceDiagram.setShowFootbox(footbox);
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) {
+ final boolean footbox = arg.get("TYPE", 0).equalsIgnoreCase("show");
+ diagram.setShowFootbox(footbox);
return CommandExecutionResult.ok();
}
}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandFootboxOld.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandFootboxOld.java
index 068af73..9883407 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandFootboxOld.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandFootboxOld.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -35,22 +35,34 @@
*/
package net.sourceforge.plantuml.sequencediagram.command;
-import java.util.List;
-
+import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.command.CommandExecutionResult;
-import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+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.sequencediagram.SequenceDiagram;
-public class CommandFootboxOld extends SingleLineCommand<SequenceDiagram> {
+public class CommandFootboxOld extends SingleLineCommand2<SequenceDiagram> {
public CommandFootboxOld() {
- super("(?i)^footbox[%s]*(on|off)?[%s]*$");
+ super(getRegexConcat());
+ }
+
+ static IRegex getRegexConcat() {
+ return RegexConcat.build(CommandFootboxOld.class.getName(), RegexLeaf.start(), //
+ new RegexLeaf("footbox"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf("TYPE", "(on|off)?"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ RegexLeaf.end()); //
}
@Override
- protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
- final boolean footbox = arg.get(0).equalsIgnoreCase("on");
- sequenceDiagram.setShowFootbox(footbox);
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) {
+ final boolean footbox = arg.get("TYPE", 0).equalsIgnoreCase("on");
+ diagram.setShowFootbox(footbox);
return CommandExecutionResult.ok();
}
}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandGrouping.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandGrouping.java
index a4dea53..0413113 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandGrouping.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandGrouping.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -38,11 +38,14 @@ package net.sourceforge.plantuml.sequencediagram.command;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
+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.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.sequencediagram.GroupingType;
@@ -54,18 +57,20 @@ public class CommandGrouping extends SingleLineCommand2<SequenceDiagram> {
super(getRegexConcat());
}
- static RegexConcat getRegexConcat() {
- return new RegexConcat(//
- new RegexLeaf("^"), //
- new RegexLeaf("PARALLEL", "(&%s*)?"), //
+ static IRegex getRegexConcat() {
+ return RegexConcat.build(CommandGrouping.class.getName(), RegexLeaf.start(), //
+ new RegexLeaf("PARALLEL", "(&[%s]*)?"), //
new RegexLeaf("TYPE", "(opt|alt|loop|par|par2|break|critical|else|end|also|group)"), //
new RegexLeaf("COLORS", "((?<!else)(?<!also)(?<!end)#\\w+)?(?:[%s]+(#\\w+))?"), //
- new RegexLeaf("COMMENT", "(?:[%s]+(.*?))?"), //
- new RegexLeaf("$"));
+ new RegexOptional(//
+ new RegexConcat( //
+ RegexLeaf.spaceOneOrMore(), //
+ new RegexLeaf("COMMENT", "(.*?)") //
+ )), RegexLeaf.end());
}
@Override
- protected CommandExecutionResult executeArg(SequenceDiagram diagram, RegexResult arg) {
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) {
String type = StringUtils.goLowerCase(arg.get("TYPE", 0));
final HtmlColor backColorElement = diagram.getSkinParam().getIHtmlColorSet()
.getColorIfValid(arg.get("COLORS", 0));
@@ -85,9 +90,10 @@ public class CommandGrouping extends SingleLineCommand2<SequenceDiagram> {
}
}
}
-
+
final boolean parallel = arg.get("PARALLEL", 0) != null;
- final boolean result = diagram.grouping(type, comment, groupingType, backColorGeneral, backColorElement, parallel);
+ final boolean result = diagram.grouping(type, comment, groupingType, backColorGeneral, backColorElement,
+ parallel);
if (result == false) {
return CommandExecutionResult.error("Cannot create group");
}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandHSpace.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandHSpace.java
index 6517ae9..22610ea 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandHSpace.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandHSpace.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -35,26 +35,36 @@
*/
package net.sourceforge.plantuml.sequencediagram.command;
-import java.util.List;
-
+import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.command.CommandExecutionResult;
-import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+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.sequencediagram.SequenceDiagram;
-public class CommandHSpace extends SingleLineCommand<SequenceDiagram> {
+public class CommandHSpace extends SingleLineCommand2<SequenceDiagram> {
public CommandHSpace() {
- super("(?i)^\\|\\|(\\d+)?\\|+$");
+ super(getRegexConcat());
+ }
+
+ static IRegex getRegexConcat() {
+ return RegexConcat.build(CommandHSpace.class.getName(), RegexLeaf.start(), //
+ new RegexLeaf("\\|\\|"), //
+ new RegexLeaf("VALUE", "(\\d+)?"), //
+ new RegexLeaf("\\|+"), RegexLeaf.end()); //
}
@Override
- protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
- final String size = arg.get(0);
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) {
+ final String size = arg.get("VALUE", 0);
if (StringUtils.isNotEmpty(size)) {
- sequenceDiagram.hspace(Integer.parseInt(size));
+ diagram.hspace(Integer.parseInt(size));
} else {
- sequenceDiagram.hspace();
+ diagram.hspace();
}
return CommandExecutionResult.ok();
}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandIgnoreNewpage.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandIgnoreNewpage.java
index 761c067..ee06db1 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandIgnoreNewpage.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandIgnoreNewpage.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -35,21 +35,31 @@
*/
package net.sourceforge.plantuml.sequencediagram.command;
-import java.util.List;
-
+import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.command.CommandExecutionResult;
-import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+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.sequencediagram.SequenceDiagram;
-public class CommandIgnoreNewpage extends SingleLineCommand<SequenceDiagram> {
+public class CommandIgnoreNewpage extends SingleLineCommand2<SequenceDiagram> {
public CommandIgnoreNewpage() {
- super("(?i)^ignore[%s]*newpage$");
+ super(getRegexConcat());
+ }
+
+ static IRegex getRegexConcat() {
+ return RegexConcat.build(CommandIgnoreNewpage.class.getName(), RegexLeaf.start(), //
+ new RegexLeaf("ignore"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf("newpage"), RegexLeaf.end()); //
}
@Override
- protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
- sequenceDiagram.ignoreNewpage();
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) {
+ diagram.ignoreNewpage();
return CommandExecutionResult.ok();
}
}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandLinkAnchor.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandLinkAnchor.java
new file mode 100644
index 0000000..af364b3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandLinkAnchor.java
@@ -0,0 +1,71 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2020, Arnaud Roques
+ *
+ * Project Info: http://plantuml.com
+ *
+ * If you like this project or if you find it useful, you can support us at:
+ *
+ * http://plantuml.com/patreon (only 1$ per month!)
+ * http://plantuml.com/paypal
+ *
+ * This file is part of PlantUML.
+ *
+ * PlantUML is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * PlantUML distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ * USA.
+ *
+ *
+ * Original Author: Arnaud Roques
+ *
+ *
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import net.sourceforge.plantuml.LineLocation;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+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.sequencediagram.SequenceDiagram;
+
+public class CommandLinkAnchor extends SingleLineCommand2<SequenceDiagram> {
+
+ public CommandLinkAnchor() {
+ super(getRegexConcat());
+ }
+
+ static IRegex getRegexConcat() {
+ return RegexConcat.build(CommandLinkAnchor.class.getName(), RegexLeaf.start(), //
+ new RegexLeaf("ANCHOR1", "\\{([\\p{L}0-9_]+)\\}"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf("LINK", "\\<-\\>"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf("ANCHOR2", "\\{([\\p{L}0-9_]+)\\}"), //
+ RegexLeaf.spaceZeroOrMore(), new RegexLeaf("MESSAGE", "(?::[%s]*(.*))?"), RegexLeaf.end());
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) {
+ final String anchor1 = arg.get("ANCHOR1", 0);
+ final String anchor2 = arg.get("ANCHOR2", 0);
+ final String message = arg.get("MESSAGE", 0);
+ return diagram.linkAnchor(anchor1, anchor2, message);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandNewpage.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandNewpage.java
index 828cde3..81c6580 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandNewpage.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandNewpage.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -35,22 +35,38 @@
*/
package net.sourceforge.plantuml.sequencediagram.command;
-import java.util.List;
-
+import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.command.CommandExecutionResult;
-import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+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.RegexOptional;
+import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
-public class CommandNewpage extends SingleLineCommand<SequenceDiagram> {
+public class CommandNewpage extends SingleLineCommand2<SequenceDiagram> {
public CommandNewpage() {
- super("(?i)^@?newpage(?:(?:[%s]*:[%s]*|[%s]+)(.*[\\p{L}0-9_.].*))?$");
+ super(getRegexConcat());
+ }
+
+ static IRegex getRegexConcat() {
+ return RegexConcat.build(CommandNewpage.class.getName(), RegexLeaf.start(), //
+ new RegexLeaf("@?"), //
+ new RegexLeaf("newpage"), //
+ new RegexOptional( //
+ new RegexConcat( //
+ new RegexLeaf("(?:[%s]*:[%s]*|[%s]+)"), //
+ new RegexLeaf("LABEL", "(.*[\\p{L}0-9_.].*)") //
+ )), RegexLeaf.end()); //
}
@Override
- protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
- final Display strings = arg.get(0) == null ? Display.NULL : Display.getWithNewlines(arg.get(0));
+ protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, LineLocation location, RegexResult arg) {
+ final String label = arg.get("LABEL", 0);
+ final Display strings = label == null ? Display.NULL : Display.getWithNewlines(label);
sequenceDiagram.newpage(strings);
return CommandExecutionResult.ok();
}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipant.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipant.java
index f6034c4..e8f8b5e 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipant.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipant.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -37,6 +37,7 @@ package net.sourceforge.plantuml.sequencediagram.command;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
@@ -46,6 +47,7 @@ import net.sourceforge.plantuml.command.SingleLineCommand2;
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.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexOr;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Display;
@@ -59,12 +61,17 @@ import net.sourceforge.plantuml.ugraphic.UFont;
public abstract class CommandParticipant extends SingleLineCommand2<SequenceDiagram> {
- public CommandParticipant(RegexConcat pattern) {
+ public CommandParticipant(IRegex pattern) {
super(pattern);
}
- static RegexLeaf getOrderRegex() {
- return new RegexLeaf("ORDER", "(?:order[%s]+(-?\\d{1,7}))?");
+ static IRegex getOrderRegex() {
+ return new RegexOptional( //
+ new RegexConcat( //
+ new RegexLeaf("order"), //
+ RegexLeaf.spaceOneOrMore(), //
+ new RegexLeaf("ORDER", "(-?\\d{1,7})") //
+ ));
}
static IRegex getRegexType() {
@@ -75,7 +82,7 @@ public abstract class CommandParticipant extends SingleLineCommand2<SequenceDiag
}
@Override
- final protected CommandExecutionResult executeArg(SequenceDiagram diagram, RegexResult arg) {
+ final protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) {
final String code = arg.get("CODE", 0);
if (diagram.participantsContainsKey(code)) {
diagram.putParticipantInLast(code);
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA.java
index 6922443..3e4837a 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -36,8 +36,10 @@
package net.sourceforge.plantuml.sequencediagram.command;
import net.sourceforge.plantuml.UrlBuilder;
+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.RegexOptional;
import net.sourceforge.plantuml.graphic.color.ColorParser;
public class CommandParticipantA extends CommandParticipant {
@@ -46,21 +48,25 @@ public class CommandParticipantA extends CommandParticipant {
super(getRegexConcat());
}
- static RegexConcat getRegexConcat() {
- return new RegexConcat(new RegexLeaf("^"), //
+ static IRegex getRegexConcat() {
+ return RegexConcat.build(CommandParticipantA.class.getName(), RegexLeaf.start(), //
getRegexType(), //
- new RegexLeaf("[%s]+"), //
- new RegexLeaf("FULL", "(?:[%g]([^%g]+)[%g][%s]+as[%s]+)?"), //
+ RegexLeaf.spaceOneOrMore(), //
+ new RegexOptional( //
+ new RegexConcat( //
+ new RegexLeaf("FULL", "[%g]([^%g]+)[%g]"), //
+ RegexLeaf.spaceOneOrMore(), //
+ new RegexLeaf("as"), //
+ RegexLeaf.spaceOneOrMore() //
+ )), //
new RegexLeaf("CODE", "([\\p{L}0-9_.@]+)"), //
- new RegexLeaf("[%s]*"), //
+ RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
- new RegexLeaf("[%s]*"), //
+ RegexLeaf.spaceZeroOrMore(), //
getOrderRegex(), //
- new RegexLeaf("[%s]*"), //
+ RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
- new RegexLeaf("[%s]*"), //
- ColorParser.exp1(), //
- new RegexLeaf("$"));
+ RegexLeaf.spaceZeroOrMore(), //
+ ColorParser.exp1(), RegexLeaf.end());
}
-
}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA2.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA2.java
index 994fa99..6ee1fb2 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA2.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA2.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -36,6 +36,7 @@
package net.sourceforge.plantuml.sequencediagram.command;
import net.sourceforge.plantuml.UrlBuilder;
+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.graphic.color.ColorParser;
@@ -46,22 +47,23 @@ public class CommandParticipantA2 extends CommandParticipant {
super(getRegexConcat());
}
- static RegexConcat getRegexConcat() {
- return new RegexConcat(new RegexLeaf("^"), //
+ static IRegex getRegexConcat() {
+ return RegexConcat.build(CommandParticipantA2.class.getName(), RegexLeaf.start(), //
getRegexType(), //
- new RegexLeaf("[%s]+"), //
+ RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("CODE", "([\\p{L}0-9_.@]+)"), //
- new RegexLeaf("[%s]+as[%s]+"), //
+ RegexLeaf.spaceOneOrMore(), //
+ new RegexLeaf("as"), //
+ RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("FULL", "[%g]([^%g]+)[%g]"), //
- new RegexLeaf("[%s]*"), //
+ RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
- new RegexLeaf("[%s]*"), //
+ RegexLeaf.spaceZeroOrMore(), //
getOrderRegex(), //
- new RegexLeaf("[%s]*"), //
+ RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
- new RegexLeaf("[%s]*"), //
- ColorParser.exp1(), //
- new RegexLeaf("$"));
+ RegexLeaf.spaceZeroOrMore(), //
+ ColorParser.exp1(), RegexLeaf.end());
}
}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA3.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA3.java
index 289df7c..8b405da 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA3.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA3.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -36,6 +36,7 @@
package net.sourceforge.plantuml.sequencediagram.command;
import net.sourceforge.plantuml.UrlBuilder;
+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.graphic.color.ColorParser;
@@ -46,21 +47,23 @@ public class CommandParticipantA3 extends CommandParticipant {
super(getRegexConcat());
}
- static RegexConcat getRegexConcat() {
- return new RegexConcat(new RegexLeaf("^"), //
+ static IRegex getRegexConcat() {
+ return RegexConcat.build(CommandParticipantA3.class.getName(), RegexLeaf.start(), //
getRegexType(), //
- new RegexLeaf("[%s]+"), //
- new RegexLeaf("FULL", "([\\p{L}0-9_.@]+)[%s]+as[%s]+"), //
+ RegexLeaf.spaceOneOrMore(), //
+ new RegexLeaf("FULL", "([\\p{L}0-9_.@]+)"), //
+ RegexLeaf.spaceOneOrMore(), //
+ new RegexLeaf("as"), //
+ RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("CODE", "([\\p{L}0-9_.@]+)"), //
- new RegexLeaf("[%s]*"), //
+ RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
- new RegexLeaf("[%s]*"), //
+ RegexLeaf.spaceZeroOrMore(), //
getOrderRegex(), //
- new RegexLeaf("[%s]*"), //
+ RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
- new RegexLeaf("[%s]*"), //
- ColorParser.exp1(), //
- new RegexLeaf("$"));
+ RegexLeaf.spaceZeroOrMore(), //
+ ColorParser.exp1(), RegexLeaf.end());
}
}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA4.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA4.java
index 677d5f8..f363e2c 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA4.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA4.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -36,6 +36,7 @@
package net.sourceforge.plantuml.sequencediagram.command;
import net.sourceforge.plantuml.UrlBuilder;
+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.graphic.color.ColorParser;
@@ -46,21 +47,19 @@ public class CommandParticipantA4 extends CommandParticipant {
super(getRegexConcat());
}
- static RegexConcat getRegexConcat() {
- return new RegexConcat(new RegexLeaf("^"), //
+ static IRegex getRegexConcat() {
+ return RegexConcat.build(CommandParticipantA4.class.getName(), RegexLeaf.start(), //
getRegexType(), //
- new RegexLeaf("[%s]+"), //
+ RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("CODE", "[%g]([^%g]+)[%g]"), //
- new RegexLeaf("[%s]*"), //
+ RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
- new RegexLeaf("[%s]*"), //
+ RegexLeaf.spaceZeroOrMore(), //
getOrderRegex(), //
- new RegexLeaf("[%s]*"), //
+ RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
- new RegexLeaf("[%s]*"), //
- ColorParser.exp1(), //
- new RegexLeaf("$"));
+ RegexLeaf.spaceZeroOrMore(), //
+ ColorParser.exp1(), RegexLeaf.end());
}
-
}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandReferenceMultilinesOverSeveral.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandReferenceMultilinesOverSeveral.java
index 023b948..db89141 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandReferenceMultilinesOverSeveral.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandReferenceMultilinesOverSeveral.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -64,7 +64,8 @@ public class CommandReferenceMultilinesOverSeveral extends CommandMultilines<Seq
}
public CommandExecutionResult execute(final SequenceDiagram diagram, BlocLines lines) {
- final List<String> line0 = StringUtils.getSplit(getStartingPattern(), StringUtils.trin(lines.getFirst499()));
+ final List<String> line0 = StringUtils.getSplit(getStartingPattern(), lines.getFirst499().getTrimmed()
+ .getString());
final HtmlColor backColorElement = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get(0));
// final HtmlColor backColorGeneral = HtmlColorSet.getInstance().getColorIfValid(line0.get(1));
@@ -88,7 +89,8 @@ public class CommandReferenceMultilinesOverSeveral extends CommandMultilines<Seq
}
final HtmlColor backColorGeneral = null;
- final Reference ref = new Reference(p, u, strings, backColorGeneral, backColorElement);
+ final Reference ref = new Reference(p, u, strings, backColorGeneral, backColorElement, diagram.getSkinParam()
+ .getCurrentStyleBuilder());
diagram.addReference(ref);
return CommandExecutionResult.ok();
}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandReferenceOverSeveral.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandReferenceOverSeveral.java
index 81b35bd..3f31775 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandReferenceOverSeveral.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandReferenceOverSeveral.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -38,12 +38,14 @@ package net.sourceforge.plantuml.sequencediagram.command;
import java.util.ArrayList;
import java.util.List;
+import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.HtmlColor;
@@ -58,18 +60,23 @@ public class CommandReferenceOverSeveral extends SingleLineCommand2<SequenceDiag
}
private static RegexConcat getConcat() {
- return new RegexConcat(new RegexLeaf("^"), //
- new RegexLeaf("REF", "ref(#\\w+)?[%s]+over[%s]+"), //
+ return RegexConcat.build(CommandReferenceOverSeveral.class.getName(), RegexLeaf.start(), //
+ new RegexLeaf("ref"), //
+ new RegexLeaf("REF", "(#\\w+)?"), //
+ RegexLeaf.spaceOneOrMore(), //
+ new RegexLeaf("over"), //
+ RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("PARTS",
"(([\\p{L}0-9_.@]+|[%g][^%g]+[%g])([%s]*,[%s]*([\\p{L}0-9_.@]+|[%g][^%g]+[%g]))*)"), //
- new RegexLeaf("[%s]*:[%s]*"), //
- new RegexLeaf("URL", "(?:\\[\\[([^|]*)(?:\\|([^|]*))?\\]\\])?"), //
- new RegexLeaf("TEXT", "(.*)"), //
- new RegexLeaf("$"));
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf(":"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexOptional(new RegexLeaf("URL", "\\[\\[([^|]*)(?:\\|([^|]*))?\\]\\]")), //
+ new RegexLeaf("TEXT", "(.*)"), RegexLeaf.end());
}
@Override
- protected CommandExecutionResult executeArg(SequenceDiagram diagram, RegexResult arg) {
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) {
final HtmlColor backColorElement = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("REF", 0));
// final HtmlColor backColorGeneral = HtmlColorSet.getInstance().getColorIfValid(arg.get("REF").get(1));
@@ -91,7 +98,8 @@ public class CommandReferenceOverSeveral extends SingleLineCommand2<SequenceDiag
}
final HtmlColor backColorGeneral = null;
- final Reference ref = new Reference(p, u, strings, backColorGeneral, backColorElement);
+ final Reference ref = new Reference(p, u, strings, backColorGeneral, backColorElement, diagram.getSkinParam()
+ .getCurrentStyleBuilder());
diagram.addReference(ref);
return CommandExecutionResult.ok();
}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandReturn.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandReturn.java
index 50f21da..1f81d45 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandReturn.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandReturn.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -35,15 +35,22 @@
*/
package net.sourceforge.plantuml.sequencediagram.command;
+import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
+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.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColorSet;
+import net.sourceforge.plantuml.sequencediagram.AbstractMessage;
import net.sourceforge.plantuml.sequencediagram.EventWithDeactivate;
import net.sourceforge.plantuml.sequencediagram.LifeEventType;
import net.sourceforge.plantuml.sequencediagram.Message;
+import net.sourceforge.plantuml.sequencediagram.MessageExo;
+import net.sourceforge.plantuml.sequencediagram.MessageExoType;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
import net.sourceforge.plantuml.skin.ArrowBody;
import net.sourceforge.plantuml.skin.ArrowConfiguration;
@@ -54,22 +61,27 @@ public class CommandReturn extends SingleLineCommand2<SequenceDiagram> {
super(getRegexConcat());
}
- private static RegexConcat getRegexConcat() {
- return new RegexConcat(new RegexLeaf("^"), //
- new RegexLeaf("PARALLEL", "(&%s*)?"), //
- new RegexLeaf("[%s]*"), //
- new RegexLeaf("return[%s]*"), //
- new RegexLeaf("MESSAGE", "(.*)"), //
- new RegexLeaf("$"));
+ private static IRegex getRegexConcat() {
+ return RegexConcat.build(CommandReturn.class.getName(), RegexLeaf.start(), //
+ new RegexLeaf("PARALLEL", "(&[%s]*)?"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf("return"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexOptional( //
+ new RegexConcat( //
+ new RegexLeaf("COLOR", "(#\\w+)"), //
+ RegexLeaf.spaceOneOrMore() //
+ )), //
+ new RegexLeaf("MESSAGE", "(.*)"), RegexLeaf.end());
}
@Override
- protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, RegexResult arg) {
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) {
- Message message1 = sequenceDiagram.getActivatingMessage();
+ AbstractMessage message1 = diagram.getActivatingMessage();
boolean doDeactivation = true;
if (message1 == null) {
- final EventWithDeactivate last = sequenceDiagram.getLastEventWithDeactivate();
+ final EventWithDeactivate last = diagram.getLastEventWithDeactivate();
if (last instanceof Message == false) {
return CommandExecutionResult.error("Nowhere to return to.");
}
@@ -77,19 +89,30 @@ public class CommandReturn extends SingleLineCommand2<SequenceDiagram> {
doDeactivation = false;
}
- final ArrowConfiguration arrow = message1.getArrowConfiguration().withBody(ArrowBody.DOTTED);
+ ArrowConfiguration arrow = message1.getArrowConfiguration().withBody(ArrowBody.DOTTED);
+ final String color = arg.get("COLOR", 0);
+ if (color != null) {
+ arrow = arrow.withColor(HtmlColorSet.getInstance().getColorIfValid(color));
+ }
final Display display = Display.getWithNewlines(arg.get("MESSAGE", 0));
- final Message message2 = new Message(message1.getParticipant2(), message1.getParticipant1(), display, arrow,
- sequenceDiagram.getNextMessageNumber());
- final boolean parallel = arg.get("PARALLEL", 0) != null;
- if (parallel) {
- message2.goParallel();
+ final AbstractMessage message2;
+ if (message1 instanceof MessageExo) {
+ final MessageExo exo1 = (MessageExo) message1;
+ message2 = new MessageExo(diagram.getSkinParam().getCurrentStyleBuilder(), exo1.getParticipant(), exo1
+ .getType().reverse(), display, arrow, diagram.getNextMessageNumber(), false);
+ } else {
+ message2 = new Message(diagram.getSkinParam().getCurrentStyleBuilder(), message1.getParticipant2(),
+ message1.getParticipant1(), display, arrow, diagram.getNextMessageNumber());
+ final boolean parallel = arg.get("PARALLEL", 0) != null;
+ if (parallel) {
+ message2.goParallel();
+ }
}
- sequenceDiagram.addMessage(message2);
+ diagram.addMessage(message2);
if (doDeactivation) {
- final String error = sequenceDiagram.activate(message1.getParticipant2(), LifeEventType.DEACTIVATE, null);
+ final String error = diagram.activate(message1.getParticipant2(), LifeEventType.DEACTIVATE, null);
if (error != null) {
return CommandExecutionResult.error(error);
}
@@ -97,5 +120,4 @@ public class CommandReturn extends SingleLineCommand2<SequenceDiagram> {
return CommandExecutionResult.ok();
}
-
}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandSkin.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandSkin.java
index c257b02..8fd5dd5 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandSkin.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandSkin.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -35,24 +35,36 @@
*/
package net.sourceforge.plantuml.sequencediagram.command;
-import java.util.List;
+import java.io.IOException;
+import net.sourceforge.plantuml.LineLocation;
+import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.command.CommandExecutionResult;
-import net.sourceforge.plantuml.command.SingleLineCommand;
-import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+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;
-public class CommandSkin extends SingleLineCommand<SequenceDiagram> {
+public class CommandSkin extends SingleLineCommand2<UmlDiagram> {
public CommandSkin() {
- super("(?i)^skin[%s]+([\\w.]+)$");
+ super(getRegexConcat());
+ }
+
+ static IRegex getRegexConcat() {
+ return RegexConcat.build(CommandSkin.class.getName(), RegexLeaf.start(), //
+ new RegexLeaf("skin"), //
+ RegexLeaf.spaceOneOrMore(), //
+ new RegexLeaf("SKIN", "([\\w.]+)"), RegexLeaf.end()); //
}
@Override
- protected CommandExecutionResult executeArg(SequenceDiagram system, List<String> arg) {
- if (system.changeSkin(arg.get(0))) {
- return CommandExecutionResult.ok();
+ protected CommandExecutionResult executeArg(UmlDiagram diagram, LineLocation location, RegexResult arg) {
+ try {
+ return diagram.loadSkin(arg.get("SKIN", 0));
+ } catch (IOException e) {
+ return CommandExecutionResult.error("Skin read error");
}
- return CommandExecutionResult.error("Cannot change skin");
}
-
}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandUrl.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandUrl.java
index 8e636ae..06f81d0 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandUrl.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandUrl.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -35,27 +35,43 @@
*/
package net.sourceforge.plantuml.sequencediagram.command;
-import java.util.List;
-
+import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
import net.sourceforge.plantuml.command.CommandExecutionResult;
-import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+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.RegexOptional;
+import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.sequencediagram.Participant;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
-public class CommandUrl extends SingleLineCommand<SequenceDiagram> {
+public class CommandUrl extends SingleLineCommand2<SequenceDiagram> {
public CommandUrl() {
- super("(?i)^url[%s]*(?:of|for)?[%s]+([\\p{L}0-9_.@]+|[%g][^%g]+[%g])[%s]+(?:is)?[%s]*(" + UrlBuilder.getRegexp() + ")$");
+ super(getRegexConcat());
+ }
+
+ static IRegex getRegexConcat() {
+ return RegexConcat.build(CommandUrl.class.getName(), RegexLeaf.start(), //
+ new RegexLeaf("url"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexOptional(new RegexLeaf("of|for")), //
+ RegexLeaf.spaceOneOrMore(), //
+ new RegexLeaf("CODE", "([\\p{L}0-9_.@]+|[%g][^%g]+[%g])"), //
+ RegexLeaf.spaceOneOrMore(), //
+ new RegexOptional(new RegexLeaf("is")), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")"), RegexLeaf.end()); //
}
@Override
- protected CommandExecutionResult executeArg(SequenceDiagram diagram, List<String> arg) {
- final String code = arg.get(0);
- final String urlString = arg.get(1);
- // final String title = arg.get(2);
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) {
+ final String code = arg.get("CODE", 0);
+ final String urlString = arg.get("URL", 0);
final Participant p = diagram.getOrCreateParticipant(code);
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
final Url url = urlBuilder.getUrl(urlString);