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

Major change on internal identifier management

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

View File

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

View File

@ -0,0 +1,83 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2023, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package com.plantuml.wasm;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.SourceStringReader;
import net.sourceforge.plantuml.core.DiagramDescription;
public class Utils {
public static int convertPng(String pathOut, String text) throws IOException {
final FileFormatOption format = new FileFormatOption(FileFormat.PNG);
text = cleanText(text);
return doTheJob(pathOut, text, format);
}
private static String cleanText(String text) {
if (text.endsWith("\n") == false)
text = text + "\n";
if (text.endsWith("@start") == false)
text = "@startuml\n" + text + "@enduml\n";
return text;
}
private static int doTheJob(String pathOut, String text, final FileFormatOption format)
throws FileNotFoundException, IOException {
final SourceStringReader sr = new SourceStringReader(text);
final FileOutputStream fos = new FileOutputStream(new File(pathOut));
DiagramDescription description = sr.outputImage(fos, format);
fos.close();
if (description.getDescription() != null && description.getDescription().contains("error"))
return 1;
return 0;
}
public static int convertSvg(String pathOut, String text) throws IOException {
final FileFormatOption format = new FileFormatOption(FileFormat.SVG);
text = cleanText(text);
return doTheJob(pathOut, text, format);
}
}

View File

@ -97,6 +97,7 @@ import ext.plantuml.com.ctreber.aclib.sort.QuickSort;
* @author Christian Treber, ct@ctreber.com
*/
public class ACearth {
// :: remove folder when WASM
public static final String VERSION = "1.1";
public static final String BUILD = "22.11.2002 004";
@ -115,6 +116,7 @@ public class ACearth {
/**
* <p>
* Well, the main class.
*
* @param markers
*/
public ACearth(List<Marker> markers) {
@ -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);

View File

@ -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()

View File

@ -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());

View File

@ -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.

View File

@ -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";

View File

@ -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
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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
}

View File

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

View File

@ -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)

View File

@ -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) {

View File

@ -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<String> result = new ArrayList<>();

View File

@ -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));

View File

@ -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<FileImageData> exportDiagrams(Diagram system, SuggestedFile suggested,
FileFormatOption fileFormatOption) throws IOException {
@ -65,6 +66,7 @@ public class PSystemUtils {
public static List<FileImageData> 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);

View File

@ -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() {

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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<? extends CharSequence> stringsToDisplay) {
return stringsToDisplay.size();

View File

@ -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;

View File

@ -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<CharSequence> 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 {

View File

@ -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<String> 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() {

View File

@ -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);
}

View File

@ -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;

View File

@ -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<String, String> 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<String> 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;
}

View File

@ -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;
}

View File

@ -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<ActivityDiagram> {
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);

View File

@ -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<ActivityDiagram> {
@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<ActivityDiagram> {
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) {

View File

@ -61,7 +61,7 @@ public class CommandInnerConcurrent extends SingleLineCommand2<ActivityDiagram>
@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));

View File

