1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-29 00:06:34 +00:00
This commit is contained in:
Arnaud Roques 2022-08-24 18:46:33 +02:00
parent b4d191a365
commit 7c576ed4ac
68 changed files with 736 additions and 667 deletions

View File

@ -85,6 +85,7 @@ public class Option {
private int ftpPort = -1; private int ftpPort = -1;
private String picowebBindAddress = null; private String picowebBindAddress = null;
private int picowebPort = -1; private int picowebPort = -1;
private boolean picowebEnableStop = false;
private boolean hideMetadata = false; private boolean hideMetadata = false;
private boolean checkMetadata = false; private boolean checkMetadata = false;
private int stdrpt = 0; private int stdrpt = 0;
@ -113,17 +114,17 @@ public class Option {
} }
public Option(String... arg) throws InterruptedException, IOException { public Option(String... arg) throws InterruptedException, IOException {
if (arg.length == 0) { if (arg.length == 0)
OptionFlags.getInstance().setGui(true); OptionFlags.getInstance().setGui(true);
}
initInclude(GraphvizUtils.getenvDefaultConfigFilename()); initInclude(GraphvizUtils.getenvDefaultConfigFilename());
for (int i = 0; i < arg.length; i++) { for (int i = 0; i < arg.length; i++) {
String s = arg[i]; String s = arg[i];
if (s.equalsIgnoreCase("-headless")) { if (s.equalsIgnoreCase("-headless")) {
// Useless because done in Run.java // Useless because done in Run.java
if (i != 0) { if (i != 0)
Log.error("Warning: -headless flag must be the first one in the command line"); Log.error("Warning: -headless flag must be the first one in the command line");
}
System.setProperty("java.awt.headless", "true"); System.setProperty("java.awt.headless", "true");
} else if (s.equalsIgnoreCase("-tsvg") || s.equalsIgnoreCase("-svg")) { } else if (s.equalsIgnoreCase("-tsvg") || s.equalsIgnoreCase("-svg")) {
setFileFormatOption(new FileFormatOption(FileFormat.SVG)); setFileFormatOption(new FileFormatOption(FileFormat.SVG));
@ -165,69 +166,69 @@ public class Option {
OptionFlags.getInstance().setOverwrite(true); OptionFlags.getInstance().setOverwrite(true);
} else if (s.equalsIgnoreCase("-output") || s.equalsIgnoreCase("-o")) { } else if (s.equalsIgnoreCase("-output") || s.equalsIgnoreCase("-o")) {
i++; i++;
if (i == arg.length) { if (i == arg.length)
continue; continue;
}
outputDir = new File(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i])); outputDir = new File(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]));
} else if (s.equalsIgnoreCase("-ofile")) { } else if (s.equalsIgnoreCase("-ofile")) {
i++; i++;
if (i == arg.length) { if (i == arg.length)
continue; continue;
}
outputFile = new File(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i])); outputFile = new File(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]));
} else if (s.equalsIgnoreCase("-graphvizdot") || s.equalsIgnoreCase("-graphviz_dot")) { } else if (s.equalsIgnoreCase("-graphvizdot") || s.equalsIgnoreCase("-graphviz_dot")) {
i++; i++;
if (i == arg.length) { if (i == arg.length)
continue; continue;
}
GraphvizUtils.setDotExecutable(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i])); GraphvizUtils.setDotExecutable(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]));
} else if (s.equalsIgnoreCase("-charset")) { } else if (s.equalsIgnoreCase("-charset")) {
i++; i++;
if (i == arg.length) { if (i == arg.length)
continue; continue;
}
charset = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]); charset = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]);
} else if (s.equalsIgnoreCase("-filename")) { } else if (s.equalsIgnoreCase("-filename")) {
i++; i++;
if (i == arg.length) { if (i == arg.length)
continue; continue;
}
filename = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]); filename = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]);
} else if (s.equalsIgnoreCase("-filedir")) { } else if (s.equalsIgnoreCase("-filedir")) {
i++; i++;
if (i == arg.length) { if (i == arg.length)
continue; continue;
}
fileDir = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]); fileDir = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]);
} else if (s.startsWith("-o") && s.length() > 3) { } else if (s.startsWith("-o") && s.length() > 3) {
s = s.substring(2); s = s.substring(2);
outputDir = new File(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(s)); outputDir = new File(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(s));
} else if (s.equalsIgnoreCase("-exclude") || s.equalsIgnoreCase("-x")) { } else if (s.equalsIgnoreCase("-exclude") || s.equalsIgnoreCase("-x")) {
i++; i++;
if (i == arg.length) { if (i == arg.length)
continue; continue;
}
excludes.add(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i])); excludes.add(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]));
} else if (s.equalsIgnoreCase("-nbthread") || s.equalsIgnoreCase("-nbthreads")) { } else if (s.equalsIgnoreCase("-nbthread") || s.equalsIgnoreCase("-nbthreads")) {
i++; i++;
if (i == arg.length) { if (i == arg.length)
continue; continue;
}
final String nb = arg[i]; final String nb = arg[i];
if ("auto".equalsIgnoreCase(nb)) { if ("auto".equalsIgnoreCase(nb))
this.nbThreads = defaultNbThreads(); this.nbThreads = defaultNbThreads();
} else if (nb.matches("\\d+")) { else if (nb.matches("\\d+"))
this.nbThreads = Integer.parseInt(nb); this.nbThreads = Integer.parseInt(nb);
}
} else if (s.equalsIgnoreCase("-timeout")) { } else if (s.equalsIgnoreCase("-timeout")) {
i++; i++;
if (i == arg.length) { if (i == arg.length)
continue; continue;
}
final String timeSeconds = arg[i]; final String timeSeconds = arg[i];
if (timeSeconds.matches("\\d+")) { if (timeSeconds.matches("\\d+"))
OptionFlags.getInstance().setTimeoutMs(Integer.parseInt(timeSeconds) * 1000L); OptionFlags.getInstance().setTimeoutMs(Integer.parseInt(timeSeconds) * 1000L);
}
} else if (s.equalsIgnoreCase("-failfast")) { } else if (s.equalsIgnoreCase("-failfast")) {
this.failfast = true; this.failfast = true;
} else if (s.equalsIgnoreCase("-failfast2")) { } else if (s.equalsIgnoreCase("-failfast2")) {
@ -238,15 +239,15 @@ public class Option {
this.checkOnly = true; this.checkOnly = true;
} else if (s.equalsIgnoreCase("-theme")) { } else if (s.equalsIgnoreCase("-theme")) {
i++; i++;
if (i == arg.length) { if (i == arg.length)
continue; continue;
}
this.config.add(0, "!theme " + arg[i]); this.config.add(0, "!theme " + arg[i]);
} else if (s.equalsIgnoreCase("-config")) { } else if (s.equalsIgnoreCase("-config")) {
i++; i++;
if (i == arg.length) { if (i == arg.length)
continue; continue;
}
initConfig(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i])); initConfig(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]));
} else if (s.startsWith("-I")) { } else if (s.startsWith("-I")) {
initInclude(s.substring(2)); initInclude(s.substring(2));
@ -261,9 +262,9 @@ public class Option {
pipe = true; pipe = true;
} else if (s.equalsIgnoreCase("-pipedelimitor")) { } else if (s.equalsIgnoreCase("-pipedelimitor")) {
i++; i++;
if (i == arg.length) { if (i == arg.length)
continue; continue;
}
pipeDelimitor = arg[i]; pipeDelimitor = arg[i];
} else if (s.equalsIgnoreCase("-pipemap")) { } else if (s.equalsIgnoreCase("-pipemap")) {
pipeMap = true; pipeMap = true;
@ -282,9 +283,9 @@ public class Option {
OptionFlags.getInstance().setExtractFromMetadata(true); OptionFlags.getInstance().setExtractFromMetadata(true);
} else if (s.equalsIgnoreCase("-logdata")) { } else if (s.equalsIgnoreCase("-logdata")) {
i++; i++;
if (i == arg.length) { if (i == arg.length)
continue; continue;
}
OptionFlags.getInstance() OptionFlags.getInstance()
.setLogData(new SFile(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]))); .setLogData(new SFile(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i])));
} else if (s.equalsIgnoreCase("-word")) { } else if (s.equalsIgnoreCase("-word")) {
@ -301,9 +302,9 @@ public class Option {
OptionPrint.printLicense(); OptionPrint.printLicense();
} else if (s.startsWith("-DPLANTUML_LIMIT_SIZE=")) { } else if (s.startsWith("-DPLANTUML_LIMIT_SIZE=")) {
final String v = s.substring("-DPLANTUML_LIMIT_SIZE=".length()); final String v = s.substring("-DPLANTUML_LIMIT_SIZE=".length());
if (v.matches("\\d+")) { if (v.matches("\\d+"))
System.setProperty("PLANTUML_LIMIT_SIZE", v); System.setProperty("PLANTUML_LIMIT_SIZE", v);
}
} else if (s.startsWith("-D")) { } else if (s.startsWith("-D")) {
manageDefine(s.substring(2)); manageDefine(s.substring(2));
} else if (s.startsWith("-S")) { } else if (s.startsWith("-S")) {
@ -371,24 +372,25 @@ public class Option {
stdrpt = 2; stdrpt = 2;
} else if (s.equalsIgnoreCase("-pipeimageindex")) { } else if (s.equalsIgnoreCase("-pipeimageindex")) {
i++; i++;
if (i == arg.length) { if (i == arg.length)
continue; continue;
}
final String nb = arg[i]; final String nb = arg[i];
if (nb.matches("\\d+")) { if (nb.matches("\\d+"))
this.imageIndex = Integer.parseInt(nb); this.imageIndex = Integer.parseInt(nb);
}
} else if (StringUtils.goLowerCase(s).startsWith("-ftp")) { } else if (StringUtils.goLowerCase(s).startsWith("-ftp")) {
final int x = s.indexOf(':'); final int x = s.indexOf(':');
if (x == -1) { if (x == -1)
this.ftpPort = 4242; this.ftpPort = 4242;
} else { else
this.ftpPort = Integer.parseInt(s.substring(x + 1)); this.ftpPort = Integer.parseInt(s.substring(x + 1));
}
} else if (StringUtils.goLowerCase(s).startsWith("-picoweb")) { } else if (StringUtils.goLowerCase(s).startsWith("-picoweb")) {
final String[] parts = s.split(":"); final String[] parts = s.split(":");
this.picowebPort = parts.length > 1 ? Integer.parseInt(parts[1]) : 8080; this.picowebPort = parts.length > 1 ? Integer.parseInt(parts[1]) : 8080;
this.picowebBindAddress = parts.length > 2 ? parts[2] : null; this.picowebBindAddress = parts.length > 2 ? parts[2] : null;
this.picowebEnableStop = StringUtils.goLowerCase(s).contains("stop");
} else if (s.startsWith("-c")) { } else if (s.startsWith("-c")) {
s = s.substring(2); s = s.substring(2);
config.add(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(s)); config.add(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(s));
@ -399,16 +401,16 @@ public class Option {
} }
public Stdrpt getStdrpt() { public Stdrpt getStdrpt() {
if (stdrpt == 1) { if (stdrpt == 1)
return new StdrptV1(); return new StdrptV1();
}
if (stdrpt == 2) { if (stdrpt == 2)
return new StdrptV2(); return new StdrptV2();
}
// Legacy case // Legacy case
if (isPipe() || isPipeMap() || isSyntax()) { if (isPipe() || isPipeMap() || isSyntax())
return new StdrptPipe0(); return new StdrptPipe0();
}
return new StdrptNull(); return new StdrptNull();
} }
@ -424,15 +426,19 @@ public class Option {
return picowebPort; return picowebPort;
} }
public boolean getPicowebEnableStop() {
return picowebEnableStop;
}
private void addInConfig(BufferedReader br) throws IOException { private void addInConfig(BufferedReader br) throws IOException {
if (br == null) { if (br == null)
return; return;
}
try { try {
String s = null; String s = null;
while ((s = br.readLine()) != null) { while ((s = br.readLine()) != null)
config.add(s); config.add(s);
}
} finally { } finally {
br.close(); br.close();
} }
@ -444,30 +450,29 @@ public class Option {
} }
private void initInclude(String filename) throws IOException { private void initInclude(String filename) throws IOException {
if (filename == null) { if (filename == null)
return; return;
}
if (filename.contains("*")) { if (filename.contains("*")) {
final FileGroup group = new FileGroup(filename, Collections.<String>emptyList(), null); final FileGroup group = new FileGroup(filename, Collections.<String>emptyList(), null);
for (File f : group.getFiles()) { for (File f : group.getFiles())
if (f.exists() && f.canRead()) { if (f.exists() && f.canRead())
addInConfig(new BufferedReader(new FileReader(f))); addInConfig(new BufferedReader(new FileReader(f)));
}
}
} else { } else {
final File f = new File(filename); final File f = new File(filename);
if (f.exists() && f.canRead()) { if (f.exists() && f.canRead())
addInConfig(new BufferedReader(new FileReader(f))); addInConfig(new BufferedReader(new FileReader(f)));
}
} }
} }
private void manageDefine(String s) { private void manageDefine(String s) {
final Pattern2 p = MyPattern.cmpile("^(\\w+)(?:=(.*))?$"); final Pattern2 p = MyPattern.cmpile("^(\\w+)(?:=(.*))?$");
final Matcher2 m = p.matcher(s); final Matcher2 m = p.matcher(s);
if (m.find()) { if (m.find())
define(m.group(1), m.group(2)); define(m.group(1), m.group(2));
}
} }
private void managePragma(String s) { private void managePragma(String s) {
@ -476,9 +481,9 @@ public class Option {
if (m.find()) { if (m.find()) {
final String var = m.group(1); final String var = m.group(1);
final String value = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m.group(2)); final String value = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m.group(2));
if (var != null && value != null) { if (var != null && value != null)
config.add("!pragma " + var + " " + value); config.add("!pragma " + var + " " + value);
}
} }
} }
@ -488,9 +493,9 @@ public class Option {
if (m.find()) { if (m.find()) {
final String var = m.group(1); final String var = m.group(1);
final String value = m.group(2); final String value = m.group(2);
if (var != null && value != null) { if (var != null && value != null)
config.add("skinparamlocked " + var + " " + value); config.add("skinparamlocked " + var + " " + value);
}
} }
} }
@ -514,9 +519,9 @@ public class Option {
final Defines result = Defines.createWithFileName(f); final Defines result = Defines.createWithFileName(f);
for (Map.Entry<String, String> ent : defines.entrySet()) { for (Map.Entry<String, String> ent : defines.entrySet()) {
String value = ent.getValue(); String value = ent.getValue();
if (value == null) { if (value == null)
value = ""; value = "";
}
result.define(ent.getKey(), Arrays.asList(value), false, null); result.define(ent.getKey(), Arrays.asList(value), false, null);
} }
return result; return result;
@ -537,9 +542,9 @@ public class Option {
public Defines getDefaultDefines() { public Defines getDefaultDefines() {
final Defines result = Defines.createEmpty(); final Defines result = Defines.createEmpty();
result.overrideFilename(filename); result.overrideFilename(filename);
for (Map.Entry<String, String> ent : defines.entrySet()) { for (Map.Entry<String, String> ent : defines.entrySet())
result.define(ent.getKey(), Arrays.asList(ent.getValue()), false, null); result.define(ent.getKey(), Arrays.asList(ent.getValue()), false, null);
}
return result; return result;
} }
@ -585,12 +590,12 @@ public class Option {
} }
public FileFormatOption getFileFormatOption() { public FileFormatOption getFileFormatOption() {
if (debugsvek) { if (debugsvek)
fileFormatOption.setDebugSvek(true); fileFormatOption.setDebugSvek(true);
}
if (hideMetadata) { if (hideMetadata)
fileFormatOption.hideMetadata(); fileFormatOption.hideMetadata();
}
return fileFormatOption; return fileFormatOption;
} }
@ -690,11 +695,8 @@ public class Option {
return preprocessorOutput; return preprocessorOutput;
} }
// public final void setPreprocessorOutput(boolean preprocessorOutput) {
// this.preprocessorOutput = preprocessorOutput;
// }
public String getFileDir() { public String getFileDir() {
return fileDir; return fileDir;
} }
} }

View File

