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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -81,7 +81,7 @@ public class CommandHideShowByVisibility extends SingleLineCommand2<UmlDiagram>
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)), " ,");
while (st.hasMoreTokens()) {
addVisibilities(st.nextToken(), portion, visibilities);

View File

@ -62,9 +62,11 @@ public class CommandHideShowSpecificClass extends SingleLineCommand2<CucaDiagram
// final String codeString = arg.get("CODE", 0);
// 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")) {
// diagram.hideOrShow(LeafType.INTERFACE, arg.get("COMMAND", 0).equalsIgnoreCase("show"));
// diagram.hideOrShow(LeafType.INTERFACE, arg.get("COMMAND",
// 0).equalsIgnoreCase("show"));
// } else {
// final Code code = diagram.buildCode(codeString);
// IEntity hidden = diagram.getEntityFactory().getLeafsget(code);
@ -72,7 +74,8 @@ public class CommandHideShowSpecificClass extends SingleLineCommand2<CucaDiagram
// hidden = diagram.getEntityFactory().getGroupsget(code);
// }
// 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"));
// }

View File

@ -55,6 +55,7 @@ import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg;
import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement;
@ -231,9 +232,14 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
final Labels labels = new Labels(arg);
Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, labels.getDisplay(), queue,
labels.getFirstLabel(), labels.getSecondLabel(), diagram.getLabeldistance(),
diagram.getLabelangle());
final String kal1 = arg.get("QUALIFIER1", 0);
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) {
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), UrlMode.STRICT);
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 String firstLabel = arg.get("FIRST_LABEL", 0);
final String secondLabel = arg.get("SECOND_LABEL", 0);
final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, labelLink, queue, firstLabel,
secondLabel, diagram.getLabeldistance(), diagram.getLabelangle());
final LinkArg linkArg = LinkArg.build(labelLink, queue, diagram.getSkinParam().classAttributeIconSize() > 0);
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,
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.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg;
import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram;
@ -72,8 +73,9 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
new RegexLeaf("HEADER", "@([\\d.]+)"), //
RegexLeaf.spaceOneOrMore() //
)), //
new RegexLeaf("ENT1", "(?:" + optionalKeywords(umlDiagramType) + "[%s]+)?"
+ "(\\.?[%pLN_]+(?:\\.[%pLN_]+)*|[%g][^%g]+[%g])[%s]*(\\<\\<.*\\>\\>)?"), //
new RegexLeaf("ENT1",
"(?:" + optionalKeywords(umlDiagramType) + "[%s]+)?"
+ "(\\.?[%pLN_]+(?:\\.[%pLN_]+)*|[%g][^%g]+[%g])[%s]*(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), //
new RegexOptional(new RegexLeaf("FIRST_LABEL", "[%g]([^%g]+)[%g]")), //
RegexLeaf.spaceZeroOrMore(), //
@ -82,8 +84,9 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
RegexLeaf.spaceZeroOrMore(), //
new RegexOptional(new RegexLeaf("SECOND_LABEL", "[%g]([^%g]+)[%g]")), //
RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("ENT2", "(?:" + optionalKeywords(umlDiagramType) + "[%s]+)?"
+ "(\\.?[%pLN_]+(?:\\.[%pLN_]+)*|[%g][^%g]+[%g])[%s]*(\\<\\<.*\\>\\>)?"), //
new RegexLeaf("ENT2",
"(?:" + optionalKeywords(umlDiagramType) + "[%s]+)?"
+ "(\\.?[%pLN_]+(?:\\.[%pLN_]+)*|[%g][^%g]+[%g])[%s]*(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), //
new RegexOptional( //
new RegexConcat( //
@ -94,19 +97,19 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
}
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)";
}
if (type == UmlDiagramType.OBJECT) {
if (type == UmlDiagramType.OBJECT)
return "(object)";
}
throw new IllegalArgumentException();
}
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_FULL;
}
@ -145,9 +148,8 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
final String queue = getQueue(arg);
int length = queue.length();
if (length == 1 && diagram.getNbOfHozizontalLollipop(normalEntity) > 1) {
if (length == 1 && diagram.getNbOfHozizontalLollipop(normalEntity) > 1)
length++;
}
String firstLabel = arg.get("FIRST_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);
if (m1.matches()) {
firstLabel = m1.group(1);
labelLink = StringUtils.trin(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils
.trin(m1.group(2))));
labelLink = StringUtils.trin(
StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils.trin(m1.group(2))));
secondLabel = m1.group(3);
} else {
final Pattern2 p2 = MyPattern.cmpile("^\"([^\"]+)\"([^\"]+)$");
@ -185,16 +187,12 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
}
}
labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(labelLink);
} /*
* else if (arg.get("LABEL_LINK_XT").get(0) != null || arg.get("LABEL_LINK_XT").get(1) != null ||
* arg.get("LABEL_LINK_XT").get(2) != null) { labelLink = arg.get("LABEL_LINK_XT").get(1); firstLabel =
* merge(firstLabel, arg.get("LABEL_LINK_XT").get(0)); secondLabel = merge(arg.get("LABEL_LINK_XT").get(2),
* secondLabel); }
*/
final Link link = new Link(diagram.getSkinParam()
.getCurrentStyleBuilder(), cl1, cl2, linkType, Display.getWithNewlines(labelLink), length,
firstLabel, secondLabel, diagram.getLabeldistance(), diagram.getLabelangle());
}
final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(labelLink), length,
diagram.getSkinParam().classAttributeIconSize() > 0);
final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType,
linkArg.withQualifier(firstLabel, secondLabel).withDistanceAngle(diagram.getLabeldistance(),
diagram.getLabelangle()));
diagram.resetPragmaLabel();
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) {
if (diagram.V1972()) {
final IEntity result = ident.size() == 1 ? diagram.getLeafVerySmart(ident) : diagram.getLeafStrict(ident);
if (result != null) {
if (result != null)
return result;
}
}
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) {
diagram.addLink(link);
if (weight == null) {
@ -253,12 +236,12 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
}
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));
}
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));
}
throw new IllegalArgumentException();
}

