1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-26 06:46:45 +00:00

Major change on internal identifier management

This commit is contained in:
Arnaud Roques 2023-01-31 20:27:04 +01:00
parent e1b9c0a0f0
commit 6979fb6d55
301 changed files with 3074 additions and 4540 deletions

View File

@ -33,11 +33,20 @@
* *
* *
*/ */
package net.sourceforge.plantuml.cucadiagram; package com.plantuml.wasm;
public interface Code { import java.io.IOException;
public String getName(); import net.sourceforge.plantuml.version.Version;
public class RunInit {
public static String pathStdlib;
public static void main(String[] argsArray) throws IOException {
pathStdlib = argsArray[0];
System.err.println("RunInit: " + Version.versionString());
System.err.println("Internal path for stblib: " + pathStdlib);
}
public Code eventuallyRemoveStartingAndEndingDoubleQuote(String format);
} }

View File

@ -0,0 +1,83 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2023, 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 com.plantuml.wasm;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.SourceStringReader;
import net.sourceforge.plantuml.core.DiagramDescription;
public class Utils {
public static int convertPng(String pathOut, String text) throws IOException {
final FileFormatOption format = new FileFormatOption(FileFormat.PNG);
text = cleanText(text);
return doTheJob(pathOut, text, format);
}
private static String cleanText(String text) {
if (text.endsWith("\n") == false)
text = text + "\n";
if (text.endsWith("@start") == false)
text = "@startuml\n" + text + "@enduml\n";
return text;
}
private static int doTheJob(String pathOut, String text, final FileFormatOption format)
throws FileNotFoundException, IOException {
final SourceStringReader sr = new SourceStringReader(text);
final FileOutputStream fos = new FileOutputStream(new File(pathOut));
DiagramDescription description = sr.outputImage(fos, format);
fos.close();
if (description.getDescription() != null && description.getDescription().contains("error"))
return 1;
return 0;
}
public static int convertSvg(String pathOut, String text) throws IOException {
final FileFormatOption format = new FileFormatOption(FileFormat.SVG);
text = cleanText(text);
return doTheJob(pathOut, text, format);
}
}

View File