@ -334,7 +334,7 @@ public class Run {
} }
private static void goPicoweb(Option option) throws IOException { private static void goPicoweb(Option option) throws IOException {
PicoWebServer.startServer(option.getPicowebPort(), option.getPicowebBindAddress()); PicoWebServer.startServer(option.getPicowebPort(), option.getPicowebBindAddress(), option.getPicowebEnableStop());
} }
public static void printFonts() { public static void printFonts() {

View File

@ -87,12 +87,6 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram,
return pragma; return pragma;
} }
// public TitledDiagram(ThemeStyle style, UmlSource source, UmlDiagramType type) {
// super(source);
// this.type = type;
// this.skinParam = SkinParam.create(type, style);
// }
public TitledDiagram(ThemeStyle style, UmlSource source, UmlDiagramType type, ISkinSimple orig) { public TitledDiagram(ThemeStyle style, UmlSource source, UmlDiagramType type, ISkinSimple orig) {
super(source); super(source);
this.type = type; this.type = type;

View File

@ -51,6 +51,7 @@ import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg;
import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType; import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement; import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement;
@ -70,15 +71,16 @@ public class CommandIf extends SingleLineCommand2<ActivityDiagram> {
new RegexLeaf("BAR", "(?:==+)[%s]*([%pLN_.]+)[%s]*(?:==+)"), // new RegexLeaf("BAR", "(?:==+)[%s]*([%pLN_.]+)[%s]*(?:==+)"), //
new RegexLeaf("QUOTED", "[%g]([^%g]+)[%g](?:[%s]+as[%s]+([%pLN_.]+))?"))), // new RegexLeaf("QUOTED", "[%g]([^%g]+)[%g](?:[%s]+as[%s]+([%pLN_.]+))?"))), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
//new RegexOptional(new RegexLeaf("ARROW", "([=-]+(?:(left|right|up|down|le?|ri?|up?|do?)(?=[-=.]))?[=-]*\\>)")), // // new RegexOptional(new RegexLeaf("ARROW",
new RegexOptional(new RegexConcat( // // "([=-]+(?:(left|right|up|down|le?|ri?|up?|do?)(?=[-=.]))?[=-]*\\>)")), //
new RegexOptional(new RegexConcat( //
new RegexLeaf("ARROW_BODY1", "([-.]+)"), // new RegexLeaf("ARROW_BODY1", "([-.]+)"), //
new RegexLeaf("ARROW_STYLE1", "(?:\\[(" + CommandLinkElement.LINE_STYLE + ")\\])?"), // new RegexLeaf("ARROW_STYLE1", "(?:\\[(" + CommandLinkElement.LINE_STYLE + ")\\])?"), //
new RegexLeaf("ARROW_DIRECTION", "(\\*|left|right|up|down|le?|ri?|up?|do?)?"), // new RegexLeaf("ARROW_DIRECTION", "(\\*|left|right|up|down|le?|ri?|up?|do?)?"), //
new RegexLeaf("ARROW_STYLE2", "(?:\\[(" + CommandLinkElement.LINE_STYLE + ")\\])?"), // new RegexLeaf("ARROW_STYLE2", "(?:\\[(" + CommandLinkElement.LINE_STYLE + ")\\])?"), //
new RegexLeaf("ARROW_BODY2", "([-.]*)"), // new RegexLeaf("ARROW_BODY2", "([-.]*)"), //
new RegexLeaf("\\>") // new RegexLeaf("\\>") //
)), // )), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexOptional(new RegexLeaf("BRACKET", "\\[([^\\]*]+[^\\]]*)\\]")), // new RegexOptional(new RegexLeaf("BRACKET", "\\[([^\\]*]+[^\\]]*)\\]")), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
@ -93,9 +95,8 @@ public class CommandIf extends SingleLineCommand2<ActivityDiagram> {
@Override @Override
protected CommandExecutionResult executeArg(ActivityDiagram diagram, LineLocation location, RegexResult arg) { protected CommandExecutionResult executeArg(ActivityDiagram diagram, LineLocation location, RegexResult arg) {
final IEntity entity1 = CommandLinkActivity.getEntity(diagram, arg, true); final IEntity entity1 = CommandLinkActivity.getEntity(diagram, arg, true);
if (entity1 == null) { if (entity1 == null)
return CommandExecutionResult.error("No if possible at this point"); return CommandExecutionResult.error("No if possible at this point");
}
final String ifCode; final String ifCode;
final String ifLabel; final String ifLabel;
@ -123,14 +124,15 @@ public class CommandIf extends SingleLineCommand2<ActivityDiagram> {
final IEntity branch = diagram.getCurrentContext().getBranch(); final IEntity branch = diagram.getCurrentContext().getBranch();
final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(arg.get("BRACKET", 0)), lenght);
Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), entity1, branch, Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), entity1, branch,
new LinkType(LinkDecor.ARROW, LinkDecor.NONE), Display.getWithNewlines(arg.get("BRACKET", 0)), lenght, null, ifLabel, new LinkType(LinkDecor.ARROW, LinkDecor.NONE), linkArg.withQualifier(null, ifLabel)
diagram.getLabeldistance(), diagram.getLabelangle()); .withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle()));
if (arg.get("ARROW", 0) != null) { if (arg.get("ARROW", 0) != null) {
final Direction direction = StringUtils.getArrowDirection(arg.get("ARROW", 0)); final Direction direction = StringUtils.getArrowDirection(arg.get("ARROW", 0));
if (direction == Direction.LEFT || direction == Direction.UP) { if (direction == Direction.LEFT || direction == Direction.UP)
link = link.getInv(); link = link.getInv();
}
} }
link.applyStyle(diagram.getSkinParam().getThemeStyle(), arg.getLazzy("ARROW_STYLE", 0)); link.applyStyle(diagram.getSkinParam().getThemeStyle(), arg.getLazzy("ARROW_STYLE", 0));

View File

@ -60,6 +60,7 @@ import net.sourceforge.plantuml.cucadiagram.ILeaf;
import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg;
import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType; import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy;
@ -125,12 +126,12 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
protected CommandExecutionResult executeArg(ActivityDiagram diagram, LineLocation location, RegexResult arg) protected CommandExecutionResult executeArg(ActivityDiagram diagram, LineLocation location, RegexResult arg)
throws NoSuchColorException { throws NoSuchColorException {
final IEntity entity1 = getEntity(diagram, arg, true); final IEntity entity1 = getEntity(diagram, arg, true);
if (entity1 == null) { if (entity1 == null)
return CommandExecutionResult.error("No such activity"); return CommandExecutionResult.error("No such activity");
}
if (arg.get("STEREOTYPE", 0) != null) { if (arg.get("STEREOTYPE", 0) != null)
entity1.setStereotype(Stereotype.build(arg.get("STEREOTYPE", 0))); entity1.setStereotype(Stereotype.build(arg.get("STEREOTYPE", 0)));
}
if (arg.get("BACKCOLOR", 0) != null) { if (arg.get("BACKCOLOR", 0) != null) {
String s = arg.get("BACKCOLOR", 0); String s = arg.get("BACKCOLOR", 0);
entity1.setSpecificColorTOBEREMOVED(ColorType.BACK, entity1.setSpecificColorTOBEREMOVED(ColorType.BACK,
@ -138,17 +139,16 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
} }
final IEntity entity2 = getEntity(diagram, arg, false); final IEntity entity2 = getEntity(diagram, arg, false);
if (entity2 == null) { if (entity2 == null)
return CommandExecutionResult.error("No such activity"); return CommandExecutionResult.error("No such activity");
}
if (arg.get("BACKCOLOR2", 0) != null) { if (arg.get("BACKCOLOR2", 0) != null) {
String s = arg.get("BACKCOLOR2", 0); String s = arg.get("BACKCOLOR2", 0);
entity2.setSpecificColorTOBEREMOVED(ColorType.BACK, entity2.setSpecificColorTOBEREMOVED(ColorType.BACK,
diagram.getSkinParam().getIHtmlColorSet().getColor(diagram.getSkinParam().getThemeStyle(), s)); diagram.getSkinParam().getIHtmlColorSet().getColor(diagram.getSkinParam().getThemeStyle(), s));
} }
if (arg.get("STEREOTYPE2", 0) != null) { if (arg.get("STEREOTYPE2", 0) != null)
entity2.setStereotype(Stereotype.build(arg.get("STEREOTYPE2", 0))); entity2.setStereotype(Stereotype.build(arg.get("STEREOTYPE2", 0)));
}
final Display linkLabel = Display.getWithNewlines(arg.get("BRACKET", 0)); final Display linkLabel = Display.getWithNewlines(arg.get("BRACKET", 0));
@ -158,24 +158,22 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
final String arrow = StringUtils.manageArrowForCuca(arrowBody1 + arrowDirection + arrowBody2 + ">"); final String arrow = StringUtils.manageArrowForCuca(arrowBody1 + arrowDirection + arrowBody2 + ">");
int lenght = arrow.length() - 1; int lenght = arrow.length() - 1;
if (arrowDirection.contains("*")) { if (arrowDirection.contains("*"))
lenght = 2; lenght = 2;
}
LinkType type = new LinkType(LinkDecor.ARROW, LinkDecor.NONE); LinkType type = new LinkType(LinkDecor.ARROW, LinkDecor.NONE);
if ((arrowBody1 + arrowBody2).contains(".")) { if ((arrowBody1 + arrowBody2).contains("."))
type = type.goDotted(); type = type.goDotted();
}
Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), entity1, entity2, type, linkLabel, final LinkArg linkArg = LinkArg.build(linkLabel, lenght, diagram.getSkinParam().classAttributeIconSize() > 0);
lenght); Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), entity1, entity2, type, linkArg);
if (arrowDirection.contains("*")) { if (arrowDirection.contains("*"))
link.setConstraint(false); link.setConstraint(false);
}
final Direction direction = StringUtils.getArrowDirection(arrowBody1 + arrowDirection + arrowBody2 + ">"); final Direction direction = StringUtils.getArrowDirection(arrowBody1 + arrowDirection + arrowBody2 + ">");
if (direction == Direction.LEFT || direction == Direction.UP) { if (direction == Direction.LEFT || direction == Direction.UP)
link = link.getInv(); link = link.getInv();
}
if (arg.get("URL", 0) != null) { if (arg.get("URL", 0) != null) {
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), UrlMode.STRICT); final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), UrlMode.STRICT);
final Url urlLink = urlBuilder.getUrl(arg.get("URL", 0)); final Url urlLink = urlBuilder.getUrl(arg.get("URL", 0));
@ -193,23 +191,23 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
final String suf = start ? "" : "2"; final String suf = start ? "" : "2";
final String openBracket2 = arg.get("OPENBRACKET" + suf, 0); final String openBracket2 = arg.get("OPENBRACKET" + suf, 0);
if (openBracket2 != null) { if (openBracket2 != null)
return diagram.createInnerActivity(); return diagram.createInnerActivity();
}
if (arg.get("STAR" + suf, 0) != null) { if (arg.get("STAR" + suf, 0) != null) {
final String suppId = arg.get("STAR" + suf, 1); final String suppId = arg.get("STAR" + suf, 1);
if (start) { if (start) {
if (suppId != null) { if (suppId != null)
diagram.getStart().setTop(true); diagram.getStart().setTop(true);
}
return diagram.getStart(); return diagram.getStart();
} }
return diagram.getEnd(suppId); return diagram.getEnd(suppId);
} }
String partition = arg.get("PARTITION" + suf, 0); String partition = arg.get("PARTITION" + suf, 0);
if (partition != null) { if (partition != null)
partition = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(partition); partition = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(partition);
}
final String idShort = arg.get("CODE" + suf, 0); final String idShort = arg.get("CODE" + suf, 0);
if (idShort != null) { if (idShort != null) {
if (partition != null) { if (partition != null) {
@ -229,9 +227,9 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
result = diagram.getOrCreate(ident, code, Display.getWithNewlines(code), type); result = diagram.getOrCreate(ident, code, Display.getWithNewlines(code), type);
} else } else
result = diagram.getOrCreate(ident, code, Display.getWithNewlines(code), type); result = diagram.getOrCreate(ident, code, Display.getWithNewlines(code), type);
if (partition != null) { if (partition != null)
diagram.endGroup(); diagram.endGroup();
}
return result; return result;
} }
final String bar = arg.get("BAR" + suf, 0); final String bar = arg.get("BAR" + suf, 0);
@ -240,9 +238,9 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
final Code codeBar = diagram.V1972() ? identBar : diagram.buildCode(bar); final Code codeBar = diagram.V1972() ? identBar : diagram.buildCode(bar);
if (diagram.V1972()) { if (diagram.V1972()) {
final ILeaf result = diagram.getLeafVerySmart(identBar); final ILeaf result = diagram.getLeafVerySmart(identBar);
if (result != null) { if (result != null)
return result; return result;
}
} }
return diagram.getOrCreate(identBar, codeBar, Display.getWithNewlines(bar), LeafType.SYNCHRO_BAR); return diagram.getOrCreate(identBar, codeBar, Display.getWithNewlines(bar), LeafType.SYNCHRO_BAR);
} }
@ -261,9 +259,9 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
: getTypeIfExisting(diagram, quotedCode); : getTypeIfExisting(diagram, quotedCode);
final IEntity result = diagram.getOrCreate(quotedIdent, quotedCode, Display.getWithNewlines(quoted.get(0)), final IEntity result = diagram.getOrCreate(quotedIdent, quotedCode, Display.getWithNewlines(quoted.get(0)),
type); type);
if (partition != null) { if (partition != null)
diagram.endGroup(); diagram.endGroup();
}
return result; return result;
} }
final String quoteInvisibleString = arg.get("QUOTED_INVISIBLE" + suf, 0); final String quoteInvisibleString = arg.get("QUOTED_INVISIBLE" + suf, 0);
@ -278,35 +276,33 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
final Code quotedInvisible = diagram.V1972() ? identInvisible : diagram.buildCode(quoteInvisibleString); final Code quotedInvisible = diagram.V1972() ? identInvisible : diagram.buildCode(quoteInvisibleString);
final IEntity result = diagram.getOrCreate(identInvisible, quotedInvisible, final IEntity result = diagram.getOrCreate(identInvisible, quotedInvisible,
Display.getWithNewlines(quotedInvisible), LeafType.ACTIVITY); Display.getWithNewlines(quotedInvisible), LeafType.ACTIVITY);
if (partition != null) { if (partition != null)
diagram.endGroup(); diagram.endGroup();
}
return result; return result;
} }
final String first = arg.get("FIRST" + suf, 0); final String first = arg.get("FIRST" + suf, 0);
if (first == null) { if (first == null)
return diagram.getLastEntityConsulted(); return diagram.getLastEntityConsulted();
}
return null; return null;
} }
private static LeafType getTypeIfExistingSmart(ActivityDiagram system, Ident ident) { private static LeafType getTypeIfExistingSmart(ActivityDiagram system, Ident ident) {
final IEntity ent = system.getLeafSmart(ident); final IEntity ent = system.getLeafSmart(ident);
if (ent != null) { if (ent != null)
if (ent.getLeafType() == LeafType.BRANCH) { if (ent.getLeafType() == LeafType.BRANCH)
return LeafType.BRANCH; return LeafType.BRANCH;
}
}
return LeafType.ACTIVITY; return LeafType.ACTIVITY;
} }
private static LeafType getTypeIfExisting(ActivityDiagram system, Code code) { private static LeafType getTypeIfExisting(ActivityDiagram system, Code code) {
if (system.leafExist(code)) { if (system.leafExist(code)) {
final IEntity ent = system.getLeaf(code); final IEntity ent = system.getLeaf(code);
if (ent.getLeafType() == LeafType.BRANCH) { if (ent.getLeafType() == LeafType.BRANCH)
return LeafType.BRANCH; return LeafType.BRANCH;
}
} }
return LeafType.ACTIVITY; return LeafType.ACTIVITY;
} }

View File

@ -64,6 +64,7 @@ import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg;
import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType; import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy;
@ -121,13 +122,12 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString());
final IEntity entity1 = CommandLinkActivity.getEntity(diagram, line0, true); final IEntity entity1 = CommandLinkActivity.getEntity(diagram, line0, true);
if (entity1 == null) { if (entity1 == null)
return CommandExecutionResult.error("No such entity"); return CommandExecutionResult.error("No such entity");
}
if (line0.get("STEREOTYPE", 0) != null) { if (line0.get("STEREOTYPE", 0) != null)
entity1.setStereotype(Stereotype.build(line0.get("STEREOTYPE", 0))); entity1.setStereotype(Stereotype.build(line0.get("STEREOTYPE", 0)));
}
final String stringColor = line0.get("BACKCOLOR", 0); final String stringColor = line0.get("BACKCOLOR", 0);
if (stringColor != null) { if (stringColor != null) {
entity1.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet() entity1.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet()
@ -149,22 +149,22 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
i++; i++;
if (i == 1 && urlActivity == null) { if (i == 1 && urlActivity == null) {
urlActivity = extractUrl(diagram, cs); urlActivity = extractUrl(diagram, cs);
if (urlActivity != null) { if (urlActivity != null)
continue; continue;
}
} }
sb.append(cs.getString()); sb.append(cs.getString());
if (i < lines.size() - 2) { if (i < lines.size() - 2)
sb.append(BackSlash.BS_BS_N); sb.append(BackSlash.BS_BS_N);
}
} }
final List<String> lineLast = StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()), final List<String> lineLast = StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()),
lines.getLast().getString()); lines.getLast().getString());
if (StringUtils.isNotEmpty(lineLast.get(0))) { if (StringUtils.isNotEmpty(lineLast.get(0))) {
if (sb.length() > 0 && sb.toString().endsWith(BackSlash.BS_BS_N) == false) { if (sb.length() > 0 && sb.toString().endsWith(BackSlash.BS_BS_N) == false)
sb.append(BackSlash.BS_BS_N); sb.append(BackSlash.BS_BS_N);
}
sb.append(lineLast.get(0)); sb.append(lineLast.get(0));
} }
@ -184,20 +184,18 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
final Ident ident = diagram.buildLeafIdent(idShort); final Ident ident = diagram.buildLeafIdent(idShort);
final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort); final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort);
final IEntity entity2 = diagram.getOrCreate(ident, code, Display.getWithNewlines(display), LeafType.ACTIVITY); final IEntity entity2 = diagram.getOrCreate(ident, code, Display.getWithNewlines(display), LeafType.ACTIVITY);
if (entity2 == null) { if (entity2 == null)
return CommandExecutionResult.error("No such entity"); return CommandExecutionResult.error("No such entity");
}
if (partition != null) { if (partition != null)
diagram.endGroup(); diagram.endGroup();
}
if (urlActivity != null) {
entity2.addUrl(urlActivity);
}
if (lineLast.get(2) != null) { if (urlActivity != null)
entity2.addUrl(urlActivity);
if (lineLast.get(2) != null)
entity2.setStereotype(Stereotype.build(lineLast.get(2))); entity2.setStereotype(Stereotype.build(lineLast.get(2)));
}
if (lineLast.get(4) != null) { if (lineLast.get(4) != null) {
String s = lineLast.get(4); String s = lineLast.get(4);
entity2.setSpecificColorTOBEREMOVED(ColorType.BACK, entity2.setSpecificColorTOBEREMOVED(ColorType.BACK,
@ -215,15 +213,14 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
final Display linkLabel = Display.getWithNewlines(line0.get("BRACKET", 0)); final Display linkLabel = Display.getWithNewlines(line0.get("BRACKET", 0));
LinkType type = new LinkType(LinkDecor.ARROW, LinkDecor.NONE); LinkType type = new LinkType(LinkDecor.ARROW, LinkDecor.NONE);
if (arrow.contains(".")) { if (arrow.contains("."))
type = type.goDotted(); type = type.goDotted();
}
Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), entity1, entity2, type, linkLabel, final LinkArg linkArg = LinkArg.build(linkLabel, lenght, diagram.getSkinParam().classAttributeIconSize() > 0);
lenght); Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), entity1, entity2, type, linkArg);
final Direction direction = StringUtils.getArrowDirection(arrowBody1 + arrowDirection + arrowBody2 + ">"); final Direction direction = StringUtils.getArrowDirection(arrowBody1 + arrowDirection + arrowBody2 + ">");
if (direction == Direction.LEFT || direction == Direction.UP) { if (direction == Direction.LEFT || direction == Direction.UP)
link = link.getInv(); link = link.getInv();
}
if (line0.get("URL", 0) != null) { if (line0.get("URL", 0) != null) {
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), UrlMode.STRICT); final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), UrlMode.STRICT);

View File

@ -66,7 +66,8 @@ public class CommandAddMethod extends SingleLineCommand2<ClassDiagram> {
} }
@Override @Override
protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg)
throws NoSuchColorException {
final String idShort = arg.get("NAME", 0); final String idShort = arg.get("NAME", 0);
final Ident ident = diagram.buildLeafIdent(idShort); final Ident ident = diagram.buildLeafIdent(idShort);
final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort); final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort);

View File

@ -59,6 +59,7 @@ import net.sourceforge.plantuml.cucadiagram.ILeaf;
import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg;
import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType; import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.cucadiagram.Stereotag; import net.sourceforge.plantuml.cucadiagram.Stereotag;
@ -214,9 +215,10 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
if (type2 == LeafType.INTERFACE && entity.getLeafType() != LeafType.INTERFACE) if (type2 == LeafType.INTERFACE && entity.getLeafType() != LeafType.INTERFACE)
typeLink = typeLink.goDashed(); typeLink = typeLink.goDashed();
final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl2, entity, typeLink, Display.NULL, 2, null, final LinkArg linkArg = LinkArg.noDisplay(2);
null, diagram.getLabeldistance(), final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl2, entity, typeLink,
diagram.getLabelangle()); linkArg.withQualifier(null, null).withDistanceAngle(diagram.getLabeldistance(),
diagram.getLabelangle()));
diagram.addLink(link); diagram.addLink(link);
} }
} }

View File

@ -81,7 +81,7 @@ public class CommandHideShowByVisibility extends SingleLineCommand2<UmlDiagram>
final EntityPortion portion = getEntityPortion(arg.get("PORTION", 0)); final EntityPortion portion = getEntityPortion(arg.get("PORTION", 0));
final Set<VisibilityModifier> visibilities = EnumSet.<VisibilityModifier> noneOf(VisibilityModifier.class); final Set<VisibilityModifier> visibilities = EnumSet.<VisibilityModifier>noneOf(VisibilityModifier.class);
final StringTokenizer st = new StringTokenizer(StringUtils.goLowerCase(arg.get("VISIBILITY", 0)), " ,"); final StringTokenizer st = new StringTokenizer(StringUtils.goLowerCase(arg.get("VISIBILITY", 0)), " ,");
while (st.hasMoreTokens()) { while (st.hasMoreTokens()) {
addVisibilities(st.nextToken(), portion, visibilities); addVisibilities(st.nextToken(), portion, visibilities);

View File

@ -62,9 +62,11 @@ public class CommandHideShowSpecificClass extends SingleLineCommand2<CucaDiagram
// final String codeString = arg.get("CODE", 0); // final String codeString = arg.get("CODE", 0);
// if (codeString.equals("class")) { // if (codeString.equals("class")) {
// diagram.hideOrShow(LeafType.CLASS, arg.get("COMMAND", 0).equalsIgnoreCase("show")); // diagram.hideOrShow(LeafType.CLASS, arg.get("COMMAND",
// 0).equalsIgnoreCase("show"));
// } else if (codeString.equals("interface")) { // } else if (codeString.equals("interface")) {
// diagram.hideOrShow(LeafType.INTERFACE, arg.get("COMMAND", 0).equalsIgnoreCase("show")); // diagram.hideOrShow(LeafType.INTERFACE, arg.get("COMMAND",
// 0).equalsIgnoreCase("show"));
// } else { // } else {
// final Code code = diagram.buildCode(codeString); // final Code code = diagram.buildCode(codeString);
// IEntity hidden = diagram.getEntityFactory().getLeafsget(code); // IEntity hidden = diagram.getEntityFactory().getLeafsget(code);
@ -72,7 +74,8 @@ public class CommandHideShowSpecificClass extends SingleLineCommand2<CucaDiagram
// hidden = diagram.getEntityFactory().getGroupsget(code); // hidden = diagram.getEntityFactory().getGroupsget(code);
// } // }
// if (hidden == null) { // if (hidden == null) {
// return CommandExecutionResult.error("Class/Package does not exist : " + code.getFullName()); // return CommandExecutionResult.error("Class/Package does not exist : " +
// code.getFullName());
// } // }
// diagram.hideOrShow(hidden, arg.get("COMMAND", 0).equalsIgnoreCase("show")); // diagram.hideOrShow(hidden, arg.get("COMMAND", 0).equalsIgnoreCase("show"));
// } // }

View File

@ -55,6 +55,7 @@ import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg;
import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType; import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement; import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement;
@ -231,9 +232,14 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
final Labels labels = new Labels(arg); final Labels labels = new Labels(arg);
Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, labels.getDisplay(), queue, final String kal1 = arg.get("QUALIFIER1", 0);
labels.getFirstLabel(), labels.getSecondLabel(), diagram.getLabeldistance(),
diagram.getLabelangle()); final LinkArg linkArg = LinkArg
.build(labels.getDisplay(), queue, diagram.getSkinParam().classAttributeIconSize() > 0)
.withQualifier(labels.getFirstLabel(), labels.getSecondLabel())
.withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle()).withKal(kal1);
Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, linkArg);
if (arg.get("URL", 0) != null) { if (arg.get("URL", 0) != null) {
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), UrlMode.STRICT); final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), UrlMode.STRICT);
final Url url = urlBuilder.getUrl(arg.get("URL", 0)); final Url url = urlBuilder.getUrl(arg.get("URL", 0));
@ -371,8 +377,10 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
final Display labelLink = Display.getWithNewlines(arg.get("LABEL_LINK", 0)); final Display labelLink = Display.getWithNewlines(arg.get("LABEL_LINK", 0));
final String firstLabel = arg.get("FIRST_LABEL", 0); final String firstLabel = arg.get("FIRST_LABEL", 0);
final String secondLabel = arg.get("SECOND_LABEL", 0); final String secondLabel = arg.get("SECOND_LABEL", 0);
final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, labelLink, queue, firstLabel, final LinkArg linkArg = LinkArg.build(labelLink, queue, diagram.getSkinParam().classAttributeIconSize() > 0);
secondLabel, diagram.getLabeldistance(), diagram.getLabelangle()); final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType,
linkArg.withQualifier(firstLabel, secondLabel).withDistanceAngle(diagram.getLabeldistance(),
diagram.getLabelangle()));
link.setColors(color().getColor(diagram.getSkinParam().getThemeStyle(), arg, link.setColors(color().getColor(diagram.getSkinParam().getThemeStyle(), arg,
diagram.getSkinParam().getIHtmlColorSet())); diagram.getSkinParam().getIHtmlColorSet()));