@ -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<ActivityDiagram> {
@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<ActivityDiagram> {
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<ActivityDiagram> {
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<ActivityDiagram> {
}
static IEntity getEntity(ActivityDiagram diagram, RegexResult arg, final boolean start) {
static EntityImp getEntity(ActivityDiagram diagram, RegexResult arg, final boolean start) {
final String suf = start ? "" : "2";
final String openBracket2 = arg.get("OPENBRACKET" + suf, 0);
@ -208,15 +209,16 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
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<ActivityDiagram> {
}
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<ActivityDiagram> {
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<ActivityDiagram> {
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;
}

View File

@ -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<ActivityDiagram>
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<ActivityDiagram>
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<ActivityDiagram>
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)

View File

@ -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<ActivityDiagram> {
@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) {

View File

@ -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 {

View File

@ -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*)");

View File

@ -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<FileSet> filesets = new ArrayList<>();

View File

@ -42,6 +42,7 @@ 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);
@ -57,5 +58,4 @@ public abstract class AbstractComponentText implements Component {
throw new UnsupportedOperationException();
}
}

View File

@ -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<HideOrShow2> hides2 = new ArrayList<>();
private final List<HideOrShow2> removed = new ArrayList<>();
protected final EntityFactory entityFactory = new EntityFactory(hides2, removed, this);
private IGroup currentGroup = entityFactory.getRootGroup();
private List<Ident> stacks2 = new ArrayList<>();
private List<IGroup> stacks = new ArrayList<>();
private List<Quark> 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<String, String> 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<EntityImp> getChildrenGroups(EntityImp parent) {
final Collection<EntityImp> 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<IGroup> getChildrenGroups(IGroup parent) {
final Collection<IGroup> 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<EntityImp> getGroups(boolean withRootGroup) {
final List<EntityImp> result = new ArrayList<>();
for (Quark quark : getPlasma().quarks()) {
if (quark.isRoot()) {
if (withRootGroup)
result.add((EntityImp) quark.getData());
} else {
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<IGroup> getGroups(boolean withRootGroup) {
if (withRootGroup == false)
return entityFactory.groups();
final Collection<IGroup> result = new ArrayList<>();
result.add(getRootGroup());
result.addAll(entityFactory.groups());
return Collections.unmodifiableCollection(result);
}
public IGroup getRootGroup() {
return entityFactory.getRootGroup();
public EntityImp getRootGroup() {
return (EntityImp) getPlasma().root().getData();
}
public final Collection<ILeaf> getLeafsvalues() {
return entityFactory.leafs2();
public final Collection<EntityImp> getLeafsvalues() {
final List<EntityImp> result = new ArrayList<>();
for (Quark quark : getPlasma().quarks()) {
if (quark.isRoot())
continue;
final EntityImp data = (EntityImp) quark.getData();
if (data != null && data.isGroup() == false)
result.add(data);
}
return Collections.unmodifiableCollection(result);
}
public final int getLeafssize() {
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<ILeaf> standalones = new ArrayList<>();
for (EntityImp g : getGroups(true)) {
final List<EntityImp> 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;

View File

@ -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<String, ILeaf> leafsByCode;
private final Map<String, IGroup> groupsByCode;
/* private */public final Map<Ident, ILeaf> leafs2 = new LinkedHashMap<Ident, ILeaf>();
/* private */public final Map<Ident, IGroup> groups2 = new LinkedHashMap<Ident, IGroup>();
private final List<Link> links = new ArrayList<>();
private int rawLayout;
private final IGroup rootGroup = new GroupRoot(this);
private final Plasma plasma;
private final EntityImp rootGroup;
private final List<HideOrShow2> hides2;
private final List<HideOrShow2> removed;
/* private */ final public CucaDiagram namespaceSeparator;
private Map<IGroup, ILeaf> emptyGroupsAsNode = new HashMap<IGroup, ILeaf>();
/* 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<HideOrShow2> hides2, List<HideOrShow2> removed, CucaDiagram namespaceSeparator) {
//
public EntityImp isIntricated(EntityImp parent) {
throw new UnsupportedOperationException();
}
public EntityFactory(List<HideOrShow2> hides2, List<HideOrShow2> removed, ICucaDiagram namespaceSeparator) {
this.hides2 = hides2;
this.removed = removed;
this.namespaceSeparator = namespaceSeparator;
this.leafsByCode = new LinkedHashMap<String, ILeaf>();
this.groupsByCode = new LinkedHashMap<String, IGroup>();
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<VisibilityModifier> hides, String namespaceSeparator) {
final public EntityImp createLeaf(Quark quark, Display display, LeafType entityType,
Set<VisibilityModifier> 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<VisibilityModifier> hides, String namespaceSeparator) {
public EntityImp createGroup(Quark quark, Display display, GroupType groupType, Set<VisibilityModifier> hides) {
Objects.requireNonNull(groupType);
for (Entry<Ident, IGroup> ent : groups2.entrySet())
if (ent.getKey().equals(ident))
return ent.getValue();
if (quark.getData() != null)
return (EntityImp) quark.getData();
// for (Entry<Ident, IGroup> 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<Ident, IGroup> 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<EntityImp> 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<ILeaf> leafs() {
final Collection<ILeaf> result = Collections.unmodifiableCollection(leafsByCode.values());
if (new ArrayList<>(result).equals(new ArrayList<>(leafs2())) == false)
bigError();
return result;
}
public final Collection<IGroup> groups() {
final Collection<IGroup> result = Collections.unmodifiableCollection(groupsByCode.values());
if (new ArrayList<>(result).equals(new ArrayList<>(groups2())) == false)
bigError();
return result;
}
public final Collection<IGroup> groups2() {
final Collection<IGroup> result = Collections.unmodifiableCollection(groups2.values());
final List<EntityImp> result = new ArrayList<>();
for (Quark quark : getPlasma().quarks()) {
if (quark.isRoot())
continue;
final EntityImp data = (EntityImp) quark.getData();
if (data != null && data.isGroup() == false)
result.add(data);
}
return Collections.unmodifiableCollection(result);
}
public final Collection<ILeaf> leafs2() {
final Collection<ILeaf> result = Collections.unmodifiableCollection(leafs2.values());
public final Collection<EntityImp> groups() {
final List<EntityImp> result = new ArrayList<>();
for (Quark quark : getPlasma().quarks()) {
if (quark.isRoot())
continue;
final EntityImp data = (EntityImp) quark.getData();
if (data != null && data.isGroup())
result.add(data);
}
// System.err.println("GROUPS=" + result.size());
return Collections.unmodifiableCollection(result);
}
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;
}
}

View File

@ -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<CucaNote> 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<ILeaf> getLeafsDirect() {
checkGroup();
final List<ILeaf> result = new ArrayList<>();
for (ILeaf ent : entityFactory.leafs()) {
if (ent.isGroup())
throw new IllegalStateException();
if (ent.getParentContainer() == this)
result.add(ent);
}
return Collections.unmodifiableCollection(result);
}
public Collection<IGroup> getChildren() {
checkGroup();
final Collection<IGroup> result = new ArrayList<>();
for (IGroup g : entityFactory.groups())
if (g != this && g.getParentContainer() == this)
result.add(g);
return Collections.unmodifiableCollection(result);
}
public void moveEntitiesTo(IGroup dest) {
checkGroup();
if (dest.isGroup() == false)
throw new UnsupportedOperationException();
for (ILeaf ent : getLeafsDirect())
((EntityImp) ent).parentContainer = dest;
for (IGroup g : dest.getChildren())
// ((EntityImpl) g).parentContainer = dest;
throw new IllegalStateException();
for (IGroup g : getChildren()) {
if (g == dest)
continue;
((EntityImp) g).parentContainer = dest;
}
}
private void moveEntitiesTo1972(IGroup dest) {
checkGroup();
if (dest.isGroup() == false)
throw new UnsupportedOperationException();
// System.err.println("moveEntitiesTo1972::before1::groups2=" +
// entityFactory.groups2());
final Ident firstIdent = getIdent();
final Ident destIdent = dest.getIdent();
// System.err.println("moveEntitiesTo1972::this=" + firstIdent);
// System.err.println("moveEntitiesTo1972::dest=" + destIdent);
if (destIdent.startsWith(firstIdent) == false)
throw new UnsupportedOperationException();
// System.err.println("moveEntitiesTo1972::before2::groups2=" +
// entityFactory.groups2());
for (ILeaf ent : new ArrayList<>(entityFactory.leafs2())) {
Ident ident = ent.getIdent();
if (ident.equals(firstIdent) == false && ident.startsWith(firstIdent)
&& ident.startsWith(destIdent) == false) {
// System.err.print("moving leaf ident1=" + ident);
entityFactory.leafs2.remove(ident);
ident = ident.move(firstIdent, destIdent);
// System.err.println(" to ident2=" + ident);
((EntityImp) ent).ident = ident;
((EntityImp) ent).code = ident;
entityFactory.leafs2.put(ident, ent);
}
}
// System.err.println("moveEntitiesTo1972::before3::groups2=" +
// entityFactory.groups2());
for (IGroup ent : new ArrayList<>(entityFactory.groups2())) {
Ident ident = ent.getIdent();
// System.err.println("found=" + ident + " " + ident.startsWith(firstIdent) + "
// "
// + ident.startsWith(destIdent));
if (ident.equals(firstIdent) == false && ident.startsWith(firstIdent)
&& ident.startsWith(destIdent) == false) {
// System.err.print("moving gr ident1=" + ident);
entityFactory.groups2.remove(ident);
ident = ident.move(firstIdent, destIdent);
// System.err.println(" to ident2=" + ident);
((EntityImp) ent).ident = ident;
((EntityImp) ent).code = ident;
entityFactory.groups2.put(ident, ent);
// System.err.println("-->groups2=" + entityFactory.groups2());
}
}
// System.err.println("moveEntitiesTo1972::after::groups2=" +
// entityFactory.groups2());
// for (IGroup g : dest.getChildren()) {
// // ((EntityImpl) g).parentContainer = dest;
// throw new IllegalStateException();
// }
//
// for (IGroup g : getChildren()) {
// if (g == dest) {
// continue;
// }
// ((EntityImpl) g).parentContainer = dest;
// }
}
public int size() {
checkGroup();
return getLeafsDirect().size();
}
public GroupType getGroupType() {
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<EntityImp> getLeafsDirect() {
final List<EntityImp> result = new ArrayList<>();
for (Quark quark : quark.getChildren()) {
final EntityImp data = (EntityImp) quark.getData();
if (data != null && data.isGroup() == false)
result.add(data);
}
return Collections.unmodifiableCollection(result);
}
public Collection<EntityImp> getChildren() {
final List<EntityImp> result = new ArrayList<>();
for (Quark quark : quark.getChildren()) {
final EntityImp data = (EntityImp) quark.getData();
if (data != null && data.isGroup())
result.add(data);
}
return Collections.unmodifiableCollection(result);
}
public int size() {
return getQuark().countChildren();
}
public boolean instanceofGroupRoot() {
return getQuark().isRoot();
}
}

View File

@ -35,19 +35,11 @@
*/
package net.sourceforge.plantuml.baraye;
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;

View File

@ -1,124 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2023, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
* Contribution: Miguel Esteves
*
*/
package net.sourceforge.plantuml.baraye;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.sourceforge.plantuml.Hideable;
import net.sourceforge.plantuml.LineConfigurable;
import net.sourceforge.plantuml.Removeable;
import net.sourceforge.plantuml.SpecificBackcolorable;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.command.Position;
import net.sourceforge.plantuml.cucadiagram.Bodier;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.CucaNote;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.EntityPosition;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Stereostyles;
import net.sourceforge.plantuml.cucadiagram.Stereotag;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.graphic.color.Colors;
import net.sourceforge.plantuml.utils.LineLocation;
public interface IEntity extends SpecificBackcolorable, Hideable, Removeable, LineConfigurable {
public Code getCode();
public String getCodeGetName();
public Ident getIdent();
public USymbol getUSymbol();
public void setUSymbol(USymbol symbol);
public LeafType getLeafType();
public Display getDisplay();
public IGroup getParentContainer();
public void setDisplay(Display display);
public String getUid();
public Url getUrl99();
public Stereotype getStereotype();
public void setStereotype(Stereotype stereotype);
public Bodier getBodier();
public void addUrl(Url url);
public boolean isGroup();
public boolean hasUrl();
public int getRawLayout();
public void putTip(String member, Display display);
public Map<String, Display> getTips();
public void addStereotag(Stereotag tag);
public Set<Stereotag> stereotags();
public boolean isAloneAndUnlinked();
public String getCodeLine();
public void setCodeLine(LineLocation codeLine);
public void setStereostyle(String stereo);
public Stereostyles getStereostyles();
public void addNote(Display note, Position position, Colors colors);
public EntityPosition getEntityPosition();
public List<CucaNote> getNotes(Position position);
}

View File

@ -1,82 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2023, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.baraye;
import java.util.Collection;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.DisplayPositioned;
import net.sourceforge.plantuml.cucadiagram.GroupType;
import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.svek.IEntityImage;
import net.sourceforge.plantuml.svek.PackageStyle;
import net.sourceforge.plantuml.svek.SingleStrategy;
public interface IGroup extends IEntity {
public boolean containsLeafRecurse(ILeaf entity);
public Collection<ILeaf> getLeafsDirect();
public Collection<IGroup> getChildren();
public void moveEntitiesTo(IGroup dest);
public int size();
public GroupType getGroupType();
public Code getNamespace();
public PackageStyle getPackageStyle();
public void overrideImage(IEntityImage img, LeafType state);
public SingleStrategy getSingleStrategy();
public FontConfiguration getFontConfigurationForTitle(ISkinParam skinParam);
public char getConcurrentSeparator();
public void setConcurrentSeparator(char separator);
public void setLegend(DisplayPositioned legend);
public DisplayPositioned getLegend();
}

View File

@ -1,88 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2023, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.baraye;
import java.util.Collection;
import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Together;
import net.sourceforge.plantuml.cucadiagram.dot.Neighborhood;
import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.skin.VisibilityModifier;
import net.sourceforge.plantuml.svek.IEntityImage;
import net.sourceforge.plantuml.svek.Margins;
public interface ILeaf extends IEntity {
public void setContainer(IGroup container);
public Margins getMargins();
public int getXposition();
public void setXposition(int pos);
public IEntityImage getSvekImage();
public String getGeneric();
public boolean muteToType(LeafType newType, USymbol newSymbol);
public void setGeneric(String generic);
public void setSvekImage(IEntityImage svekImage);
public void setNeighborhood(Neighborhood neighborhood);
public Neighborhood getNeighborhood();
public Collection<String> getPortShortNames();
public void addPortShortName(String portShortName);
public void setVisibilityModifier(VisibilityModifier visibility);
public VisibilityModifier getVisibilityModifier();
public void setStatic(boolean isStatic);
public boolean isStatic();
public Together getTogether();
public void setTogether(Together together);
}

View File

@ -38,20 +38,18 @@ package net.sourceforge.plantuml.baraye;
import java.util.ArrayList;
import java.util.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<List<String>, Quark> quarks = new LinkedHashMap<>();
private final List<Quark> quarks = new ArrayList<>();
public Plasma(String separator) {
final List<String> 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<String> result = root.getSignature();
@ -87,53 +89,63 @@ public class Plasma {
}
Quark ensurePresent(List<String> 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<Quark> quarks() {
return Collections.unmodifiableCollection(new ArrayList<>(quarks.values()));
return Collections.unmodifiableCollection(quarks);
}
// public boolean exists(String name) {
// for (Quark quark : quarks.values())
// if (quark.getName().equals(name))
// return true;
// return false;
// }
public Quark getIfExistsFromName(String name) {
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<String> 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<Quark> getChildren(Quark parent) {
final List<Quark> 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);
}
}

View File

@ -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<String> parts;
private final String name;
private Object data;
Quark(Plasma plasma, Quark parent, List<String> parts) {
super(new ArrayList<String>(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<String>(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<String> getSignature() {
return new ArrayList<>(parts);
final List<String> result = new ArrayList<>();
if (parent != null)
result.addAll(parent.getSignature());
result.add(name);
return result;
}
public List<String> parts() {
return getSignature();
}
public boolean containsLarge(Quark other) {
return other.parts.size() > this.parts.size() && other.parts.subList(0, this.parts.size()).equals(this.parts);
final List<String> signature = this.parts();
final List<String> otherSignature = other.parts();
return otherSignature.size() > signature.size()
&& otherSignature.subList(0, signature.size()).equals(signature);
}
// @Override
@ -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<String> sig = new ArrayList<>(getSignature());
sig.add(name);
return plasma.getIfExists(sig);
}
public Quark parse(Quark path) {
final List<String> 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<String> 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;
}
}

View File

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

View File

@ -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;

View File

@ -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);
}

View File

@ -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<ClassDiagram> {
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))

View File

@ -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<ClassDiagram> {
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),

View File

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

View File

@ -41,7 +41,8 @@ import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.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.ClassDiagram;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
@ -50,9 +51,7 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOptional;
import net.sourceforge.plantuml.command.regex.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.Stereotag;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
@ -206,16 +205,22 @@ public class CommandCreateElementFull2 extends SingleLineCommand2<ClassDiagram>
}
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(),

View File

@ -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<ClassDiagram>
@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();
}

View File

@ -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<UmlDiagram> {
} 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<UmlDiagram> {
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<UmlDiagram> {
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()));
}

View File

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

View File

@ -1,601 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2023, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
* Contribution : Hisashi Miyashita
*
*
*/
package net.sourceforge.plantuml.classdiagram.command;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlMode;
import net.sourceforge.plantuml.baraye.IEntity;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexOr;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArg;
import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement;
import net.sourceforge.plantuml.descdiagram.command.Labels;
import net.sourceforge.plantuml.graphic.color.ColorParser;
import net.sourceforge.plantuml.graphic.color.ColorType;
import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram;
import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
import net.sourceforge.plantuml.utils.Direction;
import net.sourceforge.plantuml.utils.LineLocation;
final public class CommandLinkClass2 extends SingleLineCommand2<AbstractClassOrObjectDiagram> {
private static final String SINGLE = "[.\\\\]{0,2}[%pLN_]+(?:[.\\\\]{1,2}[%pLN_]+)*";
private static final String SINGLE_GUILLEMENT = "[%g][.\\\\]{0,2}[%pLN_]+(?:[.\\\\]{1,2}[%pLN_]+)*[%g]";
private static final String SINGLE2 = "(?:" + SINGLE + "|" + SINGLE_GUILLEMENT + ")";
private static final String COUPLE = "\\([%s]*(" + SINGLE2 + ")[%s]*,[%s]*(" + SINGLE2 + ")[%s]*\\)";
public CommandLinkClass2(UmlDiagramType umlDiagramType) {
super(getRegexConcat(umlDiagramType));
}
static private RegexConcat getRegexConcat(UmlDiagramType umlDiagramType) {
return RegexConcat.build(CommandLinkClass2.class.getName() + umlDiagramType, RegexLeaf.start(), //
new RegexOptional( //
new RegexConcat( //
new RegexLeaf("HEADER", "@([\\d.]+)"), //
RegexLeaf.spaceOneOrMore() //
)), new RegexOr( //
new RegexLeaf("ENT1", getClassIdentifier()), //
new RegexLeaf("COUPLE1", COUPLE)), //
RegexLeaf.spaceZeroOrMore(), //
new RegexOptional(new RegexConcat( //
RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("[\\[]"), //
new RegexLeaf("QUALIFIER1", "([^\\[\\]]+)"), //
new RegexLeaf("[\\]]"), //
RegexLeaf.spaceOneOrMore() //
)), //
new RegexOptional(new RegexLeaf("FIRST_LABEL", "[%g]([^%g]+)[%g]")), //
RegexLeaf.spaceZeroOrMore(), //
new RegexConcat(
//
new RegexLeaf("ARROW_HEAD1",
"((?<=[%s])+[ox]|[)#\\[<*+^}]|\\<_|\\<\\|[\\:\\|]|[<\\[]\\||\\}o|\\}\\||\\|o|\\|\\|)?"), //
new RegexLeaf("ARROW_BODY1", "([-=.]+)"), //
new RegexLeaf("ARROW_STYLE1", "(?:\\[(" + CommandLinkElement.LINE_STYLE + ")\\])?"), //
new RegexLeaf("ARROW_DIRECTION", "(left|right|up|down|le?|ri?|up?|do?)?"), //
new RegexOptional(new RegexLeaf("INSIDE", "(0|\\(0\\)|\\(0|0\\))(?=[-=.~])")), //
new RegexLeaf("ARROW_STYLE2", "(?:\\[(" + CommandLinkElement.LINE_STYLE + ")\\])?"), //
new RegexLeaf("ARROW_BODY2", "([-=.]*)"), //
new RegexLeaf("ARROW_HEAD2",
"([ox][%s]+|:\\>\\>?|_\\>|[(#\\]>*+^\\{]|[\\|\\:]\\|\\>|\\|[>\\]]|o\\{|\\|\\{|o\\||\\|\\|)?")), //
RegexLeaf.spaceZeroOrMore(), //
new RegexOptional(new RegexLeaf("SECOND_LABEL", "[%g]([^%g]+)[%g]")), //
new RegexOptional(new RegexConcat( //
RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("[\\[]"), //
new RegexLeaf("QUALIFIER2", "([^\\[\\]]+)"), //
new RegexLeaf("[\\]]"), //
RegexLeaf.spaceOneOrMore() //
)), //
RegexLeaf.spaceZeroOrMore(), //
new RegexOr( //
new RegexLeaf("ENT2", getClassIdentifier()), //
new RegexLeaf("COUPLE2", COUPLE)), //
RegexLeaf.spaceZeroOrMore(), //
color().getRegex(), //
RegexLeaf.spaceZeroOrMore(), //
UrlBuilder.OPTIONAL, //
RegexLeaf.spaceZeroOrMore(), //
new RegexOptional( //
new RegexConcat( //
new RegexLeaf(":"), //
RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("LABEL_LINK", "(.+)") //
)), RegexLeaf.end());
}
private static ColorParser color() {
return ColorParser.simpleColor(ColorType.LINE);
}
private static String getClassIdentifier() {
return "(" + getSeparator() + "?[%pLN_$]+(?:" + getSeparator() + "[%pLN_$]+)*|[%g][^%g]+[%g])";
}
public static String getSeparator() {
return "(?:\\.|::|\\\\|\\\\\\\\)";
}
@Override
protected CommandExecutionResult executeArg(AbstractClassOrObjectDiagram diagram, LineLocation location,
RegexResult arg) throws NoSuchColorException {
final String ent1String = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 0), "\"");
final String ent2String = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 0), "\"");
if (ent1String == null && ent2String == null)
return executeArgSpecial3(diagram, arg);
if (ent1String == null)
return executeArgSpecial1(diagram, arg);
if (ent2String == null)
return executeArgSpecial2(diagram, arg);
Ident ident1 = diagram.buildLeafIdentSpecial(ent1String);
Ident ident2 = diagram.buildLeafIdentSpecial(ent2String);
Ident ident1pure = Ident.empty().add(ent1String, diagram.getNamespaceSeparator());
Ident ident2pure = Ident.empty().add(ent2String, diagram.getNamespaceSeparator());
Code code1 = diagram.buildCode(ent1String);
Code code2 = diagram.buildCode(ent2String);
if (isGroupButNotTheCurrentGroup(diagram, code1, ident1)
&& isGroupButNotTheCurrentGroup(diagram, code2, ident2)) {
return executePackageLink(diagram, arg);
}
String port1 = null;
String port2 = null;
if (removeMemberPartLegacy1972(diagram, ident1) != null) {
port1 = ident1.getPortMember();
code1 = removeMemberPartLegacy1972(diagram, ident1);
ident1 = ident1.removeMemberPart();
}
if (removeMemberPartLegacy1972(diagram, ident2) != null) {
port2 = ident2.getPortMember();
code2 = removeMemberPartLegacy1972(diagram, ident2);
ident2 = ident2.removeMemberPart();
}
final IEntity cl1 = getFoo1(diagram, code1, ident1, ident1pure);
final IEntity cl2 = getFoo1(diagram, code2, ident2, ident2pure);
final LinkType linkType = getLinkType(arg);
final Direction dir = getDirection(arg);
final int queue;
if (dir == Direction.LEFT || dir == Direction.RIGHT)
queue = 1;
else
queue = getQueueLength(arg);
final Labels labels = new Labels(arg);
final String kal1 = arg.get("QUALIFIER1", 0);
final String kal2 = arg.get("QUALIFIER2", 0);
final LinkArg linkArg = LinkArg
.build(labels.getDisplay(), queue, diagram.getSkinParam().classAttributeIconSize() > 0)
.withQuantifier(labels.getFirstLabel(), labels.getSecondLabel())
.withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle()).withKal(kal1, kal2);
Link link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2,
linkType, linkArg);
if (arg.get("URL", 0) != null) {
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), UrlMode.STRICT);
final Url url = urlBuilder.getUrl(arg.get("URL", 0));
link.setUrl(url);
}
link.setPortMembers(port1, port2);
if (dir == Direction.LEFT || dir == Direction.UP)
link = link.getInv();
link.setLinkArrow(labels.getLinkArrow());
link.setColors(color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet()));
link.applyStyle(arg.getLazzy("ARROW_STYLE", 0));
link.setCodeLine(location);
addLink(diagram, link, arg.get("HEADER", 0));
return CommandExecutionResult.ok();
}
private IEntity getFoo1(AbstractClassOrObjectDiagram diagram, Code code, Ident ident, Ident pure) {
if (isGroupButNotTheCurrentGroup(diagram, code, ident))
return diagram.getGroupVerySmart(ident);
return diagram.getOrCreateLeaf(ident, code, null, null);
}
private boolean isGroupButNotTheCurrentGroup(AbstractClassOrObjectDiagram diagram, Code code, Ident ident) {
if (diagram.getCurrentGroup().getCodeGetName().equals(code.getName()))
return false;
if (diagram.isGroupStrict(ident))
return true;
return diagram.isGroup(code);
}
private Code removeMemberPartLegacy1972(AbstractClassOrObjectDiagram diagram, Ident ident) {
if (diagram.leafExist(ident))
return null;
final Ident before = ident.removeMemberPart();
if (before == null)
return null;
final Code code = before.toCode(diagram);
if (diagram.leafExist(code) == false)
return null;
return code;
}
private void addLink(AbstractClassOrObjectDiagram diagram, Link link, String weight) {
diagram.addLink(link);
if (weight == null) {
// final LinkType type = link.getType();
// --|> highest
// --*, -->, --o normal
// ..*, ..>, ..o lowest
// if (type.isDashed() == false) {
// if (type.contains(LinkDecor.EXTENDS)) {
// link.setWeight(3);
// }
// if (type.contains(LinkDecor.ARROW) ||
// type.contains(LinkDecor.COMPOSITION)
// || type.contains(LinkDecor.AGREGATION)) {
// link.setWeight(2);
// }
// }
} else {
link.setWeight(Double.parseDouble(weight));
}
}
private CommandExecutionResult executePackageLink(AbstractClassOrObjectDiagram diagram, RegexResult arg)
throws NoSuchColorException {
final String ent1String = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 0), "\"");
final String ent2String = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 0), "\"");
Ident ident1 = diagram.buildLeafIdentSpecial(ent1String);
Ident ident2 = diagram.buildLeafIdentSpecial(ent2String);
final Ident ident1pure = Ident.empty().add(ent1String, diagram.getNamespaceSeparator());
final Ident ident2pure = Ident.empty().add(ent2String, diagram.getNamespaceSeparator());
Code code1 = diagram.buildCode(ent1String);
Code code2 = diagram.buildCode(ent2String);
if (removeMemberPartLegacy1972(diagram, ident1) != null) {
code1 = removeMemberPartLegacy1972(diagram, ident1);
ident1 = ident1.removeMemberPart();
}
if (removeMemberPartLegacy1972(diagram, ident2) != null) {
code2 = removeMemberPartLegacy1972(diagram, ident2);
ident2 = ident2.removeMemberPart();
}
final IEntity cl1 = getFoo1(diagram, code1, ident1, ident1pure);
final IEntity cl2 = getFoo1(diagram, code2, ident2, ident2pure);
final LinkType linkType = getLinkType(arg);
final Direction dir = getDirection(arg);
final int queue;
if (dir == Direction.LEFT || dir == Direction.RIGHT)
queue = 1;
else
queue = getQueueLength(arg);
final Display labelLink = Display.getWithNewlines(arg.get("LABEL_LINK", 0));
final String firstLabel = arg.get("FIRST_LABEL", 0);
final String secondLabel = arg.get("SECOND_LABEL", 0);
final LinkArg linkArg = LinkArg.build(labelLink, queue, diagram.getSkinParam().classAttributeIconSize() > 0);
final Link link = new Link(diagram.getIEntityFactory(), diagram.getSkinParam().getCurrentStyleBuilder(), cl1,
cl2, linkType, linkArg.withQuantifier(firstLabel, secondLabel)
.withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle()));
link.setColors(color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet()));
diagram.resetPragmaLabel();
link.applyStyle(arg.getLazzy("ARROW_STYLE", 0));
addLink(diagram, link, arg.get("HEADER", 0));
return CommandExecutionResult.ok();
}
private CommandExecutionResult executeArgSpecial1(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
final String name1A = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("COUPLE1", 0));
final String name1B = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("COUPLE1", 1));
final Code clName1A = diagram.buildCode(name1A);
final Code clName1B = diagram.buildCode(name1B);
if (diagram.leafExist(clName1A) == false)
return CommandExecutionResult.error("No class " + clName1A);
if (diagram.leafExist(clName1B) == false)
return CommandExecutionResult.error("No class " + clName1B);
final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 0), "\"");
final Code ent2 = diagram.buildCode(idShort);
final IEntity cl2 = diagram.getOrCreateLeaf(diagram.buildLeafIdent(idShort), ent2, null, null);
final LinkType linkType = getLinkType(arg);
final Display label = Display.getWithNewlines(arg.get("LABEL_LINK", 0));
final boolean result = diagram.associationClass(1, name1A, name1B, cl2, linkType, label);
if (result == false)
return CommandExecutionResult.error("Cannot have more than 2 assocications");
return CommandExecutionResult.ok();
}
private CommandExecutionResult executeArgSpecial3(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
final String name1A = arg.get("COUPLE1", 0);
final String name1B = arg.get("COUPLE1", 1);
final String name2A = arg.get("COUPLE2", 0);
final String name2B = arg.get("COUPLE2", 1);
final Code clName1A = diagram.buildCode(name1A);
final Code clName1B = diagram.buildCode(name1B);
final Code clName2A = diagram.buildCode(name2A);
final Code clName2B = diagram.buildCode(name2B);
if (diagram.leafExist(clName1A) == false)
return CommandExecutionResult.error("No class " + clName1A);
if (diagram.leafExist(clName1B) == false)
return CommandExecutionResult.error("No class " + clName1B);
if (diagram.leafExist(clName2A) == false)
return CommandExecutionResult.error("No class " + clName2A);
if (diagram.leafExist(clName2B) == false)
return CommandExecutionResult.error("No class " + clName2B);
final LinkType linkType = getLinkType(arg);
final Display label = Display.getWithNewlines(arg.get("LABEL_LINK", 0));
return diagram.associationClass(name1A, name1B, name2A, name2B, linkType, label);
}
private CommandExecutionResult executeArgSpecial2(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
final String name2A = arg.get("COUPLE2", 0);
final String name2B = arg.get("COUPLE2", 1);
final Code clName2A = diagram.buildCode(name2A);
final Code clName2B = diagram.buildCode(name2B);
if (diagram.leafExist(clName2A) == false)
return CommandExecutionResult.error("No class " + clName2A);
if (diagram.leafExist(clName2B) == false)
return CommandExecutionResult.error("No class " + clName2B);
final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 0), "\"");
final Code ent1 = diagram.buildCode(idShort);
final IEntity cl1 = diagram.getOrCreateLeaf(diagram.buildLeafIdent(idShort), ent1, null, null);
final LinkType linkType = getLinkType(arg);
final Display label = Display.getWithNewlines(arg.get("LABEL_LINK", 0));
final boolean result = diagram.associationClass(2, name2A, name2B, cl1, linkType, label);
if (result == false)
return CommandExecutionResult.error("Cannot have more than 2 assocications");
return CommandExecutionResult.ok();
}
private LinkDecor getDecors1(String s) {
if (s == null) {
return LinkDecor.NONE;
}
s = StringUtils.trin(s);
if ("<|".equals(s))
return LinkDecor.EXTENDS;
if ("<|:".equals(s))
return LinkDecor.DEFINEDBY;
if ("<||".equals(s))
return LinkDecor.REDEFINES;
if ("}".equals(s))
return LinkDecor.CROWFOOT;
if ("}o".equals(s))
return LinkDecor.CIRCLE_CROWFOOT;
if ("}|".equals(s))
return LinkDecor.LINE_CROWFOOT;
if ("|o".equals(s))
return LinkDecor.CIRCLE_LINE;
if ("||".equals(s))
return LinkDecor.DOUBLE_LINE;
if ("<".equals(s))
return LinkDecor.ARROW;
if ("^".equals(s))
return LinkDecor.EXTENDS;
if ("+".equals(s))
return LinkDecor.PLUS;
if ("o".equals(s))
return LinkDecor.AGREGATION;
if ("x".equals(s))
return LinkDecor.NOT_NAVIGABLE;
if ("*".equals(s))
return LinkDecor.COMPOSITION;
if ("#".equals(s))
return LinkDecor.SQUARE;
if (")".equals(s))
return LinkDecor.PARENTHESIS;
return LinkDecor.NONE;
}
private LinkDecor getDecors2(String s) {
if (s == null)
return LinkDecor.NONE;
s = StringUtils.trin(s);
if ("|>".equals(s))
return LinkDecor.EXTENDS;
if (":|>".equals(s))
return LinkDecor.DEFINEDBY;
if ("||>".equals(s))
return LinkDecor.REDEFINES;
if (">".equals(s))
return LinkDecor.ARROW;
if ("{".equals(s))
return LinkDecor.CROWFOOT;
if ("o{".equals(s))
return LinkDecor.CIRCLE_CROWFOOT;
if ("|{".equals(s))
return LinkDecor.LINE_CROWFOOT;
if ("o|".equals(s))
return LinkDecor.CIRCLE_LINE;
if ("||".equals(s))
return LinkDecor.DOUBLE_LINE;
if ("^".equals(s))
return LinkDecor.EXTENDS;
if ("+".equals(s))
return LinkDecor.PLUS;
if ("o".equals(s))
return LinkDecor.AGREGATION;
if ("x".equals(s))
return LinkDecor.NOT_NAVIGABLE;
if ("*".equals(s))
return LinkDecor.COMPOSITION;
if ("#".equals(s))
return LinkDecor.SQUARE;
if ("(".equals(s))
return LinkDecor.PARENTHESIS;
return LinkDecor.NONE;
}
private LinkType getLinkType(RegexResult arg) {
final LinkDecor decors1 = getDecors1(getArrowHead1(arg));
final LinkDecor decors2 = getDecors2(getArrowHead2(arg));
LinkType result = new LinkType(decors2, decors1);
if (arg.get("ARROW_BODY1", 0).contains(".") || arg.get("ARROW_BODY2", 0).contains("."))
result = result.goDashed();
final String middle = arg.get("INSIDE", 0);
if ("0".equals(middle))
result = result.withMiddleCircle();
else if ("0)".equals(middle))
result = result.withMiddleCircleCircled1();
else if ("(0".equals(middle))
result = result.withMiddleCircleCircled2();
else if ("(0)".equals(middle))
result = result.withMiddleCircleCircled();
return result;
}
private int getQueueLength(RegexResult arg) {
String s = getFullArrow(arg);
s = s.replaceAll("[^-.=]", "");
return s.length();
}
private Direction getDirection(RegexResult arg) {
// final LinkDecor decors1 = getDecors1(getArrowHead1(arg));
// final LinkDecor decors2 = getDecors2(getArrowHead2(arg));
String s = getFullArrow(arg);
s = s.replaceAll("[^-.=\\w]", "");
if (s.startsWith("o"))
s = s.substring(1);
if (s.endsWith("o"))
s = s.substring(0, s.length() - 1);
Direction result = StringUtils.getQueueDirection(s);
// if (isInversed(decors1, decors2) && s.matches(".*\\w.*")) {
// result = result.getInv();
// }
return result;
}
private String getArrowHead1(RegexResult arg) {
return getArrowHead(arg, "ARROW_HEAD1");
}
private String getArrowHead2(RegexResult arg) {
return getArrowHead(arg, "ARROW_HEAD2");
}
private String getArrowHead(RegexResult arg, final String key) {
return notNull(arg.get(key, 0));
}
private String getFullArrow(RegexResult arg) {
return getArrowHead1(arg) + notNull(arg.get("ARROW_BODY1", 0)) + notNull(arg.get("ARROW_DIRECTION", 0))
+ notNull(arg.get("ARROW_BODY2", 0)) + getArrowHead2(arg);
}
public static String notNull(String s) {
if (s == null)
return "";
return s;
}
}