View File

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

View File

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

View File

@ -77,7 +77,8 @@ public final class CommandConstraintOnLinks extends SingleLineCommand2<CucaDiagr
}
@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();
if (links == null) {
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.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg;
import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.graphic.color.ColorParser;
@ -167,13 +168,17 @@ public final class CommandFactoryNoteActivity implements SingleMultiFactoryComma
final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).goDashed();
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) {
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) {
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) {
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 {
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.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg;
import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.cucadiagram.Stereotag;
@ -259,15 +260,19 @@ public final class CommandFactoryNoteOnEntity implements SingleMultiFactoryComma
final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).goDashed();
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);
} 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);
} 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) {
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 {
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.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg;
import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.graphic.color.ColorParser;
@ -88,7 +89,7 @@ public final class CommandFactoryTipOnEntity implements SingleMultiFactoryComman
RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("\\{"), //
RegexLeaf.end() //
);
);
}
return RegexConcat.build(CommandFactoryTipOnEntity.class.getName() + key + withBracket, RegexLeaf.start(), //
new RegexLeaf("note"), //
@ -103,7 +104,7 @@ public final class CommandFactoryTipOnEntity implements SingleMultiFactoryComman
RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
RegexLeaf.end() //
);
);
}
public Command<AbstractEntityDiagram> createSingleLine() {
@ -122,7 +123,8 @@ public final class CommandFactoryTipOnEntity implements SingleMultiFactoryComman
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);
final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString());
lines = lines.subExtract(1, 1);
@ -154,8 +156,8 @@ public final class CommandFactoryTipOnEntity implements SingleMultiFactoryComman
return CommandExecutionResult.error("Nothing to note to");
}
final IEntity cl1 = diagram.getOrCreateLeaf(identShort, codeShort, null, null);
final Position position = Position.valueOf(StringUtils.goUpperCase(pos)).withRankdir(
diagram.getSkinParam().getRankdir());
final Position position = Position.valueOf(StringUtils.goUpperCase(pos))
.withRankdir(diagram.getSkinParam().getRankdir());
final Ident identTip = diagram.buildLeafIdent(idShort + "$$$" + position.name());
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 Link link;
if (position == Position.RIGHT) {
link = new Link(diagram.getSkinParam()
.getCurrentStyleBuilder(), cl1, (IEntity) tips, type, Display.NULL, 1);
link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, (IEntity) tips, type,
LinkArg.noDisplay(1));
} else {
link = new Link(diagram.getSkinParam()
.getCurrentStyleBuilder(), (IEntity) tips, cl1, type, Display.NULL, 1);
link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), (IEntity) tips, cl1, type,
LinkArg.noDisplay(1));
}
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.IEntity;
import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg;
import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType;
@ -77,10 +78,8 @@ public class CommandLinkBlock extends SingleLineCommand2<CompositeDiagram> {
protected CommandExecutionResult executeArg(CompositeDiagram diagram, LineLocation location, RegexResult arg) {
final String ent1 = arg.get("ENT1", 0);
final String ent2 = arg.get("ENT2", 0);
final IEntity cl1 = diagram.getOrCreateLeaf(diagram.buildLeafIdent(ent1),
diagram.buildCode(ent1), null, null);
final IEntity cl2 = diagram.getOrCreateLeaf(diagram.buildLeafIdent(ent2),
diagram.buildCode(ent2), null, null);
final IEntity cl1 = diagram.getOrCreateLeaf(diagram.buildLeafIdent(ent1), diagram.buildCode(ent1), null, null);
final IEntity cl2 = diagram.getOrCreateLeaf(diagram.buildLeafIdent(ent2), diagram.buildCode(ent2), null, null);
final String deco1 = arg.get("DECO1", 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 Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, Display.getWithNewlines(arg.get("DISPLAY", 0)),
queue.length());
final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(arg.get("DISPLAY", 0)), queue.length(),
diagram.getSkinParam().classAttributeIconSize() > 0);
final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, linkArg);
diagram.addLink(link);
return CommandExecutionResult.ok();
}
private LinkDecor getLinkDecor(String s) {
if ("[]".equals(s)) {
if ("[]".equals(s))
return LinkDecor.SQUARE_toberemoved;
}
return LinkDecor.NONE;
}

