diff --git a/src/net/sourceforge/plantuml/cucadiagram/Code.java b/src/com/plantuml/wasm/RunInit.java similarity index 76% rename from src/net/sourceforge/plantuml/cucadiagram/Code.java rename to src/com/plantuml/wasm/RunInit.java index 8eccd8e7a..0d5dbe7d2 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Code.java +++ b/src/com/plantuml/wasm/RunInit.java @@ -30,14 +30,23 @@ * * * Original Author: Arnaud Roques - * + * * */ -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); } diff --git a/src/com/plantuml/wasm/Utils.java b/src/com/plantuml/wasm/Utils.java new file mode 100644 index 000000000..5b0f186d5 --- /dev/null +++ b/src/com/plantuml/wasm/Utils.java @@ -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); + } + +} diff --git a/src/ext/plantuml/com/ctreber/acearth/ACearth.java b/src/ext/plantuml/com/ctreber/acearth/ACearth.java index 0b3c8e78c..cc0b2c738 100644 --- a/src/ext/plantuml/com/ctreber/acearth/ACearth.java +++ b/src/ext/plantuml/com/ctreber/acearth/ACearth.java @@ -97,6 +97,7 @@ import ext.plantuml.com.ctreber.aclib.sort.QuickSort; * @author Christian Treber, ct@ctreber.com */ public class ACearth { + // :: remove folder when WASM public static final String VERSION = "1.1"; public static final String BUILD = "22.11.2002 004"; @@ -115,7 +116,8 @@ public class ACearth { /** *

* Well, the main class. - * @param markers + * + * @param markers */ public ACearth(List markers) { // fsStartTime = System.currentTimeMillis(); @@ -171,15 +173,15 @@ public class ACearth { // Process stars and lines (produces ScanDots-s). List lScanDots = new ArrayList(); if (fConf.getBoolean("starsP")) { - ScanDotGenerator lGenerator = new DotGeneratorStars(fConf.getInt("imageWidth"), - fConf.getInt("imageHeight"), fConf.getDouble("starFrequency"), fConf.getInt("bigStars"), new Random(fCurrentTime)); + ScanDotGenerator lGenerator = new DotGeneratorStars(fConf.getInt("imageWidth"), fConf.getInt("imageHeight"), + fConf.getDouble("starFrequency"), fConf.getInt("bigStars"), new Random(fCurrentTime)); lGenerator.generateScanDots(); lScanDots.addAll(lGenerator.getScanDots()); } if (fConf.getBoolean("gridP")) { - ScanDotGenerator lGenerator = new DotGeneratorLines(lProjection, fConf.getInt("gridDivision"), fConf - .getInt("gridPixelDivision")); + ScanDotGenerator lGenerator = new DotGeneratorLines(lProjection, fConf.getInt("gridDivision"), + fConf.getInt("gridPixelDivision")); lGenerator.generateScanDots(); lScanDots.addAll(lGenerator.getScanDots()); } @@ -233,7 +235,8 @@ public class ACearth { if (fConf.getInt("fixedTime") == 0) { // No fixed time. // final long lTimePassed = System.currentTimeMillis() - fsStartTime; - // fCurrentTime = fsStartTime + (long) (fConf.getDouble("timeWarpFactor") * lTimePassed); + // fCurrentTime = fsStartTime + (long) (fConf.getDouble("timeWarpFactor") * + // lTimePassed); fCurrentTime = System.currentTimeMillis(); } else { // Fixed time. @@ -259,8 +262,8 @@ public class ACearth { // for ViewRotGalactic, compute appropriate viewing rotation if (fConf.is("viewRotationType", "Galactic")) { - fViewRotation = (Toolkit.degsToRads(fConf.getSunPos().getLat() - * Math.sin((fViewPos.getLong() - fConf.getSunPos().getLong())))); + fViewRotation = (Toolkit.degsToRads( + fConf.getSunPos().getLat() * Math.sin((fViewPos.getLong() - fConf.getSunPos().getLong())))); } else { fViewRotation = fConf.getDouble("viewRotation"); } @@ -290,8 +293,8 @@ public class ACearth { z = 1; /* - * rotate in about y axis (from z towards x) according to the number of - * orbits we've completed + * rotate in about y axis (from z towards x) according to the number of orbits + * we've completed */ a = (double) pTimeMillis / (fConf.getDouble("orbitPeriod") * 3600 * 1000) * 2 * Math.PI; c = Math.cos(a); @@ -302,8 +305,8 @@ public class ACearth { x = t2; /* - * rotate about z axis (from x towards y) according to the inclination - * of the orbit + * rotate about z axis (from x towards y) according to the inclination of the + * orbit */ a = Toolkit.degsToRads(fConf.getDouble("orbitInclination")); c = Math.cos(a); @@ -314,8 +317,8 @@ public class ACearth { y = t2; /* - * rotate about y axis (from x towards z) according to the number of - * rotations the earth has made + * rotate about y axis (from x towards z) according to the number of rotations + * the earth has made */ a = ((double) pTimeMillis / 86400000) * (2 * Math.PI); c = Math.cos(a); diff --git a/src/ext/plantuml/com/ctreber/aclib/gui/MOBoolean.java b/src/ext/plantuml/com/ctreber/aclib/gui/MOBoolean.java index 814b9272f..d06e22066 100644 --- a/src/ext/plantuml/com/ctreber/aclib/gui/MOBoolean.java +++ b/src/ext/plantuml/com/ctreber/aclib/gui/MOBoolean.java @@ -9,6 +9,7 @@ package ext.plantuml.com.ctreber.aclib.gui; */ public class MOBoolean extends MonitoredObject { + // :: remove folder when WASM private boolean fBoolean; public MOBoolean() diff --git a/src/ext/plantuml/com/ctreber/aclib/sort/CTSort.java b/src/ext/plantuml/com/ctreber/aclib/sort/CTSort.java index 4e9950b2f..c87497bc1 100644 --- a/src/ext/plantuml/com/ctreber/aclib/sort/CTSort.java +++ b/src/ext/plantuml/com/ctreber/aclib/sort/CTSort.java @@ -11,6 +11,7 @@ import java.util.Comparator; */ abstract public class CTSort { + // :: remove folder when WASM public void sort(Object[] items) { sort(items, new DefaultComparator()); diff --git a/src/ext/plantuml/com/google/zxing/BarcodeFormat.java b/src/ext/plantuml/com/google/zxing/BarcodeFormat.java index 13567630c..35a649542 100644 --- a/src/ext/plantuml/com/google/zxing/BarcodeFormat.java +++ b/src/ext/plantuml/com/google/zxing/BarcodeFormat.java @@ -24,6 +24,7 @@ import java.util.Hashtable; * @author Sean Owen */ public final class BarcodeFormat { + // :: remove folder when WASM // No, we can't use an enum here. J2ME doesn't support it. diff --git a/src/jcckit/GraphicsPlotCanvas.java b/src/jcckit/GraphicsPlotCanvas.java index f2e346573..687bce1e8 100644 --- a/src/jcckit/GraphicsPlotCanvas.java +++ b/src/jcckit/GraphicsPlotCanvas.java @@ -48,6 +48,7 @@ import jcckit.util.Factory; * @author Franz-Josef Elmer */ public class GraphicsPlotCanvas extends PlotCanvas { + // ::remove folder when WASM /** Key of a configuration parameter. */ public static final String BACKGROUND_KEY = "background"; public static final String FOREGROUND_KEY = "foreground"; diff --git a/src/net/sourceforge/plantuml/AbstractPSystem.java b/src/net/sourceforge/plantuml/AbstractPSystem.java index 23c1ccd30..0de274cab 100644 --- a/src/net/sourceforge/plantuml/AbstractPSystem.java +++ b/src/net/sourceforge/plantuml/AbstractPSystem.java @@ -78,10 +78,12 @@ public abstract class AbstractPSystem implements Diagram { toAppend.append(Version.versionString()); toAppend.append("(" + Version.compileTimeString() + ")\n"); toAppend.append("(" + License.getCurrent() + " source distribution)\n"); + // ::comment when WASM for (String name : OptionPrint.interestingProperties()) { toAppend.append(name); toAppend.append(BackSlash.CHAR_NEWLINE); } + // ::done return toAppend.toString(); } @@ -178,10 +180,12 @@ public abstract class AbstractPSystem implements Diagram { // } return exportDiagramNow(os, index, fileFormatOption); } finally { - if (OptionFlags.getInstance().isEnableStats()) { + // ::comment when WASM + if (OptionFlags.getInstance().isEnableStats()) StatsUtilsIncrement.onceMoreGenerate(System.currentTimeMillis() - now, getClass(), fileFormatOption.getFileFormat()); - } + + // ::done } } diff --git a/src/net/sourceforge/plantuml/DirWatcher.java b/src/net/sourceforge/plantuml/DirWatcher.java index 9511e0fc5..6877e1783 100644 --- a/src/net/sourceforge/plantuml/DirWatcher.java +++ b/src/net/sourceforge/plantuml/DirWatcher.java @@ -49,6 +49,7 @@ import net.sourceforge.plantuml.preproc.FileWithSuffix; @Deprecated public class DirWatcher { + // ::remove file when WASM final private File dir; final private Option option; diff --git a/src/net/sourceforge/plantuml/DirWatcher2.java b/src/net/sourceforge/plantuml/DirWatcher2.java index ac185198a..d849574ac 100644 --- a/src/net/sourceforge/plantuml/DirWatcher2.java +++ b/src/net/sourceforge/plantuml/DirWatcher2.java @@ -53,6 +53,7 @@ import net.sourceforge.plantuml.log.Logme; import net.sourceforge.plantuml.preproc.FileWithSuffix; public class DirWatcher2 { + // ::remove file when WASM final private File dir; final private Option option; diff --git a/src/net/sourceforge/plantuml/EmptyImageBuilder.java b/src/net/sourceforge/plantuml/EmptyImageBuilder.java index c0abd7111..dc1ae5f6f 100644 --- a/src/net/sourceforge/plantuml/EmptyImageBuilder.java +++ b/src/net/sourceforge/plantuml/EmptyImageBuilder.java @@ -74,6 +74,7 @@ public class EmptyImageBuilder { if (width <= 0 || height <= 0) throw new IllegalArgumentException("width and height must be positive"); + // ::comment when WASM if (width > GraphvizUtils.getenvImageLimit()) { Log.info("Width too large " + width + ". You should set PLANTUML_LIMIT_SIZE"); width = GraphvizUtils.getenvImageLimit(); @@ -82,6 +83,7 @@ public class EmptyImageBuilder { Log.info("Height too large " + height + ". You should set PLANTUML_LIMIT_SIZE"); height = GraphvizUtils.getenvImageLimit(); } + // ::done this.background = background; this.stringBounder = stringBounder; Log.info("Creating image " + width + "x" + height); diff --git a/src/net/sourceforge/plantuml/FileFormat.java b/src/net/sourceforge/plantuml/FileFormat.java index ad51d62b3..762c24264 100644 --- a/src/net/sourceforge/plantuml/FileFormat.java +++ b/src/net/sourceforge/plantuml/FileFormat.java @@ -63,8 +63,7 @@ import net.sourceforge.plantuml.ugraphic.debug.StringBounderDebug; */ public enum FileFormat { - PNG("image/png"), // - SVG("image/svg+xml"), // + // ::comment when WASM EPS("application/postscript"), // EPS_TEXT("application/postscript"), // ATXT("text/plain"), // @@ -85,7 +84,10 @@ public enum FileFormat { BASE64("text/plain; charset=x-user-defined"), // BRAILLE_PNG("image/png"), // PREPROC("text/plain"), // - DEBUG("text/plain"); // + DEBUG("text/plain"), // + // ::done + PNG("image/png"), // + SVG("image/svg+xml"); // private final String mimeType; @@ -103,6 +105,7 @@ public enum FileFormat { * @return a string starting by a point. */ public String getFileSuffix() { + // ::comment when WASM if (name().startsWith("XMI")) return ".xmi"; @@ -120,6 +123,7 @@ public enum FileFormat { if (this == EPS_TEXT) return EPS.getFileSuffix(); + // ::done return "." + StringUtils.goLowerCase(name()); } @@ -136,17 +140,19 @@ public enum FileFormat { } public StringBounder getDefaultStringBounder(TikzFontDistortion tikzFontDistortion, SvgCharSizeHack charSizeHack) { + // ::comment when WASM if (this == LATEX || this == LATEX_NO_PREAMBLE) return getTikzStringBounder(tikzFontDistortion); if (this == BRAILLE_PNG) return getBrailleStringBounder(); - if (this == SVG) - return getSvgStringBounder(charSizeHack); - if (this == DEBUG) return new StringBounderDebug(); + // ::done + + if (this == SVG) + return getSvgStringBounder(charSizeHack); return getNormalStringBounder(); } @@ -193,6 +199,7 @@ public enum FileFormat { return new XDimension2D(rect.getWidth(), rect.getHeight()); } + // ::comment when WASM private StringBounder getBrailleStringBounder() { return new StringBounderRaw() { public String toString() { @@ -320,5 +327,6 @@ public enum FileFormat { } return false; } + // ::done } diff --git a/src/net/sourceforge/plantuml/ISourceFileReader.java b/src/net/sourceforge/plantuml/ISourceFileReader.java index b7a36aeb1..2aa1fdbb7 100644 --- a/src/net/sourceforge/plantuml/ISourceFileReader.java +++ b/src/net/sourceforge/plantuml/ISourceFileReader.java @@ -39,6 +39,7 @@ import java.io.IOException; import java.util.List; public interface ISourceFileReader { + // ::remove file when WASM public List getGeneratedImages() throws IOException; diff --git a/src/net/sourceforge/plantuml/Option.java b/src/net/sourceforge/plantuml/Option.java index f23f0726f..b89ad3e06 100644 --- a/src/net/sourceforge/plantuml/Option.java +++ b/src/net/sourceforge/plantuml/Option.java @@ -115,6 +115,7 @@ public class Option { this.fileFormatOption = newFormat; } + // ::comment when WASM public Option(String... arg) throws InterruptedException, IOException { if (arg.length == 0) OptionFlags.getInstance().setGui(true); @@ -403,6 +404,7 @@ public class Option { } } } + // ::done public Stdrpt getStdrpt() { if (stdrpt == 1) diff --git a/src/net/sourceforge/plantuml/OptionFlags.java b/src/net/sourceforge/plantuml/OptionFlags.java index 7099fd1f2..a6fba2570 100644 --- a/src/net/sourceforge/plantuml/OptionFlags.java +++ b/src/net/sourceforge/plantuml/OptionFlags.java @@ -77,6 +77,7 @@ public class OptionFlags { // static public final boolean LINK_BETWEEN_FIELDS = true; + // ::comment when WASM public void reset() { reset(false); GraphvizUtils.setDotExecutable(null); @@ -85,6 +86,7 @@ public class OptionFlags { public final void setDotExecutable(String dotExecutable) { GraphvizUtils.setDotExecutable(dotExecutable); } + // ::done private OptionFlags() { reset(true); @@ -195,6 +197,7 @@ public class OptionFlags { private final AtomicBoolean logDataInitized = new AtomicBoolean(false); public void logData(final SFile file, Diagram system) { + // ::comment when WASM final String warnOrError = system.getWarningOrError(); if (warnOrError == null) { return; @@ -222,6 +225,7 @@ public class OptionFlags { Logme.error(e); } } + // ::done } public final void setLogData(SFile logData) { diff --git a/src/net/sourceforge/plantuml/OptionPrint.java b/src/net/sourceforge/plantuml/OptionPrint.java index 1d6a8195a..740c2efe2 100644 --- a/src/net/sourceforge/plantuml/OptionPrint.java +++ b/src/net/sourceforge/plantuml/OptionPrint.java @@ -56,6 +56,7 @@ import net.sourceforge.plantuml.version.PSystemVersion; import net.sourceforge.plantuml.version.Version; public class OptionPrint { + //::remove file when WASM static public void printTestDot() throws InterruptedException { final List result = new ArrayList<>(); diff --git a/src/net/sourceforge/plantuml/PSystemBuilder.java b/src/net/sourceforge/plantuml/PSystemBuilder.java index a5748e6c5..1ea4ba3fb 100644 --- a/src/net/sourceforge/plantuml/PSystemBuilder.java +++ b/src/net/sourceforge/plantuml/PSystemBuilder.java @@ -148,11 +148,13 @@ public class PSystemBuilder { result = PSystemErrorUtils.merge(errors); return result; } finally { + // ::comment when WASM if (result != null && OptionFlags.getInstance().isEnableStats()) { StatsUtilsIncrement.onceMoreParse(System.currentTimeMillis() - now, result.getClass()); } Log.info("Compilation duration " + (System.currentTimeMillis() - now)); RegexConcat.printCacheInfo(); + // ::done } } @@ -174,46 +176,63 @@ public class PSystemBuilder { factories.add(new PSystemVersionFactory()); factories.add(new PSystemDonorsFactory()); factories.add(new PSystemSkinparameterListFactory()); + // ::comment when WASM factories.add(new PSystemListFontsFactory()); + // ::done factories.add(new PSystemListEmojiFactory()); + // ::comment when WASM factories.add(new PSystemOpenIconicFactory()); factories.add(new PSystemListOpenIconicFactory()); factories.add(new PSystemListInternalSpritesFactory()); + // ::done factories.add(new PSystemSaltFactory2(DiagramType.SALT)); factories.add(new PSystemSaltFactory2(DiagramType.UML)); + // ::comment when WASM factories.add(new PSystemDotFactory(DiagramType.DOT)); factories.add(new PSystemDotFactory(DiagramType.UML)); + // ::done factories.add(new NwDiagramFactory(DiagramType.NW)); factories.add(new NwDiagramFactory(DiagramType.UML)); factories.add(new MindMapDiagramFactory()); factories.add(new WBSDiagramFactory()); + // ::comment when WASM factories.add(new PSystemDitaaFactory(DiagramType.DITAA)); factories.add(new PSystemDitaaFactory(DiagramType.UML)); + // ::done if (License.getCurrent() == License.GPL || License.getCurrent() == License.GPLV2) { + // ::comment when WASM factories.add(new PSystemJcckitFactory(DiagramType.JCCKIT)); factories.add(new PSystemJcckitFactory(DiagramType.UML)); + // ::done // factories.add(new PSystemLogoFactory()); factories.add(new PSystemSudokuFactory()); } + // ::comment when WASM factories.add(new PSystemDefinitionFactory()); + // ::done factories.add(new ListSpriteDiagramFactory()); + // ::comment when WASM factories.add(new StdlibDiagramFactory()); factories.add(new PSystemMathFactory(DiagramType.MATH)); factories.add(new PSystemLatexFactory(DiagramType.LATEX)); + // ::done // factories.add(new PSystemStatsFactory()); factories.add(new PSystemCreoleFactory()); factories.add(new PSystemEggFactory()); factories.add(new PSystemAppleTwoFactory()); factories.add(new PSystemRIPFactory()); // factories.add(new PSystemLostFactory()); - if (SecurityUtils.getSecurityProfile() == SecurityProfile.UNSECURE) { + // ::comment when WASM + if (SecurityUtils.getSecurityProfile() == SecurityProfile.UNSECURE) factories.add(new PSystemPathFactory()); - } + // ::done factories.add(new PSystemOregonFactory()); factories.add(new PSystemCharlieFactory()); + // ::comment when WASM if (License.getCurrent() == License.GPL || License.getCurrent() == License.GPLV2) { factories.add(new PSystemXearthFactory()); } + // ::done factories.add(new GanttDiagramFactory()); factories.add(new FlowDiagramFactory()); // factories.add(new PSystemTreeFactory(DiagramType.JUNGLE)); diff --git a/src/net/sourceforge/plantuml/PSystemUtils.java b/src/net/sourceforge/plantuml/PSystemUtils.java index 71184850a..1d3941860 100644 --- a/src/net/sourceforge/plantuml/PSystemUtils.java +++ b/src/net/sourceforge/plantuml/PSystemUtils.java @@ -56,6 +56,7 @@ import net.sourceforge.plantuml.ugraphic.color.HColors; import net.sourceforge.plantuml.utils.Log; public class PSystemUtils { + // :: remove file when WASM public static List exportDiagrams(Diagram system, SuggestedFile suggested, FileFormatOption fileFormatOption) throws IOException { @@ -65,6 +66,7 @@ public class PSystemUtils { public static List exportDiagrams(Diagram system, SuggestedFile suggestedFile, FileFormatOption fileFormatOption, boolean checkMetadata) throws IOException { + // ::comment when WASM final SFile existingFile = suggestedFile.getFile(0); if (checkMetadata && fileFormatOption.getFileFormat().doesSupportMetadata() && existingFile.exists()) { // && system.getNbImages() == 1) { @@ -75,6 +77,7 @@ public class PSystemUtils { return Arrays.asList(new FileImageData(existingFile, null)); } } + // ::done if (system instanceof NewpagedDiagram) return exportDiagramsNewpaged((NewpagedDiagram) system, suggestedFile, fileFormatOption); @@ -82,8 +85,10 @@ public class PSystemUtils { if (system instanceof SequenceDiagram) return exportDiagramsSequence((SequenceDiagram) system, suggestedFile, fileFormatOption); + // ::comment when WASM if (system instanceof CucaDiagram && fileFormatOption.getFileFormat() == FileFormat.HTML) return createFilesHtml((CucaDiagram) system, suggestedFile); + // ::done return exportDiagramsDefault(system, suggestedFile, fileFormatOption); } @@ -146,10 +151,12 @@ public class PSystemUtils { } finally { fos.close(); } + // ::comment when SPAM if (cmap != null && cmap.containsCMapData()) system.exportCmap(suggestedFile, i, cmap); Log.info("File size : " + f.length()); + // ::done result.add(new FileImageData(f, cmap)); } return result; @@ -200,8 +207,10 @@ public class PSystemUtils { if (imageData == null) return emptyList(); + // ::comment when SPAM if (imageData.containsCMapData() && system instanceof UmlDiagram) ((UmlDiagram) system).exportCmap(suggestedFile, 0, imageData); + // ::done if (system instanceof TitledDiagram && fileFormatOption.getFileFormat() == FileFormat.PNG) return splitPng((TitledDiagram) system, suggestedFile, imageData, fileFormatOption); diff --git a/src/net/sourceforge/plantuml/Run.java b/src/net/sourceforge/plantuml/Run.java index e6d65c199..2f5d1c64c 100644 --- a/src/net/sourceforge/plantuml/Run.java +++ b/src/net/sourceforge/plantuml/Run.java @@ -75,6 +75,7 @@ import net.sourceforge.plantuml.utils.Log; import net.sourceforge.plantuml.version.Version; public class Run { + // ::remove file when WASM private static Cypher cypher; @@ -335,7 +336,8 @@ public class Run { } 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() { diff --git a/src/net/sourceforge/plantuml/SourceFileReader.java b/src/net/sourceforge/plantuml/SourceFileReader.java index ecde8f320..08718acd2 100644 --- a/src/net/sourceforge/plantuml/SourceFileReader.java +++ b/src/net/sourceforge/plantuml/SourceFileReader.java @@ -48,6 +48,7 @@ import net.sourceforge.plantuml.utils.Log; @HaxeIgnored public class SourceFileReader extends SourceFileReaderAbstract implements ISourceFileReader { + // ::remove file when WASM private File outputDirectory; diff --git a/src/net/sourceforge/plantuml/SourceFileReaderAbstract.java b/src/net/sourceforge/plantuml/SourceFileReaderAbstract.java index 1bfcfd7db..3bf229cf5 100644 --- a/src/net/sourceforge/plantuml/SourceFileReaderAbstract.java +++ b/src/net/sourceforge/plantuml/SourceFileReaderAbstract.java @@ -65,6 +65,7 @@ import net.sourceforge.plantuml.security.SecurityUtils; import net.sourceforge.plantuml.utils.Log; public abstract class SourceFileReaderAbstract implements ISourceFileReader { + // ::remove file when WASM final private File file; diff --git a/src/net/sourceforge/plantuml/SourceFileReaderCopyCat.java b/src/net/sourceforge/plantuml/SourceFileReaderCopyCat.java index 306415249..5cd923cef 100644 --- a/src/net/sourceforge/plantuml/SourceFileReaderCopyCat.java +++ b/src/net/sourceforge/plantuml/SourceFileReaderCopyCat.java @@ -42,6 +42,7 @@ import java.util.List; import net.sourceforge.plantuml.preproc.Defines; public class SourceFileReaderCopyCat extends SourceFileReaderAbstract implements ISourceFileReader { + // ::remove file when WASM private final File outputDirectory; diff --git a/src/net/sourceforge/plantuml/SourceFileReaderHardFile.java b/src/net/sourceforge/plantuml/SourceFileReaderHardFile.java index 32bae2111..095f09c22 100644 --- a/src/net/sourceforge/plantuml/SourceFileReaderHardFile.java +++ b/src/net/sourceforge/plantuml/SourceFileReaderHardFile.java @@ -43,6 +43,7 @@ import net.sourceforge.plantuml.preproc.Defines; import net.sourceforge.plantuml.security.SFile; public class SourceFileReaderHardFile extends SourceFileReaderAbstract implements ISourceFileReader { + // ::remove file when WASM private final File outputFile; diff --git a/src/net/sourceforge/plantuml/StringUtils.java b/src/net/sourceforge/plantuml/StringUtils.java index e6a4c912d..598b2ce04 100644 --- a/src/net/sourceforge/plantuml/StringUtils.java +++ b/src/net/sourceforge/plantuml/StringUtils.java @@ -353,6 +353,7 @@ public class StringUtils { return result; } + // ::comment when WASM public static int getWcWidth(Display stringsToDisplay) { int result = 1; for (CharSequence s : stringsToDisplay) { @@ -366,6 +367,7 @@ public class StringUtils { } return result; } + // ::done public static int getHeight(List stringsToDisplay) { return stringsToDisplay.size(); diff --git a/src/net/sourceforge/plantuml/SuggestedFile.java b/src/net/sourceforge/plantuml/SuggestedFile.java index 9e4453eab..82d6bae28 100644 --- a/src/net/sourceforge/plantuml/SuggestedFile.java +++ b/src/net/sourceforge/plantuml/SuggestedFile.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml; import net.sourceforge.plantuml.security.SFile; public class SuggestedFile { + // ::remove file when WASM private final FileFormat fileFormat; private final int initialCpt; diff --git a/src/net/sourceforge/plantuml/TitledDiagram.java b/src/net/sourceforge/plantuml/TitledDiagram.java index 377d32f5a..038e0d6b0 100644 --- a/src/net/sourceforge/plantuml/TitledDiagram.java +++ b/src/net/sourceforge/plantuml/TitledDiagram.java @@ -81,7 +81,9 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram, private final SkinParam skinParam; + // ::comment when WASM private Animation animation; + // ::done private final Pragma pragma = new Pragma(); @@ -252,6 +254,7 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram, return ClockwiseTopRightBottomLeft.same(10); } + // ::comment when WASM final public void setAnimation(Iterable animationData) { // try { final AnimationDecoder animationDecoder = new AnimationDecoder(animationData); @@ -264,6 +267,7 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram, final public Animation getAnimation() { return animation; } + // ::done @Override public ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) throws IOException { diff --git a/src/net/sourceforge/plantuml/UmlDiagram.java b/src/net/sourceforge/plantuml/UmlDiagram.java index 354846265..dd7eb0b94 100644 --- a/src/net/sourceforge/plantuml/UmlDiagram.java +++ b/src/net/sourceforge/plantuml/UmlDiagram.java @@ -129,8 +129,10 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot fileFormatOption = fileFormatOption.withTikzFontDistortion(getSkinParam().getTikzFontDistortion()); + // ::comment when WASM if (fileFormatOption.getFileFormat() == FileFormat.PDF) return exportDiagramInternalPdf(os, index); + // ::done try { 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, String metadata, String flash, List strings) throws IOException { + // ::comment when WASM if (fileFormat.getFileFormat() == FileFormat.ATXT || fileFormat.getFileFormat() == FileFormat.UTXT) { exportDiagramErrorText(os, exception, strings); return; } + // ::done strings.addAll(CommandExecutionResult.getStackTrace(exception)); BufferedImage im2 = null; + // ::comment when WASM if (flash != null) { final FlashCodeUtils utils = FlashCodeFactory.getFlashCodeUtils(); try { @@ -176,8 +181,9 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot } if (im2 != null) GraphvizCrash.addDecodeHint(strings); - } + // ::done + final BufferedImage im = im2; final TextBlockBackcolored graphicStrings = GraphicStrings.createBlackOnWhite(strings, IconLoader.getRandom(), GraphicPosition.BACKGROUND_CORNER_TOP_RIGHT); @@ -245,6 +251,7 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot return strings; } + // ::comment when WASM private void exportDiagramInternalMjpeg(OutputStream os) throws IOException { final SFile f = new SFile("c:/test.avi"); 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 { final File svg = FileUtils.createTempFileLegacy("pdf", ".svf"); final File pdfFile = FileUtils.createTempFileLegacy("pdf", ".pdf"); @@ -280,9 +285,6 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot 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) throws FileNotFoundException { 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) { return name.replaceAll("(?i)\\.\\w{3}$", ".cmapx"); } + // ::done + + private XDimension2D lastInfo; + + protected abstract ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) + throws IOException; @Override public String getWarningOrError() { diff --git a/src/net/sourceforge/plantuml/Url.java b/src/net/sourceforge/plantuml/Url.java index 399c698ad..75b9d2af3 100644 --- a/src/net/sourceforge/plantuml/Url.java +++ b/src/net/sourceforge/plantuml/Url.java @@ -93,9 +93,11 @@ public class Url implements EnsureVisible { } 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()); - } + // ::done + return visible.getCoords(scale); } diff --git a/src/net/sourceforge/plantuml/acearth/PSystemXearth.java b/src/net/sourceforge/plantuml/acearth/PSystemXearth.java index 2e9bf6ec0..4b47169f8 100644 --- a/src/net/sourceforge/plantuml/acearth/PSystemXearth.java +++ b/src/net/sourceforge/plantuml/acearth/PSystemXearth.java @@ -58,6 +58,7 @@ import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.UmlSource; public class PSystemXearth extends AbstractPSystem { + // :: remove folder when WASM final private int width; final private int height; diff --git a/src/net/sourceforge/plantuml/activitydiagram/ActivityDiagram.java b/src/net/sourceforge/plantuml/activitydiagram/ActivityDiagram.java index f281f57d7..77fdd3017 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/ActivityDiagram.java +++ b/src/net/sourceforge/plantuml/activitydiagram/ActivityDiagram.java @@ -42,23 +42,19 @@ import java.util.Objects; import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.baraye.CucaDiagram; -import net.sourceforge.plantuml.baraye.IEntity; -import net.sourceforge.plantuml.baraye.ILeaf; +import net.sourceforge.plantuml.baraye.EntityImp; +import net.sourceforge.plantuml.baraye.Quark; import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.UmlSource; -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.NamespaceStrategy; -import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.utils.Direction; public class ActivityDiagram extends CucaDiagram { - private IEntity lastEntityConsulted; - private IEntity lastEntityBrancheConsulted; + private EntityImp lastEntityConsulted; + private EntityImp lastEntityBrancheConsulted; private ConditionalContext currentContext; public ActivityDiagram(UmlSource source, Map skinParam) { @@ -66,34 +62,33 @@ public class ActivityDiagram extends CucaDiagram { setNamespaceSeparator(null); } - public ILeaf getOrCreateLeaf(Ident ident, Code code, LeafType type, USymbol symbol) { - return getOrCreateLeafDefault(Objects.requireNonNull(ident), code, type, symbol); - } - private String getAutoBranch() { return "#" + this.getUniqueSequence(); } - public IEntity getOrCreate(Ident idNewLong, Code code, Display display, LeafType type) { - final IEntity result; - final boolean leafExist = leafExist(code); - if (leafExist) { - result = getOrCreateLeafDefault(idNewLong, code, type, null); - if (result.getLeafType() != type) { - return null; - } - } else { - result = createLeaf(idNewLong, code, display, type, null); - } - updateLasts(result); - return result; - } +// public final IEntity getOrCreateInActivity(Quark idNewLong, String codeString, Display display, LeafType type) { +// final Quark code = buildFromFullPath(codeString); +// final IEntity result; +// if (code.getData() == null) { +// final Quark quark = getPlasma().getIfExistsFromName(code.getName()); +// if (quark != null && quark.getData() != null) +// result = getFromName(code.getName()); +// else +// result = reallyCreateLeaf(idNewLong, display, type, null); +// } else { +// result = (ILeaf) code.getData(); +// if (result.getLeafType() != type) +// return null; +// } +// updateLasts(result); +// return result; +// } public void startIf(String optionalCodeString) { final String idShort = optionalCodeString == null ? getAutoBranch() : optionalCodeString; - final Ident idNewLong = buildLeafIdent(idShort); - final Code code = buildCode(idShort); - final IEntity br = createLeaf(idNewLong, code, Display.create(""), LeafType.BRANCH, null); + final Quark quark = quarkInContext(cleanIdForQuark(idShort), false); + // final Quark code = buildCode(idShort); + final EntityImp br = reallyCreateLeaf(quark, Display.create(""), LeafType.BRANCH, null); currentContext = new ConditionalContext(currentContext, br, Direction.DOWN); } @@ -101,38 +96,37 @@ public class ActivityDiagram extends CucaDiagram { currentContext = currentContext.getParent(); } - public ILeaf getStart() { - final Ident ident = buildLeafIdent("start"); - final Code code = buildCode("start"); - return (ILeaf) getOrCreate(ident, code, Display.getWithNewlines("start"), LeafType.CIRCLE_START); + public EntityImp getStart() { + final Quark quark = quarkInContext("start", false); + if (quark.getData() == null) { + 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 Ident ident = buildLeafIdent(tmp); - final Code code = buildCode(tmp); - return (ILeaf) getOrCreate(ident, code, Display.getWithNewlines("end"), LeafType.CIRCLE_END); - } - - private void updateLasts(final IEntity result) { - if (result == null || result.getLeafType() == LeafType.NOTE) { - return; - } - this.lastEntityConsulted = result; - if (result.getLeafType() == LeafType.BRANCH) { - lastEntityBrancheConsulted = result; + final Quark quark = quarkInContext(tmp, false); + if (quark.getData() == null) { + quark.setData(reallyCreateLeaf(quark, Display.getWithNewlines("end"), LeafType.CIRCLE_END, null)); } + return (EntityImp) quark.getData(); } @Override - public ILeaf createLeaf(Ident idNewLong, Code code, Display display, LeafType type, USymbol symbol) { - final ILeaf result = super.createLeaf(Objects.requireNonNull(idNewLong), code, display, type, symbol); - updateLasts(result); - return result; + protected void updateLasts(EntityImp result) { + if (result == null || result.getLeafType() == LeafType.NOTE) + return; + + // System.err.println("updateLasts " + result); + this.lastEntityConsulted = result; + if (result.getLeafType() == LeafType.BRANCH) + lastEntityBrancheConsulted = result; + } - public IEntity createNote(Ident idNewLong, Code code, Display display) { - return super.createLeaf(Objects.requireNonNull(idNewLong), code, display, LeafType.NOTE, null); + public EntityImp createNote(Quark idNewLong, String code__, Display display) { + return reallyCreateLeaf(Objects.requireNonNull(idNewLong), display, LeafType.NOTE, null); } final protected List getDotStrings() { @@ -144,12 +138,12 @@ public class ActivityDiagram extends CucaDiagram { return new DiagramDescription("(" + getLeafssize() + " activities)"); } - public IEntity getLastEntityConsulted() { + public EntityImp getLastEntityConsulted() { return lastEntityConsulted; } @Deprecated - public IEntity getLastEntityBrancheConsulted() { + public EntityImp getLastEntityBrancheConsulted() { return lastEntityBrancheConsulted; } @@ -157,41 +151,36 @@ public class ActivityDiagram extends CucaDiagram { return currentContext; } - public final void setLastEntityConsulted(IEntity lastEntityConsulted) { + public final void setLastEntityConsulted(EntityImp lastEntityConsulted) { + // System.err.println("setLastEntityConsulted " + lastEntityConsulted); this.lastEntityConsulted = lastEntityConsulted; } - public IEntity createInnerActivity() { - // Log.println("createInnerActivity A"); + public EntityImp createInnerActivity() { + final String idShort = "##" + this.getUniqueSequence(); - final Ident idNewLong = buildLeafIdent(idShort); - final Code code = buildCode(idShort); - gotoGroup(idNewLong, code, Display.getWithNewlines(code), GroupType.INNER_ACTIVITY, getCurrentGroup(), - NamespaceStrategy.SINGLE); - final IEntity g = getCurrentGroup(); - // g.setRankdir(Rankdir.LEFT_TO_RIGHT); + + final Quark quark = quarkInContext(idShort, false); + gotoGroup(quark, Display.getWithNewlines(quark.getName()), GroupType.INNER_ACTIVITY); + final EntityImp g = getCurrentGroup(); + lastEntityConsulted = null; lastEntityBrancheConsulted = null; - // Log.println("createInnerActivity B "+getCurrentGroup()); + return g; } public void concurrentActivity(String name) { - // Log.println("concurrentActivity A name=" + name+" "+getCurrentGroup()); - if (getCurrentGroup().getGroupType() == GroupType.CONCURRENT_ACTIVITY) { - // getCurrentGroup().setRankdir(Rankdir.LEFT_TO_RIGHT); + if (getCurrentGroup().getGroupType() == GroupType.CONCURRENT_ACTIVITY) endGroup(); - // Log.println("endgroup"); - } + 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()); - } - final Ident idNewLong = buildLeafIdent(idShort); - gotoGroup(idNewLong, code, Display.getWithNewlines("code"), GroupType.CONCURRENT_ACTIVITY, getCurrentGroup(), - NamespaceStrategy.SINGLE); + + final Quark idNewLong = quarkInContext(idShort, false); + gotoGroup(idNewLong, Display.getWithNewlines("code"), GroupType.CONCURRENT_ACTIVITY); lastEntityConsulted = null; lastEntityBrancheConsulted = null; } diff --git a/src/net/sourceforge/plantuml/activitydiagram/ConditionalContext.java b/src/net/sourceforge/plantuml/activitydiagram/ConditionalContext.java index 4e8177f64..06f7c394b 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/ConditionalContext.java +++ b/src/net/sourceforge/plantuml/activitydiagram/ConditionalContext.java @@ -37,17 +37,17 @@ package net.sourceforge.plantuml.activitydiagram; 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.utils.Direction; public class ConditionalContext { - private final IEntity branch; + private final EntityImp branch; private final Direction direction; 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); if (branch.getLeafType() != LeafType.BRANCH) { throw new IllegalArgumentException(); @@ -64,7 +64,7 @@ public class ConditionalContext { return parent; } - public final IEntity getBranch() { + public final EntityImp getBranch() { return branch; } diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandElse.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandElse.java index 4646d779a..0eee8df0d 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandElse.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandElse.java @@ -36,7 +36,7 @@ package net.sourceforge.plantuml.activitydiagram.command; 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.SingleLineCommand2; import net.sourceforge.plantuml.command.regex.IRegex; @@ -66,7 +66,7 @@ public class CommandElse extends SingleLineCommand2 { if (system.getCurrentContext() == null) { return CommandExecutionResult.error("No if for this else"); } - final IEntity branch = system.getCurrentContext().getBranch(); + final EntityImp branch = system.getCurrentContext().getBranch(); system.setLastEntityConsulted(branch); diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java index 54dfe55de..d014901d0 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java @@ -37,7 +37,7 @@ package net.sourceforge.plantuml.activitydiagram.command; import net.sourceforge.plantuml.StringUtils; 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.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; @@ -94,7 +94,7 @@ public class CommandIf extends SingleLineCommand2 { @Override 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) return CommandExecutionResult.error("No if possible at this point"); @@ -122,10 +122,10 @@ public class CommandIf extends SingleLineCommand2 { 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); - 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) .withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle())); if (arg.get("ARROW", 0) != null) { diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandInnerConcurrent.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandInnerConcurrent.java index 491960e29..3201acba5 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandInnerConcurrent.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandInnerConcurrent.java @@ -61,7 +61,7 @@ public class CommandInnerConcurrent extends SingleLineCommand2 @Override 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"); } diagram.concurrentActivity(arg.get("NAME", 0)); diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java index 4b2caf65d..2afba240c 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java @@ -40,7 +40,8 @@ import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; 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.command.CommandExecutionResult; 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.RegexPartialMatch; import net.sourceforge.plantuml.command.regex.RegexResult; -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.LinkArg; import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.cucadiagram.LinkType; -import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement; import net.sourceforge.plantuml.graphic.color.ColorParser; @@ -124,7 +122,8 @@ public class CommandLinkActivity extends SingleLineCommand2 { @Override protected CommandExecutionResult executeArg(ActivityDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { - final IEntity entity1 = getEntity(diagram, arg, true); + final EntityImp entity1 = getEntity(diagram, arg, true); + if (entity1 == null) return CommandExecutionResult.error("No such activity"); @@ -136,10 +135,12 @@ public class CommandLinkActivity extends SingleLineCommand2 { 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) return CommandExecutionResult.error("No such activity"); + diagram.setLastEntityConsulted(entity2); + if (arg.get("BACKCOLOR2", 0) != null) { String s = arg.get("BACKCOLOR2", 0); entity2.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet().getColor(s)); @@ -163,7 +164,7 @@ public class CommandLinkActivity extends SingleLineCommand2 { type = type.goDotted(); 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); if (arrowDirection.contains("*")) link.setConstraint(false); @@ -185,7 +186,7 @@ public class CommandLinkActivity extends SingleLineCommand2 { } - 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 openBracket2 = arg.get("OPENBRACKET" + suf, 0); @@ -208,15 +209,16 @@ public class CommandLinkActivity extends SingleLineCommand2 { final String idShort = arg.get("CODE" + suf, 0); if (idShort != null) { if (partition != null) { - final Ident idNewLong = diagram.buildLeafIdent(partition); - final Code codeP = diagram.buildCode(partition); - diagram.gotoGroup(idNewLong, codeP, Display.getWithNewlines(partition), GroupType.PACKAGE, - diagram.getRootGroup(), NamespaceStrategy.SINGLE); + final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(partition), false); + diagram.gotoGroup(quark, Display.getWithNewlines(quark), GroupType.PACKAGE); } - final Ident ident = diagram.buildLeafIdent(idShort); - final Code code = diagram.buildCode(idShort); - final LeafType type = getTypeIfExisting(diagram, code); - final IEntity result = diagram.getOrCreate(ident, code, Display.getWithNewlines(code), type); + final Quark ident = diagram.quarkInContext(diagram.cleanIdForQuark(idShort), false); + + final LeafType type = getTypeIfExisting(diagram, ident); + EntityImp result = (EntityImp) ident.getData(); + if (result == null) + result = diagram.reallyCreateLeaf(ident, Display.getWithNewlines(idShort), type, null); + if (partition != null) diagram.endGroup(); @@ -224,24 +226,26 @@ public class CommandLinkActivity extends SingleLineCommand2 { } final String bar = arg.get("BAR" + suf, 0); if (bar != null) { - final Ident identBar = diagram.buildLeafIdent(bar); - final Code codeBar = diagram.buildCode(bar); - return diagram.getOrCreate(identBar, codeBar, Display.getWithNewlines(bar), LeafType.SYNCHRO_BAR); + final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(bar), false); + EntityImp result = (EntityImp) quark.getData(); + if (result == null) + result = diagram.reallyCreateLeaf(quark, Display.getWithNewlines(bar), LeafType.SYNCHRO_BAR, null); + return result; } final RegexPartialMatch quoted = arg.get("QUOTED" + suf); if (quoted.get(0) != null) { final String quotedString = quoted.get(1) == null ? quoted.get(0) : quoted.get(1); if (partition != null) { - final Ident idNewLong = diagram.buildLeafIdent(partition); - final Code codeP = diagram.buildCode(partition); - diagram.gotoGroup(idNewLong, codeP, Display.getWithNewlines(partition), GroupType.PACKAGE, - diagram.getRootGroup(), NamespaceStrategy.SINGLE); + final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(partition), false); + diagram.gotoGroup(quark, Display.getWithNewlines(partition), GroupType.PACKAGE); } - final Ident quotedIdent = diagram.buildLeafIdent(quotedString); - final Code quotedCode = diagram.buildCode(quotedString); - final LeafType type = getTypeIfExisting(diagram, quotedCode); - final IEntity result = diagram.getOrCreate(quotedIdent, quotedCode, Display.getWithNewlines(quoted.get(0)), - type); + + final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(quotedString), false); + + final LeafType type = getTypeIfExisting(diagram, quark); + EntityImp result = (EntityImp) quark.getData(); + if (result == null) + result = diagram.reallyCreateLeaf(quark, Display.getWithNewlines(quoted.get(0)), type, null); if (partition != null) diagram.endGroup(); @@ -250,15 +254,14 @@ public class CommandLinkActivity extends SingleLineCommand2 { final String quoteInvisibleString = arg.get("QUOTED_INVISIBLE" + suf, 0); if (quoteInvisibleString != null) { if (partition != null) { - final Ident idNewLong = diagram.buildLeafIdent(partition); - final Code codeP = diagram.buildCode(partition); - diagram.gotoGroup(idNewLong, codeP, Display.getWithNewlines(partition), GroupType.PACKAGE, - diagram.getRootGroup(), NamespaceStrategy.SINGLE); + final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(partition), false); + diagram.gotoGroup(quark, Display.getWithNewlines(quark), GroupType.PACKAGE); } - final Ident identInvisible = diagram.buildLeafIdent(quoteInvisibleString); - final Code quotedInvisible = diagram.buildCode(quoteInvisibleString); - final IEntity result = diagram.getOrCreate(identInvisible, quotedInvisible, - Display.getWithNewlines(quotedInvisible), LeafType.ACTIVITY); + final Quark identInvisible = diagram.quarkInContext(diagram.cleanIdForQuark(quoteInvisibleString), false); + EntityImp result = (EntityImp) identInvisible.getData(); + if (result == null) + result = diagram.reallyCreateLeaf(identInvisible, Display.getWithNewlines(identInvisible.getName()), + LeafType.ACTIVITY, null); if (partition != null) diagram.endGroup(); @@ -271,13 +274,13 @@ public class CommandLinkActivity extends SingleLineCommand2 { return null; } - private static LeafType getTypeIfExisting(ActivityDiagram system, Code code) { - if (system.leafExist(code)) { - final IEntity ent = system.getLeaf(code); - if (ent.getLeafType() == LeafType.BRANCH) - return LeafType.BRANCH; - - } + private static LeafType getTypeIfExisting(ActivityDiagram system, Quark code) { +// if (code.getData() == null) { +// final Quark quark = system.getPlasma().getIfExistsFromName(code.getName()); +// final IEntity ent = quark == null ? null : (ILeaf) quark.getData(); +// if (ent.getLeafType() == LeafType.BRANCH) +// return LeafType.BRANCH; +// } return LeafType.ACTIVITY; } diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java index ddc6047dd..bc8cf5e5d 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java @@ -43,7 +43,8 @@ import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; 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.command.CommandExecutionResult; 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.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.GroupType; -import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.LinkArg; import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.cucadiagram.LinkType; -import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement; import net.sourceforge.plantuml.graphic.color.ColorType; @@ -122,7 +120,7 @@ public class CommandLinkLongActivity extends CommandMultilines2 lines = lines.trim(); 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) return CommandExecutionResult.error("No such entity"); @@ -178,15 +176,16 @@ public class CommandLinkLongActivity extends CommandMultilines2 partition = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(partition); } if (partition != null) { - final Ident idNewLong = diagram.buildLeafIdent(partition); - diagram.gotoGroup(idNewLong, diagram.buildCode(partition), Display.getWithNewlines(partition), - GroupType.PACKAGE, null, NamespaceStrategy.SINGLE); + final Quark idNewLong = diagram.quarkInContext(diagram.cleanIdForQuark(partition), false); + diagram.gotoGroup(idNewLong, Display.getWithNewlines(partition), GroupType.PACKAGE); } - final Ident ident = diagram.buildLeafIdent(idShort); - final Code code = diagram.buildCode(idShort); - final IEntity entity2 = diagram.getOrCreate(ident, code, Display.getWithNewlines(display), LeafType.ACTIVITY); + final Quark ident = diagram.quarkInContext(diagram.cleanIdForQuark(idShort), false); + + EntityImp entity2 = (EntityImp) ident.getData(); 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) diagram.endGroup(); @@ -217,7 +216,7 @@ public class CommandLinkLongActivity extends CommandMultilines2 type = type.goDotted(); 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); final Direction direction = StringUtils.getArrowDirection(arrowBody1 + arrowDirection + arrowBody2 + ">"); if (direction == Direction.LEFT || direction == Direction.UP) diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java index dd88036eb..d6dfedce7 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java @@ -35,10 +35,9 @@ */ package net.sourceforge.plantuml.activitydiagram.command; -import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.activitydiagram.ActivityDiagram; -import net.sourceforge.plantuml.baraye.IEntity; -import net.sourceforge.plantuml.baraye.IGroup; +import net.sourceforge.plantuml.baraye.EntityImp; +import net.sourceforge.plantuml.baraye.Quark; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; 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.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.GroupType; -import net.sourceforge.plantuml.cucadiagram.Ident; -import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorType; @@ -87,13 +83,13 @@ public class CommandPartition extends SingleLineCommand2 { @Override protected CommandExecutionResult executeArg(ActivityDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { - final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("NAME", 0)); - final Ident ident = diagram.buildLeafIdent(idShort); - final Code code = diagram.buildCode(idShort); - final IGroup currentPackage = diagram.getCurrentGroup(); - diagram.gotoGroup(ident, code, Display.getWithNewlines(code), GroupType.PACKAGE, currentPackage, - NamespaceStrategy.SINGLE); - final IEntity p = diagram.getCurrentGroup(); + final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(arg.get("NAME", 0)), false); +// final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("NAME", 0)); +// final Quark ident = diagram.buildFromName(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(idShort)); +// final Quark code = diagram.buildFromFullPath(idShort); + + diagram.gotoGroup(quark, Display.getWithNewlines(quark.getName()), GroupType.PACKAGE); + final EntityImp p = diagram.getCurrentGroup(); final Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet()); if (colors.isEmpty() == false) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorAssembly.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorAssembly.java index 0d84fc5a4..ec26185fb 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorAssembly.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorAssembly.java @@ -45,7 +45,6 @@ import net.sourceforge.plantuml.awt.geom.XPoint2D; import net.sourceforge.plantuml.graphic.Rainbow; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.ugraphic.UTranslate; public class FtileFactoryDelegatorAssembly extends FtileFactoryDelegator { diff --git a/src/net/sourceforge/plantuml/anim/AffineTransformation.java b/src/net/sourceforge/plantuml/anim/AffineTransformation.java index 1aca82064..255813091 100644 --- a/src/net/sourceforge/plantuml/anim/AffineTransformation.java +++ b/src/net/sourceforge/plantuml/anim/AffineTransformation.java @@ -47,6 +47,7 @@ import net.sourceforge.plantuml.awt.geom.XPoint2D; import net.sourceforge.plantuml.ugraphic.MinMax; public class AffineTransformation { + // ::remove folder when WASM 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*)"); @@ -143,12 +144,12 @@ public class AffineTransformation { public MinMax getMinMax(XDimension2D rect) { MinMax result = MinMax.getEmpty(false); final AffineTransform tmp = getAffineTransform(rect); - + result = result.addPoint(new XPoint2D(0, 0).transform(tmp)); result = result.addPoint(new XPoint2D(0, rect.getHeight()).transform(tmp)); result = result.addPoint(new XPoint2D(rect.getWidth(), 0).transform(tmp)); result = result.addPoint(new XPoint2D(rect.getWidth(), rect.getHeight()).transform(tmp)); - + return result; } diff --git a/src/net/sourceforge/plantuml/ant/CheckZipTask.java b/src/net/sourceforge/plantuml/ant/CheckZipTask.java index f6c628a20..05c5bdae9 100644 --- a/src/net/sourceforge/plantuml/ant/CheckZipTask.java +++ b/src/net/sourceforge/plantuml/ant/CheckZipTask.java @@ -54,6 +54,7 @@ import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.security.SecurityUtils; public class CheckZipTask extends Task { + // ::remove folder when WASM private String zipfile = null; private List filesets = new ArrayList<>(); diff --git a/src/net/sourceforge/plantuml/asciiart/AbstractComponentText.java b/src/net/sourceforge/plantuml/asciiart/AbstractComponentText.java index baed1386c..8bf96d6e1 100644 --- a/src/net/sourceforge/plantuml/asciiart/AbstractComponentText.java +++ b/src/net/sourceforge/plantuml/asciiart/AbstractComponentText.java @@ -42,13 +42,14 @@ import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.StyleSignatureBasic; public abstract class AbstractComponentText implements Component { + // ::remove folder when WASM public final XDimension2D getPreferredDimension(StringBounder stringBounder) { final double w = getPreferredWidth(stringBounder); final double h = getPreferredHeight(stringBounder); return new XDimension2D(w, h); } - + public Style[] getUsedStyles() { throw new UnsupportedOperationException(); } @@ -57,5 +58,4 @@ public abstract class AbstractComponentText implements Component { throw new UnsupportedOperationException(); } - } diff --git a/src/net/sourceforge/plantuml/baraye/CucaDiagram.java b/src/net/sourceforge/plantuml/baraye/CucaDiagram.java index 382e7cae7..c11b6a826 100644 --- a/src/net/sourceforge/plantuml/baraye/CucaDiagram.java +++ b/src/net/sourceforge/plantuml/baraye/CucaDiagram.java @@ -50,15 +50,13 @@ import java.util.concurrent.atomic.AtomicInteger; import net.sourceforge.plantuml.BackSlash; import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.FileFormatOption; +import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.api.ImageDataSimple; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.core.ImageData; 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.EntityGender; 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.HideOrShow2; import net.sourceforge.plantuml.cucadiagram.ICucaDiagram; -import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.LinkConstraint; import net.sourceforge.plantuml.cucadiagram.Magma; import net.sourceforge.plantuml.cucadiagram.MagmaList; -import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; import net.sourceforge.plantuml.cucadiagram.PortionShower; import net.sourceforge.plantuml.cucadiagram.Together; import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramTxtMaker; -import net.sourceforge.plantuml.cucadiagram.entity.IEntityFactory; import net.sourceforge.plantuml.elk.CucaDiagramFileMakerElk; import net.sourceforge.plantuml.graphic.USymbol; 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.svek.CucaDiagramFileMaker; import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek; -import net.sourceforge.plantuml.utils.Log; import net.sourceforge.plantuml.xmi.CucaDiagramXmiMaker; import net.sourceforge.plantuml.xmlsc.StateDiagramScxmlMaker; public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, PortionShower, ICucaDiagram { - static public final boolean QUARK = false; - private String namespaceSeparator = null; private boolean namespaceSeparatorHasBeenSet = false; - public Quark currentQuark() { - throw new UnsupportedOperationException(); - } - - public /* protected */ Plasma getPlasma() { - throw new UnsupportedOperationException(); + public final boolean mergeIntricated() { + return false; } private final List hides2 = new ArrayList<>(); private final List removed = new ArrayList<>(); protected final EntityFactory entityFactory = new EntityFactory(hides2, removed, this); - private IGroup currentGroup = entityFactory.getRootGroup(); - private List stacks2 = new ArrayList<>(); - private List stacks = new ArrayList<>(); + + private List stacks = new ArrayList<>(); private boolean visibilityModifierPresent; - private NamespaceStrategy lastNamespaceStrategy; + // private NamespaceStrategy lastNamespaceStrategy; 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 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; } - private Ident getLastID() { - if (stacks2.size() == 0) { - // Thread.dumpStack(); - return Ident.empty(); - // throw new IllegalArgumentException(); - } - return this.stacks2.get(stacks2.size() - 1); + public Quark currentQuark() { + return this.stacks.get(stacks.size() - 1); + } + + public String cleanIdForQuark(String id) { + if (id == null) + return null; + return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(id); } final public void setNamespaceSeparator(String namespaceSeparator) { this.namespaceSeparatorHasBeenSet = true; this.namespaceSeparator = namespaceSeparator; + getPlasma().setSeparator(namespaceSeparator); } final public String getNamespaceSeparator() { @@ -157,103 +145,127 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, @Override public boolean hasUrl() { - for (IEntity entity : getGroups(true)) - if (entity.hasUrl()) - return true; - - for (IEntity entity : entityFactory.leafs()) - if (entity.hasUrl()) - return true; - - for (Link link : getLinks()) - if (link.hasUrl()) + for (Quark quark : getPlasma().quarks()) { + final EntityImp ent = (EntityImp) quark.getData(); + if (ent != null && ent.hasUrl()) return true; + } return false; } - final public void setLastEntity(ILeaf foo) { - this.lastEntity = foo; + final public void setLastEntity(EntityImp foo) { + this.lastEntity = (EntityImp) foo; } - final protected ILeaf getOrCreateLeafDefault(Ident idNewLong, Code code, LeafType type, USymbol symbol) { - Objects.requireNonNull(idNewLong); + protected void updateLasts(EntityImp result) { + } + + final public EntityImp reallyCreateLeaf(Quark ident, Display display, LeafType type, USymbol symbol) { Objects.requireNonNull(type); - ILeaf result = entityFactory.getLeaf(code); - - 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 (ident.getData() != null) + throw new IllegalStateException(); 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) { - return getLastID().add(id, getNamespaceSeparator()); + final public Quark quarkInContext(String full, boolean specialForCreateClass) { + final String sep = getNamespaceSeparator(); + if (sep == null) { + final Quark result = getPlasma().getIfExistsFromName(full); + if (result != null) + return result; + return currentQuark().child(full); + } + + final Quark currentQuark = currentQuark(); + 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 String first = full.substring(0, x); + final boolean firstPackageDoesExist = getPlasma().root().childIfExists(first) != null; + + if (firstPackageDoesExist) + return getPlasma().root().child(full); + return currentQuark.child(full); + } - final public Ident buildLeafIdentSpecial(String id) { - return buildFullyQualified(id); + public String removePortId(String id) { + // 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 Ident buildLeafIdentSpecial2(String id) { - return buildFullyQualified(id); + public String getPortId(String id) { + // To be kept + if ("::".equals(namespaceSeparator)) + return null; + final int x = id.lastIndexOf("::"); + if (x == -1) + return null; + return id.substring(x + 2); } - final public Ident buildFullyQualified(String id) { - return entityFactory.buildFullyQualified(getLastID(), Ident.empty().add(id, getNamespaceSeparator())); + public /* protected */ Plasma getPlasma() { + return entityFactory.getPlasma(); } - final public Code buildCode(String s) { - return CodeImpl.of(s); - } + final public Collection getChildrenGroups(EntityImp parent) { + final Collection result = new ArrayList<>(); - public boolean leafExist(Code code) { - return entityFactory.getLeaf(code) != null; - } + final Quark parent__; + if (parent.instanceofGroupRoot()) + parent__ = getPlasma().root(); + else + parent__ = ((EntityImp) parent).getQuark(); - public boolean leafExistStrict(Ident ident) { - return entityFactory.getLeafStrict(ident) != null; - } - - final public Collection getChildrenGroups(IGroup parent) { - final Collection result = new ArrayList<>(); - for (IGroup gg : getGroups(false)) - if (gg.getParentContainer() == parent) + for (EntityImp gg : getGroups(false)) + if (gg.getQuark().getParent() == parent__) result.add(gg); 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() { if (currentTogether != null) return CommandExecutionResult.error("Cannot nest together"); @@ -262,69 +274,21 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, return CommandExecutionResult.ok(); } - final public CommandExecutionResult gotoGroup(Ident ident, Code code, Display display, GroupType type, - IGroup parent, NamespaceStrategy strategy) { + final public CommandExecutionResult gotoGroup(Quark ident, Display display, GroupType type) { if (currentTogether != null) return CommandExecutionResult.error("Cannot be done inside 'together'"); - if (this.lastNamespaceStrategy != null && strategy != this.lastNamespaceStrategy) - return CommandExecutionResult.error("Cannot mix packages and namespaces"); - this.lastNamespaceStrategy = strategy; - - 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(); + if (ident.getData() == null) { + final EntityImp result = entityFactory.createGroup(ident, display, type, getHides()); + ident.setData(result); } + final EntityImp ent = (EntityImp) ident.getData(); + ent.setDisplay(display); + ent.muteToType2(type); + + this.stacks.add(ident); + 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; } -// if (currentGroup.getGroupType() == GroupType.TOGETHER) { -// currentGroup = currentGroup.getParentContainer(); -// return true; -// } - - if (stacks2.size() > 0) { - // Thread.dumpStack(); - stacks2.remove(stacks2.size() - 1); + if (stacks.size() > 0) { + stacks.remove(stacks.size() - 1); + return true; } - if (EntityUtils.groupRoot(currentGroup)) { - Log.error("No parent group"); + + return false; + + } + + public final EntityImp getCurrentGroup() { + 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 getGroups(boolean withRootGroup) { + final List result = new ArrayList<>(); + for (Quark quark : getPlasma().quarks()) { + if (quark.isRoot()) { + if (withRootGroup) + result.add((EntityImp) quark.getData()); + } else { + final EntityImp data = (EntityImp) quark.getData(); + if (data != null && data.isGroup()) + result.add(data); + } } - if (stacks.size() > 0) - currentGroup = stacks.remove(stacks.size() - 1); - else - currentGroup = currentGroup.getParentContainer(); - return true; - } - - private void gotoGroupInternal(Ident idNewLong, 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.getLeafStrict(idNewLong) != null) { - result = entityFactory.muteToGroup(code.getName(), namespace, type, parent); - result.setDisplay(display); - } else { - result = entityFactory.createGroup(idNewLong, code, display, namespace, type, parent, getHides(), - getNamespaceSeparator()); - } - 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 getGroups(boolean withRootGroup) { - if (withRootGroup == false) - return entityFactory.groups(); - - final Collection result = new ArrayList<>(); - result.add(getRootGroup()); - result.addAll(entityFactory.groups()); return Collections.unmodifiableCollection(result); } - public IGroup getRootGroup() { - return entityFactory.getRootGroup(); + public EntityImp getRootGroup() { + return (EntityImp) getPlasma().root().getData(); } - public final Collection getLeafsvalues() { - return entityFactory.leafs2(); + public final Collection getLeafsvalues() { + final List 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() { 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) { entityFactory.addLink(link); } @@ -506,6 +400,7 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, return result.toArray(new String[result.size()]); } + // ::comment when WASM private void createFilesGraphml(OutputStream suggestedFile) throws IOException { final CucaDiagramGraphmlMaker maker = new CucaDiagramGraphmlMaker(this); maker.createFiles(suggestedFile); @@ -521,11 +416,18 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, 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 protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) throws IOException { final FileFormat fileFormat = fileFormatOption.getFileFormat(); + // ::comment when WASM if (fileFormat == FileFormat.ATXT || fileFormat == FileFormat.UTXT) { try { createFilesTxt(os, index, fileFormat); @@ -549,18 +451,24 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, createFilesScxml(os); return ImageDataSimple.ok(); } + // ::done if (getUmlDiagramType() == UmlDiagramType.COMPOSITE) { throw new UnsupportedOperationException(); } + this.eventuallyBuildPhantomGroups(); final CucaDiagramFileMaker maker; + // ::comment when WASM if (this.isUseElk()) maker = new CucaDiagramFileMakerElk(this, fileFormatOption.getDefaultStringBounder(getSkinParam())); else if (this.isUseSmetana()) + // ::done maker = new CucaDiagramFileMakerSmetana(this, fileFormatOption.getDefaultStringBounder(getSkinParam())); + // ::comment when WASM else maker = new CucaDiagramFileMakerSvek(this); + // ::done 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; } - private void createFilesTxt(OutputStream os, int index, FileFormat fileFormat) throws IOException { - final CucaDiagramTxtMaker maker = new CucaDiagramTxtMaker(this, fileFormat); - maker.createFiles(os, index); - } - - public boolean isAutarkic(IGroup g) { -// if (g.getGroupType() == GroupType.TOGETHER) -// return false; - + public boolean isAutarkic(EntityImp g) { if (g.getGroupType() == GroupType.PACKAGE) return false; @@ -613,7 +513,7 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, if (EntityUtils.isPureInnerLink3(g, link) == false) return false; - for (ILeaf leaf : g.getLeafsDirect()) + for (EntityImp leaf : g.getLeafsDirect()) if (leaf.getEntityPosition() != EntityPosition.NORMAL) return false; @@ -663,8 +563,8 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, return "25"; } - final public boolean isEmpty(IGroup gToTest) { - for (IEntity gg : getGroups(false)) { + final public boolean isEmpty(EntityImp gToTest) { + for (EntityImp gg : getGroups(false)) { if (gg == gToTest) continue; @@ -683,7 +583,7 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, 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) return false; @@ -735,7 +635,7 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, return Collections.unmodifiableSet(hides); } - final public boolean isStandalone(IEntity ent) { + final public boolean isStandalone(EntityImp ent) { for (final Link link : getLinks()) if (link.getEntity1() == ent || link.getEntity2() == ent) return false; @@ -743,7 +643,7 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, return true; } - final public boolean isStandaloneForArgo(IEntity ent) { + final public boolean isStandaloneForArgo(EntityImp ent) { for (final Link link : getLinks()) { if (link.isHidden() || link.isInvis()) continue; @@ -780,27 +680,24 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, return null; } - private ILeaf lastEntity = null; + protected EntityImp lastEntity = null; - final public ILeaf getLastEntity() { + final public EntityImp getLastEntity() { return lastEntity; } - final public IEntityFactory getIEntityFactory() { - return entityFactory; - } - final public EntityFactory getEntityFactory() { + // throw new UnsupportedOperationException(); return entityFactory; } public void applySingleStrategy() { final MagmaList magmaList = new MagmaList(); - for (IGroup g : getGroups(true)) { - final List standalones = new ArrayList<>(); + for (EntityImp g : getGroups(true)) { + final List standalones = new ArrayList<>(); - for (ILeaf ent : g.getLeafsDirect()) + for (EntityImp ent : g.getLeafsDirect()) if (isStandalone(ent)) standalones.add(ent); @@ -812,7 +709,7 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, magmaList.add(magma); } - for (IGroup g : getGroups(true)) { + for (EntityImp g : getGroups(true)) { final MagmaList magmas = magmaList.getMagmas(g); if (magmas.size() < 3) continue; diff --git a/src/net/sourceforge/plantuml/baraye/EntityFactory.java b/src/net/sourceforge/plantuml/baraye/EntityFactory.java index f9075ba89..c2d78e0a3 100644 --- a/src/net/sourceforge/plantuml/baraye/EntityFactory.java +++ b/src/net/sourceforge/plantuml/baraye/EntityFactory.java @@ -38,11 +38,7 @@ package net.sourceforge.plantuml.baraye; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; -import java.util.Map.Entry; import java.util.Objects; 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.BodierMap; import net.sourceforge.plantuml.cucadiagram.BodyFactory; -import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.GroupRoot; import net.sourceforge.plantuml.cucadiagram.GroupType; 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.Link; -import net.sourceforge.plantuml.cucadiagram.Stereotag; import net.sourceforge.plantuml.cucadiagram.Stereotype; -import net.sourceforge.plantuml.cucadiagram.Together; import net.sourceforge.plantuml.cucadiagram.entity.IEntityFactory; -import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.skin.VisibilityModifier; public final class EntityFactory implements IEntityFactory { - private final Map leafsByCode; - private final Map groupsByCode; - - /* private */public final Map leafs2 = new LinkedHashMap(); - /* private */public final Map groups2 = new LinkedHashMap(); - private final List links = new ArrayList<>(); private int rawLayout; - private final IGroup rootGroup = new GroupRoot(this); + private final Plasma plasma; + + private final EntityImp rootGroup; private final List hides2; private final List removed; - /* private */ final public CucaDiagram namespaceSeparator; - private Map emptyGroupsAsNode = new HashMap(); + /* private */ final public ICucaDiagram namespaceSeparator; - public ILeaf getLeafForEmptyGroup(IGroup g) { - return emptyGroupsAsNode.get(g); + public EntityImp getLeafForEmptyGroup(EntityImp g) { + throw new UnsupportedOperationException(); } - public ILeaf createLeafForEmptyGroup(IGroup g, ISkinParam skinParam) { - final ILeaf folder = this.createLeaf(null, g.getIdent(), g.getCode(), g.getDisplay(), LeafType.EMPTY_PACKAGE, - g.getParentContainer(), null, this.namespaceSeparator.getNamespaceSeparator()); - ((EntityImp) folder).setOriginalGroup(g); - 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 EntityImp createLeafForEmptyGroup(EntityImp g, ISkinParam skinPdaram) { + final EntityImp ent = (EntityImp) g; + ent.muteToType2(LeafType.EMPTY_PACKAGE); + return ent; } - public EntityFactory(List hides2, List removed, CucaDiagram namespaceSeparator) { +// + public EntityImp isIntricated(EntityImp parent) { + throw new UnsupportedOperationException(); + } + + public EntityFactory(List hides2, List removed, ICucaDiagram namespaceSeparator) { this.hides2 = hides2; this.removed = removed; this.namespaceSeparator = namespaceSeparator; - this.leafsByCode = new LinkedHashMap(); - this.groupsByCode = new LinkedHashMap(); + this.plasma = new Plasma("."); + this.rootGroup = new EntityImp(this.plasma.root(), this, null, GroupType.ROOT, 0); + this.plasma.root().setData(rootGroup); } - public boolean isHidden(ILeaf leaf) { - final IEntity other = isNoteWithSingleLinkAttachedTo(leaf); - if (other instanceof ILeaf) - return isHidden((ILeaf) other); + public boolean isHidden(EntityImp leaf) { + final EntityImp other = isNoteWithSingleLinkAttachedTo(leaf); + if (other != null && other != leaf) + return isHidden(other); boolean hidden = false; for (HideOrShow2 hide : hides2) @@ -134,10 +115,10 @@ public final class EntityFactory implements IEntityFactory { return result; } - public boolean isRemoved(ILeaf leaf) { - final IEntity other = isNoteWithSingleLinkAttachedTo(leaf); - if (other instanceof ILeaf) - return isRemoved((ILeaf) other); + public boolean isRemoved(EntityImp leaf) { + final EntityImp other = isNoteWithSingleLinkAttachedTo(leaf); + if (other instanceof EntityImp) + return isRemoved((EntityImp) other); boolean result = false; for (HideOrShow2 hide : removed) @@ -146,11 +127,11 @@ public final class EntityFactory implements IEntityFactory { return result; } - private IEntity isNoteWithSingleLinkAttachedTo(ILeaf note) { + private EntityImp isNoteWithSingleLinkAttachedTo(EntityImp note) { if (note.getLeafType() != LeafType.NOTE) return null; assert note.getLeafType() == LeafType.NOTE; - IEntity other = null; + EntityImp other = null; for (Link link : this.getLinks()) { if (link.getType().isInvisible()) continue; @@ -167,7 +148,7 @@ public final class EntityFactory implements IEntityFactory { } - public boolean isRemovedIgnoreUnlinked(ILeaf leaf) { + public boolean isRemovedIgnoreUnlinked(EntityImp leaf) { boolean result = false; for (HideOrShow2 hide : removed) if (hide.isAboutUnlinked() == false) @@ -176,8 +157,8 @@ public final class EntityFactory implements IEntityFactory { return result; } - public ILeaf createLeaf(Together together, Ident ident, Code code, Display display, LeafType entityType, - IGroup parentContainer, Set hides, String namespaceSeparator) { + final public EntityImp createLeaf(Quark quark, Display display, LeafType entityType, + Set hides) { final Bodier bodier; if (Objects.requireNonNull(entityType) == LeafType.MAP) bodier = new BodierMap(); @@ -186,169 +167,68 @@ public final class EntityFactory implements IEntityFactory { else bodier = BodyFactory.createLeaf(entityType, hides); - final EntityImp result = new EntityImp(ident, code, this, bodier, parentContainer, entityType, - namespaceSeparator, rawLayout); + final EntityImp result = new EntityImp(quark, this, bodier, entityType, rawLayout); bodier.setLeaf(result); result.setDisplay(display); - result.setTogether(together); return result; } - public IGroup createGroup(Ident ident, Code code, Display display, Code namespace, GroupType groupType, - IGroup parentContainer, Set hides, String namespaceSeparator) { + public EntityImp createGroup(Quark quark, Display display, GroupType groupType, Set hides) { Objects.requireNonNull(groupType); - for (Entry ent : groups2.entrySet()) - if (ent.getKey().equals(ident)) - return ent.getValue(); + if (quark.getData() != null) + return (EntityImp) quark.getData(); +// for (Entry ent : groups2.entrySet()) +// if (ent.getKey().equals(ident)) +// return ent.getValue(); final Bodier bodier = BodyFactory.createGroup(hides); - final EntityImp result = new EntityImp(ident, code, this, bodier, parentContainer, groupType, namespace, - namespaceSeparator, rawLayout); + final EntityImp result = new EntityImp(quark, this, bodier, groupType, rawLayout); if (Display.isNull(display) == false) result.setDisplay(display); return result; } - public void addLeaf(ILeaf entity) { - 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() { + public EntityImp getRootGroup() { return rootGroup; } - public final ILeaf getLeafStrict(Ident ident) { - return leafs2.get(ident); - } - - public Ident buildFullyQualified(Ident currentPath, Ident id) { - if (currentPath.equals(id) == false) - if (leafs2.containsKey(id) || groups2.containsKey(id)) - return id; - - if (id.size() > 1) - return id; - - return currentPath.add(id); - } - - public final IGroup getGroupStrict(Ident ident) { - if (namespaceSeparator.getNamespaceSeparator() == null) - return getGroupVerySmart(ident); - - final IGroup result = groups2.get(ident); - return result; - } - - public final IGroup getGroupVerySmart(Ident ident) { - final IGroup result = groups2.get(ident); + public final EntityImp getLeafStrict(Quark ident) { + if (ident instanceof Quark == false) + throw new UnsupportedOperationException(); + final Quark quark = (Quark) ident; + final EntityImp result = (EntityImp) quark.getData(); if (result == null) - for (Entry ent : groups2.entrySet()) - if (ent.getKey().getLast().equals(ident.getLast())) - return ent.getValue(); - + throw new UnsupportedOperationException(); return result; } - public final ILeaf getLeaf(Code code) { - final ILeaf result = leafsByCode.get(code.getName()); - if (result != null && result != leafs2.get(result.getIdent())) - bigError(); + public final Collection leafs() { - for (ILeaf tmp : leafsByCode.values()) - if (tmp.getIdent().equals(code)) - return tmp; - - return result; - } - - 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 leafs() { - final Collection result = Collections.unmodifiableCollection(leafsByCode.values()); - if (new ArrayList<>(result).equals(new ArrayList<>(leafs2())) == false) - bigError(); - - return result; - } - - public final Collection groups() { - final Collection result = Collections.unmodifiableCollection(groupsByCode.values()); - if (new ArrayList<>(result).equals(new ArrayList<>(groups2())) == false) - bigError(); - - return result; - } - - public final Collection groups2() { - final Collection result = Collections.unmodifiableCollection(groups2.values()); + final List 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 Collection leafs2() { - final Collection result = Collections.unmodifiableCollection(leafs2.values()); + public final Collection groups() { + final List 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); + } public void incRawLayout() { @@ -381,12 +261,11 @@ public final class EntityFactory implements IEntityFactory { } - public IGroup getParentContainer(Ident ident, IGroup parentContainer) { - return Objects.requireNonNull(parentContainer); - } - - public CucaDiagram getDiagram() { + public ICucaDiagram getDiagram() { return namespaceSeparator; } + public Plasma getPlasma() { + return plasma; + } } diff --git a/src/net/sourceforge/plantuml/baraye/EntityImp.java b/src/net/sourceforge/plantuml/baraye/EntityImp.java index cbe47fca5..aa8e804c0 100644 --- a/src/net/sourceforge/plantuml/baraye/EntityImp.java +++ b/src/net/sourceforge/plantuml/baraye/EntityImp.java @@ -50,19 +50,21 @@ import java.util.Set; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.Guillemet; +import net.sourceforge.plantuml.Hideable; 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.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.DisplayPositioned; import net.sourceforge.plantuml.cucadiagram.EntityPosition; -import net.sourceforge.plantuml.cucadiagram.GroupRoot; 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.Link; 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.LineLocation; -final public class EntityImp implements ILeaf, IGroup { +final public class EntityImp implements SpecificBackcolorable, Hideable, Removeable, LineConfigurable { private final EntityFactory entityFactory; - // Entity - private/* final */Code code; - private/* final */Ident ident; + private Quark quark; private Url url; @@ -110,10 +110,6 @@ final public class EntityImp implements ILeaf, IGroup { private Stereotype stereotype; private Stereostyles stereostyles = Stereostyles.NONE; private String generic; - private IGroup parentContainer; - - // Group - private Code namespace; private GroupType groupType; @@ -134,7 +130,7 @@ final public class EntityImp implements ILeaf, IGroup { private Together together; - @Override + // public void addNote(Display note, Position position, Colors colors) { if (position == Position.TOP) 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)); } - @Override + // public List getNotes(Position position) { if (position == Position.TOP) return Collections.unmodifiableList(notesTop); @@ -160,47 +156,45 @@ final public class EntityImp implements ILeaf, IGroup { } // Back to Entity - private EntityImp(Ident ident, EntityFactory entityFactory, Code code, Bodier bodier, IGroup parentContainer, - String namespaceSeparator, int rawLayout) { - this.ident = Objects.requireNonNull(ident); - this.uid = StringUtils.getUid("cl", entityFactory.getDiagram().getUniqueSequence()); - this.code = Objects.requireNonNull(code); + private EntityImp(Quark quark, EntityFactory entityFactory, Bodier bodier, int rawLayout) { + this.quark = Objects.requireNonNull(quark); + if (quark.isRoot()) + this.uid = "clroot"; + else + this.uid = StringUtils.getUid("cl", entityFactory.getDiagram().getUniqueSequence()); this.entityFactory = entityFactory; this.bodier = bodier; - this.parentContainer = parentContainer; this.rawLayout = rawLayout; } - public EntityImp(Ident ident, Code code, EntityFactory entityFactory, Bodier bodier, IGroup parentContainer, - LeafType leafType, String namespaceSeparator, int rawLayout) { - this(Objects.requireNonNull(ident), entityFactory, code, bodier, parentContainer, namespaceSeparator, - rawLayout); - // System.err.println("ID for leaf=" + code + " " + ident); - // ident.checkSameAs(code, namespaceSeparator); + EntityImp(Quark quark, EntityFactory entityFactory, Bodier bodier, LeafType leafType, int rawLayout) { + this(Objects.requireNonNull(quark), entityFactory, bodier, rawLayout); this.leafType = leafType; } - public EntityImp(Ident ident, Code code, EntityFactory entityFactory, Bodier bodier, IGroup parentContainer, - GroupType groupType, Code namespace, String namespaceSeparator, int 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); + EntityImp(Quark quark, EntityFactory entityFactory, Bodier bodier, GroupType groupType, int rawLayout) { + this(Objects.requireNonNull(quark), entityFactory, bodier, rawLayout); this.groupType = groupType; - this.namespace = namespace; - } - - public void setContainer(IGroup container) { - checkNotGroup(); - this.parentContainer = Objects.requireNonNull(container); } public LeafType getLeafType() { 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) { - checkNotGroup(); + // checkNotGroup(); Objects.requireNonNull(newType); if (leafType != LeafType.STILL_UNKNOWN) { if (newType == this.leafType) @@ -225,16 +219,16 @@ final public class EntityImp implements ILeaf, IGroup { return true; } - public Code getCode() { - return code; + public Quark getQuark() { + return quark; + } + + public String getCode() { + return getQuark().getName(); } public String getCodeGetName() { - return getCode().getName(); - } - - public Ident getIdent() { - return ident; + return getQuark().getName(); } public Display getDisplay() { @@ -257,18 +251,8 @@ final public class EntityImp implements ILeaf, IGroup { this.stereotype = stereotype; } - public final IGroup getParentContainer() { - return entityFactory.getParentContainer(ident, parentContainer); - // Objects.requireNonNull(parentContainer); - // return parentContainer; - } - - @Override public String toString() { - // return super.toString() + code + " " + display + "(" + leafType + ")[" + - // groupType + "] " + xposition + " " - // + getUid(); - return "EntityImpl " + code + ident + " " + display + "(" + leafType + ")[" + groupType + "] " + getUid(); + return quark.toString() + " " + display + "(" + leafType + ")[" + groupType + "] " + getUid(); } public final Url getUrl99() { @@ -346,7 +330,7 @@ final public class EntityImp implements ILeaf, IGroup { if (leafType != LeafType.STATE) return EntityPosition.NORMAL; - if (getParentContainer() instanceof GroupRoot) + if (quark.isRoot()) return EntityPosition.NORMAL; 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 getLeafsDirect() { - checkGroup(); - final List 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 getChildren() { - checkGroup(); - final Collection 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() { checkGroup(); return groupType; } - public Code getNamespace() { - checkGroup(); - return namespace; - } - public PackageStyle getPackageStyle() { checkGroup(); if (stereotype == null) @@ -543,26 +393,34 @@ final public class EntityImp implements ILeaf, IGroup { if (EntityUtils.isPureInnerLink12(this, link)) entityFactory.removeLink(link); - entityFactory.removeGroup(getCodeGetName()); - for (ILeaf ent : new ArrayList<>(entityFactory.leafs())) - if (this != ent && this == ent.getParentContainer()) - entityFactory.removeLeaf(ent.getCodeGetName()); - - entityFactory.addLeaf(this); +// if (entityFactory.namespaceSeparator.V1972()) { +// entityFactory.removeGroup(getIdent()); +// for (ILeaf ent : new ArrayList<>(entityFactory.leafs())) +// if (this != ent && getIdent().equals(ent.getIdent().parent())) +// entityFactory.removeLeaf(ent.getIdent()); +// +// } 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.leafType = leafType; } - public /* private */ void muteToGroup(Code namespaceNew, GroupType groupType, IGroup parentContainer) { - checkNotGroup(); - if (parentContainer.isGroup() == false) - throw new IllegalArgumentException(); - - this.namespace = namespaceNew; - this.groupType = groupType; - this.leafType = null; - this.parentContainer = parentContainer; - } +// void muteToGroup(Code namespaceNew, GroupType groupType, IGroup parentContainer) { +// checkNotGroup(); +// if (parentContainer.isGroup() == false) +// throw new IllegalArgumentException(); +// +// this.namespace = namespaceNew; +// this.groupType = groupType; +// this.leafType = null; +// this.parentContainer = parentContainer; +// } public USymbol getUSymbol() { if (getLeafType() == LeafType.CIRCLE) @@ -583,13 +441,15 @@ final public class EntityImp implements ILeaf, IGroup { } public boolean isHidden() { - if (parentContainer != null && parentContainer.isHidden()) + if (getParentContainer() != null && getParentContainer().isHidden()) return true; return isHiddenInternal(); } private boolean isHiddenInternal() { + if (quark.isRoot()) + return false; if (isGroup()) { if (entityFactory.isHidden(this)) return true; @@ -597,12 +457,12 @@ final public class EntityImp implements ILeaf, IGroup { if (getLeafsDirect().size() == 0) return false; - for (ILeaf leaf : getLeafsDirect()) - if (((EntityImp) leaf).isHiddenInternal() == false) + for (EntityImp leaf : getLeafsDirect()) + if (leaf.isHiddenInternal() == false) return false; - for (IGroup g : getChildren()) - if (((EntityImp) g).isHiddenInternal() == false) + for (EntityImp g : getChildren()) + if (g.isHiddenInternal() == false) return false; return true; @@ -611,7 +471,7 @@ final public class EntityImp implements ILeaf, IGroup { } public boolean isRemoved() { - if (parentContainer != null && parentContainer.isRemoved()) + if (getParentContainer() != null && getParentContainer().isRemoved()) return true; return isRemovedInternal(); @@ -625,11 +485,11 @@ final public class EntityImp implements ILeaf, IGroup { if (getLeafsDirect().size() == 0 && getChildren().size() == 0) return false; - for (ILeaf leaf : getLeafsDirect()) + for (EntityImp leaf : getLeafsDirect()) if (((EntityImp) leaf).isRemovedInternal() == false) return false; - for (IGroup g : getChildren()) + for (EntityImp g : getChildren()) if (((EntityImp) g).isRemovedInternal() == false) return false; @@ -644,7 +504,7 @@ final public class EntityImp implements ILeaf, IGroup { for (Link link : entityFactory.getLinks()) if (link.contains(this)) { - final ILeaf other = (ILeaf) link.getOther(this); + final EntityImp other = (EntityImp) link.getOther(this); final boolean removed = entityFactory.isRemovedIgnoreUnlinked(other); if (removed == false && link.getType().isInvisible() == false) return false; @@ -743,17 +603,6 @@ final public class EntityImp implements ILeaf, IGroup { 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() { if (this.codeLine == null) return null; @@ -765,12 +614,12 @@ final public class EntityImp implements ILeaf, IGroup { this.codeLine = codeLine; } - @Override + // public void setStereostyle(String stereo) { this.stereostyles = Stereostyles.build(stereo); } - @Override + // public Stereostyles getStereostyles() { return stereostyles; } @@ -794,18 +643,18 @@ final public class EntityImp implements ILeaf, IGroup { return Collections.unmodifiableList(result); } - public CucaDiagram getDiagram() { + public ICucaDiagram getDiagram() { return entityFactory.getDiagram(); } private boolean isStatic; - @Override + // public void setStatic(boolean isStatic) { this.isStatic = isStatic; } - @Override + // public boolean isStatic() { return isStatic; } @@ -835,14 +684,46 @@ final public class EntityImp implements ILeaf, IGroup { } - @Override public Together getTogether() { return together; } - @Override public void setTogether(Together together) { this.together = together; } + public EntityImp getParentContainer() { + if (quark.isRoot()) + return null; + return (EntityImp) quark.getParent().getData(); + } + + public Collection getLeafsDirect() { + final List 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 getChildren() { + final List 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(); + } + } diff --git a/src/net/sourceforge/plantuml/baraye/EntityUtils.java b/src/net/sourceforge/plantuml/baraye/EntityUtils.java index 078e87b1e..da28abfdc 100644 --- a/src/net/sourceforge/plantuml/baraye/EntityUtils.java +++ b/src/net/sourceforge/plantuml/baraye/EntityUtils.java @@ -35,19 +35,11 @@ */ package net.sourceforge.plantuml.baraye; -import net.sourceforge.plantuml.cucadiagram.GroupRoot; import net.sourceforge.plantuml.cucadiagram.Link; public abstract class EntityUtils { - public static boolean groupRoot(IGroup g) { - if (g == null) - throw new IllegalStateException(); - - return g instanceof GroupRoot; - } - - private static boolean isParent(IGroup groupToBeTested, IGroup parentGroup) { + private static boolean isParent(EntityImp groupToBeTested, EntityImp parentGroup) { if (groupToBeTested.isGroup() == false) // Very strange! return false; @@ -55,40 +47,72 @@ public abstract class EntityUtils { if (groupToBeTested.isGroup() == false) throw new IllegalArgumentException(); - while (EntityUtils.groupRoot(groupToBeTested) == false) { + while (groupToBeTested.getQuark().isRoot() == false) { if (groupToBeTested == parentGroup) return true; groupToBeTested = groupToBeTested.getParentContainer(); if (groupToBeTested.isGroup() == false) - throw new IllegalStateException(); + return false; + // throw new IllegalStateException(); } return false; } - public static boolean isPureInnerLink12(IGroup group, Link link) { + public static boolean isPureInnerLink12(EntityImp group, Link link) { if (group.isGroup() == false) throw new IllegalArgumentException(); - final IEntity e1 = link.getEntity1(); - final IEntity e2 = link.getEntity2(); - final IGroup group1 = e1.getParentContainer(); - final IGroup group2 = e2.getParentContainer(); + 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(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) throw new IllegalArgumentException(); - final IEntity e1 = link.getEntity1(); - final IEntity e2 = link.getEntity2(); - final IGroup group1 = e1.getParentContainer(); - final IGroup group2 = e2.getParentContainer(); + final EntityImp e1 = link.getEntity1(); + final EntityImp e2 = link.getEntity2(); + final EntityImp group1 = e1.getParentContainer(); + final EntityImp group2 = e2.getParentContainer(); if (isParent(group2, group) == isParent(group1, group)) return true; diff --git a/src/net/sourceforge/plantuml/baraye/IEntity.java b/src/net/sourceforge/plantuml/baraye/IEntity.java deleted file mode 100644 index 2751ce300..000000000 --- a/src/net/sourceforge/plantuml/baraye/IEntity.java +++ /dev/null @@ -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 getTips(); - - public void addStereotag(Stereotag tag); - - public Set 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 getNotes(Position position); - -} diff --git a/src/net/sourceforge/plantuml/baraye/IGroup.java b/src/net/sourceforge/plantuml/baraye/IGroup.java deleted file mode 100644 index 55b350597..000000000 --- a/src/net/sourceforge/plantuml/baraye/IGroup.java +++ /dev/null @@ -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 getLeafsDirect(); - - public Collection 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(); - -} diff --git a/src/net/sourceforge/plantuml/baraye/ILeaf.java b/src/net/sourceforge/plantuml/baraye/ILeaf.java deleted file mode 100644 index 20cd97db8..000000000 --- a/src/net/sourceforge/plantuml/baraye/ILeaf.java +++ /dev/null @@ -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 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); - -} diff --git a/src/net/sourceforge/plantuml/baraye/Plasma.java b/src/net/sourceforge/plantuml/baraye/Plasma.java index ad84da55a..30345714c 100644 --- a/src/net/sourceforge/plantuml/baraye/Plasma.java +++ b/src/net/sourceforge/plantuml/baraye/Plasma.java @@ -38,20 +38,18 @@ package net.sourceforge.plantuml.baraye; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; public class Plasma { private String separator; private final Quark root; - private final Map, Quark> quarks = new LinkedHashMap<>(); + private final List quarks = new ArrayList<>(); public Plasma(String separator) { - final List empty = Collections.emptyList(); - this.root = ensurePresent(empty); + this.root = new Quark(this, null, ""); this.separator = separator; + this.quarks.add(root); } public Quark root() { @@ -68,6 +66,10 @@ public class Plasma { this.separator = separator; } + public final boolean hasSeparator() { + return this.separator != null && this.separator != "\u0000"; + } + public Quark parse(Quark root, String full) { final List result = root.getSignature(); @@ -87,53 +89,63 @@ public class Plasma { } Quark ensurePresent(List result) { - Quark quark = quarks.get(result); + Quark quark = getIfExists(result); if (quark == null) { - if (result.size() == 0) - quark = new Quark(this, null, result); - else { + if (result.size() == 0) { + // quark = new Quark(this, null, result); + throw new UnsupportedOperationException(); + } else { 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); - quarks.put(result, quark); + // System.err.println("PUTTING " + quark); + quarks.add(quark); } return quark; } public Collection 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) { - 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)) - return quark; - return null; + count++; + return count; } public Quark getIfExistsFromFullPath(String full) { - for (Quark quark : quarks.values()) + for (Quark quark : quarks) if (quark.toString(separator).equals(full)) return quark; return null; } public Quark getIfExists(List signature) { - return quarks.get(signature); + for (Quark quark : quarks) + if (quark.getSignature().equals(signature)) + return quark; + return null; } public int countChildren(Quark parent) { int count = 0; - for (Quark quark : new ArrayList<>(quarks.values())) + for (Quark quark : quarks) if (quark.getParent() == parent) count++; return count; @@ -141,21 +153,19 @@ public class Plasma { public List getChildren(Quark parent) { final List result = new ArrayList<>(); - for (Quark quark : new ArrayList<>(quarks.values())) + for (Quark quark : quarks) if (quark.getParent() == parent) result.add(quark); return Collections.unmodifiableList(result); } - public void moveAllTo(Quark src, Quark dest) { - for (Quark quark : new ArrayList<>(quarks.values())) { - if (quark == dest) + public void moveAllChildOfToAnewFather(Quark oldFather, Quark newFather) { + for (Quark quark : quarks) { + if (quark == newFather) continue; - if (src.containsLarge(quark)) { - quarks.remove(quark.getSignature()); - quark.internalMove(src, dest); - quarks.put(quark.getSignature(), quark); - } + + if (quark.getParent() == oldFather) + quark.setParent(newFather); } } diff --git a/src/net/sourceforge/plantuml/baraye/Quark.java b/src/net/sourceforge/plantuml/baraye/Quark.java index a10b398b7..204dd258d 100644 --- a/src/net/sourceforge/plantuml/baraye/Quark.java +++ b/src/net/sourceforge/plantuml/baraye/Quark.java @@ -38,50 +38,46 @@ package net.sourceforge.plantuml.baraye; import java.util.ArrayList; import java.util.List; -import net.sourceforge.plantuml.cucadiagram.Code; -import net.sourceforge.plantuml.cucadiagram.Ident; - -public class Quark extends Ident implements Code { +public class Quark { private final Plasma plasma; private /* final */ Quark parent; - // private final List parts; + private final String name; private Object data; - Quark(Plasma plasma, Quark parent, List parts) { - super(new ArrayList(parts)); + Quark(Plasma plasma, Quark parent, String name) { + this.name = name; this.plasma = plasma; 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(parts); } public Quark getParent() { return parent; -// if (parts.size() == 0) -// return null; -// return plasma.ensurePresent(parts.subList(0, parts.size() - 1)); } @Override public String toString() { // return parts.toString() + "(parent=" + parent + ")"; - return parts.toString(); + return getSignature().toString(); } public List getSignature() { - return new ArrayList<>(parts); + final List result = new ArrayList<>(); + if (parent != null) + result.addAll(parent.getSignature()); + result.add(name); + return result; + } + + public List parts() { + return getSignature(); } public boolean containsLarge(Quark other) { - return other.parts.size() > this.parts.size() && other.parts.subList(0, this.parts.size()).equals(this.parts); + final List signature = this.parts(); + final List otherSignature = other.parts(); + return otherSignature.size() > signature.size() + && otherSignature.subList(0, signature.size()).equals(signature); } // @Override @@ -97,23 +93,12 @@ public class Quark extends Ident implements Code { // 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) { if (sep == null) sep = "."; final StringBuilder sb = new StringBuilder(); - for (String s : parts) { + for (String s : parts()) { if (sb.length() > 0) sb.append(sep); @@ -123,24 +108,21 @@ public class Quark extends Ident implements Code { } public String getName() { - if (parts.size() == 0) - return ""; + return name; + } - return parts.get(parts.size() - 1); + public String getQualifiedName() { + if (plasma.hasSeparator()) + return toString(plasma.getSeparator()); + return name; } 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() { return plasma; } @@ -153,26 +135,14 @@ public class Quark extends Ident implements Code { this.data = data; } - @Override - public Ident eventuallyRemoveStartingAndEndingDoubleQuote(String format) { - return this; - // throw new UnsupportedOperationException(); - } - public Quark childIfExists(String name) { final List sig = new ArrayList<>(getSignature()); sig.add(name); return plasma.getIfExists(sig); } - public Quark parse(Quark path) { - final List sig = new ArrayList<>(getSignature()); - sig.addAll(path.getSignature()); - return plasma.ensurePresent(sig); - } - - public Quark child(String name) { - return plasma.parse(this, name); + public Quark child(String full) { + return plasma.parse(this, full); } public int countChildren() { @@ -183,20 +153,28 @@ public class Quark extends Ident implements Code { return plasma.getChildren(this); } - public void moveTo(Quark dest) { - plasma.moveAllTo(this, dest); + public String forXmi() { + 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) { - System.err.print("Intermal move from " + this + " to "); - if (src.getDepth() + 1 != dest.getDepth()) - throw new UnsupportedOperationException("to be finished"); - final List previous = this.getSignature(); - parts.clear(); - parts.addAll(dest.getSignature()); - parts.addAll(previous.subList(src.getDepth(), previous.size())); - this.parent = plasma.ensurePresent(parts.subList(0, parts.size() - 1)); - System.err.println(toString()); + public String getPortMember() { + final String last = getName(); + final int x = last.lastIndexOf("::"); + if (x == -1) { + return null; + } + return last.substring(x + 2); + } + + void setParent(Quark newFather) { + this.parent = newFather; } } diff --git a/src/net/sourceforge/plantuml/braille/BrailleChar.java b/src/net/sourceforge/plantuml/braille/BrailleChar.java index acc320957..2485c873a 100644 --- a/src/net/sourceforge/plantuml/braille/BrailleChar.java +++ b/src/net/sourceforge/plantuml/braille/BrailleChar.java @@ -36,6 +36,7 @@ package net.sourceforge.plantuml.braille; public class BrailleChar { + // ::remove folder when WASM private final int id; diff --git a/src/net/sourceforge/plantuml/brotli/BitReader.java b/src/net/sourceforge/plantuml/brotli/BitReader.java index 35d4ba1f6..19780129a 100644 --- a/src/net/sourceforge/plantuml/brotli/BitReader.java +++ b/src/net/sourceforge/plantuml/brotli/BitReader.java @@ -12,6 +12,7 @@ package net.sourceforge.plantuml.brotli; * Bit reading helpers. */ final class BitReader { + // ::remove folder when WASM // Added by Arnaud... not very beautifull private static final boolean CHECK_UNUSED_BYTES_AFTER_END = false; diff --git a/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java b/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java index 59a992d9d..66c17e01d 100644 --- a/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java +++ b/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java @@ -38,24 +38,14 @@ package net.sourceforge.plantuml.classdiagram; import java.io.IOException; import java.io.OutputStream; import java.util.Map; -import java.util.Objects; import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.UmlDiagramType; -import net.sourceforge.plantuml.baraye.EntityUtils; -import net.sourceforge.plantuml.baraye.IGroup; -import net.sourceforge.plantuml.baraye.ILeaf; +import net.sourceforge.plantuml.baraye.EntityImp; import net.sourceforge.plantuml.core.ImageData; 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.graphic.TextBlock; -import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram; import net.sourceforge.plantuml.svek.image.EntityImageClass; @@ -65,91 +55,49 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram { super(source, UmlDiagramType.CLASS, skinParam); } - private Code getShortName1972(Code code) { - final String separator = Objects.requireNonNull(getNamespaceSeparator()); - final String codeString = code.getName(); - final String namespace = getNamespace1972(code, getNamespaceSeparator()); - if (namespace == null) - return buildCode(codeString); +// @Override +// protected ILeaf getOrCreateLeaf2(Quark ident, Quark code, LeafType type, USymbol symbol) { +// Objects.requireNonNull(ident); +// if (type == null) { +// code = code.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:"); +// 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 getOrCreateLeaf(Ident ident, Code code, LeafType type, USymbol symbol) { - Objects.requireNonNull(ident); - if (type == null) { - code = code.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:"); - if (getNamespaceSeparator() == null) - return getOrCreateLeafDefault(ident, code, LeafType.CLASS, symbol); - - code = getFullyQualifiedCode1972(code); - if (super.leafExist(code)) - return getOrCreateLeafDefault(ident, code, LeafType.CLASS, symbol); - - 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)); - } +// @Override +// public ILeaf createLeaf(Quark idNewLong, String displayString, 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, displayString, display, type, symbol); +// +// if (getNamespaceSeparator() == null) +// return super.createLeaf(idNewLong, displayString, display, type, symbol); +// +// final ILeaf result = createLeafInternal(idNewLong, display, type, symbol); +// this.lastEntity = (EntityImp) result; +// return result; +// } private boolean allowMixing; @@ -191,14 +139,14 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram { private RowLayout getRawLayout(int raw) { final RowLayout rawLayout = new RowLayout(); - for (ILeaf leaf : entityFactory.leafs()) + for (EntityImp leaf : entityFactory.leafs()) if (leaf.getRawLayout() == raw) rawLayout.addLeaf(getEntityImageClass(leaf)); return rawLayout; } - private TextBlock getEntityImageClass(ILeaf entity) { + private TextBlock getEntityImageClass(EntityImp entity) { return new EntityImageClass(entity, getSkinParam(), this); } diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandAddMethod.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandAddMethod.java index a869f884e..bba96c61d 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandAddMethod.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandAddMethod.java @@ -35,7 +35,8 @@ */ 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.command.CommandExecutionResult; 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.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; -import net.sourceforge.plantuml.cucadiagram.Code; -import net.sourceforge.plantuml.cucadiagram.Ident; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.skin.VisibilityModifier; import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; import net.sourceforge.plantuml.utils.LineLocation; @@ -69,9 +70,13 @@ public class CommandAddMethod extends SingleLineCommand2 { protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final String idShort = arg.get("NAME", 0); - final Ident ident = diagram.buildLeafIdent(idShort); - final Code code = diagram.buildCode(idShort); - final IEntity entity = diagram.getOrCreateLeaf(ident, code, null, null); + final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(idShort), false); + EntityImp entity = (EntityImp) quark.getData(); + 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); if (field.length() > 0 && VisibilityModifier.isVisibilityCharacter(field)) diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java index 9f02478b6..cf2ec2a28 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java @@ -40,9 +40,7 @@ import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; -import net.sourceforge.plantuml.baraye.CucaDiagram; import net.sourceforge.plantuml.baraye.EntityImp; -import net.sourceforge.plantuml.baraye.ILeaf; import net.sourceforge.plantuml.baraye.Quark; import net.sourceforge.plantuml.classdiagram.ClassDiagram; 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.RegexOr; 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.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Stereotag; import net.sourceforge.plantuml.cucadiagram.Stereotype; @@ -135,48 +132,65 @@ public class CommandCreateClass extends SingleLineCommand2 { throws NoSuchColorException { final String typeString = StringUtils.goUpperCase(arg.get("TYPE", 0)); final LeafType type = LeafType.getLeafType(typeString); - final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.getLazzy("CODE", 0), - "\"([:"); - final String display = arg.getLazzy("DISPLAY", 0); + final String idShort = diagram.cleanIdForQuark(arg.getLazzy("CODE", 0)); + final String displayString = arg.getLazzy("DISPLAY", 0); final String genericOption = arg.getLazzy("DISPLAY", 1); final String generic = genericOption != null ? genericOption : arg.get("GENERIC", 0); final String stereo = arg.get("STEREO", 0); - /* final */ ILeaf entity; - if (CucaDiagram.QUARK) { - final Quark current = diagram.currentQuark(); - final Quark idNewLong = (Quark) diagram.buildLeafIdent(idShort); - if (idNewLong.getData() == null) - entity = diagram.createLeaf(idNewLong, idNewLong, Display.getWithNewlines(display), type, null); - else - entity = (ILeaf) idNewLong.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) { - final Display withNewlines = Display.getWithNewlines(display); - entity = diagram.createLeaf(idNewLong, idNewLong, withNewlines, type, null); - } + 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 { - 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) - return CommandExecutionResult.error("Bad name"); + if (entity.muteToType(type, null) == false) + 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) { entity.setStereotype(Stereotype.build(stereo, diagram.getSkinParam().getCircledCharacterRadius(), diagram.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER), diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java index 62424f75d..859872ed9 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java @@ -40,10 +40,7 @@ import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; 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.ILeaf; import net.sourceforge.plantuml.baraye.Quark; import net.sourceforge.plantuml.classdiagram.ClassDiagram; 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.RegexOr; 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.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.LinkArg; @@ -156,9 +152,71 @@ public class CommandCreateClassMultilines extends CommandMultilines2 1) { entity.setCodeLine(lines.getAt(0).getLocation()); @@ -192,7 +250,7 @@ public class CommandCreateClassMultilines extends CommandMultilines2 } final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeRaw); - final Ident ident = diagram.buildLeafIdent(idShort); - final Code code = diagram.buildCode(idShort); - String display = displayRaw; - if (display == null) - display = code.getName(); + final Display display = Display.getWithNewlines(displayRaw == null ? idShort : displayRaw); + final Quark quark = diagram.quarkInContext(idShort, false); + EntityImp entity = (EntityImp) quark.getData(); + if (entity == null) + 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 IEntity entity = diagram.getOrCreateLeaf(ident, code, type, usymbol); - entity.setDisplay(Display.getWithNewlines(display)); +// final IEntity entity = diagram.getOrCreateLeaf(ident, code, type, usymbol); + entity.setDisplay(display); entity.setUSymbol(usymbol); if (stereotype != null) entity.setStereotype(Stereotype.build(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandDiamondAssociation.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandDiamondAssociation.java index 38048e193..a0e59a721 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandDiamondAssociation.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandDiamondAssociation.java @@ -35,6 +35,7 @@ */ package net.sourceforge.plantuml.classdiagram.command; +import net.sourceforge.plantuml.baraye.Quark; import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.command.CommandExecutionResult; 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.RegexLeaf; 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.utils.LineLocation; @@ -65,13 +64,14 @@ public class CommandDiamondAssociation extends SingleLineCommand2 @Override protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) { final String idShort = arg.get("CODE", 0); - final Ident ident = diagram.buildLeafIdent(idShort); - final Code code = diagram.buildCode(idShort); - final boolean leafExist = diagram.leafExist(code); - if (leafExist) - return CommandExecutionResult.error("Already existing : " + code.getName()); + final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(idShort), false); +// final Quark ident = diagram.buildFromName(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(idShort)); +// final Quark code = diagram.buildFromFullPath(idShort); +// final boolean leafExist = diagram.leafExist(code); + 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(); } diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByGender.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByGender.java index 1cbbd988b..276e16062 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByGender.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByGender.java @@ -37,8 +37,9 @@ package net.sourceforge.plantuml.classdiagram.command; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.UmlDiagram; +import net.sourceforge.plantuml.baraye.EntityImp; 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.SingleLineCommand2; 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.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexResult; -import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.EntityGender; import net.sourceforge.plantuml.cucadiagram.EntityGenderUtils; import net.sourceforge.plantuml.cucadiagram.EntityPortion; -import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.descdiagram.DescriptionDiagram; import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram; @@ -146,8 +145,12 @@ public class CommandHideShowByGender extends SingleLineCommand2 { } else if (arg1.startsWith("<<")) { gender = EntityGenderUtils.byStereotype(arg1); } else { - final IEntity entity = diagram.getOrCreateLeaf(diagram.buildLeafIdent(arg1), diagram.buildCode(arg1), null, - null); + final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(arg1), false); + 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); } @@ -189,9 +192,15 @@ public class CommandHideShowByGender extends SingleLineCommand2 { gender = EntityGenderUtils.byStereotype(arg1); } else { arg1 = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg1); - final Ident ident = diagram.buildLeafIdent(arg1); - final Code code = diagram.buildCode(arg1); - final IEntity entity = diagram.getOrCreateLeaf(ident, code, null, null); + final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(arg1), false); + EntityImp entity = (EntityImp) quark.getData(); + 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); } if (gender != null) { @@ -200,7 +209,7 @@ public class CommandHideShowByGender extends SingleLineCommand2 { if (empty == true && emptyMembers == false) { 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())); } diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java index ae67c8689..7858d26f3 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java @@ -41,7 +41,8 @@ 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.baraye.EntityImp; +import net.sourceforge.plantuml.baraye.Quark; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; 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.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.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.LinkArg; import net.sourceforge.plantuml.cucadiagram.LinkDecor; @@ -157,8 +157,8 @@ final public class CommandLinkClass extends SingleLineCommand2 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) .withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle())); link.setColors(color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet())); @@ -321,22 +299,63 @@ final public class CommandLinkClass extends SingleLineCommand2 { - - 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; - } - -} diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkLollipop.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkLollipop.java index fc175bec0..f94687114 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkLollipop.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkLollipop.java @@ -37,7 +37,8 @@ package net.sourceforge.plantuml.classdiagram.command; import net.sourceforge.plantuml.StringUtils; 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.SingleLineCommand2; 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.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.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.LinkArg; @@ -119,27 +118,40 @@ final public class CommandLinkLollipop extends SingleLineCommand2 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) .withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle())); diagram.resetPragmaLabel(); @@ -198,10 +210,6 @@ final public class CommandLinkLollipop extends SingleLineCommand2 { protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final String name = arg.get("NAME", 0); - final Ident ident = diagram.buildLeafIdent(name); - final Code code = diagram.buildCode(name); 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(), diagram.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER), diagram.getSkinParam().getIHtmlColorSet())); diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandUrl.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandUrl.java index 2965c2525..46b307b22 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandUrl.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandUrl.java @@ -38,7 +38,8 @@ package net.sourceforge.plantuml.classdiagram.command; 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.baraye.EntityImp; +import net.sourceforge.plantuml.baraye.Quark; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.command.CommandExecutionResult; 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.RegexOptional; 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; public class CommandUrl extends SingleLineCommand2 { @@ -75,17 +74,22 @@ public class CommandUrl extends SingleLineCommand2 { @Override protected CommandExecutionResult executeArg(AbstractEntityDiagram diagram, LineLocation location, RegexResult arg) { final String idShort = arg.get("CODE", 0); - final Ident ident = diagram.buildLeafIdent(idShort); - final Code code = diagram.buildCode(idShort); +// final Quark ident = diagram.buildFromName(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(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 IEntity entity; - final boolean leafExist = diagram.leafExist(code); - if (leafExist) - entity = diagram.getOrCreateLeaf(ident, code, null, null); - else if (diagram.isGroup(code)) - entity = diagram.getGroup(code); - else - return CommandExecutionResult.error(code + " does not exist"); +// final boolean leafExist = code.getData() != null; +// if (leafExist) +// entity = diagram.getOrCreateLeaf(ident, code, null, null); +// else if (diagram.isGroup(idShort)) +// entity = diagram.getGroup(idShort); +// else +// return CommandExecutionResult.error(code + " does not exist"); // final IEntity entity = diagram.getOrCreateLeaf(code, null); final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), UrlMode.STRICT); diff --git a/src/net/sourceforge/plantuml/code/CompressionBrotli.java b/src/net/sourceforge/plantuml/code/CompressionBrotli.java index d443e34b3..ebaebeb03 100644 --- a/src/net/sourceforge/plantuml/code/CompressionBrotli.java +++ b/src/net/sourceforge/plantuml/code/CompressionBrotli.java @@ -44,16 +44,15 @@ import net.sourceforge.plantuml.brotli.BrotliInputStream; import net.sourceforge.plantuml.log.Logme; public class CompressionBrotli implements Compression { + // ::remove file when WASM public byte[] compress(byte[] in) { throw new UnsupportedOperationException(); } public ByteArray decompress(byte[] in) throws NoPlantumlCompressionException { - try ( - final BrotliInputStream brotli = new BrotliInputStream(new ByteArrayInputStream(in)); - final ByteArrayOutputStream result = new ByteArrayOutputStream(); - ) { + try (final BrotliInputStream brotli = new BrotliInputStream(new ByteArrayInputStream(in)); + final ByteArrayOutputStream result = new ByteArrayOutputStream();) { FileUtils.copyToStream(brotli, result); return ByteArray.from(result.toByteArray()); } catch (IOException e) { diff --git a/src/net/sourceforge/plantuml/code/CompressionZlib.java b/src/net/sourceforge/plantuml/code/CompressionZlib.java index 8973afee9..f1418f9cf 100644 --- a/src/net/sourceforge/plantuml/code/CompressionZlib.java +++ b/src/net/sourceforge/plantuml/code/CompressionZlib.java @@ -43,12 +43,16 @@ import net.sourceforge.plantuml.code.deflate.Decompressor; public class CompressionZlib implements Compression { + // ::comment when WASM private static boolean USE_ZOPFLI = false; + // ::done private static final int COMPRESSION_LEVEL = 9; public byte[] compress(byte[] in) { + // ::comment when WASM if (USE_ZOPFLI) return new CompressionZopfliZlib().compress(in); + // ::done if (in.length == 0) return null; diff --git a/src/net/sourceforge/plantuml/code/CompressionZlibAttic.java b/src/net/sourceforge/plantuml/code/CompressionZlibAttic.java index 3f97ec042..40483ae97 100644 --- a/src/net/sourceforge/plantuml/code/CompressionZlibAttic.java +++ b/src/net/sourceforge/plantuml/code/CompressionZlibAttic.java @@ -42,6 +42,7 @@ import java.util.zip.Inflater; @Deprecated public class CompressionZlibAttic implements Compression { + // ::remove file when WASM private static boolean USE_ZOPFLI = false; private static final int COMPRESSION_LEVEL = 9; diff --git a/src/net/sourceforge/plantuml/code/CompressionZopfliZlib.java b/src/net/sourceforge/plantuml/code/CompressionZopfliZlib.java index 7e6d5ea12..a968c49f9 100644 --- a/src/net/sourceforge/plantuml/code/CompressionZopfliZlib.java +++ b/src/net/sourceforge/plantuml/code/CompressionZopfliZlib.java @@ -41,6 +41,7 @@ import net.sourceforge.plantuml.zopfli.Options.OutputFormat; import net.sourceforge.plantuml.zopfli.Zopfli; public class CompressionZopfliZlib implements Compression { + // ::remove file when WASM public byte[] compress(byte[] in) { if (in.length == 0) diff --git a/src/net/sourceforge/plantuml/command/CommandAffineTransform.java b/src/net/sourceforge/plantuml/command/CommandAffineTransform.java index d95314522..3076543cd 100644 --- a/src/net/sourceforge/plantuml/command/CommandAffineTransform.java +++ b/src/net/sourceforge/plantuml/command/CommandAffineTransform.java @@ -62,7 +62,9 @@ public class CommandAffineTransform extends SingleLineCommand2 { @Override protected CommandExecutionResult executeArg(UmlDiagram diagram, LineLocation location, RegexResult arg) { final CharSequence value = arg.get("ANIMATION", 0); + // ::comment when WASM diagram.setAnimation(Collections.singletonList(value)); + // ::done return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/command/CommandNamespace.java b/src/net/sourceforge/plantuml/command/CommandNamespace.java index 32cb32b13..0182aed1b 100644 --- a/src/net/sourceforge/plantuml/command/CommandNamespace.java +++ b/src/net/sourceforge/plantuml/command/CommandNamespace.java @@ -38,20 +38,15 @@ package net.sourceforge.plantuml.command; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; -import net.sourceforge.plantuml.baraye.CucaDiagram; -import net.sourceforge.plantuml.baraye.IEntity; -import net.sourceforge.plantuml.baraye.IGroup; +import net.sourceforge.plantuml.baraye.EntityImp; import net.sourceforge.plantuml.baraye.Quark; import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; -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.NamespaceStrategy; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.graphic.USymbols; @@ -87,27 +82,14 @@ public class CommandNamespace extends SingleLineCommand2 { protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final String idShort = arg.get("NAME", 0); - final Code code; - final IGroup currentPackage; - final Display display; - final Ident idNewLong; - if (CucaDiagram.QUARK) { - 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); +// final Quark current = diagram.currentQuark(); +// final Quark idNewLong = current.child(idShort); + final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(idShort), true); + final CommandExecutionResult status = diagram.gotoGroup(quark, + Display.getWithNewlines(quark.getQualifiedName()), GroupType.PACKAGE); if (status.isOk() == false) return status; - final IEntity p = diagram.getCurrentGroup(); + final EntityImp p = diagram.getCurrentGroup(); final String stereotype = arg.get("STEREOTYPE", 0); if (stereotype != null) { final USymbol usymbol = USymbols.fromString(stereotype, diagram.getSkinParam().actorStyle(), diff --git a/src/net/sourceforge/plantuml/command/CommandNamespace2.java b/src/net/sourceforge/plantuml/command/CommandNamespace2.java index c07efccca..bbb98e1ad 100644 --- a/src/net/sourceforge/plantuml/command/CommandNamespace2.java +++ b/src/net/sourceforge/plantuml/command/CommandNamespace2.java @@ -38,18 +38,15 @@ package net.sourceforge.plantuml.command; 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.baraye.IGroup; +import net.sourceforge.plantuml.baraye.EntityImp; +import net.sourceforge.plantuml.baraye.Quark; import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; -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.NamespaceStrategy; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorType; @@ -89,16 +86,15 @@ public class CommandNamespace2 extends SingleLineCommand2 { protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final String idShort = arg.get("NAME", 0); - final Ident ident = diagram.buildLeafIdent(idShort); - final Code code = diagram.buildCode(idShort); - final IGroup currentPackage = diagram.getCurrentGroup(); + // final Quark ident = diagram.buildFromName(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(idShort)); + final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(idShort), true); + final String disp = arg.getLazzy("DISPLAY", 0); final Display display = Display.getWithNewlines(disp); - final CommandExecutionResult status = diagram.gotoGroup(ident, code, display, GroupType.PACKAGE, currentPackage, - NamespaceStrategy.MULTIPLE); + final CommandExecutionResult status = diagram.gotoGroup(quark, display, GroupType.PACKAGE); if (status.isOk() == false) return status; - final IEntity p = diagram.getCurrentGroup(); + final EntityImp p = diagram.getCurrentGroup(); final String stereotype = arg.get("STEREOTYPE", 0); if (stereotype != null) p.setStereotype(Stereotype.build(stereotype)); diff --git a/src/net/sourceforge/plantuml/command/CommandNamespaceEmpty.java b/src/net/sourceforge/plantuml/command/CommandNamespaceEmpty.java index 56fa8546b..374d731a0 100644 --- a/src/net/sourceforge/plantuml/command/CommandNamespaceEmpty.java +++ b/src/net/sourceforge/plantuml/command/CommandNamespaceEmpty.java @@ -38,18 +38,15 @@ package net.sourceforge.plantuml.command; 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.baraye.IGroup; +import net.sourceforge.plantuml.baraye.EntityImp; +import net.sourceforge.plantuml.baraye.Quark; import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; -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.NamespaceStrategy; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorType; @@ -84,15 +81,20 @@ public class CommandNamespaceEmpty extends SingleLineCommand2 { protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final String idShort = arg.get("NAME", 0); - final Ident idNewLong = diagram.buildLeafIdent(idShort); - final Code code = diagram.buildCode(idShort); - final IGroup currentPackage = diagram.getCurrentGroup(); - final Display display = Display.getWithNewlines(code); - final CommandExecutionResult status = diagram.gotoGroup(idNewLong, code, display, GroupType.PACKAGE, - currentPackage, NamespaceStrategy.MULTIPLE); + + final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(idShort), true); + if (quark.getData() != null) + return CommandExecutionResult.error("Already exists " + quark.getName()); + +// 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) return status; - final IEntity p = diagram.getCurrentGroup(); + final EntityImp p = diagram.getCurrentGroup(); final String stereotype = arg.get("STEREOTYPE", 0); if (stereotype != null) p.setStereotype(Stereotype.build(stereotype)); diff --git a/src/net/sourceforge/plantuml/command/CommandPackage.java b/src/net/sourceforge/plantuml/command/CommandPackage.java index 62e1933e6..e7754f261 100644 --- a/src/net/sourceforge/plantuml/command/CommandPackage.java +++ b/src/net/sourceforge/plantuml/command/CommandPackage.java @@ -39,9 +39,7 @@ import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; -import net.sourceforge.plantuml.baraye.CucaDiagram; -import net.sourceforge.plantuml.baraye.IEntity; -import net.sourceforge.plantuml.baraye.IGroup; +import net.sourceforge.plantuml.baraye.EntityImp; import net.sourceforge.plantuml.baraye.Quark; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; 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.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexResult; -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.NamespaceStrategy; import net.sourceforge.plantuml.cucadiagram.Stereotag; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.USymbol; @@ -108,42 +103,41 @@ public class CommandPackage extends SingleLineCommand2 { @Override protected CommandExecutionResult executeArg(AbstractEntityDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { - final String idShort; - /* final */String display; + String idShort; + String display; final String name = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("NAME", 0)); - boolean override1972 = false; + if (arg.get("AS", 0) == null) { if (name.length() == 0) { idShort = "##" + diagram.getUniqueSequence(); display = null; + throw new IllegalStateException("AS"); } else { idShort = name; display = idShort; - override1972 = true; } } else { - display = name; + display = name; idShort = arg.get("AS", 0); } - final Ident ident; - final Code code; - - if (CucaDiagram.QUARK) { - final Quark current = diagram.currentQuark(); - code = current; - ident = current.child(idShort); +// final Quark current = diagram.currentQuark(); +// final Quark ident = current.child(idShort); + final Quark quark; + if (arg.get("AS", 0) == null) { + quark = diagram.quarkInContext(diagram.cleanIdForQuark(name), true); + display = quark.getQualifiedName(); } else { - ident = diagram.buildLeafIdent(idShort); - code = diagram.buildCode(idShort); + quark = diagram.quarkInContext(diagram.cleanIdForQuark(arg.get("AS", 0)), true); + display = name; } - final IGroup currentPackage = diagram.getCurrentGroup(); - final CommandExecutionResult status = diagram.gotoGroup(ident, code, Display.getWithNewlines(display), - GroupType.PACKAGE, currentPackage, NamespaceStrategy.SINGLE); + + final CommandExecutionResult status = diagram.gotoGroup(quark, Display.getWithNewlines(display), + GroupType.PACKAGE); if (status.isOk() == false) return status; - final IEntity p = diagram.getCurrentGroup(); + final EntityImp p = diagram.getCurrentGroup(); final String stereotype = arg.get("STEREOTYPE", 0); diff --git a/src/net/sourceforge/plantuml/command/CommandPackageEmpty.java b/src/net/sourceforge/plantuml/command/CommandPackageEmpty.java index 90e9bcc24..0fa96b171 100644 --- a/src/net/sourceforge/plantuml/command/CommandPackageEmpty.java +++ b/src/net/sourceforge/plantuml/command/CommandPackageEmpty.java @@ -36,19 +36,16 @@ package net.sourceforge.plantuml.command; import net.sourceforge.plantuml.StringUtils; -import net.sourceforge.plantuml.baraye.IEntity; -import net.sourceforge.plantuml.baraye.IGroup; +import net.sourceforge.plantuml.baraye.EntityImp; +import net.sourceforge.plantuml.baraye.Quark; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexResult; -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.NamespaceStrategy; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; import net.sourceforge.plantuml.utils.LineLocation; @@ -97,14 +94,12 @@ public class CommandPackageEmpty extends SingleLineCommand2 { } } else { 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( "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 + "'. Please update your diagram."); - } - if (name.equalsIgnoreCase("layout") && value.equalsIgnoreCase("smetana")) { + + if (name.equalsIgnoreCase("layout") && value.equalsIgnoreCase("smetana")) system.setUseSmetana(true); - } - if (name.equalsIgnoreCase("layout") && value.equalsIgnoreCase("elk")) { + + if (name.equalsIgnoreCase("layout") && value.equalsIgnoreCase("elk")) system.setUseElk(true); - } - if (name.equalsIgnoreCase("layout") && value.equalsIgnoreCase(GraphvizUtils.VIZJS)) { + + if (name.equalsIgnoreCase("layout") && value.equalsIgnoreCase(GraphvizUtils.VIZJS)) system.getSkinParam().setUseVizJs(true); - } + // ::done + } return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/command/note/CommandFactoryNote.java b/src/net/sourceforge/plantuml/command/note/CommandFactoryNote.java index ab7b2433a..31ad4460e 100644 --- a/src/net/sourceforge/plantuml/command/note/CommandFactoryNote.java +++ b/src/net/sourceforge/plantuml/command/note/CommandFactoryNote.java @@ -35,7 +35,8 @@ */ 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.command.CommandCreateClassMultilines; 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.RegexLeaf; 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.Stereotag; import net.sourceforge.plantuml.cucadiagram.Stereotype; @@ -136,13 +135,19 @@ public final class CommandFactoryNote implements SingleMultiFactoryCommand { @@ -72,12 +73,15 @@ public class CommandCreateBlock extends SingleLineCommand2 { protected CommandExecutionResult executeArg(CompositeDiagram diagram, LineLocation location, RegexResult arg) { String display = arg.get("DISPLAY", 0); final String idShort = arg.get("CODE", 0); - final Code code = diagram.buildCode(idShort); - if (display == null) { - display = code.getName(); - } - final IEntity ent = diagram.getOrCreateLeaf(diagram.buildLeafIdent(idShort), code, null, null); - ent.setDisplay(Display.getWithNewlines(display)); + final Quark quark = diagram.quarkInContext(idShort, false); + if (display == null) + display = quark.getName(); + + if (quark.getData() != null) + 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(); } diff --git a/src/net/sourceforge/plantuml/compositediagram/command/CommandCreatePackageBlock.java b/src/net/sourceforge/plantuml/compositediagram/command/CommandCreatePackageBlock.java index d07d7342f..cc416cf69 100644 --- a/src/net/sourceforge/plantuml/compositediagram/command/CommandCreatePackageBlock.java +++ b/src/net/sourceforge/plantuml/compositediagram/command/CommandCreatePackageBlock.java @@ -35,7 +35,7 @@ */ 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.SingleLineCommand2; 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.RegexResult; import net.sourceforge.plantuml.compositediagram.CompositeDiagram; -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.NamespaceStrategy; import net.sourceforge.plantuml.utils.LineLocation; public class CommandCreatePackageBlock extends SingleLineCommand2 { @@ -74,16 +71,14 @@ public class CommandCreatePackageBlock extends SingleLineCommand2 { protected CommandExecutionResult executeArg(CompositeDiagram diagram, LineLocation location, RegexResult arg) { final String ent1 = arg.get("ENT1", 0); final String ent2 = arg.get("ENT2", 0); - final IEntity cl1 = diagram.getOrCreateLeaf(diagram.buildLeafIdent(ent1), diagram.buildCode(ent1), null, null); - final IEntity cl2 = diagram.getOrCreateLeaf(diagram.buildLeafIdent(ent2), diagram.buildCode(ent2), null, null); + final Quark quark1 = diagram.quarkInContext(diagram.cleanIdForQuark(ent1), false); + 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 deco2 = arg.get("DECO2", 0); @@ -95,7 +105,7 @@ public class CommandLinkBlock extends SingleLineCommand2 { final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(arg.get("DISPLAY", 0)), queue.length(), 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); diagram.addLink(link); return CommandExecutionResult.ok(); diff --git a/src/net/sourceforge/plantuml/creole/atom/AtomImg.java b/src/net/sourceforge/plantuml/creole/atom/AtomImg.java index 89d555317..6fdac3703 100644 --- a/src/net/sourceforge/plantuml/creole/atom/AtomImg.java +++ b/src/net/sourceforge/plantuml/creole/atom/AtomImg.java @@ -48,7 +48,6 @@ import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.code.Base64Coder; import net.sourceforge.plantuml.creole.legacy.AtomTextUtils; import net.sourceforge.plantuml.flashcode.FlashCodeFactory; -import net.sourceforge.plantuml.flashcode.FlashCodeUtils; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.ImgValign; 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) { - final FlashCodeUtils utils = FlashCodeFactory.getFlashCodeUtils(); - BufferedImage im = utils.exportFlashcode(flash, Color.BLACK, Color.WHITE); + BufferedImage im = null; + // :: comment when WASM + im = FlashCodeFactory.getFlashCodeUtils().exportFlashcode(flash, Color.BLACK, Color.WHITE); if (im == null) + // ::done im = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB); return new AtomImg( diff --git a/src/net/sourceforge/plantuml/creole/atom/AtomMath.java b/src/net/sourceforge/plantuml/creole/atom/AtomMath.java index 8c20cf726..5dbf5703f 100644 --- a/src/net/sourceforge/plantuml/creole/atom/AtomMath.java +++ b/src/net/sourceforge/plantuml/creole/atom/AtomMath.java @@ -49,6 +49,7 @@ import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorSimple; public class AtomMath extends AbstractAtom implements Atom { + // ::remove file when WASM private final ScientificEquationSafe math; private final HColor foreground; diff --git a/src/net/sourceforge/plantuml/creole/command/CommandCreoleLatex.java b/src/net/sourceforge/plantuml/creole/command/CommandCreoleLatex.java index c97beb801..fb92ad197 100644 --- a/src/net/sourceforge/plantuml/creole/command/CommandCreoleLatex.java +++ b/src/net/sourceforge/plantuml/creole/command/CommandCreoleLatex.java @@ -43,6 +43,7 @@ import net.sourceforge.plantuml.graphic.Splitter; import net.sourceforge.plantuml.math.ScientificEquationSafe; public class CommandCreoleLatex implements Command { + // ::remove file when WASM @Override public String startingChars() { diff --git a/src/net/sourceforge/plantuml/creole/command/CommandCreoleMath.java b/src/net/sourceforge/plantuml/creole/command/CommandCreoleMath.java index 9cd8916df..2585d30e9 100644 --- a/src/net/sourceforge/plantuml/creole/command/CommandCreoleMath.java +++ b/src/net/sourceforge/plantuml/creole/command/CommandCreoleMath.java @@ -43,6 +43,7 @@ import net.sourceforge.plantuml.graphic.Splitter; import net.sourceforge.plantuml.math.ScientificEquationSafe; public class CommandCreoleMath implements Command { + // ::remove file when WASM @Override public String startingChars() { diff --git a/src/net/sourceforge/plantuml/creole/legacy/CreoleParser.java b/src/net/sourceforge/plantuml/creole/legacy/CreoleParser.java index 500b4ae2e..54b19353c 100644 --- a/src/net/sourceforge/plantuml/creole/legacy/CreoleParser.java +++ b/src/net/sourceforge/plantuml/creole/legacy/CreoleParser.java @@ -104,8 +104,10 @@ public class CreoleParser implements SheetBuilder { return new StripeTree(fontConfiguration, skinParam, line); } else if (Parser.isCodeStart(line)) { return new StripeCode(fontConfiguration.changeFamily(Parser.MONOSPACED)); + // ::comment when WASM } else if (Parser.isLatexStart(line)) { return new StripeLatex(fontConfiguration); + // ::done } return new CreoleStripeSimpleParser(line, context, fontConfiguration, skinParam, creoleMode) .createStripe(context); diff --git a/src/net/sourceforge/plantuml/creole/legacy/StripeLatex.java b/src/net/sourceforge/plantuml/creole/legacy/StripeLatex.java index c322b9078..aa1a5e5aa 100644 --- a/src/net/sourceforge/plantuml/creole/legacy/StripeLatex.java +++ b/src/net/sourceforge/plantuml/creole/legacy/StripeLatex.java @@ -49,7 +49,7 @@ import net.sourceforge.plantuml.math.ScientificEquationSafe; import net.sourceforge.plantuml.ugraphic.UGraphic; public class StripeLatex implements StripeRaw { - + // ::remove file when WASM final private FontConfiguration fontConfiguration; final private StringBuilder formula = new StringBuilder(); private AtomMath atom; diff --git a/src/net/sourceforge/plantuml/creole/legacy/StripeSimple.java b/src/net/sourceforge/plantuml/creole/legacy/StripeSimple.java index f2e044cae..909206b96 100644 --- a/src/net/sourceforge/plantuml/creole/legacy/StripeSimple.java +++ b/src/net/sourceforge/plantuml/creole/legacy/StripeSimple.java @@ -162,8 +162,10 @@ public class StripeSimple implements Stripe { addCommand(CommandCreoleQrcode.create()); addCommand(CommandCreoleOpenIcon.create()); addCommand(CommandCreoleEmoji.create()); + // ::comment when WASM addCommand(CommandCreoleMath.create()); addCommand(CommandCreoleLatex.create()); + // ::done addCommand(CommandCreoleSprite.create()); addCommand(CommandCreoleSpace.create()); addCommand(CommandCreoleFontFamilyChange.create()); @@ -284,9 +286,11 @@ public class StripeSimple implements Stripe { atoms.add(new AtomEmoji(emoji, 1, fontConfiguration.getSize2D(), col)); } + // ::comment when WASM public void addMath(ScientificEquationSafe math) { atoms.add(new AtomMath(math, fontConfiguration.getColor(), fontConfiguration.getExtendedColor())); } + // ::done private void modifyStripe(String line) { final StringBuilder pending = new StringBuilder(); diff --git a/src/net/sourceforge/plantuml/cucadiagram/Bodier.java b/src/net/sourceforge/plantuml/cucadiagram/Bodier.java index 427550f7d..f2e96773f 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Bodier.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Bodier.java @@ -38,7 +38,7 @@ package net.sourceforge.plantuml.cucadiagram; import java.util.List; 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.TextBlock; import net.sourceforge.plantuml.style.Style; @@ -46,7 +46,7 @@ import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public interface Bodier { - public void setLeaf(ILeaf leaf); + public void setLeaf(EntityImp leaf); public Display getFieldsToDisplay(); diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodierJSon.java b/src/net/sourceforge/plantuml/cucadiagram/BodierJSon.java index ab906c63b..9e25839eb 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodierJSon.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodierJSon.java @@ -39,7 +39,7 @@ import java.util.List; import java.util.Objects; 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.TextBlock; import net.sourceforge.plantuml.json.JsonValue; @@ -48,7 +48,7 @@ import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class BodierJSon implements Bodier { - private ILeaf leaf; + private EntityImp leaf; private JsonValue json; @Override @@ -60,7 +60,7 @@ public class BodierJSon implements Bodier { } @Override - public void setLeaf(ILeaf leaf) { + public void setLeaf(EntityImp leaf) { this.leaf = Objects.requireNonNull(leaf); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodierLikeClassOrObject.java b/src/net/sourceforge/plantuml/cucadiagram/BodierLikeClassOrObject.java index 4123872e9..bdfe765b8 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodierLikeClassOrObject.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodierLikeClassOrObject.java @@ -44,7 +44,7 @@ import java.util.Set; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.StringUtils; 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.legacy.CreoleParser; import net.sourceforge.plantuml.graphic.FontConfiguration; @@ -63,7 +63,7 @@ public class BodierLikeClassOrObject implements Bodier { private LeafType type; private List methodsToDisplay; private List fieldsToDisplay; - private ILeaf leaf; + private EntityImp leaf; @Override public void muteClassToObject() { @@ -82,7 +82,7 @@ public class BodierLikeClassOrObject implements Bodier { } @Override - public void setLeaf(ILeaf leaf) { + public void setLeaf(EntityImp leaf) { this.leaf = Objects.requireNonNull(leaf); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodierMap.java b/src/net/sourceforge/plantuml/cucadiagram/BodierMap.java index 744dd0d3d..a7e32cae1 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodierMap.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodierMap.java @@ -46,7 +46,7 @@ import java.util.regex.Pattern; import net.sourceforge.plantuml.ISkinParam; 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.TextBlock; import net.sourceforge.plantuml.style.Style; @@ -55,7 +55,7 @@ public class BodierMap implements Bodier { private final List rawBody = new ArrayList<>(); private final Map map = new LinkedHashMap(); - private ILeaf leaf; + private EntityImp leaf; @Override public void muteClassToObject() { @@ -66,7 +66,7 @@ public class BodierMap implements Bodier { } @Override - public void setLeaf(ILeaf leaf) { + public void setLeaf(EntityImp leaf) { this.leaf = Objects.requireNonNull(leaf); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodierSimple.java b/src/net/sourceforge/plantuml/cucadiagram/BodierSimple.java index 7dab8f8c9..1b6f96497 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodierSimple.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodierSimple.java @@ -41,7 +41,7 @@ import java.util.List; import java.util.Objects; 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.HorizontalAlignment; import net.sourceforge.plantuml.graphic.TextBlock; @@ -51,7 +51,7 @@ import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class BodierSimple implements Bodier { private final List rawBody = new ArrayList<>(); - private ILeaf leaf; + private EntityImp leaf; @Override public void muteClassToObject() { @@ -62,7 +62,7 @@ public class BodierSimple implements Bodier { } @Override - public void setLeaf(ILeaf leaf) { + public void setLeaf(EntityImp leaf) { this.leaf = Objects.requireNonNull(leaf); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced1.java b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced1.java index 6a9f10156..2135f81f0 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced1.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced1.java @@ -46,7 +46,7 @@ import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.Url; 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.Parser; 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 List urls = new ArrayList<>(); - private final ILeaf entity; + private final EntityImp entity; private final boolean inEllipse; private final Style style; - BodyEnhanced1(HorizontalAlignment align, List rawBody, ISkinParam skinParam, ILeaf entity, + BodyEnhanced1(HorizontalAlignment align, List rawBody, ISkinParam skinParam, EntityImp entity, Style style) { super(align, style.getFontConfiguration(skinParam.getIHtmlColorSet(), entity.getColors()), style); this.style = style; @@ -88,7 +88,7 @@ public class BodyEnhanced1 extends BodyEnhancedAbstract implements TextBlock, Wi 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); this.style = style; diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodyFactory.java b/src/net/sourceforge/plantuml/cucadiagram/BodyFactory.java index 5a6a0de84..abcea8ec9 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodyFactory.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodyFactory.java @@ -41,7 +41,7 @@ import java.util.Set; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinSimple; 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.HorizontalAlignment; import net.sourceforge.plantuml.graphic.TextBlock; @@ -64,12 +64,12 @@ public class BodyFactory { } public static TextBlock create1(HorizontalAlignment align, List rawBody, ISkinParam skinParam, - Stereotype stereotype, ILeaf entity, Style style) { + Stereotype stereotype, EntityImp entity, Style style) { return new BodyEnhanced1(align, rawBody, skinParam, entity, style); } 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); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/CodeImpl.java b/src/net/sourceforge/plantuml/cucadiagram/CodeImpl.java deleted file mode 100644 index 639130f76..000000000 --- a/src/net/sourceforge/plantuml/cucadiagram/CodeImpl.java +++ /dev/null @@ -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)); - } - -} diff --git a/src/net/sourceforge/plantuml/cucadiagram/Display.java b/src/net/sourceforge/plantuml/cucadiagram/Display.java index c075fd123..bf4858efc 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Display.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Display.java @@ -52,6 +52,7 @@ import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.SpriteContainer; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; +import net.sourceforge.plantuml.baraye.Quark; import net.sourceforge.plantuml.command.regex.Matcher2; import net.sourceforge.plantuml.command.regex.MyPattern; import net.sourceforge.plantuml.command.regex.Pattern2; @@ -102,6 +103,8 @@ public class Display implements Iterable { // } public boolean equalsLike(Display other) { + if (isNull(this)) + return isNull(other); return this.displayData.equals(other.displayData); } @@ -197,7 +200,7 @@ public class Display implements Iterable { 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()); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/EntityGender.java b/src/net/sourceforge/plantuml/cucadiagram/EntityGender.java index 703036619..6679ca263 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/EntityGender.java +++ b/src/net/sourceforge/plantuml/cucadiagram/EntityGender.java @@ -35,8 +35,8 @@ */ package net.sourceforge.plantuml.cucadiagram; -import net.sourceforge.plantuml.baraye.IEntity; +import net.sourceforge.plantuml.baraye.EntityImp; public interface EntityGender { - public boolean contains(IEntity test); + public boolean contains(EntityImp test); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/EntityGenderUtils.java b/src/net/sourceforge/plantuml/cucadiagram/EntityGenderUtils.java index 85eb73bb5..98442d4af 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/EntityGenderUtils.java +++ b/src/net/sourceforge/plantuml/cucadiagram/EntityGenderUtils.java @@ -36,23 +36,22 @@ package net.sourceforge.plantuml.cucadiagram; import net.sourceforge.plantuml.Guillemet; +import net.sourceforge.plantuml.baraye.EntityImp; import net.sourceforge.plantuml.baraye.EntityUtils; -import net.sourceforge.plantuml.baraye.IEntity; -import net.sourceforge.plantuml.baraye.IGroup; public class EntityGenderUtils { static public EntityGender byEntityType(final LeafType type) { return new EntityGender() { - public boolean contains(IEntity test) { + public boolean contains(EntityImp test) { return test.getLeafType() == type; } }; } - static public EntityGender byEntityAlone(final IEntity entity) { + static public EntityGender byEntityAlone(final EntityImp entity) { return new EntityGender() { - public boolean contains(IEntity test) { + public boolean contains(EntityImp test) { return test.getUid().equals(entity.getUid()); } }; @@ -60,7 +59,7 @@ public class EntityGenderUtils { static public EntityGender byStereotype(final String stereotype) { return new EntityGender() { - public boolean contains(IEntity test) { + public boolean contains(EntityImp test) { if (test.getStereotype() == null) { return false; } @@ -69,13 +68,13 @@ public class EntityGenderUtils { }; } - static public EntityGender byPackage(final IGroup group) { - if (EntityUtils.groupRoot(group)) { + static public EntityGender byPackage(final EntityImp group) { + if (group.getQuark().isRoot()) { throw new IllegalArgumentException(); } return new EntityGender() { - public boolean contains(IEntity test) { - if (EntityUtils.groupRoot(test.getParentContainer())) { + public boolean contains(EntityImp test) { + if (test.getParentContainer().getQuark().isRoot()) { return false; } if (group == test.getParentContainer()) { @@ -88,7 +87,7 @@ public class EntityGenderUtils { static public EntityGender and(final EntityGender g1, final EntityGender g2) { return new EntityGender() { - public boolean contains(IEntity test) { + public boolean contains(EntityImp test) { return g1.contains(test) && g2.contains(test); } }; @@ -96,7 +95,7 @@ public class EntityGenderUtils { static public EntityGender all() { return new EntityGender() { - public boolean contains(IEntity test) { + public boolean contains(EntityImp test) { return true; } }; @@ -104,7 +103,7 @@ public class EntityGenderUtils { static public EntityGender emptyMethods() { return new EntityGender() { - public boolean contains(IEntity test) { + public boolean contains(EntityImp test) { return test.getBodier().getMethodsToDisplay().size() == 0; } }; @@ -112,7 +111,7 @@ public class EntityGenderUtils { static public EntityGender emptyFields() { return new EntityGender() { - public boolean contains(IEntity test) { + public boolean contains(EntityImp test) { return test.getBodier().getFieldsToDisplay().size() == 0; } }; diff --git a/src/net/sourceforge/plantuml/cucadiagram/GroupHierarchy.java b/src/net/sourceforge/plantuml/cucadiagram/GroupHierarchy.java index 20e10681e..1cdad08a9 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/GroupHierarchy.java +++ b/src/net/sourceforge/plantuml/cucadiagram/GroupHierarchy.java @@ -37,13 +37,13 @@ package net.sourceforge.plantuml.cucadiagram; import java.util.Collection; -import net.sourceforge.plantuml.baraye.IGroup; +import net.sourceforge.plantuml.baraye.EntityImp; public interface GroupHierarchy { - public IGroup getRootGroup(); + public EntityImp getRootGroup(); - public Collection getChildrenGroups(IGroup parent); + public Collection getChildrenGroups(EntityImp parent); - public boolean isEmpty(IGroup g); + public boolean isEmpty(EntityImp g); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/GroupPrinter.java b/src/net/sourceforge/plantuml/cucadiagram/GroupPrinter.java index 4824cdff9..df090f6bd 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/GroupPrinter.java +++ b/src/net/sourceforge/plantuml/cucadiagram/GroupPrinter.java @@ -38,8 +38,7 @@ package net.sourceforge.plantuml.cucadiagram; import java.io.IOException; import java.io.PrintWriter; -import net.sourceforge.plantuml.baraye.IGroup; -import net.sourceforge.plantuml.baraye.ILeaf; +import net.sourceforge.plantuml.baraye.EntityImp; import net.sourceforge.plantuml.log.Logme; import net.sourceforge.plantuml.security.SFile; @@ -51,7 +50,7 @@ public class GroupPrinter { this.pw = pw; } - private void printGroup(IGroup group) { + private void printGroup(EntityImp group) { pw.println(""); pw.println(""); pw.println(""); pw.println("
"); @@ -61,7 +60,7 @@ public class GroupPrinter { if (group.getLeafsDirect().size() == 0) { pw.println("No direct leaf"); } else { - for (ILeaf leaf : group.getLeafsDirect()) { + for (EntityImp leaf : group.getLeafsDirect()) { pw.println("
    "); printLeaf(leaf); pw.println("
"); @@ -72,7 +71,7 @@ public class GroupPrinter { if (group.getChildren().size() > 0) { pw.println("
"); - for (IGroup g : group.getChildren()) { + for (EntityImp g : group.getChildren()) { pw.println("
"); printGroup(g); pw.println("
"); @@ -83,11 +82,11 @@ public class GroupPrinter { pw.println("
"); } - private void printLeaf(ILeaf leaf) { + private void printLeaf(EntityImp leaf) { pw.println("

  • " + leaf.getCodeGetName()); } - public static void print(SFile f, IGroup rootGroup) { + public static void print(SFile f, EntityImp rootGroup) { try (PrintWriter pw = f.createPrintWriter()) { pw.println(""); new GroupPrinter(pw).printGroup(rootGroup); diff --git a/src/net/sourceforge/plantuml/cucadiagram/GroupRoot.java b/src/net/sourceforge/plantuml/cucadiagram/GroupRoot.java deleted file mode 100644 index 7da5fc439..000000000 --- a/src/net/sourceforge/plantuml/cucadiagram/GroupRoot.java +++ /dev/null @@ -1,345 +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.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.Url; -import net.sourceforge.plantuml.baraye.EntityFactory; -import net.sourceforge.plantuml.baraye.IGroup; -import net.sourceforge.plantuml.baraye.ILeaf; -import net.sourceforge.plantuml.command.Position; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.USymbol; -import net.sourceforge.plantuml.graphic.color.ColorType; -import net.sourceforge.plantuml.graphic.color.Colors; -import net.sourceforge.plantuml.svek.IEntityImage; -import net.sourceforge.plantuml.svek.PackageStyle; -import net.sourceforge.plantuml.svek.SingleStrategy; -import net.sourceforge.plantuml.ugraphic.UStroke; -import net.sourceforge.plantuml.ugraphic.color.HColor; -import net.sourceforge.plantuml.utils.LineLocation; - -public class GroupRoot implements IGroup { - - private final EntityFactory entityFactory; - - public GroupRoot(EntityFactory entityFactory) { - this.entityFactory = entityFactory; - } - - @Override - public Collection getLeafsDirect() { - final List result = new ArrayList<>(); - for (ILeaf ent : entityFactory.leafs()) - if (ent.getParentContainer() == this) - result.add(ent); - - return Collections.unmodifiableCollection(result); - - } - - @Override - public String toString() { - return "ROOT"; - } - - @Override - public boolean isGroup() { - return true; - } - - @Override - public Display getDisplay() { - throw new UnsupportedOperationException(); - - } - - @Override - public void setDisplay(Display display) { - throw new UnsupportedOperationException(); - - } - - @Override - public LeafType getLeafType() { - throw new UnsupportedOperationException(); - } - - @Override - public String getUid() { - throw new UnsupportedOperationException(); - - } - - @Override - public Url getUrl99() { - return null; - - } - - @Override - public Stereotype getStereotype() { - throw new UnsupportedOperationException(); - - } - - @Override - public void setStereotype(Stereotype stereotype) { - throw new UnsupportedOperationException(); - } - - @Override - public Code getCode() { - return CodeImpl.of("__ROOT__"); - } - - @Override - public String getCodeGetName() { - return getCode().getName(); - } - - @Override - public void addUrl(Url url) { - throw new UnsupportedOperationException(); - - } - - @Override - public IGroup getParentContainer() { - return null; - } - - @Override - public boolean containsLeafRecurse(ILeaf entity) { - throw new UnsupportedOperationException(); - - } - - @Override - public Collection getChildren() { - final List result = new ArrayList<>(); - for (IGroup ent : entityFactory.groups()) - if (ent.getParentContainer() == this) - result.add(ent); - - return Collections.unmodifiableCollection(result); - } - - @Override - public void moveEntitiesTo(IGroup dest) { - throw new UnsupportedOperationException(); - } - - @Override - public int size() { - throw new UnsupportedOperationException(); - } - - @Override - public GroupType getGroupType() { - return null; - } - - @Override - public Code getNamespace() { - throw new UnsupportedOperationException(); - - } - - @Override - public PackageStyle getPackageStyle() { - throw new UnsupportedOperationException(); - - } - - @Override - public void overrideImage(IEntityImage img, LeafType state) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean isHidden() { - return false; - } - - @Override - public USymbol getUSymbol() { - return null; - // throw new UnsupportedOperationException(); - } - - @Override - public void setUSymbol(USymbol symbol) { - throw new UnsupportedOperationException(); - } - - @Override - public SingleStrategy getSingleStrategy() { - return SingleStrategy.SQUARE; - } - - @Override - public boolean isRemoved() { - return false; - } - - @Override - public boolean hasUrl() { - return false; - } - - @Override - public int getRawLayout() { - throw new UnsupportedOperationException(); - } - - @Override - public char getConcurrentSeparator() { - throw new UnsupportedOperationException(); - } - - @Override - public void setConcurrentSeparator(char separator) { - // throw new UnsupportedOperationException(); - } - - @Override - public void putTip(String member, Display display) { - throw new UnsupportedOperationException(); - } - - @Override - public Map getTips() { - throw new UnsupportedOperationException(); - } - - @Override - public Bodier getBodier() { - throw new UnsupportedOperationException(); - } - - @Override - public Colors getColors() { - return Colors.empty(); - } - - @Override - public void setColors(Colors colors) { - throw new UnsupportedOperationException(); - } - - public void setSpecificColorTOBEREMOVED(ColorType type, HColor color) { - throw new UnsupportedOperationException(); - } - - public void setSpecificLineStroke(UStroke specificLineStroke) { - throw new UnsupportedOperationException(); - } - - public FontConfiguration getFontConfigurationForTitle(ISkinParam skinParam) { - throw new UnsupportedOperationException(); - } - - public void addStereotag(Stereotag tag) { - throw new UnsupportedOperationException(); - } - - public Set stereotags() { - throw new UnsupportedOperationException(); - } - - @Override - public void setLegend(DisplayPositioned legend) { - throw new UnsupportedOperationException(); - } - - @Override - public DisplayPositioned getLegend() { - throw new UnsupportedOperationException(); - } - - @Override - public Ident getIdent() { - return Ident.empty(); - } - - @Override - public boolean isAloneAndUnlinked() { - throw new UnsupportedOperationException(); - } - - @Override - public String getCodeLine() { - throw new UnsupportedOperationException(); - } - - @Override - public void setCodeLine(LineLocation codeLine) { - throw new UnsupportedOperationException(); - } - - @Override - public void setStereostyle(String stereo) { - throw new UnsupportedOperationException(); - } - - @Override - public Stereostyles getStereostyles() { - throw new UnsupportedOperationException(); - } - - @Override - public void addNote(Display note, Position position, Colors colors) { - throw new UnsupportedOperationException(); - } - - @Override - public EntityPosition getEntityPosition() { - throw new UnsupportedOperationException(); - } - - @Override - public List getNotes(Position position) { - throw new UnsupportedOperationException(); - } -} diff --git a/src/net/sourceforge/plantuml/cucadiagram/GroupType.java b/src/net/sourceforge/plantuml/cucadiagram/GroupType.java index 98b65aeb4..fdffd680d 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/GroupType.java +++ b/src/net/sourceforge/plantuml/cucadiagram/GroupType.java @@ -37,6 +37,6 @@ package net.sourceforge.plantuml.cucadiagram; public enum GroupType { - PACKAGE, STATE, CONCURRENT_STATE, INNER_ACTIVITY, CONCURRENT_ACTIVITY, DOMAIN, REQUIREMENT + ROOT, PACKAGE, STATE, CONCURRENT_STATE, INNER_ACTIVITY, CONCURRENT_ACTIVITY, DOMAIN, REQUIREMENT } diff --git a/src/net/sourceforge/plantuml/cucadiagram/HideOrShow2.java b/src/net/sourceforge/plantuml/cucadiagram/HideOrShow2.java index 2f145698c..655400907 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/HideOrShow2.java +++ b/src/net/sourceforge/plantuml/cucadiagram/HideOrShow2.java @@ -35,7 +35,7 @@ */ package net.sourceforge.plantuml.cucadiagram; -import net.sourceforge.plantuml.baraye.ILeaf; +import net.sourceforge.plantuml.baraye.EntityImp; public class HideOrShow2 { @@ -47,7 +47,7 @@ public class HideOrShow2 { return what + " (" + show + ")"; } - private boolean isApplyable(ILeaf leaf) { + private boolean isApplyable(EntityImp leaf) { if (what.startsWith("$")) return isApplyableTag(leaf, what.substring(1)); @@ -72,7 +72,7 @@ public class HideOrShow2 { return what.equalsIgnoreCase("@unlinked"); } - private boolean isApplyableUnlinked(ILeaf leaf) { + private boolean isApplyableUnlinked(EntityImp leaf) { if (leaf.isAloneAndUnlinked()) return true; @@ -90,7 +90,7 @@ public class HideOrShow2 { return false; } - private boolean isApplyableTag(ILeaf leaf, String pattern) { + private boolean isApplyableTag(EntityImp leaf, String pattern) { for (Stereotag tag : leaf.stereotags()) if (match(tag.getName(), pattern)) return true; @@ -115,7 +115,7 @@ public class HideOrShow2 { this.show = show; } - public boolean apply(boolean hidden, ILeaf leaf) { + public boolean apply(boolean hidden, EntityImp leaf) { if (isApplyable(leaf)) return !show; diff --git a/src/net/sourceforge/plantuml/cucadiagram/ICucaDiagram.java b/src/net/sourceforge/plantuml/cucadiagram/ICucaDiagram.java index 1cbb2e2d5..14cfb2c46 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/ICucaDiagram.java +++ b/src/net/sourceforge/plantuml/cucadiagram/ICucaDiagram.java @@ -44,8 +44,7 @@ import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.Pragma; import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.baraye.EntityFactory; -import net.sourceforge.plantuml.baraye.IGroup; -import net.sourceforge.plantuml.baraye.ILeaf; +import net.sourceforge.plantuml.baraye.EntityImp; import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.style.StyleBuilder; import net.sourceforge.plantuml.ugraphic.ImageBuilder; @@ -72,19 +71,19 @@ public interface ICucaDiagram extends GroupHierarchy, PortionShower, Annotated { String getFlashData(); - Collection getLeafsvalues(); + Collection getLeafsvalues(); ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) throws IOException; String getNamespaceSeparator(); - Collection getGroups(boolean b); + Collection getGroups(boolean b); UmlSource getSource(); String[] getDotStringSkek(); - boolean isAutarkic(IGroup g); + boolean isAutarkic(EntityImp g); int getUniqueSequence(); diff --git a/src/net/sourceforge/plantuml/cucadiagram/Ident.java b/src/net/sourceforge/plantuml/cucadiagram/Ident.java deleted file mode 100644 index 969b20bdc..000000000 --- a/src/net/sourceforge/plantuml/cucadiagram/Ident.java +++ /dev/null @@ -1,296 +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.ArrayList; -import java.util.Collections; -import java.util.List; - -import net.sourceforge.plantuml.StringUtils; -import net.sourceforge.plantuml.baraye.CucaDiagram; -import net.sourceforge.plantuml.baraye.EntityFactory; - -public class Ident implements Code { - - final protected List parts; - - public /* private */ Ident(List parts) { - this.parts = parts; - } - - @Override - public String toString() { - return parts.toString(); - } - - public boolean startsWith(Ident other) { - if (other.parts.size() > this.parts.size()) - return false; - - for (int i = 0; i < other.parts.size(); i++) - if (other.parts.get(i).equals(this.parts.get(i)) == false) - return false; - - return true; - } - - public String forXmi() { - final StringBuilder sb = new StringBuilder(); - for (String s : parts) { - if (sb.length() > 0) - sb.append("."); - - sb.append(s); - } - return sb.toString(); - } - - public Ident add(Ident added) { - final List copy = new ArrayList<>(parts); - copy.addAll(added.parts); - return new Ident(copy); - } - - public static Ident empty() { - return new Ident(Collections.emptyList()); - } - - public String getLast() { - if (parts.size() == 0) { - return ""; - } - return parts.get(parts.size() - 1); - } - - public Code toCode(CucaDiagram diagram) { - return CodeImpl.of(getLast()); - } - - public Ident eventuallyRemoveStartingAndEndingDoubleQuote(String format) { - final List copy = new ArrayList<>(parts); - final int pos = copy.size() - 1; - copy.set(pos, StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(copy.get(pos), format)); - return new Ident(copy); - } - - public Ident removeStartingParenthesis() { - final List copy = new ArrayList<>(parts); - final int pos = copy.size() - 1; - final String last = copy.get(pos); - if (last.startsWith("()") == false) { - throw new IllegalStateException(); - } - copy.set(pos, StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(last.substring(2).trim())); - return new Ident(copy); - } - - public Ident addSuffix(String suffix) { - final List copy = new ArrayList<>(parts); - final int pos = copy.size() - 1; - copy.set(pos, copy.get(pos) + suffix); - return new Ident(copy); - // return new Code(fullName + suffix); - } - - public Ident removeMemberPart() { - final String last = getLast(); - final int x = last.lastIndexOf("::"); - if (x == -1) { - return null; - } - final List copy = new ArrayList<>(parts); - final int pos = copy.size() - 1; - copy.set(pos, last.substring(0, x)); - return new Ident(copy); - } - - public String getPortMember() { - final String last = getLast(); - final int x = last.lastIndexOf("::"); - if (x == -1) { - return null; - } - return last.substring(x + 2); - } - - static private Ident from(String full, String separator) { - final Ident result = new Ident(new ArrayList()); - if (isOdd(full, separator)) { - result.parts.add(full); - return result; - } - while (true) { - int idx = full.indexOf(separator); - if (idx == -1) { - result.parts.add(full); - result.checkResult(separator); - return result; - } - if (idx > 0) { - result.parts.add(full.substring(0, idx)); - } - full = full.substring(idx + separator.length()); - } - } - - private static boolean isOdd(String full, String separator) { - return separator == null || full.contains(separator + separator) || full.endsWith(separator); - } - - private void checkResult(String separator) { - for (String s : this.parts) { - if (s.length() == 0) { - throw new IllegalStateException(toString()); - } - if (separator != null && s.contains(separator) && s.endsWith(separator) == false - && s.contains(separator + separator) == false) { - throw new IllegalStateException(toString()); - } - } - } - - public Ident add(String sup, String separator) { - this.checkResult(separator); - final Ident added = from(sup, separator); - final List list = new ArrayList<>(this.parts.size() + added.parts.size()); - list.addAll(this.parts); - list.addAll(added.parts); - final Ident result = new Ident(list); - result.checkResult(separator); - return result; - } - - public Ident parent() { - if (parts.size() == 0) { - throw new IllegalArgumentException(); - } - return new Ident(parts.subList(0, parts.size() - 1)); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof CodeImpl) { - final CodeImpl other = (CodeImpl) obj; - return other.getName().equals(toString(".")); - } - final Ident other = (Ident) obj; - return this.parts.equals(other.parts); - } - - @Override - public int hashCode() { - return parts.hashCode(); - } - - public String toString(String sep) { - if (sep == null) { - sep = "."; - } - final StringBuilder sb = new StringBuilder(); - for (String s : parts) { - if (sb.length() > 0) { - sb.append(sep); - } - sb.append(s); - } - return sb.toString(); - } - - public void checkSameAs(Code code, String separator, CucaDiagram diagram) { - final String last = parts.get(parts.size() - 1); - if (separator == null) { - if (code.getName().equals(last) != true && code.getName().equals(toString(separator)) == false) { -// System.err.println("code1=" + code); -// System.err.println("this1=" + this); - EntityFactory.bigError(); - } - } else { - if (getLastPart(code.getName(), separator).equals(last) != true - && code.getName().equals(toString(separator)) == false) { -// System.err.println("code2=" + code); -// System.err.println("this2=" + this); - EntityFactory.bigError(); - } - } - } - - private String getLastPart(String fullName, String separator) { - if (separator == null) { - return fullName; - } - final int x = fullName.lastIndexOf(separator); - if (x == -1) { - return fullName; - } - return fullName.substring(x + separator.length()); - } - - // public int compareTo(Code o) { - // throw new UnsupportedOperationException(); - // } - - public String getName() { - return getLast(); - } - - public boolean isRoot() { - return parts.size() == 0; - } - - public Ident move(Ident from, Ident to) { - if (this.startsWith(from) == false) { - throw new IllegalArgumentException(); - } - final List result = new ArrayList<>(to.parts); - for (int i = from.parts.size(); i < this.parts.size(); i++) { - result.add(this.parts.get(i)); - } - return new Ident(result); - } - - public int size() { - return parts.size(); - } - - public Ident getPrefix(int toIndex) { - return new Ident(this.parts.subList(0, toIndex)); - } - - public Ident getSuffix(int fromIndex) { - return new Ident(this.parts.subList(fromIndex, this.parts.size())); - } - -} diff --git a/src/net/sourceforge/plantuml/cucadiagram/Link.java b/src/net/sourceforge/plantuml/cucadiagram/Link.java index a66e3ecd0..9d998d6c9 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Link.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Link.java @@ -41,13 +41,9 @@ import net.sourceforge.plantuml.Hideable; import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.OptionFlags; import net.sourceforge.plantuml.Removeable; -import net.sourceforge.plantuml.SpecificBackcolorable; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.baraye.EntityImp; -import net.sourceforge.plantuml.baraye.IEntity; -import net.sourceforge.plantuml.baraye.IGroup; -import net.sourceforge.plantuml.baraye.ILeaf; import net.sourceforge.plantuml.cucadiagram.entity.IEntityFactory; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -67,8 +63,8 @@ public class Link extends WithLinkType implements Hideable, Removeable { return styleBuilder; } - final private IEntity cl1; - final private IEntity cl2; + final private EntityImp cl1; + final private EntityImp cl2; private String port1; private String port2; @@ -113,7 +109,7 @@ public class Link extends WithLinkType implements Hideable, Removeable { return new UComment("link " + getEntity1().getCodeGetName() + " to " + getEntity2().getCodeGetName()); } - public Link(IEntityFactory entityFactory, StyleBuilder styleBuilder, IEntity cl1, IEntity cl2, LinkType type, + public Link(IEntityFactory entityFactory, StyleBuilder styleBuilder, EntityImp cl1, EntityImp cl2, LinkType type, LinkArg linkArg) { if (linkArg.getLength() < 1) throw new IllegalArgumentException(); @@ -177,7 +173,7 @@ public class Link extends WithLinkType implements Hideable, Removeable { this.invis = invis; } - public boolean isBetween(IEntity cl1, IEntity cl2) { + public boolean isBetween(EntityImp cl1, EntityImp cl2) { if (cl1.equals(this.cl1) && cl2.equals(this.cl2)) return true; @@ -192,31 +188,23 @@ public class Link extends WithLinkType implements Hideable, Removeable { return super.toString() + " {" + linkArg.getLength() + "} " + cl1 + "-->" + cl2; } - public SpecificBackcolorable getZEntity1() { + public EntityImp getEntity1() { return cl1; } - public SpecificBackcolorable getZEntity2() { - return cl2; - } - - public IEntity getEntity1() { - return cl1; - } - - public IEntity getEntity2() { + public EntityImp getEntity2() { return cl2; } public EntityPort getEntityPort1(Bibliotekon bibliotekon) { - return getEntityPort((ILeaf) cl1, port1, bibliotekon); + return getEntityPort(cl1, port1, bibliotekon); } public EntityPort getEntityPort2(Bibliotekon bibliotekon) { - return getEntityPort((ILeaf) cl2, port2, bibliotekon); + return getEntityPort(cl2, port2, bibliotekon); } - private EntityPort getEntityPort(ILeaf leaf, String port, Bibliotekon bibliotekon) { + private EntityPort getEntityPort(EntityImp leaf, String port, Bibliotekon bibliotekon) { if (leaf.getEntityPosition().usePortP()) return EntityPort.forPort(bibliotekon.getNodeUid(leaf)); return EntityPort.create(bibliotekon.getNodeUid(leaf), port); @@ -242,11 +230,11 @@ public class Link extends WithLinkType implements Hideable, Removeable { return result; } - private boolean isReallyGroup(IEntity ent) { + private boolean isReallyGroup(EntityImp ent) { if (ent.isGroup() == false) return false; - final IGroup group = (IGroup) ent; + final EntityImp group = (EntityImp) ent; return group.getChildren().size() + group.getLeafsDirect().size() > 0; } @@ -277,7 +265,7 @@ public class Link extends WithLinkType implements Hideable, Removeable { return result; } - private boolean isLollipopInterfaceEye(IEntity ent) { + private boolean isLollipopInterfaceEye(EntityImp ent) { return ent.getUSymbol() instanceof USymbolInterface; } @@ -342,7 +330,7 @@ public class Link extends WithLinkType implements Hideable, Removeable { return false; } - public boolean contains(IEntity entity) { + public boolean contains(EntityImp entity) { if (isSame(getEntity1(), entity)) return true; if (isSame(getEntity2(), entity)) @@ -351,17 +339,11 @@ public class Link extends WithLinkType implements Hideable, Removeable { return false; } - static private boolean isSame(IEntity a, IEntity b) { - if (a == b) - return true; - if (((EntityImp) a).getOriginalGroup() == b) - return true; - if (((EntityImp) b).getOriginalGroup() == a) - return true; - return false; + static private boolean isSame(EntityImp a, EntityImp b) { + return a == b; } - public IEntity getOther(IEntity entity) { + public EntityImp getOther(EntityImp entity) { if (isSame(getEntity1(), entity)) return getEntity2(); @@ -510,10 +492,10 @@ public class Link extends WithLinkType implements Hideable, Removeable { this.port1 = port1; this.port2 = port2; if (port1 != null) - ((ILeaf) cl1).addPortShortName(port1); + ((EntityImp) cl1).addPortShortName(port1); if (port2 != null) - ((ILeaf) cl2).addPortShortName(port2); + ((EntityImp) cl2).addPortShortName(port2); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/LinkType.java b/src/net/sourceforge/plantuml/cucadiagram/LinkType.java index ec8930d3d..92ce7b17e 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/LinkType.java +++ b/src/net/sourceforge/plantuml/cucadiagram/LinkType.java @@ -209,11 +209,15 @@ public class LinkType { || isOf(LinkDecor.REDEFINES); } + private boolean isExtendsOrPlus() { + return isExtends() || isPlus() || isOf(LinkDecor.DEFINEDBY) || isOf(LinkDecor.REDEFINES); + } + private boolean isOf(LinkDecor ld) { return decor1 == ld || decor2 == ld; } - private boolean isExtends() { + public boolean isExtends() { return decor1 == LinkDecor.EXTENDS || decor2 == LinkDecor.EXTENDS; } diff --git a/src/net/sourceforge/plantuml/cucadiagram/Magma.java b/src/net/sourceforge/plantuml/cucadiagram/Magma.java index 851b348eb..abab0a4be 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Magma.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Magma.java @@ -38,48 +38,47 @@ package net.sourceforge.plantuml.cucadiagram; import java.util.List; import net.sourceforge.plantuml.baraye.CucaDiagram; -import net.sourceforge.plantuml.baraye.IGroup; -import net.sourceforge.plantuml.baraye.ILeaf; +import net.sourceforge.plantuml.baraye.EntityImp; public class Magma { private final CucaDiagram diagram; - private final List standalones; + private final List standalones; private final LinkType linkType = new LinkType(LinkDecor.NONE, LinkDecor.NONE).getInvisible(); - public Magma(CucaDiagram system, List standalones) { + public Magma(CucaDiagram system, List standalones) { this.diagram = system; this.standalones = standalones; } public void putInSquare() { - final SquareLinker linker = new SquareLinker() { - public void topDown(ILeaf top, ILeaf down) { - diagram.addLink(new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), + final SquareLinker linker = new SquareLinker() { + public void topDown(EntityImp top, EntityImp down) { + diagram.addLink(new Link(diagram.getEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), top, down, linkType, LinkArg.noDisplay(2))); } - public void leftRight(ILeaf left, ILeaf right) { - diagram.addLink(new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), + public void leftRight(EntityImp left, EntityImp right) { + diagram.addLink(new Link(diagram.getEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), left, right, linkType, LinkArg.noDisplay(1))); } }; - new SquareMaker().putInSquare(standalones, linker); + new SquareMaker().putInSquare(standalones, linker); } - public IGroup getContainer() { - final IGroup parent = standalones.get(0).getParentContainer(); - if (parent == null) { + public EntityImp getContainer() { + final EntityImp parent = standalones.get(0).getParentContainer(); + if (parent == null) return null; - } + return parent.getParentContainer(); } public boolean isComplete() { - final IGroup parent = getContainer(); - if (parent == null) { + final EntityImp parent = getContainer(); + if (parent == null) return false; - } + return parent.size() == standalones.size(); } @@ -87,16 +86,16 @@ public class Magma { return SquareMaker.computeBranch(standalones.size()); } - private ILeaf getTopLeft() { + private EntityImp getTopLeft() { return standalones.get(0); } - private ILeaf getBottomLeft() { + private EntityImp getBottomLeft() { int result = SquareMaker.getBottomLeft(standalones.size()); return standalones.get(result); } - private ILeaf getTopRight() { + private EntityImp getTopRight() { final int s = squareSize(); return standalones.get(s - 1); } @@ -107,13 +106,13 @@ public class Magma { } public void linkToDown(Magma down) { - diagram.addLink(new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), + diagram.addLink(new Link(diagram.getEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), this.getBottomLeft(), down.getTopLeft(), linkType, LinkArg.noDisplay(2))); } public void linkToRight(Magma right) { - diagram.addLink(new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), + diagram.addLink(new Link(diagram.getEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), this.getTopRight(), right.getTopLeft(), linkType, LinkArg.noDisplay(1))); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/MagmaList.java b/src/net/sourceforge/plantuml/cucadiagram/MagmaList.java index b5a620e09..6d9ced036 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/MagmaList.java +++ b/src/net/sourceforge/plantuml/cucadiagram/MagmaList.java @@ -38,7 +38,7 @@ package net.sourceforge.plantuml.cucadiagram; import java.util.ArrayList; import java.util.List; -import net.sourceforge.plantuml.baraye.IGroup; +import net.sourceforge.plantuml.baraye.EntityImp; public class MagmaList { @@ -48,7 +48,7 @@ public class MagmaList { all.add(magma); } - public MagmaList getMagmas(IGroup group) { + public MagmaList getMagmas(EntityImp group) { final MagmaList result = new MagmaList(); for (Magma m : all) { if (m.getContainer() == group) { diff --git a/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java b/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java index 368dbbd95..7afbb29ae 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java +++ b/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java @@ -48,7 +48,7 @@ import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.awt.geom.XDimension2D; 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.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.FontConfiguration; @@ -88,14 +88,14 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlock, private final HorizontalAlignment align; private final List embeddeds = new ArrayList<>(); - private final ILeaf leaf; + private final EntityImp leaf; private final Style style; - public MethodsOrFieldsArea(Display members, ISkinParam skinParam, ILeaf leaf, Style style) { + public MethodsOrFieldsArea(Display members, ISkinParam skinParam, EntityImp leaf, Style style) { this(members, skinParam, HorizontalAlignment.LEFT, leaf, style); } - public MethodsOrFieldsArea(Display members, ISkinParam skinParam, HorizontalAlignment align, ILeaf leaf, + public MethodsOrFieldsArea(Display members, ISkinParam skinParam, HorizontalAlignment align, EntityImp leaf, Style style) { this.style = style; this.leaf = leaf; diff --git a/src/net/sourceforge/plantuml/cucadiagram/NamespaceStrategy.java b/src/net/sourceforge/plantuml/cucadiagram/NamespaceStrategy.java deleted file mode 100644 index 1de39df08..000000000 --- a/src/net/sourceforge/plantuml/cucadiagram/NamespaceStrategy.java +++ /dev/null @@ -1,42 +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; - -public enum NamespaceStrategy { - - SINGLE, MULTIPLE; - -} diff --git a/src/net/sourceforge/plantuml/cucadiagram/PortionShower.java b/src/net/sourceforge/plantuml/cucadiagram/PortionShower.java index 395d16e16..398f66a99 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/PortionShower.java +++ b/src/net/sourceforge/plantuml/cucadiagram/PortionShower.java @@ -35,9 +35,9 @@ */ package net.sourceforge.plantuml.cucadiagram; -import net.sourceforge.plantuml.baraye.IEntity; +import net.sourceforge.plantuml.baraye.EntityImp; public interface PortionShower { - boolean showPortion(EntityPortion portion, IEntity entity); + boolean showPortion(EntityPortion portion, EntityImp entity); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/AbstractGraphviz.java b/src/net/sourceforge/plantuml/cucadiagram/dot/AbstractGraphviz.java index 113d947df..7ac9f561a 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/AbstractGraphviz.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/AbstractGraphviz.java @@ -49,6 +49,7 @@ import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.utils.Log; abstract class AbstractGraphviz implements Graphviz { + // ::remove file when WASM private final File dotExe; private final String dotString; @@ -76,7 +77,7 @@ abstract class AbstractGraphviz implements Graphviz { this.dotString = dotString; this.type = Objects.requireNonNull(type); } - + protected boolean findExecutableOnPath() { return true; } diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramSimplifierActivity.java b/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramSimplifierActivity.java index bf9420ef6..c2988d307 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramSimplifierActivity.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramSimplifierActivity.java @@ -40,7 +40,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import net.sourceforge.plantuml.baraye.IGroup; +import net.sourceforge.plantuml.baraye.EntityImp; import net.sourceforge.plantuml.cucadiagram.ICucaDiagram; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.graphic.StringBounder; @@ -59,8 +59,8 @@ public final class CucaDiagramSimplifierActivity { boolean changed; do { changed = false; - final Collection groups = new ArrayList<>(diagram.getGroups(false)); - for (IGroup g : groups) { + final Collection groups = new ArrayList<>(diagram.getGroups(false)); + for (EntityImp g : groups) { if (diagram.isAutarkic(g)) { // final EntityType type; // if (g.zgetGroupType() == GroupType.INNER_ACTIVITY) { @@ -86,7 +86,7 @@ public final class CucaDiagramSimplifierActivity { // proxy.setSvekImage(maker.getImage()); // } - private IEntityImage computeImage(IGroup g) throws IOException, InterruptedException { + private IEntityImage computeImage(EntityImp g) throws IOException, InterruptedException { final GroupPngMakerActivity maker = new GroupPngMakerActivity(diagram, g, stringBounder); return maker.getImage(); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramSimplifierState.java b/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramSimplifierState.java index 13476d2b7..e329a64fc 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramSimplifierState.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramSimplifierState.java @@ -41,8 +41,7 @@ import java.util.Collection; import java.util.LinkedHashSet; import java.util.List; -import net.sourceforge.plantuml.baraye.IGroup; -import net.sourceforge.plantuml.cucadiagram.GroupRoot; +import net.sourceforge.plantuml.baraye.EntityImp; import net.sourceforge.plantuml.cucadiagram.GroupType; import net.sourceforge.plantuml.cucadiagram.ICucaDiagram; import net.sourceforge.plantuml.cucadiagram.LeafType; @@ -62,8 +61,8 @@ public final class CucaDiagramSimplifierState { boolean changed; do { changed = false; - final Collection groups = getOrdered(diagram.getRootGroup()); - for (IGroup g : groups) { + final Collection groups = getOrdered(diagram.getRootGroup()); + for (EntityImp g : groups) if (diagram.isAutarkic(g)) { final IEntityImage img = computeImage(g); g.overrideImage(img, g.getGroupType() == GroupType.CONCURRENT_STATE ? LeafType.STATE_CONCURRENT @@ -71,47 +70,45 @@ public final class CucaDiagramSimplifierState { changed = true; } - } + } while (changed); } - private Collection getOrdered(IGroup root) { - final Collection ordered = new LinkedHashSet<>(); + private Collection getOrdered(EntityImp root) { + final Collection ordered = new LinkedHashSet<>(); ordered.add(root); int size = 1; while (true) { size = ordered.size(); addOneLevel(ordered); - if (size == ordered.size()) { + if (size == ordered.size()) break; - } + } - final List result = new ArrayList<>(); - for (IGroup g : ordered) { - if (g instanceof GroupRoot == false) { + final List result = new ArrayList<>(); + for (EntityImp g : ordered) + if (g.instanceofGroupRoot() == false) result.add(0, g); - } - } + return result; } - private void addOneLevel(Collection currents) { - for (IGroup g : new ArrayList<>(currents)) { - for (IGroup child : reverse(g.getChildren())) { + private void addOneLevel(Collection currents) { + for (EntityImp g : new ArrayList<>(currents)) + for (EntityImp child : reverse(g.getChildren())) currents.add(child); - } - } + } - private List reverse(Collection source) { - final List result = new ArrayList<>(); - for (IGroup g : source) { + private List reverse(Collection source) { + final List result = new ArrayList<>(); + for (EntityImp g : source) result.add(0, g); - } + return result; } - private IEntityImage computeImage(IGroup g) throws IOException, InterruptedException { + private IEntityImage computeImage(EntityImp g) throws IOException, InterruptedException { final GroupPngMakerState maker = new GroupPngMakerState(diagram, g, stringBounder); return maker.getImage(); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramTxtMaker.java b/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramTxtMaker.java index d048ff770..3fb48311e 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramTxtMaker.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramTxtMaker.java @@ -50,7 +50,7 @@ import net.sourceforge.plantuml.BackSlash; import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.awt.geom.XPoint2D; -import net.sourceforge.plantuml.baraye.IEntity; +import net.sourceforge.plantuml.baraye.EntityImp; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.EntityPortion; import net.sourceforge.plantuml.cucadiagram.ICucaDiagram; @@ -66,6 +66,7 @@ import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt; public final class CucaDiagramTxtMaker { + // ::remove file when WASM // private final CucaDiagram diagram; private final FileFormat fileFormat; @@ -80,7 +81,7 @@ public final class CucaDiagramTxtMaker { return 10; } - private boolean showMember(IEntity entity) { + private boolean showMember(EntityImp entity) { final boolean showMethods = portionShower.showPortion(EntityPortion.METHOD, entity); final boolean showFields = portionShower.showPortion(EntityPortion.FIELD, entity); return showMethods || showFields; @@ -93,9 +94,9 @@ public final class CucaDiagramTxtMaker { final Cluster root = new Cluster(null, 0, 0); int uid = 0; - final Map blocks = new HashMap(); + final Map blocks = new HashMap(); - for (IEntity ent : diagram.getLeafsvalues()) { + for (EntityImp ent : diagram.getLeafsvalues()) { // printClass(ent); // ug.translate(0, getHeight(ent) + 1); final double width = getWidth(ent) * getXPixelPerChar(); @@ -120,7 +121,7 @@ public final class CucaDiagramTxtMaker { } p.getDotPath().draw(globalUg.getCharArea(), getXPixelPerChar(), getYPixelPerChar()); } - for (IEntity ent : diagram.getLeafsvalues()) { + for (EntityImp ent : diagram.getLeafsvalues()) { final Block b = blocks.get(ent); final XPoint2D p = b.getPosition(); printClass(ent, (UGraphicTxt) globalUg @@ -129,7 +130,7 @@ public final class CucaDiagramTxtMaker { } - private void printClass(final IEntity ent, UGraphicTxt ug) { + private void printClass(final EntityImp ent, UGraphicTxt ug) { final int w = getWidth(ent); final int h = getHeight(ent); ug.getCharArea().drawBoxSimple(0, 0, w, h); @@ -167,7 +168,7 @@ public final class CucaDiagramTxtMaker { return Collections.singletonList(suggestedFile); } - private int getHeight(IEntity entity) { + private int getHeight(EntityImp entity) { int result = StringUtils.getHeight(entity.getDisplay()); if (showMember(entity)) { for (CharSequence att : entity.getBodier().getRawBody()) { @@ -185,7 +186,7 @@ public final class CucaDiagramTxtMaker { return result + 3; } - private int getWidth(IEntity entity) { + private int getWidth(EntityImp entity) { int result = StringUtils.getWcWidth(entity.getDisplay()); if (showMember(entity)) { for (CharSequence att : entity.getBodier().getRawBody()) { diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/DebugTrace.java b/src/net/sourceforge/plantuml/cucadiagram/dot/DebugTrace.java index 9dc468758..ceea6b325 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/DebugTrace.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/DebugTrace.java @@ -41,6 +41,7 @@ import java.io.PrintWriter; import net.sourceforge.plantuml.security.SFile; public class DebugTrace { + // ::remove file when WASM private static final SFile out = new SFile("debug" + System.currentTimeMillis() + ".txt"); diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/DotData.java b/src/net/sourceforge/plantuml/cucadiagram/dot/DotData.java index 2bbda7e73..f038b84d2 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/DotData.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/DotData.java @@ -47,9 +47,7 @@ import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.Pragma; import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.baraye.EntityFactory; -import net.sourceforge.plantuml.baraye.IEntity; -import net.sourceforge.plantuml.baraye.IGroup; -import net.sourceforge.plantuml.baraye.ILeaf; +import net.sourceforge.plantuml.baraye.EntityImp; import net.sourceforge.plantuml.cucadiagram.EntityPortion; import net.sourceforge.plantuml.cucadiagram.GroupHierarchy; import net.sourceforge.plantuml.cucadiagram.Link; @@ -59,12 +57,12 @@ import net.sourceforge.plantuml.svek.DotMode; final public class DotData implements PortionShower { final private List links; - final private Collection leafs; + final private Collection leafs; final private UmlDiagramType umlDiagramType; final private ISkinParam skinParam; // final private Rankdir rankdir; final private GroupHierarchy groupHierarchy; - final private IGroup topParent; + final private EntityImp topParent; final private PortionShower portionShower; final private boolean isHideEmptyDescriptionForState; final private DotMode dotMode; @@ -77,7 +75,7 @@ final public class DotData implements PortionShower { return entityFactory; } - public DotData(IGroup topParent, List links, Collection leafs, UmlDiagramType umlDiagramType, + public DotData(EntityImp topParent, List links, Collection leafs, UmlDiagramType umlDiagramType, ISkinParam skinParam, GroupHierarchy groupHierarchy, PortionShower portionShower, EntityFactory entityFactory, boolean isHideEmptyDescriptionForState, DotMode dotMode, String namespaceSeparator, Pragma pragma) { @@ -96,11 +94,11 @@ final public class DotData implements PortionShower { this.entityFactory = entityFactory; } - public DotData(IGroup topParent, List links, Collection leafs, UmlDiagramType umlDiagramType, + public DotData(EntityImp topParent, List links, Collection leafs, UmlDiagramType umlDiagramType, ISkinParam skinParam, GroupHierarchy groupHierarchy, EntityFactory entityFactory, boolean isHideEmptyDescriptionForState, DotMode dotMode, String namespaceSeparator, Pragma pragma) { this(topParent, links, leafs, umlDiagramType, skinParam, groupHierarchy, new PortionShower() { - public boolean showPortion(EntityPortion portion, IEntity entity) { + public boolean showPortion(EntityPortion portion, EntityImp entity) { return true; } }, entityFactory, isHideEmptyDescriptionForState, dotMode, namespaceSeparator, pragma); @@ -122,23 +120,23 @@ final public class DotData implements PortionShower { return links; } - public Collection getLeafs() { + public Collection getLeafs() { return leafs; } - public final IGroup getTopParent() { + public final EntityImp getTopParent() { return topParent; } - public boolean isEmpty(IGroup g) { + public boolean isEmpty(EntityImp g) { return groupHierarchy.isEmpty(g); } - public boolean showPortion(EntityPortion portion, IEntity entity) { + public boolean showPortion(EntityPortion portion, EntityImp entity) { return portionShower.showPortion(portion, entity); } - public IGroup getRootGroup() { + public EntityImp getRootGroup() { return entityFactory.getRootGroup(); } @@ -188,7 +186,7 @@ final public class DotData implements PortionShower { some.add(link); } } - final ILeaf leaf = getLeaf(key); + final EntityImp leaf = getLeaf(key); final Neighborhood neighborhood = new Neighborhood(leaf, some, getLinksOfThisLeaf(leaf)); leaf.setNeighborhood(neighborhood); } @@ -205,7 +203,7 @@ final public class DotData implements PortionShower { } } - private List getLinksOfThisLeaf(ILeaf leaf) { + private List getLinksOfThisLeaf(EntityImp leaf) { final List result = new ArrayList<>(); for (Link link : links) { if (link.contains(leaf)) { @@ -215,8 +213,8 @@ final public class DotData implements PortionShower { return result; } - private ILeaf getLeaf(String key) { - for (ILeaf entity : leafs) { + private EntityImp getLeaf(String key) { + for (EntityImp entity : leafs) { if (entity.getUid().equals(key)) { return entity; } diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/DotMaker2.java b/src/net/sourceforge/plantuml/cucadiagram/dot/DotMaker2.java index 9fac5410c..9f0f5c3cd 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/DotMaker2.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/DotMaker2.java @@ -36,6 +36,7 @@ package net.sourceforge.plantuml.cucadiagram.dot; final public class DotMaker2 { + // ::remove file when WASM private static boolean isJunit = false; diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/ExeState.java b/src/net/sourceforge/plantuml/cucadiagram/dot/ExeState.java index 628142b5d..bd6c4f806 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/ExeState.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/ExeState.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.cucadiagram.dot; import java.io.File; public enum ExeState { + // ::remove file when WASM NULL_UNDEFINED, OK, DOES_NOT_EXIST, IS_A_DIRECTORY, NOT_A_FILE, CANNOT_BE_READ; diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/Graphviz.java b/src/net/sourceforge/plantuml/cucadiagram/dot/Graphviz.java index 2a4fcb2e3..40b84eb50 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/Graphviz.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/Graphviz.java @@ -39,6 +39,7 @@ import java.io.File; import java.io.OutputStream; public interface Graphviz { + // ::remove file when WASM public ProcessState createFile3(OutputStream os); diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizLinux.java b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizLinux.java index c1c1a0ff2..7ba1cfe57 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizLinux.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizLinux.java @@ -40,6 +40,7 @@ import java.io.File; import net.sourceforge.plantuml.ISkinParam; class GraphvizLinux extends AbstractGraphviz { + // ::remove file when WASM GraphvizLinux(ISkinParam skinParam, String dotString, String... type) { super(skinParam, dotString, type); diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizUtils.java b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizUtils.java index f5dd1f12c..f74ef98ea 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizUtils.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizUtils.java @@ -53,6 +53,7 @@ import net.sourceforge.plantuml.vizjs.GraphvizJs; import net.sourceforge.plantuml.vizjs.VizJsEngine; public class GraphvizUtils { + // :: remove file when WASM public static final String VIZJS = "vizjs"; private static int DOT_VERSION_LIMIT = 226; diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersion.java b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersion.java index 410573910..06ee93e20 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersion.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersion.java @@ -36,6 +36,7 @@ package net.sourceforge.plantuml.cucadiagram.dot; public interface GraphvizVersion { + // ::comment when WASM public boolean useShieldForQuantifier(); public boolean useProtectionWhenThereALinkFromOrToGroup(); @@ -43,7 +44,8 @@ public interface GraphvizVersion { public boolean useXLabelInsteadOfLabel(); public boolean isVizjs(); - + public boolean ignoreHorizontalLinks(); + // ::done } diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersionFinder.java b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersionFinder.java index c3dfde9b8..cf832e840 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersionFinder.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersionFinder.java @@ -42,6 +42,7 @@ import java.util.regex.Pattern; import net.sourceforge.plantuml.StringUtils; public class GraphvizVersionFinder { + // ::remove file when WASM final private File dotExe; final public static GraphvizVersion DEFAULT = new GraphvizVersion() { diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersions.java b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersions.java index acf5ae523..6cfbf155b 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersions.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersions.java @@ -40,6 +40,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class GraphvizVersions { + // ::remove file when WASM private final static GraphvizVersions singleton = new GraphvizVersions(); diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizWindowsLite.java b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizWindowsLite.java index 71e65adae..ca7e993c6 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizWindowsLite.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizWindowsLite.java @@ -41,6 +41,7 @@ import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.windowsdot.WindowsDotArchive; class GraphvizWindowsLite extends AbstractGraphviz { + // ::remove file when WASM static private File specificDotExe; diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizWindowsOld.java b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizWindowsOld.java index 744282e6d..d659e36db 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizWindowsOld.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizWindowsOld.java @@ -47,6 +47,7 @@ import net.sourceforge.plantuml.log.Logme; import net.sourceforge.plantuml.windowsdot.WindowsDotArchive; class GraphvizWindowsOld extends AbstractGraphviz { + // ::remove file when WASM static private File specificDotExe; diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/Neighborhood.java b/src/net/sourceforge/plantuml/cucadiagram/dot/Neighborhood.java index 9ee26a699..8a39d9b34 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/Neighborhood.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/Neighborhood.java @@ -43,7 +43,7 @@ import java.util.Set; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XPoint2D; import net.sourceforge.plantuml.awt.geom.XRectangle2D; -import net.sourceforge.plantuml.baraye.ILeaf; +import net.sourceforge.plantuml.baraye.EntityImp; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.svek.Bibliotekon; import net.sourceforge.plantuml.svek.SvekLine; @@ -54,11 +54,11 @@ import net.sourceforge.plantuml.ugraphic.UTranslate; public class Neighborhood { - private final ILeaf leaf; + private final EntityImp leaf; private final List sametailLinks; private final List allButSametails; - public Neighborhood(ILeaf leaf, List sametailLinks, List all) { + public Neighborhood(EntityImp leaf, List sametailLinks, List all) { this.leaf = leaf; this.sametailLinks = sametailLinks; this.allButSametails = new ArrayList<>(all); diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/ProcessRunner.java b/src/net/sourceforge/plantuml/cucadiagram/dot/ProcessRunner.java index 0ab967ec7..c29978f6c 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/ProcessRunner.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/ProcessRunner.java @@ -48,6 +48,7 @@ import net.sourceforge.plantuml.log.Logme; import net.sourceforge.plantuml.security.SFile; public class ProcessRunner { + // ::remove file when WASM private final String[] cmd; diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/ProcessState.java b/src/net/sourceforge/plantuml/cucadiagram/dot/ProcessState.java index c5a71f019..ecc38e45d 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/ProcessState.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/ProcessState.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.cucadiagram.dot; import java.io.IOException; public class ProcessState { + // ::remove file when WASM private final String name; private final IOException cause; diff --git a/src/net/sourceforge/plantuml/cucadiagram/entity/IEntityFactory.java b/src/net/sourceforge/plantuml/cucadiagram/entity/IEntityFactory.java index 7885a8b2b..80d269b5c 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/entity/IEntityFactory.java +++ b/src/net/sourceforge/plantuml/cucadiagram/entity/IEntityFactory.java @@ -37,13 +37,13 @@ package net.sourceforge.plantuml.cucadiagram.entity; import java.util.Collection; -import net.sourceforge.plantuml.baraye.ILeaf; +import net.sourceforge.plantuml.baraye.EntityImp; import net.sourceforge.plantuml.cucadiagram.Stereotype; public interface IEntityFactory { public boolean isRemoved(Stereotype stereotype); - public Collection leafs(); + public Collection leafs(); } diff --git a/src/net/sourceforge/plantuml/definition/PSystemDefinition.java b/src/net/sourceforge/plantuml/definition/PSystemDefinition.java index f54a60ca2..4e7d2de96 100644 --- a/src/net/sourceforge/plantuml/definition/PSystemDefinition.java +++ b/src/net/sourceforge/plantuml/definition/PSystemDefinition.java @@ -53,6 +53,7 @@ import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.color.HColors; public class PSystemDefinition extends PlainDiagram implements UDrawable { + // ::remove folder when WASM private final List lines = new ArrayList<>(); private final String startLine; diff --git a/src/net/sourceforge/plantuml/descdiagram/CommandCreateDomain.java b/src/net/sourceforge/plantuml/descdiagram/CommandCreateDomain.java index 44e694c11..a272e0f74 100644 --- a/src/net/sourceforge/plantuml/descdiagram/CommandCreateDomain.java +++ b/src/net/sourceforge/plantuml/descdiagram/CommandCreateDomain.java @@ -39,8 +39,8 @@ import net.sourceforge.plantuml.FontParam; 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.baraye.IGroup; +import net.sourceforge.plantuml.baraye.EntityImp; +import net.sourceforge.plantuml.baraye.Quark; import net.sourceforge.plantuml.classdiagram.command.GenericRegexProducer; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; @@ -48,12 +48,9 @@ import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; -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.NamespaceStrategy; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.graphic.USymbols; @@ -87,36 +84,37 @@ public class CommandCreateDomain extends SingleLineCommand2 @Override protected CommandExecutionResult executeArg(DescriptionDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { - String type = arg.get("TYPE", 0); - String display = arg.getLazzy("DISPLAY", 0); + String typeString = arg.get("TYPE", 0); + String displayString = arg.getLazzy("DISPLAY", 0); String codeString = arg.getLazzy("CODE", 0); if (codeString == null) - codeString = display; + codeString = displayString; // final String genericOption = arg.getLazzy("DISPLAY", 1); // final String generic = genericOption != null ? genericOption : // arg.get("GENERIC", 0); final String stereotype = arg.get("STEREO", 0); + final GroupType type = typeString.equalsIgnoreCase("domain") ? GroupType.DOMAIN : GroupType.REQUIREMENT; + final LeafType type2 = typeString.equalsIgnoreCase("domain") ? LeafType.DOMAIN : LeafType.REQUIREMENT; - final Ident ident = diagram.buildLeafIdent(codeString); - final Code code = diagram.buildCode(codeString); - if (diagram.leafExist(code)) + final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(codeString), false); + +// final Quark ident = diagram.buildFromName(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeString)); +// final Quark code = diagram.buildFromFullPath(codeString); + if (quark.getData() != null) return CommandExecutionResult.error("Object already exists : " + codeString); - Display d = Display.getWithNewlines(display); + Display display = Display.getWithNewlines(displayString); final String urlString = arg.get("URL", 0); final String group = arg.get("GROUP", 0); - IEntity entity; + EntityImp entity; if (group != null) { - final IGroup currentGroup = diagram.getCurrentGroup(); - diagram.gotoGroup(ident, code, d, - type.equalsIgnoreCase("domain") ? GroupType.DOMAIN : GroupType.REQUIREMENT, currentGroup, - NamespaceStrategy.SINGLE); + final EntityImp currentGroup = diagram.getCurrentGroup(); + diagram.gotoGroup(quark, display, type); entity = diagram.getCurrentGroup(); } else { - entity = diagram.createLeaf(ident, code, d, - type.equalsIgnoreCase("domain") ? LeafType.DOMAIN : LeafType.REQUIREMENT, null); + entity = diagram.reallyCreateLeaf(quark, display, type2, null); } if (stereotype != null) { entity.setStereotype(Stereotype.build(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), @@ -131,24 +129,24 @@ public class CommandCreateDomain extends SingleLineCommand2 final String s = arg.get("COLOR", 0); entity.setSpecificColorTOBEREMOVED(ColorType.BACK, s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s)); - if (type.equalsIgnoreCase("domain")) { + if (typeString.equalsIgnoreCase("domain")) { if (stereotype != null && stereotype.equalsIgnoreCase("<>")) - type = "machine"; + typeString = "machine"; if (stereotype != null && stereotype.equalsIgnoreCase("<>")) - type = "causal"; + typeString = "causal"; if (stereotype != null && stereotype.equalsIgnoreCase("<>")) - type = "designed"; + typeString = "designed"; if (stereotype != null && stereotype.equalsIgnoreCase("<>")) - type = "lexical"; + typeString = "lexical"; if (stereotype != null && stereotype.equalsIgnoreCase("<>")) - type = "biddable"; + typeString = "biddable"; } - USymbol usymbol = USymbols.fromString(type, diagram.getSkinParam()); + USymbol usymbol = USymbols.fromString(typeString, diagram.getSkinParam()); entity.setUSymbol(usymbol); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/descdiagram/DescriptionDiagram.java b/src/net/sourceforge/plantuml/descdiagram/DescriptionDiagram.java index 7a7e2a384..48f7cf2be 100644 --- a/src/net/sourceforge/plantuml/descdiagram/DescriptionDiagram.java +++ b/src/net/sourceforge/plantuml/descdiagram/DescriptionDiagram.java @@ -36,15 +36,12 @@ package net.sourceforge.plantuml.descdiagram; import java.util.Map; -import java.util.Objects; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.UmlDiagramType; -import net.sourceforge.plantuml.baraye.ILeaf; +import net.sourceforge.plantuml.baraye.EntityImp; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; 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; import net.sourceforge.plantuml.graphic.USymbols; @@ -55,55 +52,76 @@ public class DescriptionDiagram extends AbstractEntityDiagram { super(source, UmlDiagramType.DESCRIPTION, skinParam); } - @Override - public Ident cleanIdent(Ident ident) { - String codeString = ident.getName(); - if (codeString.startsWith("[") && codeString.endsWith("]")) { - return ident.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:"); - } - if (codeString.startsWith(":") && codeString.endsWith(":")) { - return ident.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:"); - } - if (codeString.startsWith("()")) { - codeString = StringUtils.trin(codeString.substring(2)); - codeString = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeString); - return ident.parent().add(Ident.empty().add(codeString, null)); - } - return ident; - } +// @Override +// public Ident cleanIdent(Ident ident) { +// String codeString = ident.getName(); +// if (codeString.startsWith("[") && codeString.endsWith("]")) { +// return ident.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:"); +// } +// if (codeString.startsWith(":") && codeString.endsWith(":")) { +// return ident.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:"); +// } +// if (codeString.startsWith("()")) { +// codeString = StringUtils.trin(codeString.substring(2)); +// codeString = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeString); +// return ident.parent().add(Ident.empty().add(codeString, null)); +// } +// return ident; +// } @Override - public ILeaf getOrCreateLeaf(Ident ident, Code code, LeafType type, USymbol symbol) { - Objects.requireNonNull(ident); - if (type == null) { - String codeString = code.getName(); - if (codeString.startsWith("[") && codeString.endsWith("]")) { - final USymbol sym = getSkinParam().componentStyle().toUSymbol(); - final Ident idNewLong = ident.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:"); - return getOrCreateLeafDefault(idNewLong, idNewLong.toCode(this), LeafType.DESCRIPTION, sym); - } - if (codeString.startsWith(":") && codeString.endsWith(":")) { - final Ident idNewLong = ident.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:"); - return getOrCreateLeafDefault(idNewLong, idNewLong.toCode(this), LeafType.DESCRIPTION, - getSkinParam().actorStyle().toUSymbol()); - } - if (codeString.startsWith("()")) { - codeString = StringUtils.trin(codeString.substring(2)); - codeString = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeString); - final Ident idNewLong = buildLeafIdent(codeString); - final Code code99 = buildCode(codeString); - return getOrCreateLeafDefault(idNewLong, code99, LeafType.DESCRIPTION, USymbols.INTERFACE); - } - final String tmp4 = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(code.getName(), "\"([:"); - final Ident idNewLong = ident.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:"); - code = buildCode(tmp4); - return getOrCreateLeafDefault(idNewLong, code, LeafType.STILL_UNKNOWN, symbol); - } - return getOrCreateLeafDefault(ident, code, type, symbol); + public String cleanIdForQuark(String id) { + if (id == null) + return null; + if (id.startsWith("()")) + id = StringUtils.trin(id.substring(2)); + return super.cleanIdForQuark(id); } +// @Override +// protected ILeaf getOrCreateLeaf2(Quark ident, Quark code, LeafType type, USymbol symbol) { +// Objects.requireNonNull(ident); +// if (type == null) { +// String codeString = code.getName(); +// if (codeString.startsWith("[") && codeString.endsWith("]")) { +// final USymbol sym = getSkinParam().componentStyle().toUSymbol(); +// final Quark idNewLong = ident.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:"); +// if (idNewLong.getData() != null) +// return (ILeaf) idNewLong.getData(); +// return reallyCreateLeaf(idNewLong, Display.getWithNewlines(idNewLong.getName()), LeafType.DESCRIPTION, +// sym); +// } +// if (codeString.startsWith(":") && codeString.endsWith(":")) { +// final Quark idNewLong = ident.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:"); +// if (idNewLong.getData() != null) +// return (ILeaf) idNewLong.getData(); +// return reallyCreateLeaf(idNewLong, Display.getWithNewlines(idNewLong.getName()), LeafType.DESCRIPTION, +// getSkinParam().actorStyle().toUSymbol()); +// } +// if (codeString.startsWith("()")) { +// codeString = StringUtils.trin(codeString.substring(2)); +// codeString = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeString); +// final Quark idNewLong = buildFromName( +// StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeString)); +// if (idNewLong.getData() != null) +// return (ILeaf) idNewLong.getData(); +// return reallyCreateLeaf(idNewLong, Display.getWithNewlines(codeString), LeafType.DESCRIPTION, +// USymbols.INTERFACE); +// } +// final String tmp4 = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(code.getName(), "\"([:"); +// final Quark idNewLong = ident.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:"); +// code = buildFromFullPath(tmp4); +// if (idNewLong.getData() != null) +// return (ILeaf) idNewLong.getData(); +// return reallyCreateLeaf(idNewLong, Display.getWithNewlines(tmp4), LeafType.STILL_UNKNOWN, symbol); +// } +// if (ident.getData() != null) +// return (ILeaf) ident.getData(); +// return reallyCreateLeaf(ident, Display.getWithNewlines(code.getName()), type, symbol); +// } + private boolean isUsecase() { - for (ILeaf leaf : getLeafsvalues()) { + for (EntityImp leaf : getLeafsvalues()) { final LeafType type = leaf.getLeafType(); final USymbol usymbol = leaf.getUSymbol(); if (type == LeafType.USECASE || usymbol == getSkinParam().actorStyle().toUSymbol()) { @@ -118,7 +136,7 @@ public class DescriptionDiagram extends AbstractEntityDiagram { super.makeDiagramReady(); final LeafType defaultType = LeafType.DESCRIPTION; final USymbol defaultSymbol = isUsecase() ? getSkinParam().actorStyle().toUSymbol() : USymbols.INTERFACE; - for (ILeaf leaf : getLeafsvalues()) { + for (EntityImp leaf : getLeafsvalues()) { if (leaf.getLeafType() == LeafType.STILL_UNKNOWN) { leaf.muteToType(defaultType, defaultSymbol); } diff --git a/src/net/sourceforge/plantuml/descdiagram/EntityImageDesignedDomain.java b/src/net/sourceforge/plantuml/descdiagram/EntityImageDesignedDomain.java index 73af15874..928fcbebd 100644 --- a/src/net/sourceforge/plantuml/descdiagram/EntityImageDesignedDomain.java +++ b/src/net/sourceforge/plantuml/descdiagram/EntityImageDesignedDomain.java @@ -43,7 +43,7 @@ import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.awt.geom.XDimension2D; -import net.sourceforge.plantuml.baraye.ILeaf; +import net.sourceforge.plantuml.baraye.EntityImp; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.FontConfiguration; @@ -67,7 +67,7 @@ public class EntityImageDesignedDomain extends AbstractEntityImage { final private TextBlock stereo; final private Url url; - public EntityImageDesignedDomain(ILeaf entity, ISkinParam skinParam) { + public EntityImageDesignedDomain(EntityImp entity, ISkinParam skinParam) { super(entity, skinParam); final Stereotype stereotype = entity.getStereotype(); this.name = TextBlockUtils.withMargin( diff --git a/src/net/sourceforge/plantuml/descdiagram/EntityImageDomain.java b/src/net/sourceforge/plantuml/descdiagram/EntityImageDomain.java index d261c8f76..d94012815 100644 --- a/src/net/sourceforge/plantuml/descdiagram/EntityImageDomain.java +++ b/src/net/sourceforge/plantuml/descdiagram/EntityImageDomain.java @@ -43,7 +43,7 @@ import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.awt.geom.XDimension2D; -import net.sourceforge.plantuml.baraye.ILeaf; +import net.sourceforge.plantuml.baraye.EntityImp; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.FontConfiguration; @@ -69,7 +69,7 @@ public class EntityImageDomain extends AbstractEntityImage { final private TextBlock stereo; final private Url url; - public EntityImageDomain(ILeaf entity, ISkinParam skinParam, char typeLetter) { + public EntityImageDomain(EntityImp entity, ISkinParam skinParam, char typeLetter) { super(entity, skinParam); final Stereotype stereotype = entity.getStereotype(); FontConfiguration fc = FontConfiguration.create(getSkinParam(), FontParam.DESIGNED_DOMAIN, stereotype); diff --git a/src/net/sourceforge/plantuml/descdiagram/EntityImageMachine.java b/src/net/sourceforge/plantuml/descdiagram/EntityImageMachine.java index 1fc8f9f42..aa3150f29 100644 --- a/src/net/sourceforge/plantuml/descdiagram/EntityImageMachine.java +++ b/src/net/sourceforge/plantuml/descdiagram/EntityImageMachine.java @@ -43,7 +43,7 @@ import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.awt.geom.XDimension2D; -import net.sourceforge.plantuml.baraye.ILeaf; +import net.sourceforge.plantuml.baraye.EntityImp; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.FontConfiguration; @@ -67,7 +67,7 @@ public class EntityImageMachine extends AbstractEntityImage { final private TextBlock stereo; final private Url url; - public EntityImageMachine(ILeaf entity, ISkinParam skinParam) { + public EntityImageMachine(EntityImp entity, ISkinParam skinParam) { super(entity, skinParam); final Stereotype stereotype = entity.getStereotype(); this.name = TextBlockUtils.withMargin( diff --git a/src/net/sourceforge/plantuml/descdiagram/EntityImageRequirement.java b/src/net/sourceforge/plantuml/descdiagram/EntityImageRequirement.java index f938c2b61..1ed4985ca 100644 --- a/src/net/sourceforge/plantuml/descdiagram/EntityImageRequirement.java +++ b/src/net/sourceforge/plantuml/descdiagram/EntityImageRequirement.java @@ -43,7 +43,7 @@ import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.awt.geom.XDimension2D; -import net.sourceforge.plantuml.baraye.ILeaf; +import net.sourceforge.plantuml.baraye.EntityImp; import net.sourceforge.plantuml.creole.Stencil; import net.sourceforge.plantuml.cucadiagram.BodyFactory; import net.sourceforge.plantuml.cucadiagram.Display; @@ -74,7 +74,7 @@ public class EntityImageRequirement extends AbstractEntityImage { final private Url url; - public EntityImageRequirement(ILeaf entity, ISkinParam skinParam) { + public EntityImageRequirement(EntityImp entity, ISkinParam skinParam) { super(entity, skinParam); final Stereotype stereotype = entity.getStereotype(); diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimate.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimate.java index 6b2cc0b7a..ba0d8fda3 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimate.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimate.java @@ -37,7 +37,8 @@ package net.sourceforge.plantuml.descdiagram.command; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.StringUtils; -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.SingleLineCommand2; import net.sourceforge.plantuml.command.regex.IRegex; @@ -46,9 +47,7 @@ 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.LeafType; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.descdiagram.DescriptionDiagram; @@ -124,20 +123,21 @@ public class CommandArchimate extends SingleLineCommand2 { throws NoSuchColorException { final String codeRaw = arg.getLazzy("CODE", 0); - final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeRaw); - final Ident ident = diagram.buildLeafIdent(idShort); - final Code code = diagram.buildCode(idShort); - final String icon = arg.getLazzy("STEREOTYPE", 0); +// final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeRaw); +// final Quark ident = diagram.buildFromName(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(idShort)); +// final Quark code = diagram.buildFromFullPath(idShort); + final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(codeRaw), false); - final IEntity entity = diagram.getOrCreateLeaf(ident, code, LeafType.DESCRIPTION, USymbols.ARCHIMATE); - - final String displayRaw = arg.getLazzy("DISPLAY", 0); - - String display = displayRaw; + String display = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.getLazzy("DISPLAY", 0)); if (display == null) - display = code.getName(); + display = quark.getName(); - display = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(display); + EntityImp entity = (EntityImp) quark.getData(); + if (entity == null) + entity = diagram.reallyCreateLeaf(quark, Display.getWithNewlines(display), LeafType.DESCRIPTION, + USymbols.ARCHIMATE); + + final String icon = arg.getLazzy("STEREOTYPE", 0); entity.setDisplay(Display.getWithNewlines(display)); entity.setUSymbol(USymbols.ARCHIMATE); diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimateMultilines.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimateMultilines.java index 42c1bb030..d9e7ff9fe 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimateMultilines.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimateMultilines.java @@ -36,9 +36,9 @@ package net.sourceforge.plantuml.descdiagram.command; import net.sourceforge.plantuml.FontParam; -import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.UrlBuilder; -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.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandMultilines2; @@ -49,9 +49,7 @@ 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.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.Stereotype; import net.sourceforge.plantuml.graphic.USymbols; @@ -106,12 +104,18 @@ public class CommandArchimateMultilines extends CommandMultilines2 2 ? codeRaw.charAt(0) : 0; } diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java index 9ada7495e..9fbc74855 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java @@ -36,8 +36,8 @@ package net.sourceforge.plantuml.descdiagram.command; import net.sourceforge.plantuml.StringUtils; -import net.sourceforge.plantuml.baraye.IEntity; -import net.sourceforge.plantuml.baraye.ILeaf; +import net.sourceforge.plantuml.baraye.EntityImp; +import net.sourceforge.plantuml.baraye.Quark; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.regex.IRegex; @@ -45,9 +45,7 @@ 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.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.Link; import net.sourceforge.plantuml.cucadiagram.LinkArg; @@ -242,16 +240,18 @@ public class CommandLinkElement extends SingleLineCommand2 { @Override protected CommandExecutionResult executeArg(DescriptionDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { - final String ent1String = arg.get("ENT1", 0); - final String ent2String = arg.get("ENT2", 0); - final String ent1 = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(ent1String); - final String ent2 = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(ent2String); - final Ident ident1 = diagram.buildLeafIdentSpecial(ent1); - final Ident ident2 = diagram.buildLeafIdentSpecial(ent2); - Ident ident1pure = Ident.empty().add(ent1, diagram.getNamespaceSeparator()); - Ident ident2pure = Ident.empty().add(ent2, diagram.getNamespaceSeparator()); - final Code code1 = diagram.buildCode(ent1String); - final Code code2 = diagram.buildCode(ent2String); + final String ent1 = arg.get("ENT1", 0); + final String ent2 = arg.get("ENT2", 0); + final String ent1clean = diagram.cleanIdForQuark(ent1); + final String ent2clean = diagram.cleanIdForQuark(ent2); +// final String ent1 = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(ent1String); +// final String ent2 = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(ent2String); +// final Quark ident1 = diagram.buildFullyQualified(ent1); +// final Quark ident2 = diagram.buildFullyQualified(ent2); +// Quark ident1pure = diagram.getPlasma().root().child(ent1); +// Quark ident2pure = diagram.getPlasma().root().child(ent2); +// final Quark code1 = diagram.buildFromFullPath(ent1String); +// final Quark code2 = diagram.buildFromFullPath(ent2String); final LinkType linkType = getLinkType(arg); final Direction dir = getDirection(arg); @@ -263,18 +263,18 @@ public class CommandLinkElement extends SingleLineCommand2 { final Labels labels = new Labels(arg); - final IEntity cl1; - final IEntity cl2; - if (diagram.isGroup(code1) && diagram.isGroup(code2)) { - cl1 = diagram.getGroup(diagram.buildCode(ent1String)); - cl2 = diagram.getGroup(diagram.buildCode(ent2String)); + final EntityImp cl1; + final EntityImp cl2; + if (diagram.isGroup(ent1clean) && diagram.isGroup(ent2clean)) { + cl1 = diagram.getGroup(ent1clean); + cl2 = diagram.getGroup(ent2clean); } else { - cl1 = getFoo1(diagram, code1, ident1, ident1pure); - cl2 = getFoo1(diagram, code2, ident2, ident2pure); + cl1 = getDummy(diagram, ent1); + cl2 = getDummy(diagram, ent2); } final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(labels.getLabelLink()), queue.length(), diagram.getSkinParam().classAttributeIconSize() > 0); - Link link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, + Link link = new Link(diagram.getEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, linkArg.withQuantifier(labels.getFirstLabel(), labels.getSecondLabel()) .withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle())); link.setLinkArrow(labels.getLinkArrow()); @@ -291,36 +291,43 @@ public class CommandLinkElement extends SingleLineCommand2 { return CommandExecutionResult.ok(); } - private IEntity getFoo1(DescriptionDiagram diagram, Code code, Ident ident, Ident pure) { - if (diagram.isGroup(code)) - return diagram.getGroup(code); +// private String removeStartingParenthesis(String s) { +// if (s.startsWith("()")) +// return s.substring(2); +// return s; +// } - final String codeString = code.getName(); - if (ident.getLast().startsWith("()")) { - ident = ident.removeStartingParenthesis(); - return getOrCreateLeaf1972(diagram, ident, ident.toCode(diagram), LeafType.DESCRIPTION, USymbols.INTERFACE, - pure); + private EntityImp getDummy(DescriptionDiagram diagram, String ident) { + if (ident.startsWith("()")) { + ident = diagram.cleanIdForQuark(ident); + final Quark quark = diagram.quarkInContext(ident, false); + if (quark.getData() != null) + return (EntityImp) quark.getData(); + return diagram.reallyCreateLeaf(quark, Display.getWithNewlines(quark.getName()), LeafType.DESCRIPTION, + USymbols.INTERFACE); } - final char codeChar = codeString.length() > 2 ? codeString.charAt(0) : 0; - final String tmp3 = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeString, "\"([:"); - final Ident ident3 = diagram.buildFullyQualified(tmp3); - final Code code3 = diagram.buildCode(tmp3); + + final char codeChar = ident.length() > 2 ? ident.charAt(0) : 0; + ident = diagram.cleanIdForQuark(ident); + final Quark quark = diagram.quarkInContext(ident, false); + + if (diagram.isGroup(quark)) + return (EntityImp) quark.getData(); + if (quark.getData() != null) + return (EntityImp) quark.getData(); + final Display display = Display.getWithNewlines(quark.getName()); + if (codeChar == '(') { - return getOrCreateLeaf1972(diagram, ident, code3, LeafType.USECASE, USymbols.USECASE, pure); + return (EntityImp) diagram.reallyCreateLeaf(quark, display, LeafType.USECASE, USymbols.USECASE); } else if (codeChar == ':') { - return getOrCreateLeaf1972(diagram, ident, code3, LeafType.DESCRIPTION, - diagram.getSkinParam().actorStyle().toUSymbol(), pure); + return (EntityImp) diagram.reallyCreateLeaf(quark, display, LeafType.DESCRIPTION, + diagram.getSkinParam().actorStyle().toUSymbol()); } else if (codeChar == '[') { final USymbol sym = diagram.getSkinParam().componentStyle().toUSymbol(); - return getOrCreateLeaf1972(diagram, ident, code3, LeafType.DESCRIPTION, sym, pure); + return (EntityImp) diagram.reallyCreateLeaf(quark, display, LeafType.DESCRIPTION, sym); } - return getOrCreateLeaf1972(diagram, ident, code, null, null, pure); - } - - private ILeaf getOrCreateLeaf1972(DescriptionDiagram diagram, Ident ident, Code code, LeafType type, USymbol symbol, - Ident pure) { - return diagram.getOrCreateLeaf(ident, code, type, symbol); + return (EntityImp) diagram.reallyCreateLeaf(quark, display, LeafType.STILL_UNKNOWN, null); } } diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandPackageWithUSymbol.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandPackageWithUSymbol.java index e8b8f6569..dd93173d2 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandPackageWithUSymbol.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandPackageWithUSymbol.java @@ -39,8 +39,8 @@ import net.sourceforge.plantuml.StringUtils; 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.baraye.IGroup; +import net.sourceforge.plantuml.baraye.EntityImp; +import net.sourceforge.plantuml.baraye.Quark; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.classdiagram.command.CommandCreateClassMultilines; import net.sourceforge.plantuml.command.CommandExecutionResult; @@ -51,11 +51,8 @@ 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.GroupType; -import net.sourceforge.plantuml.cucadiagram.Ident; -import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; import net.sourceforge.plantuml.cucadiagram.Stereotag; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.USymbols; @@ -153,14 +150,12 @@ public class CommandPackageWithUSymbol extends SingleLineCommand2 getDonors() throws IOException { final List lines = new ArrayList<>(); + // ::comment when WASM final Transcoder t = TranscoderImpl.utf8(new AsciiEncoder(), new StringCompressorNone(), new CompressionBrotli()); try { @@ -155,6 +156,7 @@ public class PSystemDonors extends PlainDiagram { } catch (NoPlantumlCompressionException e) { Logme.error(e); } + // ::done return lines; } diff --git a/src/net/sourceforge/plantuml/eggs/PSystemLost.java b/src/net/sourceforge/plantuml/eggs/PSystemLost.java index d1fbdb791..cfd9fccca 100644 --- a/src/net/sourceforge/plantuml/eggs/PSystemLost.java +++ b/src/net/sourceforge/plantuml/eggs/PSystemLost.java @@ -40,6 +40,7 @@ import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.UmlSource; public class PSystemLost extends PlainStringsDiagram { + // ::remove file when WASM public PSystemLost(UmlSource source) { super(source); diff --git a/src/net/sourceforge/plantuml/eggs/PSystemLostFactory.java b/src/net/sourceforge/plantuml/eggs/PSystemLostFactory.java index 123f2282e..a644e8b44 100644 --- a/src/net/sourceforge/plantuml/eggs/PSystemLostFactory.java +++ b/src/net/sourceforge/plantuml/eggs/PSystemLostFactory.java @@ -40,6 +40,7 @@ import net.sourceforge.plantuml.command.PSystemSingleLineFactory; import net.sourceforge.plantuml.core.UmlSource; public class PSystemLostFactory extends PSystemSingleLineFactory { + // ::remove file when WASM @Override protected AbstractPSystem executeLine(UmlSource source, String line) { diff --git a/src/net/sourceforge/plantuml/eggs/PSystemPath.java b/src/net/sourceforge/plantuml/eggs/PSystemPath.java index 05da248fe..70edff1de 100644 --- a/src/net/sourceforge/plantuml/eggs/PSystemPath.java +++ b/src/net/sourceforge/plantuml/eggs/PSystemPath.java @@ -46,6 +46,7 @@ import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.ugraphic.color.ColorMapper; public class PSystemPath extends AbstractPSystem { + // ::remove file when WASM private final GraphicsPath path; diff --git a/src/net/sourceforge/plantuml/eggs/PSystemPathFactory.java b/src/net/sourceforge/plantuml/eggs/PSystemPathFactory.java index 3fe9d5ab1..65f47e147 100644 --- a/src/net/sourceforge/plantuml/eggs/PSystemPathFactory.java +++ b/src/net/sourceforge/plantuml/eggs/PSystemPathFactory.java @@ -43,6 +43,7 @@ import net.sourceforge.plantuml.command.regex.Pattern2; import net.sourceforge.plantuml.core.UmlSource; public class PSystemPathFactory extends PSystemSingleLineFactory { + // ::remove file when WASM final private static Pattern2 p = MyPattern.cmpile("^path[%s]+([0-9A-Za-z]+)$"); diff --git a/src/net/sourceforge/plantuml/elk/CucaDiagramFileMakerElk.java b/src/net/sourceforge/plantuml/elk/CucaDiagramFileMakerElk.java index 7339e07c8..46fd456ef 100644 --- a/src/net/sourceforge/plantuml/elk/CucaDiagramFileMakerElk.java +++ b/src/net/sourceforge/plantuml/elk/CucaDiagramFileMakerElk.java @@ -56,9 +56,7 @@ import net.sourceforge.plantuml.api.ImageDataSimple; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XPoint2D; import net.sourceforge.plantuml.baraye.EntityFactory; -import net.sourceforge.plantuml.baraye.IEntity; -import net.sourceforge.plantuml.baraye.IGroup; -import net.sourceforge.plantuml.baraye.ILeaf; +import net.sourceforge.plantuml.baraye.EntityImp; import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.GroupType; @@ -146,13 +144,14 @@ https://rtsys.informatik.uni-kiel.de/~biblio/downloads/theses/yab-bt.pdf https://rtsys.informatik.uni-kiel.de/~biblio/downloads/theses/thw-bt.pdf */ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker { + // ::remove folder when WASM private final ICucaDiagram diagram; private final StringBounder stringBounder; private final DotStringFactory dotStringFactory; - private final Map nodes = new LinkedHashMap(); - private final Map clusters = new LinkedHashMap(); + private final Map nodes = new LinkedHashMap(); + private final Map clusters = new LinkedHashMap(); private final Map edges = new LinkedHashMap(); public CucaDiagramFileMakerElk(ICucaDiagram diagram, StringBounder stringBounder) { @@ -226,13 +225,13 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker { } private void drawAllClusters(UGraphic ug) { - for (Entry ent : clusters.entrySet()) + for (Entry ent : clusters.entrySet()) drawSingleCluster(ug, ent.getKey(), ent.getValue()); } private void drawAllNodes(UGraphic ug) { - for (Entry ent : nodes.entrySet()) + for (Entry ent : nodes.entrySet()) drawSingleNode(ug, ent.getKey(), ent.getValue()); } @@ -247,7 +246,7 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker { } } - private void drawSingleCluster(UGraphic ug, IGroup group, ElkNode elkNode) { + private void drawSingleCluster(UGraphic ug, EntityImp group, ElkNode elkNode) { final XPoint2D corner = getPosition(elkNode); final URectangle rect = new URectangle(elkNode.getWidth(), elkNode.getHeight()); @@ -287,7 +286,7 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker { // ug.apply(HColorUtils.BLACK).apply(new UStroke(1.5)).apply(new UTranslate(corner)).draw(rect); } - private TextBlock getTitleBlock(IGroup g) { + private TextBlock getTitleBlock(EntityImp g) { final Display label = g.getDisplay(); if (label == null) return TextBlockUtils.empty(0, 0); @@ -301,7 +300,7 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker { return null; } - private void drawSingleNode(UGraphic ug, ILeaf leaf, ElkNode elkNode) { + private void drawSingleNode(UGraphic ug, EntityImp leaf, ElkNode elkNode) { final IEntityImage image = printEntityInternal(leaf); // Retrieve coord from ELK final XPoint2D corner = getPosition(elkNode); @@ -315,7 +314,7 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker { final XPoint2D translate = getPosition(edge.getContainingNode()); final double magicY2 = 0; - final IEntity dest = link.getEntity2(); + final EntityImp dest = link.getEntity2(); if (dest.getUSymbol() instanceof USymbolFolder) { // System.err.println("dest=" + dest); // final IEntityImage image = printEntityInternal((ILeaf) dest); @@ -340,16 +339,16 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker { } - private Collection getUnpackagedEntities() { - final List result = new ArrayList<>(); - for (ILeaf ent : diagram.getLeafsvalues()) + private Collection getUnpackagedEntities() { + final List result = new ArrayList<>(); + for (EntityImp ent : diagram.getLeafsvalues()) if (diagram.getEntityFactory().getRootGroup() == ent.getParentContainer()) result.add(ent); return result; } - private ElkNode getElkNode(final IEntity entity) { + private ElkNode getElkNode(final EntityImp entity) { ElkNode node = nodes.get(entity); if (node == null) node = clusters.get(entity); @@ -389,15 +388,15 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker { } - private void printAllSubgroups(ElkNode cluster, IGroup group) { - for (IGroup g : diagram.getChildrenGroups(group)) { + private void printAllSubgroups(ElkNode cluster, EntityImp group) { + for (EntityImp g : diagram.getChildrenGroups(group)) { if (g.isRemoved()) { continue; } if (diagram.isEmpty(g) && g.getGroupType() == GroupType.PACKAGE) { final ISkinParam skinParam = diagram.getSkinParam(); final EntityFactory entityFactory = diagram.getEntityFactory(); - final ILeaf folder = entityFactory.createLeafForEmptyGroup(g, skinParam); + final EntityImp folder = entityFactory.createLeafForEmptyGroup(g, skinParam); System.err.println("STILL IN PROGRESS"); // printEntityNew(folder); } else { @@ -419,7 +418,7 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker { } - private void printSingleGroup(IGroup g) { + private void printSingleGroup(EntityImp g) { if (g.getGroupType() == GroupType.CONCURRENT_STATE) return; @@ -427,9 +426,9 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker { printAllSubgroups(clusters.get(g), g); } - private void printEntities(ElkNode parent, Collection entities) { + private void printEntities(ElkNode parent, Collection entities) { // Convert all "leaf" to ELK node - for (ILeaf ent : entities) { + for (EntityImp ent : entities) { if (ent.isRemoved()) continue; @@ -444,7 +443,7 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker { } - private void manageSingleNode(final ElkNode root, ILeaf leaf) { + private void manageSingleNode(final ElkNode root, EntityImp leaf) { final IEntityImage image = printEntityInternal(leaf); // Expected dimension of the node @@ -544,7 +543,7 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker { return dotStringFactory.getBibliotekon(); } - private IEntityImage printEntityInternal(ILeaf ent) { + private IEntityImage printEntityInternal(EntityImp ent) { if (ent.isRemoved()) throw new IllegalStateException(); diff --git a/src/net/sourceforge/plantuml/eps/EpsGraphics.java b/src/net/sourceforge/plantuml/eps/EpsGraphics.java index 6f20bd08e..3e95e3b4b 100644 --- a/src/net/sourceforge/plantuml/eps/EpsGraphics.java +++ b/src/net/sourceforge/plantuml/eps/EpsGraphics.java @@ -54,6 +54,7 @@ import net.sourceforge.plantuml.utils.MathUtils; import net.sourceforge.plantuml.version.Version; public class EpsGraphics { + // ::remove folder when WASM public static final String END_OF_FILE = "%plantuml done"; protected static final long COEF = 100L; diff --git a/src/net/sourceforge/plantuml/error/PSystemError.java b/src/net/sourceforge/plantuml/error/PSystemError.java index d4016cb3c..b1dce25bb 100644 --- a/src/net/sourceforge/plantuml/error/PSystemError.java +++ b/src/net/sourceforge/plantuml/error/PSystemError.java @@ -61,7 +61,6 @@ import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.eggs.PSystemWelcome; import net.sourceforge.plantuml.flashcode.FlashCodeFactory; -import net.sourceforge.plantuml.flashcode.FlashCodeUtils; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.GraphicPosition; import net.sourceforge.plantuml.graphic.GraphicStrings; @@ -233,6 +232,7 @@ public abstract class PSystemError extends PlainDiagram { @Override final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) throws IOException { + // ::comment when WASM if (fileFormat.getFileFormat() == FileFormat.ATXT || fileFormat.getFileFormat() == FileFormat.UTXT) { final UGraphicTxt ugt = new UGraphicTxt(); final UmlCharArea area = ugt.getCharArea(); @@ -241,6 +241,7 @@ public abstract class PSystemError extends PlainDiagram { return new ImageDataSimple(1, 1); } + // ::done return super.exportDiagramNow(os, num, fileFormat); } @@ -298,9 +299,11 @@ public abstract class PSystemError extends PlainDiagram { } private TextBlock addMessageLiberapay(final TextBlock source) throws IOException { - if (LicenseInfo.retrieveNamedOrDistributorQuickIsValid()) { + // ::comment when WASM + if (LicenseInfo.retrieveNamedOrDistributorQuickIsValid()) return source; - } + // ::done + final TextBlock message = getMessageLiberapay(); TextBlock result = TextBlockUtils.mergeTB(message, source, HorizontalAlignment.LEFT); result = TextBlockUtils.mergeTB(result, message, HorizontalAlignment.LEFT); @@ -308,9 +311,11 @@ public abstract class PSystemError extends PlainDiagram { } private TextBlock addMessagePatreon(final TextBlock source) throws IOException { - if (LicenseInfo.retrieveNamedOrDistributorQuickIsValid()) { + // ::comment when WASM + if (LicenseInfo.retrieveNamedOrDistributorQuickIsValid()) return source; - } + // ::done + final TextBlock message = getMessagePatreon(); TextBlock result = TextBlockUtils.mergeTB(message, source, HorizontalAlignment.LEFT); result = TextBlockUtils.mergeTB(result, message, HorizontalAlignment.LEFT); @@ -318,14 +323,17 @@ public abstract class PSystemError extends PlainDiagram { } private TextBlock addMessageDedication(final TextBlock source) throws IOException { - if (LicenseInfo.retrieveNamedOrDistributorQuickIsValid()) { + // ::comment when WASM + if (LicenseInfo.retrieveNamedOrDistributorQuickIsValid()) return source; - } + // ::done + final TextBlock message = getMessageDedication(); TextBlock result = TextBlockUtils.mergeTB(message, source, HorizontalAlignment.LEFT); return result; } + // ::comment when WASM private TextBlock addMessageAdopt(final TextBlock source) throws IOException { if (LicenseInfo.retrieveNamedOrDistributorQuickIsValid()) { return source; @@ -334,6 +342,7 @@ public abstract class PSystemError extends PlainDiagram { TextBlock result = TextBlockUtils.mergeTB(message, source, HorizontalAlignment.LEFT); return result; } + // ::done private TextBlock addMessageArecibo(final TextBlock source) throws IOException { final UImage message = new UImage( @@ -343,11 +352,12 @@ public abstract class PSystemError extends PlainDiagram { } private TextBlockBackcolored getMessageDedication() { - final FlashCodeUtils utils = FlashCodeFactory.getFlashCodeUtils(); final HColorSimple backColor = (HColorSimple) HColorSet.instance().getColorOrWhite("#eae2c9"); - final BufferedImage qrcode = smaller( - utils.exportFlashcode("http://plantuml.com/dedication", Color.BLACK, backColor.getAwtColor())); + // ::comment when WASM + final BufferedImage qrcode = smaller(FlashCodeFactory.getFlashCodeUtils() + .exportFlashcode("http://plantuml.com/dedication", Color.BLACK, backColor.getAwtColor())); + // ::done final Display disp = Display.create("Add your own dedication into PlantUML", " ", "For just $5 per month!", "Details on [[https://plantuml.com/dedication]]"); @@ -356,12 +366,16 @@ public abstract class PSystemError extends PlainDiagram { final TextBlock text = TextBlockUtils .withMargin(disp.create(fc, HorizontalAlignment.LEFT, new SpriteContainerEmpty()), 10, 0); final TextBlock result; + // ::comment when WASM if (qrcode == null) { + // ::done result = text; + // ::comment when WASM } else { final UImage qr = new UImage(new PixelImage(qrcode, AffineTransformType.TYPE_NEAREST_NEIGHBOR)).scale(3); result = TextBlockUtils.mergeLR(text, TextBlockUtils.fromUImage(qr), VerticalAlignment.CENTER); } + // ::done return TextBlockUtils.addBackcolor(result, backColor); } @@ -388,26 +402,41 @@ public abstract class PSystemError extends PlainDiagram { final Color back = new Color(message.getImage(1).getRGB(0, 0)); final HColor backColor = HColors.simple(back); - final FlashCodeUtils utils = FlashCodeFactory.getFlashCodeUtils(); - final BufferedImage qrcode = smaller( - utils.exportFlashcode("http://plantuml.com/patreon", Color.BLACK, Color.WHITE)); + // ::comment when WASM + final BufferedImage qrcode = smaller(FlashCodeFactory.getFlashCodeUtils() + .exportFlashcode("http://plantuml.com/patreon", Color.BLACK, Color.WHITE)); + // ::done final int scale = 2; - final double imWidth = message.getWidth() + (qrcode == null ? 0 : qrcode.getWidth() * scale + 20); - final double imHeight = qrcode == null ? message.getHeight() - : Math.max(message.getHeight(), qrcode.getHeight() * scale + 10); + final double imWidth; + final double imHeight; + // ::comment when WASM + if (qrcode == null) { + // ::done + imWidth = message.getWidth(); + imHeight = message.getHeight(); + // ::comment when WASM + } else { + imWidth = message.getWidth() + qrcode.getWidth() * scale + 20; + imHeight = Math.max(message.getHeight(), qrcode.getHeight() * scale + 10); + } + // ::done return new TextBlockBackcolored() { public void drawU(UGraphic ug) { + // ::comment when WASM if (qrcode == null) { + // ::done ug.apply(new UTranslate(1, 1)).draw(message); + // ::comment when WASM } else { final UImage qr = new UImage(new PixelImage(qrcode, AffineTransformType.TYPE_NEAREST_NEIGHBOR)) .scale(scale); ug.apply(new UTranslate(1, (imHeight - message.getHeight()) / 2)).draw(message); ug.apply(new UTranslate(1 + message.getWidth(), (imHeight - qr.getHeight()) / 2)).draw(qr); } + // ::done } public XRectangle2D getInnerPosition(String member, StringBounder stringBounder, InnerStrategy strategy) { @@ -435,25 +464,42 @@ public abstract class PSystemError extends PlainDiagram { final Color back = new Color(message.getImage(1).getRGB(0, 0)); final HColor backColor = HColors.simple(back); - final FlashCodeUtils utils = FlashCodeFactory.getFlashCodeUtils(); - final BufferedImage qrcode = smaller(utils.exportFlashcode("http://plantuml.com/lp", Color.BLACK, Color.WHITE)); + // ::comment when WASM + final BufferedImage qrcode = smaller(FlashCodeFactory.getFlashCodeUtils() + .exportFlashcode("http://plantuml.com/lp", Color.BLACK, Color.WHITE)); + // ::done final int scale = 2; - final double imWidth = message.getWidth() + (qrcode == null ? 0 : qrcode.getWidth() * scale + 20); - final double imHeight = qrcode == null ? message.getHeight() - : Math.max(message.getHeight(), qrcode.getHeight() * scale + 10); + final double imWidth; + final double imHeight; + // ::comment when WASM + if (qrcode == null) { + // ::done + imWidth = message.getWidth(); + imHeight = message.getHeight(); + // ::comment when WASM + } else { + imWidth = message.getWidth() + qrcode.getWidth() * scale + 20; + imHeight = Math.max(message.getHeight(), qrcode.getHeight() * scale + 10); + } + // ::done + return new TextBlockBackcolored() { public void drawU(UGraphic ug) { + // ::comment when WASM if (qrcode == null) { + // ::done ug.apply(new UTranslate(1, 1)).draw(message); + // ::comment when WASM } else { final UImage qr = new UImage(new PixelImage(qrcode, AffineTransformType.TYPE_NEAREST_NEIGHBOR)) .scale(scale); ug.apply(new UTranslate(1, (imHeight - message.getHeight()) / 2)).draw(message); ug.apply(new UTranslate(1 + message.getWidth(), (imHeight - qr.getHeight()) / 2)).draw(qr); } + // ::done } public XRectangle2D getInnerPosition(String member, StringBounder stringBounder, InnerStrategy strategy) { diff --git a/src/net/sourceforge/plantuml/flashcode/FlashCodeFactory.java b/src/net/sourceforge/plantuml/flashcode/FlashCodeFactory.java index 012c5202f..ef3305e43 100644 --- a/src/net/sourceforge/plantuml/flashcode/FlashCodeFactory.java +++ b/src/net/sourceforge/plantuml/flashcode/FlashCodeFactory.java @@ -36,6 +36,7 @@ package net.sourceforge.plantuml.flashcode; public class FlashCodeFactory { + // :: remove folder when WASM public static FlashCodeUtils getFlashCodeUtils() { final String name = "net.sourceforge.plantuml.flashcode.FlashCodeUtilsZxing"; diff --git a/src/net/sourceforge/plantuml/font/PSystemListFonts.java b/src/net/sourceforge/plantuml/font/PSystemListFonts.java index 125dad106..4d353b155 100644 --- a/src/net/sourceforge/plantuml/font/PSystemListFonts.java +++ b/src/net/sourceforge/plantuml/font/PSystemListFonts.java @@ -42,6 +42,7 @@ import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.UmlSource; public class PSystemListFonts extends PlainStringsDiagram { + // ::remove folder when WASM public PSystemListFonts(UmlSource source, String text) { super(source); diff --git a/src/net/sourceforge/plantuml/ftp/FtpConnexion.java b/src/net/sourceforge/plantuml/ftp/FtpConnexion.java index e246ef671..12c021fc5 100644 --- a/src/net/sourceforge/plantuml/ftp/FtpConnexion.java +++ b/src/net/sourceforge/plantuml/ftp/FtpConnexion.java @@ -53,6 +53,7 @@ import net.sourceforge.plantuml.SourceStringReader; import net.sourceforge.plantuml.core.DiagramDescription; public class FtpConnexion { + // ::remove folder when WASM private final String user; private final Map incoming = new HashMap(); diff --git a/src/net/sourceforge/plantuml/graphml/CucaDiagramGraphmlMaker.java b/src/net/sourceforge/plantuml/graphml/CucaDiagramGraphmlMaker.java index f6cf93ba4..758b505ae 100644 --- a/src/net/sourceforge/plantuml/graphml/CucaDiagramGraphmlMaker.java +++ b/src/net/sourceforge/plantuml/graphml/CucaDiagramGraphmlMaker.java @@ -49,6 +49,7 @@ import net.sourceforge.plantuml.utils.Log; import net.sourceforge.plantuml.xmi.XmlDiagramTransformer; public final class CucaDiagramGraphmlMaker { + // ::remove folder when WASM private final ICucaDiagram diagram; diff --git a/src/net/sourceforge/plantuml/graphml/GraphmlDescriptionDiagram.java b/src/net/sourceforge/plantuml/graphml/GraphmlDescriptionDiagram.java index b97924a0d..51f226843 100644 --- a/src/net/sourceforge/plantuml/graphml/GraphmlDescriptionDiagram.java +++ b/src/net/sourceforge/plantuml/graphml/GraphmlDescriptionDiagram.java @@ -52,8 +52,7 @@ import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Document; import org.w3c.dom.Element; -import net.sourceforge.plantuml.baraye.IEntity; -import net.sourceforge.plantuml.cucadiagram.GroupRoot; +import net.sourceforge.plantuml.baraye.EntityImp; import net.sourceforge.plantuml.descdiagram.DescriptionDiagram; import net.sourceforge.plantuml.xmi.XmlDiagramTransformer; import net.sourceforge.plantuml.xml.XmlFactories; @@ -81,21 +80,21 @@ public class GraphmlDescriptionDiagram implements XmlDiagramTransformer { graph.setAttribute("edgedefault", "undirected"); graphml.appendChild(graph); - for (final IEntity ent : diagram.getLeafsvalues()) - if (ent.getParentContainer() instanceof GroupRoot) + for (final EntityImp ent : diagram.getLeafsvalues()) + if (ent.getParentContainer().instanceofGroupRoot()) addElement(ent, graph); } - private void addElement(IEntity tobeAdded, Element container) { + private void addElement(EntityImp tobeAdded, Element container) { final Element element = createEntityNode(tobeAdded); container.appendChild(element); } - private Element createEntityNode(IEntity entity) { + private Element createEntityNode(EntityImp entity) { final Element cla = document.createElement("node"); - cla.setAttribute("id", entity.getCode().getName()); + cla.setAttribute("id", entity.getCode()); return cla; } diff --git a/src/net/sourceforge/plantuml/html/CucaDiagramHtmlMaker.java b/src/net/sourceforge/plantuml/html/CucaDiagramHtmlMaker.java index 3bb4f26f5..b16db269f 100644 --- a/src/net/sourceforge/plantuml/html/CucaDiagramHtmlMaker.java +++ b/src/net/sourceforge/plantuml/html/CucaDiagramHtmlMaker.java @@ -46,13 +46,14 @@ import java.util.List; import net.sourceforge.plantuml.FileImageData; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.baraye.CucaDiagram; -import net.sourceforge.plantuml.baraye.IEntity; +import net.sourceforge.plantuml.baraye.EntityImp; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.security.SFile; public final class CucaDiagramHtmlMaker { + // ::remove folder when WASM private final CucaDiagram diagram; private final SFile dir; @@ -82,7 +83,7 @@ public final class CucaDiagramHtmlMaker { private void printAllType(final PrintWriter pw, LeafType type) throws IOException { if (hasSome(type)) { pw.println("

    " + type.toHtml() + "

    "); - for (final IEntity ent : diagram.getLeafsvalues()) { + for (final EntityImp ent : diagram.getLeafsvalues()) { if (ent.getLeafType() != type) { continue; } @@ -105,7 +106,7 @@ public final class CucaDiagramHtmlMaker { } private boolean hasSome(final LeafType type) { - for (IEntity ent : diagram.getLeafsvalues()) { + for (EntityImp ent : diagram.getLeafsvalues()) { if (ent.getLeafType() == type) { return true; } @@ -113,7 +114,7 @@ public final class CucaDiagramHtmlMaker { return false; } - private void export(IEntity entity) throws IOException { + private void export(EntityImp entity) throws IOException { final SFile f = dir.file(LinkHtmlPrinter.urlOf(entity)); final PrintWriter pw = f.createPrintWriter(); pw.println(""); @@ -176,12 +177,12 @@ public final class CucaDiagramHtmlMaker { pw.println(""); } - final Collection notes = getNotes(entity); + final Collection notes = getNotes(entity); if (notes.size() > 0) { pw.println("
    "); pw.println("

    Notes:

    "); pw.println("