View File

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

View File

@ -36,7 +36,8 @@
package net.sourceforge.plantuml.classdiagram.command;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.baraye.IEntity;
import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.classdiagram.ClassDiagram;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
@ -44,8 +45,6 @@ import net.sourceforge.plantuml.command.regex.IRegex;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.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.Stereotype;
import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
import net.sourceforge.plantuml.utils.LineLocation;
@ -68,10 +67,16 @@ public class CommandStereotype extends SingleLineCommand2<ClassDiagram> {
protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg)
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()));

View File

@ -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<AbstractEntityDiagram> {
@ -75,17 +74,22 @@ public class CommandUrl extends SingleLineCommand2<AbstractEntityDiagram> {
@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);

View File

@ -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) {

View File

@ -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;

View File

@ -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;

View File

@ -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)

View File

@ -62,7 +62,9 @@ public class CommandAffineTransform extends SingleLineCommand2<UmlDiagram> {
@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();
}

View File

@ -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<ClassDiagram> {
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(),

View File

@ -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<ClassDiagram> {
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));

View File

@ -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<ClassDiagram> {
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));

View File

@ -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<AbstractEntityDiagram> {
@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;
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);

View File

@ -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<AbstractEntityDiagra
display = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("DISPLAY", 0));
idShort = arg.get("CODE", 0);
}
final IGroup currentPackage = diagram.getCurrentGroup();
final Ident ident = diagram.buildLeafIdent(idShort);
final Code code = diagram.buildCode(idShort);
final CommandExecutionResult status = diagram.gotoGroup(ident, code, Display.getWithNewlines(display),
GroupType.PACKAGE, currentPackage, NamespaceStrategy.SINGLE);
final Quark quark = diagram.quarkInContext(diagram.cleanIdForQuark(idShort), true);
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 color = arg.get("COLOR", 0);
if (color != null)
p.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet().getColor(color));