View File

@ -54,6 +54,7 @@ import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg;
import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType; import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram; import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram;
@ -72,8 +73,9 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
new RegexLeaf("HEADER", "@([\\d.]+)"), // new RegexLeaf("HEADER", "@([\\d.]+)"), //
RegexLeaf.spaceOneOrMore() // RegexLeaf.spaceOneOrMore() //
)), // )), //
new RegexLeaf("ENT1", "(?:" + optionalKeywords(umlDiagramType) + "[%s]+)?" new RegexLeaf("ENT1",
+ "(\\.?[%pLN_]+(?:\\.[%pLN_]+)*|[%g][^%g]+[%g])[%s]*(\\<\\<.*\\>\\>)?"), // "(?:" + optionalKeywords(umlDiagramType) + "[%s]+)?"
+ "(\\.?[%pLN_]+(?:\\.[%pLN_]+)*|[%g][^%g]+[%g])[%s]*(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexOptional(new RegexLeaf("FIRST_LABEL", "[%g]([^%g]+)[%g]")), // new RegexOptional(new RegexLeaf("FIRST_LABEL", "[%g]([^%g]+)[%g]")), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
@ -82,8 +84,9 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexOptional(new RegexLeaf("SECOND_LABEL", "[%g]([^%g]+)[%g]")), // new RegexOptional(new RegexLeaf("SECOND_LABEL", "[%g]([^%g]+)[%g]")), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("ENT2", "(?:" + optionalKeywords(umlDiagramType) + "[%s]+)?" new RegexLeaf("ENT2",
+ "(\\.?[%pLN_]+(?:\\.[%pLN_]+)*|[%g][^%g]+[%g])[%s]*(\\<\\<.*\\>\\>)?"), // "(?:" + optionalKeywords(umlDiagramType) + "[%s]+)?"
+ "(\\.?[%pLN_]+(?:\\.[%pLN_]+)*|[%g][^%g]+[%g])[%s]*(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexOptional( // new RegexOptional( //
new RegexConcat( // new RegexConcat( //
@ -94,19 +97,19 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
} }
private static String optionalKeywords(UmlDiagramType type) { private static String optionalKeywords(UmlDiagramType type) {
if (type == UmlDiagramType.CLASS) { if (type == UmlDiagramType.CLASS)
return "(interface|enum|annotation|abstract[%s]+class|abstract|class|entity|protocol|struct|exception)"; return "(interface|enum|annotation|abstract[%s]+class|abstract|class|entity|protocol|struct|exception)";
}
if (type == UmlDiagramType.OBJECT) { if (type == UmlDiagramType.OBJECT)
return "(object)"; return "(object)";
}
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
private LeafType getType(String desc) { private LeafType getType(String desc) {
if (desc.charAt(0) == desc.charAt(1)) { if (desc.charAt(0) == desc.charAt(1))
return LeafType.LOLLIPOP_HALF; return LeafType.LOLLIPOP_HALF;
}
return LeafType.LOLLIPOP_FULL; return LeafType.LOLLIPOP_FULL;
} }
@ -145,9 +148,8 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
final String queue = getQueue(arg); final String queue = getQueue(arg);
int length = queue.length(); int length = queue.length();
if (length == 1 && diagram.getNbOfHozizontalLollipop(normalEntity) > 1) { if (length == 1 && diagram.getNbOfHozizontalLollipop(normalEntity) > 1)
length++; length++;
}
String firstLabel = arg.get("FIRST_LABEL", 0); String firstLabel = arg.get("FIRST_LABEL", 0);
String secondLabel = arg.get("SECOND_LABEL", 0); String secondLabel = arg.get("SECOND_LABEL", 0);
@ -161,8 +163,8 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
final Matcher2 m1 = p1.matcher(labelLink); final Matcher2 m1 = p1.matcher(labelLink);
if (m1.matches()) { if (m1.matches()) {
firstLabel = m1.group(1); firstLabel = m1.group(1);
labelLink = StringUtils.trin(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils labelLink = StringUtils.trin(
.trin(m1.group(2)))); StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils.trin(m1.group(2))));
secondLabel = m1.group(3); secondLabel = m1.group(3);
} else { } else {
final Pattern2 p2 = MyPattern.cmpile("^\"([^\"]+)\"([^\"]+)$"); final Pattern2 p2 = MyPattern.cmpile("^\"([^\"]+)\"([^\"]+)$");
@ -185,16 +187,12 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
} }
} }
labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(labelLink); labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(labelLink);
} /* }
* else if (arg.get("LABEL_LINK_XT").get(0) != null || arg.get("LABEL_LINK_XT").get(1) != null || final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(labelLink), length,
* arg.get("LABEL_LINK_XT").get(2) != null) { labelLink = arg.get("LABEL_LINK_XT").get(1); firstLabel = diagram.getSkinParam().classAttributeIconSize() > 0);
* merge(firstLabel, arg.get("LABEL_LINK_XT").get(0)); secondLabel = merge(arg.get("LABEL_LINK_XT").get(2), final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType,
* secondLabel); } linkArg.withQualifier(firstLabel, secondLabel).withDistanceAngle(diagram.getLabeldistance(),
*/ diagram.getLabelangle()));
final Link link = new Link(diagram.getSkinParam()
.getCurrentStyleBuilder(), cl1, cl2, linkType, Display.getWithNewlines(labelLink), length,
firstLabel, secondLabel, diagram.getLabeldistance(), diagram.getLabelangle());
diagram.resetPragmaLabel(); diagram.resetPragmaLabel();
addLink(diagram, link, arg.get("HEADER", 0)); addLink(diagram, link, arg.get("HEADER", 0));
@ -204,28 +202,13 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
private IEntity getFoo1(AbstractClassOrObjectDiagram diagram, final Code code, final Ident ident) { private IEntity getFoo1(AbstractClassOrObjectDiagram diagram, final Code code, final Ident ident) {
if (diagram.V1972()) { if (diagram.V1972()) {
final IEntity result = ident.size() == 1 ? diagram.getLeafVerySmart(ident) : diagram.getLeafStrict(ident); final IEntity result = ident.size() == 1 ? diagram.getLeafVerySmart(ident) : diagram.getLeafStrict(ident);
if (result != null) { if (result != null)
return result; return result;
}
} }
return diagram.getOrCreateLeaf(ident, code, null, null); return diagram.getOrCreateLeaf(ident, code, null, null);
} }
// private String merge(String a, String b) {
// if (a == null && b == null) {
// return null;
// }
// if (a == null && b != null) {
// return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(b);
// }
// if (b == null && a != null) {
// return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(a);
// }
// return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(a) +
// BackSlash.VV1
// + StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(b);
// }
private void addLink(AbstractClassOrObjectDiagram diagram, Link link, String weight) { private void addLink(AbstractClassOrObjectDiagram diagram, Link link, String weight) {
diagram.addLink(link); diagram.addLink(link);
if (weight == null) { if (weight == null) {
@ -253,12 +236,12 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
} }
private String getQueue(RegexResult arg) { private String getQueue(RegexResult arg) {
if (arg.get("LOL_THEN_ENT", 1) != null) { if (arg.get("LOL_THEN_ENT", 1) != null)
return StringUtils.trin(arg.get("LOL_THEN_ENT", 1)); return StringUtils.trin(arg.get("LOL_THEN_ENT", 1));
}
if (arg.get("ENT_THEN_LOL", 0) != null) { if (arg.get("ENT_THEN_LOL", 0) != null)
return StringUtils.trin(arg.get("ENT_THEN_LOL", 0)); return StringUtils.trin(arg.get("ENT_THEN_LOL", 0));
}
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }

View File

@ -65,15 +65,16 @@ public class CommandStereotype extends SingleLineCommand2<ClassDiagram> {
} }
@Override @Override
protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg)
throws NoSuchColorException {
final String name = arg.get("NAME", 0); final String name = arg.get("NAME", 0);
final Ident ident = diagram.buildLeafIdent(name); final Ident ident = diagram.buildLeafIdent(name);
final Code code = diagram.V1972() ? ident : diagram.buildCode(name); final Code code = diagram.V1972() ? ident : diagram.buildCode(name);
final String stereotype = arg.get("STEREO", 0); final String stereotype = arg.get("STEREO", 0);
final IEntity entity = diagram.getOrCreateLeaf(ident, code, null, null); final IEntity entity = diagram.getOrCreateLeaf(ident, code, null, null);
entity.setStereotype(Stereotype.build(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram entity.setStereotype(Stereotype.build(stereotype, diagram.getSkinParam().getCircledCharacterRadius(),
.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER), diagram.getSkinParam() diagram.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER),
.getIHtmlColorSet())); diagram.getSkinParam().getIHtmlColorSet()));
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();
} }

View File

@ -35,7 +35,6 @@
*/ */
package net.sourceforge.plantuml.classdiagram.command; package net.sourceforge.plantuml.classdiagram.command;
public class GenericRegexProducer { public class GenericRegexProducer {
public final static String PATTERN = "[^\\<\\>/]" + getGenericRegex(4); public final static String PATTERN = "[^\\<\\>/]" + getGenericRegex(4);

View File

@ -77,7 +77,8 @@ public final class CommandConstraintOnLinks extends SingleLineCommand2<CucaDiagr
} }
@Override @Override
protected CommandExecutionResult executeArg(CucaDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { protected CommandExecutionResult executeArg(CucaDiagram diagram, LineLocation location, RegexResult arg)
throws NoSuchColorException {
final List<Link> links = diagram.getTwoLastLinks(); final List<Link> links = diagram.getTwoLastLinks();
if (links == null) { if (links == null) {
return CommandExecutionResult.error("Cannot put constraint on two last links"); return CommandExecutionResult.error("Cannot put constraint on two last links");

View File

@ -58,6 +58,7 @@ import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg;
import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType; import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorParser;
@ -167,13 +168,17 @@ public final class CommandFactoryNoteActivity implements SingleMultiFactoryComma
final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).goDashed(); final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).goDashed();
if (position == Position.RIGHT) { if (position == Position.RIGHT) {
link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), activity, note, type, Display.NULL, 1); link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), activity, note, type,
LinkArg.noDisplay(1));
} else if (position == Position.LEFT) { } else if (position == Position.LEFT) {
link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), note, activity, type, Display.NULL, 1); link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), note, activity, type,
LinkArg.noDisplay(1));
} else if (position == Position.BOTTOM) { } else if (position == Position.BOTTOM) {
link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), activity, note, type, Display.NULL, 2); link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), activity, note, type,
LinkArg.noDisplay(2));
} else if (position == Position.TOP) { } else if (position == Position.TOP) {
link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), note, activity, type, Display.NULL, 2); link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), note, activity, type,
LinkArg.noDisplay(2));
} else { } else {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }

View File

@ -61,6 +61,7 @@ import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg;
import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType; import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.cucadiagram.Stereotag; import net.sourceforge.plantuml.cucadiagram.Stereotag;
@ -259,15 +260,19 @@ public final class CommandFactoryNoteOnEntity implements SingleMultiFactoryComma
final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).goDashed(); final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).goDashed();
if (position == Position.RIGHT) { if (position == Position.RIGHT) {
link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, note, type, Display.NULL, 1); link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, note, type,
LinkArg.noDisplay(1));
link.setHorizontalSolitary(true); link.setHorizontalSolitary(true);
} else if (position == Position.LEFT) { } else if (position == Position.LEFT) {
link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), note, cl1, type, Display.NULL, 1); link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), note, cl1, type,
LinkArg.noDisplay(1));
link.setHorizontalSolitary(true); link.setHorizontalSolitary(true);
} else if (position == Position.BOTTOM) { } else if (position == Position.BOTTOM) {
link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, note, type, Display.NULL, 2); link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, note, type,
LinkArg.noDisplay(2));
} else if (position == Position.TOP) { } else if (position == Position.TOP) {
link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), note, cl1, type, Display.NULL, 2); link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), note, cl1, type,
LinkArg.noDisplay(2));
} else { } else {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }

View File

@ -56,6 +56,7 @@ import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg;
import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType; import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorParser;
@ -88,7 +89,7 @@ public final class CommandFactoryTipOnEntity implements SingleMultiFactoryComman
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("\\{"), // new RegexLeaf("\\{"), //
RegexLeaf.end() // RegexLeaf.end() //
); );
} }
return RegexConcat.build(CommandFactoryTipOnEntity.class.getName() + key + withBracket, RegexLeaf.start(), // return RegexConcat.build(CommandFactoryTipOnEntity.class.getName() + key + withBracket, RegexLeaf.start(), //
new RegexLeaf("note"), // new RegexLeaf("note"), //
@ -103,7 +104,7 @@ public final class CommandFactoryTipOnEntity implements SingleMultiFactoryComman
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), // new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
RegexLeaf.end() // RegexLeaf.end() //
); );
} }
public Command<AbstractEntityDiagram> createSingleLine() { public Command<AbstractEntityDiagram> createSingleLine() {
@ -122,7 +123,8 @@ public final class CommandFactoryTipOnEntity implements SingleMultiFactoryComman
return "^[%s]*(end[%s]?note)$"; return "^[%s]*(end[%s]?note)$";
} }
protected CommandExecutionResult executeNow(final AbstractEntityDiagram system, BlocLines lines) throws NoSuchColorException { protected CommandExecutionResult executeNow(final AbstractEntityDiagram system, BlocLines lines)
throws NoSuchColorException {
// StringUtils.trim(lines, false); // StringUtils.trim(lines, false);
final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString());
lines = lines.subExtract(1, 1); lines = lines.subExtract(1, 1);
@ -154,8 +156,8 @@ public final class CommandFactoryTipOnEntity implements SingleMultiFactoryComman
return CommandExecutionResult.error("Nothing to note to"); return CommandExecutionResult.error("Nothing to note to");
} }
final IEntity cl1 = diagram.getOrCreateLeaf(identShort, codeShort, null, null); final IEntity cl1 = diagram.getOrCreateLeaf(identShort, codeShort, null, null);
final Position position = Position.valueOf(StringUtils.goUpperCase(pos)).withRankdir( final Position position = Position.valueOf(StringUtils.goUpperCase(pos))
diagram.getSkinParam().getRankdir()); .withRankdir(diagram.getSkinParam().getRankdir());
final Ident identTip = diagram.buildLeafIdent(idShort + "$$$" + position.name()); final Ident identTip = diagram.buildLeafIdent(idShort + "$$$" + position.name());
IEntity tips = diagram.getLeafStrict(identTip); IEntity tips = diagram.getLeafStrict(identTip);
@ -164,11 +166,11 @@ public final class CommandFactoryTipOnEntity implements SingleMultiFactoryComman
final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).getInvisible(); final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).getInvisible();
final Link link; final Link link;
if (position == Position.RIGHT) { if (position == Position.RIGHT) {
link = new Link(diagram.getSkinParam() link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, (IEntity) tips, type,
.getCurrentStyleBuilder(), cl1, (IEntity) tips, type, Display.NULL, 1); LinkArg.noDisplay(1));
} else { } else {
link = new Link(diagram.getSkinParam() link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), (IEntity) tips, cl1, type,
.getCurrentStyleBuilder(), (IEntity) tips, cl1, type, Display.NULL, 1); LinkArg.noDisplay(1));
} }
diagram.addLink(link); diagram.addLink(link);
} }

View File

@ -46,6 +46,7 @@ import net.sourceforge.plantuml.compositediagram.CompositeDiagram;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg;
import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType; import net.sourceforge.plantuml.cucadiagram.LinkType;
@ -77,10 +78,8 @@ public class CommandLinkBlock extends SingleLineCommand2<CompositeDiagram> {
protected CommandExecutionResult executeArg(CompositeDiagram diagram, LineLocation location, RegexResult arg) { protected CommandExecutionResult executeArg(CompositeDiagram diagram, LineLocation location, RegexResult arg) {
final String ent1 = arg.get("ENT1", 0); final String ent1 = arg.get("ENT1", 0);
final String ent2 = arg.get("ENT2", 0); final String ent2 = arg.get("ENT2", 0);
final IEntity cl1 = diagram.getOrCreateLeaf(diagram.buildLeafIdent(ent1), final IEntity cl1 = diagram.getOrCreateLeaf(diagram.buildLeafIdent(ent1), diagram.buildCode(ent1), null, null);
diagram.buildCode(ent1), null, null); final IEntity cl2 = diagram.getOrCreateLeaf(diagram.buildLeafIdent(ent2), diagram.buildCode(ent2), null, null);
final IEntity cl2 = diagram.getOrCreateLeaf(diagram.buildLeafIdent(ent2),
diagram.buildCode(ent2), null, null);
final String deco1 = arg.get("DECO1", 0); final String deco1 = arg.get("DECO1", 0);
final String deco2 = arg.get("DECO2", 0); final String deco2 = arg.get("DECO2", 0);
@ -94,16 +93,17 @@ public class CommandLinkBlock extends SingleLineCommand2<CompositeDiagram> {
final String queue = arg.get("QUEUE", 0); final String queue = arg.get("QUEUE", 0);
final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, Display.getWithNewlines(arg.get("DISPLAY", 0)), final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(arg.get("DISPLAY", 0)), queue.length(),
queue.length()); diagram.getSkinParam().classAttributeIconSize() > 0);
final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, linkArg);
diagram.addLink(link); diagram.addLink(link);
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();
} }
private LinkDecor getLinkDecor(String s) { private LinkDecor getLinkDecor(String s) {
if ("[]".equals(s)) { if ("[]".equals(s))
return LinkDecor.SQUARE_toberemoved; return LinkDecor.SQUARE_toberemoved;
}
return LinkDecor.NONE; return LinkDecor.NONE;
} }

View File

