1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-25 06:17:33 +00:00

version 1.2020.0

This commit is contained in:
Arnaud Roques 2020-01-12 23:13:17 +01:00
parent 275cde19a8
commit 19b9eb3534
137 changed files with 2096 additions and 2585 deletions

View File

@ -35,7 +35,7 @@
<groupId>net.sourceforge.plantuml</groupId>
<artifactId>plantuml</artifactId>
<version>1.2019.14-SNAPSHOT</version>
<version>1.2020.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>PlantUML</name>

View File

@ -57,6 +57,7 @@ import static gen.lib.cgraph.obj__c.agroot;
import static gen.lib.common.utils__c.UF_setname;
import static gen.lib.common.utils__c.UF_singleton;
import static gen.lib.dotgen.class2__c.class2;
import static gen.lib.dotgen.class2__c.merge_chain;
import static gen.lib.dotgen.class2__c.mergeable;
import static gen.lib.dotgen.dotinit__c.dot_root;
import static gen.lib.dotgen.fastgr__c.delete_fast_edge;
@ -67,6 +68,7 @@ import static gen.lib.dotgen.fastgr__c.find_flat_edge;
import static gen.lib.dotgen.fastgr__c.flat_edge;
import static gen.lib.dotgen.fastgr__c.merge_oneway;
import static gen.lib.dotgen.fastgr__c.other_edge;
import static gen.lib.dotgen.fastgr__c.safe_other_edge;
import static gen.lib.dotgen.fastgr__c.virtual_edge;
import static gen.lib.dotgen.fastgr__c.virtual_node;
import static gen.lib.dotgen.mincross__c.allocate_ranks;
@ -112,7 +114,6 @@ import h.ST_Agnode_s;
import h.ST_Agraph_s;
import h.ST_nodequeue;
import h.ST_pointf;
import smetana.core.__ptr__;
public class cluster__c {
//1 2digov3edok6d5srhgtlmrycs
@ -940,9 +941,9 @@ try {
ED_to_virt(e, null);
if (ED_to_virt(prev) == null)
continue; /* internal edge */
UNSUPPORTED("8d5mw7m9lzlseqbyx8a8mncgs"); // merge_chain(subg, e, ED_to_virt(prev), 0);
UNSUPPORTED("87mmnlsj8quzlzg0vxax15kt2"); // safe_other_edge(e);
UNSUPPORTED("6hyelvzskqfqa07xtgjtvg2is"); // continue;
merge_chain(subg, e, ED_to_virt(prev), false);
safe_other_edge(e);
continue;
}
/* flat edges */
if (ND_rank(agtail(e)) == ND_rank(aghead(e))) {

View File

@ -797,18 +797,17 @@ LEAVING("bf1j97keudu416avridkj9fpb","find_flat_edge");
//3 cttswsffgmw1g710jzvdd3wzn
// static void safe_list_append(edge_t * e, elist * L)
public static Object safe_list_append(Object... arg) {
UNSUPPORTED("59dl3yc4jbcy2pb7j1njhlybi"); // static void
UNSUPPORTED("3kdqf9wvozj4zu6wrv6ur2k47"); // safe_list_append(edge_t * e, elist * L)
UNSUPPORTED("erg9i1970wdri39osu8hx2a6e"); // {
UNSUPPORTED("b17di9c7wgtqm51bvsyxz6e2f"); // int i;
UNSUPPORTED("dhvbzrcz6s76mme3x94begmvr"); // for (i = 0; i < L->size; i++)
UNSUPPORTED("c0a4ruccwt5263vw39xrttm0y"); // if (e == L->list[i])
UNSUPPORTED("6cprbghvenu9ldc0ez1ifc63q"); // return;
public static void safe_list_append(ST_Agedge_s e, ST_elist L) {
ENTERING("cttswsffgmw1g710jzvdd3wzn","safe_list_append");
try {
int i;
for (i = 0; i < L.size; i++)
if (EQ(e, L.list.get(i)))
return;
UNSUPPORTED("cslejjtgepjdwlcykfas4fmvz"); // elist_append(e, (*L));
UNSUPPORTED("c24nfmv9i7o5eoqaymbibp7m7"); // }
throw new UnsupportedOperationException();
} finally {
LEAVING("cttswsffgmw1g710jzvdd3wzn","safe_list_append");
}
}
@ -907,13 +906,13 @@ LEAVING("73oebfcfiescklohgt8mddswc","other_edge");
//3 4zg1fp1b7bhnx2tbeaij8yeel
// void safe_other_edge(edge_t * e)
public static Object safe_other_edge(Object... arg) {
UNSUPPORTED("3cc9ux78ad0yjajm0nkpos345"); // void safe_other_edge(edge_t * e)
UNSUPPORTED("erg9i1970wdri39osu8hx2a6e"); // {
UNSUPPORTED("bn816jsdz3qke6htvbwvztrpc"); // safe_list_append(e, &(ND_other(agtail(e))));
UNSUPPORTED("c24nfmv9i7o5eoqaymbibp7m7"); // }
throw new UnsupportedOperationException();
public static void safe_other_edge(ST_Agedge_s e) {
ENTERING("4zg1fp1b7bhnx2tbeaij8yeel","safe_other_edge");
try {
safe_list_append(e, ND_other(agtail(e)));
} finally {
LEAVING("4zg1fp1b7bhnx2tbeaij8yeel","safe_other_edge");
}
}

View File

@ -47,8 +47,8 @@ public interface AFile {
public AParentFolder getParentFile();
public String getAbsolutePath();
public File getUnderlyingFile();
public File getSystemFolder() throws IOException;
}

View File

@ -78,12 +78,12 @@ public class AFileRegular implements AFile {
return new AParentFolderRegular(file.getParentFile());
}
public String getAbsolutePath() {
return file.getAbsolutePath();
}
public File getUnderlyingFile() {
return file;
}
public File getSystemFolder() throws IOException {
return file.getParentFile().getCanonicalFile();
}
}

View File

@ -113,12 +113,12 @@ public class AFileZipEntry implements AFile {
return new AParentFolderZip(zipFile, entry);
}
public String getAbsolutePath() {
return zipFile.getAbsolutePath() + "~" + entry;
}
public File getUnderlyingFile() {
return zipFile;
}
public File getSystemFolder() throws IOException {
return zipFile.getParentFile().getCanonicalFile();
}
}

View File

@ -49,7 +49,6 @@ import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.error.PSystemErrorPreprocessor;
import net.sourceforge.plantuml.preproc.Defines;
import net.sourceforge.plantuml.preproc2.PreprocessorMode;
import net.sourceforge.plantuml.preproc2.PreprocessorModeSet;
import net.sourceforge.plantuml.tim.TimLoader;
import net.sourceforge.plantuml.utils.StartUtils;
@ -98,7 +97,6 @@ public class BlockUml {
return result;
}
private PreprocessorMode pmode = PreprocessorMode.V1_LEGACY;
private boolean preprocessorError;
public BlockUml(List<StringLocated> strings, Defines defines, ISkinSimple skinParam, PreprocessorModeSet mode) {
@ -108,16 +106,15 @@ public class BlockUml {
if (StartUtils.startsWithSymbolAnd("start", s0) == false) {
throw new IllegalArgumentException();
}
if (mode != null && mode.getPreprocessorMode() == PreprocessorMode.V2_NEW_TIM) {
this.pmode = mode.getPreprocessorMode();
if (mode == null) {
this.data = new ArrayList<StringLocated>(strings);
} else {
final TimLoader timLoader = new TimLoader(mode.getImportedFiles(), defines, mode.getCharset(),
(DefinitionsContainer) mode);
timLoader.load(strings);
this.data = timLoader.getResultList();
this.debug = timLoader.getDebug();
this.preprocessorError = timLoader.isPreprocessorError();
} else {
this.data = new ArrayList<StringLocated>(strings);
}
}
@ -192,25 +189,14 @@ public class BlockUml {
}
public List<String> getDefinition(boolean withHeader) {
final List<String> data2 = new ArrayList<String>();
final List<String> result = new ArrayList<String>();
for (StringLocated s : data) {
data2.add(s.getString());
result.add(s.getString());
}
if (withHeader) {
return Collections.unmodifiableList(data2);
return Collections.unmodifiableList(result);
}
return Collections.unmodifiableList(data2.subList(1, data2.size() - 1));
}
public List<String> getDefinition2(boolean withHeader) {
final List<String> data2 = new ArrayList<String>();
for (StringLocated s : debug) {
data2.add(s.getString());
}
if (withHeader) {
return Collections.unmodifiableList(data2);
}
return Collections.unmodifiableList(data2.subList(1, data2.size() - 1));
return Collections.unmodifiableList(result.subList(1, result.size() - 1));
}
public Defines getLocalDefines() {

View File

@ -47,42 +47,37 @@ import java.util.Set;
import net.sourceforge.plantuml.preproc.Defines;
import net.sourceforge.plantuml.preproc.FileWithSuffix;
import net.sourceforge.plantuml.preproc.ImportedFiles;
import net.sourceforge.plantuml.preproc.PreprocessorChangeModeReader;
import net.sourceforge.plantuml.preproc.ReadLineNumbered;
import net.sourceforge.plantuml.preproc.ReadLineReader;
import net.sourceforge.plantuml.preproc.UncommentReadLine;
import net.sourceforge.plantuml.preproc2.Preprocessor;
import net.sourceforge.plantuml.preproc2.PreprocessorMode;
import net.sourceforge.plantuml.utils.StartUtils;
public final class BlockUmlBuilder implements DefinitionsContainer {
private PreprocessorMode mode = PreprocessorMode.V2_NEW_TIM;
private final List<BlockUml> blocks = new ArrayList<BlockUml>();
private Set<FileWithSuffix> usedFiles = new HashSet<FileWithSuffix>();
private final UncommentReadLine reader2;
private final UncommentReadLine reader;
private final Defines defines;
private final ImportedFiles importedFiles;
private final String charset;
public BlockUmlBuilder(List<String> config, String charset, Defines defines, Reader reader, File newCurrentDir,
public BlockUmlBuilder(List<String> config, String charset, Defines defines, Reader readerInit, File newCurrentDir,
String desc) throws IOException {
ReadLineNumbered includer = null;
this.defines = defines;
this.charset = charset;
try {
this.reader2 = new UncommentReadLine(new PreprocessorChangeModeReader(ReadLineReader.create(reader, desc),
this));
this.reader = new UncommentReadLine(ReadLineReader.create(readerInit, desc));
this.importedFiles = ImportedFiles.createImportedFiles(new AParentFolderRegular(newCurrentDir));
includer = new Preprocessor(config, reader2, charset, defines, this, importedFiles);
includer = new Preprocessor(config, reader);
init(includer);
} finally {
if (includer != null) {
includer.close();
usedFiles = includer.getFilesUsed();
}
reader.close();
readerInit.close();
}
}
@ -102,11 +97,11 @@ public final class BlockUmlBuilder implements DefinitionsContainer {
}
if (StartUtils.isArobasePauseDiagram(s.getString())) {
paused = true;
reader2.setPaused(true);
reader.setPaused(true);
}
if (StartUtils.isExit(s.getString())) {
paused = true;
reader2.setPaused(true);
reader.setPaused(true);
}
if (current2 != null && paused == false) {
current2.add(s);
@ -119,7 +114,7 @@ public final class BlockUmlBuilder implements DefinitionsContainer {
if (StartUtils.isArobaseUnpauseDiagram(s.getString())) {
paused = false;
reader2.setPaused(false);
reader.setPaused(false);
}
if (StartUtils.isArobaseEndDiagram(s.getString()) && current2 != null) {
if (paused) {
@ -127,7 +122,7 @@ public final class BlockUmlBuilder implements DefinitionsContainer {
}
blocks.add(new BlockUml(current2, defines.cloneMe(), null, this));
current2 = null;
reader2.setPaused(false);
reader.setPaused(false);
}
}
}
@ -140,33 +135,15 @@ public final class BlockUmlBuilder implements DefinitionsContainer {
return Collections.unmodifiableSet(usedFiles);
}
public List<String> getDefinition1(String name) {
public List<String> getDefinition(String name) {
for (BlockUml block : blocks) {
if (block.isStartDef(name)) {
this.defines.importFrom(block.getLocalDefines());
return block.getDefinition(false);
}
}
return Collections.emptyList();
}
public List<String> getDefinition2(String name) {
for (BlockUml block : blocks) {
if (block.isStartDef(name)) {
return block.getDefinition2(false);
}
}
return Collections.emptyList();
}
public PreprocessorMode getPreprocessorMode() {
return mode;
}
public void setPreprocessorMode(PreprocessorMode mode) {
this.mode = mode;
}
public final ImportedFiles getImportedFiles() {
return importedFiles;
}

View File

@ -41,7 +41,6 @@ import net.sourceforge.plantuml.preproc2.PreprocessorModeSet;
public interface DefinitionsContainer extends PreprocessorModeSet {
public List<String> getDefinition1(String name);
public List<String> getDefinition2(String name);
public List<String> getDefinition(String name);
}

View File

@ -470,7 +470,11 @@ public class Option {
public Defines getDefaultDefines(File f) {
final Defines result = Defines.createWithFileName(f);
for (Map.Entry<String, String> ent : defines.entrySet()) {
result.define(ent.getKey(), Arrays.asList(ent.getValue()), false, null);
String value = ent.getValue();
if (value == null) {
value = "";
}
result.define(ent.getKey(), Arrays.asList(value), false, null);
}
return result;
}

View File

@ -55,6 +55,10 @@ public class OptionFlags {
static public boolean ALLOW_INCLUDE = true;
static public void setAllowIncludeFalse() {
ALLOW_INCLUDE = false;
}
static public void setMaxPixel(int max) {
ImageBuilder.setMaxPixel(max);
}

View File

@ -46,7 +46,6 @@ import net.sourceforge.plantuml.api.PSystemFactory;
import net.sourceforge.plantuml.bpm.BpmDiagramFactory;
import net.sourceforge.plantuml.classdiagram.ClassDiagramFactory;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.compositediagram.CompositeDiagramFactory;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.core.DiagramType;
import net.sourceforge.plantuml.core.UmlSource;

View File

@ -49,7 +49,6 @@ import java.util.Set;
import java.util.TreeSet;
import net.sourceforge.plantuml.command.BlocLines;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;

View File

@ -56,6 +56,13 @@ final public class StringLocated {
return new StringLocated(s + endOfLine, location, preprocessorError);
}
public StringLocated mergeEndBackslash(StringLocated next) {
if (StringUtils.endsWithBackslash(s) == false) {
throw new IllegalArgumentException();
}
return new StringLocated(s.substring(0, s.length() - 1) + next.s, location, preprocessorError);
}
public StringLocated(String s, LineLocation location, String preprocessorError) {
if (s == null) {
throw new IllegalArgumentException();

View File

@ -40,6 +40,7 @@ import java.util.List;
import net.sourceforge.plantuml.Direction;
import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.cucadiagram.Code;
@ -67,7 +68,6 @@ public class ActivityDiagram extends CucaDiagram {
public ILeaf getOrCreateLeaf(Ident ident, Code code, LeafType type, USymbol symbol) {
checkNotNull(ident);
// final Ident idNewLong = buildLeafIdent(id);
return getOrCreateLeafDefault(ident, code, type, symbol);
}
@ -77,11 +77,10 @@ public class ActivityDiagram extends CucaDiagram {
public IEntity getOrCreate(Ident idNewLong, Code code, Display display, LeafType type) {
final IEntity result;
// final Ident idNewLong = buildLeafIdent(id);
if (leafExist(code)) {
final boolean leafExist = this.V1972() ? leafExistSmart(idNewLong) : leafExist(code);
if (leafExist) {
result = getOrCreateLeafDefault(idNewLong, code, type, null);
if (result.getLeafType() != type) {
// throw new IllegalArgumentException("Already known: " + code + " " + result.getType() + " " + type);
return null;
}
} else {
@ -91,11 +90,19 @@ public class ActivityDiagram extends CucaDiagram {
return result;
}
@Override
public /*final*/ ILeaf getLeafVerySmart(Ident ident) {
final ILeaf result = super.getLeafVerySmart(ident);
updateLasts(result);
return result;
}
public void startIf(String optionalCodeString) {
final String idShort = optionalCodeString == null ? getAutoBranch() : optionalCodeString;
final Ident idNewLong = buildLeafIdent(idShort);
final IEntity br = createLeaf(idNewLong, buildCode(idShort), Display.create(""),
LeafType.BRANCH, null);
final Code code = this.V1972() ? idNewLong : buildCode(idShort);
final IEntity br = createLeaf(idNewLong, code, Display.create(""), LeafType.BRANCH, null);
currentContext = new ConditionalContext(currentContext, br, Direction.DOWN);
}
@ -104,14 +111,16 @@ public class ActivityDiagram extends CucaDiagram {
}
public ILeaf getStart() {
return (ILeaf) getOrCreate(buildLeafIdent("start"), buildCode("start"),
Display.getWithNewlines("start"), LeafType.CIRCLE_START);
final Ident ident = buildLeafIdent("start");
final Code code = this.V1972() ? ident : buildCode("start");
return (ILeaf) getOrCreate(ident, code, Display.getWithNewlines("start"), LeafType.CIRCLE_START);
}
public ILeaf getEnd(String suppId) {
final String tmp = suppId == null ? "end" : "end$" + suppId;
final Code code = buildCode(tmp);
return (ILeaf) getOrCreate(buildLeafIdent(tmp), code, Display.getWithNewlines("end"), LeafType.CIRCLE_END);
final Ident ident = buildLeafIdent(tmp);
final Code code = this.V1972() ? ident : buildCode(tmp);
return (ILeaf) getOrCreate(ident, code, Display.getWithNewlines("end"), LeafType.CIRCLE_END);
}
private void updateLasts(final IEntity result) {
@ -134,7 +143,6 @@ public class ActivityDiagram extends CucaDiagram {
public IEntity createNote(Ident idNewLong, Code code, Display display) {
checkNotNull(idNewLong);
// final Ident idNewLong = buildLeafIdent(id);
return super.createLeaf(idNewLong, code, display, LeafType.NOTE, null);
}
@ -172,8 +180,8 @@ public class ActivityDiagram extends CucaDiagram {
public IEntity createInnerActivity() {
// Log.println("createInnerActivity A");
final String idShort = "##" + UniqueSequence.getValue();
final Code code = buildCode(idShort);
final Ident idNewLong = buildLeafIdent(idShort);
final Code code = this.V1972() ? idNewLong : buildCode(idShort);
gotoGroup(idNewLong, code, Display.getWithNewlines(code), GroupType.INNER_ACTIVITY, getCurrentGroup(),
NamespaceStrategy.SINGLE);
final IEntity g = getCurrentGroup();

View File

@ -56,6 +56,7 @@ import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.GroupType;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.ILeaf;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link;
@ -206,15 +207,23 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
}
final String idShort = arg.get("CODE" + suf, 0);
if (idShort != null) {
final Code code = diagram.buildCode(idShort);
if (partition != null) {
final Ident idNewLong = diagram.buildLeafIdent(partition);
diagram.gotoGroup(idNewLong, diagram.buildCode(partition), Display.getWithNewlines(partition),
GroupType.PACKAGE, diagram.getRootGroup(), NamespaceStrategy.SINGLE);
final Code codeP = diagram.V1972() ? idNewLong : diagram.buildCode(partition);
diagram.gotoGroup(idNewLong, codeP, Display.getWithNewlines(partition), GroupType.PACKAGE,
diagram.getRootGroup(), NamespaceStrategy.SINGLE);
}
final LeafType type = getTypeIfExisting(diagram, code);
final IEntity result = diagram.getOrCreate(diagram.buildLeafIdent(idShort), code,
Display.getWithNewlines(code), type);
final Ident ident = diagram.buildLeafIdent(idShort);
final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort);
final LeafType type = diagram.V1972() ? getTypeIfExistingSmart(diagram, ident) : getTypeIfExisting(diagram,
code);
IEntity result;
if (diagram.V1972()) {
result = diagram.getLeafVerySmart(ident);
if (result == null)
result = diagram.getOrCreate(ident, code, Display.getWithNewlines(code), type);
} else
result = diagram.getOrCreate(ident, code, Display.getWithNewlines(code), type);
if (partition != null) {
diagram.endGroup();
}
@ -222,21 +231,31 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
}
final String bar = arg.get("BAR" + suf, 0);
if (bar != null) {
return diagram.getOrCreate(diagram.buildLeafIdent(bar), diagram.buildCode(bar),
Display.getWithNewlines(bar), LeafType.SYNCHRO_BAR);
final Ident identBar = diagram.buildLeafIdent(bar);
final Code codeBar = diagram.V1972() ? identBar : diagram.buildCode(bar);
if (diagram.V1972()) {
final ILeaf result = diagram.getLeafVerySmart(identBar);
if (result != null) {
return result;
}
}
return diagram.getOrCreate(identBar, codeBar, Display.getWithNewlines(bar), LeafType.SYNCHRO_BAR);
}
final RegexPartialMatch quoted = arg.get("QUOTED" + suf);
if (quoted.get(0) != null) {
final String quotedString = quoted.get(1) == null ? quoted.get(0) : quoted.get(1);
final Code quotedCode = diagram.buildCode(quotedString);
if (partition != null) {
final Ident idNewLong = diagram.buildLeafIdent(partition);
diagram.gotoGroup(idNewLong, diagram.buildCode(partition), Display.getWithNewlines(partition),
GroupType.PACKAGE, diagram.getRootGroup(), NamespaceStrategy.SINGLE);
final Code codeP = diagram.V1972() ? idNewLong : diagram.buildCode(partition);
diagram.gotoGroup(idNewLong, codeP, Display.getWithNewlines(partition), GroupType.PACKAGE,
diagram.getRootGroup(), NamespaceStrategy.SINGLE);
}
final LeafType type = getTypeIfExisting(diagram, quotedCode);
final IEntity result = diagram.getOrCreate(diagram.buildLeafIdent(quotedString), quotedCode,
Display.getWithNewlines(quoted.get(0)), type);
final Ident quotedIdent = diagram.buildLeafIdent(quotedString);
final Code quotedCode = diagram.V1972() ? quotedIdent : diagram.buildCode(quotedString);
final LeafType type = diagram.V1972() ? getTypeIfExistingSmart(diagram, quotedIdent) : getTypeIfExisting(
diagram, quotedCode);
final IEntity result = diagram.getOrCreate(quotedIdent, quotedCode, Display.getWithNewlines(quoted.get(0)),
type);
if (partition != null) {
diagram.endGroup();
}
@ -244,13 +263,15 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
}
final String quoteInvisibleString = arg.get("QUOTED_INVISIBLE" + suf, 0);
if (quoteInvisibleString != null) {
final Code quotedInvisible = diagram.buildCode(quoteInvisibleString);
if (partition != null) {
final Ident idNewLong = diagram.buildLeafIdent(partition);
diagram.gotoGroup(idNewLong, diagram.buildCode(partition), Display.getWithNewlines(partition),
GroupType.PACKAGE, diagram.getRootGroup(), NamespaceStrategy.SINGLE);
final Code codeP = diagram.V1972() ? idNewLong : diagram.buildCode(partition);
diagram.gotoGroup(idNewLong, codeP, Display.getWithNewlines(partition), GroupType.PACKAGE,
diagram.getRootGroup(), NamespaceStrategy.SINGLE);
}
final IEntity result = diagram.getOrCreate(diagram.buildLeafIdent(quoteInvisibleString), quotedInvisible,
final Ident identInvisible = diagram.buildLeafIdent(quoteInvisibleString);
final Code quotedInvisible = diagram.V1972() ? identInvisible : diagram.buildCode(quoteInvisibleString);
final IEntity result = diagram.getOrCreate(identInvisible, quotedInvisible,
Display.getWithNewlines(quotedInvisible), LeafType.ACTIVITY);
if (partition != null) {
diagram.endGroup();
@ -265,9 +286,9 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
return null;
}
private static LeafType getTypeIfExisting(ActivityDiagram system, Ident ident) {
if (system.leafExist(ident)) {
final IEntity ent = system.getLeaf(ident);
private static LeafType getTypeIfExistingSmart(ActivityDiagram system, Ident ident) {
final IEntity ent = system.getLeafSmart(ident);
if (ent != null) {
if (ent.getLeafType() == LeafType.BRANCH) {
return LeafType.BRANCH;
}

View File

@ -168,7 +168,6 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
final String display = sb.toString();
final String idShort = lineLast.get(1) == null ? display : lineLast.get(1);
final Code code = diagram.buildCode(idShort);
String partition = null;
if (lineLast.get(3) != null) {
@ -177,11 +176,12 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
}
if (partition != null) {
final Ident idNewLong = diagram.buildLeafIdent(partition);
diagram.gotoGroup(idNewLong, diagram.buildCode(partition),
Display.getWithNewlines(partition), GroupType.PACKAGE, null, NamespaceStrategy.SINGLE);
diagram.gotoGroup(idNewLong, diagram.buildCode(partition), Display.getWithNewlines(partition),
GroupType.PACKAGE, null, NamespaceStrategy.SINGLE);
}
final IEntity entity2 = diagram.getOrCreate(diagram.buildLeafIdent(idShort), code,
Display.getWithNewlines(display), LeafType.ACTIVITY);
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) {
return CommandExecutionResult.error("No such entity");
}

View File

@ -86,10 +86,10 @@ public class CommandPartition extends SingleLineCommand2<ActivityDiagram> {
@Override
protected CommandExecutionResult executeArg(ActivityDiagram diagram, LineLocation location, RegexResult arg) {
final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("NAME", 0));
final Code code = diagram.buildCode(idShort);
final Ident ident = diagram.buildLeafIdent(idShort);
final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort);
final IGroup currentPackage = diagram.getCurrentGroup();
final Ident idNewLong = diagram.buildLeafIdent(idShort);
diagram.gotoGroup(idNewLong, code, Display.getWithNewlines(code), GroupType.PACKAGE, currentPackage,
diagram.gotoGroup(ident, code, Display.getWithNewlines(code), GroupType.PACKAGE, currentPackage,
NamespaceStrategy.SINGLE);
final IEntity p = diagram.getCurrentGroup();

View File

@ -40,6 +40,7 @@ import java.io.OutputStream;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.creole.CreoleMode;
@ -80,6 +81,12 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram {
@Override
public ILeaf getOrCreateLeaf(Ident ident, Code code, LeafType type, USymbol symbol) {
checkNotNull(ident);
if (this.V1972()) {
if (type == null) {
type = LeafType.CLASS;
}
return getOrCreateLeafDefault(ident, code, type, symbol);
}
if (type == null) {
code = code.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:");
if (getNamespaceSeparator() == null) {
@ -110,6 +117,9 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram {
&& type != LeafType.LOLLIPOP_HALF && type != LeafType.NOTE) {
return super.createLeaf(idNewLong, code, display, type, symbol);
}
if (this.V1972()) {
return super.createLeaf(idNewLong, code, display, type, symbol);
}
if (getNamespaceSeparator() == null) {
return super.createLeaf(idNewLong, code, display, type, symbol);
}
@ -121,6 +131,8 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram {
}
private ILeaf createEntityWithNamespace1972(Ident id, Code fullyCode, Display display, LeafType type, USymbol symbol) {
if (this.V1972())
throw new UnsupportedOperationException();
checkNotNull(id);
final IGroup backupCurrentGroup = getCurrentGroup();
final IGroup group = backupCurrentGroup;

View File

@ -36,6 +36,7 @@
package net.sourceforge.plantuml.classdiagram.command;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.classdiagram.ClassDiagram;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
@ -45,6 +46,7 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.skin.VisibilityModifier;
public class CommandAddMethod extends SingleLineCommand2<ClassDiagram> {
@ -66,8 +68,17 @@ public class CommandAddMethod extends SingleLineCommand2<ClassDiagram> {
@Override
protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) {
final String idShort = arg.get("NAME", 0);
final IEntity entity = diagram.getOrCreateLeaf(diagram.buildLeafIdent(idShort),
diagram.buildCode(idShort), null, null);
final Ident ident = diagram.buildLeafIdent(idShort);
final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort);
/* final */IEntity entity;
if (diagram.V1972()) {
entity = diagram.getLeafVerySmart(diagram.cleanIdent(ident));
if (entity == null) {
entity = diagram.getOrCreateLeaf(ident, code, null, null);
}
} else {
entity = diagram.getOrCreateLeaf(ident, code, null, null);
}
final String field = arg.get("DATA", 0);
if (field.length() > 0 && VisibilityModifier.isVisibilityCharacter(field)) {

View File

@ -37,6 +37,7 @@ package net.sourceforge.plantuml.classdiagram.command;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
@ -126,22 +127,34 @@ public class CommandCreateClass extends SingleLineCommand2<ClassDiagram> {
@Override
protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) {
final LeafType type = LeafType.getLeafType(StringUtils.goUpperCase(arg.get("TYPE", 0)));
final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.getLazzy("CODE", 0), "\"([:");
final Code code = diagram.buildCode(idShort);
final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.getLazzy("CODE", 0),
"\"([:");
final String display = arg.getLazzy("DISPLAY", 0);
final String genericOption = arg.getLazzy("DISPLAY", 1);
final String generic = genericOption != null ? genericOption : arg.get("GENERIC", 0);
final String stereotype = arg.get("STEREO", 0);
final ILeaf entity;
if (diagram.leafExist(code)) {
entity = diagram.getOrCreateLeaf(diagram.buildLeafIdent(idShort), code, type, null);
if (entity.muteToType(type, null) == false) {
return CommandExecutionResult.error("Bad name");
final Ident idNewLong = diagram.buildLeafIdent(idShort);
if (diagram.V1972()) {
if (diagram.leafExistSmart(idNewLong)) {
entity = diagram.getOrCreateLeaf(idNewLong, idNewLong, type, null);
if (entity.muteToType(type, null) == false) {
return CommandExecutionResult.error("Bad name");
}
} else {
entity = diagram.createLeaf(idNewLong, idNewLong, Display.getWithNewlines(display), type, null);
}
} else {
final Ident idNewLong = diagram.buildLeafIdent(idShort);
entity = diagram.createLeaf(idNewLong, code, Display.getWithNewlines(display), type, null);
final Code code = diagram.buildCode(idShort);
if (diagram.leafExist(code)) {
entity = diagram.getOrCreateLeaf(idNewLong, code, type, null);
if (entity.muteToType(type, null) == false) {
return CommandExecutionResult.error("Bad name");
}
} else {
entity = diagram.createLeaf(idNewLong, code, Display.getWithNewlines(display), type, null);
}
}
if (stereotype != null) {
entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram

View File

@ -36,6 +36,7 @@
package net.sourceforge.plantuml.classdiagram.command;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.StringLocated;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url;
@ -207,8 +208,9 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
final String codes = arg.get(keyword, 1);
for (String s : codes.split(",")) {
final String idShort = StringUtils.trin(s);
final Code other = diagram.buildCode(idShort);
final IEntity cl2 = diagram.getOrCreateLeaf(diagram.buildLeafIdent(idShort), other, type2, null);
final Ident ident = diagram.buildLeafIdent(idShort);
final Code other = diagram.V1972() ? ident : diagram.buildCode(idShort);
final IEntity cl2 = diagram.getOrCreateLeaf(ident, other, type2, null);
LinkType typeLink = new LinkType(LinkDecor.NONE, LinkDecor.EXTENDS);
if (type2 == LeafType.INTERFACE && entity.getLeafType() != LeafType.INTERFACE) {
typeLink = typeLink.goDashed();
@ -232,22 +234,34 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.getLazzy("CODE", 0),
"\"([:");
final Code code = diagram.buildCode(idShort);
final Ident ident = diagram.buildLeafIdent(idShort);
final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort);
final String display = arg.getLazzy("DISPLAY", 0);
final String genericOption = arg.getLazzy("DISPLAY", 1);
final String generic = genericOption != null ? genericOption : arg.get("GENERIC", 0);
final String stereotype = arg.get("STEREO", 0);
final ILeaf result;
if (diagram.leafExist(code)) {
result = diagram.getOrCreateLeaf(diagram.buildLeafIdent(idShort), code, null, null);
if (result.muteToType(type, null) == false) {
return null;
/* final */ILeaf result;
if (diagram.V1972()) {
result = diagram.getLeafSmart(ident);
if (result != null) {
// result = diagram.getOrCreateLeaf(ident, code, null, null);
if (result.muteToType(type, null) == false) {
return null;
}
} else {
result = diagram.createLeaf(ident, code, Display.getWithNewlines(display), type, null);
}
} else {
final Ident idNewLong = diagram.buildLeafIdent(idShort);
result = diagram.createLeaf(idNewLong, code, Display.getWithNewlines(display), type, null);
if (diagram.leafExist(code)) {
result = diagram.getOrCreateLeaf(ident, code, null, null);
if (result.muteToType(type, null) == false) {
return null;
}
} else {
result = diagram.createLeaf(ident, code, Display.getWithNewlines(display), type, null);
}
}
result.setVisibilityModifier(visibilityModifier);
if (stereotype != null) {

View File

@ -37,6 +37,7 @@ package net.sourceforge.plantuml.classdiagram.command;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
@ -52,6 +53,7 @@ import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Stereotag;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
@ -192,14 +194,15 @@ public class CommandCreateElementFull2 extends SingleLineCommand2<ClassDiagram>
}
final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeRaw);
final Code code = diagram.buildCode(idShort);
final Ident ident = diagram.buildLeafIdent(idShort);
final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort);
String display = displayRaw;
if (display == null) {
display = code.getName();
}
display = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(display);
final String stereotype = arg.getLazzy("STEREOTYPE", 0);
final IEntity entity = diagram.getOrCreateLeaf(diagram.buildLeafIdent(idShort), code, type, usymbol);
final IEntity entity = diagram.getOrCreateLeaf(ident, code, type, usymbol);
entity.setDisplay(Display.getWithNewlines(display));
entity.setUSymbol(usymbol);
if (stereotype != null) {

View File

@ -36,6 +36,7 @@
package net.sourceforge.plantuml.classdiagram.command;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.classdiagram.ClassDiagram;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
@ -65,12 +66,13 @@ public class CommandDiamondAssociation extends SingleLineCommand2<ClassDiagram>
@Override
protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) {
final String idShort = arg.get("CODE", 0);
final Code code = diagram.buildCode(idShort);
if (diagram.leafExist(code)) {
final Ident ident = diagram.buildLeafIdent(idShort);
final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort);
final boolean leafExist = diagram.V1972() ? diagram.leafExistSmart(ident) : diagram.leafExist(code);
if (leafExist) {
return CommandExecutionResult.error("Already existing : " + code.getName());
}
final Ident idNewLong = diagram.buildLeafIdent(idShort);
diagram.createLeaf(idNewLong, code, Display.NULL, LeafType.ASSOCIATION, null);
diagram.createLeaf(ident, code, Display.NULL, LeafType.ASSOCIATION, null);
return CommandExecutionResult.ok();
}

View File

@ -36,6 +36,7 @@
package net.sourceforge.plantuml.classdiagram.command;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.command.CommandExecutionResult;
@ -51,6 +52,7 @@ import net.sourceforge.plantuml.cucadiagram.EntityGenderUtils;
import net.sourceforge.plantuml.cucadiagram.EntityPortion;
import net.sourceforge.plantuml.cucadiagram.EntityUtils;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.descdiagram.DescriptionDiagram;
import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram;
@ -136,8 +138,8 @@ public class CommandHideShowByGender extends SingleLineCommand2<UmlDiagram> {
} else if (arg1.startsWith("<<")) {
gender = EntityGenderUtils.byStereotype(arg1);
} else {
final IEntity entity = diagram.getOrCreateLeaf(diagram.buildLeafIdent(arg1),
diagram.buildCode(arg1), null, null);
final IEntity entity = diagram.getOrCreateLeaf(diagram.buildLeafIdent(arg1), diagram.buildCode(arg1), null,
null);
gender = EntityGenderUtils.byEntityAlone(entity);
}
@ -168,8 +170,9 @@ public class CommandHideShowByGender extends SingleLineCommand2<UmlDiagram> {
} else if (arg1.startsWith("<<")) {
gender = EntityGenderUtils.byStereotype(arg1);
} else {
final IEntity entity = diagram.getOrCreateLeaf(diagram.buildLeafIdent(arg1),
diagram.buildCode(arg1), null, null);
final Ident ident = diagram.buildLeafIdent(arg1);
final Code code = diagram.V1972() ? ident : diagram.buildCode(arg1);
final IEntity entity = diagram.getOrCreateLeaf(ident, code, null, null);
gender = EntityGenderUtils.byEntityAlone(entity);
}
if (gender != null) {

View File

@ -37,6 +37,7 @@ package net.sourceforge.plantuml.classdiagram.command;
import net.sourceforge.plantuml.Direction;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.Url;
@ -145,10 +146,12 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
return executeArgSpecial2(diagram, arg);
}
Code code1 = diagram.buildCode(ent1String);
Code code2 = diagram.buildCode(ent2String);
Ident ident1 = diagram.buildLeafIdent(ent1String);
Ident ident2 = diagram.buildLeafIdent(ent2String);
Ident ident1 = diagram.buildLeafIdentSpecial(ent1String);
Ident ident2 = diagram.buildLeafIdentSpecial(ent2String);
Ident ident1pure = Ident.empty().add(ent1String, diagram.getNamespaceSeparator());
Ident ident2pure = Ident.empty().add(ent2String, diagram.getNamespaceSeparator());
Code code1 = diagram.V1972() ? ident1 : diagram.buildCode(ent1String);
Code code2 = diagram.V1972() ? ident2 : diagram.buildCode(ent2String);
if (isGroupButNotTheCurrentGroup(diagram, code1, ident1)
&& isGroupButNotTheCurrentGroup(diagram, code2, ident2)) {
return executePackageLink(diagram, arg);
@ -157,19 +160,32 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
String port1 = null;
String port2 = null;
if (removeMemberPart(diagram, ident1) != null) {
port1 = ident1.getPortMember();
code1 = removeMemberPart(diagram, ident1);
ident1 = ident1.removeMemberPart();
}
if (removeMemberPart(diagram, ident2) != null) {
port2 = ident2.getPortMember();
code2 = removeMemberPart(diagram, ident2);
ident2 = ident2.removeMemberPart();
if (diagram.V1972()) {
if (removeMemberPartIdent(diagram, ident1) != null) {
port1 = ident1.getPortMember();
ident1 = removeMemberPartIdent(diagram, ident1);
code1 = ident1;
}
if (removeMemberPartIdent(diagram, ident2) != null) {
port2 = ident2.getPortMember();
ident2 = removeMemberPartIdent(diagram, ident2);
code2 = ident2;
}
} else {
if (removeMemberPartLegacy1972(diagram, ident1) != null) {
port1 = ident1.getPortMember();
code1 = removeMemberPartLegacy1972(diagram, ident1);
ident1 = ident1.removeMemberPart();
}
if (removeMemberPartLegacy1972(diagram, ident2) != null) {
port2 = ident2.getPortMember();
code2 = removeMemberPartLegacy1972(diagram, ident2);
ident2 = ident2.removeMemberPart();
}
}
final IEntity cl1 = getFoo1(diagram, code1, ident1);
final IEntity cl2 = getFoo1(diagram, code2, ident2);
final IEntity cl1 = getFoo1(diagram, code1, ident1, ident1pure);
final IEntity cl2 = getFoo1(diagram, code2, ident2, ident2pure);
final LinkType linkType = getLinkType(arg);
final Direction dir = getDirection(arg);
@ -260,36 +276,66 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
return CommandExecutionResult.ok();
}
private IEntity getFoo1(AbstractClassOrObjectDiagram diagram, Code code, Ident ident) {
private IEntity getFoo1(AbstractClassOrObjectDiagram diagram, Code code, Ident ident, Ident pure) {
if (isGroupButNotTheCurrentGroup(diagram, code, ident)) {
final Code tap = ident.toCode();
if (diagram.V1972()) {
return diagram.getGroupVerySmart(ident);
}
final Code tap = ident.toCode(diagram);
return diagram.getGroup(tap);
}
if (diagram.V1972()) {
final IEntity result = pure.size() == 1 ? diagram.getLeafVerySmart(ident) : diagram.getLeafStrict(ident);
if (result != null) {
return result;
}
}
return diagram.getOrCreateLeaf(ident, code, null, null);
}
private boolean isGroupButNotTheCurrentGroup(AbstractClassOrObjectDiagram diagram, Code code, Ident ident) {
if (diagram.getCurrentGroup().getCodeGetName().equals(code.getName())) {
return false;
if (diagram.V1972()) {
if (diagram.getCurrentGroup().getCodeGetName().equals(code.getName())) {
return false;
}
return diagram.isGroupVerySmart(ident);
} else {
if (diagram.getCurrentGroup().getCodeGetName().equals(code.getName())) {
return false;
}
return diagram.isGroup(code);
}
return diagram.isGroup(code);
}
private Code removeMemberPart(AbstractClassOrObjectDiagram diagram, Ident ident) {
if (diagram.leafExist(ident)) {
private Ident removeMemberPartIdent(AbstractClassOrObjectDiagram diagram, Ident ident) {
if (diagram.leafExistSmart(ident)) {
return null;
}
final Ident before2 = ident.removeMemberPart();
if (before2 == null) {
final Ident before = ident.removeMemberPart();
if (before == null) {
return null;
}
final Code before = before2.toCode();
if (diagram.leafExist(before) == false) {
if (diagram.leafExistSmart(before) == false) {
return null;
}
return before;
}
private Code removeMemberPartLegacy1972(AbstractClassOrObjectDiagram diagram, Ident ident) {
if (diagram.leafExist(ident)) {
return null;
}
final Ident before = ident.removeMemberPart();
if (before == null) {
return null;
}
final Code code = before.toCode(diagram);
if (diagram.leafExist(code) == false) {
return null;
}
return code;
}
private void addLink(AbstractClassOrObjectDiagram diagram, Link link, String weight) {
diagram.addLink(link);
if (weight == null) {
@ -313,10 +359,12 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
}
private CommandExecutionResult executePackageLink(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
final IEntity cl1 = diagram.getGroup(diagram.buildCode(StringUtils
.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 0), "\"")));
final IEntity cl2 = diagram.getGroup(diagram.buildCode(StringUtils
.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 0), "\"")));
final String ent1String = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 0), "\"");
final String ent2String = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 0), "\"");
final IEntity cl1 = diagram.V1972() ? diagram.getGroupVerySmart(diagram.buildLeafIdent(ent1String)) : diagram
.getGroup(diagram.buildCode(ent1String));
final IEntity cl2 = diagram.V1972() ? diagram.getGroupVerySmart(diagram.buildLeafIdent(ent2String)) : diagram
.getGroup(diagram.buildCode(ent2String));
final LinkType linkType = getLinkType(arg);
final Direction dir = getDirection(arg);
@ -343,6 +391,8 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
}
private CommandExecutionResult executeArgSpecial1(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
if (diagram.V1972())
return executeArgSpecial1972Ident1(diagram, arg);
final String name1A = arg.get("COUPLE1", 0);
final String name1B = arg.get("COUPLE1", 1);
final Code clName1A = diagram.buildCode(name1A);
@ -369,7 +419,91 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
return CommandExecutionResult.ok();
}
private CommandExecutionResult executeArgSpecial1972Ident1(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
final String name1A = arg.get("COUPLE1", 0);
final String name1B = arg.get("COUPLE1", 1);
final Ident ident1A = diagram.buildLeafIdent(name1A);
final Ident ident1B = diagram.buildLeafIdent(name1B);
if (diagram.leafExistSmart(ident1A) == false) {
return CommandExecutionResult.error("No class " + ident1A.getName());
}
if (diagram.leafExistSmart(ident1B) == false) {
return CommandExecutionResult.error("No class " + ident1B.getName());
}
final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 0), "\"");
final Ident ident2 = diagram.buildLeafIdent(idShort);
final IEntity cl2 = diagram.getOrCreateLeaf(ident2, ident2, null, null);
final LinkType linkType = getLinkType(arg);
final Display label = Display.getWithNewlines(arg.get("LABEL_LINK", 0));
final boolean result = diagram.associationClass(1, name1A, name1B, cl2, linkType, label);
if (result == false) {
return CommandExecutionResult.error("Cannot have more than 2 assocications");
}
return CommandExecutionResult.ok();
}
private CommandExecutionResult executeArgSpecial1972Ident2(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
final String name2A = arg.get("COUPLE2", 0);
final String name2B = arg.get("COUPLE2", 1);
final Ident ident2A = diagram.buildLeafIdent(name2A);
final Ident ident2B = diagram.buildLeafIdent(name2B);
if (diagram.leafExistSmart(ident2A) == false) {
return CommandExecutionResult.error("No class " + ident2A.getName());
}
if (diagram.leafExistSmart(ident2B) == false) {
return CommandExecutionResult.error("No class " + ident2B.getName());
}
final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 0), "\"");
final Ident ident1 = diagram.buildLeafIdent(idShort);
final IEntity cl1 = diagram.getOrCreateLeaf(ident1, ident1, null, null);
final LinkType linkType = getLinkType(arg);
final Display label = Display.getWithNewlines(arg.get("LABEL_LINK", 0));
final boolean result = diagram.associationClass(2, name2A, name2B, cl1, linkType, label);
if (result == false) {
return CommandExecutionResult.error("Cannot have more than 2 assocications");
}
return CommandExecutionResult.ok();
}
private CommandExecutionResult executeArgSpecial1972Ident3(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
final String name1A = arg.get("COUPLE1", 0);
final String name1B = arg.get("COUPLE1", 1);
final String name2A = arg.get("COUPLE2", 0);
final String name2B = arg.get("COUPLE2", 1);
final Ident ident1A = diagram.buildLeafIdent(name1A);
final Ident ident1B = diagram.buildLeafIdent(name1B);
final Ident ident2A = diagram.buildLeafIdent(name2A);
final Ident ident2B = diagram.buildLeafIdent(name2B);
if (diagram.leafExistSmart(ident1A) == false) {
return CommandExecutionResult.error("No class " + ident1A.getName());
}
if (diagram.leafExistSmart(ident1B) == false) {
return CommandExecutionResult.error("No class " + ident1B.getName());
}
if (diagram.leafExistSmart(ident2A) == false) {
return CommandExecutionResult.error("No class " + ident2A.getName());
}
if (diagram.leafExistSmart(ident2B) == false) {
return CommandExecutionResult.error("No class " + ident2B.getName());
}
final LinkType linkType = getLinkType(arg);
final Display label = Display.getWithNewlines(arg.get("LABEL_LINK", 0));
return diagram.associationClass(name1A, name1B, name2A, name2B, linkType, label);
}
private CommandExecutionResult executeArgSpecial3(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
if (diagram.V1972())
return executeArgSpecial1972Ident3(diagram, arg);
final String name1A = arg.get("COUPLE1", 0);
final String name1B = arg.get("COUPLE1", 1);
final String name2A = arg.get("COUPLE2", 0);
@ -398,6 +532,8 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
}
private CommandExecutionResult executeArgSpecial2(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
if (diagram.V1972())
return executeArgSpecial1972Ident2(diagram, arg);
final String name2A = arg.get("COUPLE2", 0);
final String name2B = arg.get("COUPLE2", 1);
final Code clName2A = diagram.buildCode(name2A);

View File

@ -36,6 +36,7 @@
package net.sourceforge.plantuml.classdiagram.command;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.command.CommandExecutionResult;
@ -116,8 +117,6 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
final String ent1 = arg.get("ENT1", 1);
final String ent2 = arg.get("ENT2", 1);
final Code ent1code = diagram.buildCode(ent1);
final Code ent2code = diagram.buildCode(ent2);
final IEntity cl1;
final IEntity cl2;
@ -126,15 +125,19 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
final String suffix = "lol" + UniqueSequence.getValue();
if (arg.get("LOL_THEN_ENT", 1) == null) {
assert arg.get("ENT_THEN_LOL", 0) != null;
cl1 = diagram.getOrCreateLeaf(diagram.buildLeafIdent(ent1), ent1code, null, null);
final Ident ident1 = diagram.buildLeafIdent(ent1);
final Code ent1code = diagram.V1972() ? ident1 : diagram.buildCode(ent1);
cl1 = getFoo1(diagram, ent1code, ident1);
final Ident idNewLong = diagram.buildLeafIdent(ent1 + suffix);
cl2 = diagram.createLeaf(idNewLong, idNewLong.toCode(), Display.getWithNewlines(ent2code),
cl2 = diagram.createLeaf(idNewLong, idNewLong.toCode(diagram), Display.getWithNewlines(ent2),
getType(arg.get("ENT_THEN_LOL", 1)), null);
normalEntity = cl1;
} else {
cl2 = diagram.getOrCreateLeaf(diagram.buildLeafIdent(ent2), ent2code, null, null);
final Ident ident2 = diagram.buildLeafIdent(ent2);
final Code ent2code = diagram.V1972() ? ident2 : diagram.buildCode(ent2);
cl2 = getFoo1(diagram, ent2code, ident2);
final Ident idNewLong = diagram.buildLeafIdent(ent2 + suffix);
cl1 = diagram.createLeaf(idNewLong, idNewLong.toCode(), Display.getWithNewlines(ent1code),
cl1 = diagram.createLeaf(idNewLong, idNewLong.toCode(diagram), Display.getWithNewlines(ent1),
getType(arg.get("LOL_THEN_ENT", 0)), null);
normalEntity = cl2;
}
@ -199,6 +202,16 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
return CommandExecutionResult.ok();
}
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) {
return result;
}
}
return diagram.getOrCreateLeaf(ident, code, null, null);
}
// private String merge(String a, String b) {
// if (a == null && b == null) {
// return null;

View File

@ -41,6 +41,7 @@ import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.IRegex;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOr;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
@ -55,7 +56,9 @@ public class CommandNamespaceSeparator extends SingleLineCommand2<CucaDiagram> {
RegexLeaf.start(), //
new RegexLeaf("set"), //
RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("namespaceseparator"), //
new RegexOr( //
new RegexLeaf("separator"), //
new RegexLeaf("namespaceseparator")), //
RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("SEPARATOR", "(\\S+)"), RegexLeaf.end()); //
}

View File

@ -37,6 +37,7 @@ package net.sourceforge.plantuml.classdiagram.command;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.classdiagram.ClassDiagram;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
@ -46,6 +47,7 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
public class CommandStereotype extends SingleLineCommand2<ClassDiagram> {
@ -65,9 +67,10 @@ public class CommandStereotype extends SingleLineCommand2<ClassDiagram> {
@Override
protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) {
final String name = arg.get("NAME", 0);
final Code code = diagram.buildCode(name);
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(diagram.buildLeafIdent(name), code, null, null);
final IEntity entity = diagram.getOrCreateLeaf(ident, code, null, null);
entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram
.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER), diagram.getSkinParam()
.getIHtmlColorSet()));

View File

@ -36,6 +36,7 @@
package net.sourceforge.plantuml.classdiagram.command;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
@ -49,6 +50,7 @@ import net.sourceforge.plantuml.command.regex.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.Ident;
public class CommandUrl extends SingleLineCommand2<AbstractEntityDiagram> {
@ -73,13 +75,15 @@ public class CommandUrl extends SingleLineCommand2<AbstractEntityDiagram> {
@Override
protected CommandExecutionResult executeArg(AbstractEntityDiagram diagram, LineLocation location, RegexResult arg) {
final String idShort = arg.get("CODE", 0);
final Code code = diagram.buildCode(idShort);
final Ident ident = diagram.buildLeafIdent(idShort);
final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort);
final String urlString = arg.get("URL", 0);
final IEntity entity;
if (diagram.leafExist(code)) {
entity = diagram.getOrCreateLeaf(diagram.buildLeafIdent(idShort), code, null, null);
} else if (diagram.isGroup(code)) {
entity = diagram.getGroup(code);
final boolean leafExist = diagram.V1972() ? diagram.leafExistSmart(ident) : diagram.leafExist(code);
if (leafExist) {
entity = diagram.getOrCreateLeaf(ident, code, null, null);
} else if (diagram.V1972() ? diagram.isGroupStrict(ident) : diagram.isGroup(code)) {
entity = diagram.V1972() ? diagram.getGroupStrict(ident) : diagram.getGroup(code);
} else {
return CommandExecutionResult.error(code + " does not exist");
}

View File

@ -36,6 +36,7 @@
package net.sourceforge.plantuml.command;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
@ -79,10 +80,19 @@ public class CommandNamespace extends SingleLineCommand2<ClassDiagram> {
@Override
protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) {
final String idShort = arg.get("NAME", 0);
final Code code = diagram.buildCode(idShort);
final IGroup currentPackage = diagram.getCurrentGroup();
final Display display = Display.getWithNewlines(code);
final Code code;
final IGroup currentPackage;
final Display display;
final Ident idNewLong = diagram.buildLeafIdent(idShort);
if (diagram.V1972()) {
code = null;
currentPackage = null;
display = Display.getWithNewlines(idNewLong.getName());
} else {
code = diagram.buildCode(idShort);
currentPackage = diagram.getCurrentGroup();
display = Display.getWithNewlines(code);
}
diagram.gotoGroup(idNewLong, code, display, GroupType.PACKAGE, currentPackage, NamespaceStrategy.MULTIPLE);
final IEntity p = diagram.getCurrentGroup();
final String stereotype = arg.get("STEREOTYPE", 0);

View File

@ -36,6 +36,7 @@
package net.sourceforge.plantuml.command;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
@ -87,12 +88,12 @@ public class CommandNamespace2 extends SingleLineCommand2<ClassDiagram> {
@Override
protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) {
final String idShort = arg.get("NAME", 0);
final Code code = diagram.buildCode(idShort);
final Ident ident = diagram.buildLeafIdent(idShort);
final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort);
final IGroup currentPackage = diagram.getCurrentGroup();
final String disp = arg.getLazzy("DISPLAY", 0);
final Display display = Display.getWithNewlines(disp);
final Ident idNewLong = diagram.buildLeafIdent(idShort);
diagram.gotoGroup(idNewLong, code, display, GroupType.PACKAGE, currentPackage, NamespaceStrategy.MULTIPLE);
diagram.gotoGroup(ident, code, display, GroupType.PACKAGE, currentPackage, NamespaceStrategy.MULTIPLE);
final IEntity p = diagram.getCurrentGroup();
final String stereotype = arg.get("STEREOTYPE", 0);
if (stereotype != null) {

View File

@ -36,6 +36,7 @@
package net.sourceforge.plantuml.command;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
@ -82,10 +83,10 @@ public class CommandNamespaceEmpty extends SingleLineCommand2<ClassDiagram> {
@Override
protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) {
final String idShort = arg.get("NAME", 0);
final Code code = diagram.buildCode(idShort);
final Ident idNewLong = diagram.buildLeafIdent(idShort);
final Code code = diagram.V1972() ? idNewLong : diagram.buildCode(idShort);
final IGroup currentPackage = diagram.getCurrentGroup();
final Display display = Display.getWithNewlines(code);
final Ident idNewLong = diagram.buildLeafIdent(idShort);
diagram.gotoGroup(idNewLong, code, display, GroupType.PACKAGE, currentPackage, NamespaceStrategy.MULTIPLE);
final IEntity p = diagram.getCurrentGroup();
final String stereotype = arg.get("STEREOTYPE", 0);

View File

@ -36,6 +36,7 @@
package net.sourceforge.plantuml.command;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
@ -102,28 +103,30 @@ public class CommandPackage extends SingleLineCommand2<AbstractEntityDiagram> {
@Override
protected CommandExecutionResult executeArg(AbstractEntityDiagram diagram, LineLocation location, RegexResult arg) {
final Code code;
final String idShort;
final String display;
/* final */String display;
final String name = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("NAME", 0));
boolean override1972 = false;
if (arg.get("AS", 0) == null) {
if (name.length() == 0) {
idShort = "##" + UniqueSequence.getValue();
code = diagram.buildCode(idShort);
display = null;
} else {
idShort = name;
code = diagram.buildCode(idShort);
display = code.getName();
display = idShort;
override1972 = true;
}
} else {
display = name;
idShort = arg.get("AS", 0);
code = diagram.buildCode(idShort);
}
final IGroup currentPackage = diagram.getCurrentGroup();
final Ident idNewLong = diagram.buildLeafIdentSpecial(idShort);
diagram.gotoGroup(idNewLong, code, Display.getWithNewlines(display), GroupType.PACKAGE, currentPackage,
// final Ident ident = diagram.buildLeafIdentSpecial(idShort);
final Ident ident = diagram.buildLeafIdent(idShort);
final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort);
if (diagram.V1972() && override1972)
display = ident.getLast();
diagram.gotoGroup(ident, code, Display.getWithNewlines(display), GroupType.PACKAGE, currentPackage,
NamespaceStrategy.SINGLE);
final IEntity p = diagram.getCurrentGroup();
final String stereotype = arg.get("STEREOTYPE", 0);

View File

@ -36,6 +36,7 @@
package net.sourceforge.plantuml.command;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
import net.sourceforge.plantuml.command.regex.IRegex;
@ -82,27 +83,24 @@ public class CommandPackageEmpty extends SingleLineCommand2<AbstractEntityDiagra
@Override
protected CommandExecutionResult executeArg(AbstractEntityDiagram diagram, LineLocation location, RegexResult arg) {
final Code code;
final String idShort;
final String display;
if (arg.get("CODE", 0) == null) {
if (StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("DISPLAY", 0)).length() == 0) {
idShort = "##" + UniqueSequence.getValue();
code = diagram.buildCode(idShort);
display = null;
} else {
idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("DISPLAY", 0));
code = diagram.buildCode(idShort);
display = code.getName();
display = idShort;
}
} else {
display = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("DISPLAY", 0));
idShort = arg.get("CODE", 0);
code = diagram.buildCode(idShort);
}
final IGroup currentPackage = diagram.getCurrentGroup();
final Ident idNewLong = diagram.buildLeafIdent(idShort);
diagram.gotoGroup(idNewLong, code, Display.getWithNewlines(display), GroupType.PACKAGE, currentPackage,
final Ident ident = diagram.buildLeafIdent(idShort);
final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort);
diagram.gotoGroup(ident, code, Display.getWithNewlines(display), GroupType.PACKAGE, currentPackage,
NamespaceStrategy.SINGLE);
final IEntity p = diagram.getCurrentGroup();
final String color = arg.get("COLOR", 0);

View File

@ -69,7 +69,7 @@ public class CommandSpriteFile extends SingleLineCommand2<UmlDiagram> {
new RegexLeaf("sprite"), //
RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("\\$?"), //
new RegexLeaf("NAME", "([\\p{L}0-9_]+)"), //
new RegexLeaf("NAME", "([-\\p{L}0-9_]+)"), //
RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("FILE", "(.*)"), RegexLeaf.end());
}

View File

@ -36,6 +36,7 @@
package net.sourceforge.plantuml.command.note;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
@ -118,10 +119,10 @@ public final class FactoryNoteActivityCommand implements SingleMultiFactoryComma
// final String s = StringUtils.getMergedLines(strings);
final String code = UniqueSequence.getString("GMN");
final Ident idNewLong = diagram.buildLeafIdent(code);
final IEntity note = diagram.createLeaf(idNewLong, diagram.buildCode(code),
strings, LeafType.NOTE, null);
final String codeString = UniqueSequence.getString("GMN");
final Ident ident = diagram.buildLeafIdent(codeString);
final Code code = diagram.V1972() ? ident : diagram.buildCode(codeString);
final IEntity note = diagram.createLeaf(ident, code, strings, LeafType.NOTE, null);
if (url != null) {
note.addUrl(url);
}
@ -137,9 +138,9 @@ public final class FactoryNoteActivityCommand implements SingleMultiFactoryComma
protected CommandExecutionResult executeArg(final ActivityDiagram diagram, LineLocation location,
RegexResult arg) {
final String tmp = UniqueSequence.getString("GN");
final Ident idNewLong = diagram.buildLeafIdent(tmp);
final IEntity note = diagram.createNote(idNewLong, diagram.buildCode(tmp),
Display.getWithNewlines(arg.get("NOTE", 0)));
final Ident ident = diagram.buildLeafIdent(tmp);
final Code code = diagram.V1972() ? ident : diagram.buildCode(tmp);
final IEntity note = diagram.createNote(ident, code, Display.getWithNewlines(arg.get("NOTE", 0)));
return executeInternal(diagram, arg, note);
}
};

View File

@ -36,6 +36,7 @@
package net.sourceforge.plantuml.command.note;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
import net.sourceforge.plantuml.classdiagram.command.CommandCreateClassMultilines;
import net.sourceforge.plantuml.command.BlocLines;
@ -127,12 +128,13 @@ public final class FactoryNoteCommand implements SingleMultiFactoryCommand<Abstr
private CommandExecutionResult executeInternal(AbstractEntityDiagram diagram, RegexResult arg, BlocLines display) {
final String idShort = arg.get("CODE", 0);
final Code code = diagram.buildCode(idShort);
if (diagram.leafExist(code)) {
final Ident ident = diagram.buildLeafIdent(idShort);
final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort);
final boolean leafExist = diagram.V1972() ? diagram.leafExistSmart(ident) : diagram.leafExist(code);
if (leafExist) {
return CommandExecutionResult.error("Note already created: " + code.getName());
}
final Ident idNewLong = diagram.buildLeafIdent(idShort);
final IEntity entity = diagram.createLeaf(idNewLong, code, display.toDisplay(), LeafType.NOTE, null);
final IEntity entity = diagram.createLeaf(ident, code, display.toDisplay(), LeafType.NOTE, null);
assert entity != null;
entity.setSpecificColorTOBEREMOVED(ColorType.BACK,
diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)));

View File

@ -36,6 +36,7 @@
package net.sourceforge.plantuml.command.note;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
@ -206,18 +207,25 @@ public final class FactoryNoteOnEntityCommand implements SingleMultiFactoryComma
return CommandExecutionResult.error("Nothing to note to");
}
} else {
final Code code = diagram.buildCode(idShort);
final Ident ident = diagram.buildLeafIdent(idShort);
final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort);
if (diagram.isGroup(code)) {
cl1 = diagram.getGroup(code);
cl1 = diagram.V1972() ? diagram.getGroupStrict(ident) : diagram.getGroup(code);
} else {
cl1 = diagram.getOrCreateLeaf(diagram.buildLeafIdent(idShort), code, null, null);
if (diagram.V1972() && diagram.leafExistSmart(diagram.cleanIdent(ident)))
cl1 = diagram.getLeafSmart(diagram.cleanIdent(ident));
else
cl1 = diagram.getOrCreateLeaf(ident, code, null, null);
}
}
final String tmp = UniqueSequence.getString("GMN");
final Ident idNewLong = diagram.buildLeafIdent(tmp);
final IEntity note = diagram.createLeaf(idNewLong, diagram.buildCode(tmp), strings.toDisplay(), LeafType.NOTE,
null);
final IEntity note;
if (diagram.V1972())
note = diagram.createLeaf(idNewLong, idNewLong, strings.toDisplay(), LeafType.NOTE, null);
else
note = diagram.createLeaf(idNewLong, diagram.buildCode(tmp), strings.toDisplay(), LeafType.NOTE, null);
final Colors colors = color().getColor(line0, diagram.getSkinParam().getIHtmlColorSet());
note.setColors(colors);

View File

@ -35,6 +35,7 @@
*/
package net.sourceforge.plantuml.command.note;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
@ -145,21 +146,21 @@ public final class FactoryTipOnEntityCommand implements SingleMultiFactoryComman
final String pos = line0.get("POSITION", 0);
final String idShort = line0.get("ENTITY", 0);
final Code codeShort = diagram.buildCode(idShort);
final Ident identShort = diagram.buildLeafIdent(idShort);
final Code codeShort = diagram.V1972() ? identShort : diagram.buildCode(idShort);
final String member = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(line0.get("ENTITY", 1));
if (codeShort == null) {
assert false;
return CommandExecutionResult.error("Nothing to note to");
}
final Ident identShort = diagram.buildLeafIdent(idShort);
final IEntity cl1 = diagram.getOrCreateLeaf(identShort, codeShort, null, null);
final Position position = Position.valueOf(StringUtils.goUpperCase(pos)).withRankdir(
diagram.getSkinParam().getRankdir());
final Ident identTip = diagram.buildLeafIdent(idShort + "$$$" + position.name());
IEntity tips = diagram.getLeaf(identTip);
IEntity tips = diagram.getLeafStrict(identTip);
if (tips == null) {
// final Code codeTip = codeShort.addSuffix("$$$" + position.name());
tips = diagram.getOrCreateLeaf(identTip, identTip.toCode(), LeafType.TIPS, null);
tips = diagram.getOrCreateLeaf(identTip, identTip.toCode(diagram), LeafType.TIPS, null);
final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).getInvisible();
final Link link;
if (position == Position.RIGHT) {

View File

@ -42,6 +42,7 @@ import net.sourceforge.plantuml.EmbeddedDiagram;
import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
@ -50,11 +51,18 @@ public class CreoleParser {
private final FontConfiguration fontConfiguration;
private final ISkinSimple skinParam;
private final HorizontalAlignment horizontalAlignment;
private final CreoleMode modeSimpleLine;
private final CreoleMode creoleMode;
private final FontConfiguration stereotypeConfiguration;
public CreoleParser(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment,
ISkinSimple skinParam, CreoleMode modeSimpleLine) {
this.modeSimpleLine = modeSimpleLine;
ISkinSimple skinParam, CreoleMode creoleMode) {
this(fontConfiguration, horizontalAlignment, skinParam, creoleMode, fontConfiguration.forceFont(null, null));
}
public CreoleParser(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment,
ISkinSimple skinParam, CreoleMode creoleMode, FontConfiguration stereotypeConfiguration) {
this.stereotypeConfiguration = stereotypeConfiguration;
this.creoleMode = creoleMode;
this.fontConfiguration = fontConfiguration;
this.skinParam = skinParam;
if (skinParam == null) {
@ -63,7 +71,8 @@ public class CreoleParser {
this.horizontalAlignment = horizontalAlignment;
}
private Stripe createStripe(String line, CreoleContext context, Stripe lastStripe) {
private Stripe createStripe(String line, CreoleContext context, Stripe lastStripe,
FontConfiguration fontConfiguration) {
if (lastStripe instanceof StripeTable && isTableLine(line)) {
final StripeTable table = (StripeTable) lastStripe;
table.analyzeAndAddNormal(line);
@ -77,7 +86,7 @@ public class CreoleParser {
} else if (isTreeStart(line)) {
return new StripeTree(fontConfiguration, skinParam, line);
}
return new CreoleStripeSimpleParser(line, context, fontConfiguration, skinParam, modeSimpleLine)
return new CreoleStripeSimpleParser(line, context, fontConfiguration, skinParam, creoleMode)
.createStripe(context);
}
@ -111,8 +120,13 @@ public class CreoleParser {
return Arrays.asList(atom);
}
};
} else if (cs instanceof Stereotype) {
for (String st : ((Stereotype) cs).getLabels(skinParam.guillemet())) {
sheet.add(createStripe(st, context, sheet.getLastStripe(), stereotypeConfiguration));
}
continue;
} else {
stripe = createStripe(cs.toString(), context, sheet.getLastStripe());
stripe = createStripe(cs.toString(), context, sheet.getLastStripe(), fontConfiguration);
}
if (stripe != null) {
sheet.add(stripe);

View File

@ -54,6 +54,7 @@ import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramTxtMaker;
import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory;
import net.sourceforge.plantuml.graphic.USymbol;
@ -68,12 +69,16 @@ import net.sourceforge.plantuml.xmlsc.StateDiagramScxmlMaker;
public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, PortionShower {
public final boolean V1972() {
return false;
}
private int horizontalPages = 1;
private int verticalPages = 1;
private final List<HideOrShow2> hides2 = new ArrayList<HideOrShow2>();
private final List<HideOrShow2> removed = new ArrayList<HideOrShow2>();
protected final EntityFactory entityFactory = new EntityFactory(hides2, removed);
protected final EntityFactory entityFactory = new EntityFactory(hides2, removed, this);
private IGroup currentGroup = entityFactory.getRootGroup();
private List<Ident> stacks2 = new ArrayList<Ident>();
private List<IGroup> stacks = new ArrayList<IGroup>();
@ -82,6 +87,10 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
public abstract IEntity getOrCreateLeaf(Ident ident, Code code, LeafType type, USymbol symbol);
public Ident cleanIdent(Ident ident) {
return ident;
}
public CucaDiagram(ISkinSimple orig) {
super(orig);
this.stacks2.add(Ident.empty());
@ -131,7 +140,11 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
if (type == null) {
throw new IllegalArgumentException();
}
ILeaf result = entityFactory.getLeaf(code);
ILeaf result;
if (this.V1972())
result = entityFactory.getLeafStrict(idNewLong);
else
result = entityFactory.getLeaf(code);
if (result == null) {
result = createLeafInternal(idNewLong, code, Display.getWithNewlines(code), type, symbol);
result.setUSymbol(symbol);
@ -147,17 +160,18 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
public ILeaf createLeaf(Ident idNewLong, Code code, Display display, LeafType type, USymbol symbol) {
checkNotNull(idNewLong);
if (entityFactory.getLeaf(idNewLong) != null) {
if (entityFactory.getLeafStrict(idNewLong) != null) {
return null;
// throw new IllegalArgumentException("Already known: " + code);
}
return createLeafInternal(idNewLong, code, display, type, symbol);
}
final protected ILeaf createLeafInternal(Ident newIdent, Code code, Display display, LeafType type, USymbol symbol) {
final protected ILeaf createLeafInternal(Ident newIdent, Code code, Display display, LeafType type,
USymbol symbol) {
checkNotNull(newIdent);
if (Display.isNull(display)) {
display = Display.getWithNewlines(code);
display = Display.getWithNewlines(code).withCreoleMode(CreoleMode.SIMPLE_LINE);
}
final ILeaf leaf = entityFactory.createLeaf(newIdent, code, display, type, getCurrentGroup(), getHides(),
getNamespaceSeparator());
@ -171,17 +185,24 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
return getLastID().add(id, namespaceSeparator);
}
final public Code buildCode(String s) {
return CodeImpl.of(s);
final public Ident buildLeafIdentSpecial(String id) {
return buildFullyQualified(id);
// if (namespaceSeparator != null) {
// if (id.contains(namespaceSeparator)) {
// return Ident.empty().add(id, namespaceSeparator);
// }
// }
// return getLastID().add(id, namespaceSeparator);
}
final public Ident buildLeafIdentSpecial(String id) {
if (namespaceSeparator != null) {
if (id.contains(namespaceSeparator)) {
return Ident.empty().add(id, namespaceSeparator);
}
}
return getLastID().add(id, namespaceSeparator);
final public Ident buildFullyQualified(String id) {
return entityFactory.buildFullyQualified(getLastID(), Ident.empty().add(id, namespaceSeparator));
}
final public Code buildCode(String s) {
if (this.V1972())
throw new UnsupportedOperationException();
return CodeImpl.of(s);
}
protected final void checkNotNull(Object id) {
@ -191,14 +212,22 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
}
public boolean leafExist(Code code) {
if (this.V1972())
throw new UnsupportedOperationException();
return entityFactory.getLeaf(code) != null;
}
public boolean leafExist(Ident ident) {
return entityFactory.getLeaf(ident) != null;
public boolean leafExistSmart(Ident ident) {
return entityFactory.getLeafSmart(ident) != null;
}
public boolean leafExistStrict(Ident ident) {
return entityFactory.getLeafStrict(ident) != null;
}
final public Collection<IGroup> getChildrenGroups(IGroup parent) {
if (this.V1972())
return getChildrenGroupsIdent1972(parent);
final Collection<IGroup> result = new ArrayList<IGroup>();
for (IGroup gg : getGroups(false)) {
if (gg.getParentContainer() == parent) {
@ -208,8 +237,23 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
return Collections.unmodifiableCollection(result);
}
private Collection<IGroup> getChildrenGroupsIdent1972(IGroup parent) {
final Collection<IGroup> result = new ArrayList<IGroup>();
for (IGroup gg : entityFactory.groups2()) {
if (gg.getIdent().parent().equals(parent.getIdent())) {
result.add(gg);
}
}
return Collections.unmodifiableCollection(result);
}
final public void gotoGroup(Ident ident, Code code, Display display, GroupType type, IGroup parent,
NamespaceStrategy strategy) {
if (this.V1972()) {
gotoGroupInternalWithNamespace(ident, code, display, code, type, parent);
return;
}
if (strategy == NamespaceStrategy.MULTIPLE) {
if (getNamespaceSeparator() != null) {
code = getFullyQualifiedCode1972(code);
@ -243,6 +287,11 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
GroupType type, IGroup parent) {
this.stacks.add(currentGroup);
this.stacks2.add(idNewLong);
if (this.V1972()) {
gotoGroupInternal(idNewLong, code, display, namespaceNew, type, parent);
return;
}
if (getNamespaceSeparator() == null) {
gotoGroupInternal(idNewLong, code, display, namespaceNew, type, parent);
return;
@ -285,12 +334,17 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
private void gotoGroupInternal(Ident idNewLong, final Code code, Display display, final Code namespace,
GroupType type, IGroup parent) {
if (this.V1972()) {
gotoGroupInternal1972(idNewLong, code, display, namespace, type, parent);
return;
}
IGroup result = entityFactory.getGroup(code);
if (result != null) {
currentGroup = result;
return;
}
if (entityFactory.getLeaf(idNewLong) != null) {
if (entityFactory.getLeafStrict(idNewLong) != null) {
result = entityFactory.muteToGroup(code.getName(), namespace, type, parent);
result.setDisplay(display);
} else {
@ -301,6 +355,30 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
currentGroup = result;
}
private void gotoGroupInternal1972(Ident idNewLong, final Code code, Display display, final Code namespace,
GroupType type, IGroup parent) {
IGroup result = entityFactory.getGroupStrict(idNewLong);
if (result != null) {
currentGroup = result;
return;
}
final boolean mutation;
if (namespaceSeparator == null)
mutation = entityFactory.getLeafVerySmart(idNewLong) != null;
else
mutation = entityFactory.getLeafStrict(idNewLong) != null;
if (mutation) {
result = entityFactory.muteToGroup1972(idNewLong, namespace, type, parent);
result.setDisplay(display);
} else {
result = entityFactory.createGroup(idNewLong, code, display, namespace, type, parent, getHides(),
getNamespaceSeparator());
}
entityFactory.addGroup(result);
currentGroup = result;
stacks2.set(stacks2.size() - 1, result.getIdent());
}
final protected void gotoGroupExternal(Ident newIdLong, final Code code, Display display, final Code namespace,
GroupType type, IGroup parent) {
IGroup result = entityFactory.getGroup(code);
@ -359,12 +437,44 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
return p;
}
public final IGroup getGroupStrict(Ident ident) {
if (!this.V1972())
throw new UnsupportedOperationException();
final IGroup p = entityFactory.getGroupStrict(ident);
if (p == null) {
throw new IllegalArgumentException();
// return null;
}
return p;
}
public final IGroup getGroupVerySmart(Ident ident) {
if (!this.V1972())
throw new UnsupportedOperationException();
final IGroup p = entityFactory.getGroupVerySmart(ident);
if (p == null) {
throw new IllegalArgumentException();
// return null;
}
return p;
}
public final boolean isGroup(Code code) {
if (this.V1972())
return isGroupStrict((Ident) code);
return leafExist(code) == false && entityFactory.getGroup(code) != null;
}
public final boolean isGroup(Ident ident) {
return leafExist(ident) == false && entityFactory.getGroup(ident) != null;
public final boolean isGroupStrict(Ident ident) {
if (!this.V1972())
throw new UnsupportedOperationException();
return leafExistStrict(ident) == false && entityFactory.getGroupStrict(ident) != null;
}
public final boolean isGroupVerySmart(Ident ident) {
if (!this.V1972())
throw new UnsupportedOperationException();
return leafExistSmart(ident) == false && entityFactory.getGroupVerySmart(ident) != null;
}
public final Collection<IGroup> getGroups(boolean withRootGroup) {
@ -393,8 +503,16 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
return entityFactory.getLeaf(code);
}
public final ILeaf getLeaf(Ident ident) {
return entityFactory.getLeaf(ident);
public final ILeaf getLeafStrict(Ident ident) {
return entityFactory.getLeafStrict(ident);
}
public final ILeaf getLeafSmart(Ident ident) {
return entityFactory.getLeafSmart(ident);
}
public /* final */ ILeaf getLeafVerySmart(Ident ident) {
return entityFactory.getLeafVerySmart(ident);
}
final public void addLink(Link link) {
@ -488,8 +606,9 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
throw new UnsupportedOperationException();
}
final CucaDiagramFileMaker maker = this.isUseJDot() ? new CucaDiagramFileMakerJDot(this,
fileFormatOption.getDefaultStringBounder()) : new CucaDiagramFileMakerSvek(this);
final CucaDiagramFileMaker maker = this.isUseJDot()
? new CucaDiagramFileMakerJDot(this, fileFormatOption.getDefaultStringBounder())
: new CucaDiagramFileMakerSvek(this);
final ImageData result = maker.createFile(os, getDotStrings(), fileFormatOption);
if (result == null) {

View File

@ -66,7 +66,6 @@ import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockSimple;
import net.sourceforge.plantuml.graphic.TextBlockSprited;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.VerticalAlignment;
@ -467,45 +466,30 @@ public class Display implements Iterable<CharSequence> {
if (getNaturalHorizontalAlignment() != null) {
horizontalAlignment = getNaturalHorizontalAlignment();
}
final FontConfiguration stereotypeConfiguration = fontConfiguration.forceFont(fontForStereotype,
htmlColorForStereotype);
if (size() > 0) {
if (get(0) instanceof Stereotype) {
return createStereotype(fontConfiguration, horizontalAlignment, spriteContainer, 0, fontForStereotype,
htmlColorForStereotype);
htmlColorForStereotype, maxMessageSize, creoleMode);
}
if (get(size() - 1) instanceof Stereotype) {
return createStereotype(fontConfiguration, horizontalAlignment, spriteContainer, size() - 1,
fontForStereotype, htmlColorForStereotype);
fontForStereotype, htmlColorForStereotype, maxMessageSize, creoleMode);
}
if (get(0) instanceof MessageNumber) {
return createMessageNumber(fontConfiguration, horizontalAlignment, spriteContainer, maxMessageSize);
return createMessageNumber(fontConfiguration, horizontalAlignment, spriteContainer, maxMessageSize,
stereotypeConfiguration);
}
}
return getCreole(fontConfiguration, horizontalAlignment, spriteContainer, maxMessageSize, creoleMode);
}
private TextBlock getCreole(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment,
ISkinSimple spriteContainer, LineBreakStrategy maxMessageSize, CreoleMode creoleMode) {
final Sheet sheet = new CreoleParser(fontConfiguration, horizontalAlignment, spriteContainer, creoleMode)
.createSheet(this);
final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, maxMessageSize, spriteContainer == null ? 0
: spriteContainer.getPadding());
return new SheetBlock2(sheetBlock1, sheetBlock1, new UStroke(1.5));
}
private TextBlock createMessageNumber(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment,
ISkinSimple spriteContainer, LineBreakStrategy maxMessageSize) {
TextBlock tb1 = subList(0, 1).getCreole(fontConfiguration, horizontalAlignment, spriteContainer,
maxMessageSize, CreoleMode.FULL);
tb1 = TextBlockUtils.withMargin(tb1, 0, 4, 0, 0);
final TextBlock tb2 = subList(1, size()).getCreole(fontConfiguration, horizontalAlignment, spriteContainer,
maxMessageSize, CreoleMode.FULL);
return TextBlockUtils.mergeLR(tb1, tb2, VerticalAlignment.CENTER);
return getCreole(fontConfiguration, horizontalAlignment, spriteContainer, maxMessageSize, creoleMode,
stereotypeConfiguration);
}
private TextBlock createStereotype(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment,
SpriteContainer spriteContainer, int position, UFont fontForStereotype, HtmlColor htmlColorForStereotype) {
SpriteContainer spriteContainer, int position, UFont fontForStereotype, HtmlColor htmlColorForStereotype,
LineBreakStrategy maxMessageSize, CreoleMode creoleMode) {
final Stereotype stereotype = (Stereotype) get(position);
TextBlock circledCharacter = null;
if (stereotype.isSpotted()) {
@ -514,15 +498,35 @@ public class Display implements Iterable<CharSequence> {
} else {
circledCharacter = stereotype.getSprite(spriteContainer);
}
if (circledCharacter != null) {
if (stereotype.getLabel(Guillemet.DOUBLE_COMPARATOR) == null) {
return new TextBlockSprited(circledCharacter, this.subList(1, this.size()), fontConfiguration,
horizontalAlignment, spriteContainer);
}
return new TextBlockSprited(circledCharacter, this, fontConfiguration, horizontalAlignment, spriteContainer);
}
return new TextBlockSimple(this, fontConfiguration, horizontalAlignment, spriteContainer, 0, fontForStereotype,
final FontConfiguration stereotypeConfiguration = fontConfiguration.forceFont(fontForStereotype,
htmlColorForStereotype);
final TextBlock result = getCreole(fontConfiguration, horizontalAlignment, (ISkinSimple) spriteContainer,
maxMessageSize, creoleMode, stereotypeConfiguration);
if (circledCharacter != null) {
return new TextBlockSprited(circledCharacter, result);
}
return result;
}
private TextBlock getCreole(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment,
ISkinSimple spriteContainer, LineBreakStrategy maxMessageSize, CreoleMode creoleMode,
FontConfiguration stereotypeConfiguration) {
final Sheet sheet = new CreoleParser(fontConfiguration, horizontalAlignment, spriteContainer, creoleMode,
stereotypeConfiguration).createSheet(this);
final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, maxMessageSize, spriteContainer == null ? 0
: spriteContainer.getPadding());
return new SheetBlock2(sheetBlock1, sheetBlock1, new UStroke(1.5));
}
private TextBlock createMessageNumber(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment,
ISkinSimple spriteContainer, LineBreakStrategy maxMessageSize, FontConfiguration stereotypeConfiguration) {
TextBlock tb1 = subList(0, 1).getCreole(fontConfiguration, horizontalAlignment, spriteContainer,
maxMessageSize, CreoleMode.FULL, stereotypeConfiguration);
tb1 = TextBlockUtils.withMargin(tb1, 0, 4, 0, 0);
final TextBlock tb2 = subList(1, size()).getCreole(fontConfiguration, horizontalAlignment, spriteContainer,
maxMessageSize, CreoleMode.FULL, stereotypeConfiguration);
return TextBlockUtils.mergeLR(tb1, tb2, VerticalAlignment.CENTER);
}
}

View File

@ -143,9 +143,18 @@ public class GroupRoot implements IGroup {
public Collection<IGroup> getChildren() {
final List<IGroup> result = new ArrayList<IGroup>();
for (IGroup ent : entityFactory.groups()) {
if (ent.getParentContainer() == this) {
result.add(ent);
if (entityFactory.namespaceSeparator.V1972()) {
for (IGroup ent : entityFactory.groups()) {
if (ent.getIdent().size() == 1) {
result.add(ent);
}
}
} else {
for (IGroup ent : entityFactory.groups()) {
if (ent.getParentContainer() == this) {
result.add(ent);
}
}
}
return Collections.unmodifiableCollection(result);

View File

@ -55,6 +55,18 @@ public class Ident implements Code {
return parts.toString();
}
public boolean startsWith(Ident other) {
if (other.parts.size() > this.parts.size()) {
return false;
}
for (int i = 0; i < other.parts.size(); i++) {
if (other.parts.get(i).equals(this.parts.get(i)) == false) {
return false;
}
}
return true;
}
public String forXmi() {
final StringBuilder sb = new StringBuilder();
for (String s : parts) {
@ -66,15 +78,26 @@ public class Ident implements Code {
return sb.toString();
}
public Ident add(Ident added) {
final List<String> copy = new ArrayList<String>(parts);
copy.addAll(added.parts);
return new Ident(copy);
}
public static Ident empty() {
return new Ident(Collections.<String> emptyList());
}
public String getLast() {
if (parts.size() == 0) {
return "";
}
return parts.get(parts.size() - 1);
}
public Code toCode() {
public Code toCode(CucaDiagram diagram) {
if (diagram.V1972())
return this;
return CodeImpl.of(getLast());
}
@ -199,7 +222,10 @@ public class Ident implements Code {
return sb.toString();
}
public void checkSameAs(Code code, String separator) {
public void checkSameAs(Code code, String separator, CucaDiagram diagram) {
if (diagram.V1972()) {
return;
}
final String last = parts.get(parts.size() - 1);
if (separator == null) {
if (code.getName().equals(last) != true && code.getName().equals(toString(separator)) == false) {
@ -236,4 +262,23 @@ public class Ident implements Code {
return getLast();
}
public boolean isRoot() {
return parts.size() == 0;
}
public Ident move(Ident from, Ident to) {
if (this.startsWith(from) == false) {
throw new IllegalArgumentException();
}
final List<String> result = new ArrayList<String>(to.parts);
for (int i = from.parts.size(); i < this.parts.size(); i++) {
result.add(this.parts.get(i));
}
return new Ident(result);
}
public int size() {
return parts.size();
}
}

View File

@ -48,6 +48,7 @@ import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryCircleLine;
import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryCrowfoot;
import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryDiamond;
import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryDoubleLine;
import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryHalfArrow;
import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryLineCrowfoot;
import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryNotNavigable;
import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryParenthesis;
@ -57,18 +58,18 @@ import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryTriangle;
public enum LinkDecor {
NONE(2, false, 0), EXTENDS(30, false, 2), COMPOSITION(15, true, 1.3), AGREGATION(15, false, 1.3), NOT_NAVIGABLE(1,
false, 0.5),
NONE(2, false, 0), EXTENDS(30, false, 2), COMPOSITION(15, true, 1.3), AGREGATION(15, false, 1.3),
NOT_NAVIGABLE(1, false, 0.5),
CROWFOOT(10, true, 0.8), CIRCLE_CROWFOOT(14, false, 0.8), CIRCLE_LINE(10, false, 0.8),
DOUBLE_LINE(7, false, 0.7), LINE_CROWFOOT(10, false, 0.8),
CROWFOOT(10, true, 0.8), CIRCLE_CROWFOOT(14, false, 0.8), CIRCLE_LINE(10, false, 0.8), DOUBLE_LINE(7, false, 0.7),
LINE_CROWFOOT(10, false, 0.8),
ARROW(10, true, 0.5), ARROW_TRIANGLE(10, true, 0.8), ARROW_AND_CIRCLE(10, false, 0.5),
CIRCLE(0, false, 0.5), CIRCLE_FILL(0, false, 0.5), CIRCLE_CONNECT(0, false, 0.5), PARENTHESIS(0, false, OptionFlags.USE_INTERFACE_EYE2 ? 0.5
: 1.0), SQUARE(0, false, 0.5),
CIRCLE(0, false, 0.5), CIRCLE_FILL(0, false, 0.5), CIRCLE_CONNECT(0, false, 0.5),
PARENTHESIS(0, false, OptionFlags.USE_INTERFACE_EYE2 ? 0.5 : 1.0), SQUARE(0, false, 0.5),
CIRCLE_CROSS(0, false, 0.5), PLUS(0, false, 1.5), SQUARRE_toberemoved(30, false, 0);
CIRCLE_CROSS(0, false, 0.5), PLUS(0, false, 1.5), HALF_ARROW(0, false, 1.5), SQUARRE_toberemoved(30, false, 0);
private final double arrowSize;
private final int margin;
@ -95,6 +96,8 @@ public enum LinkDecor {
public ExtremityFactory getExtremityFactory(HtmlColor backgroundColor) {
if (this == LinkDecor.PLUS) {
return new ExtremityFactoryPlus();
} else if (this == LinkDecor.HALF_ARROW) {
return new ExtremityFactoryHalfArrow();
} else if (this == LinkDecor.ARROW_TRIANGLE) {
return new ExtremityFactoryTriangle();
} else if (this == LinkDecor.CROWFOOT) {

View File

@ -1,40 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.cucadiagram;
public class Namespace {
}

View File

@ -266,7 +266,7 @@ public class Stereotype implements CharSequence {
public List<String> getLabels(Guillemet guillemet) {
final String labelLocal = getLabel(Guillemet.DOUBLE_COMPARATOR);
if (labelLocal == null) {
return null;
return Collections.emptyList();
}
return cutLabels(labelLocal, guillemet);
}

View File

@ -46,37 +46,54 @@ import net.sourceforge.plantuml.StringUtils;
class GraphvizWindows extends AbstractGraphviz {
static private File specificDotExe;
@Override
protected File specificDotExe() {
final File result = searchInDir(new File("c:/Program Files"));
if (result != null) {
return result;
synchronized (GraphvizWindows.class) {
if (specificDotExe == null) {
specificDotExe = specificDotExeSlow();
}
return specificDotExe;
}
final File result86 = searchInDir(new File("c:/Program Files (x86)"));
if (result86 != null) {
return result86;
}
final File resultEclipse = searchInDir(new File("c:/eclipse/graphviz"));
if (resultEclipse != null) {
return resultEclipse;
}
private File specificDotExeSlow() {
for (File tmp : new File("c:/").listFiles(new FileFilter() {
public boolean accept(File pathname) {
return pathname.isDirectory() && pathname.canRead();
}
})) {
final File result = searchInDir(tmp);
if (result != null) {
return result;
}
}
return null;
}
private static File searchInDir(final File programFile) {
if (programFile.exists() == false || programFile.isDirectory() == false) {
private static File searchInDir(final File dir) {
if (dir.exists() == false || dir.isDirectory() == false) {
return null;
}
final List<File> dots = new ArrayList<File>();
for (File f : programFile.listFiles(new FileFilter() {
final File[] files = dir.listFiles(new FileFilter() {
public boolean accept(File pathname) {
return pathname.isDirectory() && StringUtils.goLowerCase(pathname.getName()).startsWith("graphviz");
}
})) {
});
if (files == null) {
return null;
}
for (File f : files) {
final File result = new File(new File(f, "bin"), "dot.exe");
if (result.exists() && result.canRead()) {
dots.add(result.getAbsoluteFile());
}
final File result2 = new File(new File(f, "release/bin"), "dot.exe");
if (result2.exists() && result2.canRead()) {
dots.add(result2.getAbsoluteFile());
}
}
return higherVersion(dots);
}
@ -98,5 +115,4 @@ class GraphvizWindows extends AbstractGraphviz {
return "dot.exe";
}
}

View File

@ -41,10 +41,13 @@ import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.cucadiagram.Bodier;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.GroupRoot;
import net.sourceforge.plantuml.cucadiagram.GroupType;
@ -59,11 +62,11 @@ import net.sourceforge.plantuml.skin.VisibilityModifier;
public final class EntityFactory {
private final Map<String, ILeaf> leafsByCode = new LinkedHashMap<String, ILeaf>();
private final Map<String, IGroup> groupsByCode = new LinkedHashMap<String, IGroup>();
private final Map<String, ILeaf> leafsByCode;
private final Map<String, IGroup> groupsByCode;
private final Map<Ident, ILeaf> leafs2 = new LinkedHashMap<Ident, ILeaf>();
private final Map<Ident, IGroup> groups2 = new LinkedHashMap<Ident, IGroup>();
/* private */final Map<Ident, ILeaf> leafs2 = new LinkedHashMap<Ident, ILeaf>();
/* private */final Map<Ident, IGroup> groups2 = new LinkedHashMap<Ident, IGroup>();
private final List<Link> links = new ArrayList<Link>();
@ -72,10 +75,20 @@ public final class EntityFactory {
private final IGroup rootGroup = new GroupRoot(this);
private final List<HideOrShow2> hides2;
private final List<HideOrShow2> removed;
/* private */ final public CucaDiagram namespaceSeparator;
public EntityFactory(List<HideOrShow2> hides2, List<HideOrShow2> removed) {
public EntityFactory(List<HideOrShow2> hides2, List<HideOrShow2> removed, CucaDiagram namespaceSeparator) {
this.hides2 = hides2;
this.removed = removed;
this.namespaceSeparator = namespaceSeparator;
// if (OptionFlags.V1972(namespaceSeparator)) {
// this.leafsByCode = null;
// this.groupsByCode = null;
// } else {
this.leafsByCode = new LinkedHashMap<String, ILeaf>();
this.groupsByCode = new LinkedHashMap<String, IGroup>();
// }
}
public boolean isHidden(ILeaf leaf) {
@ -95,17 +108,9 @@ public final class EntityFactory {
}
public void thisIsGoingToBeALeaf(Ident ident) {
// if (byIdents.containsKey(ident) == false) {
// System.err.println("thisIsGoingToBeALeaf::byIdents=" + byIdents.keySet());
// System.err.println("thisIsGoingToBeALeaf::ident=" + ident);
// // Thread.dumpStack();
// // System.exit(0);
// }
// byIdents.remove(ident);
}
public void thisIsNotArealGroup(Ident ident) {
// byIdents.remove(ident);
}
public ILeaf createLeaf(Ident ident, Code code, Display display, LeafType entityType, IGroup parentContainer,
@ -113,17 +118,11 @@ public final class EntityFactory {
if (entityType == null) {
throw new IllegalArgumentException();
}
// if (byIdents.containsKey(ident)) {
// throw new IllegalArgumentException();
// }
final Bodier bodier = new Bodier(entityType, hides);
final EntityImpl result = new EntityImpl(ident, code, this, bodier, parentContainer, entityType,
namespaceSeparator, rawLayout);
bodier.setLeaf(result);
result.setDisplay(display);
// System.err.println("adding1 "+ident);
// byIdents.put(ident, result);
// System.err.println("EntityFactory::createLeaf=" + result);
return result;
}
@ -132,34 +131,40 @@ public final class EntityFactory {
if (groupType == null) {
throw new IllegalArgumentException();
}
// if (byIdents.containsKey(ident)) {
// throw new IllegalArgumentException();
// }
final Bodier bodier = new Bodier(null, hides);
final EntityImpl result = new EntityImpl(ident, code, this, bodier, parentContainer, groupType, namespace,
namespaceSeparator, rawLayout);
if (Display.isNull(display) == false) {
result.setDisplay(display);
}
// System.err.println("adding2 "+ident);
// byIdents.put(ident, result);
// System.err.println("EntityFactory::createGroup=" + result);
return result;
}
public void addLeaf(ILeaf entity) {
// System.err.println("EntityFactory::addLeaf=" + entity);
leafsByCode.put(entity.getCodeGetName(), entity);
if (namespaceSeparator.V1972() == false)
leafsByCode.put(entity.getCodeGetName(), entity);
leafs2.put(entity.getIdent(), entity);
if (namespaceSeparator.V1972())
ensureParentIsCreated(entity.getIdent());
}
public void addGroup(IGroup group) {
// System.err.println("EntityFactory::addGroup=" + group);
groupsByCode.put(group.getCodeGetName(), group);
if (namespaceSeparator.V1972() == false)
groupsByCode.put(group.getCodeGetName(), group);
groups2.put(group.getIdent(), group);
if (namespaceSeparator.V1972())
ensureParentIsCreated(group.getIdent());
}
private void ensureParentIsCreated(Ident ident) {
if (groups2.get(ident.parent()) != null)
return;
getParentContainer(ident, null);
}
void removeGroup(String name) {
if (namespaceSeparator.V1972())
throw new UnsupportedOperationException();
final IEntity removed = groupsByCode.remove(name);
if (removed == null) {
throw new IllegalArgumentException();
@ -170,13 +175,22 @@ public final class EntityFactory {
}
}
void removeGroup(Ident ident) {
final IEntity removed = groups2.remove(ident);
if (removed == null) {
throw new IllegalArgumentException();
}
}
public static void bigError() {
Thread.dumpStack();
// Thread.dumpStack();
// System.exit(0);
// throw new IllegalArgumentException();
}
void removeLeaf(String name) {
if (namespaceSeparator.V1972())
throw new UnsupportedOperationException();
final IEntity removed = leafsByCode.remove(name);
if (removed == null) {
throw new IllegalArgumentException();
@ -187,7 +201,25 @@ public final class EntityFactory {
}
}
void removeLeaf(Ident ident) {
final IEntity removed = leafs2.remove(ident);
if (removed == null) {
System.err.println("leafs2=" + leafs2.keySet());
throw new IllegalArgumentException(ident.toString());
}
}
private void removeLeaf1972(ILeaf leaf) {
final boolean removed = leafs2.values().remove(leaf);
if (removed == false) {
System.err.println("leafs2=" + leafs2.keySet());
throw new IllegalArgumentException(leaf.toString());
}
}
public IGroup muteToGroup(String name, Code namespace, GroupType type, IGroup parent) {
if (namespaceSeparator.V1972())
throw new UnsupportedOperationException();
final ILeaf leaf = leafsByCode.get(name);
((EntityImpl) leaf).muteToGroup(namespace, type, parent);
final IGroup result = (IGroup) leaf;
@ -195,15 +227,91 @@ public final class EntityFactory {
return result;
}
public IGroup muteToGroup1972(Ident ident, Code namespace, GroupType type, IGroup parent) {
if (!namespaceSeparator.V1972())
throw new UnsupportedOperationException();
final ILeaf leaf;
if (namespaceSeparator.getNamespaceSeparator() == null)
leaf = getLeafVerySmart(ident);
else
leaf = leafs2.get(ident);
((EntityImpl) leaf).muteToGroup(namespace, type, parent);
final IGroup result = (IGroup) leaf;
removeLeaf1972(leaf);
return result;
}
public IGroup getRootGroup() {
return rootGroup;
}
public final ILeaf getLeaf(Ident ident) {
public final ILeaf getLeafStrict(Ident ident) {
return leafs2.get(ident);
}
public final ILeaf getLeafSmart(Ident ident) {
if (!namespaceSeparator.V1972())
throw new UnsupportedOperationException();
final ILeaf result = leafs2.get(ident);
if (result == null && ident.size() == 1) {
for (Entry<Ident, ILeaf> ent : leafs2.entrySet()) {
if (ent.getKey().getLast().equals(ident.getLast())) {
return ent.getValue();
}
}
}
return result;
}
public final ILeaf getLeafVerySmart(Ident ident) {
if (!namespaceSeparator.V1972())
throw new UnsupportedOperationException();
final ILeaf result = leafs2.get(ident);
if (result == null) {
for (Entry<Ident, ILeaf> ent : leafs2.entrySet()) {
if (ent.getKey().getLast().equals(ident.getLast())) {
return ent.getValue();
}
}
}
return result;
}
public Ident buildFullyQualified(Ident currentPath, Ident id) {
if (currentPath.equals(id) == false) {
if (leafs2.containsKey(id) || groups2.containsKey(id)) {
return id;
}
}
if (id.size() > 1) {
return id;
}
return currentPath.add(id);
}
public final IGroup getGroupStrict(Ident ident) {
if (namespaceSeparator.getNamespaceSeparator() == null) {
return getGroupVerySmart(ident);
}
final IGroup result = groups2.get(ident);
return result;
}
public final IGroup getGroupVerySmart(Ident ident) {
final IGroup result = groups2.get(ident);
if (result == null) {
for (Entry<Ident, IGroup> ent : groups2.entrySet()) {
if (ent.getKey().getLast().equals(ident.getLast())) {
return ent.getValue();
}
}
}
return result;
}
public final ILeaf getLeaf(Code code) {
if (namespaceSeparator.V1972())
throw new UnsupportedOperationException();
final ILeaf result = leafsByCode.get(code.getName());
if (result != null && result != leafs2.get(result.getIdent())) {
bigError();
@ -212,6 +320,8 @@ public final class EntityFactory {
}
public final IGroup getGroup(Code code) {
if (namespaceSeparator.V1972())
throw new UnsupportedOperationException();
final IGroup result = groupsByCode.get(code.getName());
if (result != null && result != groups2.get(result.getIdent())) {
bigError();
@ -219,12 +329,9 @@ public final class EntityFactory {
return result;
}
public final IGroup getGroup(Ident ident) {
final IGroup result = groups2.get(ident);
return result;
}
public final Collection<ILeaf> leafs() {
if (namespaceSeparator.V1972())
return leafs2();
final Collection<ILeaf> result = Collections.unmodifiableCollection(leafsByCode.values());
if (new ArrayList<ILeaf>(result).equals(new ArrayList<ILeaf>(leafs2())) == false) {
bigError();
@ -233,6 +340,8 @@ public final class EntityFactory {
}
public final Collection<IGroup> groups() {
if (namespaceSeparator.V1972())
return groups2();
final Collection<IGroup> result = Collections.unmodifiableCollection(groupsByCode.values());
if (new ArrayList<IGroup>(result).equals(new ArrayList<IGroup>(groups2())) == false) {
bigError();
@ -282,19 +391,24 @@ public final class EntityFactory {
}
public IGroup getParentContainer(Ident ident, IGroup parentContainer) {
if (namespaceSeparator.V1972()) {
final Ident parent = ident.parent();
if (parent.isRoot()) {
return this.rootGroup;
}
IGroup result = getGroupStrict(parent);
if (result != null) {
return result;
}
System.err.println("getParentContainer::groups2=" + groups2);
result = createGroup(parent, parent, Display.getWithNewlines(parent.getName()), null, GroupType.PACKAGE,
null, Collections.<VisibilityModifier>emptySet(), namespaceSeparator.getNamespaceSeparator());
addGroup(result);
return result;
}
if (parentContainer == null) {
throw new IllegalArgumentException();
}
// if (parentContainer == null) {
// } else {
// final Ident identParent = parentContainer.getIdent();
// if (ident.parent().equals(identParent) == false) {
// System.err.println("ident=" + ident);
// System.err.println("parentContainer=" + identParent);
// Thread.dumpStack();
// System.exit(0);
// }
// }
return parentContainer;
}

View File

@ -48,6 +48,7 @@ import java.util.Set;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.Guillemet;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.cucadiagram.Bodier;
@ -83,8 +84,8 @@ final class EntityImpl implements ILeaf, IGroup {
private final EntityFactory entityFactory;
// Entity
private final Code code;
private final Ident ident;
private/* final */Code code;
private/* final */Ident ident;
private Url url;
@ -139,6 +140,9 @@ final class EntityImpl implements ILeaf, IGroup {
private EntityImpl(Ident ident, EntityFactory entityFactory, Code code, Bodier bodier, IGroup parentContainer,
String namespaceSeparator, int rawLayout) {
checkNotNull(ident);
if (entityFactory.namespaceSeparator.V1972()) {
code = ident;
}
if (code == null) {
throw new IllegalArgumentException();
}
@ -164,7 +168,7 @@ final class EntityImpl implements ILeaf, IGroup {
this(ident, entityFactory, code, bodier, parentContainer, namespaceSeparator, rawLayout);
checkNotNull(ident);
// System.err.println("ID for group=" + code + " " + ident);
ident.checkSameAs(code, namespaceSeparator);
ident.checkSameAs(code, namespaceSeparator, entityFactory.namespaceSeparator);
this.groupType = groupType;
this.namespace = namespace;
}
@ -259,6 +263,8 @@ final class EntityImpl implements ILeaf, IGroup {
public String toString() {
// return super.toString() + code + " " + display + "(" + leafType + ")[" + groupType + "] " + xposition + " "
// + getUid();
if (entityFactory.namespaceSeparator.V1972())
return getUid() + " " + ident + " " + display + "(" + leafType + ")[" + groupType + "]";
return super.toString() + code + ident + " " + display + "(" + leafType + ")[" + groupType + "] " + getUid();
}
@ -399,6 +405,10 @@ final class EntityImpl implements ILeaf, IGroup {
}
public void moveEntitiesTo(IGroup dest) {
if (entityFactory.namespaceSeparator.V1972()) {
moveEntitiesTo1972(dest);
return;
}
checkGroup();
if (dest.isGroup() == false) {
throw new UnsupportedOperationException();
@ -420,6 +430,65 @@ final class EntityImpl implements ILeaf, IGroup {
}
private void moveEntitiesTo1972(IGroup dest) {
checkGroup();
if (dest.isGroup() == false) {
throw new UnsupportedOperationException();
}
System.err.println("moveEntitiesTo1972::before1::groups2=" + entityFactory.groups2());
final Ident firstIdent = getIdent();
final Ident destIdent = dest.getIdent();
System.err.println("moveEntitiesTo1972::this=" + firstIdent);
System.err.println("moveEntitiesTo1972::dest=" + destIdent);
if (destIdent.startsWith(firstIdent) == false) {
throw new UnsupportedOperationException();
}
System.err.println("moveEntitiesTo1972::before2::groups2=" + entityFactory.groups2());
for (ILeaf ent : new ArrayList<ILeaf>(entityFactory.leafs2())) {
Ident ident = ent.getIdent();
if (ident.equals(firstIdent) == false && ident.startsWith(firstIdent)
&& ident.startsWith(destIdent) == false) {
System.err.print("moving leaf ident1=" + ident);
entityFactory.leafs2.remove(ident);
ident = ident.move(firstIdent, destIdent);
System.err.println(" to ident2=" + ident);
((EntityImpl) ent).ident = ident;
((EntityImpl) ent).code = ident;
entityFactory.leafs2.put(ident, ent);
}
}
System.err.println("moveEntitiesTo1972::before3::groups2=" + entityFactory.groups2());
for (IGroup ent : new ArrayList<IGroup>(entityFactory.groups2())) {
Ident ident = ent.getIdent();
System.err.println("found=" + ident + " " + ident.startsWith(firstIdent) + " "
+ ident.startsWith(destIdent));
if (ident.equals(firstIdent) == false && ident.startsWith(firstIdent)
&& ident.startsWith(destIdent) == false) {
System.err.print("moving gr ident1=" + ident);
entityFactory.groups2.remove(ident);
ident = ident.move(firstIdent, destIdent);
System.err.println(" to ident2=" + ident);
((EntityImpl) ent).ident = ident;
((EntityImpl) ent).code = ident;
entityFactory.groups2.put(ident, ent);
System.err.println("-->groups2=" + entityFactory.groups2());
}
}
System.err.println("moveEntitiesTo1972::after::groups2=" + entityFactory.groups2());
// for (IGroup g : dest.getChildren()) {
// // ((EntityImpl) g).parentContainer = dest;
// throw new IllegalStateException();
// }
//
// for (IGroup g : getChildren()) {
// if (g == dest) {
// continue;
// }
// ((EntityImpl) g).parentContainer = dest;
// }
}
public int size() {
checkGroup();
return getLeafsDirect().size();
@ -470,10 +539,19 @@ final class EntityImpl implements ILeaf, IGroup {
}
}
entityFactory.removeGroup(getCodeGetName());
for (ILeaf ent : new ArrayList<ILeaf>(entityFactory.leafs())) {
if (this != ent && this == ent.getParentContainer()) {
entityFactory.removeLeaf(ent.getCodeGetName());
if (entityFactory.namespaceSeparator.V1972()) {
entityFactory.removeGroup(getIdent());
for (ILeaf ent : new ArrayList<ILeaf>(entityFactory.leafs())) {
if (this != ent && getIdent().equals(ent.getIdent().parent())) {
entityFactory.removeLeaf(ent.getIdent());
}
}
} else {
entityFactory.removeGroup(getCodeGetName());
for (ILeaf ent : new ArrayList<ILeaf>(entityFactory.leafs())) {
if (this != ent && this == ent.getParentContainer()) {
entityFactory.removeLeaf(ent.getCodeGetName());
}
}
}

View File

@ -37,6 +37,7 @@ package net.sourceforge.plantuml.descdiagram;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
@ -86,17 +87,22 @@ public class CommandCreateDomain extends SingleLineCommand2<DescriptionDiagram>
protected CommandExecutionResult executeArg(DescriptionDiagram diagram, LineLocation location, RegexResult arg) {
String type = arg.get("TYPE", 0);
String display = arg.getLazzy("DISPLAY", 0);
String code = arg.getLazzy("CODE", 0);
if (code == null) {
code = display;
String codeString = arg.getLazzy("CODE", 0);
if (codeString == null) {
codeString = display;
}
final String genericOption = arg.getLazzy("DISPLAY", 1);
final String generic = genericOption != null ? genericOption : arg.get("GENERIC", 0);
// final String genericOption = arg.getLazzy("DISPLAY", 1);
// final String generic = genericOption != null ? genericOption : arg.get("GENERIC", 0);
final String stereotype = arg.get("STEREO", 0);
if (diagram.leafExist(diagram.buildCode(code))) {
return CommandExecutionResult.error("Object already exists : " + code);
final Ident ident = diagram.buildLeafIdent(codeString);
final Code code = diagram.V1972() ? ident : diagram.buildCode(codeString);
if (diagram.V1972() && diagram.leafExistSmart(ident)) {
return CommandExecutionResult.error("Object already exists : " + codeString);
}
if (!diagram.V1972() && diagram.leafExist(code)) {
return CommandExecutionResult.error("Object already exists : " + codeString);
}
Display d = Display.getWithNewlines(display);
final String urlString = arg.get("URL", 0);
@ -104,15 +110,12 @@ public class CommandCreateDomain extends SingleLineCommand2<DescriptionDiagram>
IEntity entity;
if (group != null) {
final IGroup currentGroup = diagram.getCurrentGroup();
final Ident idNewLong = diagram.buildLeafIdent(code);
diagram.gotoGroup(idNewLong, diagram.buildCode(code), d,
type.equalsIgnoreCase("domain") ? GroupType.DOMAIN : GroupType.REQUIREMENT, currentGroup,
NamespaceStrategy.SINGLE);
diagram.gotoGroup(ident, code, d, type.equalsIgnoreCase("domain") ? GroupType.DOMAIN
: GroupType.REQUIREMENT, currentGroup, NamespaceStrategy.SINGLE);
entity = diagram.getCurrentGroup();
} else {
final Ident idNewLong = diagram.buildLeafIdent(code);
entity = diagram.createLeaf(idNewLong, diagram.buildCode(code), d,
type.equalsIgnoreCase("domain") ? LeafType.DOMAIN : LeafType.REQUIREMENT, null);
entity = diagram.createLeaf(ident, code, d, type.equalsIgnoreCase("domain") ? LeafType.DOMAIN
: LeafType.REQUIREMENT, null);
}
if (stereotype != null) {
entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram

View File

@ -36,6 +36,7 @@
package net.sourceforge.plantuml.descdiagram;
import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
@ -51,6 +52,23 @@ public class DescriptionDiagram extends AbstractEntityDiagram {
super(skinParam);
}
@Override
public Ident cleanIdent(Ident ident) {
String codeString = ident.getName();
if (codeString.startsWith("[") && codeString.endsWith("]")) {
return ident.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:");
}
if (codeString.startsWith(":") && codeString.endsWith(":")) {
return ident.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:");
}
if (codeString.startsWith("()")) {
codeString = StringUtils.trin(codeString.substring(2));
codeString = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeString);
return ident.parent().add(Ident.empty().add(codeString, null));
}
return ident;
}
@Override
public ILeaf getOrCreateLeaf(Ident ident, Code code, LeafType type, USymbol symbol) {
checkNotNull(ident);
@ -59,21 +77,23 @@ public class DescriptionDiagram extends AbstractEntityDiagram {
if (codeString.startsWith("[") && codeString.endsWith("]")) {
final USymbol sym = getSkinParam().useUml2ForComponent() ? USymbol.COMPONENT2 : USymbol.COMPONENT1;
final Ident idNewLong = ident.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:");
return getOrCreateLeafDefault(idNewLong, idNewLong.toCode(), LeafType.DESCRIPTION, sym);
return getOrCreateLeafDefault(idNewLong, idNewLong.toCode(this), LeafType.DESCRIPTION, sym);
}
if (codeString.startsWith(":") && codeString.endsWith(":")) {
final Ident idNewLong = ident.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:");
return getOrCreateLeafDefault(idNewLong, idNewLong.toCode(), LeafType.DESCRIPTION, getSkinParam().getActorStyle()
.getUSymbol());
return getOrCreateLeafDefault(idNewLong, idNewLong.toCode(this), LeafType.DESCRIPTION, getSkinParam()
.getActorStyle().getUSymbol());
}
if (codeString.startsWith("()")) {
codeString = StringUtils.trin(codeString.substring(2));
codeString = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeString);
final Ident idNewLong = buildLeafIdent(codeString);
return getOrCreateLeafDefault(idNewLong, buildCode(codeString), LeafType.DESCRIPTION, USymbol.INTERFACE);
final Code code99 = this.V1972() ? idNewLong : buildCode(codeString);
return getOrCreateLeafDefault(idNewLong, code99, LeafType.DESCRIPTION, USymbol.INTERFACE);
}
code = buildCode(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(code.getName(), "\"([:"));
final String tmp4 = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(code.getName(), "\"([:");
final Ident idNewLong = ident.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:");
code = this.V1972() ? idNewLong : buildCode(tmp4);
return getOrCreateLeafDefault(idNewLong, code, LeafType.STILL_UNKNOWN, symbol);
}
return getOrCreateLeafDefault(ident, code, type, symbol);

View File

@ -37,6 +37,7 @@ package net.sourceforge.plantuml.descdiagram.command;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
@ -49,6 +50,7 @@ import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.descdiagram.DescriptionDiagram;
@ -122,10 +124,11 @@ public class CommandArchimate extends SingleLineCommand2<DescriptionDiagram> {
final String codeRaw = arg.getLazzy("CODE", 0);
final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeRaw);
final Code code = diagram.buildCode(idShort);
final Ident ident = diagram.buildLeafIdent(idShort);
final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort);
final String icon = arg.getLazzy("STEREOTYPE", 0);
final IEntity entity = diagram.getOrCreateLeaf(diagram.buildLeafIdent(idShort), code, LeafType.DESCRIPTION, USymbol.ARCHIMATE);
final IEntity entity = diagram.getOrCreateLeaf(ident, code, LeafType.DESCRIPTION, USymbol.ARCHIMATE);
final String displayRaw = arg.getLazzy("DISPLAY", 0);

View File

@ -36,6 +36,7 @@
package net.sourceforge.plantuml.descdiagram.command;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
@ -51,6 +52,7 @@ import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.USymbol;
@ -103,10 +105,11 @@ public class CommandArchimateMultilines extends CommandMultilines2<AbstractEntit
final String codeRaw = line0.getLazzy("CODE", 0);
final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeRaw);
final Code code = diagram.buildCode(idShort);
final Ident ident = diagram.buildLeafIdent(idShort);
final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort);
final String icon = line0.getLazzy("STEREOTYPE", 0);
final IEntity entity = diagram.getOrCreateLeaf(diagram.buildLeafIdent(idShort), code, LeafType.DESCRIPTION, USymbol.RECTANGLE);
final IEntity entity = diagram.getOrCreateLeaf(ident, code, LeafType.DESCRIPTION, USymbol.RECTANGLE);
lines = lines.subExtract(1, 1);
Display display = lines.toDisplay();

View File

@ -37,6 +37,7 @@ package net.sourceforge.plantuml.descdiagram.command;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
@ -54,6 +55,7 @@ import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.ILeaf;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.descdiagram.DescriptionDiagram;
@ -65,7 +67,7 @@ import net.sourceforge.plantuml.graphic.color.Colors;
public class CommandCreateElementFull extends SingleLineCommand2<DescriptionDiagram> {
public static final String ALL_TYPES = "artifact|actor|folder|card|file|package|rectangle|node|frame|cloud|database|queue|stack|storage|agent|usecase|component|boundary|control|entity|interface|circle|collections";
public static final String ALL_TYPES = "artifact|actor|folder|card|file|package|rectangle|label|node|frame|cloud|database|queue|stack|storage|agent|usecase|component|boundary|control|entity|interface|circle|collections";
public CommandCreateElementFull() {
super(getRegexConcat());
@ -188,20 +190,24 @@ public class CommandCreateElementFull extends SingleLineCommand2<DescriptionDiag
}
final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeRaw);
final Code code = diagram.buildCode(idShort);
if (diagram.isGroup(code)) {
final Ident ident = diagram.buildLeafIdent(idShort);
final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort);
if (!diagram.V1972() && diagram.isGroup(code)) {
return CommandExecutionResult.error("This element (" + code.getName() + ") is already defined");
}
if (diagram.V1972() && diagram.isGroupStrict(ident)) {
return CommandExecutionResult.error("This element (" + ident.getName() + ") is already defined");
}
String display = displayRaw;
if (display == null) {
display = code.getName();
}
display = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(display);
final String stereotype = arg.getLazzy("STEREOTYPE", 0);
if (existsWithBadType(diagram, code, type, usymbol)) {
if (existsWithBadType3(diagram, code, ident, type, usymbol)) {
return CommandExecutionResult.error("This element (" + code.getName() + ") is already defined");
}
final IEntity entity = diagram.getOrCreateLeaf(diagram.buildLeafIdent(idShort), code, type, usymbol);
final IEntity entity = diagram.getOrCreateLeaf(ident, code, type, usymbol);
entity.setDisplay(Display.getWithNewlines(display));
entity.setUSymbol(usymbol);
if (stereotype != null) {
@ -230,19 +236,33 @@ public class CommandCreateElementFull extends SingleLineCommand2<DescriptionDiag
return CommandExecutionResult.ok();
}
public static boolean existsWithBadType(AbstractEntityDiagram diagram, final Code code, LeafType type,
public static boolean existsWithBadType3(AbstractEntityDiagram diagram, Code code, Ident ident, LeafType type,
USymbol usymbol) {
if (diagram.leafExist(code) == false) {
if (diagram.V1972()) {
if (diagram.leafExistSmart(ident) == false) {
return false;
}
final ILeaf other = diagram.getLeafSmart(ident);
if (other.getLeafType() != type) {
return true;
}
if (usymbol != null && other.getUSymbol() != usymbol) {
return true;
}
return false;
} else {
if (diagram.leafExist(code) == false) {
return false;
}
final ILeaf other = diagram.getLeaf(code);
if (other.getLeafType() != type) {
return true;
}
if (usymbol != null && other.getUSymbol() != usymbol) {
return true;
}
return false;
}
final ILeaf other = diagram.getLeaf(code);
if (other.getLeafType() != type) {
return true;
}
if (usymbol != null && other.getUSymbol() != usymbol) {
return true;
}
return false;
}
private char getCharEncoding(final String codeRaw) {

View File

@ -38,6 +38,7 @@ package net.sourceforge.plantuml.descdiagram.command;
import java.util.List;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
@ -141,7 +142,6 @@ public class CommandCreateElementMultilines extends CommandMultilines2<AbstractE
}
final String idShort = line0.get("CODE", 0);
final Code code = diagram.buildCode(idShort);
final List<String> lineLast = StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()), lines.getLast499()
.getString());
lines = lines.subExtract(1, 1);
@ -157,11 +157,12 @@ public class CommandCreateElementMultilines extends CommandMultilines2<AbstractE
final String stereotype = line0.get("STEREO", 0);
if (CommandCreateElementFull.existsWithBadType(diagram, code, type, usymbol)) {
final Ident ident = diagram.buildLeafIdent(idShort);
final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort);
if (CommandCreateElementFull.existsWithBadType3(diagram, code, ident, type, usymbol)) {
return CommandExecutionResult.error("This element (" + code.getName() + ") is already defined");
}
final Ident idNewLong = diagram.buildLeafIdent(idShort);
final ILeaf result = diagram.createLeaf(idNewLong, code, display, type, usymbol);
final ILeaf result = diagram.createLeaf(ident, code, display, type, usymbol);
if (result == null) {
return CommandExecutionResult.error("This element (" + code.getName() + ") is already defined");
}

View File

@ -90,7 +90,7 @@ public class CommandLinkElement extends SingleLineCommand2<DescriptionDiagram> {
new RegexOptional(new RegexLeaf("INSIDE", "(0|\\(0\\)|\\(0|0\\))(?=[-=.~])")), //
new RegexLeaf("ARROW_STYLE2", "(?:\\[(" + LINE_STYLE + ")\\])?"), //
new RegexLeaf("BODY2", "([-=.~]*)"), //
new RegexLeaf("HEAD1", "(\\(0|>>|[>^*+#0@(]|\\|>|o[%s]+)?"), //
new RegexLeaf("HEAD1", "(\\(0|>>|[>^*+#0@(]|\\|>|\\\\\\\\|o[%s]+)?"), //
RegexLeaf.spaceZeroOrMore(), //
new RegexOptional(new RegexLeaf("LABEL2", "[%g]([^%g]+)[%g]")), //
RegexLeaf.spaceZeroOrMore(), //
@ -130,6 +130,8 @@ public class CommandLinkElement extends SingleLineCommand2<DescriptionDiagram> {
d1 = LinkDecor.AGREGATION;
} else if (head1.equals("+")) {
d1 = LinkDecor.PLUS;
} else if (head1.equals("\\\\")) {
d1 = LinkDecor.HALF_ARROW;
} else if (head1.equals(">>")) {
d1 = LinkDecor.ARROW_TRIANGLE;
} else if (head1.equals("^")) {
@ -289,18 +291,12 @@ public class CommandLinkElement extends SingleLineCommand2<DescriptionDiagram> {
protected CommandExecutionResult executeArg(DescriptionDiagram diagram, LineLocation location, RegexResult arg) {
final String ent1String = arg.get("ENT1", 0);
final String ent2String = arg.get("ENT2", 0);
final Code code1 = diagram.buildCode(ent1String);
final Code code2 = diagram.buildCode(ent2String);
if (diagram.isGroup(code1) && diagram.isGroup(code2)) {
return executePackageLink(diagram, arg);
}
final Ident ident1 = diagram.buildLeafIdent(ent1String);
final Ident ident2 = diagram.buildLeafIdent(ent2String);
final IEntity cl1 = getFoo1(diagram, code1, ident1);
final IEntity cl2 = getFoo1(diagram, code2, ident2);
final Ident ident1 = diagram.buildFullyQualified(ent1String);
final Ident ident2 = diagram.buildFullyQualified(ent2String);
Ident ident1pure = Ident.empty().add(ent1String, diagram.getNamespaceSeparator());
Ident ident2pure = Ident.empty().add(ent2String, diagram.getNamespaceSeparator());
final Code code1 = diagram.V1972() ? ident1 : diagram.buildCode(ent1String);
final Code code2 = diagram.V1972() ? ident2 : diagram.buildCode(ent2String);
final LinkType linkType = getLinkType(arg);
final Direction dir = getDirection(arg);
@ -310,9 +306,19 @@ public class CommandLinkElement extends SingleLineCommand2<DescriptionDiagram> {
} else {
queue = getQueue(arg);
}
final Labels labels = new Labels(arg);
final IEntity cl1;
final IEntity cl2;
if (diagram.isGroup(code1) && diagram.isGroup(code2)) {
cl1 = diagram.V1972() ? diagram.getGroupStrict(diagram.buildLeafIdent(ent1String)) : diagram
.getGroup(diagram.buildCode(ent1String));
cl2 = diagram.V1972() ? diagram.getGroupStrict(diagram.buildLeafIdent(ent2String)) : diagram
.getGroup(diagram.buildCode(ent2String));
} else {
cl1 = getFoo1(diagram, code1, ident1, ident1pure);
cl2 = getFoo1(diagram, code2, ident2, ident2pure);
}
Link link = new Link(cl1, cl2, linkType, Display.getWithNewlines(labels.labelLink), queue.length(),
labels.firstLabel, labels.secondLabel, diagram.getLabeldistance(), diagram.getLabelangle(), diagram
.getSkinParam().getCurrentStyleBuilder());
@ -330,58 +336,46 @@ public class CommandLinkElement extends SingleLineCommand2<DescriptionDiagram> {
return CommandExecutionResult.ok();
}
private IEntity getFoo1(DescriptionDiagram diagram, Code code, Ident ident) {
if (diagram.isGroup(code)) {
private IEntity getFoo1(DescriptionDiagram diagram, Code code, Ident ident, Ident pure) {
if (!diagram.V1972() && diagram.isGroup(code)) {
return diagram.getGroup(code);
}
return getOrCreateLeafInternal(diagram, code, ident);
}
private ILeaf getOrCreateLeafInternal(DescriptionDiagram diagram, Code code, Ident ident) {
if (diagram.V1972() && diagram.isGroupStrict(ident)) {
return diagram.getGroupStrict(ident);
}
final String codeString = code.getName();
if (ident.getLast().startsWith("()")) {
ident = ident.removeStartingParenthesis();
return diagram.getOrCreateLeaf(ident, ident.toCode(), LeafType.DESCRIPTION, USymbol.INTERFACE);
return getOrCreateLeaf1972(diagram, ident, ident.toCode(diagram), LeafType.DESCRIPTION, USymbol.INTERFACE,
pure);
}
final char codeChar = codeString.length() > 2 ? codeString.charAt(0) : 0;
final Code code3 = diagram.buildCode(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeString, "\"([:"));
final Ident ident3 = diagram.buildLeafIdent(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(
codeString, "\"([:"));
final String tmp3 = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeString, "\"([:");
final Ident ident3 = diagram.buildFullyQualified(tmp3);
final Code code3 = diagram.V1972() ? ident3 : diagram.buildCode(tmp3);
if (codeChar == '(') {
return diagram.getOrCreateLeaf(ident3, code3, LeafType.USECASE, USymbol.USECASE);
return getOrCreateLeaf1972(diagram, ident3, code3, LeafType.USECASE, USymbol.USECASE, pure);
} else if (codeChar == ':') {
return diagram.getOrCreateLeaf(ident3, code3, LeafType.DESCRIPTION, diagram.getSkinParam().getActorStyle()
.getUSymbol());
return getOrCreateLeaf1972(diagram, ident3, code3, LeafType.DESCRIPTION, diagram.getSkinParam()
.getActorStyle().getUSymbol(), pure);
} else if (codeChar == '[') {
final USymbol sym = diagram.getSkinParam().useUml2ForComponent() ? USymbol.COMPONENT2 : USymbol.COMPONENT1;
return diagram.getOrCreateLeaf(ident3, code3, LeafType.DESCRIPTION, sym);
return getOrCreateLeaf1972(diagram, ident3, code3, LeafType.DESCRIPTION, sym, pure);
}
return diagram.getOrCreateLeaf(ident, code, null, null);
return getOrCreateLeaf1972(diagram, ident, code, null, null, pure);
}
private CommandExecutionResult executePackageLink(DescriptionDiagram diagram, RegexResult arg) {
final IEntity cl1 = diagram.getGroup(diagram.buildCode(arg.get("ENT1", 0)));
final IEntity cl2 = diagram.getGroup(diagram.buildCode(arg.get("ENT2", 0)));
final LinkType linkType = getLinkType(arg);
final Direction dir = getDirection(arg);
final String queue;
if (dir == Direction.LEFT || dir == Direction.RIGHT) {
queue = "-";
} else {
queue = getQueue(arg);
private ILeaf getOrCreateLeaf1972(DescriptionDiagram diagram, Ident ident, Code code, LeafType type,
USymbol symbol, Ident pure) {
if (diagram.V1972()) {
final ILeaf result = pure.size() == 1 ? diagram.getLeafVerySmart(ident) : diagram.getLeafStrict(ident);
// final ILeaf result = diagram.getLeafSmart(ident);
if (result != null) {
return result;
}
}
final Labels labels = new Labels(arg);
Link link = new Link(cl1, cl2, linkType, Display.getWithNewlines(labels.labelLink), queue.length(), diagram
.getSkinParam().getCurrentStyleBuilder());
if (dir == Direction.LEFT || dir == Direction.UP) {
link = link.getInv();
}
link.applyStyle(arg.getLazzy("ARROW_STYLE", 0));
diagram.addLink(link);
return CommandExecutionResult.ok();
return diagram.getOrCreateLeaf(ident, code, type, symbol);
}
}

View File

@ -36,6 +36,7 @@
package net.sourceforge.plantuml.descdiagram.command;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
@ -138,26 +139,24 @@ public class CommandPackageWithUSymbol extends SingleLineCommand2<AbstractEntity
protected CommandExecutionResult executeArg(AbstractEntityDiagram diagram, LineLocation location, RegexResult arg) {
final String codeRaw = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.getLazzy("CODE", 0));
final String displayRaw = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.getLazzy("DISPLAY", 0));
final Code code;
final String display;
final String idShort;
if (codeRaw.length() == 0) {
idShort = UniqueSequence.getString("##");
code = diagram.buildCode(idShort);
display = null;
} else {
idShort = codeRaw;
code = diagram.buildCode(idShort);
if (displayRaw == null) {
display = code.getName();
display = idShort;
} else {
display = displayRaw;
}
}
final Ident ident = diagram.buildLeafIdent(idShort);
final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort);
final IGroup currentPackage = diagram.getCurrentGroup();
final Ident idNewLong = diagram.buildLeafIdent(idShort);
diagram.gotoGroup(idNewLong, code, Display.getWithNewlines(display), GroupType.PACKAGE, currentPackage,
diagram.gotoGroup(ident, code, Display.getWithNewlines(display), GroupType.PACKAGE, currentPackage,
NamespaceStrategy.SINGLE);
final IEntity p = diagram.getCurrentGroup();
p.setUSymbol(USymbol.getFromString(arg.get("SYMBOL", 0), diagram.getSkinParam().getActorStyle()));

View File

@ -71,23 +71,24 @@ public class PSystemDonors extends AbstractPSystem {
private static final int COLS = 6;
private static final int FREE_LINES = 6;
public static final String DONORS = "6ym902mFR3fSuLzO9ciEU-UTVLaMenKnfVRDznXLdPaQKLLXAao0mEOTctOFBc-_C0Zx6pfwpEqxFUut"
+ "qbz4LxhtJJEYBLjJd6SKnOAWnzlacc6RUtjIPKW9Ogde_il4xUdMSI4sJgWGoY75FJja_dVfXBnNLM6M"
+ "xbPr_dI5saaRsR46R3M7opy5BaNbN0u56eGQqwaxr-5GHQEyUk1h2qqoA5pv2dnBAcR5n0wHugiRH-2J"
+ "pWnghTCwnoVIQlzI5z1Hvt9DYPI4yZnA95gtbVQE0tHVm6GIYKSTiC4ve9B3VeAftPw88N6hGOFAd8p6"
+ "fcgsFB70H02Qs8u_bA9cyvJCd8PE91vBe8JFht42i5UggOZPaSs0afxHegT9GfVNA-7cUB4qHUgWuJOm"
+ "uE6aJT1AGVu7Ek7NxgikcInZLzHCUGhprMmUYeSKNQnFPlJjh8M9yd-p8JFLyuhQvYcTnxhQ-9_DeTWq"
+ "PTNmcz76FEVWFhqjfD1neG3RIw3dUaV5_9cdZOLq2CzZwOLic8jNbb44pXgdYiLVnPRMoBzrXHfR5ylD"
+ "ZGLzpD-GMyb09rOX5aCVqqfcPUSJ9KrJu_EGHqF7Pn9hacRr3kbRYdCj__UsiAAPPXZeUXTpcgwDA1L6"
+ "GTMTR9e8J0kz6WeBo1selKnkrPVLG_phV43chOaa8hSvWNwcUaAzoyKgp1rhkjJ4363nb6Wd4gyRYI2h"
+ "BkXrG9b5fYFqsqrwfYsEXQTERtZSj1c3-g9ELqx2Lmk1TpTCohoP76pVuPo2n_7bUVLz7-5Z5S1Qt7lR"
+ "HMe-Wu5sImj6H5gEACTHTaburq0PMOmbBnhYpnxMk7ZePl0-aqNxc7ctEGvP0YhFceTMkiMuTKs6lYCc"
+ "cx1NiMXh8FYIc0Mg8-DzmEM2v84gBY5ncy4AE7W1mgyFNh4H5kxMGTKj8oT7rodCrdrr6cW9VjpMWQMo"
+ "3pnLk7Nth3Y3D4gTLynxOSsRnZwa-5X0kHmKpAI9ie-Kefgsbf5HOmnwzhg3vtQgsmAxZMyrZ1KARrDq"
+ "qs83jYbgkehjHXFpH5HHgH6NFXP6mCyy_2OyDDOXnj_qiXbnfhaXJ4c54vvVd2qDsnujibwZrstRzhPo"
+ "_lo_rsG7ftfSvrK5q1M4_DzCcTo81TSrFON-tkMBFfWpMIsgrJY9bUUMdWMO32AtRFQcVPgHtQapokrg"
+ "WpxhyQ6IlwaS9wZh4vPVp59KXoznDjlU6auLvhxvHZZ9eV3-fwYoAJ-uAYKrCO9DxEGepkDuhgCKTrrS"
+ "GGJq3HS5ndxpisBDbum-NpJdC1mPyjCHTZdStRMW2casfmKMwQplhTkwP7R_IqRmXL6JTbOFQurZX5IB" + "G57DXFeu3000";
public static final String DONORS = "6_C902mFU3XMJbc44wzsvvsjcZxOY0eHBCyJYiF08fxk1iGVuDxfSR-H_YAwqhrlcX5jsPhYFACe5WGz"
+ "tYRN3DlSsmEncfYlaZlpHhymBmn9Q4C2N8Sx8ZvLXfGWbehklqpSdcuT5-9WXmgX75BSio7JYHWNmTFc"
+ "zIrbijRaGSBf_cywBUuU2c6MPYkSZqQe_GEd6AjhBdS_Yheqwk8kLQrkXHhJgOjZk2eqogi7lhPGCYey"
+ "DCvtG8jPCTb3f4JhnX6YHcU6aPgqpiaJUMh_KI-WJUToJOcS2UKnIYIwRYkTsNVG_OBabn0AkM2Bm08g"
+ "7BuJj7Ljn4X2CcWOwibeRBbconCt377enBxyer7KkATaUXhQ965Ne2JgQnoGz4eZMiJiz6P09SzeCQD9"
+ "KbVcJNXy7PQcQ1qqt0iMOPQq2Qi9v4te2P_mLPTCpl5ILF2cfoIFPflGKDasuDxCwDjSInBbVxSnS-Qx"
+ "HxLvIcUhgut_sHnorvHLosz66-qSmRs_BQHWSR50VW2zD2SgoPzbtrX8GhYtqWiPdFklNAC8d3qo5HR_"
+ "4LjQe__MbMniHIoF6mjyN5zNcfB1bbo5N8Q-fbNABPqlb9IcnkSXZvQEpoJMbCpgdQUFKJAtyl-xOILc"
+ "Li90LwQORRfUK3HMiPgUR4m4fq7tXjm4o0ke3fDRULWznA_p0Pct9ICHkGt9AEJhB-MGYnGciAO7Iim0"
+ "5ayfxI69U212JJlGsr1fHTeYzDjDUjgMZ8Nxf3yyxfePepoYaneduO-5mE669JLlfhkqxz4JU8ulpwlk"
+ "8tMi0bpBlJTSfFeP3AmhBHY1r1tHsFUoIyAXWH9Px2Ll3V4zmneN3ps-u4mM7M96c-EGvQ5oEncjz1R3"
+ "koP3tocJpTkhlyWRIBm8wo4T6OtW_M7oI2qkaOHqi1m_Mm1Yvk8LkrBWcaBLBJidc-iKfhglFeHAyEDy"
+ "0gFoBJp3MElkHN46DCgS4_DUMVFHU0qfFXPGFOS8MjA9CaTAKQQjPMJCMeEUWzR1zbFT5lJR-5R3gaBn"
+ "RH7TiTW0Q7t6DAFtS0Cy4Ifg5Rpaf330Nxz-JG_6EiJujPVDY8DaSqaCeGAQqtznMfflnz0IrblqVzks"
+ "lQsSF_zUHtPm6esxhog8deB0_rsKd8EchlEf-c_WWoJYW9MOjN4IAo-DtWWa9JYE3rPHJqqpwdToHhaj"
+ "jUYTnuSg_NQgn84vDoo_QAKeXoznohQtXbEbP3_-nk8aXuP_YYfhChagfJKnefhOsL6Sfx7lKOgxhbf1"
+ "17FW4e6zN_zqckOXO_QBbJaC1qD-FY9T3k6kXRMOriPfWVtYhEyjRLqouN_92ByKQzhEwc6wSVnRsWNA"
+ "lXr9mdWKi7PAd2Ua1lyb0m00";
/*
* Special thanks to our sponsors and donors:

View File

@ -331,7 +331,9 @@ public class QuoteUtils {
"Pngnfgebcur vf nyjnlf whfg nebhaq gur pbeare.",
"Orjner bs ohtf va gur nobir pbqr; V unir bayl cebirq vg pbeerpg, abg gevrq vg",
"V'z abg n erny cebtenzzre. V guebj gbtrgure guvatf hagvy vg jbexf gura V zbir ba",
"#qrsvar DHRFGVBA ((oo)||!(oo))");
"#qrsvar DHRFGVBA ((oo)||!(oo))", "Pbzchgref ner hfryrff. Gurl pna bayl tvir lbh nafjref",
"Gur Vagrearg? Vf gung guvat fgvyy nebhaq?",
"Va beqre gb haqrefgnaq erphefvba, bar zhfg svefg haqrefgnaq erphefvba");
private QuoteUtils() {
}

View File

@ -37,69 +37,51 @@ package net.sourceforge.plantuml.graphic;
import java.awt.geom.Dimension2D;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.EmbeddedDiagram;
import net.sourceforge.plantuml.Guillemet;
import net.sourceforge.plantuml.SpriteContainer;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public class TextBlockSimple extends AbstractTextBlock implements TextBlock {
public final class TextBlockSimple extends AbstractTextBlock implements TextBlock {
private List<Line> lines2;
private List<Line> lines;
private final Display texts;
private final FontConfiguration fontConfiguration;
private final UFont fontForStereotype;
private final HorizontalAlignment horizontalAlignment;
private final SpriteContainer spriteContainer;
private final double maxMessageSize;
private final HtmlColor htmlColorForStereotype;
protected TextBlockSimple(Display texts, FontConfiguration fontConfiguration,
HorizontalAlignment horizontalAlignment, SpriteContainer spriteContainer, double maxMessageSize) {
this(texts, fontConfiguration, horizontalAlignment, spriteContainer, maxMessageSize, null, null);
}
public TextBlockSimple(Display texts, FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment,
SpriteContainer spriteContainer, double maxMessageSize, UFont fontForStereotype,
HtmlColor htmlColorForStereotype) {
SpriteContainer spriteContainer, double maxMessageSize) {
this.texts = texts;
this.fontConfiguration = fontConfiguration;
this.horizontalAlignment = horizontalAlignment;
this.spriteContainer = spriteContainer;
this.maxMessageSize = maxMessageSize;
this.fontForStereotype = fontForStereotype;
this.htmlColorForStereotype = htmlColorForStereotype;
}
private List<Line> getLines(StringBounder stringBounder) {
if (lines2 == null) {
if (lines == null) {
if (stringBounder == null) {
throw new IllegalStateException();
}
this.lines2 = new ArrayList<Line>();
this.lines = new ArrayList<Line>();
for (CharSequence s : texts) {
if (s instanceof Stereotype) {
lines2.addAll(createLinesForStereotype(
fontConfiguration.forceFont(fontForStereotype, htmlColorForStereotype), (Stereotype) s,
horizontalAlignment, spriteContainer));
} else if (s instanceof EmbeddedDiagram) {
lines2.add(((EmbeddedDiagram) s).asDraw(null));
if (s instanceof EmbeddedDiagram) {
lines.add(((EmbeddedDiagram) s).asDraw(null));
} else {
addInLines(stringBounder, s.toString());
}
}
}
return lines2;
return lines;
}
private void addInLines(StringBounder stringBounder, String s) {
@ -145,11 +127,11 @@ public class TextBlockSimple extends AbstractTextBlock implements TextBlock {
if (s.length() == 0 || MyPattern.mtches(s, "^[%s]*$ ")) {
return;
}
lines2.add(SingleLine.withSomeHtmlTag(s, fontConfiguration, horizontalAlignment, spriteContainer));
lines.add(SingleLine.withSomeHtmlTag(s, fontConfiguration, horizontalAlignment, spriteContainer));
}
private void addSingleLine(String s) {
lines2.add(SingleLine.withSomeHtmlTag(s, fontConfiguration, horizontalAlignment, spriteContainer));
lines.add(SingleLine.withSomeHtmlTag(s, fontConfiguration, horizontalAlignment, spriteContainer));
}
private double getTextWidth(StringBounder stringBounder, String s) {
@ -157,16 +139,6 @@ public class TextBlockSimple extends AbstractTextBlock implements TextBlock {
return line.calculateDimension(stringBounder).getWidth();
}
private List<SingleLine> createLinesForStereotype(FontConfiguration fontConfiguration, Stereotype s,
HorizontalAlignment horizontalAlignment, SpriteContainer spriteContainer) {
assert s.getLabel(Guillemet.DOUBLE_COMPARATOR) != null;
final List<SingleLine> result = new ArrayList<SingleLine>();
for (String st : s.getLabels(spriteContainer.guillemet())) {
result.add(SingleLine.withSomeHtmlTag(st, fontConfiguration, horizontalAlignment, spriteContainer));
}
return Collections.unmodifiableList(result);
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
return getTextDimension(stringBounder);
}

View File

@ -38,27 +38,24 @@ package net.sourceforge.plantuml.graphic;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.SpriteContainer;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public class TextBlockSprited extends TextBlockSimple {
public class TextBlockSprited extends AbstractTextBlock {
private final TextBlock parent;
private final TextBlock sprite;
public TextBlockSprited(TextBlock sprite, Display texts, FontConfiguration fontConfiguration,
HorizontalAlignment horizontalAlignment, SpriteContainer spriteContainer) {
super(texts, fontConfiguration, horizontalAlignment, spriteContainer, 0);
public TextBlockSprited(TextBlock sprite, TextBlock parent) {
this.sprite = sprite;
this.parent = parent;
}
@Override
public Dimension2D calculateDimension(StringBounder stringBounder) {
final double widthCircledCharacter = getCircledCharacterWithAndMargin(stringBounder);
final double heightCircledCharacter = sprite.calculateDimension(stringBounder).getHeight();
final Dimension2D dim = super.calculateDimension(stringBounder);
final Dimension2D dim = parent.calculateDimension(stringBounder);
return new Dimension2DDouble(dim.getWidth() + widthCircledCharacter, Math.max(heightCircledCharacter,
dim.getHeight()));
}
@ -67,7 +64,6 @@ public class TextBlockSprited extends TextBlockSimple {
return sprite.calculateDimension(stringBounder).getWidth() + 6.0;
}
@Override
public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
@ -75,7 +71,7 @@ public class TextBlockSprited extends TextBlockSimple {
final double widthCircledCharacter = getCircledCharacterWithAndMargin(stringBounder);
super.drawU(ug.apply(new UTranslate(widthCircledCharacter, 0)));
parent.drawU(ug.apply(new UTranslate(widthCircledCharacter, 0)));
}
}

View File

@ -65,6 +65,8 @@ public abstract class USymbol {
public final static USymbol FILE = record("FILE", SkinParameter.FILE, new USymbolFile());
public final static USymbol RECTANGLE = record("RECTANGLE", SkinParameter.RECTANGLE, new USymbolRect(
SkinParameter.RECTANGLE));
public final static USymbol LABEL = record("LABEL", SkinParameter.RECTANGLE, new USymbolLabel(
SkinParameter.RECTANGLE));
public final static USymbol ARCHIMATE = record("ARCHIMATE", SkinParameter.ARCHIMATE, new USymbolRect(
SkinParameter.ARCHIMATE));
public final static USymbol COLLECTIONS = record("COLLECTIONS", SkinParameter.COLLECTIONS, new USymbolCollections(
@ -210,6 +212,8 @@ public abstract class USymbol {
usymbol = USymbol.PACKAGE;
} else if (symbol.equalsIgnoreCase("rectangle")) {
usymbol = USymbol.RECTANGLE;
} else if (symbol.equalsIgnoreCase("label")) {
usymbol = USymbol.LABEL;
} else if (symbol.equalsIgnoreCase("collections")) {
usymbol = USymbol.COLLECTIONS;
} else if (symbol.equalsIgnoreCase("node")) {

View File

@ -0,0 +1,129 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.graphic;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.ugraphic.Shadowable;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UGraphicStencil;
import net.sourceforge.plantuml.ugraphic.UPath;
import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate;
class USymbolLabel extends USymbol {
private final SkinParameter skinParameter;
public USymbolLabel(SkinParameter skinParameter) {
this.skinParameter = skinParameter;
}
@Override
public SkinParameter getSkinParameter() {
return skinParameter;
}
private Margin getMargin() {
return new Margin(10, 10, 10, 10);
}
@Override
public TextBlock asSmall(TextBlock name, final TextBlock label, final TextBlock stereotype,
final SymbolContext symbolContext, final HorizontalAlignment stereoAlignment) {
return new AbstractTextBlock() {
public void drawU(UGraphic ug) {
final Dimension2D dim = calculateDimension(ug.getStringBounder());
ug = UGraphicStencil.create(ug, getRectangleStencil(dim), new UStroke());
ug = symbolContext.apply(ug);
final Margin margin = getMargin();
final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, stereoAlignment);
tb.drawU(ug.apply(new UTranslate(margin.getX1(), margin.getY1())));
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
final Dimension2D dimLabel = label.calculateDimension(stringBounder);
final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
return getMargin().addDimension(Dimension2DDouble.mergeTB(dimStereo, dimLabel));
}
};
}
@Override
public TextBlock asBig(final TextBlock title, final HorizontalAlignment labelAlignment, final TextBlock stereotype,
final double width, final double height, final SymbolContext symbolContext,
final HorizontalAlignment stereoAlignment) {
return new AbstractTextBlock() {
public void drawU(UGraphic ug) {
ug = symbolContext.apply(ug);
final Dimension2D dimStereo = stereotype.calculateDimension(ug.getStringBounder());
final double posStereoX;
final double posStereoY;
if (stereoAlignment == HorizontalAlignment.RIGHT) {
posStereoX = width - dimStereo.getWidth() - getMargin().getX1() / 2;
posStereoY = getMargin().getY1() / 2;
} else {
posStereoX = (width - dimStereo.getWidth()) / 2;
posStereoY = 2;
}
stereotype.drawU(ug.apply(new UTranslate(posStereoX, posStereoY)));
final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
final double posTitle;
if (labelAlignment == HorizontalAlignment.LEFT) {
posTitle = 3;
} else if (labelAlignment == HorizontalAlignment.RIGHT) {
posTitle = width - dimTitle.getWidth() - 3;
} else {
posTitle = (width - dimTitle.getWidth()) / 2;
}
title.drawU(ug.apply(new UTranslate(posTitle, 2 + dimStereo.getHeight())));
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
return new Dimension2DDouble(width, height);
}
};
}
@Override
public boolean manageHorizontalLine() {
return true;
}
}

View File

@ -49,18 +49,11 @@ import net.sourceforge.plantuml.ugraphic.UTranslate;
class USymbolRect extends USymbol {
private final SkinParameter skinParameter;
// private final HorizontalAlignment stereotypeAlignement;
public USymbolRect(SkinParameter skinParameter) {
this.skinParameter = skinParameter;
// this.stereotypeAlignement = stereotypeAlignement;
}
// @Override
// public USymbol withStereoAlignment(HorizontalAlignment alignment) {
// return new USymbolRect(skinParameter, alignment);
// }
@Override
public SkinParameter getSkinParameter() {
return skinParameter;

View File

@ -39,6 +39,8 @@ import java.util.ArrayList;
import java.util.List;
import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.cucadiagram.Code;
@ -47,6 +49,7 @@ import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
import net.sourceforge.plantuml.cucadiagram.GroupRoot;
import net.sourceforge.plantuml.cucadiagram.IEntity;
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.LinkDecor;
@ -60,6 +63,16 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
super(orig);
}
@Override
public Ident cleanIdent(Ident ident) {
String codeString = ident.getName();
if (codeString.startsWith("\"") && codeString.endsWith("\"")) {
return ident.eventuallyRemoveStartingAndEndingDoubleQuote("\"");
}
return ident;
}
final public boolean insertBetween(IEntity entity1, IEntity entity2, IEntity node) {
final Link link = foundLink(entity1, entity2);
if (link == null) {
@ -107,24 +120,29 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
public CommandExecutionResult associationClass(String name1A, String name1B, String name2A, String name2B,
LinkType linkType, Display label) {
final IEntity entity1A = getOrCreateLeaf(buildLeafIdent(name1A), buildCode(name1A),
null, null);
final IEntity entity1B = getOrCreateLeaf(buildLeafIdent(name1B), buildCode(name1B),
null, null);
final IEntity entity2A = getOrCreateLeaf(buildLeafIdent(name2A), buildCode(name2A),
null, null);
final IEntity entity2B = getOrCreateLeaf(buildLeafIdent(name2B), buildCode(name2B),
null, null);
final Ident ident1A = buildLeafIdent(name1A);
final Ident ident1B = buildLeafIdent(name1B);
final Ident ident2A = buildLeafIdent(name2A);
final Ident ident2B = buildLeafIdent(name2B);
final Code code1A = this.V1972() ? ident1A : buildCode(name1A);
final Code code1B = this.V1972() ? ident1B : buildCode(name1B);
final Code code2A = this.V1972() ? ident2A : buildCode(name2A);
final Code code2B = this.V1972() ? ident2B : buildCode(name2B);
final IEntity entity1A = getOrCreateLeaf(ident1A, code1A, null, null);
final IEntity entity1B = getOrCreateLeaf(ident1B, code1B, null, null);
final IEntity entity2A = getOrCreateLeaf(ident2A, code2A, null, null);
final IEntity entity2B = getOrCreateLeaf(ident2B, code2B, null, null);
final List<Association> same1 = getExistingAssociatedPoints(entity1A, entity1B);
final List<Association> same2 = getExistingAssociatedPoints(entity2A, entity2B);
if (same1.size() == 0 && same2.size() == 0) {
final String tmp1 = UniqueSequence.getString("apoint");
final IEntity point1 = getOrCreateLeaf(buildLeafIdent(tmp1), buildCode(tmp1),
LeafType.POINT_FOR_ASSOCIATION, null);
final String tmp2 = UniqueSequence.getString("apoint");
final IEntity point2 = getOrCreateLeaf(buildLeafIdent(tmp2), buildCode(tmp2),
LeafType.POINT_FOR_ASSOCIATION, null);
final Ident ident1 = buildLeafIdent(tmp1);
final Ident ident2 = buildLeafIdent(tmp2);
final Code code1 = this.V1972() ? ident1 : buildCode(tmp1);
final Code code2 = this.V1972() ? ident2 : buildCode(tmp2);
final IEntity point1 = getOrCreateLeaf(ident1, code1, LeafType.POINT_FOR_ASSOCIATION, null);
final IEntity point2 = getOrCreateLeaf(ident2, code2, LeafType.POINT_FOR_ASSOCIATION, null);
insertPointBetween(entity1A, entity1B, point1);
insertPointBetween(entity2A, entity2B, point2);
@ -176,10 +194,12 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
public boolean associationClass(int mode, String name1, String name2, IEntity associed, LinkType linkType,
Display label) {
final IEntity entity1 = getOrCreateLeaf(buildLeafIdent(name1), buildCode(name1), null,
null);
final IEntity entity2 = getOrCreateLeaf(buildLeafIdent(name2), buildCode(name2), null,
null);
final Ident ident1 = buildLeafIdent(name1);
final Ident ident2 = buildLeafIdent(name2);
final Code code1 = this.V1972() ? ident1 : buildCode(name1);
final Code code2 = this.V1972() ? ident2 : buildCode(name2);
final IEntity entity1 = getOrCreateLeaf(ident1, code1, null, null);
final IEntity entity2 = getOrCreateLeaf(ident2, code2, null, null);
final List<Association> same = getExistingAssociatedPoints(entity1, entity2);
if (same.size() > 1) {
return false;
@ -227,8 +247,9 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
this.entity2 = entity2;
this.associed = associed;
final String idShort = UniqueSequence.getString("apoint");
point = getOrCreateLeaf(buildLeafIdent(idShort), buildCode(idShort),
LeafType.POINT_FOR_ASSOCIATION, null);
final Ident ident = buildLeafIdent(idShort);
final Code code = AbstractClassOrObjectDiagram.this.V1972() ? ident : buildCode(idShort);
point = getOrCreateLeaf(ident, code, LeafType.POINT_FOR_ASSOCIATION, null);
}

View File

@ -37,6 +37,7 @@ package net.sourceforge.plantuml.objectdiagram.command;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
@ -79,15 +80,15 @@ public class CommandCreateEntityObject extends SingleLineCommand2<AbstractClassO
protected CommandExecutionResult executeArg(AbstractClassOrObjectDiagram diagram, LineLocation location,
RegexResult arg) {
final String idShort = arg.get("NAME", 1);
final Code code = diagram.buildCode(idShort);
final Ident ident = diagram.buildLeafIdent(idShort);
final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort);
final String display = arg.get("NAME", 0);
final String stereotype = arg.get("STEREO", 0);
if (diagram.leafExist(code)) {
final boolean leafExist = diagram.V1972() ? diagram.leafExistSmart(ident) : diagram.leafExist(code);
if (leafExist) {
return CommandExecutionResult.error("Object already exists : " + code);
}
final Ident idNewLong = diagram.buildLeafIdent(idShort);
final IEntity entity = diagram.createLeaf(idNewLong, code, Display.getWithNewlines(display),
LeafType.OBJECT, null);
final IEntity entity = diagram.createLeaf(ident, code, Display.getWithNewlines(display), LeafType.OBJECT, null);
if (stereotype != null) {
entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram
.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER), diagram.getSkinParam()
@ -103,5 +104,4 @@ public class CommandCreateEntityObject extends SingleLineCommand2<AbstractClassO
diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)));
return CommandExecutionResult.ok();
}
}

View File

@ -36,6 +36,7 @@
package net.sourceforge.plantuml.objectdiagram.command;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.StringLocated;
import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.command.BlocLines;
@ -105,14 +106,15 @@ public class CommandCreateEntityObjectMultilines extends CommandMultilines2<Abst
private IEntity executeArg0(AbstractClassOrObjectDiagram diagram, RegexResult line0) {
final String name = line0.get("NAME", 1);
final Code code = diagram.buildCode(name);
final Ident ident = diagram.buildLeafIdent(name);
final Code code = diagram.V1972() ? ident : diagram.buildCode(name);
final String display = line0.get("NAME", 0);
final String stereotype = line0.get("STEREO", 0);
if (diagram.leafExist(code)) {
final boolean leafExist = diagram.V1972() ? diagram.leafExistSmart(ident) : diagram.leafExist(code);
if (leafExist) {
return diagram.getOrCreateLeaf(diagram.buildLeafIdent(name), code, LeafType.OBJECT, null);
}
final Ident idNewLong = diagram.buildLeafIdent(name);
final IEntity entity = diagram.createLeaf(idNewLong, code, Display.getWithNewlines(display), LeafType.OBJECT, null);
final IEntity entity = diagram.createLeaf(ident, code, Display.getWithNewlines(display), LeafType.OBJECT, null);
if (stereotype != null) {
entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram
.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER), diagram.getSkinParam()

View File

@ -42,6 +42,8 @@ import java.util.regex.Pattern;
import net.sourceforge.plantuml.AParentFolder;
import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.tim.TVariable;
import net.sourceforge.plantuml.tim.expression.TValue;
public class Define {
@ -122,4 +124,7 @@ public class Define {
return signature.getFonctionName();
}
public TVariable asTVariable() {
return new TVariable(TValue.fromString(definition));
}
}

View File

@ -45,6 +45,7 @@ import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -52,13 +53,15 @@ import java.util.regex.Pattern;
import net.sourceforge.plantuml.AParentFolder;
import net.sourceforge.plantuml.Log;
import net.sourceforge.plantuml.api.ApiWarning;
import net.sourceforge.plantuml.tim.EaterException;
import net.sourceforge.plantuml.tim.TMemory;
import net.sourceforge.plantuml.tim.TVariableScope;
import net.sourceforge.plantuml.version.Version;
public class Defines implements Truth {
private final Map<String, String> environment = new LinkedHashMap<String, String>();
private final Map<String, Define> values = new LinkedHashMap<String, Define>();
private final Map<String, Define> savedState = new LinkedHashMap<String, Define>();
@Deprecated
@ApiWarning(willBeRemoved = "in next major release")
@ -75,6 +78,15 @@ public class Defines implements Truth {
return new Defines();
}
public void copyTo(TMemory memory) throws EaterException {
for (Entry<String, Define> ent : values.entrySet()) {
final String name = ent.getKey();
final Define def = ent.getValue();
memory.putVariable(name, def.asTVariable(), TVariableScope.GLOBAL);
}
}
public void overrideFilename(String filename) {
if (filename != null) {
environment.put("filename", filename);
@ -244,15 +256,4 @@ public class Defines implements Truth {
return line;
}
public void saveState1() {
this.savedState.putAll(values);
}
public void restoreState1() {
this.values.clear();
this.values.putAll(savedState);
magic = null;
}
}

View File

@ -1,58 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.preproc;
public class DefinesGet {
private final Defines defines;
public DefinesGet(Defines defines) {
this.defines = defines;
}
public final Defines get() {
return defines;
}
public void saveState() {
this.defines.saveState1();
}
public void restoreState() {
this.defines.restoreState1();
}
}

View File

@ -60,9 +60,16 @@ public class FileWithSuffix {
@Override
public String toString() {
if (file == null) {
return super.toString();
}
return file.toString();
}
public Reader getReader(String charset) throws IOException {
if (file == null) {
return null;
}
if (entry == null) {
if (charset == null) {
Log.info("Using default charset");
@ -108,45 +115,33 @@ public class FileWithSuffix {
this.file = new AFileRegular(file);
this.suffix = suffix;
this.entry = null;
// this.description = file.getAbsolutePath();
this.description = getFileName(file);
}
public static String getFileName(File file) {
return file.getName();
}
public static String getAbsolutePath(File file) {
return file.getAbsolutePath();
}
public FileWithSuffix(ImportedFiles importedFiles, String fileName, String suffix) throws IOException {
final int idx = fileName.indexOf('~');
FileWithSuffix(String description, String suffix, AFile file, String entry) {
this.description = description;
this.suffix = suffix;
if (idx == -1) {
this.file = importedFiles.getAFile(fileName);
this.entry = null;
} else {
this.file = importedFiles.getAFile(fileName.substring(0, idx));
this.entry = fileName.substring(idx + 1);
}
if (file == null) {
this.description = fileName;
} else if (entry == null) {
// this.description = file.getAbsolutePath();
this.description = fileName;
} else {
// this.description = file.getAbsolutePath() + "~" + entry;
this.description = fileName;
}
this.file = file;
this.entry = entry;
}
static FileWithSuffix none() {
return new FileWithSuffix("NONE", null, null, null);
}
@Override
public int hashCode() {
return (file == null ? 0 : file.hashCode()) + (suffix == null ? 0 : suffix.hashCode() * 43)
+ (entry == null ? 0 : entry.hashCode());
int v = 0;
if (file != null) {
v += file.hashCode();
}
if (suffix != null) {
v += suffix.hashCode() * 43;
}
if (entry != null) {
v += entry.hashCode();
}
return v;
}
@Override
@ -165,6 +160,23 @@ public class FileWithSuffix {
return false;
}
public AParentFolder getParentFile() {
if (file == null) {
return null;
}
Log.info("Getting parent of " + file);
Log.info("-->The parent is " + file.getParentFile());
return file.getParentFile();
}
public String getDescription() {
return description;
}
public final String getSuffix() {
return suffix;
}
private static boolean equals(String s1, String s2) {
if (s1 == null && s2 == null) {
return true;
@ -184,22 +196,8 @@ public class FileWithSuffix {
return result;
}
public AParentFolder getParentFile() {
Log.info("Getting parent of " + file);
Log.info("-->The parent is " + file.getParentFile());
return file.getParentFile();
}
public String getDescription() {
return description;
}
public final String getSuffix() {
return suffix;
}
public String toStringDebug() {
return file.getAbsolutePath();
public static String getFileName(File file) {
return file.getName();
}
}

View File

@ -1,126 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.preproc;
import java.io.IOException;
import net.sourceforge.plantuml.StringLocated;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.version.Version;
public class IfManager extends ReadLineInstrumented implements ReadLine {
protected static final Pattern2 ifdefPattern = MyPattern.cmpile("^[%s]*!if(n)?def[%s]+(.+)$");
protected static final Pattern2 ifcomparePattern = MyPattern
.cmpile("^[%s]*!if[%s]+\\%(\\w+)\\%[%s]*(\\<|\\<=|\\>|\\>=|=|==|!=|\\<\\>)[%s]*(\\d+)$");
protected static final Pattern2 elsePattern = MyPattern.cmpile("^[%s]*!else[%s]*$");
protected static final Pattern2 endifPattern = MyPattern.cmpile("^[%s]*!endif[%s]*$");
private final DefinesGet defines;
private final ReadLine source;
private IfManager child;
public IfManager(ReadLine source, DefinesGet defines) {
this.defines = defines;
this.source = source;
}
@Override
final StringLocated readLineInst() throws IOException {
if (child != null) {
final StringLocated s = child.readLine();
if (s != null) {
return s;
}
child = null;
}
return readLineInternal();
}
protected StringLocated readLineInternal() throws IOException {
final StringLocated s = source.readLine();
if (s == null) {
return null;
}
Matcher2 m = ifcomparePattern.matcher(s.getString());
if (m.find()) {
final int value1 = getValue(m.group(1));
final String operator = m.group(2);
final int value2 = Integer.parseInt(m.group(3));
final boolean ok = new NumericCompare(operator).isCompareOk(value1, value2);
if (ok) {
child = new IfManagerPositif(source, defines);
} else {
child = new IfManagerNegatif(source, defines);
}
return this.readLine();
}
m = ifdefPattern.matcher(s.getString());
if (m.find()) {
boolean ok = defines.get().isDefine(m.group(2));
if (m.group(1) != null) {
ok = !ok;
}
if (ok) {
child = new IfManagerPositif(source, defines);
} else {
child = new IfManagerNegatif(source, defines);
}
return this.readLine();
}
return s;
}
private int getValue(final String arg) {
if (arg.equalsIgnoreCase("PLANTUML_VERSION")) {
return Version.versionPatched();
}
return 0;
}
@Override
void closeInst() throws IOException {
source.close();
}
}

View File

@ -1,83 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.preproc;
import java.io.IOException;
import net.sourceforge.plantuml.StringLocated;
import net.sourceforge.plantuml.command.regex.Matcher2;
class IfManagerNegatif extends IfManager {
private boolean skippingDone = false;
public IfManagerNegatif(ReadLine source, DefinesGet defines) {
super(source, defines);
}
@Override
protected StringLocated readLineInternal() throws IOException {
if (skippingDone == false) {
skippingDone = true;
do {
final StringLocated s = readLine();
if (s == null) {
return null;
}
Matcher2 m = endifPattern.matcher(s.getString());
if (m.find()) {
return null;
}
m = elsePattern.matcher(s.getString());
if (m.find()) {
break;
}
} while (true);
}
final StringLocated s = super.readLineInternal();
if (s == null) {
return null;
}
final Matcher2 m = endifPattern.matcher(s.getString());
if (m.find()) {
return null;
}
return s;
}
}

View File

@ -1,75 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.preproc;
import java.io.IOException;
import net.sourceforge.plantuml.StringLocated;
import net.sourceforge.plantuml.command.regex.Matcher2;
class IfManagerPositif extends IfManager {
public IfManagerPositif(ReadLine source, DefinesGet defines) {
super(source, defines);
}
@Override
protected StringLocated readLineInternal() throws IOException {
StringLocated s = super.readLineInternal();
if (s == null) {
return null;
}
Matcher2 m = endifPattern.matcher(s.getString());
if (m.find()) {
return null;
}
m = elsePattern.matcher(s.getString());
if (m.find()) {
do {
s = readLine();
if (s == null) {
return null;
}
m = endifPattern.matcher(s.getString());
if (m.find()) {
return null;
}
} while (true);
}
return s;
}
}

View File

@ -47,9 +47,11 @@ import net.sourceforge.plantuml.AFileZipEntry;
import net.sourceforge.plantuml.AParentFolder;
import net.sourceforge.plantuml.FileSystem;
import net.sourceforge.plantuml.Log;
import net.sourceforge.plantuml.OptionFlags;
public class ImportedFiles {
private static final List<File> INCLUDE_PATH = FileSystem.getPath("plantuml.include.path", true);
private final List<File> imported;
private final AParentFolder currentDir;
@ -75,8 +77,8 @@ public class ImportedFiles {
}
public AFile getAFile(String nameOrPath) throws IOException {
Log.info("ImportedFiles::getAFile nameOrPath = " + nameOrPath);
Log.info("ImportedFiles::getAFile currentDir = " + currentDir);
// Log.info("ImportedFiles::getAFile nameOrPath = " + nameOrPath);
// Log.info("ImportedFiles::getAFile currentDir = " + currentDir);
final AParentFolder dir = currentDir;
if (dir == null || isAbsolute(nameOrPath)) {
return new AFileRegular(new File(nameOrPath).getCanonicalFile());
@ -105,7 +107,7 @@ public class ImportedFiles {
public List<File> getPath() {
final List<File> result = new ArrayList<File>(imported);
result.addAll(FileSystem.getPath("plantuml.include.path", true));
result.addAll(INCLUDE_PATH);
result.addAll(FileSystem.getPath("java.class.path", true));
return result;
}
@ -123,4 +125,35 @@ public class ImportedFiles {
return currentDir;
}
public FileWithSuffix getFile(String filename, String suffix) throws IOException {
final int idx = filename.indexOf('~');
final AFile file;
final String entry;
if (idx == -1) {
file = getAFile(filename);
entry = null;
} else {
file = getAFile(filename.substring(0, idx));
entry = filename.substring(idx + 1);
}
if (isAllowed(file) == false) {
return FileWithSuffix.none();
}
return new FileWithSuffix(filename, suffix, file, entry);
}
private boolean isAllowed(AFile file) throws IOException {
if (OptionFlags.ALLOW_INCLUDE) {
return true;
}
if (file != null) {
final File folder = file.getSystemFolder();
// System.err.println("canonicalPath=" + path + " " + folder + " " + INCLUDE_PATH);
if (INCLUDE_PATH.contains(folder)) {
return true;
}
}
return false;
}
}

View File

@ -1,67 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.preproc;
import java.io.IOException;
import net.sourceforge.plantuml.StringLocated;
import net.sourceforge.plantuml.preproc2.PreprocessorMode;
import net.sourceforge.plantuml.preproc2.PreprocessorModeSet;
public class PreprocessorChangeModeReader implements ReadLine {
private final ReadLine raw;
private final PreprocessorModeSet mode;
public PreprocessorChangeModeReader(ReadLine source, PreprocessorModeSet mode) {
this.raw = source;
this.mode = mode;
}
public void close() throws IOException {
raw.close();
}
public StringLocated readLine() throws IOException {
final StringLocated line = raw.readLine();
if (line != null && line.getTrimmed().getString().endsWith("!preprocessorV2")) {
this.mode.setPreprocessorMode(PreprocessorMode.V2_NEW_TIM);
return new StringLocated("", line.getLocation());
}
return line;
}
}

View File

@ -1,49 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.preproc;
import net.sourceforge.plantuml.StringLocated;
public class ReadLineEmpty implements ReadLine {
public void close() {
}
public StringLocated readLine() {
return null;
}
}

View File

@ -1,98 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.preproc;
import java.io.IOException;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicLong;
import net.sourceforge.plantuml.Log;
import net.sourceforge.plantuml.StringLocated;
public abstract class ReadLineInstrumented implements ReadLine {
private static final boolean TRACE = false;
private static ConcurrentMap<Class, AtomicLong> durations = new ConcurrentHashMap<Class, AtomicLong>();
private static ConcurrentMap<Class, AtomicLong> maxes = new ConcurrentHashMap<Class, AtomicLong>();
private long current = 0;
private AtomicLong get(ConcurrentMap<Class, AtomicLong> source) {
AtomicLong result = source.get(getClass());
if (result == null) {
result = new AtomicLong();
source.put(getClass(), result);
}
return result;
}
public final StringLocated readLine() throws IOException {
if (TRACE == false) {
return readLineInst();
}
final long now = System.currentTimeMillis();
try {
return readLineInst();
} finally {
final long time = System.currentTimeMillis() - now;
current += time;
get(durations).addAndGet(time);
}
}
@Override
public String toString() {
return super.toString() + " current=" + current;
}
abstract StringLocated readLineInst() throws IOException;
public final void close() throws IOException {
if (TRACE) {
if (current > get(maxes).get()) {
get(maxes).set(current);
}
Log.info("DURATION::" + getClass() + " duration= " + get(durations).get() + " current=" + current + " max="
+ get(maxes).get());
}
closeInst();
}
abstract void closeInst() throws IOException;
}

View File

@ -44,9 +44,8 @@ import net.sourceforge.plantuml.LineLocationImpl;
import net.sourceforge.plantuml.Log;
import net.sourceforge.plantuml.StringLocated;
public class ReadLineReader extends ReadLineInstrumented implements ReadLine {
public class ReadLineReader implements ReadLine {
// private static final int LIMIT = 850;
private final BufferedReader br;
private LineLocationImpl location;
private final String description;
@ -78,8 +77,7 @@ public class ReadLineReader extends ReadLineInstrumented implements ReadLine {
return new ReadLineReader(reader, description, parent);
}
@Override
StringLocated readLineInst() throws IOException {
public StringLocated readLine() throws IOException {
String s = br.readLine();
location = location.oneLineRead();
if (s == null) {
@ -108,8 +106,7 @@ public class ReadLineReader extends ReadLineInstrumented implements ReadLine {
return new StringLocated(s, location);
}
@Override
void closeInst() throws IOException {
public void close() throws IOException {
br.close();
}

View File

@ -35,27 +35,64 @@
*/
package net.sourceforge.plantuml.preproc;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.StringLocated;
import net.sourceforge.plantuml.tim.EaterException;
import net.sourceforge.plantuml.tim.EaterStartsub;
import net.sourceforge.plantuml.tim.TContext;
import net.sourceforge.plantuml.tim.TLineType;
import net.sourceforge.plantuml.tim.TMemory;
public class Sub {
private final String name;
private final List<String> lines = new ArrayList<String>();
private final List<StringLocated> lines = new ArrayList<StringLocated>();
public Sub(String name) {
this.name = name;
}
public void add(StringLocated s) {
this.lines.add(s.getString());
@Override
public String toString() {
return super.toString() + " " + name;
}
public ReadLine getReadLine(LineLocation lineLocation) {
return new ReadLineList(lines, lineLocation);
public void add(StringLocated s) {
this.lines.add(s);
}
public final List<StringLocated> lines() {
return Collections.unmodifiableList(lines);
}
public static Sub fromFile(ReadLine reader, String blocname, TContext context, TMemory memory) throws IOException,
EaterException {
Sub result = null;
StringLocated s = null;
while ((s = reader.readLine()) != null) {
final TLineType type = TLineType.getFromLine(s.getTrimmed().getString());
if (type == TLineType.STARTSUB) {
final EaterStartsub eater = new EaterStartsub(s.getTrimmed().getString());
eater.execute(context, memory);
if (eater.getSubname().equals(blocname)) {
result = new Sub(blocname);
}
continue;
}
if (type == TLineType.ENDSUB && result != null) {
reader.close();
return result;
}
if (result != null) {
result.add(s);
}
}
reader.close();
return null;
}
}

View File

@ -1,93 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.preproc;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.sourceforge.plantuml.StringLocated;
import net.sourceforge.plantuml.tim.EaterException;
import net.sourceforge.plantuml.tim.EaterStartsub;
import net.sourceforge.plantuml.tim.TContext;
import net.sourceforge.plantuml.tim.TLineType;
import net.sourceforge.plantuml.tim.TMemory;
public class Sub2 {
private final String name;
private final List<StringLocated> lines = new ArrayList<StringLocated>();
public Sub2(String name) {
this.name = name;
}
public void add(StringLocated s) {
this.lines.add(s);
}
public final List<StringLocated> lines() {
return Collections.unmodifiableList(lines);
}
public static Sub2 fromFile(ReadLine reader, String blocname, TContext context, TMemory memory) throws IOException,
EaterException {
Sub2 result = null;
StringLocated s = null;
while ((s = reader.readLine()) != null) {
final TLineType type = TLineType.getFromLine(s.getTrimmed().getString());
if (type == TLineType.STARTSUB) {
final EaterStartsub eater = new EaterStartsub(s.getTrimmed().getString());
eater.execute(context, memory);
if (eater.getSubname().equals(blocname)) {
result = new Sub2(blocname);
}
continue;
}
if (type == TLineType.ENDSUB && result != null) {
reader.close();
return result;
}
if (result != null) {
result.add(s);
}
}
reader.close();
return null;
}
}

View File

@ -43,7 +43,7 @@ import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.utils.StartUtils;
public class UncommentReadLine extends ReadLineInstrumented implements ReadLine {
public class UncommentReadLine implements ReadLine {
private static final Pattern2 unpause = MyPattern.cmpile(StartUtils.PAUSE_PATTERN);
@ -55,13 +55,7 @@ public class UncommentReadLine extends ReadLineInstrumented implements ReadLine
this.raw = source;
}
@Override
public String toString() {
return "UncommentReadLine of " + raw;
}
@Override
StringLocated readLineInst() throws IOException {
public StringLocated readLine() throws IOException {
final StringLocated result = raw.readLine();
if (result == null) {
@ -87,8 +81,7 @@ public class UncommentReadLine extends ReadLineInstrumented implements ReadLine
return result;
}
@Override
void closeInst() throws IOException {
public void close() throws IOException {
this.raw.close();
}

View File

@ -37,67 +37,27 @@ package net.sourceforge.plantuml.preproc2;
import java.io.IOException;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import net.sourceforge.plantuml.DefinitionsContainer;
import net.sourceforge.plantuml.StringLocated;
import net.sourceforge.plantuml.preproc.Defines;
import net.sourceforge.plantuml.preproc.DefinesGet;
import net.sourceforge.plantuml.preproc.FileWithSuffix;
import net.sourceforge.plantuml.preproc.IfManagerFilter;
import net.sourceforge.plantuml.preproc.ImportedFiles;
import net.sourceforge.plantuml.preproc.ReadLine;
import net.sourceforge.plantuml.preproc.ReadLineNumbered;
public class Preprocessor implements ReadLineNumbered {
private final ReadLine source;
private final PreprocessorInclude include;
private final PreprocessorModeSet mode;
private final ReadLine sourceV2;
public Preprocessor(List<String> config, ReadLine reader, String charset, Defines defines,
DefinitionsContainer definitionsContainer, ImportedFiles importedFiles) throws IOException {
this(config, reader, charset, new DefinesGet(defines), definitionsContainer, new HashSet<FileWithSuffix>(),
importedFiles, true);
}
Preprocessor(List<String> config, ReadLine reader, String charset, DefinesGet defines,
DefinitionsContainer definitionsContainer, Set<FileWithSuffix> filesUsedGlobal,
ImportedFiles importedFiles, boolean doSaveState) throws IOException {
this.mode = definitionsContainer;
if (doSaveState) {
defines.saveState();
}
final ReadFilterAnd filtersV2 = new ReadFilterAnd();
filtersV2.add(new ReadLineQuoteComment(true));
filtersV2.add(new ReadLineAddConfig(config));
this.sourceV2 = filtersV2.applyFilter(reader);
public Preprocessor(List<String> config, ReadLine reader) throws IOException {
final ReadFilterAnd filters = new ReadFilterAnd();
filters.add(new ReadLineQuoteComment(false));
include = new PreprocessorInclude(config, charset, defines, definitionsContainer, importedFiles,
filesUsedGlobal);
filters.add(new ReadLineAddConfig(config));
filters.add(new IfManagerFilter(defines));
filters.add(new PreprocessorDefineApply(defines));
filters.add(new SubPreprocessor(charset, definitionsContainer));
filters.add(new PreprocessorDefineLearner(defines, importedFiles.getCurrentDir()));
filters.add(include);
// filters.add(new ReadLineQuoteComment(true));
filters.add(new ReadFilterAddConfig(config));
filters.add(new ReadFilterMergeLines());
this.source = filters.applyFilter(reader);
}
private boolean isV2() {
return mode != null && mode.getPreprocessorMode() == PreprocessorMode.V2_NEW_TIM;
}
public StringLocated readLine() throws IOException {
if (isV2()) {
return sourceV2.readLine();
}
return source.readLine();
}
@ -107,7 +67,7 @@ public class Preprocessor implements ReadLineNumbered {
public Set<FileWithSuffix> getFilesUsed() {
// System.err.println("************************** WARNING **************************");
// return Collections.emptySet();
return Collections.unmodifiableSet(include.getFilesUsedGlobal());
return Collections.emptySet();
// return Collections.unmodifiableSet(include.getFilesUsedGlobal());
}
}

View File

@ -1,91 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.preproc2;
import java.io.IOException;
import java.util.List;
import net.sourceforge.plantuml.StringLocated;
import net.sourceforge.plantuml.preproc.DefinesGet;
import net.sourceforge.plantuml.preproc.ReadLine;
import net.sourceforge.plantuml.preproc.ReadLineList;
public class PreprocessorDefineApply implements ReadFilter {
private final DefinesGet defines;
public PreprocessorDefineApply(DefinesGet defines) throws IOException {
this.defines = defines;
}
public ReadLine applyFilter(final ReadLine source) {
return new Inner(source);
}
class Inner extends ReadLineInsertable {
final ReadLine source;
Inner(ReadLine source) {
this.source = source;
}
@Override
void closeInternal() throws IOException {
source.close();
}
@Override
StringLocated readLineInternal() throws IOException {
final StringLocated s = this.source.readLine();
if (s == null || s.getPreprocessorError() != null) {
return s;
}
if (PreprocessorDefineLearner.isLearningLine(s)) {
return s;
}
final List<String> result = defines.get().applyDefines(s.getString());
if (result.size() > 1) {
insert(new ReadLineList(result, s.getLocation()));
return readLine();
}
String tmp = result.get(0);
return new StringLocated(tmp, s.getLocation(), s.getPreprocessorError());
}
}
}

View File

@ -1,182 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.preproc2;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.plantuml.AParentFolder;
import net.sourceforge.plantuml.StringLocated;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.preproc.DefinesGet;
import net.sourceforge.plantuml.preproc.ReadLine;
import net.sourceforge.plantuml.utils.StartUtils;
public class PreprocessorDefineLearner implements ReadFilter {
private static final String END_DEFINE_LONG = "!enddefinelong";
private static final String ID = "[A-Za-z_][A-Za-z_0-9]*";
private static final String ID_ARG = "\\s*[A-Za-z_][A-Za-z_0-9]*\\s*(?:=\\s*(?:\"[^\"]*\"|'[^']*')\\s*)?";
private static final String ARG = "(?:\\(" + ID_ARG + "(?:," + ID_ARG + ")*?\\))?";
private static final Pattern2 defineShortPattern = MyPattern.cmpile("^[%s]*!define[%s]+(" + ID + ARG + ")"
+ "(?:[%s]+(.*))?$");
private static final Pattern2 filenamePattern = MyPattern.cmpile("^[%s]*!filename[%s]+(.+)$");
private static final Pattern2 undefPattern = MyPattern.cmpile("^[%s]*!undef[%s]+(" + ID + ")$");
private static final Pattern2 definelongPattern = MyPattern.cmpile("^[%s]*!definelong[%s]+(" + ID + ARG + ")");
private static final Pattern2 enddefinelongPattern = MyPattern.cmpile("^[%s]*" + END_DEFINE_LONG + "[%s]*$");
private final DefinesGet defines;
private final AParentFolder currentDir;
public PreprocessorDefineLearner(DefinesGet defines, AParentFolder currentDir) {
this.defines = defines;
this.currentDir = currentDir;
}
public static boolean isLearningLine(StringLocated s) {
Matcher2 m = defineShortPattern.matcher(s.getString());
if (m.find()) {
return true;
}
m = definelongPattern.matcher(s.getString());
if (m.find()) {
return true;
}
m = undefPattern.matcher(s.getString());
if (m.find()) {
return true;
}
return false;
}
public ReadLine applyFilter(final ReadLine source) {
return new ReadLine() {
public void close() throws IOException {
source.close();
}
public StringLocated readLine() throws IOException {
while (true) {
final StringLocated s = source.readLine();
if (s == null || s.getPreprocessorError() != null) {
return s;
}
if (StartUtils.isArobaseStartDiagram(s.getString())) {
defines.restoreState();
return s;
}
Matcher2 m = filenamePattern.matcher(s.getString());
if (m.find()) {
manageFilename(m);
continue;
}
m = defineShortPattern.matcher(s.getString());
if (m.find()) {
manageDefineShort(source, m, s.getString().trim().endsWith("()"));
continue;
}
m = definelongPattern.matcher(s.getString());
if (m.find()) {
manageDefineLong(source, m, s.getString().trim().endsWith("()"));
continue;
}
m = undefPattern.matcher(s.getString());
if (m.find()) {
manageUndef(m);
continue;
}
return s;
}
}
};
}
private void manageUndef(Matcher2 m) throws IOException {
defines.get().undefine(m.group(1));
}
private void manageDefineLong(ReadLine source, Matcher2 m, boolean emptyParentheses) throws IOException {
final String group1 = m.group(1);
final List<String> def = new ArrayList<String>();
while (true) {
final StringLocated read = source.readLine();
if (read == null) {
return;
}
if (enddefinelongPattern.matcher(read.getString()).find()) {
defines.get().define(group1, def, emptyParentheses, currentDir);
return;
}
def.add(read.getString());
}
}
private void manageFilename(Matcher2 m) {
final String group1 = m.group(1);
this.defines.get().overrideFilename(group1);
}
private void manageDefineShort(ReadLine source, Matcher2 m, boolean emptyParentheses) throws IOException {
final String group1 = m.group(1);
final String group2 = m.group(2);
if (group2 == null) {
defines.get().define(group1, null, emptyParentheses, null);
} else {
final List<String> strings = defines.get().applyDefines(group2);
if (strings.size() > 1) {
defines.get().define(group1, strings, emptyParentheses, null);
} else {
final StringBuilder value = new StringBuilder(strings.get(0));
while (StringUtils.endsWithBackslash(value.toString())) {
value.setLength(value.length() - 1);
final StringLocated read = source.readLine();
value.append(read.getString());
}
final List<String> li = new ArrayList<String>();
li.add(value.toString());
defines.get().define(group1, li, emptyParentheses, null);
}
}
}
}

View File

@ -1,382 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
* Modified by: Nicolas Jouanin
*
*
*/
package net.sourceforge.plantuml.preproc2;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.DefinitionsContainer;
import net.sourceforge.plantuml.FileSystem;
import net.sourceforge.plantuml.Log;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.StringLocated;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.preproc.DefinesGet;
import net.sourceforge.plantuml.preproc.FileWithSuffix;
import net.sourceforge.plantuml.preproc.ImportedFiles;
import net.sourceforge.plantuml.preproc.ReadLine;
import net.sourceforge.plantuml.preproc.ReadLineEmpty;
import net.sourceforge.plantuml.preproc.ReadLineList;
import net.sourceforge.plantuml.preproc.ReadLineReader;
import net.sourceforge.plantuml.preproc.ReadLineSimple;
import net.sourceforge.plantuml.preproc.ReadLineSingle;
import net.sourceforge.plantuml.preproc.StartDiagramExtractReader;
import net.sourceforge.plantuml.preproc.Stdlib;
import net.sourceforge.plantuml.tim.EaterException;
import net.sourceforge.plantuml.utils.StartUtils;
public class PreprocessorInclude implements ReadFilter {
private static final Pattern2 includeDefPattern = MyPattern.cmpile("^[%s]*!includedef[%s]+[%g]?([^%g]+)[%g]?$");
private static final Pattern2 includeDefaultStrategy = MyPattern.cmpile("^[%s]*!default_include[%s]+(once|many)$");
private static final Pattern2 includePattern = MyPattern.cmpile("^[%s]*!include[%s]+[%g]?([^%g]+)[%g]?$");
private static final Pattern2 includeManyPattern = MyPattern.cmpile("^[%s]*!include_many[%s]+[%g]?([^%g]+)[%g]?$");
private static final Pattern2 includeOncePattern = MyPattern.cmpile("^[%s]*!include_once[%s]+[%g]?([^%g]+)[%g]?$");
private static final Pattern2 importPattern = MyPattern.cmpile("^[%s]*!import[%s]+[%g]?([^%g]+)[%g]?$");
private static final Pattern2 includePatternStdlib = MyPattern.cmpile("^[%s]*!include[%s]+(\\<[^%g]+\\>)$");
private static final Pattern2 includeURLPattern = MyPattern.cmpile("^[%s]*!includeurl[%s]+[%g]?([^%g]+)[%g]?$");
private final String charset;
private final DefinesGet defines;
private final List<String> config;
private final DefinitionsContainer definitionsContainer;
private final ImportedFiles importedFiles;
private final Set<FileWithSuffix> filesUsedCurrent = new HashSet<FileWithSuffix>();
private final Set<FileWithSuffix> filesUsedGlobal;
private PreprocessorIncludeStrategy strategy = PreprocessorIncludeStrategy.ONCE;
public PreprocessorInclude(List<String> config, String charset, DefinesGet defines,
DefinitionsContainer definitionsContainer, ImportedFiles importedFiles, Set<FileWithSuffix> filesUsedGlobal) {
this.charset = charset;
this.config = config;
this.defines = defines;
this.definitionsContainer = definitionsContainer;
this.importedFiles = importedFiles;
this.filesUsedGlobal = filesUsedGlobal;
}
public ReadLine applyFilter(ReadLine source) {
return new Inner(source);
}
class Inner extends ReadLineInsertable {
final ReadLine source;
Inner(ReadLine source) {
this.source = source;
}
@Override
void closeInternal() throws IOException {
source.close();
}
@Override
StringLocated readLineInternal() throws IOException {
final StringLocated s = source.readLine();
if (s == null || s.getPreprocessorError() != null) {
return s;
}
if (s != null && StartUtils.startOrEnd(s)) {
// http://plantuml.sourceforge.net/qa/?qa=3389/error-generating-when-same-file-included-different-diagram
filesUsedCurrent.clear();
strategy = PreprocessorIncludeStrategy.ONCE;
return s;
}
if (s.getPreprocessorError() == null && OptionFlags.ALLOW_INCLUDE) {
final Matcher2 m0 = importPattern.matcher(s.getString());
if (m0.find()) {
final StringLocated err = manageFileImport(s, m0);
if (err != null) {
insert(new ReadLineSingle(err));
}
return readLine();
}
final Matcher2 m1 = includePattern.matcher(s.getString());
if (m1.find()) {
insert(manageFileInclude(s, m1, strategy));
return readLine();
}
final Matcher2 m2 = includeManyPattern.matcher(s.getString());
if (m2.find()) {
insert(manageFileInclude(s, m2, PreprocessorIncludeStrategy.MANY));
return readLine();
}
final Matcher2 m3 = includeOncePattern.matcher(s.getString());
if (m3.find()) {
insert(manageFileInclude(s, m3, PreprocessorIncludeStrategy.ONCE));
return readLine();
}
final Matcher2 m4 = includeDefPattern.matcher(s.getString());
if (m4.find()) {
insert(manageDefinitionInclude(s, m4));
return readLine();
}
} else {
final Matcher2 m1 = includePatternStdlib.matcher(s.getString());
if (m1.find()) {
insert(manageFileInclude(s, m1, PreprocessorIncludeStrategy.ONCE));
return readLine();
}
}
final Matcher2 mUrl = includeURLPattern.matcher(s.getString());
if (s.getPreprocessorError() == null && mUrl.find()) {
insert(manageUrlInclude(s, mUrl));
return readLine();
}
final Matcher2 m2 = includeDefaultStrategy.matcher(s.getString());
if (m2.find()) {
strategy = PreprocessorIncludeStrategy.fromString(m2.group(1));
return readLine();
}
return s;
}
}
private StringLocated manageFileImport(StringLocated s, Matcher2 m) throws IOException {
final String fileName = m.group(1);
final File file = FileSystem.getInstance().getFile(withEnvironmentVariable(fileName));
if (file.exists() && file.isDirectory() == false) {
importedFiles.add(file);
return null;
}
return s.withErrorPreprocessor("Cannot import " + FileWithSuffix.getFileName(file));
}
private ReadLine manageUrlInclude(StringLocated s, Matcher2 m) throws IOException {
String urlString = m.group(1);
urlString = defines.get().applyDefines(urlString).get(0);
final int idx = urlString.lastIndexOf('!');
String suf = null;
if (idx != -1) {
suf = urlString.substring(idx + 1);
urlString = urlString.substring(0, idx);
}
try {
if (urlString.toLowerCase().startsWith("https://") == false
&& urlString.toLowerCase().startsWith("http://") == false) {
return new ReadLineSingle(s.withErrorPreprocessor("Cannot include url " + urlString));
}
final URL url = new URL(urlString);
return new Preprocessor(config, getReaderIncludeUrl(url, s, suf, charset), charset, defines, definitionsContainer,
filesUsedGlobal, importedFiles, false);
} catch (MalformedURLException e) {
return new ReadLineSingle(s.withErrorPreprocessor("Cannot include url " + urlString));
}
}
private ReadLine manageDefinitionInclude(StringLocated s, Matcher2 matcher) throws IOException {
final String definitionName = matcher.group(1);
final List<String> definition = definitionsContainer.getDefinition1(definitionName);
return new Preprocessor(config, new ReadLineList(definition, s.getLocation()), charset, defines,
definitionsContainer, filesUsedGlobal, importedFiles, false);
}
private ReadLine manageFileInclude(StringLocated s, Matcher2 matcher, PreprocessorIncludeStrategy allowMany)
throws IOException {
String fileName = matcher.group(1);
fileName = defines.get().applyDefines(fileName).get(0);
if (fileName.startsWith("<") && fileName.endsWith(">")) {
final ReadLine strlibReader = getReaderStdlibInclude(s, fileName.substring(1, fileName.length() - 1));
if (strlibReader == null) {
return new ReadLineSingle(s.withErrorPreprocessor("Cannot include " + fileName));
}
return new Preprocessor(config, strlibReader, charset, defines, definitionsContainer, filesUsedGlobal,
importedFiles, false);
}
final int idx = fileName.lastIndexOf('!');
String suf = null;
if (idx != -1) {
suf = fileName.substring(idx + 1);
fileName = fileName.substring(0, idx);
}
final FileWithSuffix f2 = new FileWithSuffix(importedFiles, withEnvironmentVariable(fileName), suf);
if (f2.fileOk() == false) {
Log.error("Current path is " + FileWithSuffix.getAbsolutePath(new File(".")));
Log.error("Cannot include " + f2.getDescription());
return new ReadLineSingle(s.withErrorPreprocessor("Cannot include " + f2.getDescription()));
} else if (allowMany == PreprocessorIncludeStrategy.ONCE && filesUsedCurrent.contains(f2)) {
// return new ReadLineSimple(s, "File already included " + f2.getDescription());
return new ReadLineEmpty();
}
filesUsedCurrent.add(f2);
filesUsedGlobal.add(f2);
return new Preprocessor(config, getReaderInclude(f2, s), charset, defines, definitionsContainer,
filesUsedGlobal, importedFiles.withCurrentDir(f2.getParentFile()), false);
}
public static String withEnvironmentVariable(String s) {
final Pattern p = Pattern.compile("%(\\w+)%");
final Matcher m = p.matcher(s);
final StringBuffer sb = new StringBuffer();
while (m.find()) {
final String var = m.group(1);
final String value = getenv(var);
if (value != null) {
m.appendReplacement(sb, Matcher.quoteReplacement(value));
}
}
m.appendTail(sb);
s = sb.toString();
return s;
}
public static String getenv(String var) {
final String env = System.getProperty(var);
if (StringUtils.isNotEmpty(env)) {
return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(env);
}
final String getenv = System.getenv(var);
if (StringUtils.isNotEmpty(getenv)) {
return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(getenv);
}
return null;
}
private static InputStream getStdlibInputStream(String filename) {
final InputStream result = Stdlib.getResourceAsStream(filename);
// Log.info("Loading sdlib " + filename + " ok");
return result;
}
public static ReadLine getReaderStdlibInclude(StringLocated s, String filename) {
Log.info("Loading sdlib " + filename);
InputStream is = getStdlibInputStream(filename);
if (is == null) {
return null;
}
final String description = "<" + filename + ">";
try {
if (StartDiagramExtractReader.containsStartDiagram(is, s, description)) {
is = getStdlibInputStream(filename);
return StartDiagramExtractReader.build(is, s, description);
}
is = getStdlibInputStream(filename);
if (is == null) {
return null;
}
return ReadLineReader.create(new InputStreamReader(is), description);
} catch (IOException e) {
e.printStackTrace();
return new ReadLineSimple(s, e.toString());
}
}
private ReadLine getReaderInclude(FileWithSuffix f2, StringLocated s) {
try {
if (StartDiagramExtractReader.containsStartDiagram(f2, s, charset)) {
return StartDiagramExtractReader.build(f2, s, charset);
}
final Reader reader = f2.getReader(charset);
if (reader == null) {
return new ReadLineSimple(s, "Cannot open " + f2.getDescription());
}
return ReadLineReader.create(reader, f2.getDescription(), s.getLocation());
} catch (IOException e) {
e.printStackTrace();
return new ReadLineSimple(s, e.toString());
}
}
private static ReadLine getReaderIncludeUrl(final URL url, StringLocated s, String suf, String charset) {
try {
if (StartDiagramExtractReader.containsStartDiagram(url, s, charset)) {
return StartDiagramExtractReader.build(url, s, suf, charset);
}
final InputStream is = url.openStream();
if (charset == null) {
Log.info("Using default charset");
return ReadLineReader.create(new InputStreamReader(is), url.toString(), s.getLocation());
}
Log.info("Using charset " + charset);
return ReadLineReader.create(new InputStreamReader(is, charset), url.toString(), s.getLocation());
} catch (IOException e) {
e.printStackTrace();
return new ReadLineSimple(s, e.toString());
}
}
public static ReadLine getReaderIncludeUrl2(final URL url, StringLocated s, String suf, String charset) throws EaterException {
try {
if (StartDiagramExtractReader.containsStartDiagram(url, s, charset)) {
return StartDiagramExtractReader.build(url, s, suf, charset);
}
final InputStream is = url.openStream();
if (charset == null) {
Log.info("Using default charset");
return ReadLineReader.create(new InputStreamReader(is), url.toString(), s.getLocation());
}
Log.info("Using charset " + charset);
return ReadLineReader.create(new InputStreamReader(is, charset), url.toString(), s.getLocation());
} catch (IOException e) {
e.printStackTrace();
throw new EaterException("Cannot open URL");
}
}
public Set<FileWithSuffix> getFilesUsedGlobal() {
return filesUsedGlobal;
}
}

View File

@ -1,42 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.preproc2;
public enum PreprocessorMode {
V1_LEGACY, V2_NEW_TIM
}

View File

@ -39,10 +39,6 @@ import net.sourceforge.plantuml.preproc.ImportedFiles;
public interface PreprocessorModeSet {
public PreprocessorMode getPreprocessorMode();
public void setPreprocessorMode(PreprocessorMode mode);
public ImportedFiles getImportedFiles();
public String getCharset();

View File

@ -0,0 +1,136 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
* Modified by: Nicolas Jouanin
*
*
*/
package net.sourceforge.plantuml.preproc2;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.Log;
import net.sourceforge.plantuml.StringLocated;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.preproc.ReadLine;
import net.sourceforge.plantuml.preproc.ReadLineReader;
import net.sourceforge.plantuml.preproc.ReadLineSimple;
import net.sourceforge.plantuml.preproc.StartDiagramExtractReader;
import net.sourceforge.plantuml.preproc.Stdlib;
import net.sourceforge.plantuml.tim.EaterException;
public class PreprocessorUtils {
public static String withEnvironmentVariable(String s) {
final Pattern p = Pattern.compile("%(\\w+)%");
final Matcher m = p.matcher(s);
final StringBuffer sb = new StringBuffer();
while (m.find()) {
final String var = m.group(1);
final String value = getenv(var);
if (value != null) {
m.appendReplacement(sb, Matcher.quoteReplacement(value));
}
}
m.appendTail(sb);
s = sb.toString();
return s;
}
public static String getenv(String var) {
final String env = System.getProperty(var);
if (StringUtils.isNotEmpty(env)) {
return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(env);
}
final String getenv = System.getenv(var);
if (StringUtils.isNotEmpty(getenv)) {
return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(getenv);
}
return null;
}
private static InputStream getStdlibInputStream(String filename) {
final InputStream result = Stdlib.getResourceAsStream(filename);
// Log.info("Loading sdlib " + filename + " ok");
return result;
}
public static ReadLine getReaderStdlibInclude(StringLocated s, String filename) {
Log.info("Loading sdlib " + filename);
InputStream is = getStdlibInputStream(filename);
if (is == null) {
return null;
}
final String description = "<" + filename + ">";
try {
if (StartDiagramExtractReader.containsStartDiagram(is, s, description)) {
is = getStdlibInputStream(filename);
return StartDiagramExtractReader.build(is, s, description);
}
is = getStdlibInputStream(filename);
if (is == null) {
return null;
}
return ReadLineReader.create(new InputStreamReader(is), description);
} catch (IOException e) {
e.printStackTrace();
return new ReadLineSimple(s, e.toString());
}
}
public static ReadLine getReaderIncludeUrl2(final URL url, StringLocated s, String suf, String charset)
throws EaterException {
try {
if (StartDiagramExtractReader.containsStartDiagram(url, s, charset)) {
return StartDiagramExtractReader.build(url, s, suf, charset);
}
final InputStream is = url.openStream();
if (charset == null) {
Log.info("Using default charset");
return ReadLineReader.create(new InputStreamReader(is), url.toString(), s.getLocation());
}
Log.info("Using charset " + charset);
return ReadLineReader.create(new InputStreamReader(is, charset), url.toString(), s.getLocation());
} catch (IOException e) {
e.printStackTrace();
throw new EaterException("Cannot open URL");
}
}
}

View File

@ -43,11 +43,11 @@ import net.sourceforge.plantuml.preproc.ReadLine;
import net.sourceforge.plantuml.preproc.ReadLineList;
import net.sourceforge.plantuml.utils.StartUtils;
public class ReadLineAddConfig implements ReadFilter {
public class ReadFilterAddConfig implements ReadFilter {
private final List<String> config;
public ReadLineAddConfig(List<String> config) {
public ReadFilterAddConfig(List<String> config) {
this.config = config;
}
@ -74,7 +74,7 @@ public class ReadLineAddConfig implements ReadFilter {
}
result = raw.readLine();
if (result != null && StartUtils.isArobaseStartDiagram(result.getString()) && config.size() > 0) {
inserted = new ReadLineQuoteComment(false).applyFilter(new ReadLineList(config, result.getLocation()));
inserted = new ReadFilterQuoteComment().applyFilter(new ReadLineList(config, result.getLocation()));
}
return result;
}

View File

@ -33,32 +33,33 @@
*
*
*/
package net.sourceforge.plantuml.preproc;
package net.sourceforge.plantuml.preproc2;
import java.io.IOException;
import net.sourceforge.plantuml.StringLocated;
import net.sourceforge.plantuml.preproc2.ReadFilter;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.preproc.ReadLine;
public class IfManagerFilter implements ReadFilter {
private final DefinesGet defines;
public IfManagerFilter(DefinesGet defines) {
this.defines = defines;
}
public class ReadFilterMergeLines implements ReadFilter {
public ReadLine applyFilter(final ReadLine source) {
return new ReadLine() {
final IfManager ifManager = new IfManager(source, defines);
public void close() throws IOException {
source.close();
}
public StringLocated readLine() throws IOException {
return ifManager.readLine();
StringLocated result = source.readLine();
while (result != null && StringUtils.endsWithBackslash(result.getString())) {
final StringLocated next = source.readLine();
if (next == null) {
break;
} else {
result = result.mergeEndBackslash(next);
}
}
return result;
}
};
}

View File

@ -40,21 +40,10 @@ import java.io.IOException;
import net.sourceforge.plantuml.StringLocated;
import net.sourceforge.plantuml.preproc.ReadLine;
public class ReadLineQuoteComment implements ReadFilter {
private final boolean ignoreMe;
public ReadLineQuoteComment(boolean ignoreMe) {
this.ignoreMe = ignoreMe;
}
public class ReadFilterQuoteComment implements ReadFilter {
public ReadLine applyFilter(final ReadLine source) {
if (ignoreMe) {
return source;
}
return new ReadLine() {
public void close() throws IOException {
source.close();
}

View File

@ -1,77 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.preproc2;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.plantuml.StringLocated;
import net.sourceforge.plantuml.preproc.ReadLine;
public abstract class ReadLineInsertable implements ReadLine {
private final List<ReadLine> sources = new ArrayList<ReadLine>();
final protected void insert(ReadLine inserted) throws IOException {
sources.add(0, inserted);
}
abstract StringLocated readLineInternal() throws IOException;
final public StringLocated readLine() throws IOException {
while (sources.size() > 0) {
final ReadLine tmp = sources.get(0);
final StringLocated result = tmp.readLine();
if (result != null) {
return result;
}
tmp.close();
sources.remove(0);
}
return readLineInternal();
}
abstract void closeInternal() throws IOException;
final public void close() throws IOException {
for (ReadLine s : sources) {
s.close();
}
closeInternal();
}
}

View File

@ -1,199 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.preproc2;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import net.sourceforge.plantuml.DefinitionsContainer;
import net.sourceforge.plantuml.FileSystem;
import net.sourceforge.plantuml.Log;
import net.sourceforge.plantuml.StringLocated;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.preproc.FileWithSuffix;
import net.sourceforge.plantuml.preproc.ReadLine;
import net.sourceforge.plantuml.preproc.ReadLineReader;
import net.sourceforge.plantuml.preproc.ReadLineSimple;
import net.sourceforge.plantuml.preproc.Sub;
public class SubPreprocessor implements ReadFilter {
private static final String ID = "[A-Za-z_][A-Za-z_0-9]*";
private static final Pattern2 includeSubPattern = MyPattern.cmpile("^[%s]*!includesub[%s]+[%g]?([^%g]+)[%g]?$");
private static final Pattern2 startsub = MyPattern.cmpile("^[%s]*!startsub[%s]+(" + ID + ")");
private static final Pattern2 endsub = MyPattern.cmpile("^[%s]*!endsub[%s]*");
private final DefinitionsContainer definitionsContainer;
private final String charset;
public SubPreprocessor(String charset, DefinitionsContainer definitionsContainer) {
this.charset = charset;
this.definitionsContainer = definitionsContainer;
}
private final Map<String, Sub> subs = new HashMap<String, Sub>();
private Sub learningSub;
private ReadLine includedSub;
public ReadLine applyFilter(ReadLine source) {
return new InnerReadLine(source);
}
class InnerReadLine implements ReadLine {
final ReadLine source;
public InnerReadLine(ReadLine source) {
this.source = source;
}
private StringLocated manageStartsub(Matcher2 m) throws IOException {
final String name = m.group(1);
learningSub = getSub(name);
return this.readLine();
}
private StringLocated manageEndsub(Matcher2 m) throws IOException {
learningSub = null;
return this.readLine();
}
public void close() throws IOException {
source.close();
}
private StringLocated manageIncludeSub(StringLocated s, Matcher2 m) throws IOException {
final String name = m.group(1);
final int idx = name.indexOf('!');
if (idx != -1) {
final String filename = name.substring(0, idx);
final String blocname = name.substring(idx + 1);
final File f = FileSystem.getInstance().getFile(PreprocessorInclude.withEnvironmentVariable(filename));
if (f.exists() == false || f.isDirectory()) {
Log.error("Cannot include " + FileWithSuffix.getAbsolutePath(f));
return s.withErrorPreprocessor("Cannot include " + FileWithSuffix.getFileName(f));
}
final SubPreprocessor data = new SubPreprocessor(charset, definitionsContainer);
InnerReadLine tmp = (InnerReadLine) data.applyFilter(getReaderIncludeWithoutComment(s, f));
while (tmp.readLine() != null) {
// Read file
}
tmp.close();
includedSub = tmp.getSub(blocname).getReadLine(s.getLocation());
} else {
includedSub = getSub(name).getReadLine(s.getLocation());
}
return this.readLine();
}
public StringLocated readLine() throws IOException {
if (includedSub != null) {
final StringLocated s = includedSub.readLine();
if (s != null) {
eventuallyLearn(s);
return s;
}
includedSub = null;
}
final StringLocated s = source.readLine();
if (s == null) {
return null;
}
final Matcher2 m1 = includeSubPattern.matcher(s.getString());
if (m1.find()) {
return manageIncludeSub(s, m1);
}
Matcher2 m = startsub.matcher(s.getString());
if (m.find()) {
return manageStartsub(m);
}
m = endsub.matcher(s.getString());
if (m.find()) {
return manageEndsub(m);
}
eventuallyLearn(s);
return s;
}
private void eventuallyLearn(final StringLocated s) {
if (learningSub != null) {
learningSub.add(s);
}
}
Sub getSub(String name) {
Sub result = subs.get(name);
if (result == null) {
result = new Sub(name);
subs.put(name, result);
}
return result;
}
}
private ReadLine getReaderIncludeWithoutComment(StringLocated s, final File f) {
return new ReadLineQuoteComment(false).applyFilter(getReaderIncludeRaw(s, f));
}
private ReadLine getReaderIncludeRaw(StringLocated s, final File f) {
try {
if (charset == null) {
Log.info("Using default charset");
return ReadLineReader.create(new FileReader(f), FileWithSuffix.getFileName(f), s.getLocation());
}
Log.info("Using charset " + charset);
return ReadLineReader.create(new InputStreamReader(new FileInputStream(f), charset), FileWithSuffix.getFileName(f),
s.getLocation());
} catch (IOException e) {
return new ReadLineSimple(s, e.toString());
}
}
}

View File

@ -37,7 +37,6 @@ package net.sourceforge.plantuml.project3;
import java.util.Collection;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;

View File

@ -45,7 +45,6 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexOr;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement;
public class VerbProjectStarts implements VerbPattern {

View File

@ -255,4 +255,7 @@ public abstract class AbstractMessage implements EventWithDeactivate, WithStyle
return this.anchor2;
}
public abstract Participant getParticipant1();
public abstract Participant getParticipant2();
}

View File

@ -56,10 +56,12 @@ public final class Message extends AbstractMessage {
return super.toString() + " " + p1 + "->" + p2 + " " + getLabel();
}
@Override
public Participant getParticipant1() {
return p1;
}
@Override
public Participant getParticipant2() {
return p2;
}

Some files were not shown because too many files have changed in this diff Show More