View File

@ -98,7 +98,8 @@ public class BodierLikeClassOrObject implements Bodier {
private boolean isBodyEnhanced() {
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 false;

View File

@ -35,6 +35,7 @@
*/
package net.sourceforge.plantuml.cucadiagram;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
@ -59,6 +60,10 @@ import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.creole.CreoleMode;
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.elk.CucaDiagramFileMakerElk;
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.CucaDiagramFileMakerSvek;
import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
import net.sourceforge.plantuml.vizjs.GraphvizJs;
import net.sourceforge.plantuml.xmi.CucaDiagramXmiMaker;
import net.sourceforge.plantuml.xmlsc.StateDiagramScxmlMaker;
@ -873,4 +879,24 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
// Strange numbers here for backwards compatibility
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;
}
public Display manageGuillemet() {
public Display manageGuillemet(boolean manageVisibilityModifier) {
final List<CharSequence> result = new ArrayList<>();
boolean first = true;
for (CharSequence line : displayData) {
@ -277,7 +277,7 @@ public class Display implements Iterable<CharSequence> {
result.add(line);
} else {
String lineString = line.toString();
if (first && VisibilityModifier.isVisibilityCharacter(line))
if (manageVisibilityModifier && first && VisibilityModifier.isVisibilityCharacter(line))
lineString = lineString.substring(1).trim();
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.
*
* You should use directly DisplayPositioned and not this interface which is here for legacy code.
* This file will be removed, so use DisplayPositioned instead.
* You should use directly DisplayPositioned and not this interface which is
* here for legacy code. This file will be removed, so use DisplayPositioned
* instead.
*
*/
@Deprecated
@ -52,10 +53,9 @@ public class DisplayPositionned {
public Display getDisplay() {
return null;
}
public boolean isNull() {
return false;
}
}

View File

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

View File

@ -43,8 +43,8 @@ public enum EntityPortion {
public Set<EntityPortion> asSet() {
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;
public abstract class EntityUtils {
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.skin.VisibilityModifier;
import net.sourceforge.plantuml.svek.IEntityImage;
import net.sourceforge.plantuml.svek.Margins;
public interface ILeaf extends IEntity {
@ -52,9 +53,7 @@ public interface ILeaf extends IEntity {
public void setTop(boolean top);
public boolean hasNearDecoration();
public void setNearDecoration(boolean nearDecoration);
public Margins getMargins();
public int getXposition();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -74,6 +74,7 @@ final public class DotData implements PortionShower {
private final ColorMapper colorMapper;
private final EntityFactory entityFactory;
private final GraphvizVersion graphvizVersion;
public EntityFactory getEntityFactory() {
return entityFactory;
@ -82,7 +83,7 @@ final public class DotData implements PortionShower {
public DotData(IGroup topParent, List<Link> links, Collection<ILeaf> leafs, UmlDiagramType umlDiagramType,
ISkinParam skinParam, GroupHierarchy groupHierarchy, PortionShower portionShower, ColorMapper colorMapper,
EntityFactory entityFactory, boolean isHideEmptyDescriptionForState, DotMode dotMode,
String namespaceSeparator, Pragma pragma) {
String namespaceSeparator, Pragma pragma, GraphvizVersion graphvizVersion) {
this.namespaceSeparator = namespaceSeparator;
this.pragma = pragma;
this.topParent = Objects.requireNonNull(topParent);
@ -97,16 +98,19 @@ final public class DotData implements PortionShower {
this.groupHierarchy = groupHierarchy;
this.portionShower = portionShower;
this.entityFactory = entityFactory;
this.graphvizVersion = graphvizVersion;
}
public DotData(IGroup topParent, List<Link> links, Collection<ILeaf> leafs, UmlDiagramType umlDiagramType,
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() {
public boolean showPortion(EntityPortion portion, IEntity entity) {
return true;
}
}, colorMapper, entityFactory, isHideEmptyDescriptionForState, dotMode, namespaceSeparator, pragma);
}, colorMapper, entityFactory, isHideEmptyDescriptionForState, dotMode, namespaceSeparator, pragma,
graphvizVersion);
}
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) {
if (f == null) {
if (f == null)
return null;
}
GraphvizVersion result = map.get(f);
if (result != null) {
if (result != null)
return result;
}
result = checkVersionSlow(f.getAbsolutePath());
map.put(f, 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.skin.VisibilityModifier;
import net.sourceforge.plantuml.svek.IEntityImage;
import net.sourceforge.plantuml.svek.Margins;
import net.sourceforge.plantuml.svek.PackageStyle;
import net.sourceforge.plantuml.svek.SingleStrategy;
import net.sourceforge.plantuml.ugraphic.UFont;
@ -112,7 +113,7 @@ final public class EntityImpl implements ILeaf, IGroup {
private GroupType groupType;
// Other
private boolean nearDecoration = false;
private Margins margins = Margins.NONE;
private final Collection<String> portShortNames = new HashSet<>();
private int xposition;
private IEntityImage svekImage;
@ -279,14 +280,15 @@ final public class EntityImpl implements ILeaf, IGroup {
this.url = url;
}
public final boolean hasNearDecoration() {
public final Margins getMargins() {
checkNotGroup();
return nearDecoration;
System.err.println("GETTING MARGIN!");
return margins;
}
public final void setNearDecoration(boolean nearDecoration) {
public final void ensureMargins(Margins newMargins) {
// checkNotGroup();
this.nearDecoration = nearDecoration;
this.margins = this.margins.merge(newMargins);
}
public int getXposition() {

View File

@ -132,7 +132,6 @@ public class CommandCreateElementParenthesis extends SingleLineCommand2<ClassDia
return ColorParser.simpleColor(ColorType.BACK, "COLOR2");
}
@Override
final protected boolean isForbidden(CharSequence line) {
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.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg;
import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
@ -258,9 +259,11 @@ public class CommandLinkElement extends SingleLineCommand2<DescriptionDiagram> {
cl1 = getFoo1(diagram, code1, ident1, ident1pure);
cl2 = getFoo1(diagram, code2, ident2, ident2pure);
}
Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, Display.getWithNewlines(labels.getLabelLink()),
queue.length(), labels.getFirstLabel(), labels.getSecondLabel(), diagram.getLabeldistance(),
diagram.getLabelangle());
final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(labels.getLabelLink()), queue.length(),
diagram.getSkinParam().classAttributeIconSize() > 0);
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());
if (dir == Direction.LEFT || dir == Direction.UP)
link = link.getInv();

View File

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

View File

@ -110,24 +110,6 @@ public class StringWithArrow {
final TextBlock arrow = new TextBlockArrow2(guide, font);
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,
HorizontalAlignment alignment, ISkinParam skinParam) {
@ -135,25 +117,9 @@ public class StringWithArrow {
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.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) {
if (tmp.getLinkArrow() != LinkArrow.NONE_OR_SEVERAL)
block = StringWithArrow.addMagicArrow2(block, tmp.getLinkArrow().mute(guide), font);
}
result = TextBlockUtils.mergeTB(result, block, alignment);
}
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.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg;
import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.cucadiagram.NoteLinkStrategy;
@ -78,11 +79,14 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
if (link == null) {
return false;
}
final Link l1 = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, node, link.getType(), link.getLabel(), link.getLength(),
link.getQualifier1(), null, link.getLabeldistance(), link.getLabelangle());
final Link l2 = new Link(getSkinParam().getCurrentStyleBuilder(), node, entity2, link.getType(), link.getLabel(), link.getLength(),
null, link.getQualifier2(), link.getLabeldistance(),
link.getLabelangle());
final Link l1 = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, node, link.getType(),
LinkArg.build(link.getLabel(), link.getLength(), getSkinParam().classAttributeIconSize() > 0)
.withQualifier(link.getQualifier1(), null)
.withDistanceAngle(link.getLabeldistance(), 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(l2);
removeLink(link);
@ -147,8 +151,8 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
insertPointBetween(entity2A, entity2B, point2);
final int length = 1;
final Link point1ToPoint2 = new Link(getSkinParam().getCurrentStyleBuilder(), point1, point2, linkType, label,
length);
final Link point1ToPoint2 = new Link(getSkinParam().getCurrentStyleBuilder(), point1, point2, linkType,
LinkArg.build(label, length));
addLink(point1ToPoint2);
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) {
Link existingLink1 = foundLink(entity1A, entity1B);
if (existingLink1 == null) {
existingLink1 = new Link(getSkinParam().getCurrentStyleBuilder(), entity1A, entity1B, new LinkType(LinkDecor.NONE, LinkDecor.NONE), Display.NULL,
2);
existingLink1 = new Link(getSkinParam().getCurrentStyleBuilder(), entity1A, entity1B,
new LinkType(LinkDecor.NONE, LinkDecor.NONE), LinkArg.noDisplay(2));
} else {
removeLink(existingLink1);
}
@ -171,13 +175,16 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
: existingLink1.getEntity2();
final Link entity1ToPoint = new Link(getSkinParam().getCurrentStyleBuilder(), entity1real, point1,
existingLink1.getType().getPart2(), existingLink1.getLabel(), existingLink1.getLength(), existingLink1.getQualifier1(),
null, existingLink1.getLabeldistance(),
existingLink1.getLabelangle());
existingLink1.getType().getPart2(),
LinkArg.build(existingLink1.getLabel(), existingLink1.getLength())
.withQualifier(existingLink1.getQualifier1(), null)
.withDistanceAngle(existingLink1.getLabeldistance(), existingLink1.getLabelangle()));
entity1ToPoint.setLinkArrow(existingLink1.getLinkArrow());
final Link pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point1, entity2real, existingLink1.getType().getPart1(),
Display.NULL, existingLink1.getLength(), null, existingLink1.getQualifier2(),
existingLink1.getLabeldistance(), existingLink1.getLabelangle());
final Link pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point1, entity2real,
existingLink1.getType().getPart1(),
LinkArg.noDisplay(existingLink1.getLength())
.withQualifier(null, existingLink1.getQualifier2())
.withDistanceAngle(existingLink1.getLabeldistance(), existingLink1.getLabelangle()));
// int length = 1;
// if (existingLink.getLength() == 1 && entity1A != entity1B) {
@ -268,8 +275,8 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
void createNew(int mode, LinkType linkType, Display label) {
existingLink = foundLink(entity1, entity2);
if (existingLink == null) {
existingLink = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, entity2, new LinkType(LinkDecor.NONE, LinkDecor.NONE), Display.NULL,
2);
existingLink = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, entity2,
new LinkType(LinkDecor.NONE, LinkDecor.NONE), LinkArg.noDisplay(2));
} else {
removeLink(existingLink);
}
@ -279,13 +286,17 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
final IEntity entity2real = existingLink.isInverted() ? existingLink.getEntity1()
: existingLink.getEntity2();
entity1ToPoint = new Link(getSkinParam().getCurrentStyleBuilder(), entity1real, point, existingLink.getType().getPart2(),
existingLink.getLabel(), existingLink.getLength(), existingLink.getQualifier1(), null,
existingLink.getLabeldistance(), existingLink.getLabelangle());
entity1ToPoint = new Link(getSkinParam().getCurrentStyleBuilder(), entity1real, point,
existingLink.getType().getPart2(),
LinkArg.build(existingLink.getLabel(), existingLink.getLength())
.withQualifier(existingLink.getQualifier1(), null)
.withDistanceAngle(existingLink.getLabeldistance(), existingLink.getLabelangle()));
entity1ToPoint.setLinkArrow(existingLink.getLinkArrow());
pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point, entity2real, existingLink.getType().getPart1(),
Display.NULL, existingLink.getLength(), null, existingLink.getQualifier2(),
existingLink.getLabeldistance(), existingLink.getLabelangle());
pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point, entity2real,
existingLink.getType().getPart1(),
LinkArg.noDisplay(existingLink.getLength())
.withQualifier(null, existingLink.getQualifier2())
.withDistanceAngle(existingLink.getLabeldistance(), existingLink.getLabelangle()));
int length = 1;
if (existingLink.getLength() == 1 && entity1 != entity2) {
@ -304,11 +315,11 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
addLink(pointToEntity2);
if (mode == 1) {
pointToAssocied = new Link(getSkinParam().getCurrentStyleBuilder(), point, associed, linkType, label,
length);
pointToAssocied = new Link(getSkinParam().getCurrentStyleBuilder(), point, associed, linkType,
LinkArg.build(label, length));
} else {
pointToAssocied = new Link(getSkinParam().getCurrentStyleBuilder(), associed, point, linkType, label,
length);
pointToAssocied = new Link(getSkinParam().getCurrentStyleBuilder(), associed, point, linkType,
LinkArg.build(label, length));
}
addLink(pointToAssocied);
}
@ -316,18 +327,20 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
void createInSecond(LinkType linkType, Display label) {
existingLink = foundLink(entity1, entity2);
if (existingLink == null) {
existingLink = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, entity2, new LinkType(LinkDecor.NONE, LinkDecor.NONE), Display.NULL,
2);
existingLink = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, entity2,
new LinkType(LinkDecor.NONE, LinkDecor.NONE), LinkArg.noDisplay(2));
} else {
removeLink(existingLink);
}
entity1ToPoint = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, point, existingLink.getType().getPart2(), existingLink.getLabel(),
2, existingLink.getQualifier1(), null, existingLink.getLabeldistance(),
existingLink.getLabelangle());
pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point, entity2, existingLink.getType().getPart1(), Display.NULL, 2,
null, existingLink.getQualifier2(), existingLink.getLabeldistance(),
existingLink.getLabelangle());
entity1ToPoint = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, point,
existingLink.getType().getPart2(),
LinkArg.build(existingLink.getLabel(), 2).withQualifier(existingLink.getQualifier1(), null)
.withDistanceAngle(existingLink.getLabeldistance(), existingLink.getLabelangle()));
pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point, entity2,
existingLink.getType().getPart1(),
LinkArg.noDisplay(2).withQualifier(null, existingLink.getQualifier2())
.withDistanceAngle(existingLink.getLabeldistance(), existingLink.getLabelangle()));
// entity1ToPoint = new Link(entity1, point, existingLink.getType(),
// null, 2);
// pointToEntity2 = new Link(point, entity2, existingLink.getType(),
@ -339,11 +352,12 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
other.pointToAssocied = other.pointToAssocied.getInv();
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);
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);
addLink(lnode);