@ -98,7 +98,8 @@ public class BodierLikeClassOrObject implements Bodier {
private boolean isBodyEnhanced() { private boolean isBodyEnhanced() {
for (CharSequence s : rawBody) for (CharSequence s : rawBody)
if (BodyEnhanced1.isBlockSeparator(s) || CreoleParser.isTableLine(s.toString()) || Parser.isTreeStart(s.toString())) if (BodyEnhanced1.isBlockSeparator(s) || CreoleParser.isTableLine(s.toString())
|| Parser.isTreeStart(s.toString()))
return true; return true;
return false; return false;

View File

@ -35,6 +35,7 @@
*/ */
package net.sourceforge.plantuml.cucadiagram; package net.sourceforge.plantuml.cucadiagram;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
@ -59,6 +60,10 @@ import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramTxtMaker; import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramTxtMaker;
import net.sourceforge.plantuml.cucadiagram.dot.Graphviz;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizVersion;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizVersions;
import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory; import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory;
import net.sourceforge.plantuml.elk.CucaDiagramFileMakerElk; import net.sourceforge.plantuml.elk.CucaDiagramFileMakerElk;
import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.graphic.USymbol;
@ -70,6 +75,7 @@ import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.svek.CucaDiagramFileMaker; import net.sourceforge.plantuml.svek.CucaDiagramFileMaker;
import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek; import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek;
import net.sourceforge.plantuml.ugraphic.color.ColorMapper; import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
import net.sourceforge.plantuml.vizjs.GraphvizJs;
import net.sourceforge.plantuml.xmi.CucaDiagramXmiMaker; import net.sourceforge.plantuml.xmi.CucaDiagramXmiMaker;
import net.sourceforge.plantuml.xmlsc.StateDiagramScxmlMaker; import net.sourceforge.plantuml.xmlsc.StateDiagramScxmlMaker;
@ -873,4 +879,24 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
// Strange numbers here for backwards compatibility // Strange numbers here for backwards compatibility
return ClockwiseTopRightBottomLeft.topRightBottomLeft(0, 5, 5, 0); return ClockwiseTopRightBottomLeft.topRightBottomLeft(0, 5, 5, 0);
} }
private GraphvizVersion graphvizVersion;
public GraphvizVersion getGraphvizVersion() {
if (graphvizVersion == null)
graphvizVersion = getGraphvizVersionInternal();
return graphvizVersion;
}
private GraphvizVersion getGraphvizVersionInternal() {
final Graphviz graphviz = GraphvizUtils.create(getSkinParam(), "foo;", "svg");
if (graphviz instanceof GraphvizJs)
return GraphvizJs.getGraphvizVersion(false);
final File f = graphviz.getDotExe();
return GraphvizVersions.getInstance().getVersion(f);
}
} }

View File

@ -269,7 +269,7 @@ public class Display implements Iterable<CharSequence> {
return result; return result;
} }
public Display manageGuillemet() { public Display manageGuillemet(boolean manageVisibilityModifier) {
final List<CharSequence> result = new ArrayList<>(); final List<CharSequence> result = new ArrayList<>();
boolean first = true; boolean first = true;
for (CharSequence line : displayData) { for (CharSequence line : displayData) {
@ -277,7 +277,7 @@ public class Display implements Iterable<CharSequence> {
result.add(line); result.add(line);
} else { } else {
String lineString = line.toString(); String lineString = line.toString();
if (first && VisibilityModifier.isVisibilityCharacter(line)) if (manageVisibilityModifier && first && VisibilityModifier.isVisibilityCharacter(line))
lineString = lineString.substring(1).trim(); lineString = lineString.substring(1).trim();
final String withGuillement = Guillemet.GUILLEMET.manageGuillemet(lineString); final String withGuillement = Guillemet.GUILLEMET.manageGuillemet(lineString);

View File

@ -41,8 +41,9 @@ import net.sourceforge.plantuml.api.ApiWarning;
* *
* There is a typo in this class name. * There is a typo in this class name.
* *
* You should use directly DisplayPositioned and not this interface which is here for legacy code. * You should use directly DisplayPositioned and not this interface which is
* This file will be removed, so use DisplayPositioned instead. * here for legacy code. This file will be removed, so use DisplayPositioned
* instead.
* *
*/ */
@Deprecated @Deprecated
@ -52,10 +53,9 @@ public class DisplayPositionned {
public Display getDisplay() { public Display getDisplay() {
return null; return null;
} }
public boolean isNull() { public boolean isNull() {
return false; return false;
} }
} }

View File

@ -115,5 +115,4 @@ public class EntityGenderUtils {
}; };
} }
} }

View File

@ -43,8 +43,8 @@ public enum EntityPortion {
public Set<EntityPortion> asSet() { public Set<EntityPortion> asSet() {
if (this == MEMBER) { if (this == MEMBER) {
return EnumSet.<EntityPortion> of(FIELD, METHOD); return EnumSet.<EntityPortion>of(FIELD, METHOD);
} }
return EnumSet.<EntityPortion> of(this); return EnumSet.<EntityPortion>of(this);
} }
} }

View File