@ -97,6 +97,7 @@ import ext.plantuml.com.ctreber.aclib.sort.QuickSort;
* @author Christian Treber, ct@ctreber.com * @author Christian Treber, ct@ctreber.com
*/ */
public class ACearth { public class ACearth {
// :: remove folder when WASM
public static final String VERSION = "1.1"; public static final String VERSION = "1.1";
public static final String BUILD = "22.11.2002 004"; public static final String BUILD = "22.11.2002 004";
@ -115,6 +116,7 @@ public class ACearth {
/** /**
* <p> * <p>
* Well, the main class. * Well, the main class.
*
* @param markers * @param markers
*/ */
public ACearth(List<Marker> markers) { public ACearth(List<Marker> markers) {
@ -171,15 +173,15 @@ public class ACearth {
// Process stars and lines (produces ScanDots-s). // Process stars and lines (produces ScanDots-s).
List lScanDots = new ArrayList(); List lScanDots = new ArrayList();
if (fConf.getBoolean("starsP")) { if (fConf.getBoolean("starsP")) {
ScanDotGenerator lGenerator = new DotGeneratorStars(fConf.getInt("imageWidth"), ScanDotGenerator lGenerator = new DotGeneratorStars(fConf.getInt("imageWidth"), fConf.getInt("imageHeight"),
fConf.getInt("imageHeight"), fConf.getDouble("starFrequency"), fConf.getInt("bigStars"), new Random(fCurrentTime)); fConf.getDouble("starFrequency"), fConf.getInt("bigStars"), new Random(fCurrentTime));
lGenerator.generateScanDots(); lGenerator.generateScanDots();
lScanDots.addAll(lGenerator.getScanDots()); lScanDots.addAll(lGenerator.getScanDots());
} }
if (fConf.getBoolean("gridP")) { if (fConf.getBoolean("gridP")) {
ScanDotGenerator lGenerator = new DotGeneratorLines(lProjection, fConf.getInt("gridDivision"), fConf ScanDotGenerator lGenerator = new DotGeneratorLines(lProjection, fConf.getInt("gridDivision"),
.getInt("gridPixelDivision")); fConf.getInt("gridPixelDivision"));
lGenerator.generateScanDots(); lGenerator.generateScanDots();
lScanDots.addAll(lGenerator.getScanDots()); lScanDots.addAll(lGenerator.getScanDots());
} }
@ -233,7 +235,8 @@ public class ACearth {
if (fConf.getInt("fixedTime") == 0) { if (fConf.getInt("fixedTime") == 0) {
// No fixed time. // No fixed time.
// final long lTimePassed = System.currentTimeMillis() - fsStartTime; // final long lTimePassed = System.currentTimeMillis() - fsStartTime;
// fCurrentTime = fsStartTime + (long) (fConf.getDouble("timeWarpFactor") * lTimePassed); // fCurrentTime = fsStartTime + (long) (fConf.getDouble("timeWarpFactor") *
// lTimePassed);
fCurrentTime = System.currentTimeMillis(); fCurrentTime = System.currentTimeMillis();
} else { } else {
// Fixed time. // Fixed time.
@ -259,8 +262,8 @@ public class ACearth {
// for ViewRotGalactic, compute appropriate viewing rotation // for ViewRotGalactic, compute appropriate viewing rotation
if (fConf.is("viewRotationType", "Galactic")) { if (fConf.is("viewRotationType", "Galactic")) {
fViewRotation = (Toolkit.degsToRads(fConf.getSunPos().getLat() fViewRotation = (Toolkit.degsToRads(
* Math.sin((fViewPos.getLong() - fConf.getSunPos().getLong())))); fConf.getSunPos().getLat() * Math.sin((fViewPos.getLong() - fConf.getSunPos().getLong()))));
} else { } else {
fViewRotation = fConf.getDouble("viewRotation"); fViewRotation = fConf.getDouble("viewRotation");
} }
@ -290,8 +293,8 @@ public class ACearth {
z = 1; z = 1;
/* /*
* rotate in about y axis (from z towards x) according to the number of * rotate in about y axis (from z towards x) according to the number of orbits
* orbits we've completed * we've completed
*/ */
a = (double) pTimeMillis / (fConf.getDouble("orbitPeriod") * 3600 * 1000) * 2 * Math.PI; a = (double) pTimeMillis / (fConf.getDouble("orbitPeriod") * 3600 * 1000) * 2 * Math.PI;
c = Math.cos(a); c = Math.cos(a);
@ -302,8 +305,8 @@ public class ACearth {
x = t2; x = t2;
/* /*
* rotate about z axis (from x towards y) according to the inclination * rotate about z axis (from x towards y) according to the inclination of the
* of the orbit * orbit
*/ */
a = Toolkit.degsToRads(fConf.getDouble("orbitInclination")); a = Toolkit.degsToRads(fConf.getDouble("orbitInclination"));
c = Math.cos(a); c = Math.cos(a);
@ -314,8 +317,8 @@ public class ACearth {
y = t2; y = t2;
/* /*
* rotate about y axis (from x towards z) according to the number of * rotate about y axis (from x towards z) according to the number of rotations
* rotations the earth has made * the earth has made
*/ */
a = ((double) pTimeMillis / 86400000) * (2 * Math.PI); a = ((double) pTimeMillis / 86400000) * (2 * Math.PI);
c = Math.cos(a); c = Math.cos(a);

View File

@ -9,6 +9,7 @@ package ext.plantuml.com.ctreber.aclib.gui;
*/ */
public class MOBoolean extends MonitoredObject public class MOBoolean extends MonitoredObject
{ {
// :: remove folder when WASM
private boolean fBoolean; private boolean fBoolean;
public MOBoolean() public MOBoolean()

View File

@ -11,6 +11,7 @@ import java.util.Comparator;
*/ */
abstract public class CTSort abstract public class CTSort
{ {
// :: remove folder when WASM
public void sort(Object[] items) public void sort(Object[] items)
{ {
sort(items, new DefaultComparator()); sort(items, new DefaultComparator());

View File

@ -24,6 +24,7 @@ import java.util.Hashtable;
* @author Sean Owen * @author Sean Owen
*/ */
public final class BarcodeFormat { public final class BarcodeFormat {
// :: remove folder when WASM
// No, we can't use an enum here. J2ME doesn't support it. // No, we can't use an enum here. J2ME doesn't support it.

View File

@ -48,6 +48,7 @@ import jcckit.util.Factory;
* @author Franz-Josef Elmer * @author Franz-Josef Elmer
*/ */
public class GraphicsPlotCanvas extends PlotCanvas { public class GraphicsPlotCanvas extends PlotCanvas {
// ::remove folder when WASM
/** Key of a configuration parameter. */ /** Key of a configuration parameter. */
public static final String BACKGROUND_KEY = "background"; public static final String BACKGROUND_KEY = "background";
public static final String FOREGROUND_KEY = "foreground"; public static final String FOREGROUND_KEY = "foreground";

View File

@ -78,10 +78,12 @@ public abstract class AbstractPSystem implements Diagram {
toAppend.append(Version.versionString()); toAppend.append(Version.versionString());
toAppend.append("(" + Version.compileTimeString() + ")\n"); toAppend.append("(" + Version.compileTimeString() + ")\n");
toAppend.append("(" + License.getCurrent() + " source distribution)\n"); toAppend.append("(" + License.getCurrent() + " source distribution)\n");
// ::comment when WASM
for (String name : OptionPrint.interestingProperties()) { for (String name : OptionPrint.interestingProperties()) {
toAppend.append(name); toAppend.append(name);
toAppend.append(BackSlash.CHAR_NEWLINE); toAppend.append(BackSlash.CHAR_NEWLINE);
} }
// ::done
return toAppend.toString(); return toAppend.toString();
} }
@ -178,10 +180,12 @@ public abstract class AbstractPSystem implements Diagram {
// } // }
return exportDiagramNow(os, index, fileFormatOption); return exportDiagramNow(os, index, fileFormatOption);
} finally { } finally {
if (OptionFlags.getInstance().isEnableStats()) { // ::comment when WASM
if (OptionFlags.getInstance().isEnableStats())
StatsUtilsIncrement.onceMoreGenerate(System.currentTimeMillis() - now, getClass(), StatsUtilsIncrement.onceMoreGenerate(System.currentTimeMillis() - now, getClass(),
fileFormatOption.getFileFormat()); fileFormatOption.getFileFormat());
}
// ::done
} }
} }

View File

@ -49,6 +49,7 @@ import net.sourceforge.plantuml.preproc.FileWithSuffix;
@Deprecated @Deprecated
public class DirWatcher { public class DirWatcher {
// ::remove file when WASM
final private File dir; final private File dir;
final private Option option; final private Option option;

View File

@ -53,6 +53,7 @@ import net.sourceforge.plantuml.log.Logme;
import net.sourceforge.plantuml.preproc.FileWithSuffix; import net.sourceforge.plantuml.preproc.FileWithSuffix;
public class DirWatcher2 { public class DirWatcher2 {
// ::remove file when WASM
final private File dir; final private File dir;
final private Option option; final private Option option;

View File

@ -74,6 +74,7 @@ public class EmptyImageBuilder {
if (width <= 0 || height <= 0) if (width <= 0 || height <= 0)
throw new IllegalArgumentException("width and height must be positive"); throw new IllegalArgumentException("width and height must be positive");
// ::comment when WASM
if (width > GraphvizUtils.getenvImageLimit()) { if (width > GraphvizUtils.getenvImageLimit()) {
Log.info("Width too large " + width + ". You should set PLANTUML_LIMIT_SIZE"); Log.info("Width too large " + width + ". You should set PLANTUML_LIMIT_SIZE");
width = GraphvizUtils.getenvImageLimit(); width = GraphvizUtils.getenvImageLimit();
@ -82,6 +83,7 @@ public class EmptyImageBuilder {
Log.info("Height too large " + height + ". You should set PLANTUML_LIMIT_SIZE"); Log.info("Height too large " + height + ". You should set PLANTUML_LIMIT_SIZE");
height = GraphvizUtils.getenvImageLimit(); height = GraphvizUtils.getenvImageLimit();
} }
// ::done
this.background = background; this.background = background;
this.stringBounder = stringBounder; this.stringBounder = stringBounder;
Log.info("Creating image " + width + "x" + height); Log.info("Creating image " + width + "x" + height);

View File

@ -63,8 +63,7 @@ import net.sourceforge.plantuml.ugraphic.debug.StringBounderDebug;
*/ */
public enum FileFormat { public enum FileFormat {
PNG("image/png"), // // ::comment when WASM
SVG("image/svg+xml"), //
EPS("application/postscript"), // EPS("application/postscript"), //
EPS_TEXT("application/postscript"), // EPS_TEXT("application/postscript"), //
ATXT("text/plain"), // ATXT("text/plain"), //
@ -85,7 +84,10 @@ public enum FileFormat {
BASE64("text/plain; charset=x-user-defined"), // BASE64("text/plain; charset=x-user-defined"), //
BRAILLE_PNG("image/png"), // BRAILLE_PNG("image/png"), //
PREPROC("text/plain"), // PREPROC("text/plain"), //
DEBUG("text/plain"); // DEBUG("text/plain"), //
// ::done
PNG("image/png"), //
SVG("image/svg+xml"); //
private final String mimeType; private final String mimeType;
@ -103,6 +105,7 @@ public enum FileFormat {
* @return a string starting by a point. * @return a string starting by a point.
*/ */
public String getFileSuffix() { public String getFileSuffix() {
// ::comment when WASM
if (name().startsWith("XMI")) if (name().startsWith("XMI"))
return ".xmi"; return ".xmi";
@ -120,6 +123,7 @@ public enum FileFormat {
if (this == EPS_TEXT) if (this == EPS_TEXT)
return EPS.getFileSuffix(); return EPS.getFileSuffix();
// ::done
return "." + StringUtils.goLowerCase(name()); return "." + StringUtils.goLowerCase(name());
} }
@ -136,17 +140,19 @@ public enum FileFormat {
} }
public StringBounder getDefaultStringBounder(TikzFontDistortion tikzFontDistortion, SvgCharSizeHack charSizeHack) { public StringBounder getDefaultStringBounder(TikzFontDistortion tikzFontDistortion, SvgCharSizeHack charSizeHack) {
// ::comment when WASM
if (this == LATEX || this == LATEX_NO_PREAMBLE) if (this == LATEX || this == LATEX_NO_PREAMBLE)
return getTikzStringBounder(tikzFontDistortion); return getTikzStringBounder(tikzFontDistortion);
if (this == BRAILLE_PNG) if (this == BRAILLE_PNG)
return getBrailleStringBounder(); return getBrailleStringBounder();
if (this == SVG)
return getSvgStringBounder(charSizeHack);
if (this == DEBUG) if (this == DEBUG)
return new StringBounderDebug(); return new StringBounderDebug();
// ::done
if (this == SVG)
return getSvgStringBounder(charSizeHack);
return getNormalStringBounder(); return getNormalStringBounder();
} }
@ -193,6 +199,7 @@ public enum FileFormat {
return new XDimension2D(rect.getWidth(), rect.getHeight()); return new XDimension2D(rect.getWidth(), rect.getHeight());
} }
// ::comment when WASM
private StringBounder getBrailleStringBounder() { private StringBounder getBrailleStringBounder() {
return new StringBounderRaw() { return new StringBounderRaw() {
public String toString() { public String toString() {
@ -320,5 +327,6 @@ public enum FileFormat {
} }
return false; return false;
} }
// ::done
} }

View File

@ -39,6 +39,7 @@ import java.io.IOException;
import java.util.List; import java.util.List;
public interface ISourceFileReader { public interface ISourceFileReader {
// ::remove file when WASM
public List<GeneratedImage> getGeneratedImages() throws IOException; public List<GeneratedImage> getGeneratedImages() throws IOException;

View File

@ -115,6 +115,7 @@ public class Option {
this.fileFormatOption = newFormat; this.fileFormatOption = newFormat;
} }
// ::comment when WASM
public Option(String... arg) throws InterruptedException, IOException { public Option(String... arg) throws InterruptedException, IOException {
if (arg.length == 0) if (arg.length == 0)
OptionFlags.getInstance().setGui(true); OptionFlags.getInstance().setGui(true);
@ -403,6 +404,7 @@ public class Option {
} }
} }
} }
// ::done
public Stdrpt getStdrpt() { public Stdrpt getStdrpt() {
if (stdrpt == 1) if (stdrpt == 1)

View File

@ -77,6 +77,7 @@ public class OptionFlags {
// static public final boolean LINK_BETWEEN_FIELDS = true; // static public final boolean LINK_BETWEEN_FIELDS = true;
// ::comment when WASM
public void reset() { public void reset() {
reset(false); reset(false);
GraphvizUtils.setDotExecutable(null); GraphvizUtils.setDotExecutable(null);
@ -85,6 +86,7 @@ public class OptionFlags {
public final void setDotExecutable(String dotExecutable) { public final void setDotExecutable(String dotExecutable) {
GraphvizUtils.setDotExecutable(dotExecutable); GraphvizUtils.setDotExecutable(dotExecutable);
} }
// ::done
private OptionFlags() { private OptionFlags() {
reset(true); reset(true);
@ -195,6 +197,7 @@ public class OptionFlags {
private final AtomicBoolean logDataInitized = new AtomicBoolean(false); private final AtomicBoolean logDataInitized = new AtomicBoolean(false);
public void logData(final SFile file, Diagram system) { public void logData(final SFile file, Diagram system) {
// ::comment when WASM
final String warnOrError = system.getWarningOrError(); final String warnOrError = system.getWarningOrError();
if (warnOrError == null) { if (warnOrError == null) {
return; return;
@ -222,6 +225,7 @@ public class OptionFlags {
Logme.error(e); Logme.error(e);
} }
} }
// ::done
} }
public final void setLogData(SFile logData) { public final void setLogData(SFile logData) {

View File

@ -56,6 +56,7 @@ import net.sourceforge.plantuml.version.PSystemVersion;
import net.sourceforge.plantuml.version.Version; import net.sourceforge.plantuml.version.Version;
public class OptionPrint { public class OptionPrint {
//::remove file when WASM
static public void printTestDot() throws InterruptedException { static public void printTestDot() throws InterruptedException {
final List<String> result = new ArrayList<>(); final List<String> result = new ArrayList<>();

View File

@ -148,11 +148,13 @@ public class PSystemBuilder {
result = PSystemErrorUtils.merge(errors); result = PSystemErrorUtils.merge(errors);
return result; return result;
} finally { } finally {
// ::comment when WASM
if (result != null && OptionFlags.getInstance().isEnableStats()) { if (result != null && OptionFlags.getInstance().isEnableStats()) {
StatsUtilsIncrement.onceMoreParse(System.currentTimeMillis() - now, result.getClass()); StatsUtilsIncrement.onceMoreParse(System.currentTimeMillis() - now, result.getClass());
} }
Log.info("Compilation duration " + (System.currentTimeMillis() - now)); Log.info("Compilation duration " + (System.currentTimeMillis() - now));
RegexConcat.printCacheInfo(); RegexConcat.printCacheInfo();
// ::done
} }
} }
@ -174,46 +176,63 @@ public class PSystemBuilder {
factories.add(new PSystemVersionFactory()); factories.add(new PSystemVersionFactory());
factories.add(new PSystemDonorsFactory()); factories.add(new PSystemDonorsFactory());
factories.add(new PSystemSkinparameterListFactory()); factories.add(new PSystemSkinparameterListFactory());
// ::comment when WASM
factories.add(new PSystemListFontsFactory()); factories.add(new PSystemListFontsFactory());
// ::done
factories.add(new PSystemListEmojiFactory()); factories.add(new PSystemListEmojiFactory());
// ::comment when WASM
factories.add(new PSystemOpenIconicFactory()); factories.add(new PSystemOpenIconicFactory());
factories.add(new PSystemListOpenIconicFactory()); factories.add(new PSystemListOpenIconicFactory());
factories.add(new PSystemListInternalSpritesFactory()); factories.add(new PSystemListInternalSpritesFactory());
// ::done
factories.add(new PSystemSaltFactory2(DiagramType.SALT)); factories.add(new PSystemSaltFactory2(DiagramType.SALT));
factories.add(new PSystemSaltFactory2(DiagramType.UML)); factories.add(new PSystemSaltFactory2(DiagramType.UML));
// ::comment when WASM
factories.add(new PSystemDotFactory(DiagramType.DOT)); factories.add(new PSystemDotFactory(DiagramType.DOT));
factories.add(new PSystemDotFactory(DiagramType.UML)); factories.add(new PSystemDotFactory(DiagramType.UML));
// ::done
factories.add(new NwDiagramFactory(DiagramType.NW)); factories.add(new NwDiagramFactory(DiagramType.NW));
factories.add(new NwDiagramFactory(DiagramType.UML)); factories.add(new NwDiagramFactory(DiagramType.UML));
factories.add(new MindMapDiagramFactory()); factories.add(new MindMapDiagramFactory());
factories.add(new WBSDiagramFactory()); factories.add(new WBSDiagramFactory());
// ::comment when WASM
factories.add(new PSystemDitaaFactory(DiagramType.DITAA)); factories.add(new PSystemDitaaFactory(DiagramType.DITAA));
factories.add(new PSystemDitaaFactory(DiagramType.UML)); factories.add(new PSystemDitaaFactory(DiagramType.UML));
// ::done
if (License.getCurrent() == License.GPL || License.getCurrent() == License.GPLV2) { if (License.getCurrent() == License.GPL || License.getCurrent() == License.GPLV2) {
// ::comment when WASM
factories.add(new PSystemJcckitFactory(DiagramType.JCCKIT)); factories.add(new PSystemJcckitFactory(DiagramType.JCCKIT));
factories.add(new PSystemJcckitFactory(DiagramType.UML)); factories.add(new PSystemJcckitFactory(DiagramType.UML));
// ::done
// factories.add(new PSystemLogoFactory()); // factories.add(new PSystemLogoFactory());
factories.add(new PSystemSudokuFactory()); factories.add(new PSystemSudokuFactory());
} }
// ::comment when WASM
factories.add(new PSystemDefinitionFactory()); factories.add(new PSystemDefinitionFactory());
// ::done
factories.add(new ListSpriteDiagramFactory()); factories.add(new ListSpriteDiagramFactory());
// ::comment when WASM
factories.add(new StdlibDiagramFactory()); factories.add(new StdlibDiagramFactory());
factories.add(new PSystemMathFactory(DiagramType.MATH)); factories.add(new PSystemMathFactory(DiagramType.MATH));
factories.add(new PSystemLatexFactory(DiagramType.LATEX)); factories.add(new PSystemLatexFactory(DiagramType.LATEX));
// ::done
// factories.add(new PSystemStatsFactory()); // factories.add(new PSystemStatsFactory());
factories.add(new PSystemCreoleFactory()); factories.add(new PSystemCreoleFactory());
factories.add(new PSystemEggFactory()); factories.add(new PSystemEggFactory());
factories.add(new PSystemAppleTwoFactory()); factories.add(new PSystemAppleTwoFactory());
factories.add(new PSystemRIPFactory()); factories.add(new PSystemRIPFactory());
// factories.add(new PSystemLostFactory()); // factories.add(new PSystemLostFactory());
if (SecurityUtils.getSecurityProfile() == SecurityProfile.UNSECURE) { // ::comment when WASM
if (SecurityUtils.getSecurityProfile() == SecurityProfile.UNSECURE)
factories.add(new PSystemPathFactory()); factories.add(new PSystemPathFactory());
} // ::done
factories.add(new PSystemOregonFactory()); factories.add(new PSystemOregonFactory());
factories.add(new PSystemCharlieFactory()); factories.add(new PSystemCharlieFactory());
// ::comment when WASM
if (License.getCurrent() == License.GPL || License.getCurrent() == License.GPLV2) { if (License.getCurrent() == License.GPL || License.getCurrent() == License.GPLV2) {
factories.add(new PSystemXearthFactory()); factories.add(new PSystemXearthFactory());
} }
// ::done
factories.add(new GanttDiagramFactory()); factories.add(new GanttDiagramFactory());
factories.add(new FlowDiagramFactory()); factories.add(new FlowDiagramFactory());
// factories.add(new PSystemTreeFactory(DiagramType.JUNGLE)); // factories.add(new PSystemTreeFactory(DiagramType.JUNGLE));

View File

@ -56,6 +56,7 @@ import net.sourceforge.plantuml.ugraphic.color.HColors;
import net.sourceforge.plantuml.utils.Log; import net.sourceforge.plantuml.utils.Log;
public class PSystemUtils { public class PSystemUtils {
// :: remove file when WASM
public static List<FileImageData> exportDiagrams(Diagram system, SuggestedFile suggested, public static List<FileImageData> exportDiagrams(Diagram system, SuggestedFile suggested,
FileFormatOption fileFormatOption) throws IOException { FileFormatOption fileFormatOption) throws IOException {
@ -65,6 +66,7 @@ public class PSystemUtils {
public static List<FileImageData> exportDiagrams(Diagram system, SuggestedFile suggestedFile, public static List<FileImageData> exportDiagrams(Diagram system, SuggestedFile suggestedFile,
FileFormatOption fileFormatOption, boolean checkMetadata) throws IOException { FileFormatOption fileFormatOption, boolean checkMetadata) throws IOException {
// ::comment when WASM
final SFile existingFile = suggestedFile.getFile(0); final SFile existingFile = suggestedFile.getFile(0);
if (checkMetadata && fileFormatOption.getFileFormat().doesSupportMetadata() && existingFile.exists()) { if (checkMetadata && fileFormatOption.getFileFormat().doesSupportMetadata() && existingFile.exists()) {
// && system.getNbImages() == 1) { // && system.getNbImages() == 1) {
@ -75,6 +77,7 @@ public class PSystemUtils {
return Arrays.asList(new FileImageData(existingFile, null)); return Arrays.asList(new FileImageData(existingFile, null));
} }
} }
// ::done
if (system instanceof NewpagedDiagram) if (system instanceof NewpagedDiagram)
return exportDiagramsNewpaged((NewpagedDiagram) system, suggestedFile, fileFormatOption); return exportDiagramsNewpaged((NewpagedDiagram) system, suggestedFile, fileFormatOption);
@ -82,8 +85,10 @@ public class PSystemUtils {
if (system instanceof SequenceDiagram) if (system instanceof SequenceDiagram)
return exportDiagramsSequence((SequenceDiagram) system, suggestedFile, fileFormatOption); return exportDiagramsSequence((SequenceDiagram) system, suggestedFile, fileFormatOption);
// ::comment when WASM
if (system instanceof CucaDiagram && fileFormatOption.getFileFormat() == FileFormat.HTML) if (system instanceof CucaDiagram && fileFormatOption.getFileFormat() == FileFormat.HTML)
return createFilesHtml((CucaDiagram) system, suggestedFile); return createFilesHtml((CucaDiagram) system, suggestedFile);
// ::done
return exportDiagramsDefault(system, suggestedFile, fileFormatOption); return exportDiagramsDefault(system, suggestedFile, fileFormatOption);
} }
@ -146,10 +151,12 @@ public class PSystemUtils {
} finally { } finally {
fos.close(); fos.close();
} }
// ::comment when SPAM
if (cmap != null && cmap.containsCMapData()) if (cmap != null && cmap.containsCMapData())
system.exportCmap(suggestedFile, i, cmap); system.exportCmap(suggestedFile, i, cmap);
Log.info("File size : " + f.length()); Log.info("File size : " + f.length());
// ::done
result.add(new FileImageData(f, cmap)); result.add(new FileImageData(f, cmap));
} }
return result; return result;
@ -200,8 +207,10 @@ public class PSystemUtils {
if (imageData == null) if (imageData == null)
return emptyList(); return emptyList();
// ::comment when SPAM
if (imageData.containsCMapData() && system instanceof UmlDiagram) if (imageData.containsCMapData() && system instanceof UmlDiagram)
((UmlDiagram) system).exportCmap(suggestedFile, 0, imageData); ((UmlDiagram) system).exportCmap(suggestedFile, 0, imageData);
// ::done
if (system instanceof TitledDiagram && fileFormatOption.getFileFormat() == FileFormat.PNG) if (system instanceof TitledDiagram && fileFormatOption.getFileFormat() == FileFormat.PNG)
return splitPng((TitledDiagram) system, suggestedFile, imageData, fileFormatOption); return splitPng((TitledDiagram) system, suggestedFile, imageData, fileFormatOption);

View File

@ -75,6 +75,7 @@ import net.sourceforge.plantuml.utils.Log;
import net.sourceforge.plantuml.version.Version; import net.sourceforge.plantuml.version.Version;
public class Run { public class Run {
// ::remove file when WASM
private static Cypher cypher; private static Cypher cypher;
@ -335,7 +336,8 @@ public class Run {
} }
private static void goPicoweb(Option option) throws IOException { private static void goPicoweb(Option option) throws IOException {
PicoWebServer.startServer(option.getPicowebPort(), option.getPicowebBindAddress(), option.getPicowebEnableStop()); PicoWebServer.startServer(option.getPicowebPort(), option.getPicowebBindAddress(),
option.getPicowebEnableStop());
} }
public static void printFonts() { public static void printFonts() {

View File

@ -48,6 +48,7 @@ import net.sourceforge.plantuml.utils.Log;
@HaxeIgnored @HaxeIgnored
public class SourceFileReader extends SourceFileReaderAbstract implements ISourceFileReader { public class SourceFileReader extends SourceFileReaderAbstract implements ISourceFileReader {
// ::remove file when WASM
private File outputDirectory; private File outputDirectory;

View File

@ -65,6 +65,7 @@ import net.sourceforge.plantuml.security.SecurityUtils;
import net.sourceforge.plantuml.utils.Log; import net.sourceforge.plantuml.utils.Log;
public abstract class SourceFileReaderAbstract implements ISourceFileReader { public abstract class SourceFileReaderAbstract implements ISourceFileReader {
// ::remove file when WASM
final private File file; final private File file;

View File

@ -42,6 +42,7 @@ import java.util.List;
import net.sourceforge.plantuml.preproc.Defines; import net.sourceforge.plantuml.preproc.Defines;
public class SourceFileReaderCopyCat extends SourceFileReaderAbstract implements ISourceFileReader { public class SourceFileReaderCopyCat extends SourceFileReaderAbstract implements ISourceFileReader {
// ::remove file when WASM
private final File outputDirectory; private final File outputDirectory;

View File

@ -43,6 +43,7 @@ import net.sourceforge.plantuml.preproc.Defines;
import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.security.SFile;
public class SourceFileReaderHardFile extends SourceFileReaderAbstract implements ISourceFileReader { public class SourceFileReaderHardFile extends SourceFileReaderAbstract implements ISourceFileReader {
// ::remove file when WASM
private final File outputFile; private final File outputFile;

View File

@ -353,6 +353,7 @@ public class StringUtils {
return result; return result;
} }
// ::comment when WASM
public static int getWcWidth(Display stringsToDisplay) { public static int getWcWidth(Display stringsToDisplay) {
int result = 1; int result = 1;
for (CharSequence s : stringsToDisplay) { for (CharSequence s : stringsToDisplay) {
@ -366,6 +367,7 @@ public class StringUtils {
} }
return result; return result;
} }
// ::done
public static int getHeight(List<? extends CharSequence> stringsToDisplay) { public static int getHeight(List<? extends CharSequence> stringsToDisplay) {
return stringsToDisplay.size(); return stringsToDisplay.size();

View File

@ -38,6 +38,7 @@ package net.sourceforge.plantuml;
import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.security.SFile;
public class SuggestedFile { public class SuggestedFile {
// ::remove file when WASM
private final FileFormat fileFormat; private final FileFormat fileFormat;
private final int initialCpt; private final int initialCpt;

View File

@ -81,7 +81,9 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram,
private final SkinParam skinParam; private final SkinParam skinParam;
// ::comment when WASM
private Animation animation; private Animation animation;
// ::done
private final Pragma pragma = new Pragma(); private final Pragma pragma = new Pragma();
@ -252,6 +254,7 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram,
return ClockwiseTopRightBottomLeft.same(10); return ClockwiseTopRightBottomLeft.same(10);
} }
// ::comment when WASM
final public void setAnimation(Iterable<CharSequence> animationData) { final public void setAnimation(Iterable<CharSequence> animationData) {
// try { // try {
final AnimationDecoder animationDecoder = new AnimationDecoder(animationData); final AnimationDecoder animationDecoder = new AnimationDecoder(animationData);
@ -264,6 +267,7 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram,
final public Animation getAnimation() { final public Animation getAnimation() {
return animation; return animation;
} }
// ::done
@Override @Override
public ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) throws IOException { public ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) throws IOException {

View File

@ -129,8 +129,10 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot
fileFormatOption = fileFormatOption.withTikzFontDistortion(getSkinParam().getTikzFontDistortion()); fileFormatOption = fileFormatOption.withTikzFontDistortion(getSkinParam().getTikzFontDistortion());
// ::comment when WASM
if (fileFormatOption.getFileFormat() == FileFormat.PDF) if (fileFormatOption.getFileFormat() == FileFormat.PDF)
return exportDiagramInternalPdf(os, index); return exportDiagramInternalPdf(os, index);
// ::done
try { try {
final ImageData imageData = exportDiagramInternal(os, index, fileFormatOption); final ImageData imageData = exportDiagramInternal(os, index, fileFormatOption);
@ -158,14 +160,17 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot
public static void exportDiagramError(OutputStream os, Throwable exception, FileFormatOption fileFormat, long seed, public static void exportDiagramError(OutputStream os, Throwable exception, FileFormatOption fileFormat, long seed,
String metadata, String flash, List<String> strings) throws IOException { String metadata, String flash, List<String> strings) throws IOException {
// ::comment when WASM
if (fileFormat.getFileFormat() == FileFormat.ATXT || fileFormat.getFileFormat() == FileFormat.UTXT) { if (fileFormat.getFileFormat() == FileFormat.ATXT || fileFormat.getFileFormat() == FileFormat.UTXT) {
exportDiagramErrorText(os, exception, strings); exportDiagramErrorText(os, exception, strings);
return; return;
} }
// ::done
strings.addAll(CommandExecutionResult.getStackTrace(exception)); strings.addAll(CommandExecutionResult.getStackTrace(exception));
BufferedImage im2 = null; BufferedImage im2 = null;
// ::comment when WASM
if (flash != null) { if (flash != null) {
final FlashCodeUtils utils = FlashCodeFactory.getFlashCodeUtils(); final FlashCodeUtils utils = FlashCodeFactory.getFlashCodeUtils();
try { try {
@ -176,8 +181,9 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot
} }
if (im2 != null) if (im2 != null)
GraphvizCrash.addDecodeHint(strings); GraphvizCrash.addDecodeHint(strings);
} }
// ::done
final BufferedImage im = im2; final BufferedImage im = im2;
final TextBlockBackcolored graphicStrings = GraphicStrings.createBlackOnWhite(strings, IconLoader.getRandom(), final TextBlockBackcolored graphicStrings = GraphicStrings.createBlackOnWhite(strings, IconLoader.getRandom(),
GraphicPosition.BACKGROUND_CORNER_TOP_RIGHT); GraphicPosition.BACKGROUND_CORNER_TOP_RIGHT);
@ -245,6 +251,7 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot
return strings; return strings;
} }
// ::comment when WASM
private void exportDiagramInternalMjpeg(OutputStream os) throws IOException { private void exportDiagramInternalMjpeg(OutputStream os) throws IOException {
final SFile f = new SFile("c:/test.avi"); final SFile f = new SFile("c:/test.avi");
final int nb = 150; final int nb = 150;
@ -266,8 +273,6 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot
} }
private XDimension2D lastInfo;
private ImageData exportDiagramInternalPdf(OutputStream os, int index) throws IOException { private ImageData exportDiagramInternalPdf(OutputStream os, int index) throws IOException {
final File svg = FileUtils.createTempFileLegacy("pdf", ".svf"); final File svg = FileUtils.createTempFileLegacy("pdf", ".svf");
final File pdfFile = FileUtils.createTempFileLegacy("pdf", ".pdf"); final File pdfFile = FileUtils.createTempFileLegacy("pdf", ".pdf");
@ -280,9 +285,6 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot
return result; return result;
} }
protected abstract ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException;
final protected void exportCmap(SuggestedFile suggestedFile, int index, final ImageData cmapdata) final protected void exportCmap(SuggestedFile suggestedFile, int index, final ImageData cmapdata)
throws FileNotFoundException { throws FileNotFoundException {
final String name = changeName(suggestedFile.getFile(index).getAbsolutePath()); final String name = changeName(suggestedFile.getFile(index).getAbsolutePath());
@ -298,6 +300,12 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot
static String changeName(String name) { static String changeName(String name) {
return name.replaceAll("(?i)\\.\\w{3}$", ".cmapx"); return name.replaceAll("(?i)\\.\\w{3}$", ".cmapx");
} }
// ::done
private XDimension2D lastInfo;
protected abstract ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException;
@Override @Override
public String getWarningOrError() { public String getWarningOrError() {

View File

@ -93,9 +93,11 @@ public class Url implements EnsureVisible {
} }
public String getCoords(double scale) { public String getCoords(double scale) {
if (DotMaker2.isJunit() && visible.getCoords(1.0).contains("0,0,0,0")) { // ::comment when WASM
if (DotMaker2.isJunit() && visible.getCoords(1.0).contains("0,0,0,0"))
throw new IllegalStateException(toString()); throw new IllegalStateException(toString());
} // ::done
return visible.getCoords(scale); return visible.getCoords(scale);
} }

View File

@ -58,6 +58,7 @@ import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.core.UmlSource;
public class PSystemXearth extends AbstractPSystem { public class PSystemXearth extends AbstractPSystem {
// :: remove folder when WASM
final private int width; final private int width;
final private int height; final private int height;

View File

@ -42,23 +42,19 @@ import java.util.Objects;
import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.baraye.CucaDiagram; import net.sourceforge.plantuml.baraye.CucaDiagram;
import net.sourceforge.plantuml.baraye.IEntity; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.baraye.ILeaf; import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.GroupType; import net.sourceforge.plantuml.cucadiagram.GroupType;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy;
import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.utils.Direction; import net.sourceforge.plantuml.utils.Direction;
public class ActivityDiagram extends CucaDiagram { public class ActivityDiagram extends CucaDiagram {
private IEntity lastEntityConsulted; private EntityImp lastEntityConsulted;
private IEntity lastEntityBrancheConsulted; private EntityImp lastEntityBrancheConsulted;
private ConditionalContext currentContext; private ConditionalContext currentContext;
public ActivityDiagram(UmlSource source, Map<String, String> skinParam) { public ActivityDiagram(UmlSource source, Map<String, String> skinParam) {
@ -66,34 +62,33 @@ public class ActivityDiagram extends CucaDiagram {
setNamespaceSeparator(null); setNamespaceSeparator(null);
} }
public ILeaf getOrCreateLeaf(Ident ident, Code code, LeafType type, USymbol symbol) {
return getOrCreateLeafDefault(Objects.requireNonNull(ident), code, type, symbol);
}
private String getAutoBranch() { private String getAutoBranch() {
return "#" + this.getUniqueSequence(); return "#" + this.getUniqueSequence();
} }
public IEntity getOrCreate(Ident idNewLong, Code code, Display display, LeafType type) { // public final IEntity getOrCreateInActivity(Quark idNewLong, String codeString, Display display, LeafType type) {
final IEntity result; // final Quark code = buildFromFullPath(codeString);
final boolean leafExist = leafExist(code); // final IEntity result;
if (leafExist) { // if (code.getData() == null) {
result = getOrCreateLeafDefault(idNewLong, code, type, null); // final Quark quark = getPlasma().getIfExistsFromName(code.getName());
if (result.getLeafType() != type) { // if (quark != null && quark.getData() != null)
return null; // result = getFromName(code.getName());
} // else
} else { // result = reallyCreateLeaf(idNewLong, display, type, null);
result = createLeaf(idNewLong, code, display, type, null); // } else {
} // result = (ILeaf) code.getData();
updateLasts(result); // if (result.getLeafType() != type)
return result; // return null;
} // }
// updateLasts(result);
// return result;
// }
public void startIf(String optionalCodeString) { public void startIf(String optionalCodeString) {
final String idShort = optionalCodeString == null ? getAutoBranch() : optionalCodeString; final String idShort = optionalCodeString == null ? getAutoBranch() : optionalCodeString;
final Ident idNewLong = buildLeafIdent(idShort); final Quark quark = quarkInContext(cleanIdForQuark(idShort), false);
final Code code = buildCode(idShort); // final Quark code = buildCode(idShort);
final IEntity br = createLeaf(idNewLong, code, Display.create(""), LeafType.BRANCH, null); final EntityImp br = reallyCreateLeaf(quark, Display.create(""), LeafType.BRANCH, null);
currentContext = new ConditionalContext(currentContext, br, Direction.DOWN); currentContext = new ConditionalContext(currentContext, br, Direction.DOWN);
} }
@ -101,38 +96,37 @@ public class ActivityDiagram extends CucaDiagram {
currentContext = currentContext.getParent(); currentContext = currentContext.getParent();
} }
public ILeaf getStart() { public EntityImp getStart() {
final Ident ident = buildLeafIdent("start"); final Quark quark = quarkInContext("start", false);
final Code code = buildCode("start"); if (quark.getData() == null) {
return (ILeaf) getOrCreate(ident, code, Display.getWithNewlines("start"), LeafType.CIRCLE_START); quark.setData(reallyCreateLeaf(quark, Display.getWithNewlines("start"), LeafType.CIRCLE_START, null));
}
return (EntityImp) quark.getData();
} }
public ILeaf getEnd(String suppId) { public EntityImp getEnd(String suppId) {
final String tmp = suppId == null ? "end" : "end$" + suppId; final String tmp = suppId == null ? "end" : "end$" + suppId;
final Ident ident = buildLeafIdent(tmp); final Quark quark = quarkInContext(tmp, false);
final Code code = buildCode(tmp); if (quark.getData() == null) {
return (ILeaf) getOrCreate(ident, code, Display.getWithNewlines("end"), LeafType.CIRCLE_END); quark.setData(reallyCreateLeaf(quark, Display.getWithNewlines("end"), LeafType.CIRCLE_END, null));
}
private void updateLasts(final IEntity result) {
if (result == null || result.getLeafType() == LeafType.NOTE) {
return;
}
this.lastEntityConsulted = result;
if (result.getLeafType() == LeafType.BRANCH) {
lastEntityBrancheConsulted = result;
} }
return (EntityImp) quark.getData();
} }
@Override @Override
public ILeaf createLeaf(Ident idNewLong, Code code, Display display, LeafType type, USymbol symbol) { protected void updateLasts(EntityImp result) {
final ILeaf result = super.createLeaf(Objects.requireNonNull(idNewLong), code, display, type, symbol); if (result == null || result.getLeafType() == LeafType.NOTE)
updateLasts(result); return;
return result;
// System.err.println("updateLasts " + result);
this.lastEntityConsulted = result;
if (result.getLeafType() == LeafType.BRANCH)
lastEntityBrancheConsulted = result;
} }
public IEntity createNote(Ident idNewLong, Code code, Display display) { public EntityImp createNote(Quark idNewLong, String code__, Display display) {
return super.createLeaf(Objects.requireNonNull(idNewLong), code, display, LeafType.NOTE, null); return reallyCreateLeaf(Objects.requireNonNull(idNewLong), display, LeafType.NOTE, null);
} }
final protected List<String> getDotStrings() { final protected List<String> getDotStrings() {
@ -144,12 +138,12 @@ public class ActivityDiagram extends CucaDiagram {
return new DiagramDescription("(" + getLeafssize() + " activities)"); return new DiagramDescription("(" + getLeafssize() + " activities)");
} }
public IEntity getLastEntityConsulted() { public EntityImp getLastEntityConsulted() {
return lastEntityConsulted; return lastEntityConsulted;
} }
@Deprecated @Deprecated
public IEntity getLastEntityBrancheConsulted() { public EntityImp getLastEntityBrancheConsulted() {
return lastEntityBrancheConsulted; return lastEntityBrancheConsulted;
} }
@ -157,41 +151,36 @@ public class ActivityDiagram extends CucaDiagram {
return currentContext; return currentContext;
} }
public final void setLastEntityConsulted(IEntity lastEntityConsulted) { public final void setLastEntityConsulted(EntityImp lastEntityConsulted) {
// System.err.println("setLastEntityConsulted " + lastEntityConsulted);
this.lastEntityConsulted = lastEntityConsulted; this.lastEntityConsulted = lastEntityConsulted;
} }
public IEntity createInnerActivity() { public EntityImp createInnerActivity() {
// Log.println("createInnerActivity A");
final String idShort = "##" + this.getUniqueSequence(); final String idShort = "##" + this.getUniqueSequence();
final Ident idNewLong = buildLeafIdent(idShort);
final Code code = buildCode(idShort); final Quark quark = quarkInContext(idShort, false);
gotoGroup(idNewLong, code, Display.getWithNewlines(code), GroupType.INNER_ACTIVITY, getCurrentGroup(), gotoGroup(quark, Display.getWithNewlines(quark.getName()), GroupType.INNER_ACTIVITY);
NamespaceStrategy.SINGLE); final EntityImp g = getCurrentGroup();
final IEntity g = getCurrentGroup();
// g.setRankdir(Rankdir.LEFT_TO_RIGHT);
lastEntityConsulted = null; lastEntityConsulted = null;
lastEntityBrancheConsulted = null; lastEntityBrancheConsulted = null;
// Log.println("createInnerActivity B "+getCurrentGroup());
return g; return g;
} }
public void concurrentActivity(String name) { public void concurrentActivity(String name) {
// Log.println("concurrentActivity A name=" + name+" "+getCurrentGroup()); if (getCurrentGroup().getGroupType() == GroupType.CONCURRENT_ACTIVITY)
if (getCurrentGroup().getGroupType() == GroupType.CONCURRENT_ACTIVITY) {
// getCurrentGroup().setRankdir(Rankdir.LEFT_TO_RIGHT);
endGroup(); endGroup();
// Log.println("endgroup");
}
final String idShort = "##" + this.getUniqueSequence(); final String idShort = "##" + this.getUniqueSequence();
// Log.println("concurrentActivity A name=" + name+" "+getCurrentGroup());
final Code code = buildCode(idShort); if (getCurrentGroup().getGroupType() != GroupType.INNER_ACTIVITY)
if (getCurrentGroup().getGroupType() != GroupType.INNER_ACTIVITY) {
throw new IllegalStateException("type=" + getCurrentGroup().getGroupType()); throw new IllegalStateException("type=" + getCurrentGroup().getGroupType());
}
final Ident idNewLong = buildLeafIdent(idShort); final Quark idNewLong = quarkInContext(idShort, false);
gotoGroup(idNewLong, code, Display.getWithNewlines("code"), GroupType.CONCURRENT_ACTIVITY, getCurrentGroup(), gotoGroup(idNewLong, Display.getWithNewlines("code"), GroupType.CONCURRENT_ACTIVITY);
NamespaceStrategy.SINGLE);
lastEntityConsulted = null; lastEntityConsulted = null;
lastEntityBrancheConsulted = null; lastEntityBrancheConsulted = null;
} }

View File

@ -37,17 +37,17 @@ package net.sourceforge.plantuml.activitydiagram;
import java.util.Objects; import java.util.Objects;
import net.sourceforge.plantuml.baraye.IEntity; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.utils.Direction; import net.sourceforge.plantuml.utils.Direction;
public class ConditionalContext { public class ConditionalContext {
private final IEntity branch; private final EntityImp branch;
private final Direction direction; private final Direction direction;
private final ConditionalContext parent; private final ConditionalContext parent;
public ConditionalContext(ConditionalContext parent, IEntity branch, Direction direction) { public ConditionalContext(ConditionalContext parent, EntityImp branch, Direction direction) {
this.branch = Objects.requireNonNull(branch); this.branch = Objects.requireNonNull(branch);
if (branch.getLeafType() != LeafType.BRANCH) { if (branch.getLeafType() != LeafType.BRANCH) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
@ -64,7 +64,7 @@ public class ConditionalContext {
return parent; return parent;
} }
public final IEntity getBranch() { public final EntityImp getBranch() {
return branch; return branch;
} }

View File

@ -36,7 +36,7 @@
package net.sourceforge.plantuml.activitydiagram.command; package net.sourceforge.plantuml.activitydiagram.command;
import net.sourceforge.plantuml.activitydiagram.ActivityDiagram; import net.sourceforge.plantuml.activitydiagram.ActivityDiagram;
import net.sourceforge.plantuml.baraye.IEntity; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.IRegex;
@ -66,7 +66,7 @@ public class CommandElse extends SingleLineCommand2<ActivityDiagram> {
if (system.getCurrentContext() == null) { if (system.getCurrentContext() == null) {
return CommandExecutionResult.error("No if for this else"); return CommandExecutionResult.error("No if for this else");
} }
final IEntity branch = system.getCurrentContext().getBranch(); final EntityImp branch = system.getCurrentContext().getBranch();
system.setLastEntityConsulted(branch); system.setLastEntityConsulted(branch);

View File

@ -37,7 +37,7 @@ package net.sourceforge.plantuml.activitydiagram.command;
import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.activitydiagram.ActivityDiagram; import net.sourceforge.plantuml.activitydiagram.ActivityDiagram;
import net.sourceforge.plantuml.baraye.IEntity; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.classdiagram.command.CommandLinkClass; import net.sourceforge.plantuml.classdiagram.command.CommandLinkClass;
import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.SingleLineCommand2;
@ -94,7 +94,7 @@ public class CommandIf extends SingleLineCommand2<ActivityDiagram> {
@Override @Override
protected CommandExecutionResult executeArg(ActivityDiagram diagram, LineLocation location, RegexResult arg) { protected CommandExecutionResult executeArg(ActivityDiagram diagram, LineLocation location, RegexResult arg) {
final IEntity entity1 = CommandLinkActivity.getEntity(diagram, arg, true); final EntityImp entity1 = CommandLinkActivity.getEntity(diagram, arg, true);
if (entity1 == null) if (entity1 == null)
return CommandExecutionResult.error("No if possible at this point"); return CommandExecutionResult.error("No if possible at this point");
@ -122,10 +122,10 @@ public class CommandIf extends SingleLineCommand2<ActivityDiagram> {
lenght = arrow.length() - 1; lenght = arrow.length() - 1;
} }
final IEntity branch = diagram.getCurrentContext().getBranch(); final EntityImp branch = diagram.getCurrentContext().getBranch();
final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(arg.get("BRACKET", 0)), lenght); final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(arg.get("BRACKET", 0)), lenght);
Link link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), entity1, Link link = new Link(diagram.getEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), entity1,
branch, new LinkType(LinkDecor.ARROW, LinkDecor.NONE), linkArg.withQuantifier(null, ifLabel) branch, new LinkType(LinkDecor.ARROW, LinkDecor.NONE), linkArg.withQuantifier(null, ifLabel)
.withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle())); .withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle()));
if (arg.get("ARROW", 0) != null) { if (arg.get("ARROW", 0) != null) {

View File

@ -61,7 +61,7 @@ public class CommandInnerConcurrent extends SingleLineCommand2<ActivityDiagram>
@Override @Override
protected CommandExecutionResult executeArg(ActivityDiagram diagram, LineLocation location, RegexResult arg) { protected CommandExecutionResult executeArg(ActivityDiagram diagram, LineLocation location, RegexResult arg) {
if (EntityUtils.groupRoot(diagram.getCurrentGroup())) { if (diagram.getCurrentGroup().getQuark().isRoot()) {
return CommandExecutionResult.error("No inner activity"); return CommandExecutionResult.error("No inner activity");
} }
diagram.concurrentActivity(arg.get("NAME", 0)); diagram.concurrentActivity(arg.get("NAME", 0));

View File

@ -40,7 +40,8 @@ import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlMode; import net.sourceforge.plantuml.UrlMode;
import net.sourceforge.plantuml.activitydiagram.ActivityDiagram; import net.sourceforge.plantuml.activitydiagram.ActivityDiagram;
import net.sourceforge.plantuml.baraye.IEntity; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.classdiagram.command.CommandLinkClass; import net.sourceforge.plantuml.classdiagram.command.CommandLinkClass;
import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.SingleLineCommand2;
@ -51,16 +52,13 @@ import net.sourceforge.plantuml.command.regex.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexOr;
import net.sourceforge.plantuml.command.regex.RegexPartialMatch; import net.sourceforge.plantuml.command.regex.RegexPartialMatch;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.GroupType; import net.sourceforge.plantuml.cucadiagram.GroupType;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg; import net.sourceforge.plantuml.cucadiagram.LinkArg;
import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType; import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy;
import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement; import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement;
import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorParser;
@ -124,7 +122,8 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
@Override @Override
protected CommandExecutionResult executeArg(ActivityDiagram diagram, LineLocation location, RegexResult arg) protected CommandExecutionResult executeArg(ActivityDiagram diagram, LineLocation location, RegexResult arg)
throws NoSuchColorException { throws NoSuchColorException {
final IEntity entity1 = getEntity(diagram, arg, true); final EntityImp entity1 = getEntity(diagram, arg, true);
if (entity1 == null) if (entity1 == null)
return CommandExecutionResult.error("No such activity"); return CommandExecutionResult.error("No such activity");
@ -136,10 +135,12 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
entity1.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet().getColor(s)); entity1.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet().getColor(s));
} }
final IEntity entity2 = getEntity(diagram, arg, false); final EntityImp entity2 = getEntity(diagram, arg, false);
if (entity2 == null) if (entity2 == null)
return CommandExecutionResult.error("No such activity"); return CommandExecutionResult.error("No such activity");
diagram.setLastEntityConsulted(entity2);
if (arg.get("BACKCOLOR2", 0) != null) { if (arg.get("BACKCOLOR2", 0) != null) {
String s = arg.get("BACKCOLOR2", 0); String s = arg.get("BACKCOLOR2", 0);
entity2.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet().getColor(s)); entity2.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet().getColor(s));
@ -163,7 +164,7 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
type = type.goDotted(); type = type.goDotted();
final LinkArg linkArg = LinkArg.build(linkLabel, lenght, diagram.getSkinParam().classAttributeIconSize() > 0); final LinkArg linkArg = LinkArg.build(linkLabel, lenght, diagram.getSkinParam().classAttributeIconSize() > 0);
Link link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), entity1, Link link = new Link(diagram.getEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), entity1,
entity2, type, linkArg); entity2, type, linkArg);
if (arrowDirection.contains("*")) if (arrowDirection.contains("*"))
link.setConstraint(false); link.setConstraint(false);
@ -185,7 +186,7 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
} }
static IEntity getEntity(ActivityDiagram diagram, RegexResult arg, final boolean start) { static EntityImp getEntity(ActivityDiagram diagram, RegexResult arg, final boolean start) {
final String suf = start ? "" : "2"; final String suf = start ? "" : "2";
final String openBracket2 = arg.get("OPENBRACKET" + suf, 0); final String openBracket2 = arg.get("OPENBRACKET" + suf, 0);
@ -208,15 +209,16 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
final String idShort = arg.get("CODE" + suf, 0); final String idShort = arg.get("CODE" + suf, 0);
if (idShort != null) { if (idShort != null) {
if (partition != null) { if (partition != null) {
final Ident idNewLong = diagram.buildLeafIdent(partition); final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(partition), false);
final Code codeP = diagram.buildCode(partition); diagram.gotoGroup(quark, Display.getWithNewlines(quark), GroupType.PACKAGE);
diagram.gotoGroup(idNewLong, codeP, Display.getWithNewlines(partition), GroupType.PACKAGE,
diagram.getRootGroup(), NamespaceStrategy.SINGLE);
} }
final Ident ident = diagram.buildLeafIdent(idShort); final Quark ident = diagram.quarkInContext(diagram.cleanIdForQuark(idShort), false);
final Code code = diagram.buildCode(idShort);
final LeafType type = getTypeIfExisting(diagram, code); final LeafType type = getTypeIfExisting(diagram, ident);
final IEntity result = diagram.getOrCreate(ident, code, Display.getWithNewlines(code), type); EntityImp result = (EntityImp) ident.getData();
if (result == null)
result = diagram.reallyCreateLeaf(ident, Display.getWithNewlines(idShort), type, null);
if (partition != null) if (partition != null)
diagram.endGroup(); diagram.endGroup();
@ -224,24 +226,26 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
} }
final String bar = arg.get("BAR" + suf, 0); final String bar = arg.get("BAR" + suf, 0);
if (bar != null) { if (bar != null) {
final Ident identBar = diagram.buildLeafIdent(bar); final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(bar), false);
final Code codeBar = diagram.buildCode(bar); EntityImp result = (EntityImp) quark.getData();
return diagram.getOrCreate(identBar, codeBar, Display.getWithNewlines(bar), LeafType.SYNCHRO_BAR); if (result == null)
result = diagram.reallyCreateLeaf(quark, Display.getWithNewlines(bar), LeafType.SYNCHRO_BAR, null);
return result;
} }
final RegexPartialMatch quoted = arg.get("QUOTED" + suf); final RegexPartialMatch quoted = arg.get("QUOTED" + suf);
if (quoted.get(0) != null) { if (quoted.get(0) != null) {
final String quotedString = quoted.get(1) == null ? quoted.get(0) : quoted.get(1); final String quotedString = quoted.get(1) == null ? quoted.get(0) : quoted.get(1);
if (partition != null) { if (partition != null) {
final Ident idNewLong = diagram.buildLeafIdent(partition); final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(partition), false);
final Code codeP = diagram.buildCode(partition); diagram.gotoGroup(quark, Display.getWithNewlines(partition), GroupType.PACKAGE);
diagram.gotoGroup(idNewLong, codeP, Display.getWithNewlines(partition), GroupType.PACKAGE,
diagram.getRootGroup(), NamespaceStrategy.SINGLE);
} }
final Ident quotedIdent = diagram.buildLeafIdent(quotedString);
final Code quotedCode = diagram.buildCode(quotedString); final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(quotedString), false);
final LeafType type = getTypeIfExisting(diagram, quotedCode);
final IEntity result = diagram.getOrCreate(quotedIdent, quotedCode, Display.getWithNewlines(quoted.get(0)), final LeafType type = getTypeIfExisting(diagram, quark);
type); EntityImp result = (EntityImp) quark.getData();
if (result == null)
result = diagram.reallyCreateLeaf(quark, Display.getWithNewlines(quoted.get(0)), type, null);
if (partition != null) if (partition != null)
diagram.endGroup(); diagram.endGroup();
@ -250,15 +254,14 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
final String quoteInvisibleString = arg.get("QUOTED_INVISIBLE" + suf, 0); final String quoteInvisibleString = arg.get("QUOTED_INVISIBLE" + suf, 0);
if (quoteInvisibleString != null) { if (quoteInvisibleString != null) {
if (partition != null) { if (partition != null) {
final Ident idNewLong = diagram.buildLeafIdent(partition); final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(partition), false);
final Code codeP = diagram.buildCode(partition); diagram.gotoGroup(quark, Display.getWithNewlines(quark), GroupType.PACKAGE);
diagram.gotoGroup(idNewLong, codeP, Display.getWithNewlines(partition), GroupType.PACKAGE,
diagram.getRootGroup(), NamespaceStrategy.SINGLE);
} }
final Ident identInvisible = diagram.buildLeafIdent(quoteInvisibleString); final Quark identInvisible = diagram.quarkInContext(diagram.cleanIdForQuark(quoteInvisibleString), false);
final Code quotedInvisible = diagram.buildCode(quoteInvisibleString); EntityImp result = (EntityImp) identInvisible.getData();
final IEntity result = diagram.getOrCreate(identInvisible, quotedInvisible, if (result == null)
Display.getWithNewlines(quotedInvisible), LeafType.ACTIVITY); result = diagram.reallyCreateLeaf(identInvisible, Display.getWithNewlines(identInvisible.getName()),
LeafType.ACTIVITY, null);
if (partition != null) if (partition != null)
diagram.endGroup(); diagram.endGroup();
@ -271,13 +274,13 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
return null; return null;
} }
private static LeafType getTypeIfExisting(ActivityDiagram system, Code code) { private static LeafType getTypeIfExisting(ActivityDiagram system, Quark code) {
if (system.leafExist(code)) { // if (code.getData() == null) {
final IEntity ent = system.getLeaf(code); // final Quark quark = system.getPlasma().getIfExistsFromName(code.getName());
if (ent.getLeafType() == LeafType.BRANCH) // final IEntity ent = quark == null ? null : (ILeaf) quark.getData();
return LeafType.BRANCH; // if (ent.getLeafType() == LeafType.BRANCH)
// return LeafType.BRANCH;
} // }
return LeafType.ACTIVITY; return LeafType.ACTIVITY;
} }

View File

@ -43,7 +43,8 @@ import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlMode; import net.sourceforge.plantuml.UrlMode;
import net.sourceforge.plantuml.activitydiagram.ActivityDiagram; import net.sourceforge.plantuml.activitydiagram.ActivityDiagram;
import net.sourceforge.plantuml.baraye.IEntity; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.classdiagram.command.CommandLinkClass; import net.sourceforge.plantuml.classdiagram.command.CommandLinkClass;
import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.CommandMultilines2; import net.sourceforge.plantuml.command.CommandMultilines2;
@ -56,16 +57,13 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexOr;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.GroupType; import net.sourceforge.plantuml.cucadiagram.GroupType;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg; import net.sourceforge.plantuml.cucadiagram.LinkArg;
import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType; import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy;
import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement; import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement;
import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.ColorType;
@ -122,7 +120,7 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
lines = lines.trim(); lines = lines.trim();
final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString());
final IEntity entity1 = CommandLinkActivity.getEntity(diagram, line0, true); final EntityImp entity1 = CommandLinkActivity.getEntity(diagram, line0, true);
if (entity1 == null) if (entity1 == null)
return CommandExecutionResult.error("No such entity"); return CommandExecutionResult.error("No such entity");
@ -178,15 +176,16 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
partition = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(partition); partition = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(partition);
} }
if (partition != null) { if (partition != null) {
final Ident idNewLong = diagram.buildLeafIdent(partition); final Quark idNewLong = diagram.quarkInContext(diagram.cleanIdForQuark(partition), false);
diagram.gotoGroup(idNewLong, diagram.buildCode(partition), Display.getWithNewlines(partition), diagram.gotoGroup(idNewLong, Display.getWithNewlines(partition), GroupType.PACKAGE);
GroupType.PACKAGE, null, NamespaceStrategy.SINGLE);
} }
final Ident ident = diagram.buildLeafIdent(idShort); final Quark ident = diagram.quarkInContext(diagram.cleanIdForQuark(idShort), false);
final Code code = diagram.buildCode(idShort);
final IEntity entity2 = diagram.getOrCreate(ident, code, Display.getWithNewlines(display), LeafType.ACTIVITY); EntityImp entity2 = (EntityImp) ident.getData();
if (entity2 == null) if (entity2 == null)
return CommandExecutionResult.error("No such entity"); entity2 = diagram.reallyCreateLeaf(ident, Display.getWithNewlines(display), LeafType.ACTIVITY, null);
diagram.setLastEntityConsulted(entity2);
if (partition != null) if (partition != null)
diagram.endGroup(); diagram.endGroup();
@ -217,7 +216,7 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
type = type.goDotted(); type = type.goDotted();
final LinkArg linkArg = LinkArg.build(linkLabel, lenght, diagram.getSkinParam().classAttributeIconSize() > 0); final LinkArg linkArg = LinkArg.build(linkLabel, lenght, diagram.getSkinParam().classAttributeIconSize() > 0);
Link link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), entity1, Link link = new Link(diagram.getEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), entity1,
entity2, type, linkArg); entity2, type, linkArg);
final Direction direction = StringUtils.getArrowDirection(arrowBody1 + arrowDirection + arrowBody2 + ">"); final Direction direction = StringUtils.getArrowDirection(arrowBody1 + arrowDirection + arrowBody2 + ">");
if (direction == Direction.LEFT || direction == Direction.UP) if (direction == Direction.LEFT || direction == Direction.UP)

View File

@ -35,10 +35,9 @@
*/ */
package net.sourceforge.plantuml.activitydiagram.command; package net.sourceforge.plantuml.activitydiagram.command;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.activitydiagram.ActivityDiagram; import net.sourceforge.plantuml.activitydiagram.ActivityDiagram;
import net.sourceforge.plantuml.baraye.IEntity; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.baraye.IGroup; import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.IRegex;
@ -46,11 +45,8 @@ import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexOr;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.GroupType; import net.sourceforge.plantuml.cucadiagram.GroupType;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy;
import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorParser;
import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.ColorType;
@ -87,13 +83,13 @@ public class CommandPartition extends SingleLineCommand2<ActivityDiagram> {
@Override @Override
protected CommandExecutionResult executeArg(ActivityDiagram diagram, LineLocation location, RegexResult arg) protected CommandExecutionResult executeArg(ActivityDiagram diagram, LineLocation location, RegexResult arg)
throws NoSuchColorException { throws NoSuchColorException {
final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("NAME", 0)); final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(arg.get("NAME", 0)), false);
final Ident ident = diagram.buildLeafIdent(idShort); // final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("NAME", 0));
final Code code = diagram.buildCode(idShort); // final Quark ident = diagram.buildFromName(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(idShort));
final IGroup currentPackage = diagram.getCurrentGroup(); // final Quark code = diagram.buildFromFullPath(idShort);
diagram.gotoGroup(ident, code, Display.getWithNewlines(code), GroupType.PACKAGE, currentPackage,
NamespaceStrategy.SINGLE); diagram.gotoGroup(quark, Display.getWithNewlines(quark.getName()), GroupType.PACKAGE);
final IEntity p = diagram.getCurrentGroup(); final EntityImp p = diagram.getCurrentGroup();
final Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet()); final Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet());
if (colors.isEmpty() == false) { if (colors.isEmpty() == false) {

View File

@ -45,7 +45,6 @@ import net.sourceforge.plantuml.awt.geom.XPoint2D;
import net.sourceforge.plantuml.graphic.Rainbow; import net.sourceforge.plantuml.graphic.Rainbow;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
public class FtileFactoryDelegatorAssembly extends FtileFactoryDelegator { public class FtileFactoryDelegatorAssembly extends FtileFactoryDelegator {

View File

@ -47,6 +47,7 @@ import net.sourceforge.plantuml.awt.geom.XPoint2D;
import net.sourceforge.plantuml.ugraphic.MinMax; import net.sourceforge.plantuml.ugraphic.MinMax;
public class AffineTransformation { public class AffineTransformation {
// ::remove folder when WASM
static private final Pattern rotate = Pattern.compile("rotate\\s+(-?\\d+\\.?\\d*)"); static private final Pattern rotate = Pattern.compile("rotate\\s+(-?\\d+\\.?\\d*)");
static private final Pattern shear = Pattern.compile("shear\\s+(-?\\d+\\.?\\d*)\\s+(-?\\d+\\.?\\d*)"); static private final Pattern shear = Pattern.compile("shear\\s+(-?\\d+\\.?\\d*)\\s+(-?\\d+\\.?\\d*)");

View File

@ -54,6 +54,7 @@ import net.sourceforge.plantuml.security.SFile;
import net.sourceforge.plantuml.security.SecurityUtils; import net.sourceforge.plantuml.security.SecurityUtils;
public class CheckZipTask extends Task { public class CheckZipTask extends Task {
// ::remove folder when WASM
private String zipfile = null; private String zipfile = null;
private List<FileSet> filesets = new ArrayList<>(); private List<FileSet> filesets = new ArrayList<>();

View File

@ -42,6 +42,7 @@ import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleSignatureBasic; import net.sourceforge.plantuml.style.StyleSignatureBasic;
public abstract class AbstractComponentText implements Component { public abstract class AbstractComponentText implements Component {
// ::remove folder when WASM
public final XDimension2D getPreferredDimension(StringBounder stringBounder) { public final XDimension2D getPreferredDimension(StringBounder stringBounder) {
final double w = getPreferredWidth(stringBounder); final double w = getPreferredWidth(stringBounder);
@ -57,5 +58,4 @@ public abstract class AbstractComponentText implements Component {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
} }

View File

@ -50,15 +50,13 @@ import java.util.concurrent.atomic.AtomicInteger;
import net.sourceforge.plantuml.BackSlash; import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.api.ImageDataSimple; import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.CodeImpl;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.EntityGender; import net.sourceforge.plantuml.cucadiagram.EntityGender;
import net.sourceforge.plantuml.cucadiagram.EntityPortion; import net.sourceforge.plantuml.cucadiagram.EntityPortion;
@ -67,17 +65,14 @@ import net.sourceforge.plantuml.cucadiagram.GroupHierarchy;
import net.sourceforge.plantuml.cucadiagram.GroupType; import net.sourceforge.plantuml.cucadiagram.GroupType;
import net.sourceforge.plantuml.cucadiagram.HideOrShow2; import net.sourceforge.plantuml.cucadiagram.HideOrShow2;
import net.sourceforge.plantuml.cucadiagram.ICucaDiagram; import net.sourceforge.plantuml.cucadiagram.ICucaDiagram;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkConstraint; import net.sourceforge.plantuml.cucadiagram.LinkConstraint;
import net.sourceforge.plantuml.cucadiagram.Magma; import net.sourceforge.plantuml.cucadiagram.Magma;
import net.sourceforge.plantuml.cucadiagram.MagmaList; import net.sourceforge.plantuml.cucadiagram.MagmaList;
import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy;
import net.sourceforge.plantuml.cucadiagram.PortionShower; import net.sourceforge.plantuml.cucadiagram.PortionShower;
import net.sourceforge.plantuml.cucadiagram.Together; import net.sourceforge.plantuml.cucadiagram.Together;
import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramTxtMaker; import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramTxtMaker;
import net.sourceforge.plantuml.cucadiagram.entity.IEntityFactory;
import net.sourceforge.plantuml.elk.CucaDiagramFileMakerElk; import net.sourceforge.plantuml.elk.CucaDiagramFileMakerElk;
import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.graphml.CucaDiagramGraphmlMaker; import net.sourceforge.plantuml.graphml.CucaDiagramGraphmlMaker;
@ -88,64 +83,57 @@ import net.sourceforge.plantuml.statediagram.StateDiagram;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft; import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.svek.CucaDiagramFileMaker; import net.sourceforge.plantuml.svek.CucaDiagramFileMaker;
import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek; import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek;
import net.sourceforge.plantuml.utils.Log;
import net.sourceforge.plantuml.xmi.CucaDiagramXmiMaker; import net.sourceforge.plantuml.xmi.CucaDiagramXmiMaker;
import net.sourceforge.plantuml.xmlsc.StateDiagramScxmlMaker; import net.sourceforge.plantuml.xmlsc.StateDiagramScxmlMaker;
public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, PortionShower, ICucaDiagram { public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, PortionShower, ICucaDiagram {
static public final boolean QUARK = false;
private String namespaceSeparator = null; private String namespaceSeparator = null;
private boolean namespaceSeparatorHasBeenSet = false; private boolean namespaceSeparatorHasBeenSet = false;
public Quark currentQuark() { public final boolean mergeIntricated() {
throw new UnsupportedOperationException(); return false;
}
public /* protected */ Plasma getPlasma() {
throw new UnsupportedOperationException();
} }
private final List<HideOrShow2> hides2 = new ArrayList<>(); private final List<HideOrShow2> hides2 = new ArrayList<>();
private final List<HideOrShow2> removed = new ArrayList<>(); private final List<HideOrShow2> removed = new ArrayList<>();
protected final EntityFactory entityFactory = new EntityFactory(hides2, removed, this); protected final EntityFactory entityFactory = new EntityFactory(hides2, removed, this);
private IGroup currentGroup = entityFactory.getRootGroup();
private List<Ident> stacks2 = new ArrayList<>(); private List<Quark> stacks = new ArrayList<>();
private List<IGroup> stacks = new ArrayList<>();
private boolean visibilityModifierPresent; private boolean visibilityModifierPresent;
private NamespaceStrategy lastNamespaceStrategy; // private NamespaceStrategy lastNamespaceStrategy;
private Together currentTogether; private Together currentTogether;
public abstract IEntity getOrCreateLeaf(Ident ident, Code code, LeafType type, USymbol symbol);
public Ident cleanIdent(Ident ident) {
return ident;
}
public CucaDiagram(UmlSource source, UmlDiagramType type, Map<String, String> orig) { public CucaDiagram(UmlSource source, UmlDiagramType type, Map<String, String> orig) {
super(source, type, orig); super(source, type, orig);
this.stacks2.add(Ident.empty()); this.stacks.add(entityFactory.getPlasma().root());
} }
final public String getPortFor(String ent1String, Ident ident1) { public String getPortFor(String entString, Quark ident) {
final int x = entString.lastIndexOf("::");
if (x == -1)
return null;
if (entString.startsWith(ident.getName()))
return entString.substring(x + 2);
return null; return null;
} }
private Ident getLastID() { public Quark currentQuark() {
if (stacks2.size() == 0) { return this.stacks.get(stacks.size() - 1);
// Thread.dumpStack();
return Ident.empty();
// throw new IllegalArgumentException();
} }
return this.stacks2.get(stacks2.size() - 1);
public String cleanIdForQuark(String id) {
if (id == null)
return null;
return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(id);
} }
final public void setNamespaceSeparator(String namespaceSeparator) { final public void setNamespaceSeparator(String namespaceSeparator) {
this.namespaceSeparatorHasBeenSet = true; this.namespaceSeparatorHasBeenSet = true;
this.namespaceSeparator = namespaceSeparator; this.namespaceSeparator = namespaceSeparator;
getPlasma().setSeparator(namespaceSeparator);
} }
final public String getNamespaceSeparator() { final public String getNamespaceSeparator() {
@ -157,103 +145,127 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
@Override @Override
public boolean hasUrl() { public boolean hasUrl() {
for (IEntity entity : getGroups(true)) for (Quark quark : getPlasma().quarks()) {
if (entity.hasUrl()) final EntityImp ent = (EntityImp) quark.getData();
return true; if (ent != null && ent.hasUrl())
for (IEntity entity : entityFactory.leafs())
if (entity.hasUrl())
return true;
for (Link link : getLinks())
if (link.hasUrl())
return true; return true;
}
return false; return false;
} }
final public void setLastEntity(ILeaf foo) { final public void setLastEntity(EntityImp foo) {
this.lastEntity = foo; this.lastEntity = (EntityImp) foo;
} }
final protected ILeaf getOrCreateLeafDefault(Ident idNewLong, Code code, LeafType type, USymbol symbol) { protected void updateLasts(EntityImp result) {
Objects.requireNonNull(idNewLong); }
final public EntityImp reallyCreateLeaf(Quark ident, Display display, LeafType type, USymbol symbol) {
Objects.requireNonNull(type); Objects.requireNonNull(type);
ILeaf result = entityFactory.getLeaf(code); if (ident.getData() != null)
throw new IllegalStateException();
if (result == null) {
result = createLeafInternal(idNewLong, code, Display.getWithNewlines(code), type, symbol);
result.setUSymbol(symbol);
}
if (result.getLeafType() == LeafType.CLASS && type == LeafType.OBJECT)
if (result.muteToType(type, symbol) == false)
return null;
this.lastEntity = result;
return result;
}
public ILeaf createLeaf(Ident idNewLong, Code code, Display display, LeafType type, USymbol symbol) {
Objects.requireNonNull(idNewLong);
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) {
Objects.requireNonNull(newIdent);
if (Display.isNull(display)) if (Display.isNull(display))
display = Display.getWithNewlines(code).withCreoleMode(CreoleMode.SIMPLE_LINE); throw new IllegalArgumentException();
final EntityImp result = entityFactory.createLeaf(ident, display, type, getHides());
result.setUSymbol(symbol);
ident.setData(result);
this.lastEntity = result;
result.setTogether(currentTogether);
updateLasts(result);
// if (type == LeafType.OBJECT)
// ((EntityImp) parent.getData()).muteToType2(type);
return result;
final ILeaf leaf = entityFactory.createLeaf(currentTogether, newIdent, code, display, type, getCurrentGroup(),
getHides(), getNamespaceSeparator());
entityFactory.addLeaf(leaf);
this.lastEntity = leaf;
leaf.setUSymbol(symbol);
return leaf;
} }
final public Ident buildLeafIdent(String id) { final public Quark quarkInContext(String full, boolean specialForCreateClass) {
return getLastID().add(id, getNamespaceSeparator()); final String sep = getNamespaceSeparator();
if (sep == null) {
final Quark result = getPlasma().getIfExistsFromName(full);
if (result != null)
return result;
return currentQuark().child(full);
} }
final public Ident buildLeafIdentSpecial(String id) { final Quark currentQuark = currentQuark();
return buildFullyQualified(id); if (full.startsWith(sep))
return getPlasma().root().child(full.substring(sep.length()));
final int x = full.indexOf(sep);
if (x == -1) {
if (specialForCreateClass == false && getPlasma().countByName(full) == 1) {
final Quark byName = getPlasma().getIfExistsFromName(full);
assert byName != null;
if (byName != currentQuark)
return byName;
}
return currentQuark.child(full);
} }
final public Ident buildLeafIdentSpecial2(String id) { final String first = full.substring(0, x);
return buildFullyQualified(id); final boolean firstPackageDoesExist = getPlasma().root().childIfExists(first) != null;
if (firstPackageDoesExist)
return getPlasma().root().child(full);
return currentQuark.child(full);
} }
final public Ident buildFullyQualified(String id) { public String removePortId(String id) {
return entityFactory.buildFullyQualified(getLastID(), Ident.empty().add(id, getNamespaceSeparator())); // To be kept
if ("::".equals(namespaceSeparator))
return id;
final int x = id.lastIndexOf("::");
if (x == -1)
return id;
return id.substring(0, x);
} }
final public Code buildCode(String s) { public String getPortId(String id) {
return CodeImpl.of(s); // To be kept
if ("::".equals(namespaceSeparator))
return null;
final int x = id.lastIndexOf("::");
if (x == -1)
return null;
return id.substring(x + 2);
} }
public boolean leafExist(Code code) { public /* protected */ Plasma getPlasma() {
return entityFactory.getLeaf(code) != null; return entityFactory.getPlasma();
} }
public boolean leafExistStrict(Ident ident) { final public Collection<EntityImp> getChildrenGroups(EntityImp parent) {
return entityFactory.getLeafStrict(ident) != null; final Collection<EntityImp> result = new ArrayList<>();
}
final public Collection<IGroup> getChildrenGroups(IGroup parent) { final Quark parent__;
final Collection<IGroup> result = new ArrayList<>(); if (parent.instanceofGroupRoot())
for (IGroup gg : getGroups(false)) parent__ = getPlasma().root();
if (gg.getParentContainer() == parent) else
parent__ = ((EntityImp) parent).getQuark();
for (EntityImp gg : getGroups(false))
if (gg.getQuark().getParent() == parent__)
result.add(gg); result.add(gg);
return Collections.unmodifiableCollection(result); return Collections.unmodifiableCollection(result);
} }
private void eventuallyBuildPhantomGroups() {
for (Quark quark : getPlasma().quarks()) {
if (quark.getData() != null)
continue;
int countChildren = quark.countChildren();
if (countChildren > 0) {
final Display display = Display.getWithNewlines(quark.getQualifiedName());
final EntityImp result = entityFactory.createGroup(quark, display, GroupType.PACKAGE, getHides());
quark.setData(result);
}
}
}
final public CommandExecutionResult gotoTogether() { final public CommandExecutionResult gotoTogether() {
if (currentTogether != null) if (currentTogether != null)
return CommandExecutionResult.error("Cannot nest together"); return CommandExecutionResult.error("Cannot nest together");
@ -262,69 +274,21 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();
} }
final public CommandExecutionResult gotoGroup(Ident ident, Code code, Display display, GroupType type, final public CommandExecutionResult gotoGroup(Quark ident, Display display, GroupType type) {
IGroup parent, NamespaceStrategy strategy) {
if (currentTogether != null) if (currentTogether != null)
return CommandExecutionResult.error("Cannot be done inside 'together'"); return CommandExecutionResult.error("Cannot be done inside 'together'");
if (this.lastNamespaceStrategy != null && strategy != this.lastNamespaceStrategy) if (ident.getData() == null) {
return CommandExecutionResult.error("Cannot mix packages and namespaces"); final EntityImp result = entityFactory.createGroup(ident, display, type, getHides());
this.lastNamespaceStrategy = strategy; ident.setData(result);
if (strategy == NamespaceStrategy.MULTIPLE) {
if (getNamespaceSeparator() != null)
code = getFullyQualifiedCode1972(code);
gotoGroupInternalWithNamespace(ident, code, display, code, type, parent);
} else if (strategy == NamespaceStrategy.SINGLE) {
final Ident newIdLong = buildLeafIdentSpecial(ident.toString(this.getNamespaceSeparator()));
gotoGroupExternal(newIdLong, code, display, null, type, parent);
stacks2.add(newIdLong);
} else {
throw new IllegalArgumentException();
} }
final EntityImp ent = (EntityImp) ident.getData();
ent.setDisplay(display);
ent.muteToType2(type);
this.stacks.add(ident);
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();
}
protected final String getNamespace1972(Code fullyCode, String separator) {
String name = fullyCode.getName();
Objects.requireNonNull(separator);
do {
final int x = name.lastIndexOf(separator);
if (x == -1)
return null;
name = name.substring(0, x);
} while (entityFactory.getLeaf(buildCode(name)) != null);
return name;
}
private void gotoGroupInternalWithNamespace(Ident idNewLong, Code code, Display display, Code namespaceNew,
GroupType type, IGroup parent) {
this.stacks.add(currentGroup);
this.stacks2.add(idNewLong);
if (getNamespaceSeparator() == null) {
gotoGroupInternal(idNewLong, code, display, namespaceNew, type, parent);
return;
}
final String namespaceCurrent = getNamespace1972(code, getNamespaceSeparator());
if (namespaceCurrent == null) {
gotoGroupInternal(idNewLong, code, display, namespaceNew, type, parent);
return;
}
final IGroup realParent = entityFactory.getGroup(buildCode(namespaceCurrent));
if (realParent == null) {
gotoGroupInternal(idNewLong, code, display, namespaceNew, type, parent);
return;
}
display = Display.create(idNewLong.getLast());
IGroup result = entityFactory.createGroup(idNewLong, code, display, namespaceNew, type, realParent, getHides(),
getNamespaceSeparator());
entityFactory.addGroup(result);
currentGroup = result;
} }
@ -335,145 +299,75 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
return true; return true;
} }
// if (currentGroup.getGroupType() == GroupType.TOGETHER) { if (stacks.size() > 0) {
// currentGroup = currentGroup.getParentContainer(); stacks.remove(stacks.size() - 1);
// return true;
// }
if (stacks2.size() > 0) {
// Thread.dumpStack();
stacks2.remove(stacks2.size() - 1);
}
if (EntityUtils.groupRoot(currentGroup)) {
Log.error("No parent group");
return false;
}
if (stacks.size() > 0)
currentGroup = stacks.remove(stacks.size() - 1);
else
currentGroup = currentGroup.getParentContainer();
return true; return true;
} }
private void gotoGroupInternal(Ident idNewLong, final Code code, Display display, final Code namespace, return false;
GroupType type, IGroup parent) {
IGroup result = entityFactory.getGroup(code);
if (result != null) {
currentGroup = result;
return;
} }
if (entityFactory.getLeafStrict(idNewLong) != null) {
result = entityFactory.muteToGroup(code.getName(), namespace, type, parent); public final EntityImp getCurrentGroup() {
result.setDisplay(display); return (EntityImp) currentQuark().getData();
}
public final EntityImp getGroup(String code) {
final Quark quark = getPlasma().getIfExistsFromName(code);
if (quark == null)
return null;
return (EntityImp) quark.getData();
}
public final boolean isGroup(String code) {
final Quark quark = getPlasma().getIfExistsFromName(code);
if (quark == null)
return false;
return isGroup(quark);
}
public final boolean isGroup(final Quark quark) {
final EntityImp ent = (EntityImp) quark.getData();
if (ent == null)
return false;
return ent.isGroup();
}
public final Collection<EntityImp> getGroups(boolean withRootGroup) {
final List<EntityImp> result = new ArrayList<>();
for (Quark quark : getPlasma().quarks()) {
if (quark.isRoot()) {
if (withRootGroup)
result.add((EntityImp) quark.getData());
} else { } else {
result = entityFactory.createGroup(idNewLong, code, display, namespace, type, parent, getHides(), final EntityImp data = (EntityImp) quark.getData();
getNamespaceSeparator()); if (data != null && data.isGroup())
result.add(data);
} }
entityFactory.addGroup(result);
currentGroup = result;
} }
final protected void gotoGroupExternal(Ident newIdLong, final Code code, Display display, final Code namespace,
GroupType type, IGroup parent) {
IGroup result = entityFactory.getGroup(code);
if (result != null) {
currentGroup = result;
return;
}
if (entityFactory.getLeaf(code) != null) {
result = entityFactory.muteToGroup(code.getName(), namespace, type, parent);
result.setDisplay(display);
} else {
result = entityFactory.createGroup(newIdLong, code, display, namespace, type, parent, getHides(),
getNamespaceSeparator());
}
entityFactory.addGroup(result);
// entityFactory.thisIsNotArealGroup(newIdLong);
currentGroup = result;
}
public final void gotoThisGroup(IGroup group) {
currentGroup = group;
}
final protected Code getFullyQualifiedCode1972(Code code) {
final String separator = Objects.requireNonNull(getNamespaceSeparator());
final String full = code.getName();
if (full.startsWith(separator))
return buildCode(full.substring(separator.length()));
if (full.contains(separator))
return buildCode(full);
if (EntityUtils.groupRoot(currentGroup))
return buildCode(full);
final Code namespace = currentGroup.getNamespace();
if (namespace == null)
return buildCode(full);
return buildCode(namespace.getName() + separator + full);
}
public final IGroup getCurrentGroup() {
return currentGroup;
}
public final IGroup getGroup(Code code) {
final IGroup p = entityFactory.getGroup(code);
return Objects.requireNonNull(p);
}
public final IGroup getGroupStrict(Ident ident) {
throw new UnsupportedOperationException();
}
public final IGroup getGroupVerySmart(Ident ident) {
throw new UnsupportedOperationException();
}
public final boolean isGroup(Code code) {
return leafExist(code) == false && entityFactory.getGroup(code) != null;
}
public final boolean isGroupStrict(Ident ident) {
throw new UnsupportedOperationException();
}
public final boolean isGroupVerySmart(Ident ident) {
throw new UnsupportedOperationException();
}
public final Collection<IGroup> getGroups(boolean withRootGroup) {
if (withRootGroup == false)
return entityFactory.groups();
final Collection<IGroup> result = new ArrayList<>();
result.add(getRootGroup());
result.addAll(entityFactory.groups());
return Collections.unmodifiableCollection(result); return Collections.unmodifiableCollection(result);
} }
public IGroup getRootGroup() { public EntityImp getRootGroup() {
return entityFactory.getRootGroup(); return (EntityImp) getPlasma().root().getData();
} }
public final Collection<ILeaf> getLeafsvalues() { public final Collection<EntityImp> getLeafsvalues() {
return entityFactory.leafs2(); final List<EntityImp> result = new ArrayList<>();
for (Quark quark : getPlasma().quarks()) {
if (quark.isRoot())
continue;
final EntityImp data = (EntityImp) quark.getData();
if (data != null && data.isGroup() == false)
result.add(data);
}
return Collections.unmodifiableCollection(result);
} }
public final int getLeafssize() { public final int getLeafssize() {
return getLeafsvalues().size(); return getLeafsvalues().size();
} }
public final ILeaf getLeaf(Code code) {
return entityFactory.getLeaf(code);
}
public final ILeaf getLeafStrict(Ident ident) {
return entityFactory.getLeafStrict(ident);
}
final public void addLink(Link link) { final public void addLink(Link link) {
entityFactory.addLink(link); entityFactory.addLink(link);
} }
@ -506,6 +400,7 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
return result.toArray(new String[result.size()]); return result.toArray(new String[result.size()]);
} }
// ::comment when WASM
private void createFilesGraphml(OutputStream suggestedFile) throws IOException { private void createFilesGraphml(OutputStream suggestedFile) throws IOException {
final CucaDiagramGraphmlMaker maker = new CucaDiagramGraphmlMaker(this); final CucaDiagramGraphmlMaker maker = new CucaDiagramGraphmlMaker(this);
maker.createFiles(suggestedFile); maker.createFiles(suggestedFile);
@ -521,11 +416,18 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
maker.createFiles(suggestedFile); maker.createFiles(suggestedFile);
} }
private void createFilesTxt(OutputStream os, int index, FileFormat fileFormat) throws IOException {
final CucaDiagramTxtMaker maker = new CucaDiagramTxtMaker(this, fileFormat);
maker.createFiles(os, index);
}
// ::done
@Override @Override
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException { throws IOException {
final FileFormat fileFormat = fileFormatOption.getFileFormat(); final FileFormat fileFormat = fileFormatOption.getFileFormat();
// ::comment when WASM
if (fileFormat == FileFormat.ATXT || fileFormat == FileFormat.UTXT) { if (fileFormat == FileFormat.ATXT || fileFormat == FileFormat.UTXT) {
try { try {
createFilesTxt(os, index, fileFormat); createFilesTxt(os, index, fileFormat);
@ -549,18 +451,24 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
createFilesScxml(os); createFilesScxml(os);
return ImageDataSimple.ok(); return ImageDataSimple.ok();
} }
// ::done
if (getUmlDiagramType() == UmlDiagramType.COMPOSITE) { if (getUmlDiagramType() == UmlDiagramType.COMPOSITE) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
this.eventuallyBuildPhantomGroups();
final CucaDiagramFileMaker maker; final CucaDiagramFileMaker maker;
// ::comment when WASM
if (this.isUseElk()) if (this.isUseElk())
maker = new CucaDiagramFileMakerElk(this, fileFormatOption.getDefaultStringBounder(getSkinParam())); maker = new CucaDiagramFileMakerElk(this, fileFormatOption.getDefaultStringBounder(getSkinParam()));
else if (this.isUseSmetana()) else if (this.isUseSmetana())
// ::done
maker = new CucaDiagramFileMakerSmetana(this, fileFormatOption.getDefaultStringBounder(getSkinParam())); maker = new CucaDiagramFileMakerSmetana(this, fileFormatOption.getDefaultStringBounder(getSkinParam()));
// ::comment when WASM
else else
maker = new CucaDiagramFileMakerSvek(this); maker = new CucaDiagramFileMakerSvek(this);
// ::done
final ImageData result = maker.createFile(os, getDotStrings(), fileFormatOption); final ImageData result = maker.createFile(os, getDotStrings(), fileFormatOption);
@ -585,15 +493,7 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
return generalWarningOrError + BackSlash.NEWLINE + warningOrError; return generalWarningOrError + BackSlash.NEWLINE + warningOrError;
} }
private void createFilesTxt(OutputStream os, int index, FileFormat fileFormat) throws IOException { public boolean isAutarkic(EntityImp g) {
final CucaDiagramTxtMaker maker = new CucaDiagramTxtMaker(this, fileFormat);
maker.createFiles(os, index);
}
public boolean isAutarkic(IGroup g) {
// if (g.getGroupType() == GroupType.TOGETHER)
// return false;
if (g.getGroupType() == GroupType.PACKAGE) if (g.getGroupType() == GroupType.PACKAGE)
return false; return false;
@ -613,7 +513,7 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
if (EntityUtils.isPureInnerLink3(g, link) == false) if (EntityUtils.isPureInnerLink3(g, link) == false)
return false; return false;
for (ILeaf leaf : g.getLeafsDirect()) for (EntityImp leaf : g.getLeafsDirect())
if (leaf.getEntityPosition() != EntityPosition.NORMAL) if (leaf.getEntityPosition() != EntityPosition.NORMAL)
return false; return false;
@ -663,8 +563,8 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
return "25"; return "25";
} }
final public boolean isEmpty(IGroup gToTest) { final public boolean isEmpty(EntityImp gToTest) {
for (IEntity gg : getGroups(false)) { for (EntityImp gg : getGroups(false)) {
if (gg == gToTest) if (gg == gToTest)
continue; continue;
@ -683,7 +583,7 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
this.visibilityModifierPresent = visibilityModifierPresent; this.visibilityModifierPresent = visibilityModifierPresent;
} }
public final boolean showPortion(EntityPortion portion, IEntity entity) { public final boolean showPortion(EntityPortion portion, EntityImp entity) {
if (getSkinParam().strictUmlStyle() && portion == EntityPortion.CIRCLED_CHARACTER) if (getSkinParam().strictUmlStyle() && portion == EntityPortion.CIRCLED_CHARACTER)
return false; return false;
@ -735,7 +635,7 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
return Collections.unmodifiableSet(hides); return Collections.unmodifiableSet(hides);
} }
final public boolean isStandalone(IEntity ent) { final public boolean isStandalone(EntityImp ent) {
for (final Link link : getLinks()) for (final Link link : getLinks())
if (link.getEntity1() == ent || link.getEntity2() == ent) if (link.getEntity1() == ent || link.getEntity2() == ent)
return false; return false;
@ -743,7 +643,7 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
return true; return true;
} }
final public boolean isStandaloneForArgo(IEntity ent) { final public boolean isStandaloneForArgo(EntityImp ent) {
for (final Link link : getLinks()) { for (final Link link : getLinks()) {
if (link.isHidden() || link.isInvis()) if (link.isHidden() || link.isInvis())
continue; continue;
@ -780,27 +680,24 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
return null; return null;
} }
private ILeaf lastEntity = null; protected EntityImp lastEntity = null;
final public ILeaf getLastEntity() { final public EntityImp getLastEntity() {
return lastEntity; return lastEntity;
} }
final public IEntityFactory getIEntityFactory() {
return entityFactory;
}
final public EntityFactory getEntityFactory() { final public EntityFactory getEntityFactory() {
// throw new UnsupportedOperationException();
return entityFactory; return entityFactory;
} }
public void applySingleStrategy() { public void applySingleStrategy() {
final MagmaList magmaList = new MagmaList(); final MagmaList magmaList = new MagmaList();
for (IGroup g : getGroups(true)) { for (EntityImp g : getGroups(true)) {
final List<ILeaf> standalones = new ArrayList<>(); final List<EntityImp> standalones = new ArrayList<>();
for (ILeaf ent : g.getLeafsDirect()) for (EntityImp ent : g.getLeafsDirect())
if (isStandalone(ent)) if (isStandalone(ent))
standalones.add(ent); standalones.add(ent);
@ -812,7 +709,7 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
magmaList.add(magma); magmaList.add(magma);
} }
for (IGroup g : getGroups(true)) { for (EntityImp g : getGroups(true)) {
final MagmaList magmas = magmaList.getMagmas(g); final MagmaList magmas = magmaList.getMagmas(g);
if (magmas.size() < 3) if (magmas.size() < 3)
continue; continue;

View File

@ -38,11 +38,7 @@ package net.sourceforge.plantuml.baraye;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
@ -51,73 +47,58 @@ import net.sourceforge.plantuml.cucadiagram.Bodier;
import net.sourceforge.plantuml.cucadiagram.BodierJSon; import net.sourceforge.plantuml.cucadiagram.BodierJSon;
import net.sourceforge.plantuml.cucadiagram.BodierMap; import net.sourceforge.plantuml.cucadiagram.BodierMap;
import net.sourceforge.plantuml.cucadiagram.BodyFactory; import net.sourceforge.plantuml.cucadiagram.BodyFactory;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.GroupRoot;
import net.sourceforge.plantuml.cucadiagram.GroupType; import net.sourceforge.plantuml.cucadiagram.GroupType;
import net.sourceforge.plantuml.cucadiagram.HideOrShow2; import net.sourceforge.plantuml.cucadiagram.HideOrShow2;
import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.ICucaDiagram;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.Stereotag;
import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.cucadiagram.Together;
import net.sourceforge.plantuml.cucadiagram.entity.IEntityFactory; import net.sourceforge.plantuml.cucadiagram.entity.IEntityFactory;
import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.skin.VisibilityModifier; import net.sourceforge.plantuml.skin.VisibilityModifier;
public final class EntityFactory implements IEntityFactory { public final class EntityFactory implements IEntityFactory {
private final Map<String, ILeaf> leafsByCode;
private final Map<String, IGroup> groupsByCode;
/* private */public final Map<Ident, ILeaf> leafs2 = new LinkedHashMap<Ident, ILeaf>();
/* private */public final Map<Ident, IGroup> groups2 = new LinkedHashMap<Ident, IGroup>();
private final List<Link> links = new ArrayList<>(); private final List<Link> links = new ArrayList<>();
private int rawLayout; private int rawLayout;
private final IGroup rootGroup = new GroupRoot(this); private final Plasma plasma;
private final EntityImp rootGroup;
private final List<HideOrShow2> hides2; private final List<HideOrShow2> hides2;
private final List<HideOrShow2> removed; private final List<HideOrShow2> removed;
/* private */ final public CucaDiagram namespaceSeparator; /* private */ final public ICucaDiagram namespaceSeparator;
private Map<IGroup, ILeaf> emptyGroupsAsNode = new HashMap<IGroup, ILeaf>();
public ILeaf getLeafForEmptyGroup(IGroup g) { public EntityImp getLeafForEmptyGroup(EntityImp g) {
return emptyGroupsAsNode.get(g); throw new UnsupportedOperationException();
} }
public ILeaf createLeafForEmptyGroup(IGroup g, ISkinParam skinParam) { public EntityImp createLeafForEmptyGroup(EntityImp g, ISkinParam skinPdaram) {
final ILeaf folder = this.createLeaf(null, g.getIdent(), g.getCode(), g.getDisplay(), LeafType.EMPTY_PACKAGE, final EntityImp ent = (EntityImp) g;
g.getParentContainer(), null, this.namespaceSeparator.getNamespaceSeparator()); ent.muteToType2(LeafType.EMPTY_PACKAGE);
((EntityImp) folder).setOriginalGroup(g); return ent;
final USymbol symbol = g.getUSymbol();
folder.setUSymbol(symbol);
folder.setStereotype(g.getStereotype());
folder.setColors(g.getColors());
if (g.getUrl99() != null)
folder.addUrl(g.getUrl99());
for (Stereotag tag : g.stereotags())
folder.addStereotag(tag);
emptyGroupsAsNode.put(g, folder);
return folder;
} }
public EntityFactory(List<HideOrShow2> hides2, List<HideOrShow2> removed, CucaDiagram namespaceSeparator) { //
public EntityImp isIntricated(EntityImp parent) {
throw new UnsupportedOperationException();
}
public EntityFactory(List<HideOrShow2> hides2, List<HideOrShow2> removed, ICucaDiagram namespaceSeparator) {
this.hides2 = hides2; this.hides2 = hides2;
this.removed = removed; this.removed = removed;
this.namespaceSeparator = namespaceSeparator; this.namespaceSeparator = namespaceSeparator;
this.leafsByCode = new LinkedHashMap<String, ILeaf>(); this.plasma = new Plasma(".");
this.groupsByCode = new LinkedHashMap<String, IGroup>(); this.rootGroup = new EntityImp(this.plasma.root(), this, null, GroupType.ROOT, 0);
this.plasma.root().setData(rootGroup);
} }
public boolean isHidden(ILeaf leaf) { public boolean isHidden(EntityImp leaf) {
final IEntity other = isNoteWithSingleLinkAttachedTo(leaf); final EntityImp other = isNoteWithSingleLinkAttachedTo(leaf);
if (other instanceof ILeaf) if (other != null && other != leaf)
return isHidden((ILeaf) other); return isHidden(other);
boolean hidden = false; boolean hidden = false;
for (HideOrShow2 hide : hides2) for (HideOrShow2 hide : hides2)
@ -134,10 +115,10 @@ public final class EntityFactory implements IEntityFactory {
return result; return result;
} }
public boolean isRemoved(ILeaf leaf) { public boolean isRemoved(EntityImp leaf) {
final IEntity other = isNoteWithSingleLinkAttachedTo(leaf); final EntityImp other = isNoteWithSingleLinkAttachedTo(leaf);
if (other instanceof ILeaf) if (other instanceof EntityImp)
return isRemoved((ILeaf) other); return isRemoved((EntityImp) other);
boolean result = false; boolean result = false;
for (HideOrShow2 hide : removed) for (HideOrShow2 hide : removed)
@ -146,11 +127,11 @@ public final class EntityFactory implements IEntityFactory {
return result; return result;
} }
private IEntity isNoteWithSingleLinkAttachedTo(ILeaf note) { private EntityImp isNoteWithSingleLinkAttachedTo(EntityImp note) {
if (note.getLeafType() != LeafType.NOTE) if (note.getLeafType() != LeafType.NOTE)
return null; return null;
assert note.getLeafType() == LeafType.NOTE; assert note.getLeafType() == LeafType.NOTE;
IEntity other = null; EntityImp other = null;
for (Link link : this.getLinks()) { for (Link link : this.getLinks()) {
if (link.getType().isInvisible()) if (link.getType().isInvisible())
continue; continue;
@ -167,7 +148,7 @@ public final class EntityFactory implements IEntityFactory {
} }
public boolean isRemovedIgnoreUnlinked(ILeaf leaf) { public boolean isRemovedIgnoreUnlinked(EntityImp leaf) {
boolean result = false; boolean result = false;
for (HideOrShow2 hide : removed) for (HideOrShow2 hide : removed)
if (hide.isAboutUnlinked() == false) if (hide.isAboutUnlinked() == false)
@ -176,8 +157,8 @@ public final class EntityFactory implements IEntityFactory {
return result; return result;
} }
public ILeaf createLeaf(Together together, Ident ident, Code code, Display display, LeafType entityType, final public EntityImp createLeaf(Quark quark, Display display, LeafType entityType,
IGroup parentContainer, Set<VisibilityModifier> hides, String namespaceSeparator) { Set<VisibilityModifier> hides) {
final Bodier bodier; final Bodier bodier;
if (Objects.requireNonNull(entityType) == LeafType.MAP) if (Objects.requireNonNull(entityType) == LeafType.MAP)
bodier = new BodierMap(); bodier = new BodierMap();
@ -186,169 +167,68 @@ public final class EntityFactory implements IEntityFactory {
else else
bodier = BodyFactory.createLeaf(entityType, hides); bodier = BodyFactory.createLeaf(entityType, hides);
final EntityImp result = new EntityImp(ident, code, this, bodier, parentContainer, entityType, final EntityImp result = new EntityImp(quark, this, bodier, entityType, rawLayout);
namespaceSeparator, rawLayout);
bodier.setLeaf(result); bodier.setLeaf(result);
result.setDisplay(display); result.setDisplay(display);
result.setTogether(together);
return result; return result;
} }
public IGroup createGroup(Ident ident, Code code, Display display, Code namespace, GroupType groupType, public EntityImp createGroup(Quark quark, Display display, GroupType groupType, Set<VisibilityModifier> hides) {
IGroup parentContainer, Set<VisibilityModifier> hides, String namespaceSeparator) {
Objects.requireNonNull(groupType); Objects.requireNonNull(groupType);
for (Entry<Ident, IGroup> ent : groups2.entrySet()) if (quark.getData() != null)
if (ent.getKey().equals(ident)) return (EntityImp) quark.getData();
return ent.getValue(); // for (Entry<Ident, IGroup> ent : groups2.entrySet())
// if (ent.getKey().equals(ident))
// return ent.getValue();
final Bodier bodier = BodyFactory.createGroup(hides); final Bodier bodier = BodyFactory.createGroup(hides);
final EntityImp result = new EntityImp(ident, code, this, bodier, parentContainer, groupType, namespace, final EntityImp result = new EntityImp(quark, this, bodier, groupType, rawLayout);
namespaceSeparator, rawLayout);
if (Display.isNull(display) == false) if (Display.isNull(display) == false)
result.setDisplay(display); result.setDisplay(display);
return result; return result;
} }
public void addLeaf(ILeaf entity) { public EntityImp getRootGroup() {
leafsByCode.put(entity.getCodeGetName(), entity);
leafs2.put(entity.getIdent(), entity);
}
public void addGroup(IGroup group) {
groupsByCode.put(group.getCodeGetName(), group);
groups2.put(group.getIdent(), group);
}
private void ensureParentIsCreated(Ident ident) {
if (groups2.get(ident.parent()) != null)
return;
getParentContainer(ident, null);
}
public /* private */ void removeGroup(String name) {
final IEntity removed = Objects.requireNonNull(groupsByCode.remove(name));
final IEntity removed2 = groups2.remove(removed.getIdent());
if (removed != removed2) {
bigError();
}
}
public /* private */ void removeGroup(Ident ident) {
Objects.requireNonNull(groups2.remove(Objects.requireNonNull(ident)));
}
public static void bigError() {
// Thread.dumpStack();
// System.exit(0);
// throw new IllegalArgumentException();
}
public /* private */ void removeLeaf(String name) {
final IEntity removed = Objects.requireNonNull(leafsByCode.remove(Objects.requireNonNull(name)));
final IEntity removed2 = leafs2.remove(removed.getIdent());
if (removed != removed2) {
bigError();
}
}
public /* private */ void removeLeaf(Ident ident) {
final IEntity removed = leafs2.remove(Objects.requireNonNull(ident));
if (removed == null) {
System.err.println("leafs2=" + leafs2.keySet());
throw new IllegalArgumentException(ident.toString());
}
}
public IGroup muteToGroup(String name, Code namespace, GroupType type, IGroup parent) {
final ILeaf leaf = leafsByCode.get(name);
((EntityImp) leaf).muteToGroup(namespace, type, parent);
final IGroup result = (IGroup) leaf;
removeLeaf(name);
return result;
}
public IGroup getRootGroup() {
return rootGroup; return rootGroup;
} }
public final ILeaf getLeafStrict(Ident ident) { public final EntityImp getLeafStrict(Quark ident) {
return leafs2.get(ident); if (ident instanceof Quark == false)
} throw new UnsupportedOperationException();
final Quark quark = (Quark) ident;
public Ident buildFullyQualified(Ident currentPath, Ident id) { final EntityImp result = (EntityImp) quark.getData();
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) if (result == null)
for (Entry<Ident, IGroup> ent : groups2.entrySet()) throw new UnsupportedOperationException();
if (ent.getKey().getLast().equals(ident.getLast()))
return ent.getValue();
return result; return result;
} }
public final ILeaf getLeaf(Code code) { public final Collection<EntityImp> leafs() {
final ILeaf result = leafsByCode.get(code.getName());
if (result != null && result != leafs2.get(result.getIdent()))
bigError();
for (ILeaf tmp : leafsByCode.values()) final List<EntityImp> result = new ArrayList<>();
if (tmp.getIdent().equals(code)) for (Quark quark : getPlasma().quarks()) {
return tmp; if (quark.isRoot())
continue;
return result; final EntityImp data = (EntityImp) quark.getData();
if (data != null && data.isGroup() == false)
result.add(data);
} }
public final IGroup getGroup(Code code) {
final IGroup result = groupsByCode.get(code.getName());
if (result != null && result != groups2.get(result.getIdent()))
bigError();
return result;
}
public final Collection<ILeaf> leafs() {
final Collection<ILeaf> result = Collections.unmodifiableCollection(leafsByCode.values());
if (new ArrayList<>(result).equals(new ArrayList<>(leafs2())) == false)
bigError();
return result;
}
public final Collection<IGroup> groups() {
final Collection<IGroup> result = Collections.unmodifiableCollection(groupsByCode.values());
if (new ArrayList<>(result).equals(new ArrayList<>(groups2())) == false)
bigError();
return result;
}
public final Collection<IGroup> groups2() {
final Collection<IGroup> result = Collections.unmodifiableCollection(groups2.values());
return Collections.unmodifiableCollection(result); return Collections.unmodifiableCollection(result);
} }
public final Collection<ILeaf> leafs2() { public final Collection<EntityImp> groups() {
final Collection<ILeaf> result = Collections.unmodifiableCollection(leafs2.values()); final List<EntityImp> result = new ArrayList<>();
for (Quark quark : getPlasma().quarks()) {
if (quark.isRoot())
continue;
final EntityImp data = (EntityImp) quark.getData();
if (data != null && data.isGroup())
result.add(data);
}
// System.err.println("GROUPS=" + result.size());
return Collections.unmodifiableCollection(result); return Collections.unmodifiableCollection(result);
} }
public void incRawLayout() { public void incRawLayout() {
@ -381,12 +261,11 @@ public final class EntityFactory implements IEntityFactory {
} }
public IGroup getParentContainer(Ident ident, IGroup parentContainer) { public ICucaDiagram getDiagram() {
return Objects.requireNonNull(parentContainer);
}
public CucaDiagram getDiagram() {
return namespaceSeparator; return namespaceSeparator;
} }
public Plasma getPlasma() {
return plasma;
}
} }

View File

@ -50,19 +50,21 @@ import java.util.Set;
import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.Guillemet; import net.sourceforge.plantuml.Guillemet;
import net.sourceforge.plantuml.Hideable;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineConfigurable;
import net.sourceforge.plantuml.Removeable;
import net.sourceforge.plantuml.SpecificBackcolorable;
import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.command.Position; import net.sourceforge.plantuml.command.Position;
import net.sourceforge.plantuml.cucadiagram.Bodier; import net.sourceforge.plantuml.cucadiagram.Bodier;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.CucaNote; import net.sourceforge.plantuml.cucadiagram.CucaNote;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.DisplayPositioned; import net.sourceforge.plantuml.cucadiagram.DisplayPositioned;
import net.sourceforge.plantuml.cucadiagram.EntityPosition; import net.sourceforge.plantuml.cucadiagram.EntityPosition;
import net.sourceforge.plantuml.cucadiagram.GroupRoot;
import net.sourceforge.plantuml.cucadiagram.GroupType; import net.sourceforge.plantuml.cucadiagram.GroupType;
import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.ICucaDiagram;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.Stereostyles; import net.sourceforge.plantuml.cucadiagram.Stereostyles;
@ -91,13 +93,11 @@ import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.utils.Direction; import net.sourceforge.plantuml.utils.Direction;
import net.sourceforge.plantuml.utils.LineLocation; import net.sourceforge.plantuml.utils.LineLocation;
final public class EntityImp implements ILeaf, IGroup { final public class EntityImp implements SpecificBackcolorable, Hideable, Removeable, LineConfigurable {
private final EntityFactory entityFactory; private final EntityFactory entityFactory;
// Entity private Quark quark;
private/* final */Code code;
private/* final */Ident ident;
private Url url; private Url url;
@ -110,10 +110,6 @@ final public class EntityImp implements ILeaf, IGroup {
private Stereotype stereotype; private Stereotype stereotype;
private Stereostyles stereostyles = Stereostyles.NONE; private Stereostyles stereostyles = Stereostyles.NONE;
private String generic; private String generic;
private IGroup parentContainer;
// Group
private Code namespace;
private GroupType groupType; private GroupType groupType;
@ -134,7 +130,7 @@ final public class EntityImp implements ILeaf, IGroup {
private Together together; private Together together;
@Override //
public void addNote(Display note, Position position, Colors colors) { public void addNote(Display note, Position position, Colors colors) {
if (position == Position.TOP) if (position == Position.TOP)
notesTop.add(CucaNote.build(note, position, colors)); notesTop.add(CucaNote.build(note, position, colors));
@ -142,7 +138,7 @@ final public class EntityImp implements ILeaf, IGroup {
notesBottom.add(CucaNote.build(note, position, colors)); notesBottom.add(CucaNote.build(note, position, colors));
} }
@Override //
public List<CucaNote> getNotes(Position position) { public List<CucaNote> getNotes(Position position) {
if (position == Position.TOP) if (position == Position.TOP)
return Collections.unmodifiableList(notesTop); return Collections.unmodifiableList(notesTop);
@ -160,47 +156,45 @@ final public class EntityImp implements ILeaf, IGroup {
} }
// Back to Entity // Back to Entity
private EntityImp(Ident ident, EntityFactory entityFactory, Code code, Bodier bodier, IGroup parentContainer, private EntityImp(Quark quark, EntityFactory entityFactory, Bodier bodier, int rawLayout) {
String namespaceSeparator, int rawLayout) { this.quark = Objects.requireNonNull(quark);
this.ident = Objects.requireNonNull(ident); if (quark.isRoot())
this.uid = "clroot";
else
this.uid = StringUtils.getUid("cl", entityFactory.getDiagram().getUniqueSequence()); this.uid = StringUtils.getUid("cl", entityFactory.getDiagram().getUniqueSequence());
this.code = Objects.requireNonNull(code);
this.entityFactory = entityFactory; this.entityFactory = entityFactory;
this.bodier = bodier; this.bodier = bodier;
this.parentContainer = parentContainer;
this.rawLayout = rawLayout; this.rawLayout = rawLayout;
} }
public EntityImp(Ident ident, Code code, EntityFactory entityFactory, Bodier bodier, IGroup parentContainer, EntityImp(Quark quark, EntityFactory entityFactory, Bodier bodier, LeafType leafType, int rawLayout) {
LeafType leafType, String namespaceSeparator, int rawLayout) { this(Objects.requireNonNull(quark), entityFactory, bodier, rawLayout);
this(Objects.requireNonNull(ident), entityFactory, code, bodier, parentContainer, namespaceSeparator,
rawLayout);
// System.err.println("ID for leaf=" + code + " " + ident);
// ident.checkSameAs(code, namespaceSeparator);
this.leafType = leafType; this.leafType = leafType;
} }
public EntityImp(Ident ident, Code code, EntityFactory entityFactory, Bodier bodier, IGroup parentContainer, EntityImp(Quark quark, EntityFactory entityFactory, Bodier bodier, GroupType groupType, int rawLayout) {
GroupType groupType, Code namespace, String namespaceSeparator, int rawLayout) { this(Objects.requireNonNull(quark), entityFactory, bodier, rawLayout);
this(Objects.requireNonNull(ident), entityFactory, code, bodier, parentContainer, namespaceSeparator,
rawLayout);
// System.err.println("ID for group=" + code + " " + ident);
ident.checkSameAs(code, namespaceSeparator, entityFactory.namespaceSeparator);
this.groupType = groupType; this.groupType = groupType;
this.namespace = namespace;
}
public void setContainer(IGroup container) {
checkNotGroup();
this.parentContainer = Objects.requireNonNull(container);
} }
public LeafType getLeafType() { public LeafType getLeafType() {
return leafType; return leafType;
} }
public void muteToType2(LeafType newType) {
if (leafType == LeafType.CLASS && newType == LeafType.OBJECT)
bodier.muteClassToObject();
this.groupType = null;
this.leafType = newType;
}
public void muteToType2(GroupType newType) {
this.groupType = newType;
this.leafType = null;
}
public boolean muteToType(LeafType newType, USymbol newSymbol) { public boolean muteToType(LeafType newType, USymbol newSymbol) {
checkNotGroup(); // checkNotGroup();
Objects.requireNonNull(newType); Objects.requireNonNull(newType);
if (leafType != LeafType.STILL_UNKNOWN) { if (leafType != LeafType.STILL_UNKNOWN) {
if (newType == this.leafType) if (newType == this.leafType)
@ -225,16 +219,16 @@ final public class EntityImp implements ILeaf, IGroup {
return true; return true;
} }
public Code getCode() { public Quark getQuark() {
return code; return quark;
}
public String getCode() {
return getQuark().getName();
} }
public String getCodeGetName() { public String getCodeGetName() {
return getCode().getName(); return getQuark().getName();
}
public Ident getIdent() {
return ident;
} }
public Display getDisplay() { public Display getDisplay() {
@ -257,18 +251,8 @@ final public class EntityImp implements ILeaf, IGroup {
this.stereotype = stereotype; this.stereotype = stereotype;
} }
public final IGroup getParentContainer() {
return entityFactory.getParentContainer(ident, parentContainer);
// Objects.requireNonNull(parentContainer);
// return parentContainer;
}
@Override
public String toString() { public String toString() {
// return super.toString() + code + " " + display + "(" + leafType + ")[" + return quark.toString() + " " + display + "(" + leafType + ")[" + groupType + "] " + getUid();
// groupType + "] " + xposition + " "
// + getUid();
return "EntityImpl " + code + ident + " " + display + "(" + leafType + ")[" + groupType + "] " + getUid();
} }
public final Url getUrl99() { public final Url getUrl99() {
@ -346,7 +330,7 @@ final public class EntityImp implements ILeaf, IGroup {
if (leafType != LeafType.STATE) if (leafType != LeafType.STATE)
return EntityPosition.NORMAL; return EntityPosition.NORMAL;
if (getParentContainer() instanceof GroupRoot) if (quark.isRoot())
return EntityPosition.NORMAL; return EntityPosition.NORMAL;
final Stereotype stereotype = getStereotype(); final Stereotype stereotype = getStereotype();
@ -371,145 +355,11 @@ final public class EntityImp implements ILeaf, IGroup {
} }
public boolean containsLeafRecurse(ILeaf leaf) {
if (Objects.requireNonNull(leaf).isGroup())
throw new IllegalArgumentException();
checkGroup();
if (leaf.getParentContainer() == this)
return true;
for (IGroup child : getChildren())
if (child.containsLeafRecurse(leaf))
return true;
return false;
}
public Collection<ILeaf> getLeafsDirect() {
checkGroup();
final List<ILeaf> result = new ArrayList<>();
for (ILeaf ent : entityFactory.leafs()) {
if (ent.isGroup())
throw new IllegalStateException();
if (ent.getParentContainer() == this)
result.add(ent);
}
return Collections.unmodifiableCollection(result);
}
public Collection<IGroup> getChildren() {
checkGroup();
final Collection<IGroup> result = new ArrayList<>();
for (IGroup g : entityFactory.groups())
if (g != this && g.getParentContainer() == this)
result.add(g);
return Collections.unmodifiableCollection(result);
}
public void moveEntitiesTo(IGroup dest) {
checkGroup();
if (dest.isGroup() == false)
throw new UnsupportedOperationException();
for (ILeaf ent : getLeafsDirect())
((EntityImp) ent).parentContainer = dest;
for (IGroup g : dest.getChildren())
// ((EntityImpl) g).parentContainer = dest;
throw new IllegalStateException();
for (IGroup g : getChildren()) {
if (g == dest)
continue;
((EntityImp) g).parentContainer = dest;
}
}
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<>(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);
((EntityImp) ent).ident = ident;
((EntityImp) ent).code = ident;
entityFactory.leafs2.put(ident, ent);
}
}
// System.err.println("moveEntitiesTo1972::before3::groups2=" +
// entityFactory.groups2());
for (IGroup ent : new ArrayList<>(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);
((EntityImp) ent).ident = ident;
((EntityImp) 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();
}
public GroupType getGroupType() { public GroupType getGroupType() {
checkGroup(); checkGroup();
return groupType; return groupType;
} }
public Code getNamespace() {
checkGroup();
return namespace;
}
public PackageStyle getPackageStyle() { public PackageStyle getPackageStyle() {
checkGroup(); checkGroup();
if (stereotype == null) if (stereotype == null)
@ -543,26 +393,34 @@ final public class EntityImp implements ILeaf, IGroup {
if (EntityUtils.isPureInnerLink12(this, link)) if (EntityUtils.isPureInnerLink12(this, link))
entityFactory.removeLink(link); entityFactory.removeLink(link);
entityFactory.removeGroup(getCodeGetName()); // if (entityFactory.namespaceSeparator.V1972()) {
for (ILeaf ent : new ArrayList<>(entityFactory.leafs())) // entityFactory.removeGroup(getIdent());
if (this != ent && this == ent.getParentContainer()) // for (ILeaf ent : new ArrayList<>(entityFactory.leafs()))
entityFactory.removeLeaf(ent.getCodeGetName()); // if (this != ent && getIdent().equals(ent.getIdent().parent()))
// entityFactory.removeLeaf(ent.getIdent());
entityFactory.addLeaf(this); //
// } else {
// entityFactory.removeGroup(getCodeGetName());
// for (ILeaf ent : new ArrayList<>(entityFactory.leafs()))
// if (this != ent && this == ent.getParentContainer())
// entityFactory.removeLeaf(ent.getCodeGetName());
// }
//
// entityFactory.addLeaf(this);
this.groupType = null; this.groupType = null;
this.leafType = leafType; this.leafType = leafType;
} }
public /* private */ void muteToGroup(Code namespaceNew, GroupType groupType, IGroup parentContainer) { // void muteToGroup(Code namespaceNew, GroupType groupType, IGroup parentContainer) {
checkNotGroup(); // checkNotGroup();
if (parentContainer.isGroup() == false) // if (parentContainer.isGroup() == false)
throw new IllegalArgumentException(); // throw new IllegalArgumentException();
//
this.namespace = namespaceNew; // this.namespace = namespaceNew;
this.groupType = groupType; // this.groupType = groupType;
this.leafType = null; // this.leafType = null;
this.parentContainer = parentContainer; // this.parentContainer = parentContainer;
} // }
public USymbol getUSymbol() { public USymbol getUSymbol() {
if (getLeafType() == LeafType.CIRCLE) if (getLeafType() == LeafType.CIRCLE)
@ -583,13 +441,15 @@ final public class EntityImp implements ILeaf, IGroup {
} }
public boolean isHidden() { public boolean isHidden() {
if (parentContainer != null && parentContainer.isHidden()) if (getParentContainer() != null && getParentContainer().isHidden())
return true; return true;
return isHiddenInternal(); return isHiddenInternal();
} }
private boolean isHiddenInternal() { private boolean isHiddenInternal() {
if (quark.isRoot())
return false;
if (isGroup()) { if (isGroup()) {
if (entityFactory.isHidden(this)) if (entityFactory.isHidden(this))
return true; return true;
@ -597,12 +457,12 @@ final public class EntityImp implements ILeaf, IGroup {
if (getLeafsDirect().size() == 0) if (getLeafsDirect().size() == 0)
return false; return false;
for (ILeaf leaf : getLeafsDirect()) for (EntityImp leaf : getLeafsDirect())
if (((EntityImp) leaf).isHiddenInternal() == false) if (leaf.isHiddenInternal() == false)
return false; return false;
for (IGroup g : getChildren()) for (EntityImp g : getChildren())
if (((EntityImp) g).isHiddenInternal() == false) if (g.isHiddenInternal() == false)
return false; return false;
return true; return true;
@ -611,7 +471,7 @@ final public class EntityImp implements ILeaf, IGroup {
} }
public boolean isRemoved() { public boolean isRemoved() {
if (parentContainer != null && parentContainer.isRemoved()) if (getParentContainer() != null && getParentContainer().isRemoved())
return true; return true;
return isRemovedInternal(); return isRemovedInternal();
@ -625,11 +485,11 @@ final public class EntityImp implements ILeaf, IGroup {
if (getLeafsDirect().size() == 0 && getChildren().size() == 0) if (getLeafsDirect().size() == 0 && getChildren().size() == 0)
return false; return false;
for (ILeaf leaf : getLeafsDirect()) for (EntityImp leaf : getLeafsDirect())
if (((EntityImp) leaf).isRemovedInternal() == false) if (((EntityImp) leaf).isRemovedInternal() == false)
return false; return false;
for (IGroup g : getChildren()) for (EntityImp g : getChildren())
if (((EntityImp) g).isRemovedInternal() == false) if (((EntityImp) g).isRemovedInternal() == false)
return false; return false;
@ -644,7 +504,7 @@ final public class EntityImp implements ILeaf, IGroup {
for (Link link : entityFactory.getLinks()) for (Link link : entityFactory.getLinks())
if (link.contains(this)) { if (link.contains(this)) {
final ILeaf other = (ILeaf) link.getOther(this); final EntityImp other = (EntityImp) link.getOther(this);
final boolean removed = entityFactory.isRemovedIgnoreUnlinked(other); final boolean removed = entityFactory.isRemovedIgnoreUnlinked(other);
if (removed == false && link.getType().isInvisible() == false) if (removed == false && link.getType().isInvisible() == false)
return false; return false;
@ -743,17 +603,6 @@ final public class EntityImp implements ILeaf, IGroup {
return legend; return legend;
} }
private IGroup originalGroup;
public void setOriginalGroup(IGroup originalGroup) {
this.originalGroup = originalGroup;
this.legend = originalGroup.getLegend();
}
public IGroup getOriginalGroup() {
return originalGroup;
}
public String getCodeLine() { public String getCodeLine() {
if (this.codeLine == null) if (this.codeLine == null)
return null; return null;
@ -765,12 +614,12 @@ final public class EntityImp implements ILeaf, IGroup {
this.codeLine = codeLine; this.codeLine = codeLine;
} }
@Override //
public void setStereostyle(String stereo) { public void setStereostyle(String stereo) {
this.stereostyles = Stereostyles.build(stereo); this.stereostyles = Stereostyles.build(stereo);
} }
@Override //
public Stereostyles getStereostyles() { public Stereostyles getStereostyles() {
return stereostyles; return stereostyles;
} }
@ -794,18 +643,18 @@ final public class EntityImp implements ILeaf, IGroup {
return Collections.unmodifiableList(result); return Collections.unmodifiableList(result);
} }
public CucaDiagram getDiagram() { public ICucaDiagram getDiagram() {
return entityFactory.getDiagram(); return entityFactory.getDiagram();
} }
private boolean isStatic; private boolean isStatic;
@Override //
public void setStatic(boolean isStatic) { public void setStatic(boolean isStatic) {
this.isStatic = isStatic; this.isStatic = isStatic;
} }
@Override //
public boolean isStatic() { public boolean isStatic() {
return isStatic; return isStatic;
} }
@ -835,14 +684,46 @@ final public class EntityImp implements ILeaf, IGroup {
} }
@Override
public Together getTogether() { public Together getTogether() {
return together; return together;
} }
@Override
public void setTogether(Together together) { public void setTogether(Together together) {
this.together = together; this.together = together;
} }
public EntityImp getParentContainer() {
if (quark.isRoot())
return null;
return (EntityImp) quark.getParent().getData();
}
public Collection<EntityImp> getLeafsDirect() {
final List<EntityImp> result = new ArrayList<>();
for (Quark quark : quark.getChildren()) {
final EntityImp data = (EntityImp) quark.getData();
if (data != null && data.isGroup() == false)
result.add(data);
}
return Collections.unmodifiableCollection(result);
}
public Collection<EntityImp> getChildren() {
final List<EntityImp> result = new ArrayList<>();
for (Quark quark : quark.getChildren()) {
final EntityImp data = (EntityImp) quark.getData();
if (data != null && data.isGroup())
result.add(data);
}
return Collections.unmodifiableCollection(result);
}
public int size() {
return getQuark().countChildren();
}
public boolean instanceofGroupRoot() {
return getQuark().isRoot();
}
} }

View File

@ -35,19 +35,11 @@
*/ */
package net.sourceforge.plantuml.baraye; package net.sourceforge.plantuml.baraye;
import net.sourceforge.plantuml.cucadiagram.GroupRoot;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
public abstract class EntityUtils { public abstract class EntityUtils {
public static boolean groupRoot(IGroup g) { private static boolean isParent(EntityImp groupToBeTested, EntityImp parentGroup) {
if (g == null)
throw new IllegalStateException();
return g instanceof GroupRoot;
}
private static boolean isParent(IGroup groupToBeTested, IGroup parentGroup) {
if (groupToBeTested.isGroup() == false) if (groupToBeTested.isGroup() == false)
// Very strange! // Very strange!
return false; return false;
@ -55,40 +47,72 @@ public abstract class EntityUtils {
if (groupToBeTested.isGroup() == false) if (groupToBeTested.isGroup() == false)
throw new IllegalArgumentException(); throw new IllegalArgumentException();
while (EntityUtils.groupRoot(groupToBeTested) == false) { while (groupToBeTested.getQuark().isRoot() == false) {
if (groupToBeTested == parentGroup) if (groupToBeTested == parentGroup)
return true; return true;
groupToBeTested = groupToBeTested.getParentContainer(); groupToBeTested = groupToBeTested.getParentContainer();
if (groupToBeTested.isGroup() == false) if (groupToBeTested.isGroup() == false)
throw new IllegalStateException(); return false;
// throw new IllegalStateException();
} }
return false; return false;
} }
public static boolean isPureInnerLink12(IGroup group, Link link) { public static boolean isPureInnerLink12(EntityImp group, Link link) {
if (group.isGroup() == false) if (group.isGroup() == false)
throw new IllegalArgumentException(); throw new IllegalArgumentException();
final IEntity e1 = link.getEntity1(); final EntityImp e1 = link.getEntity1();
final IEntity e2 = link.getEntity2(); final EntityImp e2 = link.getEntity2();
final IGroup group1 = e1.getParentContainer(); final EntityImp group1 = e1.getParentContainer();
final IGroup group2 = e2.getParentContainer(); final EntityImp group2 = e2.getParentContainer();
if (isParent(group1, group) && isParent(group2, group)) if (isParent(group1, group) && isParent(group2, group))
return true; return true;
return false; return false;
} }
public static boolean isPureInnerLink3(IGroup group, Link link) { // public static boolean isPureInnerLink12(EntityImp group, Link link) {
// if (group.isGroup() == false)
// throw new IllegalArgumentException();
//
// final EntityImp e1 = (EntityImp) link.getZEntity1();
// final EntityImp e2 = (EntityImp) link.getZEntity2();
// final Quark group1 = e1.getQuark().getParent();
// final Quark group2 = e2.getQuark().getParent();
// if (group.getQuark().containsLarge(group1) && group.getQuark().containsLarge(group2))
// return true;
//// if (isParent(group1, group) && isParent(group2, group))
//// return true;
//
// return false;
// }
//
// public static boolean isPureInnerLink12(EntityImp group, Link link) {
// if (group.isGroup() == false)
// throw new IllegalArgumentException();
//
// final EntityImp e1 = link.getEntity1();
// final EntityImp e2 = link.getEntity2();
// final EntityImp group1 = e1.getParentContainer();
// final EntityImp group2 = e2.getParentContainer();
// if (isParent(group1, group) && isParent(group2, group))
// return true;
//
// return false;
// }
public static boolean isPureInnerLink3(EntityImp group, Link link) {
if (group.isGroup() == false) if (group.isGroup() == false)
throw new IllegalArgumentException(); throw new IllegalArgumentException();
final IEntity e1 = link.getEntity1(); final EntityImp e1 = link.getEntity1();
final IEntity e2 = link.getEntity2(); final EntityImp e2 = link.getEntity2();
final IGroup group1 = e1.getParentContainer(); final EntityImp group1 = e1.getParentContainer();
final IGroup group2 = e2.getParentContainer(); final EntityImp group2 = e2.getParentContainer();
if (isParent(group2, group) == isParent(group1, group)) if (isParent(group2, group) == isParent(group1, group))
return true; return true;

View File

@ -1,124 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2023, 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
* Contribution: Miguel Esteves
*
*/
package net.sourceforge.plantuml.baraye;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.sourceforge.plantuml.Hideable;
import net.sourceforge.plantuml.LineConfigurable;
import net.sourceforge.plantuml.Removeable;
import net.sourceforge.plantuml.SpecificBackcolorable;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.command.Position;
import net.sourceforge.plantuml.cucadiagram.Bodier;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.CucaNote;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.EntityPosition;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Stereostyles;
import net.sourceforge.plantuml.cucadiagram.Stereotag;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.graphic.color.Colors;
import net.sourceforge.plantuml.utils.LineLocation;
public interface IEntity extends SpecificBackcolorable, Hideable, Removeable, LineConfigurable {
public Code getCode();
public String getCodeGetName();
public Ident getIdent();
public USymbol getUSymbol();
public void setUSymbol(USymbol symbol);
public LeafType getLeafType();
public Display getDisplay();
public IGroup getParentContainer();
public void setDisplay(Display display);
public String getUid();
public Url getUrl99();
public Stereotype getStereotype();
public void setStereotype(Stereotype stereotype);
public Bodier getBodier();
public void addUrl(Url url);
public boolean isGroup();
public boolean hasUrl();
public int getRawLayout();
public void putTip(String member, Display display);
public Map<String, Display> getTips();
public void addStereotag(Stereotag tag);
public Set<Stereotag> stereotags();
public boolean isAloneAndUnlinked();
public String getCodeLine();
public void setCodeLine(LineLocation codeLine);
public void setStereostyle(String stereo);
public Stereostyles getStereostyles();
public void addNote(Display note, Position position, Colors colors);
public EntityPosition getEntityPosition();
public List<CucaNote> getNotes(Position position);
}

View File

@ -1,82 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2023, 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.baraye;
import java.util.Collection;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.DisplayPositioned;
import net.sourceforge.plantuml.cucadiagram.GroupType;
import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.svek.IEntityImage;
import net.sourceforge.plantuml.svek.PackageStyle;
import net.sourceforge.plantuml.svek.SingleStrategy;
public interface IGroup extends IEntity {
public boolean containsLeafRecurse(ILeaf entity);
public Collection<ILeaf> getLeafsDirect();
public Collection<IGroup> getChildren();
public void moveEntitiesTo(IGroup dest);
public int size();
public GroupType getGroupType();
public Code getNamespace();
public PackageStyle getPackageStyle();
public void overrideImage(IEntityImage img, LeafType state);
public SingleStrategy getSingleStrategy();
public FontConfiguration getFontConfigurationForTitle(ISkinParam skinParam);
public char getConcurrentSeparator();
public void setConcurrentSeparator(char separator);
public void setLegend(DisplayPositioned legend);
public DisplayPositioned getLegend();
}

View File

@ -1,88 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2023, 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.baraye;
import java.util.Collection;
import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Together;
import net.sourceforge.plantuml.cucadiagram.dot.Neighborhood;
import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.skin.VisibilityModifier;
import net.sourceforge.plantuml.svek.IEntityImage;
import net.sourceforge.plantuml.svek.Margins;
public interface ILeaf extends IEntity {
public void setContainer(IGroup container);
public Margins getMargins();
public int getXposition();
public void setXposition(int pos);
public IEntityImage getSvekImage();
public String getGeneric();
public boolean muteToType(LeafType newType, USymbol newSymbol);
public void setGeneric(String generic);
public void setSvekImage(IEntityImage svekImage);
public void setNeighborhood(Neighborhood neighborhood);
public Neighborhood getNeighborhood();
public Collection<String> getPortShortNames();
public void addPortShortName(String portShortName);
public void setVisibilityModifier(VisibilityModifier visibility);
public VisibilityModifier getVisibilityModifier();
public void setStatic(boolean isStatic);
public boolean isStatic();
public Together getTogether();
public void setTogether(Together together);
}

View File

@ -38,20 +38,18 @@ package net.sourceforge.plantuml.baraye;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map;
public class Plasma { public class Plasma {
private String separator; private String separator;
private final Quark root; private final Quark root;
private final Map<List<String>, Quark> quarks = new LinkedHashMap<>(); private final List<Quark> quarks = new ArrayList<>();
public Plasma(String separator) { public Plasma(String separator) {
final List<String> empty = Collections.emptyList(); this.root = new Quark(this, null, "");
this.root = ensurePresent(empty);
this.separator = separator; this.separator = separator;
this.quarks.add(root);
} }
public Quark root() { public Quark root() {
@ -68,6 +66,10 @@ public class Plasma {
this.separator = separator; this.separator = separator;
} }
public final boolean hasSeparator() {
return this.separator != null && this.separator != "\u0000";
}
public Quark parse(Quark root, String full) { public Quark parse(Quark root, String full) {
final List<String> result = root.getSignature(); final List<String> result = root.getSignature();
@ -87,53 +89,63 @@ public class Plasma {
} }
Quark ensurePresent(List<String> result) { Quark ensurePresent(List<String> result) {
Quark quark = quarks.get(result); Quark quark = getIfExists(result);
if (quark == null) { if (quark == null) {
if (result.size() == 0) if (result.size() == 0) {
quark = new Quark(this, null, result); // quark = new Quark(this, null, result);
else { throw new UnsupportedOperationException();
} else {
final Quark parent = ensurePresent(result.subList(0, result.size() - 1)); final Quark parent = ensurePresent(result.subList(0, result.size() - 1));
quark = new Quark(this, parent, result); quark = new Quark(this, parent, result.get(result.size() - 1));
} }
System.err.println("PUTTING " + quark); // System.err.println("PUTTING " + quark);
quarks.put(result, quark); quarks.add(quark);
} }
return quark; return quark;
} }
public Collection<Quark> quarks() { public Collection<Quark> quarks() {
return Collections.unmodifiableCollection(new ArrayList<>(quarks.values())); return Collections.unmodifiableCollection(quarks);
} }
// public boolean exists(String name) {
// for (Quark quark : quarks.values())
// if (quark.getName().equals(name))
// return true;
// return false;
// }
public Quark getIfExistsFromName(String name) { public Quark getIfExistsFromName(String name) {
for (Quark quark : quarks.values()) Quark result = null;
for (Quark quark : quarks)
if (quark.getName().equals(name)) {
// if (result != null)
// throw new IllegalArgumentException("Duplicate name: " + name);
result = quark;
return result;
}
return result;
}
public int countByName(String name) {
int count = 0;
for (Quark quark : quarks)
if (quark.getName().equals(name)) if (quark.getName().equals(name))
return quark; count++;
return null; return count;
} }
public Quark getIfExistsFromFullPath(String full) { public Quark getIfExistsFromFullPath(String full) {
for (Quark quark : quarks.values()) for (Quark quark : quarks)
if (quark.toString(separator).equals(full)) if (quark.toString(separator).equals(full))
return quark; return quark;
return null; return null;
} }
public Quark getIfExists(List<String> signature) { public Quark getIfExists(List<String> signature) {
return quarks.get(signature); for (Quark quark : quarks)
if (quark.getSignature().equals(signature))
return quark;
return null;
} }
public int countChildren(Quark parent) { public int countChildren(Quark parent) {
int count = 0; int count = 0;
for (Quark quark : new ArrayList<>(quarks.values())) for (Quark quark : quarks)
if (quark.getParent() == parent) if (quark.getParent() == parent)
count++; count++;
return count; return count;
@ -141,21 +153,19 @@ public class Plasma {
public List<Quark> getChildren(Quark parent) { public List<Quark> getChildren(Quark parent) {
final List<Quark> result = new ArrayList<>(); final List<Quark> result = new ArrayList<>();
for (Quark quark : new ArrayList<>(quarks.values())) for (Quark quark : quarks)
if (quark.getParent() == parent) if (quark.getParent() == parent)
result.add(quark); result.add(quark);
return Collections.unmodifiableList(result); return Collections.unmodifiableList(result);
} }
public void moveAllTo(Quark src, Quark dest) { public void moveAllChildOfToAnewFather(Quark oldFather, Quark newFather) {
for (Quark quark : new ArrayList<>(quarks.values())) { for (Quark quark : quarks) {
if (quark == dest) if (quark == newFather)
continue; continue;
if (src.containsLarge(quark)) {
quarks.remove(quark.getSignature()); if (quark.getParent() == oldFather)
quark.internalMove(src, dest); quark.setParent(newFather);
quarks.put(quark.getSignature(), quark);
}
} }
} }

View File

@ -38,50 +38,46 @@ package net.sourceforge.plantuml.baraye;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.cucadiagram.Code; public class Quark {
import net.sourceforge.plantuml.cucadiagram.Ident;
public class Quark extends Ident implements Code {
private final Plasma plasma; private final Plasma plasma;
private /* final */ Quark parent; private /* final */ Quark parent;
// private final List<String> parts; private final String name;
private Object data; private Object data;
Quark(Plasma plasma, Quark parent, List<String> parts) { Quark(Plasma plasma, Quark parent, String name) {
super(new ArrayList<String>(parts)); this.name = name;
this.plasma = plasma; this.plasma = plasma;
this.parent = parent; this.parent = parent;
if (parent == null) {
if (parts.size() != 0)
throw new IllegalStateException();
} else {
if (parent.parts.equals(parts.subList(0, parts.size() - 1)) == false)
throw new IllegalStateException();
}
// this.parts = new ArrayList<String>(parts);
} }
public Quark getParent() { public Quark getParent() {
return parent; return parent;
// if (parts.size() == 0)
// return null;
// return plasma.ensurePresent(parts.subList(0, parts.size() - 1));
} }
@Override @Override
public String toString() { public String toString() {
// return parts.toString() + "(parent=" + parent + ")"; // return parts.toString() + "(parent=" + parent + ")";
return parts.toString(); return getSignature().toString();
} }
public List<String> getSignature() { public List<String> getSignature() {
return new ArrayList<>(parts); final List<String> result = new ArrayList<>();
if (parent != null)
result.addAll(parent.getSignature());
result.add(name);
return result;
}
public List<String> parts() {
return getSignature();
} }
public boolean containsLarge(Quark other) { public boolean containsLarge(Quark other) {
return other.parts.size() > this.parts.size() && other.parts.subList(0, this.parts.size()).equals(this.parts); final List<String> signature = this.parts();
final List<String> otherSignature = other.parts();
return otherSignature.size() > signature.size()
&& otherSignature.subList(0, signature.size()).equals(signature);
} }
// @Override // @Override
@ -97,23 +93,12 @@ public class Quark extends Ident implements Code {
// return parts.hashCode(); // return parts.hashCode();
// } // }
public boolean startsWith(Quark 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 toString(String sep) { public String toString(String sep) {
if (sep == null) if (sep == null)
sep = "."; sep = ".";
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
for (String s : parts) { for (String s : parts()) {
if (sb.length() > 0) if (sb.length() > 0)
sb.append(sep); sb.append(sep);
@ -123,24 +108,21 @@ public class Quark extends Ident implements Code {
} }
public String getName() { public String getName() {
if (parts.size() == 0) return name;
return ""; }
return parts.get(parts.size() - 1); public String getQualifiedName() {
if (plasma.hasSeparator())
return toString(plasma.getSeparator());
return name;
} }
public boolean isRoot() { public boolean isRoot() {
return parts.size() == 0; return parent == null;
// throw new UnsupportedOperationException();
// return parts.size() == 0;
} }
public int getDepth() {
return parts.size();
}
// public int size() {
// return parts.size();
// }
public final Plasma getPlasma() { public final Plasma getPlasma() {
return plasma; return plasma;
} }
@ -153,26 +135,14 @@ public class Quark extends Ident implements Code {
this.data = data; this.data = data;
} }
@Override
public Ident eventuallyRemoveStartingAndEndingDoubleQuote(String format) {
return this;
// throw new UnsupportedOperationException();
}
public Quark childIfExists(String name) { public Quark childIfExists(String name) {
final List<String> sig = new ArrayList<>(getSignature()); final List<String> sig = new ArrayList<>(getSignature());
sig.add(name); sig.add(name);
return plasma.getIfExists(sig); return plasma.getIfExists(sig);
} }
public Quark parse(Quark path) { public Quark child(String full) {
final List<String> sig = new ArrayList<>(getSignature()); return plasma.parse(this, full);
sig.addAll(path.getSignature());
return plasma.ensurePresent(sig);
}
public Quark child(String name) {
return plasma.parse(this, name);
} }
public int countChildren() { public int countChildren() {
@ -183,20 +153,28 @@ public class Quark extends Ident implements Code {
return plasma.getChildren(this); return plasma.getChildren(this);
} }
public void moveTo(Quark dest) { public String forXmi() {
plasma.moveAllTo(this, dest); final StringBuilder sb = new StringBuilder();
for (String s : parts()) {
if (sb.length() > 0)
sb.append(".");
sb.append(s);
}
return sb.toString();
} }
public void internalMove(Quark src, Quark dest) { public String getPortMember() {
System.err.print("Intermal move from " + this + " to "); final String last = getName();
if (src.getDepth() + 1 != dest.getDepth()) final int x = last.lastIndexOf("::");
throw new UnsupportedOperationException("to be finished"); if (x == -1) {
final List<String> previous = this.getSignature(); return null;
parts.clear(); }
parts.addAll(dest.getSignature()); return last.substring(x + 2);
parts.addAll(previous.subList(src.getDepth(), previous.size())); }
this.parent = plasma.ensurePresent(parts.subList(0, parts.size() - 1));
System.err.println(toString()); void setParent(Quark newFather) {
this.parent = newFather;
} }
} }

View File

@ -36,6 +36,7 @@
package net.sourceforge.plantuml.braille; package net.sourceforge.plantuml.braille;
public class BrailleChar { public class BrailleChar {
// ::remove folder when WASM
private final int id; private final int id;

View File

@ -12,6 +12,7 @@ package net.sourceforge.plantuml.brotli;
* Bit reading helpers. * Bit reading helpers.
*/ */
final class BitReader { final class BitReader {
// ::remove folder when WASM
// Added by Arnaud... not very beautifull // Added by Arnaud... not very beautifull
private static final boolean CHECK_UNUSED_BYTES_AFTER_END = false; private static final boolean CHECK_UNUSED_BYTES_AFTER_END = false;

View File

@ -38,24 +38,14 @@ package net.sourceforge.plantuml.classdiagram;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.baraye.EntityUtils; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.baraye.IGroup;
import net.sourceforge.plantuml.baraye.ILeaf;
import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.GroupType;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram; import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram;
import net.sourceforge.plantuml.svek.image.EntityImageClass; import net.sourceforge.plantuml.svek.image.EntityImageClass;
@ -65,91 +55,49 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram {
super(source, UmlDiagramType.CLASS, skinParam); super(source, UmlDiagramType.CLASS, skinParam);
} }
private Code getShortName1972(Code code) { // @Override
final String separator = Objects.requireNonNull(getNamespaceSeparator()); // protected ILeaf getOrCreateLeaf2(Quark ident, Quark code, LeafType type, USymbol symbol) {
final String codeString = code.getName(); // Objects.requireNonNull(ident);
final String namespace = getNamespace1972(code, getNamespaceSeparator()); // if (type == null) {
if (namespace == null) // code = code.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:");
return buildCode(codeString); // if (code.getData() != null)
// return (ILeaf) code.getData();
// if (getNamespaceSeparator() == null)
// return reallyCreateLeaf(ident, Display.getWithNewlines(code.getName()), LeafType.CLASS, symbol);
// // return getOrCreateLeafDefault(ident, code.getName(), LeafType.CLASS, symbol);
//
// if (ident.getData() != null)
// return (ILeaf) ident.getData();
// final ILeaf result = reallyCreateLeaf(ident, Display.getWithNewlines(ident.getName()), LeafType.CLASS, symbol);
// this.lastEntity = (EntityImp) result;
// return result;
// }
// if (code.getData() != null)
// return (ILeaf) code.getData();
// if (getNamespaceSeparator() == null)
// return reallyCreateLeaf(ident, Display.getWithNewlines(code.getName()), type, symbol);
// // return getOrCreateLeafDefault(ident, code.getName(), type, symbol);
//
// final ILeaf result = reallyCreateLeaf(ident, Display.getWithNewlines(ident.getName()), type, symbol);
// this.lastEntity = (EntityImp) result;
// return result;
// }
return buildCode(codeString.substring(namespace.length() + separator.length())); // @Override
} // public ILeaf createLeaf(Quark idNewLong, String displayString, Display display, LeafType type, USymbol symbol) {
// Objects.requireNonNull(idNewLong);
@Override // if (type != LeafType.ABSTRACT_CLASS && type != LeafType.ANNOTATION && type != LeafType.CLASS
public ILeaf getOrCreateLeaf(Ident ident, Code code, LeafType type, USymbol symbol) { // && type != LeafType.INTERFACE && type != LeafType.ENUM && type != LeafType.LOLLIPOP_FULL
Objects.requireNonNull(ident); // && type != LeafType.LOLLIPOP_HALF && type != LeafType.NOTE)
if (type == null) { // return super.createLeaf(idNewLong, displayString, display, type, symbol);
code = code.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:"); //
if (getNamespaceSeparator() == null) // if (getNamespaceSeparator() == null)
return getOrCreateLeafDefault(ident, code, LeafType.CLASS, symbol); // return super.createLeaf(idNewLong, displayString, display, type, symbol);
//
code = getFullyQualifiedCode1972(code); // final ILeaf result = createLeafInternal(idNewLong, display, type, symbol);
if (super.leafExist(code)) // this.lastEntity = (EntityImp) result;
return getOrCreateLeafDefault(ident, code, LeafType.CLASS, symbol); // return result;
// }
return createEntityWithNamespace1972(ident, code, Display.getWithNewlines(ident.getLast()), LeafType.CLASS,
symbol);
}
if (getNamespaceSeparator() == null)
return getOrCreateLeafDefault(ident, code, type, symbol);
code = getFullyQualifiedCode1972(code);
if (super.leafExist(code))
return getOrCreateLeafDefault(ident, code, type, symbol);
return createEntityWithNamespace1972(ident, code, Display.getWithNewlines(ident.getLast()), type, symbol);
}
@Override
public ILeaf createLeaf(Ident idNewLong, Code code, Display display, LeafType type, USymbol symbol) {
Objects.requireNonNull(idNewLong);
if (type != LeafType.ABSTRACT_CLASS && type != LeafType.ANNOTATION && type != LeafType.CLASS
&& type != LeafType.INTERFACE && type != LeafType.ENUM && type != LeafType.LOLLIPOP_FULL
&& type != LeafType.LOLLIPOP_HALF && type != LeafType.NOTE)
return super.createLeaf(idNewLong, code, display, type, symbol);
if (getNamespaceSeparator() == null)
return super.createLeaf(idNewLong, code, display, type, symbol);
code = getFullyQualifiedCode1972(code);
if (super.leafExist(code))
throw new IllegalArgumentException("Already known: " + code);
return createEntityWithNamespace1972(idNewLong, code, display, type, symbol);
}
private ILeaf createEntityWithNamespace1972(Ident id, Code fullyCode, Display display, LeafType type,
USymbol symbol) {
Objects.requireNonNull(id);
final IGroup backupCurrentGroup = getCurrentGroup();
final IGroup group = backupCurrentGroup;
final String namespaceString = getNamespace1972(fullyCode, getNamespaceSeparator());
if (namespaceString != null
&& (EntityUtils.groupRoot(group) || group.getCodeGetName().equals(namespaceString) == false)) {
final Code namespace = buildCode(namespaceString);
final Display tmp = Display.getWithNewlines(namespaceString);
final Ident newIdLong = buildLeafIdentSpecial(namespaceString);
// final Ident newIdLong = buildLeafIdentSpecial2(namespaceString);
gotoGroupExternal(newIdLong, namespace, tmp, namespace, GroupType.PACKAGE, getRootGroup());
}
final Display tmpDisplay;
if (Display.isNull(display))
tmpDisplay = Display.getWithNewlines(getShortName1972(fullyCode)).withCreoleMode(CreoleMode.SIMPLE_LINE);
else
tmpDisplay = display;
final ILeaf result = createLeafInternal(id, fullyCode, tmpDisplay, type, symbol);
gotoThisGroup(backupCurrentGroup);
return result;
}
@Override
public final boolean leafExist(Code code) {
if (getNamespaceSeparator() == null)
return super.leafExist(code);
return super.leafExist(getFullyQualifiedCode1972(code));
}
private boolean allowMixing; private boolean allowMixing;
@ -191,14 +139,14 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram {
private RowLayout getRawLayout(int raw) { private RowLayout getRawLayout(int raw) {
final RowLayout rawLayout = new RowLayout(); final RowLayout rawLayout = new RowLayout();
for (ILeaf leaf : entityFactory.leafs()) for (EntityImp leaf : entityFactory.leafs())
if (leaf.getRawLayout() == raw) if (leaf.getRawLayout() == raw)
rawLayout.addLeaf(getEntityImageClass(leaf)); rawLayout.addLeaf(getEntityImageClass(leaf));
return rawLayout; return rawLayout;
} }
private TextBlock getEntityImageClass(ILeaf entity) { private TextBlock getEntityImageClass(EntityImp entity) {
return new EntityImageClass(entity, getSkinParam(), this); return new EntityImageClass(entity, getSkinParam(), this);
} }

View File

@ -35,7 +35,8 @@
*/ */
package net.sourceforge.plantuml.classdiagram.command; package net.sourceforge.plantuml.classdiagram.command;
import net.sourceforge.plantuml.baraye.IEntity; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.classdiagram.ClassDiagram;
import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.SingleLineCommand2;
@ -43,8 +44,8 @@ import net.sourceforge.plantuml.command.regex.IRegex;
import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.skin.VisibilityModifier; import net.sourceforge.plantuml.skin.VisibilityModifier;
import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
import net.sourceforge.plantuml.utils.LineLocation; import net.sourceforge.plantuml.utils.LineLocation;
@ -69,9 +70,13 @@ public class CommandAddMethod extends SingleLineCommand2<ClassDiagram> {
protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg)
throws NoSuchColorException { throws NoSuchColorException {
final String idShort = arg.get("NAME", 0); final String idShort = arg.get("NAME", 0);
final Ident ident = diagram.buildLeafIdent(idShort); final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(idShort), false);
final Code code = diagram.buildCode(idShort); EntityImp entity = (EntityImp) quark.getData();
final IEntity entity = diagram.getOrCreateLeaf(ident, code, null, null); if (entity == null)
entity = diagram.reallyCreateLeaf(quark, Display.getWithNewlines(quark), LeafType.CLASS, null);
// final Quark ident = diagram.buildFromName(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(idShort));
// final Quark code = diagram.buildFromFullPath(idShort);
// final IEntity entity = diagram.getOrCreateLeaf(ident, code, null, null);
final String field = arg.get("DATA", 0); final String field = arg.get("DATA", 0);
if (field.length() > 0 && VisibilityModifier.isVisibilityCharacter(field)) if (field.length() > 0 && VisibilityModifier.isVisibilityCharacter(field))

View File

@ -40,9 +40,7 @@ import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlMode; import net.sourceforge.plantuml.UrlMode;
import net.sourceforge.plantuml.baraye.CucaDiagram;
import net.sourceforge.plantuml.baraye.EntityImp; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.baraye.ILeaf;
import net.sourceforge.plantuml.baraye.Quark; import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.classdiagram.ClassDiagram;
import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandExecutionResult;
@ -53,9 +51,8 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexOr;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Stereotag; import net.sourceforge.plantuml.cucadiagram.Stereotag;
import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.cucadiagram.Stereotype;
@ -135,48 +132,65 @@ public class CommandCreateClass extends SingleLineCommand2<ClassDiagram> {
throws NoSuchColorException { throws NoSuchColorException {
final String typeString = StringUtils.goUpperCase(arg.get("TYPE", 0)); final String typeString = StringUtils.goUpperCase(arg.get("TYPE", 0));
final LeafType type = LeafType.getLeafType(typeString); final LeafType type = LeafType.getLeafType(typeString);
final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.getLazzy("CODE", 0), final String idShort = diagram.cleanIdForQuark(arg.getLazzy("CODE", 0));
"\"([:"); final String displayString = arg.getLazzy("DISPLAY", 0);
final String display = arg.getLazzy("DISPLAY", 0);
final String genericOption = arg.getLazzy("DISPLAY", 1); final String genericOption = arg.getLazzy("DISPLAY", 1);
final String generic = genericOption != null ? genericOption : arg.get("GENERIC", 0); final String generic = genericOption != null ? genericOption : arg.get("GENERIC", 0);
final String stereo = arg.get("STEREO", 0); final String stereo = arg.get("STEREO", 0);
/* final */ ILeaf entity;
if (CucaDiagram.QUARK) { final Quark quark = diagram.quarkInContext(idShort, true);
final Quark current = diagram.currentQuark();
final Quark idNewLong = (Quark) diagram.buildLeafIdent(idShort); Display display = Display.getWithNewlines(displayString);
if (idNewLong.getData() == null) if (Display.isNull(display))
entity = diagram.createLeaf(idNewLong, idNewLong, Display.getWithNewlines(display), type, null); display = Display.getWithNewlines(quark.getName()).withCreoleMode(CreoleMode.SIMPLE_LINE);
else
entity = (ILeaf) idNewLong.getData(); EntityImp entity = (EntityImp) quark.getData();
if (entity == null || entity.isGroup()) {
for (Quark tmp : diagram.getPlasma().quarks())
if (tmp.getData() instanceof EntityImp) {
final EntityImp tmp2 = (EntityImp) tmp.getData();
if (tmp2 != null && tmp.getName().equals(idShort) && tmp2.isGroup() == false) {
entity = (ILeaf) tmp.getData();
break;
}
}
}
if (entity == null) { if (entity == null) {
final Display withNewlines = Display.getWithNewlines(display); entity = diagram.reallyCreateLeaf(quark, display, type, null);
entity = diagram.createLeaf(idNewLong, idNewLong, withNewlines, type, null);
}
} else { } else {
final Ident idNewLong = diagram.buildLeafIdent(idShort);
final Code code = diagram.buildCode(idShort);
if (diagram.leafExist(code)) {
entity = diagram.getOrCreateLeaf(idNewLong, code, type, null);
if (entity.muteToType(type, null) == false) if (entity.muteToType(type, null) == false)
return CommandExecutionResult.error("Bad name"); return CommandExecutionResult.error("Bad name");
entity.setDisplay(display);
} else {
entity = diagram.createLeaf(idNewLong, code, Display.getWithNewlines(display), type, null);
}
} }
// final Quark quark = diagram.getPlasma().getIfExistsFromName(idShort);
// if (quark != null && quark.getData() != null)
// entity = diagram.getFromName(idShort);
// else
// } else
// entity = (ILeaf) quark.getData();
// if (entity == null || entity.isGroup()) {
// for (Quark tmp : diagram.getPlasma().quarks())
// if (tmp.getData() instanceof EntityImp) {
// final EntityImp tmp2 = (EntityImp) tmp.getData();
// if (tmp2 != null && tmp.getName().equals(idShort) && tmp2.isGroup() == false) {
// entity = (ILeaf) tmp.getData();
// break;
// }
// }
// }
// if (entity == null) {
// entity = diagram.reallyCreateLeaf(quark, display, type, null);
// } else {
// if (entity.muteToType(type, null) == false)
// return CommandExecutionResult.error("Bad name");
// }
// } else {
// final Quark idNewLong = diagram.buildLeafIdent(idShort);
// final Quark 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);
// }
// }
diagram.setLastEntity(entity);
if (stereo != null) { if (stereo != null) {
entity.setStereotype(Stereotype.build(stereo, diagram.getSkinParam().getCircledCharacterRadius(), entity.setStereotype(Stereotype.build(stereo, diagram.getSkinParam().getCircledCharacterRadius(),
diagram.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER), diagram.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER),

View File

@ -40,10 +40,7 @@ import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlMode; import net.sourceforge.plantuml.UrlMode;
import net.sourceforge.plantuml.baraye.CucaDiagram;
import net.sourceforge.plantuml.baraye.EntityImp; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.baraye.IEntity;
import net.sourceforge.plantuml.baraye.ILeaf;
import net.sourceforge.plantuml.baraye.Quark; import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.classdiagram.ClassDiagram;
import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandExecutionResult;
@ -56,9 +53,8 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexOr;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg; import net.sourceforge.plantuml.cucadiagram.LinkArg;
@ -156,9 +152,71 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
protected CommandExecutionResult executeNow(ClassDiagram diagram, BlocLines lines) throws NoSuchColorException { protected CommandExecutionResult executeNow(ClassDiagram diagram, BlocLines lines) throws NoSuchColorException {
lines = lines.trimSmart(1); lines = lines.trimSmart(1);
final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString());
final IEntity entity = executeArg0(diagram, line0); final String typeString = StringUtils.goUpperCase(line0.get("TYPE", 0));
if (entity == null) final LeafType type = LeafType.getLeafType(typeString);
return CommandExecutionResult.error("No such entity"); final String visibilityString = line0.get("VISIBILITY", 0);
VisibilityModifier visibilityModifier = null;
if (visibilityString != null)
visibilityModifier = VisibilityModifier.getVisibilityModifier(visibilityString + "FOO", false);
final String idShort = diagram.cleanIdForQuark(line0.getLazzy("CODE", 0));
final String displayString = line0.getLazzy("DISPLAY", 0);
final String genericOption = line0.getLazzy("DISPLAY", 1);
final String generic = genericOption != null ? genericOption : line0.get("GENERIC", 0);
final String stereotype = line0.get("STEREO", 0);
final Quark quark = diagram.quarkInContext(idShort, true);
Display display = Display.getWithNewlines(displayString);
if (Display.isNull(display))
display = Display.getWithNewlines(quark.getName()).withCreoleMode(CreoleMode.SIMPLE_LINE);
EntityImp entity = (EntityImp) quark.getData();
if (entity == null) {
entity = diagram.reallyCreateLeaf(quark, display, type, null);
} else {
if (entity.muteToType(type, null) == false)
return CommandExecutionResult.error("Cannot create " + idShort + " because it already exists");
entity.setDisplay(display);
}
diagram.setLastEntity(entity);
entity.setVisibilityModifier(visibilityModifier);
if (stereotype != null) {
entity.setStereotype(Stereotype.build(stereotype, diagram.getSkinParam().getCircledCharacterRadius(),
diagram.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER),
diagram.getSkinParam().getIHtmlColorSet()));
entity.setStereostyle(stereotype);
}
final String urlString = line0.get("URL", 0);
if (urlString != null) {
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), UrlMode.STRICT);
final Url url = urlBuilder.getUrl(urlString);
entity.addUrl(url);
}
Colors colors = color().getColor(line0, diagram.getSkinParam().getIHtmlColorSet());
final String s1 = line0.get("LINECOLOR", 1);
final HColor lineColor = s1 == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s1);
if (lineColor != null)
colors = colors.add(ColorType.LINE, lineColor);
if (line0.get("LINECOLOR", 0) != null)
colors = colors.addLegacyStroke(line0.get("LINECOLOR", 0));
entity.setColors(colors);
if (generic != null)
entity.setGeneric(generic);
if (typeString.contains("STATIC"))
entity.setStatic(true);
if (lines.size() > 1) { if (lines.size() > 1) {
entity.setCodeLine(lines.getAt(0).getLocation()); entity.setCodeLine(lines.getAt(0).getLocation());
@ -192,7 +250,7 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();
} }
public static void addTags(IEntity entity, String tags) { public static void addTags(EntityImp entity, String tags) {
if (tags == null) if (tags == null)
return; return;
@ -203,7 +261,7 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
} }
} }
public static void manageExtends(String keyword, ClassDiagram diagram, RegexResult arg, final IEntity entity) { public static void manageExtends(String keyword, ClassDiagram diagram, RegexResult arg, final EntityImp entity) {
if (arg.get(keyword, 0) != null) { if (arg.get(keyword, 0) != null) {
final Mode mode = arg.get(keyword, 0).equalsIgnoreCase("extends") ? Mode.EXTENDS : Mode.IMPLEMENTS; final Mode mode = arg.get(keyword, 0).equalsIgnoreCase("extends") ? Mode.EXTENDS : Mode.IMPLEMENTS;
LeafType type2 = LeafType.CLASS; LeafType type2 = LeafType.CLASS;
@ -216,15 +274,22 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
final String codes = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(keyword, 1)); final String codes = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(keyword, 1));
for (String s : codes.split(",")) { for (String s : codes.split(",")) {
final String idShort = StringUtils.trin(s); final String idShort = StringUtils.trin(s);
final Ident ident = diagram.buildLeafIdent(idShort); // final Quark ident = diagram
final Code other = diagram.buildCode(idShort); // .buildFromName(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(idShort));
final IEntity cl2 = diagram.getOrCreateLeaf(ident, other, type2, null); // final Quark other = diagram.buildFromFullPath(idShort);
// final IEntity cl2 = diagram.getOrCreateLeaf(ident, other, type2, null);
final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(idShort), true);
EntityImp cl2 = (EntityImp) quark.getData();
if (cl2 == null)
cl2 = diagram.reallyCreateLeaf(quark, Display.getWithNewlines(quark.getName()), type2, null);
LinkType typeLink = new LinkType(LinkDecor.NONE, LinkDecor.EXTENDS); LinkType typeLink = new LinkType(LinkDecor.NONE, LinkDecor.EXTENDS);
if (type2 == LeafType.INTERFACE && entity.getLeafType() != LeafType.INTERFACE) if (type2 == LeafType.INTERFACE && entity.getLeafType() != LeafType.INTERFACE)
typeLink = typeLink.goDashed(); typeLink = typeLink.goDashed();
final LinkArg linkArg = LinkArg.noDisplay(2); final LinkArg linkArg = LinkArg.noDisplay(2);
final Link link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), final Link link = new Link(diagram.getEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(),
cl2, entity, typeLink, linkArg.withQuantifier(null, null) cl2, entity, typeLink, linkArg.withQuantifier(null, null)
.withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle())); .withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle()));
diagram.addLink(link); diagram.addLink(link);
@ -232,7 +297,7 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
} }
} }
private IEntity executeArg0(ClassDiagram diagram, RegexResult line0) throws NoSuchColorException { private EntityImp executeArg0(ClassDiagram diagram, RegexResult line0) throws NoSuchColorException {
final String typeString = StringUtils.goUpperCase(line0.get("TYPE", 0)); final String typeString = StringUtils.goUpperCase(line0.get("TYPE", 0));
final LeafType type = LeafType.getLeafType(typeString); final LeafType type = LeafType.getLeafType(typeString);
@ -241,61 +306,46 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
if (visibilityString != null) if (visibilityString != null)
visibilityModifier = VisibilityModifier.getVisibilityModifier(visibilityString + "FOO", false); visibilityModifier = VisibilityModifier.getVisibilityModifier(visibilityString + "FOO", false);
final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(line0.getLazzy("CODE", 0), final String idShort = diagram.cleanIdForQuark(line0.getLazzy("CODE", 0));
"\"([:");
final Ident ident = diagram.buildLeafIdent(idShort); final String displayString = line0.getLazzy("DISPLAY", 0);
final Code code = diagram.buildCode(idShort);
final String display = line0.getLazzy("DISPLAY", 0);
final String genericOption = line0.getLazzy("DISPLAY", 1); final String genericOption = line0.getLazzy("DISPLAY", 1);
final String generic = genericOption != null ? genericOption : line0.get("GENERIC", 0); final String generic = genericOption != null ? genericOption : line0.get("GENERIC", 0);
final String stereotype = line0.get("STEREO", 0); final String stereotype = line0.get("STEREO", 0);
/* final */ILeaf result; final Quark quark = diagram.quarkInContext(idShort, true);
if (CucaDiagram.QUARK) {
final Quark current = diagram.currentQuark();
final Quark idNewLong = (Quark) diagram.buildLeafIdent(idShort);
if (idNewLong.getData() == null)
result = diagram.createLeaf(idNewLong, code, Display.getWithNewlines(display), type, null);
else
result = (ILeaf) idNewLong.getData();
if (result == null || result.isGroup()) {
for (Quark tmp : diagram.getPlasma().quarks())
if (tmp.getData() instanceof EntityImp) {
final EntityImp tmp2 = (EntityImp) tmp.getData();
if (tmp2 != null && tmp.getName().equals(idShort) && tmp2.isGroup() == false) {
result = (ILeaf) tmp.getData();
break;
}
}
}
if (result == null)
result = diagram.createLeaf(idNewLong, idNewLong, Display.getWithNewlines(display), type, null);
diagram.setLastEntity(result);
} else {
if (diagram.leafExist(code)) {
result = diagram.getOrCreateLeaf(ident, code, null, null);
if (result.muteToType(type, null) == false)
return null;
Display display = Display.getWithNewlines(displayString);
if (Display.isNull(display))
display = Display.getWithNewlines(quark.getName()).withCreoleMode(CreoleMode.SIMPLE_LINE);
EntityImp entity = (EntityImp) quark.getData();
if (entity == null) {
entity = diagram.reallyCreateLeaf(quark, display, type, null);
} else { } else {
result = diagram.createLeaf(ident, code, Display.getWithNewlines(display), type, null); // if (entity.muteToType(type, null) == false)
} // return null;
entity.setDisplay(display);
} }
result.setVisibilityModifier(visibilityModifier); diagram.setLastEntity(entity);
entity.setVisibilityModifier(visibilityModifier);
if (stereotype != null) { if (stereotype != null) {
result.setStereotype(Stereotype.build(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), entity.setStereotype(Stereotype.build(stereotype, diagram.getSkinParam().getCircledCharacterRadius(),
diagram.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER), diagram.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER),
diagram.getSkinParam().getIHtmlColorSet())); diagram.getSkinParam().getIHtmlColorSet()));
result.setStereostyle(stereotype); entity.setStereostyle(stereotype);
} }
final String urlString = line0.get("URL", 0); final String urlString = line0.get("URL", 0);
if (urlString != null) { if (urlString != null) {
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), UrlMode.STRICT); final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), UrlMode.STRICT);
final Url url = urlBuilder.getUrl(urlString); final Url url = urlBuilder.getUrl(urlString);
result.addUrl(url); entity.addUrl(url);
} }
Colors colors = color().getColor(line0, diagram.getSkinParam().getIHtmlColorSet()); Colors colors = color().getColor(line0, diagram.getSkinParam().getIHtmlColorSet());
@ -308,14 +358,14 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
if (line0.get("LINECOLOR", 0) != null) if (line0.get("LINECOLOR", 0) != null)
colors = colors.addLegacyStroke(line0.get("LINECOLOR", 0)); colors = colors.addLegacyStroke(line0.get("LINECOLOR", 0));
result.setColors(colors); entity.setColors(colors);
if (generic != null) if (generic != null)
result.setGeneric(generic); entity.setGeneric(generic);
if (typeString.contains("STATIC")) if (typeString.contains("STATIC"))
result.setStatic(true); entity.setStatic(true);
return result; return entity;
} }
} }

View File

@ -41,7 +41,8 @@ import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlMode; import net.sourceforge.plantuml.UrlMode;
import net.sourceforge.plantuml.baraye.IEntity; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.classdiagram.ClassDiagram;
import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.SingleLineCommand2;
@ -50,9 +51,7 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexOr;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Stereotag; import net.sourceforge.plantuml.cucadiagram.Stereotag;
import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.cucadiagram.Stereotype;
@ -206,16 +205,22 @@ public class CommandCreateElementFull2 extends SingleLineCommand2<ClassDiagram>
} }
final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeRaw); final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeRaw);
final Ident ident = diagram.buildLeafIdent(idShort); final Display display = Display.getWithNewlines(displayRaw == null ? idShort : displayRaw);
final Code code = diagram.buildCode(idShort); final Quark quark = diagram.quarkInContext(idShort, false);
String display = displayRaw; EntityImp entity = (EntityImp) quark.getData();
if (display == null) if (entity == null)
display = code.getName(); entity = diagram.reallyCreateLeaf(quark, display, type, usymbol);
display = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(display); // final Quark ident = diagram.buildFromName(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(idShort));
// final Quark code = diagram.buildFromFullPath(idShort);
// String display = displayRaw;
// if (display == null)
// display = code.getName();
//
// display = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(display);
final String stereotype = arg.getLazzy("STEREOTYPE", 0); final String stereotype = arg.getLazzy("STEREOTYPE", 0);
final IEntity entity = diagram.getOrCreateLeaf(ident, code, type, usymbol); // final IEntity entity = diagram.getOrCreateLeaf(ident, code, type, usymbol);
entity.setDisplay(Display.getWithNewlines(display)); entity.setDisplay(display);
entity.setUSymbol(usymbol); entity.setUSymbol(usymbol);
if (stereotype != null) if (stereotype != null)
entity.setStereotype(Stereotype.build(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), entity.setStereotype(Stereotype.build(stereotype, diagram.getSkinParam().getCircledCharacterRadius(),

View File

@ -35,6 +35,7 @@
*/ */
package net.sourceforge.plantuml.classdiagram.command; package net.sourceforge.plantuml.classdiagram.command;
import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.classdiagram.ClassDiagram;
import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.SingleLineCommand2;
@ -42,9 +43,7 @@ import net.sourceforge.plantuml.command.regex.IRegex;
import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.utils.LineLocation; import net.sourceforge.plantuml.utils.LineLocation;
@ -65,13 +64,14 @@ public class CommandDiamondAssociation extends SingleLineCommand2<ClassDiagram>
@Override @Override
protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) { protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) {
final String idShort = arg.get("CODE", 0); final String idShort = arg.get("CODE", 0);
final Ident ident = diagram.buildLeafIdent(idShort); final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(idShort), false);
final Code code = diagram.buildCode(idShort); // final Quark ident = diagram.buildFromName(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(idShort));
final boolean leafExist = diagram.leafExist(code); // final Quark code = diagram.buildFromFullPath(idShort);
if (leafExist) // final boolean leafExist = diagram.leafExist(code);
return CommandExecutionResult.error("Already existing : " + code.getName()); if (quark.getData() != null)
return CommandExecutionResult.error("Already existing : " + quark.getName());
diagram.createLeaf(ident, code, Display.NULL, LeafType.ASSOCIATION, null); diagram.reallyCreateLeaf(quark, Display.getWithNewlines(""), LeafType.ASSOCIATION, null);
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();
} }

View File

@ -37,8 +37,9 @@ package net.sourceforge.plantuml.classdiagram.command;
import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.baraye.EntityUtils; import net.sourceforge.plantuml.baraye.EntityUtils;
import net.sourceforge.plantuml.baraye.IEntity; import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.IRegex;
@ -46,11 +47,9 @@ import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.EntityGender; import net.sourceforge.plantuml.cucadiagram.EntityGender;
import net.sourceforge.plantuml.cucadiagram.EntityGenderUtils; import net.sourceforge.plantuml.cucadiagram.EntityGenderUtils;
import net.sourceforge.plantuml.cucadiagram.EntityPortion; import net.sourceforge.plantuml.cucadiagram.EntityPortion;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.descdiagram.DescriptionDiagram; import net.sourceforge.plantuml.descdiagram.DescriptionDiagram;
import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram; import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram;
@ -146,8 +145,12 @@ public class CommandHideShowByGender extends SingleLineCommand2<UmlDiagram> {
} else if (arg1.startsWith("<<")) { } else if (arg1.startsWith("<<")) {
gender = EntityGenderUtils.byStereotype(arg1); gender = EntityGenderUtils.byStereotype(arg1);
} else { } else {
final IEntity entity = diagram.getOrCreateLeaf(diagram.buildLeafIdent(arg1), diagram.buildCode(arg1), null, final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(arg1), false);
null); if (quark.getData() == null)
return CommandExecutionResult.error("No such element " + quark.getName());
// final IEntity entity = diagram.getOrCreateLeaf(quark,
// diagram.buildFromFullPath(arg1), null, null);
final EntityImp entity = (EntityImp) quark.getData();
gender = EntityGenderUtils.byEntityAlone(entity); gender = EntityGenderUtils.byEntityAlone(entity);
} }
@ -189,9 +192,15 @@ public class CommandHideShowByGender extends SingleLineCommand2<UmlDiagram> {
gender = EntityGenderUtils.byStereotype(arg1); gender = EntityGenderUtils.byStereotype(arg1);
} else { } else {
arg1 = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg1); arg1 = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg1);
final Ident ident = diagram.buildLeafIdent(arg1); final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(arg1), false);
final Code code = diagram.buildCode(arg1); EntityImp entity = (EntityImp) quark.getData();
final IEntity entity = diagram.getOrCreateLeaf(ident, code, null, null); if (entity == null)
return CommandExecutionResult.error("No such element " + quark.getName());
// entity = diagram.reallyCreateLeaf(quark,
// Display.getWithNewlines(quark.getParent()), LeafType.CLASS, null);
// final Quark ident = diagram.buildFromName(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg1));
// final Quark code = diagram.buildFromFullPath(arg1);
// final IEntity entity = diagram.getOrCreateLeaf(ident, code, null, null);
gender = EntityGenderUtils.byEntityAlone(entity); gender = EntityGenderUtils.byEntityAlone(entity);
} }
if (gender != null) { if (gender != null) {
@ -200,7 +209,7 @@ public class CommandHideShowByGender extends SingleLineCommand2<UmlDiagram> {
if (empty == true && emptyMembers == false) { if (empty == true && emptyMembers == false) {
gender = EntityGenderUtils.and(gender, emptyByGender(portion)); gender = EntityGenderUtils.and(gender, emptyByGender(portion));
} }
if (EntityUtils.groupRoot(diagram.getCurrentGroup()) == false) { if (diagram.getCurrentGroup().getQuark().isRoot() == false) {
gender = EntityGenderUtils.and(gender, EntityGenderUtils.byPackage(diagram.getCurrentGroup())); gender = EntityGenderUtils.and(gender, EntityGenderUtils.byPackage(diagram.getCurrentGroup()));
} }

View File

@ -41,7 +41,8 @@ import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlMode; import net.sourceforge.plantuml.UrlMode;
import net.sourceforge.plantuml.baraye.IEntity; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexConcat;
@ -49,9 +50,8 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexOr;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg; import net.sourceforge.plantuml.cucadiagram.LinkArg;
import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.cucadiagram.LinkDecor;
@ -157,8 +157,8 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
protected CommandExecutionResult executeArg(AbstractClassOrObjectDiagram diagram, LineLocation location, protected CommandExecutionResult executeArg(AbstractClassOrObjectDiagram diagram, LineLocation location,
RegexResult arg) throws NoSuchColorException { RegexResult arg) throws NoSuchColorException {
final String ent1String = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 0), "\""); String ent1String = diagram.cleanIdForQuark(arg.get("ENT1", 0));
final String ent2String = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 0), "\""); String ent2String = diagram.cleanIdForQuark(arg.get("ENT2", 0));
if (ent1String == null && ent2String == null) if (ent1String == null && ent2String == null)
return executeArgSpecial3(diagram, arg); return executeArgSpecial3(diagram, arg);
@ -168,35 +168,33 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
if (ent2String == null) if (ent2String == null)
return executeArgSpecial2(diagram, arg); return executeArgSpecial2(diagram, arg);
Ident ident1 = diagram.buildLeafIdentSpecial2(ent1String); // if (isGroupButNotTheCurrentGroup(diagram, ent1String) && isGroupButNotTheCurrentGroup(diagram, ent2String)) {
Ident ident2 = diagram.buildLeafIdentSpecial2(ent2String); // return executePackageLink(diagram, arg);
final Ident ident1pure = Ident.empty().add(ent1String, diagram.getNamespaceSeparator()); // }
final Ident ident2pure = Ident.empty().add(ent2String, diagram.getNamespaceSeparator());
Code code1 = diagram.buildCode(ent1String);
Code code2 = diagram.buildCode(ent2String);
if (isGroupButNotTheCurrentGroup(diagram, code1, ident1)
&& isGroupButNotTheCurrentGroup(diagram, code2, ident2)) {
return executePackageLink(diagram, arg);
}
String port1 = diagram.getPortFor(ent1String, ident1);
String port2 = diagram.getPortFor(ent2String, ident2);
if (port1 == null && removeMemberPartLegacy1972(diagram, ident1) != null) {
port1 = ident1.getPortMember();
code1 = removeMemberPartLegacy1972(diagram, ident1);
ident1 = ident1.removeMemberPart();
}
if (port2 == null && removeMemberPartLegacy1972(diagram, ident2) != null) {
port2 = ident2.getPortMember();
code2 = removeMemberPartLegacy1972(diagram, ident2);
ident2 = ident2.removeMemberPart();
}
final IEntity cl1 = getFoo1(diagram, code1, ident1, ident1pure);
final IEntity cl2 = getFoo1(diagram, code2, ident2, ident2pure);
String port1 = null;
String port2 = null;
final LinkType linkType = getLinkType(arg); final LinkType linkType = getLinkType(arg);
if (ent1String.contains("::") && diagram.getPlasma().getIfExistsFromName(ent1String) == null) {
port1 = diagram.getPortId(ent1String);
ent1String = diagram.removePortId(ent1String);
}
if (ent2String.contains("::") && diagram.getPlasma().getIfExistsFromName(ent2String) == null) {
port2 = diagram.getPortId(ent2String);
ent2String = diagram.removePortId(ent2String);
}
final Quark quark1 = diagram.quarkInContext(ent1String, false);
final Quark quark2 = diagram.quarkInContext(ent2String, false);
EntityImp cl1 = (EntityImp) quark1.getData();
if (cl1 == null)
cl1 = diagram.reallyCreateLeaf(quark1, Display.getWithNewlines(quark1.getName()), LeafType.CLASS, null);
EntityImp cl2 = (EntityImp) quark2.getData();
if (cl2 == null)
cl2 = diagram.reallyCreateLeaf(quark2, Display.getWithNewlines(quark2.getName()), LeafType.CLASS, null);
final Direction dir = getDirection(arg); final Direction dir = getDirection(arg);
final int queue; final int queue;
if (dir == Direction.LEFT || dir == Direction.RIGHT) if (dir == Direction.LEFT || dir == Direction.RIGHT)
@ -214,7 +212,7 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
.withQuantifier(labels.getFirstLabel(), labels.getSecondLabel()) .withQuantifier(labels.getFirstLabel(), labels.getSecondLabel())
.withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle()).withKal(kal1, kal2); .withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle()).withKal(kal1, kal2);
Link link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, Link link = new Link(diagram.getEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2,
linkType, linkArg); linkType, linkArg);
if (arg.get("URL", 0) != null) { if (arg.get("URL", 0) != null) {
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), UrlMode.STRICT); final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), UrlMode.STRICT);
@ -236,33 +234,13 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();
} }
private IEntity getFoo1(AbstractClassOrObjectDiagram diagram, Code code, Ident ident, Ident pure) { // private boolean isGroupButNotTheCurrentGroup(AbstractClassOrObjectDiagram diagram, String code) {
if (isGroupButNotTheCurrentGroup(diagram, code, ident)) // if (diagram.getCurrentGroup().getCodeGetName().equals(code))
return diagram.getGroup(code); // return false;
return diagram.getOrCreateLeaf(ident, code, null, null); //
} // return diagram.isGroup(code);
// }
private boolean isGroupButNotTheCurrentGroup(AbstractClassOrObjectDiagram diagram, Code code, Ident ident) {
if (diagram.getCurrentGroup().getCodeGetName().equals(code.getName()))
return false;
return diagram.isGroup(code);
}
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) { private void addLink(AbstractClassOrObjectDiagram diagram, Link link, String weight) {
diagram.addLink(link); diagram.addLink(link);
@ -290,8 +268,8 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
throws NoSuchColorException { throws NoSuchColorException {
final String ent1String = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 0), "\""); final String ent1String = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 0), "\"");
final String ent2String = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 0), "\""); final String ent2String = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 0), "\"");
final IEntity cl1 = diagram.getGroup(diagram.buildCode(ent1String)); final EntityImp cl1 = diagram.getGroup(ent1String);
final IEntity cl2 = diagram.getGroup(diagram.buildCode(ent2String)); final EntityImp cl2 = diagram.getGroup(ent2String);
final LinkType linkType = getLinkType(arg); final LinkType linkType = getLinkType(arg);
final Direction dir = getDirection(arg); final Direction dir = getDirection(arg);
@ -305,7 +283,7 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
final String firstLabel = arg.get("FIRST_LABEL", 0); final String firstLabel = arg.get("FIRST_LABEL", 0);
final String secondLabel = arg.get("SECOND_LABEL", 0); final String secondLabel = arg.get("SECOND_LABEL", 0);
final LinkArg linkArg = LinkArg.build(labelLink, queue, diagram.getSkinParam().classAttributeIconSize() > 0); final LinkArg linkArg = LinkArg.build(labelLink, queue, diagram.getSkinParam().classAttributeIconSize() > 0);
final Link link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1, final Link link = new Link(diagram.getEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1,
cl2, linkType, linkArg.withQuantifier(firstLabel, secondLabel) cl2, linkType, linkArg.withQuantifier(firstLabel, secondLabel)
.withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle())); .withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle()));
link.setColors(color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet())); link.setColors(color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet()));
@ -321,22 +299,63 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
private CommandExecutionResult executeArgSpecial1(AbstractClassOrObjectDiagram diagram, RegexResult arg) { private CommandExecutionResult executeArgSpecial1(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
final String name1A = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("COUPLE1", 0)); final String name1A = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("COUPLE1", 0));
final String name1B = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("COUPLE1", 1)); final String name1B = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("COUPLE1", 1));
final Code clName1A = diagram.buildCode(name1A);
final Code clName1B = diagram.buildCode(name1B);
if (diagram.leafExist(clName1A) == false)
return CommandExecutionResult.error("No class " + clName1A);
if (diagram.leafExist(clName1B) == false) Quark quark1A = diagram.quarkInContext(name1A, false);
return CommandExecutionResult.error("No class " + clName1B); Quark quark1B = diagram.quarkInContext(name1B, false);
final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 0), "\""); if (quark1A.getData() != null == false)
final Code ent2 = diagram.buildCode(idShort); return CommandExecutionResult.error("No class " + name1A);
final IEntity cl2 = diagram.getOrCreateLeaf(diagram.buildLeafIdent(idShort), ent2, null, null);
if (quark1B.getData() != null == false)
return CommandExecutionResult.error("No class " + name1B);
EntityImp cl1A = (EntityImp) quark1A.getData();
EntityImp cl1B = (EntityImp) quark1B.getData();
final String id2 = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 0), "\"");
final Quark ent2 = diagram.quarkInContext(id2, false);
EntityImp cl2 = (EntityImp) ent2.getData();
if (cl2 == null)
cl2 = diagram.reallyCreateLeaf(ent2, Display.getWithNewlines(ent2.getName()), LeafType.CLASS, null);
final LinkType linkType = getLinkType(arg); final LinkType linkType = getLinkType(arg);
final Display label = Display.getWithNewlines(arg.get("LABEL_LINK", 0)); final Display label = Display.getWithNewlines(arg.get("LABEL_LINK", 0));
final boolean result = diagram.associationClass(1, name1A, name1B, cl2, linkType, label); final boolean result = diagram.associationClass(1, cl1A, cl1B, cl2, linkType, label);
if (result == false)
return CommandExecutionResult.error("Cannot have more than 2 assocications");
return CommandExecutionResult.ok();
}
private CommandExecutionResult executeArgSpecial2(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
final String name2A = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("COUPLE2", 0));
final String name2B = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("COUPLE2", 1));
final Quark quark2A = diagram.quarkInContext(name2A, false);
final Quark quark2B = diagram.quarkInContext(name2B, false);
if (quark2A.getData() != null == false)
return CommandExecutionResult.error("No class " + name2A);
if (quark2B.getData() != null == false)
return CommandExecutionResult.error("No class " + name2B);
final EntityImp cl2A = (EntityImp) quark2A.getData();
final EntityImp cl2B = (EntityImp) quark2B.getData();
final String id1 = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 0), "\"");
final Quark ent1 = diagram.quarkInContext(id1, false);
EntityImp cl1 = (EntityImp) ent1.getData();
if (cl1 == null)
cl1 = diagram.reallyCreateLeaf(ent1, Display.getWithNewlines(ent1.getName()), LeafType.CLASS, null);
final LinkType linkType = getLinkType(arg);
final Display label = Display.getWithNewlines(arg.get("LABEL_LINK", 0));
final boolean result = diagram.associationClass(2, cl2A, cl2B, cl1, linkType, label);
if (result == false) if (result == false)
return CommandExecutionResult.error("Cannot have more than 2 assocications"); return CommandExecutionResult.error("Cannot have more than 2 assocications");
@ -344,61 +363,41 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
} }
private CommandExecutionResult executeArgSpecial3(AbstractClassOrObjectDiagram diagram, RegexResult arg) { private CommandExecutionResult executeArgSpecial3(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 Code clName1A = diagram.buildCode(name1A);
final Code clName1B = diagram.buildCode(name1B);
final Code clName2A = diagram.buildCode(name2A);
final Code clName2B = diagram.buildCode(name2B);
if (diagram.leafExist(clName1A) == false)
return CommandExecutionResult.error("No class " + clName1A);
if (diagram.leafExist(clName1B) == false) final String name1A = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("COUPLE1", 0));
return CommandExecutionResult.error("No class " + clName1B); final String name1B = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("COUPLE1", 1));
final String name2A = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("COUPLE2", 0));
final String name2B = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("COUPLE2", 1));
if (diagram.leafExist(clName2A) == false) final Quark quark1A = diagram.quarkInContext(name1A, false);
return CommandExecutionResult.error("No class " + clName2A); final Quark quark1B = diagram.quarkInContext(name1B, false);
final Quark quark2A = diagram.quarkInContext(name2A, false);
final Quark quark2B = diagram.quarkInContext(name2B, false);
if (diagram.leafExist(clName2B) == false) if (quark1A.getData() != null == false)
return CommandExecutionResult.error("No class " + clName2B); return CommandExecutionResult.error("No class " + name1A);
if (quark1B.getData() != null == false)
return CommandExecutionResult.error("No class " + name1B);
if (quark2A.getData() != null == false)
return CommandExecutionResult.error("No class " + name2A);
if (quark2B.getData() != null == false)
return CommandExecutionResult.error("No class " + name2B);
final EntityImp cl1A = (EntityImp) quark1A.getData();
final EntityImp cl1B = (EntityImp) quark1B.getData();
final EntityImp cl2A = (EntityImp) quark2A.getData();
final EntityImp cl2B = (EntityImp) quark2B.getData();
final LinkType linkType = getLinkType(arg); final LinkType linkType = getLinkType(arg);
final Display label = Display.getWithNewlines(arg.get("LABEL_LINK", 0)); final Display label = Display.getWithNewlines(arg.get("LABEL_LINK", 0));
return diagram.associationClass(name1A, name1B, name2A, name2B, linkType, label); return diagram.associationClass(cl1A, cl1B, cl2A, cl2B, linkType, label);
}
private CommandExecutionResult executeArgSpecial2(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
final String name2A = arg.get("COUPLE2", 0);
final String name2B = arg.get("COUPLE2", 1);
final Code clName2A = diagram.buildCode(name2A);
final Code clName2B = diagram.buildCode(name2B);
if (diagram.leafExist(clName2A) == false)
return CommandExecutionResult.error("No class " + clName2A);
if (diagram.leafExist(clName2B) == false)
return CommandExecutionResult.error("No class " + clName2B);
final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 0), "\"");
final Code ent1 = diagram.buildCode(idShort);
final IEntity cl1 = diagram.getOrCreateLeaf(diagram.buildLeafIdent(idShort), ent1, 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 LinkDecor getDecors1(String s) { private LinkDecor getDecors1(String s) {
if (s == null) { if (s == null)
return LinkDecor.NONE; return LinkDecor.NONE;
}
s = StringUtils.trin(s); s = StringUtils.trin(s);
if ("<|".equals(s)) if ("<|".equals(s))
return LinkDecor.EXTENDS; return LinkDecor.EXTENDS;

View File

@ -1,601 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2023, 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
* Contribution : Hisashi Miyashita
*
*
*/
package net.sourceforge.plantuml.classdiagram.command;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlMode;
import net.sourceforge.plantuml.baraye.IEntity;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexOr;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg;
import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement;
import net.sourceforge.plantuml.descdiagram.command.Labels;
import net.sourceforge.plantuml.graphic.color.ColorParser;
import net.sourceforge.plantuml.graphic.color.ColorType;
import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram;
import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
import net.sourceforge.plantuml.utils.Direction;
import net.sourceforge.plantuml.utils.LineLocation;
final public class CommandLinkClass2 extends SingleLineCommand2<AbstractClassOrObjectDiagram> {
private static final String SINGLE = "[.\\\\]{0,2}[%pLN_]+(?:[.\\\\]{1,2}[%pLN_]+)*";
private static final String SINGLE_GUILLEMENT = "[%g][.\\\\]{0,2}[%pLN_]+(?:[.\\\\]{1,2}[%pLN_]+)*[%g]";
private static final String SINGLE2 = "(?:" + SINGLE + "|" + SINGLE_GUILLEMENT + ")";
private static final String COUPLE = "\\([%s]*(" + SINGLE2 + ")[%s]*,[%s]*(" + SINGLE2 + ")[%s]*\\)";
public CommandLinkClass2(UmlDiagramType umlDiagramType) {
super(getRegexConcat(umlDiagramType));
}
static private RegexConcat getRegexConcat(UmlDiagramType umlDiagramType) {
return RegexConcat.build(CommandLinkClass2.class.getName() + umlDiagramType, RegexLeaf.start(), //
new RegexOptional( //
new RegexConcat( //
new RegexLeaf("HEADER", "@([\\d.]+)"), //
RegexLeaf.spaceOneOrMore() //
)), new RegexOr( //
new RegexLeaf("ENT1", getClassIdentifier()), //
new RegexLeaf("COUPLE1", COUPLE)), //
RegexLeaf.spaceZeroOrMore(), //
new RegexOptional(new RegexConcat( //
RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("[\\[]"), //
new RegexLeaf("QUALIFIER1", "([^\\[\\]]+)"), //
new RegexLeaf("[\\]]"), //
RegexLeaf.spaceOneOrMore() //
)), //
new RegexOptional(new RegexLeaf("FIRST_LABEL", "[%g]([^%g]+)[%g]")), //
RegexLeaf.spaceZeroOrMore(), //
new RegexConcat(
//
new RegexLeaf("ARROW_HEAD1",
"((?<=[%s])+[ox]|[)#\\[<*+^}]|\\<_|\\<\\|[\\:\\|]|[<\\[]\\||\\}o|\\}\\||\\|o|\\|\\|)?"), //
new RegexLeaf("ARROW_BODY1", "([-=.]+)"), //
new RegexLeaf("ARROW_STYLE1", "(?:\\[(" + CommandLinkElement.LINE_STYLE + ")\\])?"), //
new RegexLeaf("ARROW_DIRECTION", "(left|right|up|down|le?|ri?|up?|do?)?"), //
new RegexOptional(new RegexLeaf("INSIDE", "(0|\\(0\\)|\\(0|0\\))(?=[-=.~])")), //
new RegexLeaf("ARROW_STYLE2", "(?:\\[(" + CommandLinkElement.LINE_STYLE + ")\\])?"), //
new RegexLeaf("ARROW_BODY2", "([-=.]*)"), //
new RegexLeaf("ARROW_HEAD2",
"([ox][%s]+|:\\>\\>?|_\\>|[(#\\]>*+^\\{]|[\\|\\:]\\|\\>|\\|[>\\]]|o\\{|\\|\\{|o\\||\\|\\|)?")), //
RegexLeaf.spaceZeroOrMore(), //
new RegexOptional(new RegexLeaf("SECOND_LABEL", "[%g]([^%g]+)[%g]")), //
new RegexOptional(new RegexConcat( //
RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("[\\[]"), //
new RegexLeaf("QUALIFIER2", "([^\\[\\]]+)"), //
new RegexLeaf("[\\]]"), //
RegexLeaf.spaceOneOrMore() //
)), //
RegexLeaf.spaceZeroOrMore(), //
new RegexOr( //
new RegexLeaf("ENT2", getClassIdentifier()), //
new RegexLeaf("COUPLE2", COUPLE)), //
RegexLeaf.spaceZeroOrMore(), //
color().getRegex(), //
RegexLeaf.spaceZeroOrMore(), //
UrlBuilder.OPTIONAL, //
RegexLeaf.spaceZeroOrMore(), //
new RegexOptional( //
new RegexConcat( //
new RegexLeaf(":"), //
RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("LABEL_LINK", "(.+)") //
)), RegexLeaf.end());
}
private static ColorParser color() {
return ColorParser.simpleColor(ColorType.LINE);
}
private static String getClassIdentifier() {
return "(" + getSeparator() + "?[%pLN_$]+(?:" + getSeparator() + "[%pLN_$]+)*|[%g][^%g]+[%g])";
}
public static String getSeparator() {
return "(?:\\.|::|\\\\|\\\\\\\\)";
}
@Override
protected CommandExecutionResult executeArg(AbstractClassOrObjectDiagram diagram, LineLocation location,
RegexResult arg) throws NoSuchColorException {
final String ent1String = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 0), "\"");
final String ent2String = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 0), "\"");
if (ent1String == null && ent2String == null)
return executeArgSpecial3(diagram, arg);
if (ent1String == null)
return executeArgSpecial1(diagram, arg);
if (ent2String == null)
return executeArgSpecial2(diagram, arg);
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.buildCode(ent1String);
Code code2 = diagram.buildCode(ent2String);
if (isGroupButNotTheCurrentGroup(diagram, code1, ident1)
&& isGroupButNotTheCurrentGroup(diagram, code2, ident2)) {
return executePackageLink(diagram, arg);
}
String port1 = null;
String port2 = null;
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, ident1pure);
final IEntity cl2 = getFoo1(diagram, code2, ident2, ident2pure);
final LinkType linkType = getLinkType(arg);
final Direction dir = getDirection(arg);
final int queue;
if (dir == Direction.LEFT || dir == Direction.RIGHT)
queue = 1;
else
queue = getQueueLength(arg);
final Labels labels = new Labels(arg);
final String kal1 = arg.get("QUALIFIER1", 0);
final String kal2 = arg.get("QUALIFIER2", 0);
final LinkArg linkArg = LinkArg
.build(labels.getDisplay(), queue, diagram.getSkinParam().classAttributeIconSize() > 0)
.withQuantifier(labels.getFirstLabel(), labels.getSecondLabel())
.withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle()).withKal(kal1, kal2);
Link link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2,
linkType, linkArg);
if (arg.get("URL", 0) != null) {
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), UrlMode.STRICT);
final Url url = urlBuilder.getUrl(arg.get("URL", 0));
link.setUrl(url);
}
link.setPortMembers(port1, port2);
if (dir == Direction.LEFT || dir == Direction.UP)
link = link.getInv();
link.setLinkArrow(labels.getLinkArrow());
link.setColors(color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet()));
link.applyStyle(arg.getLazzy("ARROW_STYLE", 0));
link.setCodeLine(location);
addLink(diagram, link, arg.get("HEADER", 0));
return CommandExecutionResult.ok();
}
private IEntity getFoo1(AbstractClassOrObjectDiagram diagram, Code code, Ident ident, Ident pure) {
if (isGroupButNotTheCurrentGroup(diagram, code, ident))
return diagram.getGroupVerySmart(ident);
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.isGroupStrict(ident))
return true;
return diagram.isGroup(code);
}
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) {
// final LinkType type = link.getType();
// --|> highest
// --*, -->, --o normal
// ..*, ..>, ..o lowest
// if (type.isDashed() == false) {
// if (type.contains(LinkDecor.EXTENDS)) {
// link.setWeight(3);
// }
// if (type.contains(LinkDecor.ARROW) ||
// type.contains(LinkDecor.COMPOSITION)
// || type.contains(LinkDecor.AGREGATION)) {
// link.setWeight(2);
// }
// }
} else {
link.setWeight(Double.parseDouble(weight));
}
}
private CommandExecutionResult executePackageLink(AbstractClassOrObjectDiagram diagram, RegexResult arg)
throws NoSuchColorException {
final String ent1String = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 0), "\"");
final String ent2String = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 0), "\"");
Ident ident1 = diagram.buildLeafIdentSpecial(ent1String);
Ident ident2 = diagram.buildLeafIdentSpecial(ent2String);
final Ident ident1pure = Ident.empty().add(ent1String, diagram.getNamespaceSeparator());
final Ident ident2pure = Ident.empty().add(ent2String, diagram.getNamespaceSeparator());
Code code1 = diagram.buildCode(ent1String);
Code code2 = diagram.buildCode(ent2String);
if (removeMemberPartLegacy1972(diagram, ident1) != null) {
code1 = removeMemberPartLegacy1972(diagram, ident1);
ident1 = ident1.removeMemberPart();
}
if (removeMemberPartLegacy1972(diagram, ident2) != null) {
code2 = removeMemberPartLegacy1972(diagram, ident2);
ident2 = ident2.removeMemberPart();
}
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);
final int queue;
if (dir == Direction.LEFT || dir == Direction.RIGHT)
queue = 1;
else
queue = getQueueLength(arg);
final Display labelLink = Display.getWithNewlines(arg.get("LABEL_LINK", 0));
final String firstLabel = arg.get("FIRST_LABEL", 0);
final String secondLabel = arg.get("SECOND_LABEL", 0);
final LinkArg linkArg = LinkArg.build(labelLink, queue, diagram.getSkinParam().classAttributeIconSize() > 0);
final Link link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1,
cl2, linkType, linkArg.withQuantifier(firstLabel, secondLabel)
.withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle()));
link.setColors(color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet()));
diagram.resetPragmaLabel();
link.applyStyle(arg.getLazzy("ARROW_STYLE", 0));
addLink(diagram, link, arg.get("HEADER", 0));
return CommandExecutionResult.ok();
}
private CommandExecutionResult executeArgSpecial1(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
final String name1A = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("COUPLE1", 0));
final String name1B = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("COUPLE1", 1));
final Code clName1A = diagram.buildCode(name1A);
final Code clName1B = diagram.buildCode(name1B);
if (diagram.leafExist(clName1A) == false)
return CommandExecutionResult.error("No class " + clName1A);
if (diagram.leafExist(clName1B) == false)
return CommandExecutionResult.error("No class " + clName1B);
final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 0), "\"");
final Code ent2 = diagram.buildCode(idShort);
final IEntity cl2 = diagram.getOrCreateLeaf(diagram.buildLeafIdent(idShort), ent2, 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 executeArgSpecial3(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 Code clName1A = diagram.buildCode(name1A);
final Code clName1B = diagram.buildCode(name1B);
final Code clName2A = diagram.buildCode(name2A);
final Code clName2B = diagram.buildCode(name2B);
if (diagram.leafExist(clName1A) == false)
return CommandExecutionResult.error("No class " + clName1A);
if (diagram.leafExist(clName1B) == false)
return CommandExecutionResult.error("No class " + clName1B);
if (diagram.leafExist(clName2A) == false)
return CommandExecutionResult.error("No class " + clName2A);
if (diagram.leafExist(clName2B) == false)
return CommandExecutionResult.error("No class " + clName2B);
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 executeArgSpecial2(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
final String name2A = arg.get("COUPLE2", 0);
final String name2B = arg.get("COUPLE2", 1);
final Code clName2A = diagram.buildCode(name2A);
final Code clName2B = diagram.buildCode(name2B);
if (diagram.leafExist(clName2A) == false)
return CommandExecutionResult.error("No class " + clName2A);
if (diagram.leafExist(clName2B) == false)
return CommandExecutionResult.error("No class " + clName2B);
final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 0), "\"");
final Code ent1 = diagram.buildCode(idShort);
final IEntity cl1 = diagram.getOrCreateLeaf(diagram.buildLeafIdent(idShort), ent1, 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 LinkDecor getDecors1(String s) {
if (s == null) {
return LinkDecor.NONE;
}
s = StringUtils.trin(s);
if ("<|".equals(s))
return LinkDecor.EXTENDS;
if ("<|:".equals(s))
return LinkDecor.DEFINEDBY;
if ("<||".equals(s))
return LinkDecor.REDEFINES;
if ("}".equals(s))
return LinkDecor.CROWFOOT;
if ("}o".equals(s))
return LinkDecor.CIRCLE_CROWFOOT;
if ("}|".equals(s))
return LinkDecor.LINE_CROWFOOT;
if ("|o".equals(s))
return LinkDecor.CIRCLE_LINE;
if ("||".equals(s))
return LinkDecor.DOUBLE_LINE;
if ("<".equals(s))
return LinkDecor.ARROW;
if ("^".equals(s))
return LinkDecor.EXTENDS;
if ("+".equals(s))
return LinkDecor.PLUS;
if ("o".equals(s))
return LinkDecor.AGREGATION;
if ("x".equals(s))
return LinkDecor.NOT_NAVIGABLE;
if ("*".equals(s))
return LinkDecor.COMPOSITION;
if ("#".equals(s))
return LinkDecor.SQUARE;
if (")".equals(s))
return LinkDecor.PARENTHESIS;
return LinkDecor.NONE;
}
private LinkDecor getDecors2(String s) {
if (s == null)
return LinkDecor.NONE;
s = StringUtils.trin(s);
if ("|>".equals(s))
return LinkDecor.EXTENDS;
if (":|>".equals(s))
return LinkDecor.DEFINEDBY;
if ("||>".equals(s))
return LinkDecor.REDEFINES;
if (">".equals(s))
return LinkDecor.ARROW;
if ("{".equals(s))
return LinkDecor.CROWFOOT;
if ("o{".equals(s))
return LinkDecor.CIRCLE_CROWFOOT;
if ("|{".equals(s))
return LinkDecor.LINE_CROWFOOT;
if ("o|".equals(s))
return LinkDecor.CIRCLE_LINE;
if ("||".equals(s))
return LinkDecor.DOUBLE_LINE;
if ("^".equals(s))
return LinkDecor.EXTENDS;
if ("+".equals(s))
return LinkDecor.PLUS;
if ("o".equals(s))
return LinkDecor.AGREGATION;
if ("x".equals(s))
return LinkDecor.NOT_NAVIGABLE;
if ("*".equals(s))
return LinkDecor.COMPOSITION;
if ("#".equals(s))
return LinkDecor.SQUARE;
if ("(".equals(s))
return LinkDecor.PARENTHESIS;
return LinkDecor.NONE;
}
private LinkType getLinkType(RegexResult arg) {
final LinkDecor decors1 = getDecors1(getArrowHead1(arg));
final LinkDecor decors2 = getDecors2(getArrowHead2(arg));
LinkType result = new LinkType(decors2, decors1);
if (arg.get("ARROW_BODY1", 0).contains(".") || arg.get("ARROW_BODY2", 0).contains("."))
result = result.goDashed();
final String middle = arg.get("INSIDE", 0);
if ("0".equals(middle))
result = result.withMiddleCircle();
else if ("0)".equals(middle))
result = result.withMiddleCircleCircled1();
else if ("(0".equals(middle))
result = result.withMiddleCircleCircled2();
else if ("(0)".equals(middle))
result = result.withMiddleCircleCircled();
return result;
}
private int getQueueLength(RegexResult arg) {
String s = getFullArrow(arg);
s = s.replaceAll("[^-.=]", "");
return s.length();
}
private Direction getDirection(RegexResult arg) {
// final LinkDecor decors1 = getDecors1(getArrowHead1(arg));
// final LinkDecor decors2 = getDecors2(getArrowHead2(arg));
String s = getFullArrow(arg);
s = s.replaceAll("[^-.=\\w]", "");
if (s.startsWith("o"))
s = s.substring(1);
if (s.endsWith("o"))
s = s.substring(0, s.length() - 1);
Direction result = StringUtils.getQueueDirection(s);
// if (isInversed(decors1, decors2) && s.matches(".*\\w.*")) {
// result = result.getInv();
// }
return result;
}
private String getArrowHead1(RegexResult arg) {
return getArrowHead(arg, "ARROW_HEAD1");
}
private String getArrowHead2(RegexResult arg) {
return getArrowHead(arg, "ARROW_HEAD2");
}
private String getArrowHead(RegexResult arg, final String key) {
return notNull(arg.get(key, 0));
}
private String getFullArrow(RegexResult arg) {
return getArrowHead1(arg) + notNull(arg.get("ARROW_BODY1", 0)) + notNull(arg.get("ARROW_DIRECTION", 0))
+ notNull(arg.get("ARROW_BODY2", 0)) + getArrowHead2(arg);
}
public static String notNull(String s) {
if (s == null)
return "";
return s;
}
}

View File

@ -37,7 +37,8 @@ package net.sourceforge.plantuml.classdiagram.command;
import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.baraye.IEntity; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.Matcher2; import net.sourceforge.plantuml.command.regex.Matcher2;
@ -48,9 +49,7 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexOr;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg; import net.sourceforge.plantuml.cucadiagram.LinkArg;
@ -119,27 +118,40 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
final String ent1 = arg.get("ENT1", 1); final String ent1 = arg.get("ENT1", 1);
final String ent2 = arg.get("ENT2", 1); final String ent2 = arg.get("ENT2", 1);
final IEntity cl1; final EntityImp cl1;
final IEntity cl2; final EntityImp cl2;
final IEntity normalEntity; final EntityImp normalEntity;
final String suffix = "lol" + diagram.getUniqueSequence(); final String suffix = "lol" + diagram.getUniqueSequence();
if (arg.get("LOL_THEN_ENT", 1) == null) { if (arg.get("LOL_THEN_ENT", 1) == null) {
assert arg.get("ENT_THEN_LOL", 0) != null;
final Ident ident1 = diagram.buildLeafIdent(ent1); final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(ent1), false);
final Code ent1code = diagram.buildCode(ent1); cl1 = (EntityImp) quark.getData();
cl1 = getFoo1(diagram, ent1code, ident1); if (cl1 == null)
final Ident idNewLong = diagram.buildLeafIdent(ent1 + suffix); return CommandExecutionResult.error("No class " + quark.getName());
cl2 = diagram.createLeaf(idNewLong, idNewLong.toCode(diagram), Display.getWithNewlines(ent2),
getType(arg.get("ENT_THEN_LOL", 1)), null); final Quark idNewLong = diagram.quarkInContext(diagram.cleanIdForQuark(ent1) + suffix, false);
final LeafType type = getType(arg.get("ENT_THEN_LOL", 1));
cl2 = diagram.reallyCreateLeaf(idNewLong, Display.getWithNewlines(ent2), type, null);
normalEntity = cl1; normalEntity = cl1;
// assert arg.get("ENT_THEN_LOL", 0) != null;
// final Quark ident1 = diagram.buildFromName(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(ent1));
// final Quark ent1code = diagram.buildFromFullPath(ent1);
// cl1 = diagram.getOrCreateLeaf(ident1, ent1code, null, null);
// final Quark idNewLong = diagram.quarkInContext(diagram.cleanIdForQuark(ent1) + suffix);
// cl2 = diagram.reallyCreateLeaf(idNewLong, Display.getWithNewlines(ent2),
// getType(arg.get("ENT_THEN_LOL", 1)), null);
// normalEntity = cl1;
} else { } else {
final Ident ident2 = diagram.buildLeafIdent(ent2); final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(ent2), false);
final Code ent2code = diagram.buildCode(ent2); cl2 = (EntityImp) quark.getData();
cl2 = getFoo1(diagram, ent2code, ident2); if (cl2 == null)
final Ident idNewLong = diagram.buildLeafIdent(ent2 + suffix); return CommandExecutionResult.error("No class " + quark.getName());
cl1 = diagram.createLeaf(idNewLong, idNewLong.toCode(diagram), Display.getWithNewlines(ent1),
getType(arg.get("LOL_THEN_ENT", 0)), null); final Quark idNewLong = diagram.quarkInContext(diagram.cleanIdForQuark(ent2) + suffix, false);
final LeafType type = getType(arg.get("LOL_THEN_ENT", 0));
cl1 = diagram.reallyCreateLeaf(idNewLong, Display.getWithNewlines(ent1), type, null);
normalEntity = cl2; normalEntity = cl2;
} }
@ -189,7 +201,7 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
} }
final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(labelLink), length, final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(labelLink), length,
diagram.getSkinParam().classAttributeIconSize() > 0); diagram.getSkinParam().classAttributeIconSize() > 0);
final Link link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1, final Link link = new Link(diagram.getEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1,
cl2, linkType, linkArg.withQuantifier(firstLabel, secondLabel) cl2, linkType, linkArg.withQuantifier(firstLabel, secondLabel)
.withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle())); .withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle()));
diagram.resetPragmaLabel(); diagram.resetPragmaLabel();
@ -198,10 +210,6 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();
} }
private IEntity getFoo1(AbstractClassOrObjectDiagram diagram, final Code code, final Ident ident) {
return diagram.getOrCreateLeaf(ident, code, null, null);
}
private void addLink(AbstractClassOrObjectDiagram diagram, Link link, String weight) { private void addLink(AbstractClassOrObjectDiagram diagram, Link link, String weight) {
diagram.addLink(link); diagram.addLink(link);
if (weight == null) { if (weight == null) {

View File

@ -36,7 +36,8 @@
package net.sourceforge.plantuml.classdiagram.command; package net.sourceforge.plantuml.classdiagram.command;
import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.baraye.IEntity; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.classdiagram.ClassDiagram;
import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.SingleLineCommand2;
@ -44,8 +45,6 @@ import net.sourceforge.plantuml.command.regex.IRegex;
import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
import net.sourceforge.plantuml.utils.LineLocation; import net.sourceforge.plantuml.utils.LineLocation;
@ -68,10 +67,16 @@ public class CommandStereotype extends SingleLineCommand2<ClassDiagram> {
protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg)
throws NoSuchColorException { throws NoSuchColorException {
final String name = arg.get("NAME", 0); final String name = arg.get("NAME", 0);
final Ident ident = diagram.buildLeafIdent(name);
final Code code = diagram.buildCode(name);
final String stereotype = arg.get("STEREO", 0); final String stereotype = arg.get("STEREO", 0);
final IEntity entity = diagram.getOrCreateLeaf(ident, code, null, null);
// final Quark ident = diagram.buildFromName(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(name));
// final Quark code = diagram.buildFromFullPath(name);
// final IEntity entity = diagram.getOrCreateLeaf(ident, code, null, null);
final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(name), false);
final EntityImp entity = (EntityImp) quark.getData();
if (entity == null)
return CommandExecutionResult.error("No such class " + quark.getName());
entity.setStereotype(Stereotype.build(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), entity.setStereotype(Stereotype.build(stereotype, diagram.getSkinParam().getCircledCharacterRadius(),
diagram.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER), diagram.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER),
diagram.getSkinParam().getIHtmlColorSet())); diagram.getSkinParam().getIHtmlColorSet()));

View File

@ -38,7 +38,8 @@ package net.sourceforge.plantuml.classdiagram.command;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlMode; import net.sourceforge.plantuml.UrlMode;
import net.sourceforge.plantuml.baraye.IEntity; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.SingleLineCommand2;
@ -47,8 +48,6 @@ import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.utils.LineLocation; import net.sourceforge.plantuml.utils.LineLocation;
public class CommandUrl extends SingleLineCommand2<AbstractEntityDiagram> { public class CommandUrl extends SingleLineCommand2<AbstractEntityDiagram> {
@ -75,17 +74,22 @@ public class CommandUrl extends SingleLineCommand2<AbstractEntityDiagram> {
@Override @Override
protected CommandExecutionResult executeArg(AbstractEntityDiagram diagram, LineLocation location, RegexResult arg) { protected CommandExecutionResult executeArg(AbstractEntityDiagram diagram, LineLocation location, RegexResult arg) {
final String idShort = arg.get("CODE", 0); final String idShort = arg.get("CODE", 0);
final Ident ident = diagram.buildLeafIdent(idShort); // final Quark ident = diagram.buildFromName(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(idShort));
final Code code = diagram.buildCode(idShort); // final Quark code = diagram.buildFromFullPath(idShort);
final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(idShort), false);
final EntityImp entity = (EntityImp) quark.getData();
if (entity == null)
return CommandExecutionResult.error(quark.getName() + " does not exist");
final String urlString = arg.get("URL", 0); final String urlString = arg.get("URL", 0);
final IEntity entity; // final boolean leafExist = code.getData() != null;
final boolean leafExist = diagram.leafExist(code); // if (leafExist)
if (leafExist) // entity = diagram.getOrCreateLeaf(ident, code, null, null);
entity = diagram.getOrCreateLeaf(ident, code, null, null); // else if (diagram.isGroup(idShort))
else if (diagram.isGroup(code)) // entity = diagram.getGroup(idShort);
entity = diagram.getGroup(code); // else
else // return CommandExecutionResult.error(code + " does not exist");
return CommandExecutionResult.error(code + " does not exist");
// final IEntity entity = diagram.getOrCreateLeaf(code, null); // final IEntity entity = diagram.getOrCreateLeaf(code, null);
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), UrlMode.STRICT); final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), UrlMode.STRICT);

View File

@ -44,16 +44,15 @@ import net.sourceforge.plantuml.brotli.BrotliInputStream;
import net.sourceforge.plantuml.log.Logme; import net.sourceforge.plantuml.log.Logme;
public class CompressionBrotli implements Compression { public class CompressionBrotli implements Compression {
// ::remove file when WASM
public byte[] compress(byte[] in) { public byte[] compress(byte[] in) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public ByteArray decompress(byte[] in) throws NoPlantumlCompressionException { public ByteArray decompress(byte[] in) throws NoPlantumlCompressionException {
try ( try (final BrotliInputStream brotli = new BrotliInputStream(new ByteArrayInputStream(in));
final BrotliInputStream brotli = new BrotliInputStream(new ByteArrayInputStream(in)); final ByteArrayOutputStream result = new ByteArrayOutputStream();) {
final ByteArrayOutputStream result = new ByteArrayOutputStream();
) {
FileUtils.copyToStream(brotli, result); FileUtils.copyToStream(brotli, result);
return ByteArray.from(result.toByteArray()); return ByteArray.from(result.toByteArray());
} catch (IOException e) { } catch (IOException e) {

View File

@ -43,12 +43,16 @@ import net.sourceforge.plantuml.code.deflate.Decompressor;
public class CompressionZlib implements Compression { public class CompressionZlib implements Compression {
// ::comment when WASM
private static boolean USE_ZOPFLI = false; private static boolean USE_ZOPFLI = false;
// ::done
private static final int COMPRESSION_LEVEL = 9; private static final int COMPRESSION_LEVEL = 9;
public byte[] compress(byte[] in) { public byte[] compress(byte[] in) {
// ::comment when WASM
if (USE_ZOPFLI) if (USE_ZOPFLI)
return new CompressionZopfliZlib().compress(in); return new CompressionZopfliZlib().compress(in);
// ::done
if (in.length == 0) if (in.length == 0)
return null; return null;

View File

@ -42,6 +42,7 @@ import java.util.zip.Inflater;
@Deprecated @Deprecated
public class CompressionZlibAttic implements Compression { public class CompressionZlibAttic implements Compression {
// ::remove file when WASM
private static boolean USE_ZOPFLI = false; private static boolean USE_ZOPFLI = false;
private static final int COMPRESSION_LEVEL = 9; private static final int COMPRESSION_LEVEL = 9;

View File

@ -41,6 +41,7 @@ import net.sourceforge.plantuml.zopfli.Options.OutputFormat;
import net.sourceforge.plantuml.zopfli.Zopfli; import net.sourceforge.plantuml.zopfli.Zopfli;
public class CompressionZopfliZlib implements Compression { public class CompressionZopfliZlib implements Compression {
// ::remove file when WASM
public byte[] compress(byte[] in) { public byte[] compress(byte[] in) {
if (in.length == 0) if (in.length == 0)

View File

@ -62,7 +62,9 @@ public class CommandAffineTransform extends SingleLineCommand2<UmlDiagram> {
@Override @Override
protected CommandExecutionResult executeArg(UmlDiagram diagram, LineLocation location, RegexResult arg) { protected CommandExecutionResult executeArg(UmlDiagram diagram, LineLocation location, RegexResult arg) {
final CharSequence value = arg.get("ANIMATION", 0); final CharSequence value = arg.get("ANIMATION", 0);
// ::comment when WASM
diagram.setAnimation(Collections.singletonList(value)); diagram.setAnimation(Collections.singletonList(value));
// ::done
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();
} }

View File

@ -38,20 +38,15 @@ package net.sourceforge.plantuml.command;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlMode; import net.sourceforge.plantuml.UrlMode;
import net.sourceforge.plantuml.baraye.CucaDiagram; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.baraye.IEntity;
import net.sourceforge.plantuml.baraye.IGroup;
import net.sourceforge.plantuml.baraye.Quark; import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.classdiagram.ClassDiagram;
import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.IRegex;
import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.GroupType; import net.sourceforge.plantuml.cucadiagram.GroupType;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy;
import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.graphic.USymbols; import net.sourceforge.plantuml.graphic.USymbols;
@ -87,27 +82,14 @@ public class CommandNamespace extends SingleLineCommand2<ClassDiagram> {
protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg)
throws NoSuchColorException { throws NoSuchColorException {
final String idShort = arg.get("NAME", 0); final String idShort = arg.get("NAME", 0);
final Code code; // final Quark current = diagram.currentQuark();
final IGroup currentPackage; // final Quark idNewLong = current.child(idShort);
final Display display; final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(idShort), true);
final Ident idNewLong; final CommandExecutionResult status = diagram.gotoGroup(quark,
if (CucaDiagram.QUARK) { Display.getWithNewlines(quark.getQualifiedName()), GroupType.PACKAGE);
final Quark current = diagram.currentQuark();
code = current;
display = Display.getWithNewlines(idShort);
idNewLong = current.child(idShort);
currentPackage = (IGroup) current.getData();
} else {
idNewLong = diagram.buildLeafIdent(idShort);
code = diagram.buildCode(idShort);
currentPackage = diagram.getCurrentGroup();
display = Display.getWithNewlines(code);
}
final CommandExecutionResult status = diagram.gotoGroup(idNewLong, code, display, GroupType.PACKAGE,
currentPackage, NamespaceStrategy.MULTIPLE);
if (status.isOk() == false) if (status.isOk() == false)
return status; return status;
final IEntity p = diagram.getCurrentGroup(); final EntityImp p = diagram.getCurrentGroup();
final String stereotype = arg.get("STEREOTYPE", 0); final String stereotype = arg.get("STEREOTYPE", 0);
if (stereotype != null) { if (stereotype != null) {
final USymbol usymbol = USymbols.fromString(stereotype, diagram.getSkinParam().actorStyle(), final USymbol usymbol = USymbols.fromString(stereotype, diagram.getSkinParam().actorStyle(),

View File

@ -38,18 +38,15 @@ package net.sourceforge.plantuml.command;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlMode; import net.sourceforge.plantuml.UrlMode;
import net.sourceforge.plantuml.baraye.IEntity; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.baraye.IGroup; import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.classdiagram.ClassDiagram;
import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.IRegex;
import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.GroupType; import net.sourceforge.plantuml.cucadiagram.GroupType;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy;
import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorParser;
import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.ColorType;
@ -89,16 +86,15 @@ public class CommandNamespace2 extends SingleLineCommand2<ClassDiagram> {
protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg)
throws NoSuchColorException { throws NoSuchColorException {
final String idShort = arg.get("NAME", 0); final String idShort = arg.get("NAME", 0);
final Ident ident = diagram.buildLeafIdent(idShort); // final Quark ident = diagram.buildFromName(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(idShort));
final Code code = diagram.buildCode(idShort); final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(idShort), true);
final IGroup currentPackage = diagram.getCurrentGroup();
final String disp = arg.getLazzy("DISPLAY", 0); final String disp = arg.getLazzy("DISPLAY", 0);
final Display display = Display.getWithNewlines(disp); final Display display = Display.getWithNewlines(disp);
final CommandExecutionResult status = diagram.gotoGroup(ident, code, display, GroupType.PACKAGE, currentPackage, final CommandExecutionResult status = diagram.gotoGroup(quark, display, GroupType.PACKAGE);
NamespaceStrategy.MULTIPLE);
if (status.isOk() == false) if (status.isOk() == false)
return status; return status;
final IEntity p = diagram.getCurrentGroup(); final EntityImp p = diagram.getCurrentGroup();
final String stereotype = arg.get("STEREOTYPE", 0); final String stereotype = arg.get("STEREOTYPE", 0);
if (stereotype != null) if (stereotype != null)
p.setStereotype(Stereotype.build(stereotype)); p.setStereotype(Stereotype.build(stereotype));

View File

@ -38,18 +38,15 @@ package net.sourceforge.plantuml.command;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlMode; import net.sourceforge.plantuml.UrlMode;
import net.sourceforge.plantuml.baraye.IEntity; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.baraye.IGroup; import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.classdiagram.ClassDiagram;
import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.IRegex;
import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.GroupType; import net.sourceforge.plantuml.cucadiagram.GroupType;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy;
import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorParser;
import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.ColorType;
@ -84,15 +81,20 @@ public class CommandNamespaceEmpty extends SingleLineCommand2<ClassDiagram> {
protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg)
throws NoSuchColorException { throws NoSuchColorException {
final String idShort = arg.get("NAME", 0); final String idShort = arg.get("NAME", 0);
final Ident idNewLong = diagram.buildLeafIdent(idShort);
final Code code = diagram.buildCode(idShort); final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(idShort), true);
final IGroup currentPackage = diagram.getCurrentGroup(); if (quark.getData() != null)
final Display display = Display.getWithNewlines(code); return CommandExecutionResult.error("Already exists " + quark.getName());
final CommandExecutionResult status = diagram.gotoGroup(idNewLong, code, display, GroupType.PACKAGE,
currentPackage, NamespaceStrategy.MULTIPLE); // final Quark idNewLong = diagram
// .buildFromName(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(idShort));
// final Quark code = diagram.buildFromFullPath(idShort);
final Display display = Display.getWithNewlines(quark.getQualifiedName());
final CommandExecutionResult status = diagram.gotoGroup(quark, display, GroupType.PACKAGE);
if (status.isOk() == false) if (status.isOk() == false)
return status; return status;
final IEntity p = diagram.getCurrentGroup(); final EntityImp p = diagram.getCurrentGroup();
final String stereotype = arg.get("STEREOTYPE", 0); final String stereotype = arg.get("STEREOTYPE", 0);
if (stereotype != null) if (stereotype != null)
p.setStereotype(Stereotype.build(stereotype)); p.setStereotype(Stereotype.build(stereotype));

View File

@ -39,9 +39,7 @@ import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlMode; import net.sourceforge.plantuml.UrlMode;
import net.sourceforge.plantuml.baraye.CucaDiagram; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.baraye.IEntity;
import net.sourceforge.plantuml.baraye.IGroup;
import net.sourceforge.plantuml.baraye.Quark; import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
import net.sourceforge.plantuml.classdiagram.command.CommandCreateClassMultilines; import net.sourceforge.plantuml.classdiagram.command.CommandCreateClassMultilines;
@ -50,11 +48,8 @@ import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.GroupType; import net.sourceforge.plantuml.cucadiagram.GroupType;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy;
import net.sourceforge.plantuml.cucadiagram.Stereotag; import net.sourceforge.plantuml.cucadiagram.Stereotag;
import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.graphic.USymbol;
@ -108,42 +103,41 @@ public class CommandPackage extends SingleLineCommand2<AbstractEntityDiagram> {
@Override @Override
protected CommandExecutionResult executeArg(AbstractEntityDiagram diagram, LineLocation location, RegexResult arg) protected CommandExecutionResult executeArg(AbstractEntityDiagram diagram, LineLocation location, RegexResult arg)
throws NoSuchColorException { throws NoSuchColorException {
final String idShort; String idShort;
/* final */String display; String display;
final String name = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("NAME", 0)); final String name = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("NAME", 0));
boolean override1972 = false;
if (arg.get("AS", 0) == null) { if (arg.get("AS", 0) == null) {
if (name.length() == 0) { if (name.length() == 0) {
idShort = "##" + diagram.getUniqueSequence(); idShort = "##" + diagram.getUniqueSequence();
display = null; display = null;
throw new IllegalStateException("AS");
} else { } else {
idShort = name; idShort = name;
display = idShort; display = idShort;
override1972 = true;
} }
} else { } else {
display = name; display = name;
idShort = arg.get("AS", 0); idShort = arg.get("AS", 0);
} }
final Ident ident; // final Quark current = diagram.currentQuark();
final Code code; // final Quark ident = current.child(idShort);
final Quark quark;
if (CucaDiagram.QUARK) { if (arg.get("AS", 0) == null) {
final Quark current = diagram.currentQuark(); quark = diagram.quarkInContext(diagram.cleanIdForQuark(name), true);
code = current; display = quark.getQualifiedName();
ident = current.child(idShort);
} else { } else {
ident = diagram.buildLeafIdent(idShort); quark = diagram.quarkInContext(diagram.cleanIdForQuark(arg.get("AS", 0)), true);
code = diagram.buildCode(idShort); display = name;
} }
final IGroup currentPackage = diagram.getCurrentGroup();
final CommandExecutionResult status = diagram.gotoGroup(ident, code, Display.getWithNewlines(display), final CommandExecutionResult status = diagram.gotoGroup(quark, Display.getWithNewlines(display),
GroupType.PACKAGE, currentPackage, NamespaceStrategy.SINGLE); GroupType.PACKAGE);
if (status.isOk() == false) if (status.isOk() == false)
return status; return status;
final IEntity p = diagram.getCurrentGroup(); final EntityImp p = diagram.getCurrentGroup();
final String stereotype = arg.get("STEREOTYPE", 0); final String stereotype = arg.get("STEREOTYPE", 0);

View File

@ -36,19 +36,16 @@
package net.sourceforge.plantuml.command; package net.sourceforge.plantuml.command;
import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.baraye.IEntity; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.baraye.IGroup; import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.IRegex;
import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.GroupType; import net.sourceforge.plantuml.cucadiagram.GroupType;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy;
import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.ColorType;
import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
import net.sourceforge.plantuml.utils.LineLocation; import net.sourceforge.plantuml.utils.LineLocation;
@ -97,14 +94,12 @@ public class CommandPackageEmpty extends SingleLineCommand2<AbstractEntityDiagra
display = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("DISPLAY", 0)); display = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("DISPLAY", 0));
idShort = arg.get("CODE", 0); idShort = arg.get("CODE", 0);
} }
final IGroup currentPackage = diagram.getCurrentGroup(); final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(idShort), true);
final Ident ident = diagram.buildLeafIdent(idShort); final CommandExecutionResult status = diagram.gotoGroup(quark, Display.getWithNewlines(display),
final Code code = diagram.buildCode(idShort); GroupType.PACKAGE);
final CommandExecutionResult status = diagram.gotoGroup(ident, code, Display.getWithNewlines(display),
GroupType.PACKAGE, currentPackage, NamespaceStrategy.SINGLE);
if (status.isOk() == false) if (status.isOk() == false)
return status; return status;
final IEntity p = diagram.getCurrentGroup(); final EntityImp p = diagram.getCurrentGroup();
final String color = arg.get("COLOR", 0); final String color = arg.get("COLOR", 0);
if (color != null) if (color != null)
p.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet().getColor(color)); p.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet().getColor(color));

View File

@ -78,23 +78,25 @@ public class CommandPragma extends SingleLineCommand2<TitledDiagram> {
} }
} else { } else {
system.getPragma().define(name, value); system.getPragma().define(name, value);
if (name.equalsIgnoreCase("graphviz_dot") && value.equalsIgnoreCase("jdot")) { // ::comment when WASM
if (name.equalsIgnoreCase("graphviz_dot") && value.equalsIgnoreCase("jdot"))
return CommandExecutionResult.error( return CommandExecutionResult.error(
"This directive has been renamed to '!pragma layout smetana'. Please update your diagram."); "This directive has been renamed to '!pragma layout smetana'. Please update your diagram.");
}
if (name.equalsIgnoreCase("graphviz_dot")) { if (name.equalsIgnoreCase("graphviz_dot"))
return CommandExecutionResult.error("This directive has been renamed to '!pragma layout " + value return CommandExecutionResult.error("This directive has been renamed to '!pragma layout " + value
+ "'. Please update your diagram."); + "'. Please update your diagram.");
}
if (name.equalsIgnoreCase("layout") && value.equalsIgnoreCase("smetana")) { if (name.equalsIgnoreCase("layout") && value.equalsIgnoreCase("smetana"))
system.setUseSmetana(true); system.setUseSmetana(true);
}
if (name.equalsIgnoreCase("layout") && value.equalsIgnoreCase("elk")) { if (name.equalsIgnoreCase("layout") && value.equalsIgnoreCase("elk"))
system.setUseElk(true); system.setUseElk(true);
}
if (name.equalsIgnoreCase("layout") && value.equalsIgnoreCase(GraphvizUtils.VIZJS)) { if (name.equalsIgnoreCase("layout") && value.equalsIgnoreCase(GraphvizUtils.VIZJS))
system.getSkinParam().setUseVizJs(true); system.getSkinParam().setUseVizJs(true);
} // ::done
} }
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();
} }

View File

@ -35,7 +35,8 @@
*/ */
package net.sourceforge.plantuml.command.note; package net.sourceforge.plantuml.command.note;
import net.sourceforge.plantuml.baraye.IEntity; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
import net.sourceforge.plantuml.classdiagram.command.CommandCreateClassMultilines; import net.sourceforge.plantuml.classdiagram.command.CommandCreateClassMultilines;
import net.sourceforge.plantuml.command.Command; import net.sourceforge.plantuml.command.Command;
@ -48,8 +49,6 @@ import net.sourceforge.plantuml.command.regex.IRegex;
import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Stereotag; import net.sourceforge.plantuml.cucadiagram.Stereotag;
import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.cucadiagram.Stereotype;
@ -136,13 +135,19 @@ public final class CommandFactoryNote implements SingleMultiFactoryCommand<Abstr
private CommandExecutionResult executeInternal(AbstractEntityDiagram diagram, RegexResult arg, BlocLines display) private CommandExecutionResult executeInternal(AbstractEntityDiagram diagram, RegexResult arg, BlocLines display)
throws NoSuchColorException { throws NoSuchColorException {
final String idShort = arg.get("CODE", 0); final String idShort = arg.get("CODE", 0);
final Ident ident = diagram.buildLeafIdent(idShort); final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(idShort), false);
final Code code = diagram.buildCode(idShort); // final Quark ident = diagram.buildFromName(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(idShort));
final boolean leafExist = diagram.leafExist(code); // final Quark code = diagram.buildFromFullPath(idShort);
if (leafExist) // final boolean leafExist = diagram.leafExist(code);
return CommandExecutionResult.error("Note already created: " + code.getName()); if (quark.getData() != null)
return CommandExecutionResult.error("Note already created: " + quark.getName());
final IEntity entity = diagram.createLeaf(ident, code, display.toDisplay(), LeafType.NOTE, null); final EntityImp entity = diagram.reallyCreateLeaf(quark, display.toDisplay(), LeafType.NOTE, null);
// final Quark quark = diagram.getPlasma().getIfExistsFromName(idShort);
// if (quark != null && quark.getData() != null)
// entity = diagram.getFromName(idShort);
// else
// entity = diagram.reallyCreateLeaf(ident, display.toDisplay(), LeafType.NOTE, null);
assert entity != null; assert entity != null;
final String s = arg.get("COLOR", 0); final String s = arg.get("COLOR", 0);
entity.setSpecificColorTOBEREMOVED(ColorType.BACK, entity.setSpecificColorTOBEREMOVED(ColorType.BACK,

View File

@ -40,7 +40,8 @@ import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlMode; import net.sourceforge.plantuml.UrlMode;
import net.sourceforge.plantuml.activitydiagram.ActivityDiagram; import net.sourceforge.plantuml.activitydiagram.ActivityDiagram;
import net.sourceforge.plantuml.baraye.IEntity; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.command.Command; import net.sourceforge.plantuml.command.Command;
import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.CommandMultilines2; import net.sourceforge.plantuml.command.CommandMultilines2;
@ -52,9 +53,7 @@ import net.sourceforge.plantuml.command.regex.IRegex;
import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg; import net.sourceforge.plantuml.cucadiagram.LinkArg;
@ -122,9 +121,9 @@ public final class CommandFactoryNoteActivity implements SingleMultiFactoryComma
// final String s = StringUtils.getMergedLines(strings); // final String s = StringUtils.getMergedLines(strings);
final String codeString = diagram.getUniqueSequence("GMN"); final String codeString = diagram.getUniqueSequence("GMN");
final Ident ident = diagram.buildLeafIdent(codeString); final Quark quark = diagram.quarkInContext(codeString, false);
final Code code = diagram.buildCode(codeString); // final Quark code = diagram.buildCode(codeString);
final IEntity note = diagram.createLeaf(ident, code, strings, LeafType.NOTE, null); final EntityImp note = diagram.reallyCreateLeaf(quark, strings, LeafType.NOTE, null);
if (url != null) if (url != null)
note.addUrl(url); note.addUrl(url);
@ -140,22 +139,24 @@ public final class CommandFactoryNoteActivity implements SingleMultiFactoryComma
protected CommandExecutionResult executeArg(final ActivityDiagram diagram, LineLocation location, protected CommandExecutionResult executeArg(final ActivityDiagram diagram, LineLocation location,
RegexResult arg) throws NoSuchColorException { RegexResult arg) throws NoSuchColorException {
final String tmp = diagram.getUniqueSequence("GN"); final String tmp = diagram.getUniqueSequence("GN");
final Ident ident = diagram.buildLeafIdent(tmp); final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(tmp), false);
final Code code = diagram.buildCode(tmp); // final Quark ident = diagram
final IEntity note = diagram.createNote(ident, code, Display.getWithNewlines(arg.get("NOTE", 0))); // .buildFromName(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(tmp));
// final Quark code = diagram.buildCode(tmp);
final EntityImp note = diagram.createNote(quark, tmp, Display.getWithNewlines(arg.get("NOTE", 0)));
return executeInternal(diagram, arg, note); return executeInternal(diagram, arg, note);
} }
}; };
} }
private CommandExecutionResult executeInternal(ActivityDiagram diagram, RegexResult arg, IEntity note) private CommandExecutionResult executeInternal(ActivityDiagram diagram, RegexResult arg, EntityImp note)
throws NoSuchColorException { throws NoSuchColorException {
final String s = arg.get("COLOR", 0); final String s = arg.get("COLOR", 0);
note.setSpecificColorTOBEREMOVED(ColorType.BACK, note.setSpecificColorTOBEREMOVED(ColorType.BACK,
s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s)); s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s));
IEntity activity = diagram.getLastEntityConsulted(); EntityImp activity = diagram.getLastEntityConsulted();
if (activity == null) if (activity == null)
activity = diagram.getStart(); activity = diagram.getStart();
@ -167,17 +168,17 @@ public final class CommandFactoryNoteActivity implements SingleMultiFactoryComma
final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).goDashed(); final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).goDashed();
if (position == Position.RIGHT) if (position == Position.RIGHT)
link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), activity, link = new Link(diagram.getEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), activity, note,
note, type, LinkArg.noDisplay(1)); type, LinkArg.noDisplay(1));
else if (position == Position.LEFT) else if (position == Position.LEFT)
link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), note, link = new Link(diagram.getEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), note, activity,
activity, type, LinkArg.noDisplay(1)); type, LinkArg.noDisplay(1));
else if (position == Position.BOTTOM) else if (position == Position.BOTTOM)
link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), activity, link = new Link(diagram.getEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), activity, note,
note, type, LinkArg.noDisplay(2)); type, LinkArg.noDisplay(2));
else if (position == Position.TOP) else if (position == Position.TOP)
link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), note, link = new Link(diagram.getEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), note, activity,
activity, type, LinkArg.noDisplay(2)); type, LinkArg.noDisplay(2));
else else
throw new IllegalArgumentException(); throw new IllegalArgumentException();

View File

@ -40,7 +40,8 @@ import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlMode; import net.sourceforge.plantuml.UrlMode;
import net.sourceforge.plantuml.baraye.IEntity; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
import net.sourceforge.plantuml.classdiagram.command.CommandCreateClassMultilines; import net.sourceforge.plantuml.classdiagram.command.CommandCreateClassMultilines;
import net.sourceforge.plantuml.command.Command; import net.sourceforge.plantuml.command.Command;
@ -55,8 +56,6 @@ import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexOr;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg; import net.sourceforge.plantuml.cucadiagram.LinkArg;
@ -211,23 +210,25 @@ public final class CommandFactoryNoteOnEntity implements SingleMultiFactoryComma
private CommandExecutionResult executeInternal(RegexResult line0, AbstractEntityDiagram diagram, Url url, private CommandExecutionResult executeInternal(RegexResult line0, AbstractEntityDiagram diagram, Url url,
BlocLines strings) throws NoSuchColorException { BlocLines strings) throws NoSuchColorException {
final String pos = line0.get("POSITION", 0); final String pos = line0.get("POSITION", 0);
final String idShort = diagram.cleanIdForQuark(line0.get("ENTITY", 0));
final String idShort = line0.get("ENTITY", 0); final EntityImp cl1;
final IEntity cl1;
if (idShort == null) { if (idShort == null) {
cl1 = diagram.getLastEntity(); cl1 = diagram.getLastEntity();
if (cl1 == null) if (cl1 == null)
return CommandExecutionResult.error("Nothing to note to"); return CommandExecutionResult.error("Nothing to note to");
} else { } else {
final Ident ident = diagram.buildLeafIdent(idShort); final Quark quark = diagram.quarkInContext(idShort, false);
final Code code = diagram.buildCode(idShort); cl1 = (EntityImp) quark.getData();
if (diagram.isGroup(code)) if (cl1 == null)
cl1 = diagram.getGroup(code); return CommandExecutionResult.error("Not known: " + idShort);
else // final Quark ident = diagram.buildFromName(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(idShort));
cl1 = diagram.getOrCreateLeaf(ident, code, null, null); // final Quark code = diagram.buildFromFullPath(idShort);
// if (diagram.isGroup(idShort))
// cl1 = diagram.getGroup(idShort);
// else
// cl1 = diagram.getOrCreateLeaf(ident, code, null, null);
} }
@ -249,9 +250,8 @@ public final class CommandFactoryNoteOnEntity implements SingleMultiFactoryComma
} }
final String tmp = diagram.getUniqueSequence("GMN"); final String tmp = diagram.getUniqueSequence("GMN");
final Ident idNewLong = diagram.buildLeafIdent(tmp); final Quark quark = diagram.quarkInContext(tmp, false);
final IEntity note = diagram.createLeaf(idNewLong, diagram.buildCode(tmp), strings.toDisplay(), LeafType.NOTE, final EntityImp note = diagram.reallyCreateLeaf(quark, strings.toDisplay(), LeafType.NOTE, null);
null);
if (stereotypeString != null) if (stereotypeString != null)
note.setStereotype(stereotype); note.setStereotype(stereotype);
@ -266,18 +266,18 @@ public final class CommandFactoryNoteOnEntity implements SingleMultiFactoryComma
final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).goDashed(); final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).goDashed();
if (position == Position.RIGHT) { if (position == Position.RIGHT) {
link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1, note, link = new Link(diagram.getEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1, note,
type, LinkArg.noDisplay(1)); type, LinkArg.noDisplay(1));
link.setHorizontalSolitary(true); link.setHorizontalSolitary(true);
} else if (position == Position.LEFT) { } else if (position == Position.LEFT) {
link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), note, cl1, link = new Link(diagram.getEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), note, cl1,
type, LinkArg.noDisplay(1)); type, LinkArg.noDisplay(1));
link.setHorizontalSolitary(true); link.setHorizontalSolitary(true);
} else if (position == Position.BOTTOM) { } else if (position == Position.BOTTOM) {
link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1, note, link = new Link(diagram.getEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1, note,
type, LinkArg.noDisplay(2)); type, LinkArg.noDisplay(2));
} else if (position == Position.TOP) { } else if (position == Position.TOP) {
link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), note, cl1, link = new Link(diagram.getEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), note, cl1,
type, LinkArg.noDisplay(2)); type, LinkArg.noDisplay(2));
} else { } else {
throw new IllegalArgumentException(); throw new IllegalArgumentException();

View File

@ -40,7 +40,8 @@ import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlMode; import net.sourceforge.plantuml.UrlMode;
import net.sourceforge.plantuml.baraye.IEntity; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
import net.sourceforge.plantuml.command.Command; import net.sourceforge.plantuml.command.Command;
import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandExecutionResult;
@ -52,8 +53,7 @@ import net.sourceforge.plantuml.command.regex.IRegex;
import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg; import net.sourceforge.plantuml.cucadiagram.LinkArg;
@ -169,29 +169,39 @@ public final class CommandFactoryTipOnEntity implements SingleMultiFactoryComman
final String pos = line0.get("POSITION", 0); final String pos = line0.get("POSITION", 0);
final String idShort = line0.get("ENTITY", 0); final String idShort = line0.get("ENTITY", 0);
final Ident identShort = diagram.buildLeafIdent(idShort);
final Code codeShort = diagram.buildCode(idShort);
final String member = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(line0.get("ENTITY", 1)); final String member = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(line0.get("ENTITY", 1));
if (codeShort == null) {
assert false; final Quark quark = diagram.quarkInContext(idShort, false);
final EntityImp cl1 = (EntityImp) quark.getData();
if (cl1 == null)
return CommandExecutionResult.error("Nothing to note to"); return CommandExecutionResult.error("Nothing to note to");
}
final IEntity cl1 = diagram.getOrCreateLeaf(identShort, codeShort, null, null);
// final Quark identShort = diagram.buildFromName(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(idShort));
// final Quark codeShort = diagram.buildFromFullPath(idShort);
// if (codeShort == null) {
// assert false;
// return CommandExecutionResult.error("Nothing to note to");
// }
// final IEntity cl1 = diagram.getOrCreateLeaf(identShort, codeShort, null, null);
final Position position = Position.valueOf(StringUtils.goUpperCase(pos)) final Position position = Position.valueOf(StringUtils.goUpperCase(pos))
.withRankdir(diagram.getSkinParam().getRankdir()); .withRankdir(diagram.getSkinParam().getRankdir());
final Ident identTip = diagram.buildLeafIdent(idShort + "$$$" + position.name()); final String tmp = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(idShort + "$$$" + position.name());
IEntity tips = diagram.getLeafStrict(identTip); final Quark identTip = diagram.quarkInContext(tmp, false);
EntityImp tips = (EntityImp) identTip.getData();
// final Quark identTip = diagram.buildFromName(tmp);
//IEntity tips = diagram.getLeafFromName(idShort + "$$$" + position.name());
if (tips == null) { if (tips == null) {
tips = diagram.getOrCreateLeaf(identTip, identTip.toCode(diagram), LeafType.TIPS, null); tips = diagram.reallyCreateLeaf(identTip, Display.getWithNewlines(""), LeafType.TIPS, null);
final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).getInvisible(); final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).getInvisible();
final Link link; final Link link;
if (position == Position.RIGHT) if (position == Position.RIGHT)
link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1, link = new Link(diagram.getEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1,
(IEntity) tips, type, LinkArg.noDisplay(1)); (EntityImp) tips, type, LinkArg.noDisplay(1));
else else
link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), link = new Link(diagram.getEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(),
(IEntity) tips, cl1, type, LinkArg.noDisplay(1)); (EntityImp) tips, cl1, type, LinkArg.noDisplay(1));
diagram.addLink(link); diagram.addLink(link);
} }

View File

@ -36,16 +36,10 @@
package net.sourceforge.plantuml.compositediagram; package net.sourceforge.plantuml.compositediagram;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.baraye.IEntity;
import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.graphic.USymbol;
public class CompositeDiagram extends AbstractEntityDiagram { public class CompositeDiagram extends AbstractEntityDiagram {
@ -53,17 +47,17 @@ public class CompositeDiagram extends AbstractEntityDiagram {
super(source, UmlDiagramType.COMPOSITE, skinParam); super(source, UmlDiagramType.COMPOSITE, skinParam);
} }
@Override // @Override
public IEntity getOrCreateLeaf(Ident ident, Code code, LeafType type, USymbol symbol) { // protected IEntity getOrCreateLeaf2(Quark ident, Quark code, LeafType type, USymbol symbol) {
Objects.requireNonNull(ident); // Objects.requireNonNull(ident);
// final Ident idNewLong = buildLeafIdent(id); // // final Ident idNewLong = buildLeafIdent(id);
if (type == null) { // if (type == null) {
if (isGroup(code)) { // if (isGroup(code.getName())) {
return getGroup(code); // return getGroup(code.getName());
} // }
return getOrCreateLeafDefault(ident, code, LeafType.BLOCK, symbol); // return reallyCreateLeaf(ident, Display.getWithNewlines(code.getName()), LeafType.BLOCK, symbol);
} // }
return getOrCreateLeafDefault(ident, code, type, symbol); // return reallyCreateLeaf(ident, Display.getWithNewlines(code.getName()), type, symbol);
} // }
} }

View File

@ -35,7 +35,8 @@
*/ */
package net.sourceforge.plantuml.compositediagram.command; package net.sourceforge.plantuml.compositediagram.command;
import net.sourceforge.plantuml.baraye.IEntity; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.IRegex;
@ -44,8 +45,8 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.compositediagram.CompositeDiagram; import net.sourceforge.plantuml.compositediagram.CompositeDiagram;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.utils.LineLocation; import net.sourceforge.plantuml.utils.LineLocation;
public class CommandCreateBlock extends SingleLineCommand2<CompositeDiagram> { public class CommandCreateBlock extends SingleLineCommand2<CompositeDiagram> {
@ -72,12 +73,15 @@ public class CommandCreateBlock extends SingleLineCommand2<CompositeDiagram> {
protected CommandExecutionResult executeArg(CompositeDiagram diagram, LineLocation location, RegexResult arg) { protected CommandExecutionResult executeArg(CompositeDiagram diagram, LineLocation location, RegexResult arg) {
String display = arg.get("DISPLAY", 0); String display = arg.get("DISPLAY", 0);
final String idShort = arg.get("CODE", 0); final String idShort = arg.get("CODE", 0);
final Code code = diagram.buildCode(idShort); final Quark quark = diagram.quarkInContext(idShort, false);
if (display == null) { if (display == null)
display = code.getName(); display = quark.getName();
}
final IEntity ent = diagram.getOrCreateLeaf(diagram.buildLeafIdent(idShort), code, null, null); if (quark.getData() != null)
ent.setDisplay(Display.getWithNewlines(display)); return CommandExecutionResult.error("Already exists " + quark.getName());
final EntityImp ent = diagram.reallyCreateLeaf(quark, Display.getWithNewlines(quark), LeafType.BLOCK, null);
// ent.setDisplay(Display.getWithNewlines(display));
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();
} }

View File

@ -35,7 +35,7 @@
*/ */
package net.sourceforge.plantuml.compositediagram.command; package net.sourceforge.plantuml.compositediagram.command;
import net.sourceforge.plantuml.baraye.IGroup; import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.IRegex;
@ -44,11 +44,8 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.compositediagram.CompositeDiagram; import net.sourceforge.plantuml.compositediagram.CompositeDiagram;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.GroupType; import net.sourceforge.plantuml.cucadiagram.GroupType;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy;
import net.sourceforge.plantuml.utils.LineLocation; import net.sourceforge.plantuml.utils.LineLocation;
public class CommandCreatePackageBlock extends SingleLineCommand2<CompositeDiagram> { public class CommandCreatePackageBlock extends SingleLineCommand2<CompositeDiagram> {
@ -74,16 +71,14 @@ public class CommandCreatePackageBlock extends SingleLineCommand2<CompositeDiagr
@Override @Override
protected CommandExecutionResult executeArg(CompositeDiagram diagram, LineLocation location, RegexResult arg) { protected CommandExecutionResult executeArg(CompositeDiagram diagram, LineLocation location, RegexResult arg) {
final IGroup currentPackage = diagram.getCurrentGroup();
String display = arg.get("DISPLAY", 0); String display = arg.get("DISPLAY", 0);
final String idShort = arg.get("CODE", 0); final String idShort = arg.get("CODE", 0);
final Code code = diagram.buildCode(idShort); final Quark quark = diagram.quarkInContext(idShort, false);
if (display == null) if (display == null)
display = code.getName(); display = quark.getName();
final Ident idNewLong = diagram.buildLeafIdent(idShort); return diagram.gotoGroup(quark, Display.getWithNewlines(display), GroupType.PACKAGE);
return diagram.gotoGroup(idNewLong, code, Display.getWithNewlines(display), GroupType.PACKAGE, currentPackage,
NamespaceStrategy.SINGLE);
} }
} }

View File

@ -34,7 +34,8 @@
*/ */
package net.sourceforge.plantuml.compositediagram.command; package net.sourceforge.plantuml.compositediagram.command;
import net.sourceforge.plantuml.baraye.IEntity; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.IRegex;
@ -78,8 +79,17 @@ public class CommandLinkBlock extends SingleLineCommand2<CompositeDiagram> {
protected CommandExecutionResult executeArg(CompositeDiagram diagram, LineLocation location, RegexResult arg) { protected CommandExecutionResult executeArg(CompositeDiagram diagram, LineLocation location, RegexResult arg) {
final String ent1 = arg.get("ENT1", 0); final String ent1 = arg.get("ENT1", 0);
final String ent2 = arg.get("ENT2", 0); final String ent2 = arg.get("ENT2", 0);
final IEntity cl1 = diagram.getOrCreateLeaf(diagram.buildLeafIdent(ent1), diagram.buildCode(ent1), null, null); final Quark quark1 = diagram.quarkInContext(diagram.cleanIdForQuark(ent1), false);
final IEntity cl2 = diagram.getOrCreateLeaf(diagram.buildLeafIdent(ent2), diagram.buildCode(ent2), null, null); final Quark quark2 = diagram.quarkInContext(diagram.cleanIdForQuark(ent2), false);
final EntityImp cl1 = (EntityImp) quark1.getData();
if (cl1 == null)
return CommandExecutionResult.error("No such element " + quark1.getName());
final EntityImp cl2 = (EntityImp) quark2.getData();
if (cl2 == null)
return CommandExecutionResult.error("No such element " + quark2.getName());
// final IEntity cl1 = diagram.getOrCreateLeaf(quark1, diagram.buildFromFullPath(ent1), null, null);
// final IEntity cl2 = diagram.getOrCreateLeaf(quark2, diagram.buildFromFullPath(ent2), null, null);
final String deco1 = arg.get("DECO1", 0); final String deco1 = arg.get("DECO1", 0);
final String deco2 = arg.get("DECO2", 0); final String deco2 = arg.get("DECO2", 0);
@ -95,7 +105,7 @@ public class CommandLinkBlock extends SingleLineCommand2<CompositeDiagram> {
final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(arg.get("DISPLAY", 0)), queue.length(), final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(arg.get("DISPLAY", 0)), queue.length(),
diagram.getSkinParam().classAttributeIconSize() > 0); diagram.getSkinParam().classAttributeIconSize() > 0);
final Link link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1, final Link link = new Link(diagram.getEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1,
cl2, linkType, linkArg); cl2, linkType, linkArg);
diagram.addLink(link); diagram.addLink(link);
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();

View File

@ -48,7 +48,6 @@ import net.sourceforge.plantuml.awt.geom.XDimension2D;
import net.sourceforge.plantuml.code.Base64Coder; import net.sourceforge.plantuml.code.Base64Coder;
import net.sourceforge.plantuml.creole.legacy.AtomTextUtils; import net.sourceforge.plantuml.creole.legacy.AtomTextUtils;
import net.sourceforge.plantuml.flashcode.FlashCodeFactory; import net.sourceforge.plantuml.flashcode.FlashCodeFactory;
import net.sourceforge.plantuml.flashcode.FlashCodeUtils;
import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.ImgValign; import net.sourceforge.plantuml.graphic.ImgValign;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
@ -82,9 +81,11 @@ public class AtomImg extends AbstractAtom implements Atom {
} }
public static Atom createQrcode(String flash, double scale) { public static Atom createQrcode(String flash, double scale) {
final FlashCodeUtils utils = FlashCodeFactory.getFlashCodeUtils(); BufferedImage im = null;
BufferedImage im = utils.exportFlashcode(flash, Color.BLACK, Color.WHITE); // :: comment when WASM
im = FlashCodeFactory.getFlashCodeUtils().exportFlashcode(flash, Color.BLACK, Color.WHITE);
if (im == null) if (im == null)
// ::done
im = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB); im = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB);
return new AtomImg( return new AtomImg(

View File

@ -49,6 +49,7 @@ import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorSimple; import net.sourceforge.plantuml.ugraphic.color.HColorSimple;
public class AtomMath extends AbstractAtom implements Atom { public class AtomMath extends AbstractAtom implements Atom {
// ::remove file when WASM
private final ScientificEquationSafe math; private final ScientificEquationSafe math;
private final HColor foreground; private final HColor foreground;

View File

@ -43,6 +43,7 @@ import net.sourceforge.plantuml.graphic.Splitter;
import net.sourceforge.plantuml.math.ScientificEquationSafe; import net.sourceforge.plantuml.math.ScientificEquationSafe;
public class CommandCreoleLatex implements Command { public class CommandCreoleLatex implements Command {
// ::remove file when WASM
@Override @Override
public String startingChars() { public String startingChars() {

View File

@ -43,6 +43,7 @@ import net.sourceforge.plantuml.graphic.Splitter;
import net.sourceforge.plantuml.math.ScientificEquationSafe; import net.sourceforge.plantuml.math.ScientificEquationSafe;
public class CommandCreoleMath implements Command { public class CommandCreoleMath implements Command {
// ::remove file when WASM
@Override @Override
public String startingChars() { public String startingChars() {

View File

@ -104,8 +104,10 @@ public class CreoleParser implements SheetBuilder {
return new StripeTree(fontConfiguration, skinParam, line); return new StripeTree(fontConfiguration, skinParam, line);
} else if (Parser.isCodeStart(line)) { } else if (Parser.isCodeStart(line)) {
return new StripeCode(fontConfiguration.changeFamily(Parser.MONOSPACED)); return new StripeCode(fontConfiguration.changeFamily(Parser.MONOSPACED));
// ::comment when WASM
} else if (Parser.isLatexStart(line)) { } else if (Parser.isLatexStart(line)) {
return new StripeLatex(fontConfiguration); return new StripeLatex(fontConfiguration);
// ::done
} }
return new CreoleStripeSimpleParser(line, context, fontConfiguration, skinParam, creoleMode) return new CreoleStripeSimpleParser(line, context, fontConfiguration, skinParam, creoleMode)
.createStripe(context); .createStripe(context);

View File

@ -49,7 +49,7 @@ import net.sourceforge.plantuml.math.ScientificEquationSafe;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
public class StripeLatex implements StripeRaw { public class StripeLatex implements StripeRaw {
// ::remove file when WASM
final private FontConfiguration fontConfiguration; final private FontConfiguration fontConfiguration;
final private StringBuilder formula = new StringBuilder(); final private StringBuilder formula = new StringBuilder();
private AtomMath atom; private AtomMath atom;

View File

@ -162,8 +162,10 @@ public class StripeSimple implements Stripe {
addCommand(CommandCreoleQrcode.create()); addCommand(CommandCreoleQrcode.create());
addCommand(CommandCreoleOpenIcon.create()); addCommand(CommandCreoleOpenIcon.create());
addCommand(CommandCreoleEmoji.create()); addCommand(CommandCreoleEmoji.create());
// ::comment when WASM
addCommand(CommandCreoleMath.create()); addCommand(CommandCreoleMath.create());
addCommand(CommandCreoleLatex.create()); addCommand(CommandCreoleLatex.create());
// ::done
addCommand(CommandCreoleSprite.create()); addCommand(CommandCreoleSprite.create());
addCommand(CommandCreoleSpace.create()); addCommand(CommandCreoleSpace.create());
addCommand(CommandCreoleFontFamilyChange.create()); addCommand(CommandCreoleFontFamilyChange.create());
@ -284,9 +286,11 @@ public class StripeSimple implements Stripe {
atoms.add(new AtomEmoji(emoji, 1, fontConfiguration.getSize2D(), col)); atoms.add(new AtomEmoji(emoji, 1, fontConfiguration.getSize2D(), col));
} }
// ::comment when WASM
public void addMath(ScientificEquationSafe math) { public void addMath(ScientificEquationSafe math) {
atoms.add(new AtomMath(math, fontConfiguration.getColor(), fontConfiguration.getExtendedColor())); atoms.add(new AtomMath(math, fontConfiguration.getColor(), fontConfiguration.getExtendedColor()));
} }
// ::done
private void modifyStripe(String line) { private void modifyStripe(String line) {
final StringBuilder pending = new StringBuilder(); final StringBuilder pending = new StringBuilder();

View File

@ -38,7 +38,7 @@ package net.sourceforge.plantuml.cucadiagram;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.baraye.ILeaf; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.Style;
@ -46,7 +46,7 @@ import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
public interface Bodier { public interface Bodier {
public void setLeaf(ILeaf leaf); public void setLeaf(EntityImp leaf);
public Display getFieldsToDisplay(); public Display getFieldsToDisplay();

View File

@ -39,7 +39,7 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.baraye.ILeaf; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.json.JsonValue; import net.sourceforge.plantuml.json.JsonValue;
@ -48,7 +48,7 @@ import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
public class BodierJSon implements Bodier { public class BodierJSon implements Bodier {
private ILeaf leaf; private EntityImp leaf;
private JsonValue json; private JsonValue json;
@Override @Override
@ -60,7 +60,7 @@ public class BodierJSon implements Bodier {
} }
@Override @Override
public void setLeaf(ILeaf leaf) { public void setLeaf(EntityImp leaf) {
this.leaf = Objects.requireNonNull(leaf); this.leaf = Objects.requireNonNull(leaf);
} }

View File

@ -44,7 +44,7 @@ import java.util.Set;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.baraye.ILeaf; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.creole.Parser; import net.sourceforge.plantuml.creole.Parser;
import net.sourceforge.plantuml.creole.legacy.CreoleParser; import net.sourceforge.plantuml.creole.legacy.CreoleParser;
import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.FontConfiguration;
@ -63,7 +63,7 @@ public class BodierLikeClassOrObject implements Bodier {
private LeafType type; private LeafType type;
private List<Member> methodsToDisplay; private List<Member> methodsToDisplay;
private List<Member> fieldsToDisplay; private List<Member> fieldsToDisplay;
private ILeaf leaf; private EntityImp leaf;
@Override @Override
public void muteClassToObject() { public void muteClassToObject() {
@ -82,7 +82,7 @@ public class BodierLikeClassOrObject implements Bodier {
} }
@Override @Override
public void setLeaf(ILeaf leaf) { public void setLeaf(EntityImp leaf) {
this.leaf = Objects.requireNonNull(leaf); this.leaf = Objects.requireNonNull(leaf);
} }

View File

@ -46,7 +46,7 @@ import java.util.regex.Pattern;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.baraye.ILeaf; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.Style;
@ -55,7 +55,7 @@ public class BodierMap implements Bodier {
private final List<CharSequence> rawBody = new ArrayList<>(); private final List<CharSequence> rawBody = new ArrayList<>();
private final Map<String, String> map = new LinkedHashMap<String, String>(); private final Map<String, String> map = new LinkedHashMap<String, String>();
private ILeaf leaf; private EntityImp leaf;
@Override @Override
public void muteClassToObject() { public void muteClassToObject() {
@ -66,7 +66,7 @@ public class BodierMap implements Bodier {
} }
@Override @Override
public void setLeaf(ILeaf leaf) { public void setLeaf(EntityImp leaf) {
this.leaf = Objects.requireNonNull(leaf); this.leaf = Objects.requireNonNull(leaf);
} }

View File

@ -41,7 +41,7 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.baraye.ILeaf; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
@ -51,7 +51,7 @@ import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
public class BodierSimple implements Bodier { public class BodierSimple implements Bodier {
private final List<CharSequence> rawBody = new ArrayList<>(); private final List<CharSequence> rawBody = new ArrayList<>();
private ILeaf leaf; private EntityImp leaf;
@Override @Override
public void muteClassToObject() { public void muteClassToObject() {
@ -62,7 +62,7 @@ public class BodierSimple implements Bodier {
} }
@Override @Override
public void setLeaf(ILeaf leaf) { public void setLeaf(EntityImp leaf) {
this.leaf = Objects.requireNonNull(leaf); this.leaf = Objects.requireNonNull(leaf);
} }

View File

@ -46,7 +46,7 @@ import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.awt.geom.XRectangle2D; import net.sourceforge.plantuml.awt.geom.XRectangle2D;
import net.sourceforge.plantuml.baraye.ILeaf; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.creole.Parser; import net.sourceforge.plantuml.creole.Parser;
import net.sourceforge.plantuml.creole.legacy.CreoleParser; import net.sourceforge.plantuml.creole.legacy.CreoleParser;
@ -70,11 +70,11 @@ public class BodyEnhanced1 extends BodyEnhancedAbstract implements TextBlock, Wi
private final boolean lineFirst; private final boolean lineFirst;
private final List<Url> urls = new ArrayList<>(); private final List<Url> urls = new ArrayList<>();
private final ILeaf entity; private final EntityImp entity;
private final boolean inEllipse; private final boolean inEllipse;
private final Style style; private final Style style;
BodyEnhanced1(HorizontalAlignment align, List<CharSequence> rawBody, ISkinParam skinParam, ILeaf entity, BodyEnhanced1(HorizontalAlignment align, List<CharSequence> rawBody, ISkinParam skinParam, EntityImp entity,
Style style) { Style style) {
super(align, style.getFontConfiguration(skinParam.getIHtmlColorSet(), entity.getColors()), style); super(align, style.getFontConfiguration(skinParam.getIHtmlColorSet(), entity.getColors()), style);
this.style = style; this.style = style;
@ -88,7 +88,7 @@ public class BodyEnhanced1 extends BodyEnhancedAbstract implements TextBlock, Wi
this.inEllipse = false; this.inEllipse = false;
} }
BodyEnhanced1(HorizontalAlignment align, Display display, ISkinParam skinParam, ILeaf entity, Style style) { BodyEnhanced1(HorizontalAlignment align, Display display, ISkinParam skinParam, EntityImp entity, Style style) {
super(align, style.getFontConfiguration(skinParam.getIHtmlColorSet(), entity.getColors()), style); super(align, style.getFontConfiguration(skinParam.getIHtmlColorSet(), entity.getColors()), style);
this.style = style; this.style = style;

View File

@ -41,7 +41,7 @@ import java.util.Set;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.baraye.ILeaf; import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
@ -64,12 +64,12 @@ public class BodyFactory {
} }
public static TextBlock create1(HorizontalAlignment align, List<CharSequence> rawBody, ISkinParam skinParam, public static TextBlock create1(HorizontalAlignment align, List<CharSequence> rawBody, ISkinParam skinParam,
Stereotype stereotype, ILeaf entity, Style style) { Stereotype stereotype, EntityImp entity, Style style) {
return new BodyEnhanced1(align, rawBody, skinParam, entity, style); return new BodyEnhanced1(align, rawBody, skinParam, entity, style);
} }
public static TextBlock create2(HorizontalAlignment align, Display display, ISkinParam skinParam, public static TextBlock create2(HorizontalAlignment align, Display display, ISkinParam skinParam,
Stereotype stereotype, ILeaf entity, Style style) { Stereotype stereotype, EntityImp entity, Style style) {
return new BodyEnhanced1(align, display, skinParam, entity, style); return new BodyEnhanced1(align, display, skinParam, entity, style);
} }

View File

@ -1,82 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2023, 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;
import java.util.Objects;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.baraye.EntityFactory;
public class CodeImpl implements Code {
private final String name;
private CodeImpl(String name) {
this.name = Objects.requireNonNull(name);
}
public static Code of(String code) {
if (code == null)
EntityFactory.bigError();
return new CodeImpl(code);
}
public final String getName() {
return name;
}
@Override
public String toString() {
return name;
}
@Override
public int hashCode() {
return name.hashCode();
}
@Override
public boolean equals(Object obj) {
final CodeImpl other = (CodeImpl) obj;
return this.name.equals(other.name);
}
public Code eventuallyRemoveStartingAndEndingDoubleQuote(String format) {
return CodeImpl.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(getName(), format));
}
}

View File

@ -52,6 +52,7 @@ import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.SpriteContainer; import net.sourceforge.plantuml.SpriteContainer;
import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlMode; import net.sourceforge.plantuml.UrlMode;
import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.command.regex.Matcher2; import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern; import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2; import net.sourceforge.plantuml.command.regex.Pattern2;
@ -102,6 +103,8 @@ public class Display implements Iterable<CharSequence> {
// } // }
public boolean equalsLike(Display other) { public boolean equalsLike(Display other) {
if (isNull(this))
return isNull(other);
return this.displayData.equals(other.displayData); return this.displayData.equals(other.displayData);
} }
@ -197,7 +200,7 @@ public class Display implements Iterable<CharSequence> {
return new Display(true, other, null, false, CreoleMode.FULL); return new Display(true, other, null, false, CreoleMode.FULL);
} }
public static Display getWithNewlines(Code s) { public static Display getWithNewlines(Quark s) {
return getWithNewlines(s.getName()); return getWithNewlines(s.getName());
} }

View File

@ -35,8 +35,8 @@
*/ */
package net.sourceforge.plantuml.cucadiagram; package net.sourceforge.plantuml.cucadiagram;
import net.sourceforge.plantuml.baraye.IEntity; import net.sourceforge.plantuml.baraye.EntityImp;
public interface EntityGender { public interface EntityGender {
public boolean contains(IEntity test); public boolean contains(EntityImp test);
} }

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