View File

@ -78,23 +78,25 @@ public class CommandPragma extends SingleLineCommand2<TitledDiagram> {
}
} 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();
}

View File

@ -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<Abstr
private CommandExecutionResult executeInternal(AbstractEntityDiagram diagram, RegexResult arg, BlocLines display)
throws NoSuchColorException {
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("Note already created: " + 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("Note already created: " + quark.getName());
final IEntity entity = diagram.createLeaf(ident, code, display.toDisplay(), LeafType.NOTE, null);
final EntityImp entity = diagram.reallyCreateLeaf(quark, display.toDisplay(), LeafType.NOTE, null);
// final Quark quark = diagram.getPlasma().getIfExistsFromName(idShort);
// if (quark != null && quark.getData() != null)
// entity = diagram.getFromName(idShort);
// else
// entity = diagram.reallyCreateLeaf(ident, display.toDisplay(), LeafType.NOTE, null);
assert entity != null;
final String s = arg.get("COLOR", 0);
entity.setSpecificColorTOBEREMOVED(ColorType.BACK,

View File

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

View File

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

View File

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

View File

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

View File

@ -35,7 +35,8 @@
*/
package net.sourceforge.plantuml.compositediagram.command;
import net.sourceforge.plantuml.baraye.IEntity;
import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.IRegex;
@ -44,8 +45,8 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.compositediagram.CompositeDiagram;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.utils.LineLocation;
public class CommandCreateBlock extends SingleLineCommand2<CompositeDiagram> {
@ -72,12 +73,15 @@ public class CommandCreateBlock extends SingleLineCommand2<CompositeDiagram> {
protected CommandExecutionResult executeArg(CompositeDiagram diagram, LineLocation location, RegexResult arg) {
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();
}

View File

@ -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<CompositeDiagram> {
@ -74,16 +71,14 @@ public class CommandCreatePackageBlock extends SingleLineCommand2<CompositeDiagr
@Override
protected CommandExecutionResult executeArg(CompositeDiagram diagram, LineLocation location, RegexResult arg) {
final IGroup currentPackage = diagram.getCurrentGroup();
String display = arg.get("DISPLAY", 0);
final String idShort = arg.get("CODE", 0);
final Code code = diagram.buildCode(idShort);
final Quark quark = diagram.quarkInContext(idShort, false);
if (display == null)
display = code.getName();
display = quark.getName();
final Ident idNewLong = diagram.buildLeafIdent(idShort);
return diagram.gotoGroup(idNewLong, code, Display.getWithNewlines(display), GroupType.PACKAGE, currentPackage,
NamespaceStrategy.SINGLE);
return diagram.gotoGroup(quark, Display.getWithNewlines(display), GroupType.PACKAGE);
}
}

View File

@ -34,7 +34,8 @@
*/
package net.sourceforge.plantuml.compositediagram.command;
import net.sourceforge.plantuml.baraye.IEntity;
import net.sourceforge.plantuml.baraye.EntityImp;
import net.sourceforge.plantuml.baraye.Quark;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.IRegex;
@ -78,8 +79,17 @@ public class CommandLinkBlock extends SingleLineCommand2<CompositeDiagram> {
protected CommandExecutionResult executeArg(CompositeDiagram diagram, LineLocation location, RegexResult arg) {
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<CompositeDiagram> {
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();

View File

@ -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(

View File

@ -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;

View File

@ -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() {

View File

@ -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() {

View File

@ -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);

View File

@ -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;

View File

@ -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();

View File

@ -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();

View File

@ -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);
}

View File

@ -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<Member> methodsToDisplay;
private List<Member> 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);
}

View File

@ -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<CharSequence> rawBody = new ArrayList<>();
private final Map<String, String> map = new LinkedHashMap<String, String>();
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);
}

View File

@ -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<CharSequence> 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);
}

View File

@ -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<Url> urls = new ArrayList<>();
private final ILeaf entity;
private final EntityImp entity;
private final boolean inEllipse;
private final Style style;
BodyEnhanced1(HorizontalAlignment align, List<CharSequence> rawBody, ISkinParam skinParam, ILeaf entity,
BodyEnhanced1(HorizontalAlignment align, List<CharSequence> rawBody, ISkinParam skinParam, EntityImp entity,
Style style) {
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;

View File

@ -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<CharSequence> 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);
}

View File

@ -1,82 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2023, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.cucadiagram;
import java.util.Objects;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.baraye.EntityFactory;
public class CodeImpl implements Code {
private final String name;
private CodeImpl(String name) {
this.name = Objects.requireNonNull(name);
}
public static Code of(String code) {
if (code == null)
EntityFactory.bigError();
return new CodeImpl(code);
}
public final String getName() {
return name;
}
@Override
public String toString() {
return name;
}
@Override
public int hashCode() {
return name.hashCode();
}
@Override
public boolean equals(Object obj) {
final CodeImpl other = (CodeImpl) obj;
return this.name.equals(other.name);
}
public Code eventuallyRemoveStartingAndEndingDoubleQuote(String format) {
return CodeImpl.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(getName(), format));
}
}

View File

@ -52,6 +52,7 @@ import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.SpriteContainer;
import net.sourceforge.plantuml.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<CharSequence> {
// }
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<CharSequence> {
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());
}

View File

@ -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);
}

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