@ -35,7 +35,6 @@
*/ */
package net.sourceforge.plantuml.cucadiagram; package net.sourceforge.plantuml.cucadiagram;
public abstract class EntityUtils { public abstract class EntityUtils {
public static boolean groupRoot(IGroup g) { public static boolean groupRoot(IGroup g) {

View File

@ -41,6 +41,7 @@ import net.sourceforge.plantuml.cucadiagram.dot.Neighborhood;
import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.skin.VisibilityModifier; import net.sourceforge.plantuml.skin.VisibilityModifier;
import net.sourceforge.plantuml.svek.IEntityImage; import net.sourceforge.plantuml.svek.IEntityImage;
import net.sourceforge.plantuml.svek.Margins;
public interface ILeaf extends IEntity { public interface ILeaf extends IEntity {
@ -52,9 +53,7 @@ public interface ILeaf extends IEntity {
public void setTop(boolean top); public void setTop(boolean top);
public boolean hasNearDecoration(); public Margins getMargins();
public void setNearDecoration(boolean nearDecoration);
public int getXposition(); public int getXposition();

View File

@ -42,11 +42,8 @@ public enum LeafType {
EMPTY_PACKAGE, EMPTY_PACKAGE,
ABSTRACT_CLASS, CLASS, INTERFACE, ANNOTATION, ABSTRACT_CLASS, CLASS, INTERFACE, ANNOTATION, PROTOCOL, STRUCT, EXCEPTION, LOLLIPOP_FULL, LOLLIPOP_HALF, NOTE, TIPS,
PROTOCOL, STRUCT, OBJECT, MAP, JSON, ASSOCIATION, ENUM, CIRCLE,
EXCEPTION,
LOLLIPOP_FULL, LOLLIPOP_HALF, NOTE, TIPS, OBJECT, MAP, JSON, ASSOCIATION,
ENUM, CIRCLE,
USECASE, USECASE_BUSINESS, USECASE, USECASE_BUSINESS,
@ -79,8 +76,8 @@ public enum LeafType {
public boolean isLikeClass() { public boolean isLikeClass() {
return this == LeafType.ANNOTATION || this == LeafType.ABSTRACT_CLASS || this == LeafType.CLASS return this == LeafType.ANNOTATION || this == LeafType.ABSTRACT_CLASS || this == LeafType.CLASS
|| this == LeafType.INTERFACE || this == LeafType.ENUM || this == LeafType.ENTITY || this == LeafType.INTERFACE || this == LeafType.ENUM || this == LeafType.ENTITY
|| this == LeafType.PROTOCOL || this == LeafType.STRUCT || this == LeafType.EXCEPTION; || this == LeafType.PROTOCOL || this == LeafType.STRUCT || this == LeafType.EXCEPTION;
} }
public String toHtml() { public String toHtml() {

View File

@ -46,6 +46,7 @@ import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.awt.geom.Dimension2D; import net.sourceforge.plantuml.awt.geom.Dimension2D;
import net.sourceforge.plantuml.command.Position; import net.sourceforge.plantuml.command.Position;
import net.sourceforge.plantuml.cucadiagram.entity.EntityImpl;
import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
@ -55,9 +56,9 @@ import net.sourceforge.plantuml.graphic.color.Colors;
import net.sourceforge.plantuml.skin.VisibilityModifier; import net.sourceforge.plantuml.skin.VisibilityModifier;
import net.sourceforge.plantuml.style.StyleBuilder; import net.sourceforge.plantuml.style.StyleBuilder;
import net.sourceforge.plantuml.svek.Bibliotekon; import net.sourceforge.plantuml.svek.Bibliotekon;
import net.sourceforge.plantuml.svek.Margins;
import net.sourceforge.plantuml.ugraphic.UComment; import net.sourceforge.plantuml.ugraphic.UComment;
import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.utils.UniqueSequence; import net.sourceforge.plantuml.utils.UniqueSequence;
public class Link extends WithLinkType implements Hideable, Removeable { public class Link extends WithLinkType implements Hideable, Removeable {
@ -72,11 +73,8 @@ public class Link extends WithLinkType implements Hideable, Removeable {
private String port1; private String port1;
private String port2; private String port2;
final private Display label; private final LinkArg linkArg;
private int length;
final private String qualifier1;
final private String qualifier2;
final private String uid = "LNK" + UniqueSequence.getValue(); final private String uid = "LNK" + UniqueSequence.getValue();
private Display note; private Display note;
@ -87,9 +85,6 @@ public class Link extends WithLinkType implements Hideable, Removeable {
private boolean invis = false; private boolean invis = false;
private double weight = 1.0; private double weight = 1.0;
private final String labeldistance;
private final String labelangle;
private boolean constraint = true; private boolean constraint = true;
private boolean inverted = false; private boolean inverted = false;
private LinkArrow linkArrow = LinkArrow.NONE_OR_SEVERAL; private LinkArrow linkArrow = LinkArrow.NONE_OR_SEVERAL;
@ -97,7 +92,6 @@ public class Link extends WithLinkType implements Hideable, Removeable {
private boolean opale; private boolean opale;
private boolean horizontalSolitary; private boolean horizontalSolitary;
private String sametail; private String sametail;
private VisibilityModifier visibilityModifier;
private final StyleBuilder styleBuilder; private final StyleBuilder styleBuilder;
private Stereotype stereotype; private Stereotype stereotype;
@ -121,56 +115,34 @@ public class Link extends WithLinkType implements Hideable, Removeable {
return new UComment("link " + getEntity1().getCodeGetName() + " to " + getEntity2().getCodeGetName()); return new UComment("link " + getEntity1().getCodeGetName() + " to " + getEntity2().getCodeGetName());
} }
public Link(StyleBuilder styleBuilder, IEntity cl1, IEntity cl2, LinkType type, Display label, int length) { public Link(StyleBuilder styleBuilder, IEntity cl1, IEntity cl2, LinkType type, LinkArg linkArg) {
this(styleBuilder, cl1, cl2, type, label, length, null, null, null, null, null); if (linkArg.getLength() < 1)
}
public Link(StyleBuilder styleBuilder, IEntity cl1, IEntity cl2, LinkType type, Display label, int length,
String qualifier1, String qualifier2, String labeldistance, String labelangle) {
this(styleBuilder, cl1, cl2, type, label, length, qualifier1, qualifier2, labeldistance, labelangle, null);
}
public Link(StyleBuilder styleBuilder, IEntity cl1, IEntity cl2, LinkType type, Display label, int length,
String qualifier1, String qualifier2, String labeldistance, String labelangle, HColor specificColor) {
if (length < 1)
throw new IllegalArgumentException(); throw new IllegalArgumentException();
this.styleBuilder = styleBuilder; this.styleBuilder = styleBuilder;
this.cl1 = Objects.requireNonNull(cl1); this.cl1 = Objects.requireNonNull(cl1);
this.cl2 = Objects.requireNonNull(cl2); this.cl2 = Objects.requireNonNull(cl2);
this.type = type; this.type = type;
if (Display.isNull(label)) {
this.label = Display.NULL;
} else {
this.label = label.manageGuillemet();
if (VisibilityModifier.isVisibilityCharacter(label.get(0)))
visibilityModifier = VisibilityModifier.getVisibilityModifier(label.get(0), false);
} this.linkArg = linkArg;
this.length = length;
this.qualifier1 = qualifier1;
this.qualifier2 = qualifier2;
this.labeldistance = labeldistance;
this.labelangle = labelangle;
this.setSpecificColor(specificColor);
if (qualifier1 != null)
((ILeaf) cl1).setNearDecoration(true);
if (qualifier2 != null) if (linkArg.getQualifier1() != null)
((ILeaf) cl2).setNearDecoration(true); ((EntityImpl) cl1).ensureMargins(Margins.uniform(16));
if (linkArg.getQualifier2() != null)
((EntityImpl) cl2).ensureMargins(Margins.uniform(16));
} }
public Link getInv() { public Link getInv() {
final Link result = new Link(styleBuilder, cl2, cl1, getType().getInversed(), label, length, qualifier2, final Link result = new Link(styleBuilder, cl2, cl1, getType().getInversed(), linkArg.getInv());
qualifier1, labeldistance, labelangle, getSpecificColor());
result.inverted = !this.inverted; result.inverted = !this.inverted;
result.port1 = this.port2; result.port1 = this.port2;
result.port2 = this.port1; result.port2 = this.port1;
result.url = this.url; result.url = this.url;
result.linkConstraint = this.linkConstraint; result.linkConstraint = this.linkConstraint;
result.stereotype = stereotype; result.stereotype = stereotype;
result.visibilityModifier = visibilityModifier; result.linkArg.setVisibilityModifier(this.linkArg.getVisibilityModifier());
return result; return result;
} }
@ -181,12 +153,12 @@ public class Link extends WithLinkType implements Hideable, Removeable {
public String getLabeldistance() { public String getLabeldistance() {
// Default in dot 1.0 // Default in dot 1.0
return labeldistance; return getLinkArg().getLabeldistance();
} }
public String getLabelangle() { public String getLabelangle() {
// Default in dot -25 // Default in dot -25
return labelangle; return getLinkArg().getLabelangle();
} }
public String getUid() { public String getUid() {
@ -216,7 +188,7 @@ public class Link extends WithLinkType implements Hideable, Removeable {
@Override @Override
public String toString() { public String toString() {
return super.toString() + " {" + length + "} " + cl1 + "-->" + cl2; return super.toString() + " {" + linkArg.getLength() + "} " + cl1 + "-->" + cl2;
} }
public IEntity getEntity1() { public IEntity getEntity1() {
@ -295,23 +267,23 @@ public class Link extends WithLinkType implements Hideable, Removeable {
} }
public Display getLabel() { public Display getLabel() {
return label; return getLinkArg().getLabel();
} }
public int getLength() { public int getLength() {
return length; return getLinkArg().getLength();
} }
public final void setLength(int length) { public final void setLength(int length) {
this.length = length; this.getLinkArg().setLength(length);
} }
public String getQualifier1() { public String getQualifier1() {
return qualifier1; return getLinkArg().getQualifier1();
} }
public String getQualifier2() { public String getQualifier2() {
return qualifier2; return getLinkArg().getQualifier2();
} }
public final double getWeight() { public final double getWeight() {
@ -389,17 +361,17 @@ public class Link extends WithLinkType implements Hideable, Removeable {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
public double getMarginDecors1(StringBounder stringBounder, UFont fontQualif, ISkinSimple spriteContainer) { // public double getMarginDecors1(StringBounder stringBounder, UFont fontQualif, ISkinSimple spriteContainer) {
final double q = getQualifierMargin(stringBounder, fontQualif, qualifier1, spriteContainer); // final double q = getQualifierMargin(stringBounder, fontQualif, linkArg.getQualifier1(), spriteContainer);
final LinkDecor decor = getType().getDecor1(); // final LinkDecor decor = getType().getDecor1();
return decor.getMargin() + q; // return decor.getMargin() + q;
} // }
//
public double getMarginDecors2(StringBounder stringBounder, UFont fontQualif, ISkinSimple spriteContainer) { // public double getMarginDecors2(StringBounder stringBounder, UFont fontQualif, ISkinSimple spriteContainer) {
final double q = getQualifierMargin(stringBounder, fontQualif, qualifier2, spriteContainer); // final double q = getQualifierMargin(stringBounder, fontQualif, linkArg.getQualifier2(), spriteContainer);
final LinkDecor decor = getType().getDecor2(); // final LinkDecor decor = getType().getDecor2();
return decor.getMargin() + q; // return decor.getMargin() + q;
} // }
private double getQualifierMargin(StringBounder stringBounder, UFont fontQualif, String qualif, private double getQualifierMargin(StringBounder stringBounder, UFont fontQualif, String qualif,
ISkinSimple spriteContainer) { ISkinSimple spriteContainer) {
@ -507,7 +479,7 @@ public class Link extends WithLinkType implements Hideable, Removeable {
} }
public boolean hasUrl() { public boolean hasUrl() {
if (Display.isNull(label) == false && label.hasUrl()) if (Display.isNull(linkArg.getLabel()) == false && linkArg.getLabel().hasUrl())
return true; return true;
return getUrl() != null; return getUrl() != null;
@ -532,10 +504,6 @@ public class Link extends WithLinkType implements Hideable, Removeable {
} }
public final VisibilityModifier getVisibilityModifier() {
return visibilityModifier;
}
private UmlDiagramType umlType; private UmlDiagramType umlType;
public void setUmlDiagramType(UmlDiagramType type) { public void setUmlDiagramType(UmlDiagramType type) {
@ -577,4 +545,12 @@ public class Link extends WithLinkType implements Hideable, Removeable {
return stereotype; return stereotype;
} }
public final LinkArg getLinkArg() {
return linkArg;
}
public final VisibilityModifier getVisibilityModifier() {
return getLinkArg().getVisibilityModifier();
}
} }

View File

@ -36,52 +36,74 @@
package net.sourceforge.plantuml.cucadiagram; package net.sourceforge.plantuml.cucadiagram;
import net.sourceforge.plantuml.skin.VisibilityModifier; import net.sourceforge.plantuml.skin.VisibilityModifier;
import net.sourceforge.plantuml.ugraphic.color.HColor;
public class LinkArg { public class LinkArg {
private final Display label; private final Display label;
private final int length;
private final String qualifier1; private final String qualifier1;
private final String qualifier2; private final String qualifier2;
private final String labeldistance; private final String labeldistance;
private final String labelangle; private final String labelangle;
private final HColor specificColor;
private VisibilityModifier visibilityModifier;
public LinkArg(Display label, int length) { private final String kal1;
this(label, length, null, null, null, null, null); private final String kal2;
private VisibilityModifier visibilityModifier;
private int length;
public static LinkArg build(final Display label, int length) {
return build(label, length, true);
}
public static LinkArg noDisplay(int length) {
return build(Display.NULL, length, true);
}
public static LinkArg build(final Display label, int length, boolean manageVisibilityModifier) {
VisibilityModifier visibilityModifier = null;
final Display newLabel;
if (Display.isNull(label)) {
newLabel = Display.NULL;
} else {
newLabel = label.manageGuillemet(manageVisibilityModifier);
if (manageVisibilityModifier && VisibilityModifier.isVisibilityCharacter(label.get(0)))
visibilityModifier = VisibilityModifier.getVisibilityModifier(label.get(0), false);
}
return new LinkArg(newLabel, length, null, null, null, null, visibilityModifier, null, null);
} }
public LinkArg withQualifier(String qualifier1, String qualifier2) { public LinkArg withQualifier(String qualifier1, String qualifier2) {
return new LinkArg(label, length, qualifier1, qualifier2, labeldistance, labelangle, specificColor); return new LinkArg(label, length, qualifier1, qualifier2, labeldistance, labelangle, visibilityModifier, kal1,
kal2);
}
public LinkArg withKal(String kal1) {
return new LinkArg(label, length, qualifier1, qualifier2, labeldistance, labelangle, visibilityModifier, kal1,
kal2);
} }
public LinkArg withDistanceAngle(String labeldistance, String labelangle) { public LinkArg withDistanceAngle(String labeldistance, String labelangle) {
return new LinkArg(label, length, qualifier1, qualifier2, labeldistance, labelangle, specificColor); return new LinkArg(label, length, qualifier1, qualifier2, labeldistance, labelangle, visibilityModifier, kal1,
} kal2);
public LinkArg withColor(HColor specificColor) {
return new LinkArg(label, length, qualifier1, qualifier2, labeldistance, labelangle, specificColor);
} }
private LinkArg(Display label, int length, String qualifier1, String qualifier2, String labeldistance, private LinkArg(Display label, int length, String qualifier1, String qualifier2, String labeldistance,
String labelangle, HColor specificColor) { String labelangle, VisibilityModifier visibilityModifier, String kal1, String kal2) {
if (Display.isNull(label)) {
this.label = Display.NULL;
} else {
this.label = label.manageGuillemet();
if (VisibilityModifier.isVisibilityCharacter(label.get(0)))
visibilityModifier = VisibilityModifier.getVisibilityModifier(label.get(0), false);
}
this.label = label;
this.visibilityModifier = visibilityModifier;
this.length = length; this.length = length;
this.qualifier1 = qualifier1; this.qualifier1 = qualifier1;
this.qualifier2 = qualifier2; this.qualifier2 = qualifier2;
this.labeldistance = labeldistance; this.labeldistance = labeldistance;
this.labelangle = labelangle; this.labelangle = labelangle;
this.specificColor = specificColor; this.kal1 = kal1;
this.kal2 = kal2;
}
public LinkArg getInv() {
return new LinkArg(label, length, qualifier2, qualifier1, labeldistance, labelangle, visibilityModifier, kal1,
kal2);
} }
public final Display getLabel() { public final Display getLabel() {
@ -108,11 +130,24 @@ public class LinkArg {
return labelangle; return labelangle;
} }
public final HColor getSpecificColor() {
return specificColor;
}
public final VisibilityModifier getVisibilityModifier() { public final VisibilityModifier getVisibilityModifier() {
return visibilityModifier; return visibilityModifier;
} }
public final void setVisibilityModifier(VisibilityModifier visibilityModifier) {
this.visibilityModifier = visibilityModifier;
}
public final void setLength(int length) {
this.length = length;
}
public final String getKal1() {
return kal1;
}
public final String getKal2() {
return kal2;
}
} }

View File

@ -35,20 +35,14 @@
*/ */
package net.sourceforge.plantuml.cucadiagram; package net.sourceforge.plantuml.cucadiagram;
public enum LinkHat { public enum LinkHat {
NONE /*, SQUARE, CIRCLE, CIRCLE_CONNECT; NONE /*
* , SQUARE, CIRCLE, CIRCLE_CONNECT;
public ExtremityFactory getExtremityFactory() { *
if (this == LinkHat.CIRCLE) { * public ExtremityFactory getExtremityFactory() { if (this == LinkHat.CIRCLE) {
return new ExtremityFactoryCircle(); * return new ExtremityFactoryCircle(); } if (this == LinkHat.CIRCLE_CONNECT) {
} * return new ExtremityFactoryCircleConnect(); } return null; }
if (this == LinkHat.CIRCLE_CONNECT) { */
return new ExtremityFactoryCircleConnect();
}
return null;
}
*/
} }

View File

@ -51,13 +51,13 @@ class Magma {
public void putInSquare() { public void putInSquare() {
final SquareLinker<ILeaf> linker = new SquareLinker<ILeaf>() { final SquareLinker<ILeaf> linker = new SquareLinker<ILeaf>() {
public void topDown(ILeaf top, ILeaf down) { public void topDown(ILeaf top, ILeaf down) {
diagram.addLink(new Link(diagram.getSkinParam() diagram.addLink(new Link(diagram.getSkinParam().getCurrentStyleBuilder(), top, down, linkType,
.getCurrentStyleBuilder(), top, down, linkType, Display.NULL, 2)); LinkArg.noDisplay(2)));
} }
public void leftRight(ILeaf left, ILeaf right) { public void leftRight(ILeaf left, ILeaf right) {
diagram.addLink(new Link(diagram.getSkinParam() diagram.addLink(new Link(diagram.getSkinParam().getCurrentStyleBuilder(), left, right, linkType,
.getCurrentStyleBuilder(), left, right, linkType, Display.NULL, 1)); LinkArg.noDisplay(1)));
} }
}; };
new SquareMaker<ILeaf>().putInSquare(standalones, linker); new SquareMaker<ILeaf>().putInSquare(standalones, linker);
@ -103,14 +103,14 @@ class Magma {
} }
public void linkToDown(Magma down) { public void linkToDown(Magma down) {
diagram.addLink(new Link(diagram diagram.addLink(new Link(diagram.getSkinParam().getCurrentStyleBuilder(), this.getBottomLeft(),
.getSkinParam().getCurrentStyleBuilder(), this.getBottomLeft(), down.getTopLeft(), linkType, Display.NULL, 2)); down.getTopLeft(), linkType, LinkArg.noDisplay(2)));
} }
public void linkToRight(Magma right) { public void linkToRight(Magma right) {
diagram.addLink(new Link(diagram diagram.addLink(new Link(diagram.getSkinParam().getCurrentStyleBuilder(), this.getTopRight(),
.getSkinParam().getCurrentStyleBuilder(), this.getTopRight(), right.getTopLeft(), linkType, Display.NULL, 1)); right.getTopLeft(), linkType, LinkArg.noDisplay(1)));
} }
} }

View File

@ -222,6 +222,4 @@ public class Member implements CharSequence {
return hasUrl; return hasUrl;
} }
} }

View File

@ -35,7 +35,6 @@
*/ */
package net.sourceforge.plantuml.cucadiagram; package net.sourceforge.plantuml.cucadiagram;
public interface PortionShower { public interface PortionShower {
boolean showPortion(EntityPortion portion, IEntity entity); boolean showPortion(EntityPortion portion, IEntity entity);

View File

@ -74,6 +74,7 @@ final public class DotData implements PortionShower {
private final ColorMapper colorMapper; private final ColorMapper colorMapper;
private final EntityFactory entityFactory; private final EntityFactory entityFactory;
private final GraphvizVersion graphvizVersion;
public EntityFactory getEntityFactory() { public EntityFactory getEntityFactory() {
return entityFactory; return entityFactory;
@ -82,7 +83,7 @@ final public class DotData implements PortionShower {
public DotData(IGroup topParent, List<Link> links, Collection<ILeaf> leafs, UmlDiagramType umlDiagramType, public DotData(IGroup topParent, List<Link> links, Collection<ILeaf> leafs, UmlDiagramType umlDiagramType,
ISkinParam skinParam, GroupHierarchy groupHierarchy, PortionShower portionShower, ColorMapper colorMapper, ISkinParam skinParam, GroupHierarchy groupHierarchy, PortionShower portionShower, ColorMapper colorMapper,
EntityFactory entityFactory, boolean isHideEmptyDescriptionForState, DotMode dotMode, EntityFactory entityFactory, boolean isHideEmptyDescriptionForState, DotMode dotMode,
String namespaceSeparator, Pragma pragma) { String namespaceSeparator, Pragma pragma, GraphvizVersion graphvizVersion) {
this.namespaceSeparator = namespaceSeparator; this.namespaceSeparator = namespaceSeparator;
this.pragma = pragma; this.pragma = pragma;
this.topParent = Objects.requireNonNull(topParent); this.topParent = Objects.requireNonNull(topParent);
@ -97,16 +98,19 @@ final public class DotData implements PortionShower {
this.groupHierarchy = groupHierarchy; this.groupHierarchy = groupHierarchy;
this.portionShower = portionShower; this.portionShower = portionShower;
this.entityFactory = entityFactory; this.entityFactory = entityFactory;
this.graphvizVersion = graphvizVersion;
} }
public DotData(IGroup topParent, List<Link> links, Collection<ILeaf> leafs, UmlDiagramType umlDiagramType, public DotData(IGroup topParent, List<Link> links, Collection<ILeaf> leafs, UmlDiagramType umlDiagramType,
ISkinParam skinParam, GroupHierarchy groupHierarchy, ColorMapper colorMapper, EntityFactory entityFactory, ISkinParam skinParam, GroupHierarchy groupHierarchy, ColorMapper colorMapper, EntityFactory entityFactory,
boolean isHideEmptyDescriptionForState, DotMode dotMode, String namespaceSeparator, Pragma pragma) { boolean isHideEmptyDescriptionForState, DotMode dotMode, String namespaceSeparator, Pragma pragma,
GraphvizVersion graphvizVersion) {
this(topParent, links, leafs, umlDiagramType, skinParam, groupHierarchy, new PortionShower() { this(topParent, links, leafs, umlDiagramType, skinParam, groupHierarchy, new PortionShower() {
public boolean showPortion(EntityPortion portion, IEntity entity) { public boolean showPortion(EntityPortion portion, IEntity entity) {
return true; return true;
} }
}, colorMapper, entityFactory, isHideEmptyDescriptionForState, dotMode, namespaceSeparator, pragma); }, colorMapper, entityFactory, isHideEmptyDescriptionForState, dotMode, namespaceSeparator, pragma,
graphvizVersion);
} }
public UmlDiagramType getUmlDiagramType() { public UmlDiagramType getUmlDiagramType() {
@ -232,4 +236,8 @@ final public class DotData implements PortionShower {
} }
public GraphvizVersion getGraphvizVersion() {
return graphvizVersion;
}
} }

View File

@ -53,13 +53,13 @@ public class GraphvizVersions {
} }
public GraphvizVersion getVersion(File f) { public GraphvizVersion getVersion(File f) {
if (f == null) { if (f == null)
return null; return null;
}
GraphvizVersion result = map.get(f); GraphvizVersion result = map.get(f);
if (result != null) { if (result != null)
return result; return result;
}
result = checkVersionSlow(f.getAbsolutePath()); result = checkVersionSlow(f.getAbsolutePath());
map.put(f, result); map.put(f, result);
return result; return result;

View File

@ -77,6 +77,7 @@ import net.sourceforge.plantuml.graphic.color.ColorType;
import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.graphic.color.Colors;
import net.sourceforge.plantuml.skin.VisibilityModifier; import net.sourceforge.plantuml.skin.VisibilityModifier;
import net.sourceforge.plantuml.svek.IEntityImage; import net.sourceforge.plantuml.svek.IEntityImage;
import net.sourceforge.plantuml.svek.Margins;
import net.sourceforge.plantuml.svek.PackageStyle; import net.sourceforge.plantuml.svek.PackageStyle;
import net.sourceforge.plantuml.svek.SingleStrategy; import net.sourceforge.plantuml.svek.SingleStrategy;
import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UFont;
@ -112,7 +113,7 @@ final public class EntityImpl implements ILeaf, IGroup {
private GroupType groupType; private GroupType groupType;
// Other // Other
private boolean nearDecoration = false; private Margins margins = Margins.NONE;
private final Collection<String> portShortNames = new HashSet<>(); private final Collection<String> portShortNames = new HashSet<>();
private int xposition; private int xposition;
private IEntityImage svekImage; private IEntityImage svekImage;
@ -279,14 +280,15 @@ final public class EntityImpl implements ILeaf, IGroup {
this.url = url; this.url = url;
} }
public final boolean hasNearDecoration() { public final Margins getMargins() {
checkNotGroup(); checkNotGroup();
return nearDecoration; System.err.println("GETTING MARGIN!");
return margins;
} }
public final void setNearDecoration(boolean nearDecoration) { public final void ensureMargins(Margins newMargins) {
// checkNotGroup(); // checkNotGroup();
this.nearDecoration = nearDecoration; this.margins = this.margins.merge(newMargins);
} }
public int getXposition() { public int getXposition() {

View File

@ -132,7 +132,6 @@ public class CommandCreateElementParenthesis extends SingleLineCommand2<ClassDia
return ColorParser.simpleColor(ColorType.BACK, "COLOR2"); return ColorParser.simpleColor(ColorType.BACK, "COLOR2");
} }
@Override @Override
final protected boolean isForbidden(CharSequence line) { final protected boolean isForbidden(CharSequence line) {
if (line.toString().matches("^[\\p{L}0-9_.]+$")) { if (line.toString().matches("^[\\p{L}0-9_.]+$")) {

View File

@ -52,6 +52,7 @@ import net.sourceforge.plantuml.cucadiagram.ILeaf;
import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg;
import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType; import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.cucadiagram.Stereotype;
@ -258,9 +259,11 @@ public class CommandLinkElement extends SingleLineCommand2<DescriptionDiagram> {
cl1 = getFoo1(diagram, code1, ident1, ident1pure); cl1 = getFoo1(diagram, code1, ident1, ident1pure);
cl2 = getFoo1(diagram, code2, ident2, ident2pure); cl2 = getFoo1(diagram, code2, ident2, ident2pure);
} }
Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, Display.getWithNewlines(labels.getLabelLink()), final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(labels.getLabelLink()), queue.length(),
queue.length(), labels.getFirstLabel(), labels.getSecondLabel(), diagram.getLabeldistance(), diagram.getSkinParam().classAttributeIconSize() > 0);
diagram.getLabelangle()); Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType,
linkArg.withQualifier(labels.getFirstLabel(), labels.getSecondLabel())
.withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle()));
link.setLinkArrow(labels.getLinkArrow()); link.setLinkArrow(labels.getLinkArrow());
if (dir == Direction.LEFT || dir == Direction.UP) if (dir == Direction.LEFT || dir == Direction.UP)
link = link.getInv(); link = link.getInv();

View File

@ -54,9 +54,8 @@ public class Labels {
this.secondLabel = arg.get("SECOND_LABEL", 0); this.secondLabel = arg.get("SECOND_LABEL", 0);
String labelLink = arg.get("LABEL_LINK", 0); String labelLink = arg.get("LABEL_LINK", 0);
if (labelLink != null) { if (labelLink != null)
labelLink = init(labelLink); labelLink = init(labelLink);
}
this.stringWithArrow = new StringWithArrow(labelLink); this.stringWithArrow = new StringWithArrow(labelLink);

View File

@ -110,24 +110,6 @@ public class StringWithArrow {
final TextBlock arrow = new TextBlockArrow2(guide, font); final TextBlock arrow = new TextBlockArrow2(guide, font);
return TextBlockUtils.mergeLR(arrow, label, VerticalAlignment.CENTER); return TextBlockUtils.mergeLR(arrow, label, VerticalAlignment.CENTER);
} }
/*
static public TextBlock addMagicArrow2(TextBlock label, GuideLine guide, FontConfiguration font) {
final TextBlock arrowRight = new TextBlockArrow(Direction.RIGHT, font);
final TextBlock arrowLeft = new TextBlockArrow(Direction.LEFT, font);
final TextBlock arrowUp = new TextBlockArrow(Direction.UP, font);
final TextBlock arrowDown = new TextBlockArrow(Direction.DOWN, font);
final TextBlock right = TextBlockUtils.mergeLR(label, arrowRight, VerticalAlignment.CENTER);
final TextBlock left = TextBlockUtils.mergeLR(arrowLeft, label, VerticalAlignment.CENTER);
final TextBlock up = TextBlockUtils.mergeLR(arrowUp, label, VerticalAlignment.CENTER);
final TextBlock down = TextBlockUtils.mergeLR(label, arrowDown, VerticalAlignment.CENTER);
return new DirectionalTextBlock(guide, right, left, up, down);
}
static public TextBlock addMagicArrow(TextBlock label, GuideLine guide, FontConfiguration font) {
final TextBlock arrow = new TextBlockArrow2(guide, font);
return TextBlockUtils.mergeLR(label, arrow, VerticalAlignment.CENTER);
}
public static TextBlock addSeveralMagicArrows(Display label, GuideLine guide, FontConfiguration font, public static TextBlock addSeveralMagicArrows(Display label, GuideLine guide, FontConfiguration font,
HorizontalAlignment alignment, ISkinParam skinParam) { HorizontalAlignment alignment, ISkinParam skinParam) {
@ -135,25 +117,9 @@ public class StringWithArrow {
for (CharSequence cs : label) { for (CharSequence cs : label) {
StringWithArrow tmp = new StringWithArrow(cs.toString()); StringWithArrow tmp = new StringWithArrow(cs.toString());
TextBlock block = tmp.getDisplay().create9(font, alignment, skinParam, skinParam.maxMessageSize()); TextBlock block = tmp.getDisplay().create9(font, alignment, skinParam, skinParam.maxMessageSize());
if (tmp.getLinkArrow() != LinkArrow.NONE_OR_SEVERAL) { if (tmp.getLinkArrow() != LinkArrow.NONE_OR_SEVERAL)
block = StringWithArrow.addMagicArrow(block, tmp.getLinkArrow().mute(guide), font);
}
result = TextBlockUtils.mergeTB(result, block, alignment);
}
return result;
}
*/
public static TextBlock addSeveralMagicArrows(Display label, GuideLine guide, FontConfiguration font,
HorizontalAlignment alignment, ISkinParam skinParam) {
TextBlock result = TextBlockUtils.EMPTY_TEXT_BLOCK;
for (CharSequence cs : label) {
StringWithArrow tmp = new StringWithArrow(cs.toString());
TextBlock block = tmp.getDisplay().create9(font, alignment, skinParam, skinParam.maxMessageSize());
if (tmp.getLinkArrow() != LinkArrow.NONE_OR_SEVERAL) {
block = StringWithArrow.addMagicArrow2(block, tmp.getLinkArrow().mute(guide), font); block = StringWithArrow.addMagicArrow2(block, tmp.getLinkArrow().mute(guide), font);
}
result = TextBlockUtils.mergeTB(result, block, alignment); result = TextBlockUtils.mergeTB(result, block, alignment);
} }
return result; return result;

View File

@ -53,6 +53,7 @@ import net.sourceforge.plantuml.cucadiagram.IGroup;
import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg;
import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType; import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.cucadiagram.NoteLinkStrategy; import net.sourceforge.plantuml.cucadiagram.NoteLinkStrategy;
@ -78,11 +79,14 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
if (link == null) { if (link == null) {
return false; return false;
} }
final Link l1 = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, node, link.getType(), link.getLabel(), link.getLength(), final Link l1 = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, node, link.getType(),
link.getQualifier1(), null, link.getLabeldistance(), link.getLabelangle()); LinkArg.build(link.getLabel(), link.getLength(), getSkinParam().classAttributeIconSize() > 0)
final Link l2 = new Link(getSkinParam().getCurrentStyleBuilder(), node, entity2, link.getType(), link.getLabel(), link.getLength(), .withQualifier(link.getQualifier1(), null)
null, link.getQualifier2(), link.getLabeldistance(), .withDistanceAngle(link.getLabeldistance(), link.getLabelangle()));
link.getLabelangle()); final Link l2 = new Link(getSkinParam().getCurrentStyleBuilder(), node, entity2, link.getType(),
LinkArg.build(link.getLabel(), link.getLength(), getSkinParam().classAttributeIconSize() > 0)
.withQualifier(null, link.getQualifier2())
.withDistanceAngle(link.getLabeldistance(), link.getLabelangle()));
addLink(l1); addLink(l1);
addLink(l2); addLink(l2);
removeLink(link); removeLink(link);
@ -147,8 +151,8 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
insertPointBetween(entity2A, entity2B, point2); insertPointBetween(entity2A, entity2B, point2);
final int length = 1; final int length = 1;
final Link point1ToPoint2 = new Link(getSkinParam().getCurrentStyleBuilder(), point1, point2, linkType, label, final Link point1ToPoint2 = new Link(getSkinParam().getCurrentStyleBuilder(), point1, point2, linkType,
length); LinkArg.build(label, length));
addLink(point1ToPoint2); addLink(point1ToPoint2);
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();
@ -159,8 +163,8 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
private void insertPointBetween(final IEntity entity1A, final IEntity entity1B, final IEntity point1) { private void insertPointBetween(final IEntity entity1A, final IEntity entity1B, final IEntity point1) {
Link existingLink1 = foundLink(entity1A, entity1B); Link existingLink1 = foundLink(entity1A, entity1B);
if (existingLink1 == null) { if (existingLink1 == null) {
existingLink1 = new Link(getSkinParam().getCurrentStyleBuilder(), entity1A, entity1B, new LinkType(LinkDecor.NONE, LinkDecor.NONE), Display.NULL, existingLink1 = new Link(getSkinParam().getCurrentStyleBuilder(), entity1A, entity1B,
2); new LinkType(LinkDecor.NONE, LinkDecor.NONE), LinkArg.noDisplay(2));
} else { } else {
removeLink(existingLink1); removeLink(existingLink1);
} }
@ -171,13 +175,16 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
: existingLink1.getEntity2(); : existingLink1.getEntity2();
final Link entity1ToPoint = new Link(getSkinParam().getCurrentStyleBuilder(), entity1real, point1, final Link entity1ToPoint = new Link(getSkinParam().getCurrentStyleBuilder(), entity1real, point1,
existingLink1.getType().getPart2(), existingLink1.getLabel(), existingLink1.getLength(), existingLink1.getQualifier1(), existingLink1.getType().getPart2(),
null, existingLink1.getLabeldistance(), LinkArg.build(existingLink1.getLabel(), existingLink1.getLength())
existingLink1.getLabelangle()); .withQualifier(existingLink1.getQualifier1(), null)
.withDistanceAngle(existingLink1.getLabeldistance(), existingLink1.getLabelangle()));
entity1ToPoint.setLinkArrow(existingLink1.getLinkArrow()); entity1ToPoint.setLinkArrow(existingLink1.getLinkArrow());
final Link pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point1, entity2real, existingLink1.getType().getPart1(), final Link pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point1, entity2real,
Display.NULL, existingLink1.getLength(), null, existingLink1.getQualifier2(), existingLink1.getType().getPart1(),
existingLink1.getLabeldistance(), existingLink1.getLabelangle()); LinkArg.noDisplay(existingLink1.getLength())
.withQualifier(null, existingLink1.getQualifier2())
.withDistanceAngle(existingLink1.getLabeldistance(), existingLink1.getLabelangle()));
// int length = 1; // int length = 1;
// if (existingLink.getLength() == 1 && entity1A != entity1B) { // if (existingLink.getLength() == 1 && entity1A != entity1B) {
@ -268,8 +275,8 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
void createNew(int mode, LinkType linkType, Display label) { void createNew(int mode, LinkType linkType, Display label) {
existingLink = foundLink(entity1, entity2); existingLink = foundLink(entity1, entity2);
if (existingLink == null) { if (existingLink == null) {
existingLink = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, entity2, new LinkType(LinkDecor.NONE, LinkDecor.NONE), Display.NULL, existingLink = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, entity2,
2); new LinkType(LinkDecor.NONE, LinkDecor.NONE), LinkArg.noDisplay(2));
} else { } else {
removeLink(existingLink); removeLink(existingLink);
} }
@ -279,13 +286,17 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
final IEntity entity2real = existingLink.isInverted() ? existingLink.getEntity1() final IEntity entity2real = existingLink.isInverted() ? existingLink.getEntity1()
: existingLink.getEntity2(); : existingLink.getEntity2();
entity1ToPoint = new Link(getSkinParam().getCurrentStyleBuilder(), entity1real, point, existingLink.getType().getPart2(), entity1ToPoint = new Link(getSkinParam().getCurrentStyleBuilder(), entity1real, point,
existingLink.getLabel(), existingLink.getLength(), existingLink.getQualifier1(), null, existingLink.getType().getPart2(),
existingLink.getLabeldistance(), existingLink.getLabelangle()); LinkArg.build(existingLink.getLabel(), existingLink.getLength())
.withQualifier(existingLink.getQualifier1(), null)
.withDistanceAngle(existingLink.getLabeldistance(), existingLink.getLabelangle()));
entity1ToPoint.setLinkArrow(existingLink.getLinkArrow()); entity1ToPoint.setLinkArrow(existingLink.getLinkArrow());
pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point, entity2real, existingLink.getType().getPart1(), pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point, entity2real,
Display.NULL, existingLink.getLength(), null, existingLink.getQualifier2(), existingLink.getType().getPart1(),
existingLink.getLabeldistance(), existingLink.getLabelangle()); LinkArg.noDisplay(existingLink.getLength())
.withQualifier(null, existingLink.getQualifier2())
.withDistanceAngle(existingLink.getLabeldistance(), existingLink.getLabelangle()));
int length = 1; int length = 1;
if (existingLink.getLength() == 1 && entity1 != entity2) { if (existingLink.getLength() == 1 && entity1 != entity2) {
@ -304,11 +315,11 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
addLink(pointToEntity2); addLink(pointToEntity2);
if (mode == 1) { if (mode == 1) {
pointToAssocied = new Link(getSkinParam().getCurrentStyleBuilder(), point, associed, linkType, label, pointToAssocied = new Link(getSkinParam().getCurrentStyleBuilder(), point, associed, linkType,
length); LinkArg.build(label, length));
} else { } else {
pointToAssocied = new Link(getSkinParam().getCurrentStyleBuilder(), associed, point, linkType, label, pointToAssocied = new Link(getSkinParam().getCurrentStyleBuilder(), associed, point, linkType,
length); LinkArg.build(label, length));
} }
addLink(pointToAssocied); addLink(pointToAssocied);
} }
@ -316,18 +327,20 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
void createInSecond(LinkType linkType, Display label) { void createInSecond(LinkType linkType, Display label) {
existingLink = foundLink(entity1, entity2); existingLink = foundLink(entity1, entity2);
if (existingLink == null) { if (existingLink == null) {
existingLink = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, entity2, new LinkType(LinkDecor.NONE, LinkDecor.NONE), Display.NULL, existingLink = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, entity2,
2); new LinkType(LinkDecor.NONE, LinkDecor.NONE), LinkArg.noDisplay(2));
} else { } else {
removeLink(existingLink); removeLink(existingLink);
} }
entity1ToPoint = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, point, existingLink.getType().getPart2(), existingLink.getLabel(), entity1ToPoint = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, point,
2, existingLink.getQualifier1(), null, existingLink.getLabeldistance(), existingLink.getType().getPart2(),
existingLink.getLabelangle()); LinkArg.build(existingLink.getLabel(), 2).withQualifier(existingLink.getQualifier1(), null)
pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point, entity2, existingLink.getType().getPart1(), Display.NULL, 2, .withDistanceAngle(existingLink.getLabeldistance(), existingLink.getLabelangle()));
null, existingLink.getQualifier2(), existingLink.getLabeldistance(), pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point, entity2,
existingLink.getLabelangle()); existingLink.getType().getPart1(),
LinkArg.noDisplay(2).withQualifier(null, existingLink.getQualifier2())
.withDistanceAngle(existingLink.getLabeldistance(), existingLink.getLabelangle()));
// entity1ToPoint = new Link(entity1, point, existingLink.getType(), // entity1ToPoint = new Link(entity1, point, existingLink.getType(),
// null, 2); // null, 2);
// pointToEntity2 = new Link(point, entity2, existingLink.getType(), // pointToEntity2 = new Link(point, entity2, existingLink.getType(),
@ -339,11 +352,12 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
other.pointToAssocied = other.pointToAssocied.getInv(); other.pointToAssocied = other.pointToAssocied.getInv();
addLink(other.pointToAssocied); addLink(other.pointToAssocied);
} }
pointToAssocied = new Link(getSkinParam().getCurrentStyleBuilder(), point, associed, linkType, label, 1); pointToAssocied = new Link(getSkinParam().getCurrentStyleBuilder(), point, associed, linkType,
LinkArg.build(label, 1));
addLink(pointToAssocied); addLink(pointToAssocied);
final Link lnode = new Link(getSkinParam().getCurrentStyleBuilder(), other.point, this.point, final Link lnode = new Link(getSkinParam().getCurrentStyleBuilder(), other.point, this.point,
new LinkType(LinkDecor.NONE, LinkDecor.NONE), Display.NULL, 1); new LinkType(LinkDecor.NONE, LinkDecor.NONE), LinkArg.noDisplay(1));
lnode.setInvis(true); lnode.setInvis(true);
addLink(lnode); addLink(lnode);

View File

@ -66,8 +66,8 @@ public class CommandAddData extends SingleLineCommand2<AbstractClassOrObjectDiag
protected CommandExecutionResult executeArg(AbstractClassOrObjectDiagram diagram, LineLocation location, protected CommandExecutionResult executeArg(AbstractClassOrObjectDiagram diagram, LineLocation location,
RegexResult arg) throws NoSuchColorException { RegexResult arg) throws NoSuchColorException {
final String name = arg.get("NAME", 0); final String name = arg.get("NAME", 0);
final IEntity entity = diagram.getOrCreateLeaf(diagram.buildLeafIdent(name), final IEntity entity = diagram.getOrCreateLeaf(diagram.buildLeafIdent(name), diagram.buildCode(name), null,
diagram.buildCode(name), null, null); null);
final String field = arg.get("DATA", 0); final String field = arg.get("DATA", 0);
if (field.length() > 0 && VisibilityModifier.isVisibilityCharacter(field)) { if (field.length() > 0 && VisibilityModifier.isVisibilityCharacter(field)) {

View File

@ -56,6 +56,7 @@ import net.sourceforge.plantuml.cucadiagram.ILeaf;
import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg;
import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType; import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.cucadiagram.Stereotype;
@ -128,8 +129,8 @@ public class CommandCreateMap extends CommandMultilines2<AbstractEntityDiagram>
final LinkType linkType = new LinkType(LinkDecor.ARROW, LinkDecor.NONE); final LinkType linkType = new LinkType(LinkDecor.ARROW, LinkDecor.NONE);
final int length = linkStr.length() - 2; final int length = linkStr.length() - 2;
final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), entity1, entity2, linkType, Display.NULL, final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), entity1, entity2, linkType,
length); LinkArg.noDisplay(length));
link.setPortMembers(key, null); link.setPortMembers(key, null);
diagram.addLink(link); diagram.addLink(link);
} }

View File

@ -52,6 +52,7 @@ import java.net.URLEncoder;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import net.sourceforge.plantuml.BlockUml; import net.sourceforge.plantuml.BlockUml;
import net.sourceforge.plantuml.ErrorUml; import net.sourceforge.plantuml.ErrorUml;
@ -69,6 +70,9 @@ import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.error.PSystemError; import net.sourceforge.plantuml.error.PSystemError;
import net.sourceforge.plantuml.error.PSystemErrorUtils; import net.sourceforge.plantuml.error.PSystemErrorUtils;
import net.sourceforge.plantuml.graphic.QuoteUtils; import net.sourceforge.plantuml.graphic.QuoteUtils;
import net.sourceforge.plantuml.json.Json;
import net.sourceforge.plantuml.json.JsonArray;
import net.sourceforge.plantuml.json.JsonObject;
import net.sourceforge.plantuml.log.Logme; import net.sourceforge.plantuml.log.Logme;
import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.security.SFile;
import net.sourceforge.plantuml.version.Version; import net.sourceforge.plantuml.version.Version;
@ -76,16 +80,19 @@ import net.sourceforge.plantuml.version.Version;
public class PicoWebServer implements Runnable { public class PicoWebServer implements Runnable {
private final Socket connect; private final Socket connect;
private static final AtomicBoolean stopRequested = new AtomicBoolean(false);
private static boolean enableStop;
public PicoWebServer(Socket c) { public PicoWebServer(Socket c) {
this.connect = c; this.connect = c;
} }
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
startServer(8080, null); startServer(8080, null, false);
} }
public static void startServer(final int port, final String bindAddress) throws IOException { public static void startServer(final int port, final String bindAddress, final boolean argEnableStop) throws IOException {
PicoWebServer.enableStop = argEnableStop;
final InetAddress bindAddress1 = bindAddress == null ? null : InetAddress.getByName(bindAddress); final InetAddress bindAddress1 = bindAddress == null ? null : InetAddress.getByName(bindAddress);
final ServerSocket serverConnect = new ServerSocket(port, 50, bindAddress1); final ServerSocket serverConnect = new ServerSocket(port, 50, bindAddress1);
System.err.println("webPort=" + serverConnect.getLocalPort()); System.err.println("webPort=" + serverConnect.getLocalPort());
@ -93,7 +100,7 @@ public class PicoWebServer implements Runnable {
} }
public static void serverLoop(final ServerSocket serverConnect) throws IOException { public static void serverLoop(final ServerSocket serverConnect) throws IOException {
while (true) { while (stopRequested.get() == false) {
final PicoWebServer myServer = new PicoWebServer(serverConnect.accept()); final PicoWebServer myServer = new PicoWebServer(serverConnect.accept());
final Thread thread = new Thread(myServer); final Thread thread = new Thread(myServer);
thread.start(); thread.start();
@ -126,6 +133,14 @@ public class PicoWebServer implements Runnable {
return; return;
if (request.getPath().startsWith("/plantuml/utxt/") && handleGET(request, out, FileFormat.UTXT)) if (request.getPath().startsWith("/plantuml/utxt/") && handleGET(request, out, FileFormat.UTXT))
return; return;
if (request.getPath().startsWith("/serverinfo") && handleInfo(out))
return;
if (request.getPath().startsWith("/plantuml/serverinfo") && handleInfo(out))
return;
if (enableStop && request.getPath().startsWith("/stopserver")) {
stopRequested.set(true);
return;
}
} else if (request.getMethod().equals("POST") && request.getPath().equals("/render")) { } else if (request.getMethod().equals("POST") && request.getPath().equals("/render")) {
handleRenderRequest(request, out); handleRenderRequest(request, out);
return; return;
@ -152,6 +167,29 @@ public class PicoWebServer implements Runnable {
} }
} }
private boolean handleInfo(BufferedOutputStream out) throws IOException {
write(out, "HTTP/1.1 " + "200");
write(out, "Cache-Control: no-cache");
write(out, "Server: PlantUML PicoWebServer " + Version.versionString());
write(out, "Date: " + new Date());
write(out, "Content-Type: application/json");
write(out, "");
final JsonArray formats = new JsonArray();
formats.add("png");
formats.add("svg");
formats.add("txt");
final JsonObject json = Json.object() //
.add("version", Version.versionString()) //
.add("PicoWebServer", true) //
.add("formats", formats); //
write(out, json.toString());
out.flush();
return true;
}
private boolean handleGET(ReceivedHTTPRequest request, BufferedOutputStream out, final FileFormat format) private boolean handleGET(ReceivedHTTPRequest request, BufferedOutputStream out, final FileFormat format)
throws IOException { throws IOException {
final int x = request.getPath().lastIndexOf('/'); final int x = request.getPath().lastIndexOf('/');

View File

@ -49,8 +49,9 @@ public abstract class AbstractTask implements Task {
this.code = code; this.code = code;
} }
public void putInSameRowAs(Task row) { final public void putInSameRowAs(Task row) {
this.row = row; if (this != row)
this.row = row;
} }
public final Task getRow() { public final Task getRow() {

View File

@ -142,15 +142,15 @@ public abstract class AbstractTaskDraw implements TaskDraw {
return margin.getTop() + getShapeHeight(stringBounder) + margin.getBottom(); return margin.getTop() + getShapeHeight(stringBounder) + margin.getBottom();
} }
public TaskDraw getTrueRow() { final public TaskDraw getTrueRow() {
return toTaskDraw.getTaskDraw(task.getRow()); return toTaskDraw.getTaskDraw(task.getRow());
} }
@Override @Override
final public Real getY(StringBounder stringBounder) { final public Real getY(StringBounder stringBounder) {
if (task.getRow() == null) { if (task.getRow() == null)
return y; return y;
}
return getTrueRow().getY(stringBounder); return getTrueRow().getY(stringBounder);
} }
@ -167,12 +167,12 @@ public abstract class AbstractTaskDraw implements TaskDraw {
final double y1 = margin.getTop() + getY(stringBounder).getCurrentValue(); final double y1 = margin.getTop() + getY(stringBounder).getCurrentValue();
final double y2 = y1 + getShapeHeight(stringBounder); final double y2 = y1 + getShapeHeight(stringBounder);
if (direction == Direction.UP) { if (direction == Direction.UP)
return y1; return y1;
}
if (direction == Direction.DOWN) { if (direction == Direction.DOWN)
return y2; return y2;
}
return (y1 + y2) / 2; return (y1 + y2) / 2;
} }

View File

@ -49,9 +49,9 @@ public class SentenceDisplayOnSameRowAs extends SentenceSimple {
public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) {
final Task task1 = (Task) subject; final Task task1 = (Task) subject;
final Task task2 = project.getExistingTask((String) complement); final Task task2 = project.getExistingTask((String) complement);
if (task2 == null) { if (task2 == null)
return CommandExecutionResult.error("No such task " + task2); return CommandExecutionResult.error("No such task " + task2);
}
task1.putInSameRowAs(task2); task1.putInSameRowAs(task2);
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();
} }

View File

@ -79,22 +79,21 @@ abstract class CommandExoArrowAny extends SingleLineCommand2<SequenceDiagram> {
final boolean dotted = body.contains("--"); final boolean dotted = body.contains("--");
final Display labels; final Display labels;
if (arg.get("LABEL", 0) == null) { if (arg.get("LABEL", 0) == null)
labels = Display.create(""); labels = Display.create("");
} else { else
labels = Display.getWithNewlines(arg.get("LABEL", 0)); labels = Display.getWithNewlines(arg.get("LABEL", 0));
}
final boolean bothDirection = arg.get("ARROW_BOTHDRESSING", 0) != null; final boolean bothDirection = arg.get("ARROW_BOTHDRESSING", 0) != null;
ArrowConfiguration config = bothDirection ? ArrowConfiguration.withDirectionBoth() ArrowConfiguration config = bothDirection ? 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);
}
final MessageExoType messageExoType = getMessageExoType(arg); final MessageExoType messageExoType = getMessageExoType(arg);
config = config.withPart(getArrowPart(dressing, messageExoType)); config = config.withPart(getArrowPart(dressing, messageExoType));
@ -103,36 +102,35 @@ abstract class CommandExoArrowAny extends SingleLineCommand2<SequenceDiagram> {
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(p, LifeEventType.CREATE, null); diagram.activate(p, LifeEventType.CREATE, null);
}
if (messageExoType == MessageExoType.TO_RIGHT || messageExoType == MessageExoType.TO_LEFT) { if (messageExoType == MessageExoType.TO_RIGHT || messageExoType == MessageExoType.TO_LEFT) {
if (containsSymbol(ARROW_SUPPCIRCLE1, arg, "o")) { if (containsSymbol(ARROW_SUPPCIRCLE1, arg, "o"))
config = config.withDecoration1(ArrowDecoration.CIRCLE); config = config.withDecoration1(ArrowDecoration.CIRCLE);
}
if (containsSymbol(ARROW_SUPPCIRCLE1, arg, "x")) { if (containsSymbol(ARROW_SUPPCIRCLE1, arg, "x"))
config = config.withHead1(ArrowHead.CROSSX); config = config.withHead1(ArrowHead.CROSSX);
}
if (containsSymbol(ARROW_SUPPCIRCLE2, arg, "o")) { if (containsSymbol(ARROW_SUPPCIRCLE2, arg, "o"))
config = config.withDecoration2(ArrowDecoration.CIRCLE); config = config.withDecoration2(ArrowDecoration.CIRCLE);
}
if (containsSymbol(ARROW_SUPPCIRCLE2, arg, "x")) { if (containsSymbol(ARROW_SUPPCIRCLE2, arg, "x"))
config = config.withHead2(ArrowHead.CROSSX); config = config.withHead2(ArrowHead.CROSSX);
}
} else { } else {
if (containsSymbol(ARROW_SUPPCIRCLE2, arg, "o")) { if (containsSymbol(ARROW_SUPPCIRCLE2, arg, "o"))
config = config.withDecoration1(ArrowDecoration.CIRCLE); config = config.withDecoration1(ArrowDecoration.CIRCLE);
}
if (containsSymbol(ARROW_SUPPCIRCLE2, arg, "x")) { if (containsSymbol(ARROW_SUPPCIRCLE2, arg, "x"))
config = config.withHead1(ArrowHead.CROSSX); config = config.withHead1(ArrowHead.CROSSX);
}
if (containsSymbol(ARROW_SUPPCIRCLE1, arg, "o")) { if (containsSymbol(ARROW_SUPPCIRCLE1, arg, "o"))
config = config.withDecoration2(ArrowDecoration.CIRCLE); config = config.withDecoration2(ArrowDecoration.CIRCLE);
}
if (containsSymbol(ARROW_SUPPCIRCLE1, arg, "x")) { if (containsSymbol(ARROW_SUPPCIRCLE1, arg, "x"))
config = config.withHead2(ArrowHead.CROSSX); config = config.withHead2(ArrowHead.CROSSX);
}
} }
final MessageExo msg = new MessageExo(diagram.getSkinParam().getCurrentStyleBuilder(), p, messageExoType, final MessageExo msg = new MessageExo(diagram.getSkinParam().getCurrentStyleBuilder(), p, messageExoType,
@ -144,17 +142,17 @@ abstract class CommandExoArrowAny extends SingleLineCommand2<SequenceDiagram> {
} }
final boolean parallel = arg.get("PARALLEL", 0) != null; final boolean parallel = arg.get("PARALLEL", 0) != null;
if (parallel) { if (parallel)
msg.goParallel(); 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
@ -176,11 +174,10 @@ abstract class CommandExoArrowAny extends SingleLineCommand2<SequenceDiagram> {
} }
} else if (diagram.isAutoactivate() } else if (diagram.isAutoactivate()
&& (config.getHead() == ArrowHead.NORMAL || config.getHead() == ArrowHead.ASYNC)) { && (config.getHead() == ArrowHead.NORMAL || config.getHead() == ArrowHead.ASYNC)) {
if (config.isDotted()) { if (config.isDotted())
diagram.activate(p, LifeEventType.DEACTIVATE, null); diagram.activate(p, LifeEventType.DEACTIVATE, null);
} else { else
diagram.activate(p, LifeEventType.ACTIVATE, activationColor); diagram.activate(p, LifeEventType.ACTIVATE, activationColor);
}
} }
@ -189,15 +186,15 @@ abstract class CommandExoArrowAny extends SingleLineCommand2<SequenceDiagram> {
private ArrowPart getArrowPart(String dressing, MessageExoType messageExoType) { private ArrowPart getArrowPart(String dressing, MessageExoType messageExoType) {
if (dressing.contains("/")) { if (dressing.contains("/")) {
if (messageExoType.getDirection() == 1) { if (messageExoType.getDirection() == 1)
return ArrowPart.BOTTOM_PART; return ArrowPart.BOTTOM_PART;
}
return ArrowPart.TOP_PART; return ArrowPart.TOP_PART;
} }
if (dressing.contains("\\")) { if (dressing.contains("\\")) {
if (messageExoType.getDirection() == 1) { if (messageExoType.getDirection() == 1)
return ArrowPart.TOP_PART; return ArrowPart.TOP_PART;
}
return ArrowPart.BOTTOM_PART; return ArrowPart.BOTTOM_PART;
} }
return ArrowPart.FULL; return ArrowPart.FULL;
@ -207,17 +204,17 @@ abstract class CommandExoArrowAny extends SingleLineCommand2<SequenceDiagram> {
private boolean isShortArrow(RegexResult arg2) { private boolean isShortArrow(RegexResult arg2) {
final String s = arg2.get(ARROW_SUPPCIRCLE2, 0); final String s = arg2.get(ARROW_SUPPCIRCLE2, 0);
if (s != null && s.contains("?")) { if (s != null && s.contains("?"))
return true; return true;
}
return false; return false;
} }
private boolean containsSymbol(String suppCircle, RegexResult arg2, String symbol) { private boolean containsSymbol(String suppCircle, RegexResult arg2, String symbol) {
final String s = arg2.get(suppCircle, 0); final String s = arg2.get(suppCircle, 0);
if (s != null && s.contains(symbol)) { if (s != null && s.contains(symbol))
return true; return true;
}
return false; return false;
} }

View File

@ -91,20 +91,20 @@ public class CommandExoArrowLeft extends CommandExoArrowAny {
final String dressing1 = arg2.get("ARROW_DRESSING1", 0); final String dressing1 = arg2.get("ARROW_DRESSING1", 0);
final String dressing2 = arg2.get("ARROW_DRESSING2", 0); final String dressing2 = arg2.get("ARROW_DRESSING2", 0);
if (start != null && start.contains("]")) { if (start != null && start.contains("]")) {
if (dressing1 != null) { if (dressing1 != null)
return MessageExoType.FROM_RIGHT; return MessageExoType.FROM_RIGHT;
}
if (dressing2 != null) { if (dressing2 != null)
return MessageExoType.TO_RIGHT; return MessageExoType.TO_RIGHT;
}
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
if (dressing1 != null) { if (dressing1 != null)
return MessageExoType.FROM_LEFT; return MessageExoType.FROM_LEFT;
}
if (dressing2 != null) { if (dressing2 != null)
return MessageExoType.TO_LEFT; return MessageExoType.TO_LEFT;
}
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }

View File

@ -91,20 +91,20 @@ public class CommandExoArrowRight extends CommandExoArrowAny {
final String dressing1 = arg2.get("ARROW_DRESSING1", 0); final String dressing1 = arg2.get("ARROW_DRESSING1", 0);
final String dressing2 = arg2.get("ARROW_DRESSING2", 0); final String dressing2 = arg2.get("ARROW_DRESSING2", 0);
if (start != null && start.contains("[")) { if (start != null && start.contains("[")) {
if (dressing1 != null) { if (dressing1 != null)
return MessageExoType.TO_LEFT; return MessageExoType.TO_LEFT;
}
if (dressing2 != null) { if (dressing2 != null)
return MessageExoType.FROM_LEFT; return MessageExoType.FROM_LEFT;
}
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
if (dressing1 != null) { if (dressing1 != null)
return MessageExoType.TO_RIGHT; return MessageExoType.TO_RIGHT;
}
if (dressing2 != null) { if (dressing2 != null)
return MessageExoType.FROM_RIGHT; return MessageExoType.FROM_RIGHT;
}
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }

View File

@ -132,13 +132,13 @@ class Step1MessageExo extends Step1Abstract {
final MessageExoType type = m.getType(); final MessageExoType type = m.getType();
ArrowConfiguration result = null; ArrowConfiguration result = null;
if (type.getDirection() == 1) { if (type.getDirection() == 1)
result = m.getArrowConfiguration(); result = m.getArrowConfiguration();
} else { else
result = m.getArrowConfiguration().reverse(); result = m.getArrowConfiguration().reverse();
}
result = result.withDecoration1(m.getArrowConfiguration().getDecoration1()); // result = result.withDecoration1(m.getArrowConfiguration().getDecoration1());
result = result.withDecoration2(m.getArrowConfiguration().getDecoration2()); // result = result.withDecoration2(m.getArrowConfiguration().getDecoration2());
return result; return result;
// ArrowConfiguration result = null; // ArrowConfiguration result = null;
// if (type.getDirection() == 1) { // if (type.getDirection() == 1) {

View File

@ -83,15 +83,16 @@ public class ComponentRoseArrow extends AbstractComponentRoseArrow {
@Override @Override
public void drawInternalU(UGraphic ug, Area area) { public void drawInternalU(UGraphic ug, Area area) {
if (getArrowConfiguration().isHidden()) final ArrowConfiguration arrowConfiguration = getArrowConfiguration();
if (arrowConfiguration.isHidden())
return; return;
final Dimension2D dimensionToUse = area.getDimensionToUse(); final Dimension2D dimensionToUse = area.getDimensionToUse();
final StringBounder stringBounder = ug.getStringBounder(); final StringBounder stringBounder = ug.getStringBounder();
ug = ug.apply(getForegroundColor()); ug = ug.apply(getForegroundColor());
final ArrowDressing dressing1 = getArrowConfiguration().getDressing1(); final ArrowDressing dressing1 = arrowConfiguration.getDressing1();
final ArrowDressing dressing2 = getArrowConfiguration().getDressing2(); final ArrowDressing dressing2 = arrowConfiguration.getDressing2();
double start = 0; double start = 0;
double len = dimensionToUse.getWidth() - 1; double len = dimensionToUse.getWidth() - 1;
@ -100,18 +101,18 @@ public class ComponentRoseArrow extends AbstractComponentRoseArrow {
final double pos1 = start + 1; final double pos1 = start + 1;
final double pos2 = len - 1; final double pos2 = len - 1;
if (getArrowConfiguration().getDecoration2() == ArrowDecoration.CIRCLE && dressing2.getHead() == ArrowHead.NONE) if (arrowConfiguration.getDecoration2() == ArrowDecoration.CIRCLE && dressing2.getHead() == ArrowHead.NONE)
len -= diamCircle / 2; len -= diamCircle / 2;
if (getArrowConfiguration().getDecoration2() == ArrowDecoration.CIRCLE && dressing2.getHead() != ArrowHead.NONE) if (arrowConfiguration.getDecoration2() == ArrowDecoration.CIRCLE && dressing2.getHead() != ArrowHead.NONE)
len -= diamCircle / 2 + thinCircle; len -= diamCircle / 2 + thinCircle;
if (getArrowConfiguration().getDecoration1() == ArrowDecoration.CIRCLE if (arrowConfiguration.getDecoration1() == ArrowDecoration.CIRCLE
&& dressing1.getHead() == ArrowHead.NONE) { && dressing1.getHead() == ArrowHead.NONE) {
start += diamCircle / 2; start += diamCircle / 2;
len -= diamCircle / 2; len -= diamCircle / 2;
} }
if (getArrowConfiguration().getDecoration1() == ArrowDecoration.CIRCLE if (arrowConfiguration.getDecoration1() == ArrowDecoration.CIRCLE
&& dressing1.getHead() == ArrowHead.NORMAL) { && dressing1.getHead() == ArrowHead.NORMAL) {
start += diamCircle + thinCircle; start += diamCircle + thinCircle;
len -= diamCircle + thinCircle; len -= diamCircle + thinCircle;
@ -144,16 +145,16 @@ public class ComponentRoseArrow extends AbstractComponentRoseArrow {
} }
drawDressing1(ug.apply(new UTranslate(pos1, posArrow + inclination1)), dressing1, drawDressing1(ug.apply(new UTranslate(pos1, posArrow + inclination1)), dressing1,
getArrowConfiguration().getDecoration1(), lenFull); arrowConfiguration.getDecoration1(), lenFull);
drawDressing2(ug.apply(new UTranslate(pos2, posArrow + inclination2)), dressing2, drawDressing2(ug.apply(new UTranslate(pos2, posArrow + inclination2)), dressing2,
getArrowConfiguration().getDecoration2(), lenFull); arrowConfiguration.getDecoration2(), lenFull);
if (inclination1 == 0 && inclination2 == 0) if (inclination1 == 0 && inclination2 == 0)
getArrowConfiguration().applyStroke(ug).apply(new UTranslate(start, posArrow)).draw(new ULine(len, 0)); arrowConfiguration.applyStroke(ug).apply(new UTranslate(start, posArrow)).draw(new ULine(len, 0));
else if (inclination1 != 0) else if (inclination1 != 0)
drawLine(getArrowConfiguration().applyStroke(ug), start + len, posArrow, 0, posArrow + inclination1); drawLine(arrowConfiguration.applyStroke(ug), start + len, posArrow, 0, posArrow + inclination1);
else if (inclination2 != 0) else if (inclination2 != 0)
drawLine(getArrowConfiguration().applyStroke(ug), start, posArrow, pos2, posArrow + inclination2); drawLine(arrowConfiguration.applyStroke(ug), start, posArrow, pos2, posArrow + inclination2);
final ArrowDirection direction2 = getDirection2(); final ArrowDirection direction2 = getDirection2();
final double textPos; final double textPos;

View File

@ -37,7 +37,6 @@ package net.sourceforge.plantuml.skin.rose;
import net.sourceforge.plantuml.AlignmentParam; import net.sourceforge.plantuml.AlignmentParam;
import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.LineParam;
import net.sourceforge.plantuml.PaddingParam; import net.sourceforge.plantuml.PaddingParam;

View File

@ -67,7 +67,8 @@ public class CommandAddField extends SingleLineCommand2<StateDiagram> {
} }
@Override @Override
protected CommandExecutionResult executeArg(StateDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { protected CommandExecutionResult executeArg(StateDiagram diagram, LineLocation location, RegexResult arg)
throws NoSuchColorException {
final String codeString = arg.getLazzy("CODE", 0); final String codeString = arg.getLazzy("CODE", 0);
final String field = arg.get("FIELD", 0); final String field = arg.get("FIELD", 0);

View File

@ -51,6 +51,7 @@ import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg;
import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType; import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.cucadiagram.Stereotype;
@ -76,19 +77,18 @@ abstract class CommandLinkStateCommon extends SingleLineCommand2<StateDiagram> {
final String ent2 = arg.get("ENT2", 0); final String ent2 = arg.get("ENT2", 0);
final IEntity cl1 = getEntityStart(diagram, ent1); final IEntity cl1 = getEntityStart(diagram, ent1);
if (cl1 == null) { if (cl1 == null)
return CommandExecutionResult return CommandExecutionResult
.error("The state " + ent1 + " has been created in a concurrent state : it cannot be used here."); .error("The state " + ent1 + " has been created in a concurrent state : it cannot be used here.");
}
final IEntity cl2 = getEntityEnd(diagram, ent2); final IEntity cl2 = getEntityEnd(diagram, ent2);
if (cl2 == null) { if (cl2 == null)
return CommandExecutionResult return CommandExecutionResult
.error("The state " + ent2 + " has been created in a concurrent state : it cannot be used here."); .error("The state " + ent2 + " has been created in a concurrent state : it cannot be used here.");
}
if (arg.get("ENT1", 1) != null) { if (arg.get("ENT1", 1) != null)
cl1.setStereotype(Stereotype.build(arg.get("ENT1", 1))); cl1.setStereotype(Stereotype.build(arg.get("ENT1", 1)));
}
if (arg.get("ENT1", 2) != null) { if (arg.get("ENT1", 2) != null) {
final String s = arg.get("ENT1", 2); final String s = arg.get("ENT1", 2);
cl1.setSpecificColorTOBEREMOVED(ColorType.BACK, cl1.setSpecificColorTOBEREMOVED(ColorType.BACK,
@ -106,9 +106,8 @@ abstract class CommandLinkStateCommon extends SingleLineCommand2<StateDiagram> {
String queue = arg.get("ARROW_BODY1", 0) + arg.get("ARROW_BODY2", 0); String queue = arg.get("ARROW_BODY1", 0) + arg.get("ARROW_BODY2", 0);
final Direction dir = getDirection(arg); final Direction dir = getDirection(arg);
if (dir == Direction.LEFT || dir == Direction.RIGHT) { if (dir == Direction.LEFT || dir == Direction.RIGHT)
queue = "-"; queue = "-";
}
final int lenght = queue.length(); final int lenght = queue.length();
@ -118,10 +117,11 @@ abstract class CommandLinkStateCommon extends SingleLineCommand2<StateDiagram> {
crossStart ? LinkDecor.CIRCLE_CROSS : LinkDecor.NONE); crossStart ? LinkDecor.CIRCLE_CROSS : LinkDecor.NONE);
final Display label = Display.getWithNewlines(arg.get("LABEL", 0)); final Display label = Display.getWithNewlines(arg.get("LABEL", 0));
Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, label, lenght); final LinkArg linkArg = LinkArg.build(label, lenght, diagram.getSkinParam().classAttributeIconSize() > 0);
if (dir == Direction.LEFT || dir == Direction.UP) { Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, linkArg);
if (dir == Direction.LEFT || dir == Direction.UP)
link = link.getInv(); link = link.getInv();
}
link.applyStyle(diagram.getSkinParam().getThemeStyle(), arg.getLazzy("ARROW_STYLE", 0)); link.applyStyle(diagram.getSkinParam().getThemeStyle(), arg.getLazzy("ARROW_STYLE", 0));
link.setUmlDiagramType(UmlDiagramType.STATE); link.setUmlDiagramType(UmlDiagramType.STATE);
diagram.addLink(link); diagram.addLink(link);
@ -131,9 +131,9 @@ abstract class CommandLinkStateCommon extends SingleLineCommand2<StateDiagram> {
private Direction getDirection(RegexResult arg) { private Direction getDirection(RegexResult arg) {
final String arrowDirection = arg.get("ARROW_DIRECTION", 0); final String arrowDirection = arg.get("ARROW_DIRECTION", 0);
if (arrowDirection != null) { if (arrowDirection != null)
return StringUtils.getQueueDirection(arrowDirection); return StringUtils.getQueueDirection(arrowDirection);
}
return getDefaultDirection(); return getDefaultDirection();
} }
@ -142,32 +142,32 @@ abstract class CommandLinkStateCommon extends SingleLineCommand2<StateDiagram> {
} }
private IEntity getEntityStart(StateDiagram diagram, final String codeString) { private IEntity getEntityStart(StateDiagram diagram, final String codeString) {
if (codeString.startsWith("[*]")) { if (codeString.startsWith("[*]"))
return diagram.getStart(); return diagram.getStart();
}
return getFoo1(diagram, codeString); return getFoo1(diagram, codeString);
} }
private IEntity getEntityEnd(StateDiagram diagram, final String codeString) { private IEntity getEntityEnd(StateDiagram diagram, final String codeString) {
if (codeString.startsWith("[*]")) { if (codeString.startsWith("[*]"))
return diagram.getEnd(); return diagram.getEnd();
}
return getFoo1(diagram, codeString); return getFoo1(diagram, codeString);
} }
private IEntity getFoo1(StateDiagram diagram, final String codeString) { private IEntity getFoo1(StateDiagram diagram, final String codeString) {
if (codeString.equalsIgnoreCase("[H]")) { if (codeString.equalsIgnoreCase("[H]"))
return diagram.getHistorical(); return diagram.getHistorical();
}
if (codeString.endsWith("[H]")) { if (codeString.endsWith("[H]"))
return diagram.getHistorical(codeString.substring(0, codeString.length() - 3)); return diagram.getHistorical(codeString.substring(0, codeString.length() - 3));
}
if (codeString.equalsIgnoreCase("[H*]")) { if (codeString.equalsIgnoreCase("[H*]"))
return diagram.getDeepHistory(); return diagram.getDeepHistory();
}
if (codeString.endsWith("[H*]")) { if (codeString.endsWith("[H*]"))
return diagram.getDeepHistory(codeString.substring(0, codeString.length() - 4)); return diagram.getDeepHistory(codeString.substring(0, codeString.length() - 4));
}
if (codeString.startsWith("=") && codeString.endsWith("=")) { if (codeString.startsWith("=") && codeString.endsWith("=")) {
final String codeString1 = removeEquals(codeString); final String codeString1 = removeEquals(codeString);
final Ident ident1 = diagram.buildLeafIdent(codeString1); final Ident ident1 = diagram.buildLeafIdent(codeString1);
@ -176,19 +176,19 @@ abstract class CommandLinkStateCommon extends SingleLineCommand2<StateDiagram> {
} }
final Ident ident = diagram.buildLeafIdent(codeString); final Ident ident = diagram.buildLeafIdent(codeString);
final Code code = diagram.V1972() ? ident : diagram.buildCode(codeString); final Code code = diagram.V1972() ? ident : diagram.buildCode(codeString);
if (diagram.checkConcurrentStateOk(ident, code) == false) { if (diagram.checkConcurrentStateOk(ident, code) == false)
return null; return null;
}
return diagram.getOrCreateLeaf(ident, code, null, null); return diagram.getOrCreateLeaf(ident, code, null, null);
} }
private String removeEquals(String code) { private String removeEquals(String code) {
while (code.startsWith("=")) { while (code.startsWith("="))
code = code.substring(1); code = code.substring(1);
}
while (code.endsWith("=")) { while (code.endsWith("="))
code = code.substring(0, code.length() - 1); code = code.substring(0, code.length() - 1);
}
return code; return code;
} }

View File

@ -76,7 +76,7 @@ public final class CucaDiagramFileMakerSvek implements CucaDiagramFileMaker {
final DotData dotData = new DotData(diagram.getEntityFactory().getRootGroup(), getOrderedLinks(), final DotData dotData = new DotData(diagram.getEntityFactory().getRootGroup(), getOrderedLinks(),
diagram.getLeafsvalues(), diagram.getUmlDiagramType(), diagram.getSkinParam(), diagram, diagram, diagram.getLeafsvalues(), diagram.getUmlDiagramType(), diagram.getSkinParam(), diagram, diagram,
diagram.getColorMapper(), diagram.getEntityFactory(), diagram.isHideEmptyDescriptionForState(), dotMode, diagram.getColorMapper(), diagram.getEntityFactory(), diagram.isHideEmptyDescriptionForState(), dotMode,
diagram.getNamespaceSeparator(), diagram.getPragma()); diagram.getNamespaceSeparator(), diagram.getPragma(), diagram.getGraphvizVersion());
final boolean intricated = diagram.mergeIntricated(); final boolean intricated = diagram.mergeIntricated();
return new GeneralImageBuilder(intricated, dotData, diagram.getEntityFactory(), diagram.getSource(), return new GeneralImageBuilder(intricated, dotData, diagram.getEntityFactory(), diagram.getSource(),
diagram.getPragma(), stringBounder, diagram.getUmlDiagramType().getStyleName()); diagram.getPragma(), stringBounder, diagram.getUmlDiagramType().getStyleName());

View File

@ -47,7 +47,7 @@ public class DecorateEntityImage3 extends AbstractTextBlock implements TextBloc
private final TextBlock original; private final TextBlock original;
private final HColor color; private final HColor color;
public DecorateEntityImage3(TextBlock original, HColor color) { private DecorateEntityImage3(TextBlock original, HColor color) {
this.original = original; this.original = original;
this.color = color; this.color = color;
} }

View File

@ -60,7 +60,6 @@ import net.sourceforge.plantuml.cucadiagram.dot.DotSplines;
import net.sourceforge.plantuml.cucadiagram.dot.Graphviz; import net.sourceforge.plantuml.cucadiagram.dot.Graphviz;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils; import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizVersion; import net.sourceforge.plantuml.cucadiagram.dot.GraphvizVersion;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizVersions;
import net.sourceforge.plantuml.cucadiagram.dot.ProcessState; import net.sourceforge.plantuml.cucadiagram.dot.ProcessState;
import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory; import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
@ -87,6 +86,8 @@ public class DotStringFactory implements Moveable {
private final StringBounder stringBounder; private final StringBounder stringBounder;
private GraphvizVersion graphvizVersion;
public DotStringFactory(StringBounder stringBounder, DotData dotData) { public DotStringFactory(StringBounder stringBounder, DotData dotData) {
this.skinParam = dotData.getSkinParam(); this.skinParam = dotData.getSkinParam();
this.umlDiagramType = dotData.getUmlDiagramType(); this.umlDiagramType = dotData.getUmlDiagramType();
@ -96,6 +97,7 @@ public class DotStringFactory implements Moveable {
this.stringBounder = stringBounder; this.stringBounder = stringBounder;
this.root = new Cluster(colorSequence, skinParam, dotData.getRootGroup()); this.root = new Cluster(colorSequence, skinParam, dotData.getRootGroup());
this.current = root; this.current = root;
this.graphvizVersion = dotData.getGraphvizVersion();
} }
public DotStringFactory(StringBounder stringBounder, CucaDiagram diagram) { public DotStringFactory(StringBounder stringBounder, CucaDiagram diagram) {
@ -107,6 +109,7 @@ public class DotStringFactory implements Moveable {
this.stringBounder = stringBounder; this.stringBounder = stringBounder;
this.root = new Cluster(colorSequence, skinParam, diagram.getEntityFactory().getRootGroup()); this.root = new Cluster(colorSequence, skinParam, diagram.getEntityFactory().getRootGroup());
this.current = root; this.current = root;
this.graphvizVersion = diagram.getGraphvizVersion();
} }
public void addNode(SvekNode node) { public void addNode(SvekNode node) {
@ -212,14 +215,14 @@ public class DotStringFactory implements Moveable {
root.printCluster1(sb, bibliotekon.allLines(), stringBounder); root.printCluster1(sb, bibliotekon.allLines(), stringBounder);
for (SvekLine line : bibliotekon.lines0()) for (SvekLine line : bibliotekon.lines0())
line.appendLine(getGraphvizVersion(), sb, dotMode, dotSplines); line.appendLine(graphvizVersion, sb, dotMode, dotSplines);
root.fillRankMin(rankMin); root.fillRankMin(rankMin);
root.printCluster2(sb, bibliotekon.allLines(), stringBounder, dotMode, getGraphvizVersion(), umlDiagramType); root.printCluster2(sb, bibliotekon.allLines(), stringBounder, dotMode, graphvizVersion, umlDiagramType);
printMinRanking(sb); printMinRanking(sb);
for (SvekLine line : bibliotekon.lines1()) for (SvekLine line : bibliotekon.lines1())
line.appendLine(getGraphvizVersion(), sb, dotMode, dotSplines); line.appendLine(graphvizVersion, sb, dotMode, dotSplines);
SvekUtils.println(sb); SvekUtils.println(sb);
sb.append("}"); sb.append("}");
@ -278,24 +281,6 @@ public class DotStringFactory implements Moveable {
return 35; return 35;
} }
private GraphvizVersion graphvizVersion;
public GraphvizVersion getGraphvizVersion() {
if (graphvizVersion == null)
graphvizVersion = getGraphvizVersionInternal();
return graphvizVersion;
}
private GraphvizVersion getGraphvizVersionInternal() {
final Graphviz graphviz = GraphvizUtils.create(skinParam, "foo;", "svg");
if (graphviz instanceof GraphvizJs)
return GraphvizJs.getGraphvizVersion(false);
final File f = graphviz.getDotExe();
return GraphvizVersions.getInstance().getVersion(f);
}
public String getSvg(BaseFile basefile, String[] dotOptions) throws IOException { public String getSvg(BaseFile basefile, String[] dotOptions) throws IOException {
String dotString = createDotString(dotOptions); String dotString = createDotString(dotOptions);
@ -314,7 +299,7 @@ public class DotStringFactory implements Moveable {
} }
} catch (GraphvizJsRuntimeException e) { } catch (GraphvizJsRuntimeException e) {
System.err.println("GraphvizJsRuntimeException"); System.err.println("GraphvizJsRuntimeException");
graphvizVersion = GraphvizJs.getGraphvizVersion(true); this.graphvizVersion = GraphvizJs.getGraphvizVersion(true);
dotString = createDotString(dotOptions); dotString = createDotString(dotOptions);
graphviz = GraphvizUtils.create(skinParam, dotString, "svg"); graphviz = GraphvizUtils.create(skinParam, dotString, "svg");
baos = new ByteArrayOutputStream(); baos = new ByteArrayOutputStream();

View File

@ -551,25 +551,25 @@ public final class GeneralImageBuilder {
if (ent.getSvekImage() == null) { if (ent.getSvekImage() == null) {
ISkinParam skinParam = dotData.getSkinParam(); ISkinParam skinParam = dotData.getSkinParam();
if (skinParam.sameClassWidth()) { if (skinParam.sameClassWidth()) {
final double width = getMaxWidth(dotStringFactory); final double width = getMaxWidth();
skinParam = new SkinParamSameClassWidth(skinParam, width); skinParam = new SkinParamSameClassWidth(skinParam, width);
} }
return createEntityImageBlock(ent, skinParam, dotData.isHideEmptyDescriptionForState(), dotData, return createEntityImageBlock(ent, skinParam, dotData.isHideEmptyDescriptionForState(), dotData,
dotStringFactory.getBibliotekon(), dotStringFactory.getGraphvizVersion(), dotStringFactory.getBibliotekon(), dotData.getGraphvizVersion(), dotData.getUmlDiagramType(),
dotData.getUmlDiagramType(), dotData.getLinks()); dotData.getLinks());
} }
return ent.getSvekImage(); return ent.getSvekImage();
} }
private double getMaxWidth(DotStringFactory dotStringFactory) { private double getMaxWidth() {
double result = 0; double result = 0;
for (ILeaf ent : dotData.getLeafs()) { for (ILeaf ent : dotData.getLeafs()) {
if (ent.getLeafType().isLikeClass() == false) if (ent.getLeafType().isLikeClass() == false)
continue; continue;
final IEntityImage im = new EntityImageClass(dotStringFactory.getGraphvizVersion(), ent, final IEntityImage im = new EntityImageClass(dotData.getGraphvizVersion(), ent, dotData.getSkinParam(),
dotData.getSkinParam(), dotData); dotData);
final double w = im.calculateDimension(stringBounder).getWidth(); final double w = im.calculateDimension(stringBounder).getWidth();
if (w > result) if (w > result)
result = w; result = w;
@ -697,7 +697,7 @@ public final class GeneralImageBuilder {
.getMergedStyle(skinParam.getCurrentStyleBuilder()); .getMergedStyle(skinParam.getCurrentStyleBuilder());
final FontConfiguration fontConfiguration = style.getFontConfiguration(skinParam.getThemeStyle(), final FontConfiguration fontConfiguration = style.getFontConfiguration(skinParam.getThemeStyle(),
skinParam.getIHtmlColorSet()); skinParam.getIHtmlColorSet(), g.getColors());
final HorizontalAlignment alignment = HorizontalAlignment.CENTER; final HorizontalAlignment alignment = HorizontalAlignment.CENTER;
return label.create(fontConfiguration, alignment, dotData.getSkinParam()); return label.create(fontConfiguration, alignment, dotData.getSkinParam());

View File

@ -128,7 +128,7 @@ public final class GroupPngMakerActivity {
final DotData dotData = new DotData(group, links, group.getLeafsDirect(), diagram.getUmlDiagramType(), final DotData dotData = new DotData(group, links, group.getLeafsDirect(), diagram.getUmlDiagramType(),
skinParam, new InnerGroupHierarchy(), diagram.getColorMapper(), diagram.getEntityFactory(), false, skinParam, new InnerGroupHierarchy(), diagram.getColorMapper(), diagram.getEntityFactory(), false,
DotMode.NORMAL, diagram.getNamespaceSeparator(), diagram.getPragma()); DotMode.NORMAL, diagram.getNamespaceSeparator(), diagram.getPragma(), diagram.getGraphvizVersion());
final GeneralImageBuilder svek2 = new GeneralImageBuilder(false, dotData, diagram.getEntityFactory(), final GeneralImageBuilder svek2 = new GeneralImageBuilder(false, dotData, diagram.getEntityFactory(),
diagram.getSource(), diagram.getPragma(), stringBounder, SName.activityDiagram); diagram.getSource(), diagram.getPragma(), stringBounder, SName.activityDiagram);

View File

@ -151,7 +151,7 @@ public final class GroupPngMakerState {
final DotData dotData = new DotData(group, links, group.getLeafsDirect(), diagram.getUmlDiagramType(), final DotData dotData = new DotData(group, links, group.getLeafsDirect(), diagram.getUmlDiagramType(),
skinParam, new InnerGroupHierarchy(), diagram.getColorMapper(), diagram.getEntityFactory(), skinParam, new InnerGroupHierarchy(), diagram.getColorMapper(), diagram.getEntityFactory(),
diagram.isHideEmptyDescriptionForState(), DotMode.NORMAL, diagram.getNamespaceSeparator(), diagram.isHideEmptyDescriptionForState(), DotMode.NORMAL, diagram.getNamespaceSeparator(),
diagram.getPragma()); diagram.getPragma(), diagram.getGraphvizVersion());
final GeneralImageBuilder svek2 = new GeneralImageBuilder(false, dotData, diagram.getEntityFactory(), final GeneralImageBuilder svek2 = new GeneralImageBuilder(false, dotData, diagram.getEntityFactory(),
diagram.getSource(), diagram.getPragma(), stringBounder, SName.stateDiagram); diagram.getSource(), diagram.getPragma(), stringBounder, SName.stateDiagram);

View File

@ -53,6 +53,14 @@ public class Margins {
return "MARGIN[" + x1 + "," + x2 + "," + y1 + "," + y2 + "]"; return "MARGIN[" + x1 + "," + x2 + "," + y1 + "," + y2 + "]";
} }
public Margins merge(Margins other) {
return new Margins(//
Math.max(this.x1, other.x1), //
Math.max(this.x2, other.x2), //
Math.max(this.y1, other.y1), //
Math.max(this.y2, other.y2));
}
public Margins(double x1, double x2, double y1, double y2) { public Margins(double x1, double x2, double y1, double y2) {
this.x1 = x1; this.x1 = x1;
this.x2 = x2; this.x2 = x2;

View File

@ -58,6 +58,7 @@ import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.awt.geom.Dimension2D; import net.sourceforge.plantuml.awt.geom.Dimension2D;
import net.sourceforge.plantuml.command.Position; import net.sourceforge.plantuml.command.Position;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.EntityPort; import net.sourceforge.plantuml.cucadiagram.EntityPort;
import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.IEntity;
@ -100,6 +101,7 @@ import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UGroupType; import net.sourceforge.plantuml.ugraphic.UGroupType;
import net.sourceforge.plantuml.ugraphic.ULine; import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.UPolygon; import net.sourceforge.plantuml.ugraphic.UPolygon;
import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
@ -260,7 +262,8 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
if (hasSeveralGuideLines) if (hasSeveralGuideLines)
block = StringWithArrow.addSeveralMagicArrows(link.getLabel(), this, font, alignment, skinParam); block = StringWithArrow.addSeveralMagicArrows(link.getLabel(), this, font, alignment, skinParam);
else else
block = link.getLabel().create9(font, alignment, skinParam, skinParam.maxMessageSize()); block = link.getLabel().create0(font, alignment, skinParam, skinParam.maxMessageSize(),
CreoleMode.SIMPLE_LINE, null, null);
labelOnly = addVisibilityModifier(block, link, skinParam); labelOnly = addVisibilityModifier(block, link, skinParam);
if (getLinkArrow() != LinkArrow.NONE_OR_SEVERAL && hasSeveralGuideLines == false) if (getLinkArrow() != LinkArrow.NONE_OR_SEVERAL && hasSeveralGuideLines == false)
@ -305,8 +308,16 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
else else
this.labelShield = 7; this.labelShield = 7;
if (link.getLinkArg().getKal1() != null) {
this.kal1 = Display.getWithNewlines(link.getLinkArg().getKal1()).create7(font, HorizontalAlignment.LEFT,
skinParam, CreoleMode.SIMPLE_LINE);
}
} }
private TextBlock kal1;
private TextBlock addVisibilityModifier(TextBlock block, Link link, ISkinParam skinParam) { private TextBlock addVisibilityModifier(TextBlock block, Link link, ISkinParam skinParam) {
final VisibilityModifier visibilityModifier = link.getVisibilityModifier(); final VisibilityModifier visibilityModifier = link.getVisibilityModifier();
if (visibilityModifier != null) { if (visibilityModifier != null) {
@ -755,6 +766,16 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
link.getLinkConstraint().drawMe(ug, skinParam); link.getLinkConstraint().drawMe(ug, skinParam);
} }
if (kal1 != null) {
final Dimension2D dim1 = kal1.calculateDimension(stringBounder);
final URectangle rect = new URectangle(dim1);
final UTranslate tr = new UTranslate(dotPath.getStartPoint()).compose(new UTranslate(dx, dy))
.compose(UTranslate.dx(-dim1.getWidth() / 2));
final UGraphic ug1 = ug.apply(tr);
ug1.apply(HColors.WHITE.bg()).draw(rect);
kal1.drawU(ug1);
}
ug.closeGroup(); ug.closeGroup();
} }

View File

@ -106,9 +106,8 @@ public class SvekNode implements Positionable, IShapePseudo, Hideable {
this.uid = String.format("sh%04d", color); this.uid = String.format("sh%04d", color);
this.shield = image.getShield(stringBounder); this.shield = image.getShield(stringBounder);
if (shield.isZero() == false && type != ShapeType.RECTANGLE && type != ShapeType.RECTANGLE_HTML_FOR_PORTS if (shield.isZero() == false && type != ShapeType.RECTANGLE && type != ShapeType.RECTANGLE_HTML_FOR_PORTS
&& type != ShapeType.RECTANGLE_WITH_CIRCLE_INSIDE) { && type != ShapeType.RECTANGLE_WITH_CIRCLE_INSIDE)
throw new IllegalArgumentException(); throw new IllegalArgumentException();
}
if (((EntityImpl) ent).getOriginalGroup() == null) { if (((EntityImpl) ent).getOriginalGroup() == null) {
this.group = null; this.group = null;
@ -221,15 +220,15 @@ public class SvekNode implements Positionable, IShapePseudo, Hideable {
} }
private void appendTr(StringBuilder sb, String portId, double height) { private void appendTr(StringBuilder sb, String portId, double height) {
if (height <= 0) { if (height <= 0)
return; return;
}
sb.append("<TR>"); sb.append("<TR>");
sb.append("<TD "); sb.append("<TD ");
sb.append(" FIXEDSIZE=\"TRUE\" WIDTH=\"" + getWidth() + "\" HEIGHT=\"" + height + "\""); sb.append(" FIXEDSIZE=\"TRUE\" WIDTH=\"" + getWidth() + "\" HEIGHT=\"" + height + "\"");
if (portId != null) { if (portId != null)
sb.append(" PORT=\"" + portId + "\""); sb.append(" PORT=\"" + portId + "\"");
}
sb.append(">"); sb.append(">");
sb.append("</TD>"); sb.append("</TD>");
sb.append("</TR>"); sb.append("</TR>");
@ -248,36 +247,36 @@ public class SvekNode implements Positionable, IShapePseudo, Hideable {
} }
private void appendShapeInternal(StringBuilder sb) { private void appendShapeInternal(StringBuilder sb) {
if (type == ShapeType.RECTANGLE && shield.isZero() == false) { if (type == ShapeType.RECTANGLE && shield.isZero() == false)
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} else if (type == ShapeType.RECTANGLE || type == ShapeType.RECTANGLE_WITH_CIRCLE_INSIDE else if (type == ShapeType.RECTANGLE || type == ShapeType.RECTANGLE_WITH_CIRCLE_INSIDE
|| type == ShapeType.FOLDER) { || type == ShapeType.FOLDER)
sb.append("shape=rect"); sb.append("shape=rect");
} else if (type == ShapeType.RECTANGLE_HTML_FOR_PORTS) { else if (type == ShapeType.RECTANGLE_HTML_FOR_PORTS)
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} else if (type == ShapeType.OCTAGON) { else if (type == ShapeType.OCTAGON)
sb.append("shape=octagon"); sb.append("shape=octagon");
} else if (type == ShapeType.HEXAGON) { else if (type == ShapeType.HEXAGON)
sb.append("shape=hexagon"); sb.append("shape=hexagon");
} else if (type == ShapeType.DIAMOND) { else if (type == ShapeType.DIAMOND)
sb.append("shape=diamond"); sb.append("shape=diamond");
} else if (type == ShapeType.CIRCLE) { else if (type == ShapeType.CIRCLE)
sb.append("shape=circle"); sb.append("shape=circle");
} else if (type == ShapeType.CIRCLE_IN_RECT) { else if (type == ShapeType.CIRCLE_IN_RECT)
sb.append("shape=circle"); sb.append("shape=circle");
} else if (type == ShapeType.OVAL) { else if (type == ShapeType.OVAL)
sb.append("shape=ellipse"); sb.append("shape=ellipse");
} else if (type == ShapeType.ROUND_RECTANGLE) { else if (type == ShapeType.ROUND_RECTANGLE)
sb.append("shape=rect,style=rounded"); sb.append("shape=rect,style=rounded");
} else { else
throw new IllegalStateException(type.toString()); throw new IllegalStateException(type.toString());
}
} }
public final String getUid() { public final String getUid() {
if (uid == null) { if (uid == null)
throw new IllegalStateException(); throw new IllegalStateException();
}
return uid; return uid;
} }
@ -347,15 +346,15 @@ public class SvekNode implements Positionable, IShapePseudo, Hideable {
} }
public Point2D projection(Point2D pt, StringBounder stringBounder) { public Point2D projection(Point2D pt, StringBounder stringBounder) {
if (getType() != ShapeType.FOLDER) { if (getType() != ShapeType.FOLDER)
return pt; return pt;
}
final ClusterPosition clusterPosition = new ClusterPosition(minX, minY, minX + width, minY + height); final ClusterPosition clusterPosition = new ClusterPosition(minX, minY, minX + width, minY + height);
if (clusterPosition.isPointJustUpper(pt)) { if (clusterPosition.isPointJustUpper(pt)) {
final Dimension2D dimName = ((EntityImageDescription) image).getNameDimension(stringBounder); final Dimension2D dimName = ((EntityImageDescription) image).getNameDimension(stringBounder);
if (pt.getX() < minX + dimName.getWidth()) { if (pt.getX() < minX + dimName.getWidth())
return pt; return pt;
}
return new Point2D.Double(pt.getX(), pt.getY() + dimName.getHeight() + 4); return new Point2D.Double(pt.getX(), pt.getY() + dimName.getHeight() + 4);
} }
return pt; return pt;

View File

@ -78,7 +78,8 @@ import net.sourceforge.plantuml.ugraphic.color.HColors;
public class EntityImageClass extends AbstractEntityImage implements Stencil, WithPorts { public class EntityImageClass extends AbstractEntityImage implements Stencil, WithPorts {
final private TextBlock body; final private TextBlock body;
final private Margins shield; // final private Margins shield;
final private GraphvizVersion version;
final private EntityImageClassHeader header; final private EntityImageClassHeader header;
final private Url url; final private Url url;
final private double roundCorner; final private double roundCorner;
@ -92,9 +93,8 @@ public class EntityImageClass extends AbstractEntityImage implements Stencil, Wi
this.lineConfig = entity; this.lineConfig = entity;
this.roundCorner = getStyle().value(PName.RoundCorner).asDouble(); this.roundCorner = getStyle().value(PName.RoundCorner).asDouble();
this.version = version;
this.shield = version != null && version.useShield() && entity.hasNearDecoration() ? Margins.uniform(16)
: Margins.NONE;
final boolean showMethods = portionShower.showPortion(EntityPortion.METHOD, entity); final boolean showMethods = portionShower.showPortion(EntityPortion.METHOD, entity);
final boolean showFields = portionShower.showPortion(EntityPortion.FIELD, entity); final boolean showFields = portionShower.showPortion(EntityPortion.FIELD, entity);
this.body = entity.getBodier().getBody(FontParam.CLASS_ATTRIBUTE, getSkinParam(), showMethods, showFields, this.body = entity.getBodier().getBody(FontParam.CLASS_ATTRIBUTE, getSkinParam(), showMethods, showFields,
@ -241,7 +241,10 @@ public class EntityImageClass extends AbstractEntityImage implements Stencil, Wi
@Override @Override
public Margins getShield(StringBounder stringBounder) { public Margins getShield(StringBounder stringBounder) {
return shield; if (version != null && version.useShield())
return ((ILeaf) getEntity()).getMargins();
return Margins.NONE;
} }
public double getStartingX(StringBounder stringBounder, double y) { public double getStartingX(StringBounder stringBounder, double y) {

View File

@ -183,7 +183,7 @@ public class EntityImageTips extends AbstractEntityImage {
final UStroke stroke = style.getStroke(); final UStroke stroke = style.getStroke();
final TextBlock textBlock = BodyFactory.create3(display, skinParam, HorizontalAlignment.LEFT, fc, final TextBlock textBlock = BodyFactory.create3(display, skinParam, HorizontalAlignment.LEFT, fc,
LineBreakStrategy.NONE, style); skinParam.wrapWidth(), style);
return new Opale(shadowing, borderColor, noteBackgroundColor, textBlock, true, stroke); return new Opale(shadowing, borderColor, noteBackgroundColor, textBlock, true, stroke);
} }

View File

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