mirror of
https://github.com/octoleo/plantuml.git
synced 2024-11-22 21:15:09 +00:00
wip
This commit is contained in:
parent
1e69806f44
commit
7f7cf2621f
@ -43,26 +43,35 @@ import java.util.Set;
|
|||||||
|
|
||||||
import net.sourceforge.plantuml.Url;
|
import net.sourceforge.plantuml.Url;
|
||||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||||
|
import net.sourceforge.plantuml.cucadiagram.Stereotype;
|
||||||
import net.sourceforge.plantuml.skin.ArrowConfiguration;
|
import net.sourceforge.plantuml.skin.ArrowConfiguration;
|
||||||
import net.sourceforge.plantuml.style.PName;
|
import net.sourceforge.plantuml.style.PName;
|
||||||
import net.sourceforge.plantuml.style.SName;
|
import net.sourceforge.plantuml.style.SName;
|
||||||
import net.sourceforge.plantuml.style.Style;
|
import net.sourceforge.plantuml.style.Style;
|
||||||
import net.sourceforge.plantuml.style.StyleBuilder;
|
import net.sourceforge.plantuml.style.StyleBuilder;
|
||||||
|
import net.sourceforge.plantuml.style.StyleSignature;
|
||||||
import net.sourceforge.plantuml.style.StyleSignatureBasic;
|
import net.sourceforge.plantuml.style.StyleSignatureBasic;
|
||||||
import net.sourceforge.plantuml.style.WithStyle;
|
import net.sourceforge.plantuml.style.WithStyle;
|
||||||
|
|
||||||
public abstract class AbstractMessage implements EventWithDeactivate, WithStyle {
|
public abstract class AbstractMessage implements EventWithDeactivate, WithStyle {
|
||||||
|
|
||||||
public Style[] getUsedStyles() {
|
private Stereotype stereotype;
|
||||||
Style style = getStyleSignature().getMergedStyle(styleBuilder);
|
|
||||||
if (style != null && arrowConfiguration.getColor() != null) {
|
public void getStereotype(Stereotype stereotype) {
|
||||||
style = style.eventuallyOverride(PName.LineColor, arrowConfiguration.getColor());
|
this.stereotype = stereotype;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final public Style[] getUsedStyles() {
|
||||||
|
Style style = getStyleSignature().getMergedStyle(styleBuilder);
|
||||||
|
if (style != null && arrowConfiguration.getColor() != null)
|
||||||
|
style = style.eventuallyOverride(PName.LineColor, arrowConfiguration.getColor());
|
||||||
|
|
||||||
return new Style[] { style };
|
return new Style[] { style };
|
||||||
}
|
}
|
||||||
|
|
||||||
public StyleSignatureBasic getStyleSignature() {
|
public StyleSignature getStyleSignature() {
|
||||||
return StyleSignatureBasic.of(SName.root, SName.element, SName.sequenceDiagram, SName.arrow);
|
return StyleSignatureBasic.of(SName.root, SName.element, SName.sequenceDiagram, SName.arrow)
|
||||||
|
.withTOBECHANGED(stereotype);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Display label;
|
private final Display label;
|
||||||
@ -103,25 +112,22 @@ public abstract class AbstractMessage implements EventWithDeactivate, WithStyle
|
|||||||
}
|
}
|
||||||
|
|
||||||
final public Url getUrl() {
|
final public Url getUrl() {
|
||||||
if (url == null) {
|
if (url == null)
|
||||||
for (Note n : noteOnMessages) {
|
for (Note n : noteOnMessages)
|
||||||
if (n.getUrl() != null) {
|
if (n.getUrl() != null)
|
||||||
return n.getUrl();
|
return n.getUrl();
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasUrl() {
|
public boolean hasUrl() {
|
||||||
for (Note n : noteOnMessages) {
|
for (Note n : noteOnMessages)
|
||||||
if (n.hasUrl()) {
|
if (n.hasUrl())
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
if (label != null && label.hasUrl())
|
||||||
if (label != null && label.hasUrl()) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
return getUrl() != null;
|
return getUrl() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,18 +137,15 @@ public abstract class AbstractMessage implements EventWithDeactivate, WithStyle
|
|||||||
public final boolean addLifeEvent(LifeEvent lifeEvent) {
|
public final boolean addLifeEvent(LifeEvent lifeEvent) {
|
||||||
lifeEvent.setMessage(this);
|
lifeEvent.setMessage(this);
|
||||||
lifeEventsType.add(lifeEvent.getType());
|
lifeEventsType.add(lifeEvent.getType());
|
||||||
if (lifeEventsType.size() == 1 && isActivate()) {
|
if (lifeEventsType.size() == 1 && isActivate())
|
||||||
firstIsActivate = true;
|
firstIsActivate = true;
|
||||||
}
|
|
||||||
|
|
||||||
if (lifeEvent.getType() == LifeEventType.ACTIVATE
|
if (lifeEvent.getType() == LifeEventType.ACTIVATE
|
||||||
&& noActivationAuthorized2.contains(lifeEvent.getParticipant())) {
|
&& noActivationAuthorized2.contains(lifeEvent.getParticipant()))
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (lifeEvent.getType() == LifeEventType.DEACTIVATE || lifeEvent.getType() == LifeEventType.DESTROY) {
|
if (lifeEvent.getType() == LifeEventType.DEACTIVATE || lifeEvent.getType() == LifeEventType.DESTROY)
|
||||||
noActivationAuthorized2.add(lifeEvent.getParticipant());
|
noActivationAuthorized2.add(lifeEvent.getParticipant());
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -176,9 +179,9 @@ public abstract class AbstractMessage implements EventWithDeactivate, WithStyle
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final Display getLabelNumbered() {
|
public final Display getLabelNumbered() {
|
||||||
if (getMessageNumber() == null) {
|
if (getMessageNumber() == null)
|
||||||
return getLabel();
|
return getLabel();
|
||||||
}
|
|
||||||
Display result = Display.empty();
|
Display result = Display.empty();
|
||||||
result = result.add(new MessageNumber(getMessageNumber()));
|
result = result.add(new MessageNumber(getMessageNumber()));
|
||||||
result = result.addAll(getLabel());
|
result = result.addAll(getLabel());
|
||||||
@ -195,9 +198,9 @@ public abstract class AbstractMessage implements EventWithDeactivate, WithStyle
|
|||||||
|
|
||||||
public final void setNote(Note note) {
|
public final void setNote(Note note) {
|
||||||
if (note.getPosition() != NotePosition.LEFT && note.getPosition() != NotePosition.RIGHT
|
if (note.getPosition() != NotePosition.LEFT && note.getPosition() != NotePosition.RIGHT
|
||||||
&& note.getPosition() != NotePosition.BOTTOM && note.getPosition() != NotePosition.TOP) {
|
&& note.getPosition() != NotePosition.BOTTOM && note.getPosition() != NotePosition.TOP)
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
|
||||||
note = note.withPosition(overrideNotePosition(note.getPosition()));
|
note = note.withPosition(overrideNotePosition(note.getPosition()));
|
||||||
this.noteOnMessages.add(note);
|
this.noteOnMessages.add(note);
|
||||||
}
|
}
|
||||||
@ -239,9 +242,9 @@ public abstract class AbstractMessage implements EventWithDeactivate, WithStyle
|
|||||||
|
|
||||||
public void setAnchor(String anchor) {
|
public void setAnchor(String anchor) {
|
||||||
this.anchor = anchor;
|
this.anchor = anchor;
|
||||||
if (anchor != null && anchor.startsWith("{")) {
|
if (anchor != null && anchor.startsWith("{"))
|
||||||
throw new IllegalArgumentException(anchor);
|
throw new IllegalArgumentException(anchor);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPart1Anchor(String anchor) {
|
public void setPart1Anchor(String anchor) {
|
||||||
|
@ -55,6 +55,7 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf;
|
|||||||
import net.sourceforge.plantuml.command.regex.RegexOr;
|
import net.sourceforge.plantuml.command.regex.RegexOr;
|
||||||
import net.sourceforge.plantuml.command.regex.RegexResult;
|
import net.sourceforge.plantuml.command.regex.RegexResult;
|
||||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||||
|
import net.sourceforge.plantuml.cucadiagram.Stereotype;
|
||||||
import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement;
|
import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement;
|
||||||
import net.sourceforge.plantuml.sequencediagram.LifeEventType;
|
import net.sourceforge.plantuml.sequencediagram.LifeEventType;
|
||||||
import net.sourceforge.plantuml.sequencediagram.Message;
|
import net.sourceforge.plantuml.sequencediagram.Message;
|
||||||
@ -117,6 +118,8 @@ public class CommandArrow extends SingleLineCommand2<SequenceDiagram> {
|
|||||||
RegexLeaf.spaceZeroOrMore(), //
|
RegexLeaf.spaceZeroOrMore(), //
|
||||||
new RegexLeaf("LIFECOLOR", "(?:(#\\w+)?)"), //
|
new RegexLeaf("LIFECOLOR", "(?:(#\\w+)?)"), //
|
||||||
RegexLeaf.spaceZeroOrMore(), //
|
RegexLeaf.spaceZeroOrMore(), //
|
||||||
|
new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), //
|
||||||
|
RegexLeaf.spaceZeroOrMore(), //
|
||||||
new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
|
new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
|
||||||
RegexLeaf.spaceZeroOrMore(), //
|
RegexLeaf.spaceZeroOrMore(), //
|
||||||
new RegexLeaf("MESSAGE", "(?::[%s]*(.*))?"), //
|
new RegexLeaf("MESSAGE", "(?::[%s]*(.*))?"), //
|
||||||
@ -129,13 +132,13 @@ public class CommandArrow extends SingleLineCommand2<SequenceDiagram> {
|
|||||||
final List<Participant> result = new ArrayList<>();
|
final List<Participant> result = new ArrayList<>();
|
||||||
for (String s : multicast.split("&")) {
|
for (String s : multicast.split("&")) {
|
||||||
s = s.trim();
|
s = s.trim();
|
||||||
if (s.length() == 0) {
|
if (s.length() == 0)
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
final Participant participant = system.getOrCreateParticipant(s);
|
final Participant participant = system.getOrCreateParticipant(s);
|
||||||
if (participant != null) {
|
if (participant != null)
|
||||||
result.add(participant);
|
result.add(participant);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return Collections.unmodifiableList(result);
|
return Collections.unmodifiableList(result);
|
||||||
}
|
}
|
||||||
@ -165,11 +168,10 @@ public class CommandArrow extends SingleLineCommand2<SequenceDiagram> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean contains(String string, String... totest) {
|
private boolean contains(String string, String... totest) {
|
||||||
for (String t : totest) {
|
for (String t : totest)
|
||||||
if (string.contains(t)) {
|
if (string.contains(t))
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,50 +230,48 @@ public class CommandArrow extends SingleLineCommand2<SequenceDiagram> {
|
|||||||
|
|
||||||
ArrowConfiguration config = hasDressing1 && hasDressing2 ? ArrowConfiguration.withDirectionBoth()
|
ArrowConfiguration config = hasDressing1 && hasDressing2 ? ArrowConfiguration.withDirectionBoth()
|
||||||
: ArrowConfiguration.withDirectionNormal();
|
: ArrowConfiguration.withDirectionNormal();
|
||||||
if (dotted) {
|
if (dotted)
|
||||||
config = config.withBody(ArrowBody.DOTTED);
|
config = config.withBody(ArrowBody.DOTTED);
|
||||||
}
|
|
||||||
if (sync) {
|
if (sync)
|
||||||
config = config.withHead(ArrowHead.ASYNC);
|
config = config.withHead(ArrowHead.ASYNC);
|
||||||
}
|
|
||||||
if (dressing2.contains("\\") || dressing1.contains("/")) {
|
if (dressing2.contains("\\") || dressing1.contains("/"))
|
||||||
config = config.withPart(ArrowPart.TOP_PART);
|
config = config.withPart(ArrowPart.TOP_PART);
|
||||||
}
|
|
||||||
if (dressing2.contains("/") || dressing1.contains("\\")) {
|
if (dressing2.contains("/") || dressing1.contains("\\"))
|
||||||
config = config.withPart(ArrowPart.BOTTOM_PART);
|
config = config.withPart(ArrowPart.BOTTOM_PART);
|
||||||
}
|
|
||||||
if (circleAtEnd) {
|
if (circleAtEnd)
|
||||||
config = config.withDecoration2(ArrowDecoration.CIRCLE);
|
config = config.withDecoration2(ArrowDecoration.CIRCLE);
|
||||||
}
|
|
||||||
if (circleAtStart) {
|
if (circleAtStart)
|
||||||
config = config.withDecoration1(ArrowDecoration.CIRCLE);
|
config = config.withDecoration1(ArrowDecoration.CIRCLE);
|
||||||
}
|
|
||||||
if (reverseDefine) {
|
if (reverseDefine) {
|
||||||
if (dressing1.contains("x")) {
|
if (dressing1.contains("x"))
|
||||||
config = config.withHead2(ArrowHead.CROSSX);
|
config = config.withHead2(ArrowHead.CROSSX);
|
||||||
}
|
|
||||||
if (dressing2.contains("x")) {
|
if (dressing2.contains("x"))
|
||||||
config = config.withHead1(ArrowHead.CROSSX);
|
config = config.withHead1(ArrowHead.CROSSX);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (dressing1.contains("x")) {
|
if (dressing1.contains("x"))
|
||||||
config = config.withHead1(ArrowHead.CROSSX);
|
config = config.withHead1(ArrowHead.CROSSX);
|
||||||
}
|
|
||||||
if (dressing2.contains("x")) {
|
if (dressing2.contains("x"))
|
||||||
config = config.withHead2(ArrowHead.CROSSX);
|
config = config.withHead2(ArrowHead.CROSSX);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
if (reverseDefine)
|
||||||
if (reverseDefine) {
|
|
||||||
config = config.reverseDefine();
|
config = config.reverseDefine();
|
||||||
}
|
|
||||||
|
|
||||||
config = applyStyle(diagram.getSkinParam().getThemeStyle(), arg.getLazzy("ARROW_STYLE", 0), config);
|
config = applyStyle(diagram.getSkinParam().getThemeStyle(), arg.getLazzy("ARROW_STYLE", 0), config);
|
||||||
|
|
||||||
final String activationSpec = arg.get("ACTIVATION", 0);
|
final String activationSpec = arg.get("ACTIVATION", 0);
|
||||||
|
|
||||||
if (activationSpec != null && activationSpec.charAt(0) == '*') {
|
if (activationSpec != null && activationSpec.charAt(0) == '*')
|
||||||
diagram.activate(p2, LifeEventType.CREATE, null);
|
diagram.activate(p2, LifeEventType.CREATE, null);
|
||||||
}
|
|
||||||
|
|
||||||
final String messageNumber = diagram.getNextMessageNumber();
|
final String messageNumber = diagram.getNextMessageNumber();
|
||||||
final Message msg = new Message(diagram.getSkinParam().getCurrentStyleBuilder(), p1, p2,
|
final Message msg = new Message(diagram.getSkinParam().getCurrentStyleBuilder(), p1, p2,
|
||||||
@ -284,34 +284,37 @@ public class CommandArrow extends SingleLineCommand2<SequenceDiagram> {
|
|||||||
msg.setUrl(urlLink);
|
msg.setUrl(urlLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean parallel = arg.get("PARALLEL", 0) != null;
|
if (arg.get("STEREOTYPE", 0) != null) {
|
||||||
if (parallel) {
|
final Stereotype stereotype = Stereotype.build(arg.get("STEREOTYPE", 0));
|
||||||
msg.goParallel();
|
msg.getStereotype(stereotype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final boolean parallel = arg.get("PARALLEL", 0) != null;
|
||||||
|
if (parallel)
|
||||||
|
msg.goParallel();
|
||||||
|
|
||||||
msg.setAnchor(arg.get("ANCHOR", 1));
|
msg.setAnchor(arg.get("ANCHOR", 1));
|
||||||
msg.setPart1Anchor(arg.get("PART1ANCHOR", 1));
|
msg.setPart1Anchor(arg.get("PART1ANCHOR", 1));
|
||||||
msg.setPart2Anchor(arg.get("PART2ANCHOR", 1));
|
msg.setPart2Anchor(arg.get("PART2ANCHOR", 1));
|
||||||
|
|
||||||
final String error = diagram.addMessage(msg);
|
final String error = diagram.addMessage(msg);
|
||||||
if (error != null) {
|
if (error != null)
|
||||||
return CommandExecutionResult.error(error);
|
return CommandExecutionResult.error(error);
|
||||||
}
|
|
||||||
final String s = arg.get("LIFECOLOR", 0);
|
final String s = arg.get("LIFECOLOR", 0);
|
||||||
|
|
||||||
final HColor activationColor = s == null ? null
|
final HColor activationColor = s == null ? null
|
||||||
: diagram.getSkinParam().getIHtmlColorSet().getColor(diagram.getSkinParam().getThemeStyle(), s);
|
: diagram.getSkinParam().getIHtmlColorSet().getColor(diagram.getSkinParam().getThemeStyle(), s);
|
||||||
|
|
||||||
if (activationSpec != null) {
|
if (activationSpec != null)
|
||||||
return manageActivations(activationSpec, diagram, p1, p2, activationColor);
|
return manageActivations(activationSpec, diagram, p1, p2, activationColor);
|
||||||
}
|
|
||||||
|
|
||||||
if (diagram.isAutoactivate() && (config.getHead() == ArrowHead.NORMAL || config.getHead() == ArrowHead.ASYNC)) {
|
if (diagram.isAutoactivate() && (config.getHead() == ArrowHead.NORMAL || config.getHead() == ArrowHead.ASYNC))
|
||||||
if (config.isDotted()) {
|
if (config.isDotted())
|
||||||
diagram.activate(p1, LifeEventType.DEACTIVATE, null);
|
diagram.activate(p1, LifeEventType.DEACTIVATE, null);
|
||||||
} else {
|
else
|
||||||
diagram.activate(p2, LifeEventType.ACTIVATE, activationColor);
|
diagram.activate(p2, LifeEventType.ACTIVATE, activationColor);
|
||||||
}
|
|
||||||
}
|
|
||||||
return CommandExecutionResult.ok();
|
return CommandExecutionResult.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,35 +346,31 @@ public class CommandArrow extends SingleLineCommand2<SequenceDiagram> {
|
|||||||
|
|
||||||
private int getLength(RegexResult arg2) {
|
private int getLength(RegexResult arg2) {
|
||||||
String sa = arg2.getLazzy("ARROW_BODYA", 0);
|
String sa = arg2.getLazzy("ARROW_BODYA", 0);
|
||||||
if (sa == null) {
|
if (sa == null)
|
||||||
sa = "";
|
sa = "";
|
||||||
}
|
|
||||||
String sb = arg2.getLazzy("ARROW_BODYB", 0);
|
String sb = arg2.getLazzy("ARROW_BODYB", 0);
|
||||||
if (sb == null) {
|
if (sb == null)
|
||||||
sb = "";
|
sb = "";
|
||||||
}
|
|
||||||
return sa.length() + sb.length();
|
return sa.length() + sb.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrowConfiguration applyStyle(ThemeStyle themeStyle, String arrowStyle, ArrowConfiguration config)
|
public static ArrowConfiguration applyStyle(ThemeStyle themeStyle, String arrowStyle, ArrowConfiguration config)
|
||||||
throws NoSuchColorException {
|
throws NoSuchColorException {
|
||||||
if (arrowStyle == null) {
|
if (arrowStyle == null)
|
||||||
return config;
|
return config;
|
||||||
}
|
|
||||||
final StringTokenizer st = new StringTokenizer(arrowStyle, ",");
|
final StringTokenizer st = new StringTokenizer(arrowStyle, ",");
|
||||||
while (st.hasMoreTokens()) {
|
while (st.hasMoreTokens()) {
|
||||||
final String s = st.nextToken();
|
final String s = st.nextToken();
|
||||||
if (s.equalsIgnoreCase("dashed")) {
|
if (s.equalsIgnoreCase("dashed")) {
|
||||||
config = config.withBody(ArrowBody.DOTTED);
|
config = config.withBody(ArrowBody.DOTTED);
|
||||||
// link.goDashed();
|
|
||||||
} else if (s.equalsIgnoreCase("bold")) {
|
} else if (s.equalsIgnoreCase("bold")) {
|
||||||
// link.goBold();
|
|
||||||
} else if (s.equalsIgnoreCase("dotted")) {
|
} else if (s.equalsIgnoreCase("dotted")) {
|
||||||
config = config.withBody(ArrowBody.DOTTED);
|
config = config.withBody(ArrowBody.DOTTED);
|
||||||
// link.goDotted();
|
|
||||||
} else if (s.equalsIgnoreCase("hidden")) {
|
} else if (s.equalsIgnoreCase("hidden")) {
|
||||||
config = config.withBody(ArrowBody.HIDDEN);
|
config = config.withBody(ArrowBody.HIDDEN);
|
||||||
// link.goHidden();
|
|
||||||
} else {
|
} else {
|
||||||
config = config.withColor(HColorSet.instance().getColor(themeStyle, s));
|
config = config.withColor(HColorSet.instance().getColor(themeStyle, s));
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,6 @@ package net.sourceforge.plantuml.style;
|
|||||||
|
|
||||||
public interface Styleable {
|
public interface Styleable {
|
||||||
|
|
||||||
public StyleSignatureBasic getStyleSignature();
|
public StyleSignature getStyleSignature();
|
||||||
|
|
||||||
}
|
}
|
@ -80,7 +80,7 @@ public class Version {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int beta() {
|
public static int beta() {
|
||||||
final int beta = 1;
|
final int beta = 2;
|
||||||
return beta;
|
return beta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user