View File

@ -66,8 +66,8 @@ public class CommandAddData extends SingleLineCommand2<AbstractClassOrObjectDiag
protected CommandExecutionResult executeArg(AbstractClassOrObjectDiagram diagram, LineLocation location,
RegexResult arg) throws NoSuchColorException {
final String name = arg.get("NAME", 0);
final IEntity entity = diagram.getOrCreateLeaf(diagram.buildLeafIdent(name),
diagram.buildCode(name), null, null);
final IEntity entity = diagram.getOrCreateLeaf(diagram.buildLeafIdent(name), diagram.buildCode(name), null,
null);
final String field = arg.get("DATA", 0);
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.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg;
import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
@ -128,8 +129,8 @@ public class CommandCreateMap extends CommandMultilines2<AbstractEntityDiagram>
final LinkType linkType = new LinkType(LinkDecor.ARROW, LinkDecor.NONE);
final int length = linkStr.length() - 2;
final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), entity1, entity2, linkType, Display.NULL,
length);
final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), entity1, entity2, linkType,
LinkArg.noDisplay(length));
link.setPortMembers(key, null);
diagram.addLink(link);
}

View File

@ -52,6 +52,7 @@ import java.net.URLEncoder;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import net.sourceforge.plantuml.BlockUml;
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.PSystemErrorUtils;
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.security.SFile;
import net.sourceforge.plantuml.version.Version;
@ -76,16 +80,19 @@ import net.sourceforge.plantuml.version.Version;
public class PicoWebServer implements Runnable {
private final Socket connect;
private static final AtomicBoolean stopRequested = new AtomicBoolean(false);
private static boolean enableStop;
public PicoWebServer(Socket c) {
this.connect = c;
}
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 ServerSocket serverConnect = new ServerSocket(port, 50, bindAddress1);
System.err.println("webPort=" + serverConnect.getLocalPort());
@ -93,7 +100,7 @@ public class PicoWebServer implements Runnable {
}
public static void serverLoop(final ServerSocket serverConnect) throws IOException {
while (true) {
while (stopRequested.get() == false) {
final PicoWebServer myServer = new PicoWebServer(serverConnect.accept());
final Thread thread = new Thread(myServer);
thread.start();
@ -126,6 +133,14 @@ public class PicoWebServer implements Runnable {
return;
if (request.getPath().startsWith("/plantuml/utxt/") && handleGET(request, out, FileFormat.UTXT))
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")) {
handleRenderRequest(request, out);
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)
throws IOException {
final int x = request.getPath().lastIndexOf('/');

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -76,7 +76,7 @@ public final class CucaDiagramFileMakerSvek implements CucaDiagramFileMaker {
final DotData dotData = new DotData(diagram.getEntityFactory().getRootGroup(), getOrderedLinks(),
diagram.getLeafsvalues(), diagram.getUmlDiagramType(), diagram.getSkinParam(), diagram, diagram,
diagram.getColorMapper(), diagram.getEntityFactory(), diagram.isHideEmptyDescriptionForState(), dotMode,
diagram.getNamespaceSeparator(), diagram.getPragma());
diagram.getNamespaceSeparator(), diagram.getPragma(), diagram.getGraphvizVersion());
final boolean intricated = diagram.mergeIntricated();
return new GeneralImageBuilder(intricated, dotData, diagram.getEntityFactory(), diagram.getSource(),
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 HColor color;
public DecorateEntityImage3(TextBlock original, HColor color) {
private DecorateEntityImage3(TextBlock original, HColor color) {
this.original = original;
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.GraphvizUtils;
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.entity.EntityFactory;
import net.sourceforge.plantuml.graphic.StringBounder;
@ -87,6 +86,8 @@ public class DotStringFactory implements Moveable {
private final StringBounder stringBounder;
private GraphvizVersion graphvizVersion;
public DotStringFactory(StringBounder stringBounder, DotData dotData) {
this.skinParam = dotData.getSkinParam();
this.umlDiagramType = dotData.getUmlDiagramType();
@ -96,6 +97,7 @@ public class DotStringFactory implements Moveable {
this.stringBounder = stringBounder;
this.root = new Cluster(colorSequence, skinParam, dotData.getRootGroup());
this.current = root;
this.graphvizVersion = dotData.getGraphvizVersion();
}
public DotStringFactory(StringBounder stringBounder, CucaDiagram diagram) {
@ -107,6 +109,7 @@ public class DotStringFactory implements Moveable {
this.stringBounder = stringBounder;
this.root = new Cluster(colorSequence, skinParam, diagram.getEntityFactory().getRootGroup());
this.current = root;
this.graphvizVersion = diagram.getGraphvizVersion();
}
public void addNode(SvekNode node) {
@ -212,14 +215,14 @@ public class DotStringFactory implements Moveable {
root.printCluster1(sb, bibliotekon.allLines(), stringBounder);
for (SvekLine line : bibliotekon.lines0())
line.appendLine(getGraphvizVersion(), sb, dotMode, dotSplines);
line.appendLine(graphvizVersion, sb, dotMode, dotSplines);
root.fillRankMin(rankMin);
root.printCluster2(sb, bibliotekon.allLines(), stringBounder, dotMode, getGraphvizVersion(), umlDiagramType);
root.printCluster2(sb, bibliotekon.allLines(), stringBounder, dotMode, graphvizVersion, umlDiagramType);
printMinRanking(sb);
for (SvekLine line : bibliotekon.lines1())
line.appendLine(getGraphvizVersion(), sb, dotMode, dotSplines);
line.appendLine(graphvizVersion, sb, dotMode, dotSplines);
SvekUtils.println(sb);
sb.append("}");
@ -278,24 +281,6 @@ public class DotStringFactory implements Moveable {
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 {
String dotString = createDotString(dotOptions);
@ -314,7 +299,7 @@ public class DotStringFactory implements Moveable {
}
} catch (GraphvizJsRuntimeException e) {
System.err.println("GraphvizJsRuntimeException");
graphvizVersion = GraphvizJs.getGraphvizVersion(true);
this.graphvizVersion = GraphvizJs.getGraphvizVersion(true);
dotString = createDotString(dotOptions);
graphviz = GraphvizUtils.create(skinParam, dotString, "svg");
baos = new ByteArrayOutputStream();

View File

@ -551,25 +551,25 @@ public final class GeneralImageBuilder {
if (ent.getSvekImage() == null) {
ISkinParam skinParam = dotData.getSkinParam();
if (skinParam.sameClassWidth()) {
final double width = getMaxWidth(dotStringFactory);
final double width = getMaxWidth();
skinParam = new SkinParamSameClassWidth(skinParam, width);
}
return createEntityImageBlock(ent, skinParam, dotData.isHideEmptyDescriptionForState(), dotData,
dotStringFactory.getBibliotekon(), dotStringFactory.getGraphvizVersion(),
dotData.getUmlDiagramType(), dotData.getLinks());
dotStringFactory.getBibliotekon(), dotData.getGraphvizVersion(), dotData.getUmlDiagramType(),
dotData.getLinks());
}
return ent.getSvekImage();
}
private double getMaxWidth(DotStringFactory dotStringFactory) {
private double getMaxWidth() {
double result = 0;
for (ILeaf ent : dotData.getLeafs()) {
if (ent.getLeafType().isLikeClass() == false)
continue;
final IEntityImage im = new EntityImageClass(dotStringFactory.getGraphvizVersion(), ent,
dotData.getSkinParam(), dotData);
final IEntityImage im = new EntityImageClass(dotData.getGraphvizVersion(), ent, dotData.getSkinParam(),
dotData);
final double w = im.calculateDimension(stringBounder).getWidth();
if (w > result)
result = w;
@ -697,7 +697,7 @@ public final class GeneralImageBuilder {
.getMergedStyle(skinParam.getCurrentStyleBuilder());
final FontConfiguration fontConfiguration = style.getFontConfiguration(skinParam.getThemeStyle(),
skinParam.getIHtmlColorSet());
skinParam.getIHtmlColorSet(), g.getColors());
final HorizontalAlignment alignment = HorizontalAlignment.CENTER;
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(),
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(),
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(),
skinParam, new InnerGroupHierarchy(), diagram.getColorMapper(), diagram.getEntityFactory(),
diagram.isHideEmptyDescriptionForState(), DotMode.NORMAL, diagram.getNamespaceSeparator(),
diagram.getPragma());
diagram.getPragma(), diagram.getGraphvizVersion());
final GeneralImageBuilder svek2 = new GeneralImageBuilder(false, dotData, diagram.getEntityFactory(),
diagram.getSource(), diagram.getPragma(), stringBounder, SName.stateDiagram);

View File

@ -53,6 +53,14 @@ public class Margins {
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) {
this.x1 = x1;
this.x2 = x2;

View File

@ -58,6 +58,7 @@ import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.awt.geom.Dimension2D;
import net.sourceforge.plantuml.command.Position;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.EntityPort;
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.ULine;
import net.sourceforge.plantuml.ugraphic.UPolygon;
import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor;
@ -260,7 +262,8 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
if (hasSeveralGuideLines)
block = StringWithArrow.addSeveralMagicArrows(link.getLabel(), this, font, alignment, skinParam);
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);
if (getLinkArrow() != LinkArrow.NONE_OR_SEVERAL && hasSeveralGuideLines == false)
@ -305,8 +308,16 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
else
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) {
final VisibilityModifier visibilityModifier = link.getVisibilityModifier();
if (visibilityModifier != null) {
@ -755,6 +766,16 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
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();
}

View File

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

View File

@ -78,7 +78,8 @@ import net.sourceforge.plantuml.ugraphic.color.HColors;
public class EntityImageClass extends AbstractEntityImage implements Stencil, WithPorts {
final private TextBlock body;
final private Margins shield;
// final private Margins shield;
final private GraphvizVersion version;
final private EntityImageClassHeader header;
final private Url url;
final private double roundCorner;
@ -92,9 +93,8 @@ public class EntityImageClass extends AbstractEntityImage implements Stencil, Wi
this.lineConfig = entity;
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 showFields = portionShower.showPortion(EntityPortion.FIELD, entity);
this.body = entity.getBodier().getBody(FontParam.CLASS_ATTRIBUTE, getSkinParam(), showMethods, showFields,
@ -241,7 +241,10 @@ public class EntityImageClass extends AbstractEntityImage implements Stencil, Wi
@Override
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) {

View File

@ -183,7 +183,7 @@ public class EntityImageTips extends AbstractEntityImage {
final UStroke stroke = style.getStroke();
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);
}

View File

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