diff --git a/pom.xml b/pom.xml index d6f7bfdb6..636c03dfd 100644 --- a/pom.xml +++ b/pom.xml @@ -30,13 +30,12 @@ Script Author: Julien Eluard --> - + 4.0.0 net.sourceforge.plantuml plantuml - 1.2019.9-SNAPSHOT + 1.2019.11-SNAPSHOT jar PlantUML @@ -125,6 +124,7 @@ ${project.basedir} stdlib/**/*.repx + skin/**/*.skin diff --git a/skin/plantuml.skin b/skin/plantuml.skin index b5c837e0f..4b2ba0869 100644 --- a/skin/plantuml.skin +++ b/skin/plantuml.skin @@ -21,8 +21,8 @@ title { HorizontalAlignment center FontSize 14 FontStyle bold - Padding 0 - Margin 4 + Padding 5 + Margin 5 LineColor none BackGroundColor none } @@ -145,21 +145,26 @@ actor { } boundary { + LineThickness 2.0 } control { + LineThickness 2.0 } entity { + LineThickness 2.0 } queue { + LineThickness 2.0 } database { } collections { + LineThickness 1.5 } swimlane { diff --git a/src/net/sourceforge/plantuml/AParentFolderRegular.java b/src/net/sourceforge/plantuml/AParentFolderRegular.java index e89b274bb..ecd222e9e 100644 --- a/src/net/sourceforge/plantuml/AParentFolderRegular.java +++ b/src/net/sourceforge/plantuml/AParentFolderRegular.java @@ -44,7 +44,7 @@ public class AParentFolderRegular implements AParentFolder { public AParentFolderRegular(File dir) { this.dir = dir; - Log.info("Creating AParentFolderRegular " + dir); + // Log.info("Creating AParentFolderRegular " + dir); } @Override @@ -54,14 +54,14 @@ public class AParentFolderRegular implements AParentFolder { public AFile getAFile(String nameOrPath) throws IOException { final File filecurrent; - Log.info("AParentFolderRegular::looking for " + nameOrPath); - Log.info("AParentFolderRegular::dir = " + dir); + // Log.info("AParentFolderRegular::looking for " + nameOrPath); + // Log.info("AParentFolderRegular::dir = " + dir); if (dir == null) { filecurrent = new File(nameOrPath); } else { filecurrent = new File(dir.getAbsoluteFile(), nameOrPath); } - Log.info("AParentFolderRegular::Filecurrent " + filecurrent); + // Log.info("AParentFolderRegular::Filecurrent " + filecurrent); if (filecurrent.exists()) { return new AFileRegular(filecurrent.getCanonicalFile()); } diff --git a/src/net/sourceforge/plantuml/BlockUmlBuilder.java b/src/net/sourceforge/plantuml/BlockUmlBuilder.java index c25cb7a33..f199844a9 100644 --- a/src/net/sourceforge/plantuml/BlockUmlBuilder.java +++ b/src/net/sourceforge/plantuml/BlockUmlBuilder.java @@ -82,6 +82,7 @@ public final class BlockUmlBuilder implements DefinitionsContainer { includer.close(); usedFiles = includer.getFilesUsed(); } + reader.close(); } } diff --git a/src/net/sourceforge/plantuml/FileFormat.java b/src/net/sourceforge/plantuml/FileFormat.java index a61746810..0b5ecccd0 100644 --- a/src/net/sourceforge/plantuml/FileFormat.java +++ b/src/net/sourceforge/plantuml/FileFormat.java @@ -42,10 +42,13 @@ import java.awt.geom.Dimension2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.File; +import java.io.IOException; import net.sourceforge.plantuml.braille.BrailleCharFactory; import net.sourceforge.plantuml.braille.UGraphicBraille; import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.png.MetadataTag; +import net.sourceforge.plantuml.svg.SvgGraphics; import net.sourceforge.plantuml.ugraphic.UFont; /** @@ -202,4 +205,32 @@ public enum FileFormat { return name.replaceAll("\\" + getFileSuffix() + "$", OptionFlags.getInstance().getFileSeparator() + String.format("%03d", i) + getFileSuffix()); } + + public boolean doesSupportMetadata() { + return this == PNG || this == SVG; + } + + public boolean equalsMetadata(String currentMetadata, File existingFile) { + try { + if (this == PNG) { + final MetadataTag tag = new MetadataTag(existingFile, "plantuml"); + final String previousMetadata = tag.getData(); + final boolean sameMetadata = currentMetadata.equals(previousMetadata); + return sameMetadata; + } + if (this == SVG) { + final String svg = FileUtils.readSvg(existingFile); + final String currentSignature = SvgGraphics.getMD5Hex(currentMetadata); + final int idx = svg.lastIndexOf(SvgGraphics.MD5_HEADER); + if (idx != -1) { + final String part = svg.substring(idx + SvgGraphics.MD5_HEADER.length()); + return part.startsWith(currentSignature); + } + + } + } catch (IOException e) { + e.printStackTrace(); + } + return false; + } } diff --git a/src/net/sourceforge/plantuml/Log.java b/src/net/sourceforge/plantuml/Log.java index d5172e72d..b69ed9a70 100644 --- a/src/net/sourceforge/plantuml/Log.java +++ b/src/net/sourceforge/plantuml/Log.java @@ -97,16 +97,16 @@ public abstract class Log { } public static void println(Object s) { - if (header2.get() == null) { - System.err.println("L = " + s); - } else { - System.err.println(header2.get() + " " + s); - } + // if (header2.get() == null) { + // System.err.println("L = " + s); + // } else { + // System.err.println(header2.get() + " " + s); + // } } - private static final ThreadLocal header2 = new ThreadLocal(); - + // private static final ThreadLocal header2 = new ThreadLocal(); + // public static void header(String s) { - header2.set(s); + // header2.set(s); } } diff --git a/src/net/sourceforge/plantuml/OptionPrint.java b/src/net/sourceforge/plantuml/OptionPrint.java index a03a57a2b..cf2c08e92 100644 --- a/src/net/sourceforge/plantuml/OptionPrint.java +++ b/src/net/sourceforge/plantuml/OptionPrint.java @@ -192,12 +192,13 @@ public class OptionPrint { public static Collection interestingProperties() { final Properties p = System.getProperties(); - final List all = withIp() ? Arrays.asList("java.runtime.name", "Java Runtime", "java.vm.name", "JVM", + final List list1 = Arrays.asList("java.runtime.name", "Java Runtime", "java.vm.name", "JVM", "java.runtime.version", "Java Version", "os.name", "Operating System", "file.encoding", - "Default Encoding", "user.language", "Language", "user.country", "Country") : Arrays.asList( - "java.runtime.name", "Java Runtime", "java.vm.name", "JVM", "java.runtime.version", "Java Version", - "os.name", "Operating System", "os.version", "OS Version", "file.encoding", "Default Encoding", - "user.language", "Language", "user.country", "Country"); + "Default Encoding", "user.language", "Language", "user.country", "Country"); + final List list2 = Arrays.asList("java.runtime.name", "Java Runtime", "java.vm.name", "JVM", + "java.runtime.version", "Java Version", "os.name", "Operating System", /* "os.version", "OS Version", */ + "file.encoding", "Default Encoding", "user.language", "Language", "user.country", "Country"); + final List all = withIp() ? list1 : list2; final List result = new ArrayList(); for (int i = 0; i < all.size(); i += 2) { result.add(all.get(i + 1) + ": " + p.getProperty(all.get(i))); diff --git a/src/net/sourceforge/plantuml/PSystemBuilder.java b/src/net/sourceforge/plantuml/PSystemBuilder.java index 8cb2bec94..00a71f953 100644 --- a/src/net/sourceforge/plantuml/PSystemBuilder.java +++ b/src/net/sourceforge/plantuml/PSystemBuilder.java @@ -145,14 +145,13 @@ public class PSystemBuilder { final List factories = new ArrayList(); factories.add(new PSystemWelcomeFactory()); factories.add(new PSystemColorsFactory()); - factories.add(new ListSpriteDiagramFactory(skinParam)); factories.add(new SequenceDiagramFactory(skinParam)); factories.add(new ClassDiagramFactory(skinParam)); factories.add(new ActivityDiagramFactory(skinParam)); factories.add(new DescriptionDiagramFactory(skinParam)); factories.add(new StateDiagramFactory(skinParam)); factories.add(new ActivityDiagramFactory3(skinParam)); - factories.add(new CompositeDiagramFactory(skinParam)); + // factories.add(new CompositeDiagramFactory(skinParam)); factories.add(new BpmDiagramFactory(DiagramType.BPM)); // factories.add(new PostIdDiagramFactory()); factories.add(new PSystemLicenseFactory()); @@ -179,6 +178,7 @@ public class PSystemBuilder { factories.add(new PSystemSudokuFactory()); } factories.add(new PSystemDefinitionFactory()); + factories.add(new ListSpriteDiagramFactory(skinParam)); factories.add(new PSystemMathFactory(DiagramType.MATH)); factories.add(new PSystemLatexFactory(DiagramType.LATEX)); // factories.add(new PSystemStatsFactory()); diff --git a/src/net/sourceforge/plantuml/PSystemUtils.java b/src/net/sourceforge/plantuml/PSystemUtils.java index 7f4e7968d..060f50966 100644 --- a/src/net/sourceforge/plantuml/PSystemUtils.java +++ b/src/net/sourceforge/plantuml/PSystemUtils.java @@ -51,7 +51,6 @@ import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.cucadiagram.CucaDiagram; import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.html.CucaDiagramHtmlMaker; -import net.sourceforge.plantuml.png.MetadataTag; import net.sourceforge.plantuml.png.PngSplitter; import net.sourceforge.plantuml.project3.GanttDiagram; import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; @@ -66,19 +65,19 @@ public class PSystemUtils { public static List exportDiagrams(Diagram system, SuggestedFile suggestedFile, FileFormatOption fileFormatOption, boolean checkMetadata) throws IOException { - final File existing = suggestedFile.getFile(0); - if (checkMetadata && existing.exists() && system.getNbImages() == 1) { - final MetadataTag tag = new MetadataTag(existing, "plantuml"); - final String previousMetadata = tag.getData(); + final File existingFile = suggestedFile.getFile(0); + if (checkMetadata && fileFormatOption.getFileFormat().doesSupportMetadata() && existingFile.exists() + && system.getNbImages() == 1) { // final String version = Version.versionString(); // System.out.println(system.getMetadata()); // System.out.println(data); // System.out.println(version); // System.out.println(data.contains(version)); - final boolean sameMetadata = system.getMetadata().equals(previousMetadata); + final boolean sameMetadata = fileFormatOption.getFileFormat().equalsMetadata(system.getMetadata(), + existingFile); if (sameMetadata) { - Log.info("Skipping " + existing.getAbsolutePath() + " because metadata has not changed."); - return Arrays.asList(new FileImageData(existing, null)); + Log.info("Skipping " + existingFile.getAbsolutePath() + " because metadata has not changed."); + return Arrays.asList(new FileImageData(existingFile, null)); } } diff --git a/src/net/sourceforge/plantuml/Pipe.java b/src/net/sourceforge/plantuml/Pipe.java index 6cef1d73b..cb9031133 100644 --- a/src/net/sourceforge/plantuml/Pipe.java +++ b/src/net/sourceforge/plantuml/Pipe.java @@ -100,11 +100,13 @@ public class Pipe { } else if (option.isPipeMap()) { final String result = sourceStringReader.getCMapData(option.getImageIndex(), option.getFileFormatOption()); + // https://forum.plantuml.net/10049/2019-pipemap-diagrams-containing-links-give-zero-exit-code + // We don't check errors + error.goOk(); if (result == null) { ps.println(); } else { ps.println(result); - error.goOk(); } } else { final OutputStream os = noStdErr ? new ByteArrayOutputStream() : ps; diff --git a/src/net/sourceforge/plantuml/SignatureUtils.java b/src/net/sourceforge/plantuml/SignatureUtils.java index 40edff348..ef830493a 100644 --- a/src/net/sourceforge/plantuml/SignatureUtils.java +++ b/src/net/sourceforge/plantuml/SignatureUtils.java @@ -52,13 +52,14 @@ import net.sourceforge.plantuml.code.AsciiEncoder; public class SignatureUtils { -// private static byte[] salting(String pass, byte[] salt) throws NoSuchAlgorithmException, InvalidKeySpecException, -// UnsupportedEncodingException { -// final byte[] tmp = salting2(pass, salt); -// return SignatureUtils.getSHA512raw(tmp); -// } + // private static byte[] salting(String pass, byte[] salt) throws NoSuchAlgorithmException, InvalidKeySpecException, + // UnsupportedEncodingException { + // final byte[] tmp = salting2(pass, salt); + // return SignatureUtils.getSHA512raw(tmp); + // } - public static byte[] salting(String pass, byte[] salt) throws NoSuchAlgorithmException, InvalidKeySpecException { + public static synchronized byte[] salting(String pass, byte[] salt) throws NoSuchAlgorithmException, + InvalidKeySpecException { final int iterations = 500; final int keyLength = 512; final SecretKeyFactory skf = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"); @@ -122,7 +123,7 @@ public class SignatureUtils { } } - public static byte[] getMD5raw(String s) throws NoSuchAlgorithmException, UnsupportedEncodingException { + public static synchronized byte[] getMD5raw(String s) throws NoSuchAlgorithmException, UnsupportedEncodingException { final MessageDigest msgDigest = MessageDigest.getInstance("MD5"); msgDigest.update(s.getBytes("UTF-8")); return msgDigest.digest(); @@ -132,7 +133,8 @@ public class SignatureUtils { return getSHA512raw(s.getBytes("UTF-8")); } - public static byte[] getSHA512raw(byte data[]) throws NoSuchAlgorithmException, UnsupportedEncodingException { + public static synchronized byte[] getSHA512raw(byte data[]) throws NoSuchAlgorithmException, + UnsupportedEncodingException { final MessageDigest msgDigest = MessageDigest.getInstance("SHA-512"); msgDigest.update(data); return msgDigest.digest(); @@ -147,7 +149,7 @@ public class SignatureUtils { } } - public static String getSignatureSha512(InputStream is) throws IOException { + public static synchronized String getSignatureSha512(InputStream is) throws IOException { try { final MessageDigest msgDigest = MessageDigest.getInstance("SHA-512"); int read = 0; @@ -178,7 +180,7 @@ public class SignatureUtils { return s; } - public static String getSignature(File f) throws IOException { + public static synchronized String getSignature(File f) throws IOException { try { final MessageDigest msgDigest = MessageDigest.getInstance("MD5"); final FileInputStream is = new FileInputStream(f); diff --git a/src/net/sourceforge/plantuml/SkinParam.java b/src/net/sourceforge/plantuml/SkinParam.java index 6f75d7f10..860c53b42 100644 --- a/src/net/sourceforge/plantuml/SkinParam.java +++ b/src/net/sourceforge/plantuml/SkinParam.java @@ -96,12 +96,12 @@ public class SkinParam implements ISkinParam { if (type == UmlDiagramType.WBS) { USE_STYLE2.set(true); } - // if (type == UmlDiagramType.SEQUENCE) { - // skin = "debug.skin"; - // USE_STYLE2.set(true); - // } +// if (type == UmlDiagramType.SEQUENCE) { +// // skin = "debug.skin"; +// USE_STYLE2.set(true); +// } // if (type == UmlDiagramType.ACTIVITY) { - // skin = "debug.skin"; + // // skin = "debug.skin"; // USE_STYLE2.set(true); // } } @@ -177,8 +177,7 @@ public class SkinParam implements ISkinParam { } if (USE_STYLES()) { final FromSkinparamToStyle convertor = new FromSkinparamToStyle(key2, value, getCurrentStyleBuilder()); - final Style style = convertor.getStyle(); - if (style != null) { + for (Style style : convertor.getStyles()) { muteStyle(style); } } diff --git a/src/net/sourceforge/plantuml/SourceFileReader.java b/src/net/sourceforge/plantuml/SourceFileReader.java index 6c7203230..76fa38c67 100644 --- a/src/net/sourceforge/plantuml/SourceFileReader.java +++ b/src/net/sourceforge/plantuml/SourceFileReader.java @@ -37,6 +37,7 @@ package net.sourceforge.plantuml; import java.io.File; import java.io.IOException; +import java.io.Reader; import java.util.Collections; import java.util.List; @@ -83,7 +84,8 @@ public class SourceFileReader extends SourceFileReaderAbstract implements ISourc } this.outputDirectory = outputDirectory; - builder = new BlockUmlBuilder(config, charset, defines, getReader(charset), file.getAbsoluteFile() + final Reader reader = getReader(charset); + builder = new BlockUmlBuilder(config, charset, defines, reader, file.getAbsoluteFile() .getParentFile(), FileWithSuffix.getFileName(file)); } diff --git a/src/net/sourceforge/plantuml/SourceFileReaderAbstract.java b/src/net/sourceforge/plantuml/SourceFileReaderAbstract.java index 337f03d4e..1d219a5d8 100644 --- a/src/net/sourceforge/plantuml/SourceFileReaderAbstract.java +++ b/src/net/sourceforge/plantuml/SourceFileReaderAbstract.java @@ -147,6 +147,7 @@ public abstract class SourceFileReaderAbstract { try { system = blockUml.getDiagram(); } catch (Throwable t) { + t.printStackTrace(); return getCrashedImage(blockUml, t, suggested.getFile(0)); } diff --git a/src/net/sourceforge/plantuml/SourceFileReaderCopyCat.java b/src/net/sourceforge/plantuml/SourceFileReaderCopyCat.java index 0d7ef2304..b44f8c1b2 100644 --- a/src/net/sourceforge/plantuml/SourceFileReaderCopyCat.java +++ b/src/net/sourceforge/plantuml/SourceFileReaderCopyCat.java @@ -37,7 +37,6 @@ package net.sourceforge.plantuml; import java.io.File; import java.io.IOException; -import java.util.Collections; import java.util.List; import net.sourceforge.plantuml.preproc.Defines; diff --git a/src/net/sourceforge/plantuml/StringLocated.java b/src/net/sourceforge/plantuml/StringLocated.java index e29c77b0f..76256daa1 100644 --- a/src/net/sourceforge/plantuml/StringLocated.java +++ b/src/net/sourceforge/plantuml/StringLocated.java @@ -52,6 +52,10 @@ final public class StringLocated { return s; } + public StringLocated append(String endOfLine) { + return new StringLocated(s + endOfLine, location, preprocessorError); + } + public StringLocated(String s, LineLocation location, String preprocessorError) { if (s == null) { throw new IllegalArgumentException(); @@ -131,4 +135,5 @@ final public class StringLocated { } return fox; } + } diff --git a/src/net/sourceforge/plantuml/UmlDiagram.java b/src/net/sourceforge/plantuml/UmlDiagram.java index b3850c9e6..e0c134903 100644 --- a/src/net/sourceforge/plantuml/UmlDiagram.java +++ b/src/net/sourceforge/plantuml/UmlDiagram.java @@ -46,7 +46,6 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.List; @@ -60,7 +59,6 @@ import net.sourceforge.plantuml.api.ImageDataSimple; import net.sourceforge.plantuml.command.BlocLines; import net.sourceforge.plantuml.command.CommandControl; import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.CommandSkinParam; import net.sourceforge.plantuml.command.CommandSkinParamMultilines; import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.core.ImageData; diff --git a/src/net/sourceforge/plantuml/acearth/PSystemXearth.java b/src/net/sourceforge/plantuml/acearth/PSystemXearth.java index f3534d866..169cd2e36 100644 --- a/src/net/sourceforge/plantuml/acearth/PSystemXearth.java +++ b/src/net/sourceforge/plantuml/acearth/PSystemXearth.java @@ -80,31 +80,33 @@ public class PSystemXearth extends AbstractPSystem { @Override final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed) throws IOException { - final ACearth earth = new ACearth(markers); - final ConfigurationACearth conf = earth.getConf(); - conf.setInt("imageWidth", width); - conf.setInt("imageHeight", height); + synchronized (PSystemXearth.class) { + final ACearth earth = new ACearth(markers); + final ConfigurationACearth conf = earth.getConf(); + conf.setInt("imageWidth", width); + conf.setInt("imageHeight", height); - for (Map.Entry ent : config.entrySet()) { - final String key = ent.getKey(); - final String value = ent.getValue(); - if (key.equalsIgnoreCase("GMT")) { - final Date date = extractGmt(value); - conf.setInt("fixedTime", (int) (date.getTime() / 1000L)); - } else if (enums.contains(key)) { - conf.getMOEnum(key).set(value); - } else if (doubles.contains(key)) { - conf.setDouble(key, Double.parseDouble(value)); - } else if (integers.contains(key)) { - conf.setInt(key, Integer.parseInt(value)); - } else if (booleans.contains(key)) { - conf.setBoolean(key, value.equalsIgnoreCase("true")); - } else { - throw new UnsupportedOperationException(key); + for (Map.Entry ent : config.entrySet()) { + final String key = ent.getKey(); + final String value = ent.getValue(); + if (key.equalsIgnoreCase("GMT")) { + final Date date = extractGmt(value); + conf.setInt("fixedTime", (int) (date.getTime() / 1000L)); + } else if (enums.contains(key)) { + conf.getMOEnum(key).set(value); + } else if (doubles.contains(key)) { + conf.setDouble(key, Double.parseDouble(value)); + } else if (integers.contains(key)) { + conf.setInt(key, Integer.parseInt(value)); + } else if (booleans.contains(key)) { + conf.setBoolean(key, value.equalsIgnoreCase("true")); + } else { + throw new UnsupportedOperationException(key); + } } + earth.exportPng(os); + return new ImageDataSimple(width, height); } - earth.exportPng(os); - return new ImageDataSimple(width, height); } private Date extractGmt(String s) { diff --git a/src/net/sourceforge/plantuml/activitydiagram/ConditionalContext.java b/src/net/sourceforge/plantuml/activitydiagram/ConditionalContext.java index 87ffaaf12..dd8dde274 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/ConditionalContext.java +++ b/src/net/sourceforge/plantuml/activitydiagram/ConditionalContext.java @@ -46,6 +46,9 @@ public class ConditionalContext { private final ConditionalContext parent; public ConditionalContext(ConditionalContext parent, IEntity branch, Direction direction) { + if (branch == null) { + throw new IllegalArgumentException("branch is null"); + } if (branch.getLeafType() != LeafType.BRANCH) { throw new IllegalArgumentException(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java index 250a262f7..2e912745d 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java @@ -75,12 +75,11 @@ public class ActivityDiagram3 extends UmlDiagram { private SwimlaneStrategy swimlaneStrategy; private final SwimlanesC swinlanes = new SwimlanesC(getSkinParam(), getPragma()); - + public ActivityDiagram3(ISkinSimple skinParam) { super(skinParam); } - private void manageSwimlaneStrategy() { if (swimlaneStrategy == null) { swimlaneStrategy = SwimlaneStrategy.SWIMLANE_FORBIDDEN; @@ -123,8 +122,8 @@ public class ActivityDiagram3 extends UmlDiagram { } } - public void addSpot(String spot) { - final InstructionSpot ins = new InstructionSpot(spot, nextLinkRenderer(), swinlanes.getCurrentSwimlane()); + public void addSpot(String spot, HtmlColor color) { + final InstructionSpot ins = new InstructionSpot(spot, color, nextLinkRenderer(), swinlanes.getCurrentSwimlane()); current().add(ins); setNextLinkRendererInternal(LinkRendering.none()); manageSwimlaneStrategy(); @@ -238,7 +237,9 @@ public class ActivityDiagram3 extends UmlDiagram { } public void fork() { - final InstructionFork instructionFork = new InstructionFork(current(), nextLinkRenderer(), getSkinParam()); + manageSwimlaneStrategy(); + final InstructionFork instructionFork = new InstructionFork(current(), nextLinkRenderer(), getSkinParam(), + swinlanes.getCurrentSwimlane()); current().add(instructionFork); setNextLinkRendererInternal(LinkRendering.none()); setCurrent(instructionFork); @@ -249,7 +250,7 @@ public class ActivityDiagram3 extends UmlDiagram { final InstructionFork currentFork = (InstructionFork) current(); currentFork.manageOutRendering(nextLinkRenderer(), false); setNextLinkRendererInternal(LinkRendering.none()); - currentFork.forkAgain(); + currentFork.forkAgain(swinlanes.getCurrentSwimlane()); return CommandExecutionResult.ok(); } return CommandExecutionResult.error("Cannot find fork"); @@ -258,7 +259,7 @@ public class ActivityDiagram3 extends UmlDiagram { public CommandExecutionResult endFork(ForkStyle forkStyle, String label) { if (current() instanceof InstructionFork) { final InstructionFork currentFork = (InstructionFork) current(); - currentFork.setStyle(forkStyle, label); + currentFork.setStyle(forkStyle, label, swinlanes.getCurrentSwimlane()); currentFork.manageOutRendering(nextLinkRenderer(), true); setNextLinkRendererInternal(LinkRendering.none()); setCurrent(currentFork.getParent()); @@ -268,7 +269,8 @@ public class ActivityDiagram3 extends UmlDiagram { } public void split() { - final InstructionSplit instructionSplit = new InstructionSplit(current(), nextLinkRenderer(), swinlanes.getCurrentSwimlane()); + final InstructionSplit instructionSplit = new InstructionSplit(current(), nextLinkRenderer(), + swinlanes.getCurrentSwimlane()); setNextLinkRendererInternal(LinkRendering.none()); current().add(instructionSplit); setCurrent(instructionSplit); @@ -295,8 +297,8 @@ public class ActivityDiagram3 extends UmlDiagram { public void startSwitch(Display test, HtmlColor color) { manageSwimlaneStrategy(); - final InstructionSwitch instructionSwitch = new InstructionSwitch(swinlanes.getCurrentSwimlane(), current(), test, - nextLinkRenderer(), color, getSkinParam()); + final InstructionSwitch instructionSwitch = new InstructionSwitch(swinlanes.getCurrentSwimlane(), current(), + test, nextLinkRenderer(), color, getSkinParam()); current().add(instructionSwitch); setNextLinkRendererInternal(LinkRendering.none()); setCurrent(instructionSwitch); @@ -310,7 +312,7 @@ public class ActivityDiagram3 extends UmlDiagram { } setNextLinkRendererInternal(LinkRendering.none()); return CommandExecutionResult.ok(); - + } return CommandExecutionResult.error("Cannot find switch"); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionFork.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionFork.java index fcfb5a412..af5ef6aa2 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionFork.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionFork.java @@ -36,6 +36,7 @@ package net.sourceforge.plantuml.activitydiagram3; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.Set; @@ -55,6 +56,8 @@ public class InstructionFork extends WithNote implements Instruction { private final Instruction parent; private final LinkRendering inlinkRendering; private final ISkinParam skinParam; + private final Swimlane swimlaneIn; + private Swimlane swimlaneOut; private ForkStyle style = ForkStyle.FORK; private String label; boolean finished = false; @@ -68,10 +71,12 @@ public class InstructionFork extends WithNote implements Instruction { return false; } - public InstructionFork(Instruction parent, LinkRendering inlinkRendering, ISkinParam skinParam) { + public InstructionFork(Instruction parent, LinkRendering inlinkRendering, ISkinParam skinParam, Swimlane swimlane) { this.parent = parent; this.inlinkRendering = inlinkRendering; this.skinParam = skinParam; + this.swimlaneIn = swimlane; + this.swimlaneOut = swimlane; this.forks.add(new InstructionList()); if (inlinkRendering == null) { throw new IllegalArgumentException(); @@ -91,7 +96,7 @@ public class InstructionFork extends WithNote implements Instruction { for (InstructionList list : forks) { all.add(list.createFtile(factory)); } - Ftile result = factory.createParallel(all, style, label); + Ftile result = factory.createParallel(all, style, label, swimlaneIn, swimlaneOut); if (getPositionedNotes().size() > 0) { result = FtileWithNoteOpale.create(result, getPositionedNotes(), skinParam, false); } @@ -102,7 +107,8 @@ public class InstructionFork extends WithNote implements Instruction { return parent; } - public void forkAgain() { + public void forkAgain(Swimlane swimlane) { + this.swimlaneOut = swimlane; this.forks.add(new InstructionList()); } @@ -126,17 +132,18 @@ public class InstructionFork extends WithNote implements Instruction { } public Set getSwimlanes() { - return InstructionList.getSwimlanes2(forks); + final Set result = new HashSet(InstructionList.getSwimlanes2(forks)); + result.add(swimlaneIn); + result.add(swimlaneOut); + return result; } public Swimlane getSwimlaneIn() { - // return parent.getSwimlaneOut(); - return forks.get(0).getSwimlaneIn(); + return swimlaneIn; } public Swimlane getSwimlaneOut() { - return forks.get(0).getSwimlaneOut(); - // return getLastList().getSwimlaneOut(); + return swimlaneOut; } public void manageOutRendering(LinkRendering nextLinkRenderer, boolean endFork) { @@ -149,9 +156,10 @@ public class InstructionFork extends WithNote implements Instruction { getLastList().setOutRendering(nextLinkRenderer); } - public void setStyle(ForkStyle style, String label) { + public void setStyle(ForkStyle style, String label, Swimlane swimlane) { this.style = style; this.label = label; + this.swimlaneOut = swimlane; } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java index 4254b79f0..eb2e95950 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java @@ -88,7 +88,7 @@ public class InstructionSplit implements Instruction { for (InstructionList list : splits) { all.add(list.createFtile(factory)); } - return factory.createParallel(all, ForkStyle.SPLIT, null); + return factory.createParallel(all, ForkStyle.SPLIT, null, swimlaneIn, swimlaneOut); } public Instruction getParent() { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSpot.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSpot.java index d1d8a9e9a..03a1fde31 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSpot.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSpot.java @@ -39,28 +39,31 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileKilled; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.graphic.HtmlColor; public class InstructionSpot extends MonoSwimable implements Instruction { private boolean killed = false; private final LinkRendering inlinkRendering; private final String spot; + private final HtmlColor color; public boolean containsBreak() { return false; } - public InstructionSpot(String spot, LinkRendering inlinkRendering, Swimlane swimlane) { + public InstructionSpot(String spot, HtmlColor color, LinkRendering inlinkRendering, Swimlane swimlane) { super(swimlane); this.spot = spot; this.inlinkRendering = inlinkRendering; + this.color = color; if (inlinkRendering == null) { throw new IllegalArgumentException(); } } public Ftile createFtile(FtileFactory factory) { - Ftile result = factory.spot(getSwimlaneIn(), spot); + Ftile result = factory.spot(getSwimlaneIn(), spot, color); result = eventuallyAddNote(factory, result, result.getSwimlaneIn()); if (killed) { return new FtileKilled(result); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java index 5a44f1d5b..9a9fa7813 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java @@ -56,7 +56,7 @@ import net.sourceforge.plantuml.graphic.color.Colors; public class CommandActivity3 extends SingleLineCommand2 { - public static final String ENDING_GROUP = "(;|\\\\\\\\|(?}\\]])(?:[/<}\\]])|(?]{1,999})(?)(?:\\>)|(?}\\]])(?:[/<}\\]])|(?]{1,999})(?)(?:\\>)|(? { @@ -52,6 +54,7 @@ public class CommandCircleSpot3 extends SingleLineCommand2 { static IRegex getRegexConcat() { return RegexConcat.build(CommandCircleSpot3.class.getName(), RegexLeaf.start(), // + ColorParser.exp4(), // new RegexLeaf("SPOT", "\\((\\S)\\)"), // new RegexLeaf(";?"), // RegexLeaf.end()); @@ -59,7 +62,8 @@ public class CommandCircleSpot3 extends SingleLineCommand2 { @Override protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) { - diagram.addSpot(arg.get("SPOT", 0)); + final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)); + diagram.addSpot(arg.get("SPOT", 0), color); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactory.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactory.java index 4134c680a..2f38386b4 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactory.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactory.java @@ -63,7 +63,7 @@ public interface FtileFactory { public Ftile end(Swimlane swimlane); - public Ftile spot(Swimlane swimlane, String spot); + public Ftile spot(Swimlane swimlane, String spot, HtmlColor color); public Ftile activity(Display label, Swimlane swimlane, BoxStyle style, Colors colors); @@ -90,7 +90,7 @@ public interface FtileFactory { public Ftile createSwitch(Swimlane swimlane, List branches, LinkRendering afterEndwhile, LinkRendering topInlinkRendering, Display labelTest); - public Ftile createParallel(List all, ForkStyle style, String label); + public Ftile createParallel(List all, ForkStyle style, String label, Swimlane in, Swimlane out); public Ftile createGroup(Ftile list, Display name, HtmlColor backColor, HtmlColor titleColor, PositionedNote note, HtmlColor borderColor, USymbol type, double roundCorner); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java index 0198b0265..04cd426d1 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java @@ -145,8 +145,8 @@ public class FtileFactoryDelegator implements FtileFactory { return factory.stop(swimlane); } - public Ftile spot(Swimlane swimlane, String spot) { - return factory.spot(swimlane, spot); + public Ftile spot(Swimlane swimlane, String spot, HtmlColor color) { + return factory.spot(swimlane, spot, color); } public Ftile activity(Display label, Swimlane swimlane, BoxStyle style, Colors colors) { @@ -201,8 +201,8 @@ public class FtileFactoryDelegator implements FtileFactory { return factory.createSwitch(swimlane, branches, afterEndwhile, topInlinkRendering, labelTest); } - public Ftile createParallel(List all, ForkStyle style, String label) { - return factory.createParallel(all, style, label); + public Ftile createParallel(List all, ForkStyle style, String label, Swimlane in, Swimlane out) { + return factory.createParallel(all, style, label, in, out); } public Ftile createGroup(Ftile list, Display name, HtmlColor backColor, HtmlColor titleColor, PositionedNote note, diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/AbstractParallelFtilesBuilder.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/AbstractParallelFtilesBuilder.java index 6f8b775b1..d2aa032a8 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/AbstractParallelFtilesBuilder.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/AbstractParallelFtilesBuilder.java @@ -140,7 +140,7 @@ public abstract class AbstractParallelFtilesBuilder { return middleDimension.getHeight(); } - protected final Swimlane swimlaneOutForStep2() { + protected Swimlane swimlaneOutForStep2() { return list.get(list.size() - 1).getSwimlaneOut(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateParallel.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateParallel.java index 54f3bb1ee..10236813e 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateParallel.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateParallel.java @@ -61,16 +61,17 @@ public class FtileFactoryDelegatorCreateParallel extends FtileFactoryDelegator { } @Override - public Ftile createParallel(List all, ForkStyle style, String label) { + public Ftile createParallel(List all, ForkStyle style, String label, Swimlane in, Swimlane out) { - final Dimension2D dimSuper = super.createParallel(all, style, label).calculateDimension(getStringBounder()); + final Dimension2D dimSuper = super.createParallel(all, style, label, in, out).calculateDimension( + getStringBounder()); final double height1 = dimSuper.getHeight() + 2 * spaceArroundBlackBar; final List list = new ArrayList(); for (Ftile tmp : all) { list.add(new FtileHeightFixed(FtileUtils.addHorizontalMargin(tmp, xMargin), height1)); } - final Ftile inner = super.createParallel(list, style, label); + final Ftile inner = super.createParallel(list, style, label, in, out); AbstractParallelFtilesBuilder builder; @@ -79,7 +80,7 @@ public class FtileFactoryDelegatorCreateParallel extends FtileFactoryDelegator { } else if (style == ForkStyle.MERGE) { builder = new ParallelBuilderMerge(skinParam(), getStringBounder(), list, inner); } else if (style == ForkStyle.FORK) { - builder = new ParallelBuilderFork(skinParam(), getStringBounder(), list, inner, label); + builder = new ParallelBuilderFork(skinParam(), getStringBounder(), list, inner, label, in, out); } else { throw new IllegalStateException(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateParallelAddingMargin.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateParallelAddingMargin.java index 52130cf70..b26904f8a 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateParallelAddingMargin.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateParallelAddingMargin.java @@ -45,6 +45,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactoryDelegator; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileHeightFixed; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils; +import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; public class FtileFactoryDelegatorCreateParallelAddingMargin extends FtileFactoryDelegator { @@ -56,16 +57,17 @@ public class FtileFactoryDelegatorCreateParallelAddingMargin extends FtileFactor } @Override - public Ftile createParallel(List all, ForkStyle style, String label) { + public Ftile createParallel(List all, ForkStyle style, String label, Swimlane in, Swimlane out) { - final Dimension2D dimSuper = super.createParallel(all, style, label).calculateDimension(getStringBounder()); + final Dimension2D dimSuper = super.createParallel(all, style, label, in, out).calculateDimension( + getStringBounder()); final double height1 = dimSuper.getHeight() + 2 * spaceArroundBlackBar; final List list = new ArrayList(); for (Ftile tmp : all) { list.add(new FtileHeightFixed(FtileUtils.addHorizontalMargin(tmp, xMargin), height1)); } - return super.createParallel(list, style, label); + return super.createParallel(list, style, label, in, out); } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileRepeat.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileRepeat.java index 323e3ace0..b3becbd6d 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileRepeat.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileRepeat.java @@ -125,7 +125,7 @@ class FtileRepeat extends AbstractFtile { final TextBlock outTb = out.create(fcArrow, HorizontalAlignment.LEFT, spriteContainer); final Ftile diamond1; - assert swimlane == repeat.getSwimlaneIn(); + // assert swimlane == repeat.getSwimlaneIn(); if (backStart == null) { diamond1 = new FtileDiamond(repeat.skinParam(), backColor, borderColor, repeat.getSwimlaneIn()); } else { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderFork.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderFork.java index d2a90fe07..f936c139a 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderFork.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderFork.java @@ -64,19 +64,29 @@ import net.sourceforge.plantuml.ugraphic.UTranslate; public class ParallelBuilderFork extends AbstractParallelFtilesBuilder { private final String label; + private final Swimlane in; + private final Swimlane out; public ParallelBuilderFork(ISkinParam skinParam, StringBounder stringBounder, final List list, Ftile inner, - String label) { + String label, Swimlane in, Swimlane out) { super(skinParam, stringBounder, list, inner); this.label = label; + this.in = in; + this.out = out; + } + + @Override + protected Swimlane swimlaneOutForStep2() { + return out; } @Override protected Ftile doStep1() { Ftile result = getMiddle(); final List conns = new ArrayList(); + final Swimlane swimlaneBlack = in; final Ftile black = new FtileBlackBlock(skinParam(), getRose() - .getHtmlColor(skinParam(), ColorParam.activityBar), getList().get(0).getSwimlaneIn()); + .getHtmlColor(skinParam(), ColorParam.activityBar), swimlaneBlack); double x = 0; for (Ftile tmp : getList()) { final Dimension2D dim = tmp.calculateDimension(getStringBounder()); @@ -101,8 +111,9 @@ public class ParallelBuilderFork extends AbstractParallelFtilesBuilder { @Override protected Ftile doStep2(Ftile result) { + final Swimlane swimlaneBlack = out; final Ftile out = new FtileBlackBlock(skinParam(), getRose().getHtmlColor(skinParam(), ColorParam.activityBar), - getList().get(0).getSwimlaneIn()); + swimlaneBlack); ((FtileBlackBlock) out).setBlackBlockDimension(result.calculateDimension(getStringBounder()).getWidth(), barHeight); if (label != null) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java index 6f55d0622..a7fe6e000 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java @@ -121,10 +121,10 @@ public class VCompactFactory implements FtileFactory { return new FtileCircleStop(skinParam(), color, swimlane, style); } - public Ftile spot(Swimlane swimlane, String spot) { + public Ftile spot(Swimlane swimlane, String spot, HtmlColor color) { // final HtmlColor color = rose.getHtmlColor(skinParam, ColorParam.activityBackground); final UFont font = skinParam.getFont(null, false, FontParam.ACTIVITY); - return new FtileCircleSpot(skinParam(), swimlane, spot, font); + return new FtileCircleSpot(skinParam(), swimlane, spot, font, color); } public Ftile end(Swimlane swimlane) { @@ -189,7 +189,7 @@ public class VCompactFactory implements FtileFactory { return new FtileForkInner(ftiles); } - public Ftile createParallel(List all, ForkStyle style, String label) { + public Ftile createParallel(List all, ForkStyle style, String label, Swimlane in, Swimlane out) { return new FtileForkInner(all); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleSpot.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleSpot.java index 219280970..796c0dd50 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleSpot.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleSpot.java @@ -65,12 +65,13 @@ public class FtileCircleSpot extends AbstractFtile { private final Swimlane swimlane; private final String spot; private final FontConfiguration fc; + private final HtmlColor backColor; - public FtileCircleSpot(ISkinParam skinParam, Swimlane swimlane, String spot, UFont font) { + public FtileCircleSpot(ISkinParam skinParam, Swimlane swimlane, String spot, UFont font, HtmlColor backColor) { super(skinParam); this.spot = spot; this.swimlane = swimlane; - // this.font = font; + this.backColor = backColor; this.fc = new FontConfiguration(skinParam, FontParam.ACTIVITY, null); } @@ -97,7 +98,8 @@ public class FtileCircleSpot extends AbstractFtile { public void drawU(UGraphic ug) { final HtmlColor borderColor = SkinParamUtils.getColor(skinParam(), null, ColorParam.activityBorder); - final HtmlColor backColor = SkinParamUtils.getColor(skinParam(), null, ColorParam.activityBackground); + final HtmlColor backColor = this.backColor == null ? SkinParamUtils.getColor(skinParam(), null, + ColorParam.activityBackground) : this.backColor; final UEllipse circle = new UEllipse(SIZE, SIZE); if (skinParam().shadowing(null)) { diff --git a/src/net/sourceforge/plantuml/bpm/BpmDiagram.java b/src/net/sourceforge/plantuml/bpm/BpmDiagram.java index 239fd5b2c..69a727524 100644 --- a/src/net/sourceforge/plantuml/bpm/BpmDiagram.java +++ b/src/net/sourceforge/plantuml/bpm/BpmDiagram.java @@ -96,7 +96,7 @@ public class BpmDiagram extends UmlDiagram { cleanGrid(grid); final GridArray gridArray = grid.toArray(SkinParam.create(getUmlDiagramType())); // gridArray.addEdges(edges); - System.err.println("gridArray=" + gridArray); + // System.err.println("gridArray=" + gridArray); return gridArray; } diff --git a/src/net/sourceforge/plantuml/bpm/CleanerMoveBlock.java b/src/net/sourceforge/plantuml/bpm/CleanerMoveBlock.java index b979e26d7..122e1719c 100644 --- a/src/net/sourceforge/plantuml/bpm/CleanerMoveBlock.java +++ b/src/net/sourceforge/plantuml/bpm/CleanerMoveBlock.java @@ -39,7 +39,7 @@ package net.sourceforge.plantuml.bpm; public class CleanerMoveBlock implements GridCleaner { public boolean clean(Grid grid) { - System.err.println("CleanerMoveBlock"); + // System.err.println("CleanerMoveBlock"); for (Line line : grid.lines().toList()) { tryGrid(grid, line); } @@ -89,6 +89,6 @@ public class CleanerMoveBlock implements GridCleaner { } private void tryBridge(Line line, Col col1, final Col col2) { - System.err.println("LINE=" + line + " " + col1 + " " + col2 + " "); + // System.err.println("LINE=" + line + " " + col1 + " " + col2 + " "); } } diff --git a/src/net/sourceforge/plantuml/classdiagram/ClassDiagramFactory.java b/src/net/sourceforge/plantuml/classdiagram/ClassDiagramFactory.java index dbe7568ce..704780e7f 100644 --- a/src/net/sourceforge/plantuml/classdiagram/ClassDiagramFactory.java +++ b/src/net/sourceforge/plantuml/classdiagram/ClassDiagramFactory.java @@ -60,6 +60,7 @@ import net.sourceforge.plantuml.command.Command; import net.sourceforge.plantuml.command.CommandEndPackage; import net.sourceforge.plantuml.command.CommandFootboxIgnored; import net.sourceforge.plantuml.command.CommandNamespace; +import net.sourceforge.plantuml.command.CommandNamespace2; import net.sourceforge.plantuml.command.CommandPackage; import net.sourceforge.plantuml.command.CommandPackageEmpty; import net.sourceforge.plantuml.command.CommandPage; @@ -123,6 +124,7 @@ public class ClassDiagramFactory extends UmlDiagramFactory { cmds.add(factoryNoteCommand.createSingleLine()); cmds.add(new CommandNamespace()); + cmds.add(new CommandNamespace2()); cmds.add(new CommandStereotype()); cmds.add(new CommandLinkClass(UmlDiagramType.CLASS)); diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByGender.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByGender.java index b60ad093b..246b27cc5 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByGender.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByGender.java @@ -35,9 +35,6 @@ */ package net.sourceforge.plantuml.classdiagram.command; -import java.util.EnumSet; -import java.util.Set; - import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.UmlDiagram; @@ -61,38 +58,36 @@ import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; public class CommandHideShowByGender extends SingleLineCommand2 { - private static final EnumSet PORTION_METHOD = EnumSet. of(EntityPortion.METHOD); - private static final EnumSet PORTION_MEMBER = EnumSet. of(EntityPortion.FIELD, - EntityPortion.METHOD); - private static final EnumSet PORTION_FIELD = EnumSet. of(EntityPortion.FIELD); - public CommandHideShowByGender() { super(getRegexConcat()); } static IRegex getRegexConcat() { - return RegexConcat.build(CommandHideShowByGender.class.getName(), RegexLeaf.start(), // - new RegexLeaf("COMMAND", "(hide|show)"), // - RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("GENDER", - "(?:(class|object|interface|enum|annotation|abstract|[\\p{L}0-9_.]+|[%g][^%g]+[%g]|\\<\\<.*\\>\\>)[%s]+)*?"), // - new RegexOptional( // - new RegexConcat( // - new RegexLeaf("EMPTY", "(empty)"), // - RegexLeaf.spaceOneOrMore()) // - ), // - new RegexLeaf("PORTION", "(members?|attributes?|fields?|methods?|circles?|circled?|stereotypes?)"), // - RegexLeaf.end()); + return RegexConcat + .build(CommandHideShowByGender.class.getName(), + RegexLeaf.start(), // + new RegexLeaf("COMMAND", "(hide|show)"), // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("GENDER", + "(?:(class|object|interface|enum|annotation|abstract|[\\p{L}0-9_.]+|[%g][^%g]+[%g]|\\<\\<.*\\>\\>)[%s]+)*?"), // + new RegexOptional( // + new RegexConcat( // + new RegexLeaf("EMPTY", "(empty)"), // + RegexLeaf.spaceOneOrMore()) // + ), // + new RegexLeaf("PORTION", + "(members?|attributes?|fields?|methods?|circles?|circled?|stereotypes?)"), // + RegexLeaf.end()); } - private final EntityGender emptyByGender(Set portion) { - if (portion == PORTION_METHOD) { + private final EntityGender emptyByGender(EntityPortion portion) { + if (portion == EntityPortion.METHOD) { return EntityGenderUtils.emptyMethods(); } - if (portion == PORTION_FIELD) { + if (portion == EntityPortion.FIELD) { return EntityGenderUtils.emptyFields(); } - if (portion == PORTION_MEMBER) { + if (portion == EntityPortion.MEMBER) { throw new IllegalArgumentException(); // return EntityGenderUtils.emptyMembers(); } @@ -115,13 +110,13 @@ public class CommandHideShowByGender extends SingleLineCommand2 { } private CommandExecutionResult executeSequenceDiagram(SequenceDiagram diagram, RegexResult arg) { - final Set portion = getEntityPortion(arg.get("PORTION", 0)); - diagram.hideOrShow(portion, arg.get("COMMAND", 0).equalsIgnoreCase("show")); + final EntityPortion portion = getEntityPortion(arg.get("PORTION", 0)); + diagram.hideOrShow(portion.asSet(), arg.get("COMMAND", 0).equalsIgnoreCase("show")); return CommandExecutionResult.ok(); } private CommandExecutionResult executeDescriptionDiagram(DescriptionDiagram diagram, RegexResult arg) { - final Set portion = getEntityPortion(arg.get("PORTION", 0)); + final EntityPortion portion = getEntityPortion(arg.get("PORTION", 0)); final EntityGender gender; final String arg1 = arg.get("GENDER", 0); if (arg1 == null) { @@ -151,7 +146,7 @@ public class CommandHideShowByGender extends SingleLineCommand2 { private CommandExecutionResult executeClassDiagram(AbstractClassOrObjectDiagram classDiagram, RegexResult arg) { - final Set portion = getEntityPortion(arg.get("PORTION", 0)); + final EntityPortion portion = getEntityPortion(arg.get("PORTION", 0)); EntityGender gender = null; final String arg1 = arg.get("GENDER", 0); @@ -177,7 +172,7 @@ public class CommandHideShowByGender extends SingleLineCommand2 { } if (gender != null) { final boolean empty = arg.get("EMPTY", 0) != null; - final boolean emptyMembers = empty && portion == PORTION_MEMBER; + final boolean emptyMembers = empty && portion == EntityPortion.MEMBER; if (empty == true && emptyMembers == false) { gender = EntityGenderUtils.and(gender, emptyByGender(portion)); } @@ -186,9 +181,9 @@ public class CommandHideShowByGender extends SingleLineCommand2 { } if (emptyMembers) { - classDiagram.hideOrShow(EntityGenderUtils.and(gender, emptyByGender(PORTION_FIELD)), PORTION_FIELD, arg + classDiagram.hideOrShow(EntityGenderUtils.and(gender, emptyByGender(EntityPortion.FIELD)), EntityPortion.FIELD, arg .get("COMMAND", 0).equalsIgnoreCase("show")); - classDiagram.hideOrShow(EntityGenderUtils.and(gender, emptyByGender(PORTION_METHOD)), PORTION_METHOD, + classDiagram.hideOrShow(EntityGenderUtils.and(gender, emptyByGender(EntityPortion.METHOD)), EntityPortion.METHOD, arg.get("COMMAND", 0).equalsIgnoreCase("show")); } else { classDiagram.hideOrShow(gender, portion, arg.get("COMMAND", 0).equalsIgnoreCase("show")); @@ -197,22 +192,22 @@ public class CommandHideShowByGender extends SingleLineCommand2 { return CommandExecutionResult.ok(); } - private Set getEntityPortion(String s) { + private EntityPortion getEntityPortion(String s) { final String sub = StringUtils.goLowerCase(s.substring(0, 3)); if (sub.equals("met")) { - return PORTION_METHOD; + return EntityPortion.METHOD; } if (sub.equals("mem")) { - return PORTION_MEMBER; + return EntityPortion.MEMBER; } if (sub.equals("att") || sub.equals("fie")) { - return PORTION_FIELD; + return EntityPortion.FIELD; } if (sub.equals("cir")) { - return EnumSet. of(EntityPortion.CIRCLED_CHARACTER); + return EntityPortion.CIRCLED_CHARACTER; } if (sub.equals("ste")) { - return EnumSet. of(EntityPortion.STEREOTYPE); + return EntityPortion.STEREOTYPE; } throw new IllegalArgumentException(); } diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByVisibility.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByVisibility.java index f9823fe19..63921202c 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByVisibility.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByVisibility.java @@ -54,11 +54,6 @@ import net.sourceforge.plantuml.skin.VisibilityModifier; public class CommandHideShowByVisibility extends SingleLineCommand2 { - private static final EnumSet PORTION_METHOD = EnumSet. of(EntityPortion.METHOD); - private static final EnumSet PORTION_MEMBER = EnumSet. of(EntityPortion.FIELD, - EntityPortion.METHOD); - private static final EnumSet PORTION_FIELD = EnumSet. of(EntityPortion.FIELD); - public CommandHideShowByVisibility() { super(getRegexConcat()); } @@ -84,7 +79,7 @@ public class CommandHideShowByVisibility extends SingleLineCommand2 private CommandExecutionResult executeArgClass(ClassDiagram classDiagram, RegexResult arg) { - final Set portion = getEntityPortion(arg.get("PORTION", 0)); + final EntityPortion portion = getEntityPortion(arg.get("PORTION", 0)); final Set visibilities = EnumSet. noneOf(VisibilityModifier.class); final StringTokenizer st = new StringTokenizer(StringUtils.goLowerCase(arg.get("VISIBILITY", 0)), " ,"); @@ -97,43 +92,43 @@ public class CommandHideShowByVisibility extends SingleLineCommand2 return CommandExecutionResult.ok(); } - private void addVisibilities(String token, Set portion, Set result) { - if (token.equals("public") && portion.contains(EntityPortion.FIELD)) { + private void addVisibilities(String token, EntityPortion portion, Set result) { + if (token.equals("public") && (portion == EntityPortion.MEMBER || portion == EntityPortion.FIELD)) { result.add(VisibilityModifier.PUBLIC_FIELD); } - if (token.equals("public") && portion.contains(EntityPortion.METHOD)) { + if (token.equals("public") && (portion == EntityPortion.MEMBER || portion == EntityPortion.METHOD)) { result.add(VisibilityModifier.PUBLIC_METHOD); } - if (token.equals("private") && portion.contains(EntityPortion.FIELD)) { + if (token.equals("private") && (portion == EntityPortion.MEMBER || portion == EntityPortion.FIELD)) { result.add(VisibilityModifier.PRIVATE_FIELD); } - if (token.equals("private") && portion.contains(EntityPortion.METHOD)) { + if (token.equals("private") && (portion == EntityPortion.MEMBER || portion == EntityPortion.METHOD)) { result.add(VisibilityModifier.PRIVATE_METHOD); } - if (token.equals("protected") && portion.contains(EntityPortion.FIELD)) { + if (token.equals("protected") && (portion == EntityPortion.MEMBER || portion == EntityPortion.FIELD)) { result.add(VisibilityModifier.PROTECTED_FIELD); } - if (token.equals("protected") && portion.contains(EntityPortion.METHOD)) { + if (token.equals("protected") && (portion == EntityPortion.MEMBER || portion == EntityPortion.METHOD)) { result.add(VisibilityModifier.PROTECTED_METHOD); } - if (token.equals("package") && portion.contains(EntityPortion.FIELD)) { + if (token.equals("package") && (portion == EntityPortion.MEMBER || portion == EntityPortion.FIELD)) { result.add(VisibilityModifier.PACKAGE_PRIVATE_FIELD); } - if (token.equals("package") && portion.contains(EntityPortion.METHOD)) { + if (token.equals("package") && (portion == EntityPortion.MEMBER || portion == EntityPortion.METHOD)) { result.add(VisibilityModifier.PACKAGE_PRIVATE_METHOD); } } - private Set getEntityPortion(String s) { + private EntityPortion getEntityPortion(String s) { final String sub = StringUtils.goLowerCase(s.substring(0, 3)); if (sub.equals("met")) { - return PORTION_METHOD; + return EntityPortion.METHOD; } if (sub.equals("mem")) { - return PORTION_MEMBER; + return EntityPortion.MEMBER; } if (sub.equals("att") || sub.equals("fie")) { - return PORTION_FIELD; + return EntityPortion.FIELD; } throw new IllegalArgumentException(); } diff --git a/src/net/sourceforge/plantuml/command/BlocLines.java b/src/net/sourceforge/plantuml/command/BlocLines.java index c450201b3..c2d49759d 100644 --- a/src/net/sourceforge/plantuml/command/BlocLines.java +++ b/src/net/sourceforge/plantuml/command/BlocLines.java @@ -294,13 +294,29 @@ public class BlocLines implements Iterable { final String first = getFirst499().getTrimmed().getString(); final String second = get499(1).getTrimmed().getString(); if (first.endsWith("{") == false && second.equals("{")) { - final String vline = first + " {"; + final StringLocated vline = getFirst499().append(" {"); final List result = new ArrayList(); - result.add(new StringLocated(vline, null)); + result.add(vline); result.addAll(this.lines.subList(2, this.lines.size())); return new BlocLines(result); } return this; } + public BlocLines eventuallyMoveAllEmptyBracket() { + final List result = new ArrayList(); + for (StringLocated line : lines) { + if (line.getTrimmed().toString().equals("{")) { + if (result.size() > 0) { + final int pos = result.size() - 1; + StringLocated last = result.get(pos); + result.set(pos, last.append(" {")); + } + } else { + result.add(line); + } + } + return new BlocLines(result); + } + } diff --git a/src/net/sourceforge/plantuml/command/CommandNamespace.java b/src/net/sourceforge/plantuml/command/CommandNamespace.java index 672ccf48e..73bcde932 100644 --- a/src/net/sourceforge/plantuml/command/CommandNamespace.java +++ b/src/net/sourceforge/plantuml/command/CommandNamespace.java @@ -64,7 +64,7 @@ public class CommandNamespace extends SingleLineCommand2 { return RegexConcat.build(CommandNamespace.class.getName(), RegexLeaf.start(), // new RegexLeaf("namespace"), // RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("NAME", "([\\p{L}0-9_][\\p{L}0-9_.:\\\\]*)"), // + new RegexLeaf("NAME", "([\\p{L}0-9_][-\\p{L}0-9_.:\\\\]*)"), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), // RegexLeaf.spaceZeroOrMore(), // @@ -79,8 +79,8 @@ public class CommandNamespace extends SingleLineCommand2 { protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) { final Code code = Code.of(arg.get("NAME", 0)); final IGroup currentPackage = diagram.getCurrentGroup(); - diagram.gotoGroup2(code, Display.getWithNewlines(code), GroupType.PACKAGE, currentPackage, - NamespaceStrategy.MULTIPLE); + final Display display = Display.getWithNewlines(code); + diagram.gotoGroup2(code, display, GroupType.PACKAGE, currentPackage, NamespaceStrategy.MULTIPLE); final IEntity p = diagram.getCurrentGroup(); final String stereotype = arg.get("STEREOTYPE", 0); if (stereotype != null) { diff --git a/src/net/sourceforge/plantuml/command/CommandNamespace2.java b/src/net/sourceforge/plantuml/command/CommandNamespace2.java new file mode 100644 index 000000000..0feb26a53 --- /dev/null +++ b/src/net/sourceforge/plantuml/command/CommandNamespace2.java @@ -0,0 +1,115 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.command; + +import net.sourceforge.plantuml.LineLocation; +import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.UrlBuilder; +import net.sourceforge.plantuml.UrlBuilder.ModeUrl; +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.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.IEntity; +import net.sourceforge.plantuml.cucadiagram.IGroup; +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; + +public class CommandNamespace2 extends SingleLineCommand2 { + + public CommandNamespace2() { + super(getRegexConcat()); + } + + private static IRegex getRegexConcat() { + return RegexConcat.build(CommandNamespace2.class.getName(), RegexLeaf.start(), // + new RegexLeaf("namespace"), // + RegexLeaf.spaceOneOrMore(), // + + new RegexLeaf("[%g]"), // + new RegexLeaf("DISPLAY", "([^%g]+)"), // + new RegexLeaf("[%g]"), // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("as"), // + RegexLeaf.spaceOneOrMore(), // + + new RegexLeaf("NAME", "([\\p{L}0-9_][-\\p{L}0-9_.:\\\\]*)"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), // + RegexLeaf.spaceZeroOrMore(), // + ColorParser.exp1(), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("\\{"), RegexLeaf.end()); + } + + @Override + protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) { + final Code code = Code.of(arg.get("NAME", 0)); + final IGroup currentPackage = diagram.getCurrentGroup(); + final String disp = arg.getLazzy("DISPLAY", 0); + final Display display = Display.getWithNewlines(disp); + diagram.gotoGroup2(code, display, GroupType.PACKAGE, currentPackage, NamespaceStrategy.MULTIPLE); + final IEntity p = diagram.getCurrentGroup(); + final String stereotype = arg.get("STEREOTYPE", 0); + if (stereotype != null) { + p.setStereotype(new Stereotype(stereotype)); + } + + final String urlString = arg.get("URL", 0); + if (urlString != null) { + final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT); + final Url url = urlBuilder.getUrl(urlString); + p.addUrl(url); + } + + final String color = arg.get("COLOR", 0); + if (color != null) { + p.setSpecificColorTOBEREMOVED(ColorType.BACK, + diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(color)); + } + return CommandExecutionResult.ok(); + } + +} diff --git a/src/net/sourceforge/plantuml/command/UmlDiagramFactory.java b/src/net/sourceforge/plantuml/command/UmlDiagramFactory.java index 0cc7fd893..2a1690da7 100644 --- a/src/net/sourceforge/plantuml/command/UmlDiagramFactory.java +++ b/src/net/sourceforge/plantuml/command/UmlDiagramFactory.java @@ -55,6 +55,7 @@ import net.sourceforge.plantuml.error.PSystemErrorUtils; import net.sourceforge.plantuml.sequencediagram.command.CommandSkin; import net.sourceforge.plantuml.sprite.CommandListSprite; import net.sourceforge.plantuml.statediagram.command.CommandHideEmptyDescription; +import net.sourceforge.plantuml.style.CommandStyleImport; import net.sourceforge.plantuml.style.CommandStyleMultilinesCSS; import net.sourceforge.plantuml.utils.StartUtils; import net.sourceforge.plantuml.version.IteratorCounter2; @@ -220,7 +221,7 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory { addCommonCommands2(cmds); addCommonHides(cmds); cmds.add(new CommandStyleMultilinesCSS()); - + cmds.add(new CommandStyleImport()); } final protected void addCommonCommands2(List cmds) { diff --git a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOverSeveralCommand.java b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOverSeveralCommand.java index dbac9d126..32cd5c2f7 100644 --- a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOverSeveralCommand.java +++ b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOverSeveralCommand.java @@ -67,6 +67,7 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF private IRegex getRegexConcatMultiLine() { return RegexConcat.build(FactorySequenceNoteOverSeveralCommand.class.getName() + "multi", RegexLeaf.start(), // + new RegexLeaf("PARALLEL", "(&[%s]*)?"), // new RegexLeaf("VMERGE", "(/)?"), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("STYLE", "(note|hnote|rnote)"), // @@ -89,6 +90,7 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF private IRegex getRegexConcatSingleLine() { return RegexConcat.build(FactorySequenceNoteOverSeveralCommand.class.getName() + "single", RegexLeaf.start(), // + new RegexLeaf("PARALLEL", "(&[%s]*)?"), // new RegexLeaf("VMERGE", "(/)?"), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("STYLE", "(note|hnote|rnote)"), // @@ -157,6 +159,7 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF if (lines.size() > 0) { final boolean tryMerge = line0.get("VMERGE", 0) != null; + final boolean parallel = line0.get("PARALLEL", 0) != null; final Display display = diagram.manageVariable(lines.toDisplay()); final Note note = new Note(p1, p2, display, diagram.getSkinParam().getCurrentStyleBuilder()); Colors colors = color().getColor(line0, diagram.getSkinParam().getIHtmlColorSet()); @@ -176,6 +179,9 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF final Url urlLink = urlBuilder.getUrl(line0.get("URL", 0)); note.setUrl(urlLink); } + if (parallel) { + note.goParallel(); + } diagram.addNote(note, tryMerge); } return CommandExecutionResult.ok(); diff --git a/src/net/sourceforge/plantuml/command/regex/Matcher2.java b/src/net/sourceforge/plantuml/command/regex/Matcher2.java index 4c337ba94..5aee3d163 100644 --- a/src/net/sourceforge/plantuml/command/regex/Matcher2.java +++ b/src/net/sourceforge/plantuml/command/regex/Matcher2.java @@ -57,7 +57,8 @@ public class Matcher2 { final long now = System.currentTimeMillis(); final String id = pattern.pattern(); try { - return new Matcher2(pattern.matcher(input), id); + final Matcher matcher2 = pattern.matcher(input); + return new Matcher2(matcher2, id); } finally { if (INSTRUMENT) { addTime(id, System.currentTimeMillis() - now); diff --git a/src/net/sourceforge/plantuml/command/regex/RegexComposed.java b/src/net/sourceforge/plantuml/command/regex/RegexComposed.java index 4b2e8988d..00634e98e 100644 --- a/src/net/sourceforge/plantuml/command/regex/RegexComposed.java +++ b/src/net/sourceforge/plantuml/command/regex/RegexComposed.java @@ -36,11 +36,13 @@ package net.sourceforge.plantuml.command.regex; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; import java.util.regex.Pattern; import net.sourceforge.plantuml.StringLocated; @@ -48,26 +50,32 @@ import net.sourceforge.plantuml.StringLocated; public abstract class RegexComposed implements IRegex { protected static final AtomicInteger nbCreateMatches = new AtomicInteger(); - protected final List partials; + private final List partials; + + protected final List partials() { + return partials; + } abstract protected String getFullSlow(); - private Pattern2 fullCached; + private final AtomicReference fullCached = new AtomicReference(); - private synchronized Pattern2 getPattern2() { - if (fullCached == null) { + private Pattern2 getPattern2() { + Pattern2 result = fullCached.get(); + if (result == null) { final String fullSlow = getFullSlow(); - fullCached = MyPattern.cmpile(fullSlow, Pattern.CASE_INSENSITIVE); + result = MyPattern.cmpile(fullSlow, Pattern.CASE_INSENSITIVE); + fullCached.set(result); } - return fullCached; + return result; } - - protected boolean isCompiled() { - return fullCached != null; + + final protected boolean isCompiled() { + return fullCached.get() != null; } public RegexComposed(IRegex... partial) { - this.partials = Arrays.asList(partial); + this.partials = Collections.unmodifiableList(Arrays.asList(partial)); } public Map createPartialMatch(Iterator it) { diff --git a/src/net/sourceforge/plantuml/command/regex/RegexConcat.java b/src/net/sourceforge/plantuml/command/regex/RegexConcat.java index e9134b29a..243ae6d42 100644 --- a/src/net/sourceforge/plantuml/command/regex/RegexConcat.java +++ b/src/net/sourceforge/plantuml/command/regex/RegexConcat.java @@ -42,13 +42,11 @@ import java.util.concurrent.atomic.AtomicLong; import net.sourceforge.plantuml.Log; import net.sourceforge.plantuml.StringLocated; -public class RegexConcat extends RegexComposed implements IRegex { +public final class RegexConcat extends RegexComposed implements IRegex { private static final ConcurrentMap cache = new ConcurrentHashMap(); private final AtomicLong foxRegex = new AtomicLong(-1L); - private boolean invoked; - // private static final Set PRINTED2 = new HashSet(); public static void printCacheInfo() { @@ -58,7 +56,7 @@ public class RegexConcat extends RegexComposed implements IRegex { if (reg.isCompiled()) { nbCompiled++; } - if (reg.invoked) { + if (reg.invoked()) { nbInvoked++; } } @@ -73,8 +71,8 @@ public class RegexConcat extends RegexComposed implements IRegex { private long foxRegex() { if (foxRegex.get() == -1L) { long tmp = 0L; - for (int i = 1; i < partials.size() - 1; i++) { - final IRegex part = partials.get(i); + for (int i = 1; i < partials().size() - 1; i++) { + final IRegex part = partials().get(i); if (part instanceof RegexLeaf) { final RegexLeaf leaf = (RegexLeaf) part; tmp = tmp | leaf.getFoxSignature(); @@ -109,9 +107,12 @@ public class RegexConcat extends RegexComposed implements IRegex { return result; } + private boolean invoked() { + return foxRegex.get() != -1L; + } + @Override public boolean match(StringLocated s) { - invoked = true; final long foxRegex = foxRegex(); if (foxRegex != 0L) { final long foxLine = s.getFoxSignature(); @@ -129,7 +130,7 @@ public class RegexConcat extends RegexComposed implements IRegex { @Override protected String getFullSlow() { final StringBuilder sb = new StringBuilder(); - for (IRegex p : partials) { + for (IRegex p : partials()) { sb.append(p.getPattern()); } return sb.toString(); diff --git a/src/net/sourceforge/plantuml/command/regex/RegexOptional.java b/src/net/sourceforge/plantuml/command/regex/RegexOptional.java index 8f7ed2234..865d479a2 100644 --- a/src/net/sourceforge/plantuml/command/regex/RegexOptional.java +++ b/src/net/sourceforge/plantuml/command/regex/RegexOptional.java @@ -46,7 +46,7 @@ public class RegexOptional extends RegexComposed implements IRegex { @Override protected String getFullSlow() { final StringBuilder sb = new StringBuilder("(?:"); - sb.append(partials.get(0).getPattern()); + sb.append(partials().get(0).getPattern()); sb.append(")?"); return sb.toString(); } diff --git a/src/net/sourceforge/plantuml/command/regex/RegexOr.java b/src/net/sourceforge/plantuml/command/regex/RegexOr.java index 94593a511..6c9fee398 100644 --- a/src/net/sourceforge/plantuml/command/regex/RegexOr.java +++ b/src/net/sourceforge/plantuml/command/regex/RegexOr.java @@ -60,7 +60,7 @@ public class RegexOr extends RegexComposed implements IRegex { if (name == null) { sb.append("?:"); } - for (IRegex p : partials) { + for (IRegex p : partials()) { sb.append(p.getPattern()); sb.append("|"); } diff --git a/src/net/sourceforge/plantuml/creole/AtomTree.java b/src/net/sourceforge/plantuml/creole/AtomTree.java index 73946c798..b0b924398 100644 --- a/src/net/sourceforge/plantuml/creole/AtomTree.java +++ b/src/net/sourceforge/plantuml/creole/AtomTree.java @@ -37,6 +37,7 @@ package net.sourceforge.plantuml.creole; import java.awt.geom.Dimension2D; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -55,6 +56,12 @@ public class AtomTree extends AbstractAtom implements Atom { private final List cells = new ArrayList(); private final Map levels = new HashMap(); private final double margin = 2; + + @Override + public List splitInTwo(StringBounder stringBounder, double width) { + return Arrays.asList((Atom) this); + } + public AtomTree(HtmlColor lineColor) { this.lineColor = lineColor; diff --git a/src/net/sourceforge/plantuml/creole/AtomWithMargin.java b/src/net/sourceforge/plantuml/creole/AtomWithMargin.java index e4688c97d..806c85949 100644 --- a/src/net/sourceforge/plantuml/creole/AtomWithMargin.java +++ b/src/net/sourceforge/plantuml/creole/AtomWithMargin.java @@ -36,6 +36,10 @@ package net.sourceforge.plantuml.creole; import java.awt.geom.Dimension2D; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.graphic.StringBounder; @@ -54,6 +58,24 @@ class AtomWithMargin extends AbstractAtom implements Atom { this.marginY2 = marginY2; } + @Override + public List splitInTwo(StringBounder stringBounder, double width) { + final List result = new ArrayList(); + final List list = atom.splitInTwo(stringBounder, width); + for (Atom a : list) { + double y1 = marginY1; + double y2 = marginY2; + if (list.size() == 2 && result.size() == 0) { + y2 = 0; + } + if (list.size() == 2 && result.size() == 1) { + y1 = 0; + } + result.add(new AtomWithMargin(a, y1, y2)); + } + return Collections.unmodifiableList(result); + } + public Dimension2D calculateDimension(StringBounder stringBounder) { return Dimension2DDouble.delta(atom.calculateDimension(stringBounder), 0, marginY1 + marginY2); } @@ -65,5 +87,5 @@ class AtomWithMargin extends AbstractAtom implements Atom { public void drawU(UGraphic ug) { atom.drawU(ug.apply(new UTranslate(0, marginY1))); } - + } diff --git a/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java b/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java index 54fcfa688..e8a79de17 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java +++ b/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java @@ -563,8 +563,8 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, return result; } - public final void hideOrShow(EntityGender gender, Set portions, boolean show) { - for (EntityPortion portion : portions) { + public final void hideOrShow(EntityGender gender, EntityPortion portions, boolean show) { + for (EntityPortion portion : portions.asSet()) { this.hideOrShows.add(new HideOrShow(gender, portion, show)); } } @@ -577,26 +577,6 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, } } - // public void hideOrShow(IEntity leaf, boolean show) { - // leaf.setRemoved(!show); - // } - - // public void hideOrShow(Stereotype stereotype, boolean show) { - // if (show) { - // hiddenStereotype.remove(stereotype.getLabel(Guillemet.DOUBLE_COMPARATOR)); - // } else { - // hiddenStereotype.add(stereotype.getLabel(Guillemet.DOUBLE_COMPARATOR)); - // } - // } - // - // public void hideOrShow(LeafType leafType, boolean show) { - // if (show) { - // hiddenType.remove(leafType); - // } else { - // hiddenType.add(leafType); - // } - // } - public void hideOrShow2(String what, boolean show) { this.hides2.add(new HideOrShow2(what, show)); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/EntityGenderUtils.java b/src/net/sourceforge/plantuml/cucadiagram/EntityGenderUtils.java index 9200efaa2..1f60a9d07 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/EntityGenderUtils.java +++ b/src/net/sourceforge/plantuml/cucadiagram/EntityGenderUtils.java @@ -115,13 +115,5 @@ public class EntityGenderUtils { }; } -// static public EntityGender emptyMembers() { -// return new EntityGender() { -// public boolean contains(IEntity test) { -// return test.getBodier().getMethodsToDisplay().size() == 0 -// && test.getBodier().getFieldsToDisplay().size() == 0; -// } -// }; -// } } diff --git a/src/net/sourceforge/plantuml/cucadiagram/EntityPortion.java b/src/net/sourceforge/plantuml/cucadiagram/EntityPortion.java index 91b2d7fa6..7cb162cb4 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/EntityPortion.java +++ b/src/net/sourceforge/plantuml/cucadiagram/EntityPortion.java @@ -35,6 +35,16 @@ */ package net.sourceforge.plantuml.cucadiagram; +import java.util.EnumSet; +import java.util.Set; + public enum EntityPortion { - FIELD, METHOD, CIRCLED_CHARACTER, STEREOTYPE, LOLLIPOP, ENTIRELY + FIELD, METHOD, MEMBER, CIRCLED_CHARACTER, STEREOTYPE; + + public Set asSet() { + if (this == MEMBER) { + return EnumSet. of(FIELD, METHOD); + } + return EnumSet. of(this); + } } diff --git a/src/net/sourceforge/plantuml/cucadiagram/entity/EntityFactory.java b/src/net/sourceforge/plantuml/cucadiagram/entity/EntityFactory.java index e870ebda0..14751af96 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/entity/EntityFactory.java +++ b/src/net/sourceforge/plantuml/cucadiagram/entity/EntityFactory.java @@ -59,9 +59,9 @@ import net.sourceforge.plantuml.skin.VisibilityModifier; public class EntityFactory { - private final Map leafs = new Protect(new LinkedHashMap()); + private final Map leafs = new LinkedHashMap(); private final List links = new ArrayList(); - private final Map groups = new Protect(new LinkedHashMap()); + private final Map groups = new LinkedHashMap(); private int rawLayout; private final IGroup rootGroup = new GroupRoot(this); @@ -209,75 +209,4 @@ public class EntityFactory { return result; } - static class Protect implements Map { - - private final Map m; - - public Protect(Map data) { - this.m = data; - } - - public O remove(Object key) { - if (key instanceof Code == false) { - throw new IllegalArgumentException(); - } - return m.remove(key); - } - - public O get(Object key) { - if (key instanceof Code == false) { - throw new IllegalArgumentException(); - } - return m.get(key); - } - - public Set keySet() { - return m.keySet(); - } - - public void putAll(Map m) { - this.m.putAll(m); - } - - public boolean containsKey(Object key) { - if (key instanceof Code == false) { - throw new IllegalArgumentException(); - } - return m.containsKey(key); - } - - public boolean isEmpty() { - return m.isEmpty(); - } - - public O put(Code key, O value) { - if (key instanceof Code == false) { - throw new IllegalArgumentException(); - } - return m.put(key, value); - } - - public boolean containsValue(Object value) { - return m.containsValue(value); - } - - public Set> entrySet() { - return m.entrySet(); - } - - public Collection values() { - return m.values(); - } - - public void clear() { - m.clear(); - - } - - public int size() { - return m.size(); - } - - } - } diff --git a/src/net/sourceforge/plantuml/donors/PSystemDonors.java b/src/net/sourceforge/plantuml/donors/PSystemDonors.java index 603711039..9b0c412e3 100644 --- a/src/net/sourceforge/plantuml/donors/PSystemDonors.java +++ b/src/net/sourceforge/plantuml/donors/PSystemDonors.java @@ -71,28 +71,28 @@ public class PSystemDonors extends AbstractPSystem { private static final int COLS = 6; private static final int FREE_LINES = 6; - public static final String DONORS = "6rW902mFR3hSmrTODcikzuop9yl7Q5RohVaQVmG9QrfMG8eAo04YsxAZMAlDIBlv0O82w3Lqz9ZRTthS" - + "RwI_YAvqzqqpecqsfpJFA8e5GUFvDksmpP-zgJAa53AGwKICX-1fynfBhQmb_o3XTFytdKBoK166eTaA" - + "vwCHQlz096FjZgt6TFUZgBjMNTob2jyADQPJn35S5HhbrGDVMoWP5IxzEdyBcfWL4pb4YgUis68UlQ67" - + "AxdGEYCBPDR-exu0BLB392Xo2L1iFKcYuwsbdNq7ki-HG8SJboYmcJ479Gxh7MZjt12pn2a23PTcOJGs" - + "aRFbYGaC-w05U_WVzKIEMz3AB8Ks9oxNW88zReR3I5gbYYPYTcWpeBX5jEX8O54NnuLmVHmCJSbvq70B" - + "KEnYWL9CQW1v4-iTV9gDV57dqZU12bxr3ecZsHbMLzaXPZutPlJjpqC2ol_-oSmOdotbQa6L9LzdVzHf" - + "87S96ZdiZTR6AblWNY_gb31_iK1-0BrK2og9xrat5bg0k9UK5-Jcd3-vZY8mDgK45di8KrgJ7zOLQ6n2" - + "bhiP2to4dujDi88jk7BvQj3DjE8vfVE5b9GGlttHgo7zLeWrSRDw-wXtJvbh-V-wQugP53VGIGczJTS2" - + "58KnMBKB4nF1ow2tGsu4P0EKXzAjE3I_o5_x0fct9lU0o6tEiLygtb0tEWGn3TPq8OKPmFmkHRbpudO7" - + "4Kvh0tgNgImZRUuocrBDr25ZxhfG9p_kcnchue0SyhpmeKvmSyEugZVBkxGVC0jubByiFlsSH_1O1JWF" - + "zzxpmj9SWe5sXZfQ86r6rFSzzKNX9WubikXRxEBakrnFN3nqFVZioQ9TpF_C-4yW7uFAonPAwfiCRn9e" - + "-WwPR4nV-IHlmFyoCCqSZenFCUzV9i_Kn14dJjCnd6ri0B1N5JwnE0Xk1gfkwTbPJ8gORBxwc3aJ_1XV" - + "W55P2vuAszdTI-8CQ9JO9-QzCkekldLAFXPG9he8bjA2KZqeAKB7C39YrA3dh3LW-rtC5kYrpsnOKYY-" - + "BQ9x6Xi0hLNHJUXxk06U21ML4bwBIS9W_A_nD3qOw-3ZDosr8WwIrIKnSwY0vkW9fwL-sRgaiDwYzrlN" - + "zQ9f-FF_oT4CJjMuvgiAeYi8_5-W81nozHvuBIhzz-2J4hSDZ62rdjY9bLT6JpDBI13SibwdRjECz4nK" - + "b3kGXTfnVAZuJog6mzInmVABPPAYso0dTRs8ErLGzlKlmaaEXSyxHPKTHLoNoZqn8fdO-L6S-TXdJu6R" - + "c-1cwePB1FgU_cwOn45jpHSfDGm7GvwAIAETpri3"; + public static final String DONORS = "6ty902mFR3fSuLzO9ciEU-UTVLaMenKn_Poll0GDwsu450sG0Q8aQloSnDhywO_J0H90rz3HOsxVwN6_" + + "aVuYkjAzRveHRVcs-MeT28Jb1yTZxQt2wPrlgWmfGKmLss-PqDxVVbneGbeh65VWfd92vl-cq-9uA8HP" + + "cgrmFXgXChPaZuwvpzsFeYvKNLo2gc-56jEfn35S5JQ6wpFKDHonwDhLyQWe6HGZh28bKJUE8C4TDngr" + + "KJd19r8B_r4BQDAQJKFIAQ1OHefOyxRC-UC0zJTXu4GGKpeS8CAXf2DuWJ54VI618AeODMgZw8pDLCzv" + + "ueE955JOWN_af7fl8TkZ31q8OhAXGC9F40HWpzLGuhEvsO3IBRp5l0QRTMfPoMZtDrDIQguqF00wOY9e" + + "1Ln1o9kW2tuVRUOIPngxei0RdiHubTi7kSZs0DXU3EZRMHC3vGizEVEKPKPrQo6TKwvp_EfiaEyQChEt" + + "cr75E8k9cD_cKXY-k03xcw2NMaF5-9lpp48sXCUKkf2Tv_Bbt8b0M6KfMUGgbgIc_hIBAMrTpFUcBEBT" + + "-tLgADimWbTJv80-gfNsXiuNYgk6-kSXZxgEJ-5hqXRYNQBlJiojuk_jRWapJbVGzIPyg6w0A3Lwucgk" + + "M5GHk8FesP27WDo1wilaLdbPFYIkvmDIRqiu49aDOYDnpRRYa8j5c0TMTgMA0S0MBj6kt_gTf5zvTK8V" + + "WfLHP8IxVhj9zx1vDioDNYj0Gur1UKDdonSPgxaW3ZDCownPFT1-n564otYGl7hUCxkk0bYJUMzRR8sd" + + "Cx2kOSumITCH-JZIbcGSwYWzYxFDcxh4gxcTx3nqEpXFRz49Piuswo5J8FUeUMcfMunxrs38crDPnQxb" + + "ehq4-kfcFL32Cpu5t6wS3Ada4eAeuKn7I4n09BNEApPOulekgdevEPwQbZ1hjzL1eDhv4Ni3GLMm4suW" + + "plfUusT4YMBdxVDUcNLNtuUKM1TG8GO48wbGjX5ILCBcL3AizrRFyUZWjL_QT46_ZM-MB0aKtW4HQhv1" + + "qYdC8q_mHirPefHJgv8lUqoCWEzn-GtsnAuES_oEbbOUPv0RWfGxfO3abs15Isst9bXlqVksRNjRDlxy" + + "tskod5Cprx7o0Bg0k02rUH4xKHVrF2d_TT0ddUCMCWD6dHpxoXjJhmSO28fcsUvLUp-ZVhcKbzjLEtsK" + + "zKEb_qCgGJ2M5oox6AMeZ3ObM6rxgniLYttxZR2NG-FycwYoAJ-uobIhPqHIiSkTEC_ZjOrK8efAESo0" + + "jXE2mDblV9P2uoMZZIjWjSC5HJwVPfV3evcMs12Kbf7rm2_T0000"; /* * Special thanks to our sponsors and donors: * - * - Noam Tamim + * - Noam Tamim */ @Override diff --git a/src/net/sourceforge/plantuml/eps/EpsGraphics.java b/src/net/sourceforge/plantuml/eps/EpsGraphics.java index 410ac679a..50636270a 100644 --- a/src/net/sourceforge/plantuml/eps/EpsGraphics.java +++ b/src/net/sourceforge/plantuml/eps/EpsGraphics.java @@ -291,6 +291,8 @@ public class EpsGraphics { curvetoNoMacro(coord[0] + x, coord[1] + y, coord[2] + x, coord[3] + y, coord[4] + x, coord[5] + y); } else if (type == USegmentType.SEG_CLOSE) { // Nothing + } else if (type == USegmentType.SEG_ARCTO) { + // Nothing } else { Log.println("unknown1 " + seg); } @@ -315,6 +317,8 @@ public class EpsGraphics { curvetoNoMacro(coord[0] + x, coord[1] + y, coord[2] + x, coord[3] + y, coord[4] + x, coord[5] + y); } else if (type == USegmentType.SEG_CLOSE) { // Nothing + } else if (type == USegmentType.SEG_ARCTO) { + // Nothing } else { Log.println("unknown2 " + seg); } diff --git a/src/net/sourceforge/plantuml/error/PSystemError.java b/src/net/sourceforge/plantuml/error/PSystemError.java index 93e6349f3..e4357fc5f 100644 --- a/src/net/sourceforge/plantuml/error/PSystemError.java +++ b/src/net/sourceforge/plantuml/error/PSystemError.java @@ -208,12 +208,12 @@ public abstract class PSystemError extends AbstractPSystem { return new ImageDataSimple(1, 1); } - // final boolean useRed = fileFormat.isUseRedForError(); final TextBlockBackcolored result = getGraphicalFormatted(); TextBlock udrawable; final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(), getMetadata(), null, 0, 0, null, false); + imageBuilder.setRandomPixel(true); if (getSource().getTotalLineCount() < 5) { udrawable = addWelcome(result); } else { @@ -242,13 +242,6 @@ public abstract class PSystemError extends AbstractPSystem { } } - // private String getRed(boolean useRed) { - // if (useRed) { - // return "#CD0A0A"; - // } - // return "red"; - // } - // final public DiagramDescription getDescription() { return new DiagramDescription("(Error)"); } diff --git a/src/net/sourceforge/plantuml/graphic/GraphicStrings.java b/src/net/sourceforge/plantuml/graphic/GraphicStrings.java index cd748b67a..882327156 100644 --- a/src/net/sourceforge/plantuml/graphic/GraphicStrings.java +++ b/src/net/sourceforge/plantuml/graphic/GraphicStrings.java @@ -66,6 +66,7 @@ public class GraphicStrings extends AbstractTextBlock implements IEntityImage { private final List strings; private final BufferedImage image; + private final double imagePadding = 30; private final GraphicPosition position; @@ -174,9 +175,9 @@ public class GraphicStrings extends AbstractTextBlock implements IEntityImage { if (position == GraphicPosition.BOTTOM) { dim = new Dimension2DDouble(dim.getWidth(), dim.getHeight() + image.getHeight()); } else if (position == GraphicPosition.BACKGROUND_CORNER_BOTTOM_RIGHT) { - dim = new Dimension2DDouble(dim.getWidth() + image.getWidth(), dim.getHeight()); + dim = new Dimension2DDouble(dim.getWidth() + imagePadding + image.getWidth(), dim.getHeight()); } else if (position == GraphicPosition.BACKGROUND_CORNER_TOP_RIGHT) { - dim = new Dimension2DDouble(dim.getWidth() + image.getWidth(), dim.getHeight()); + dim = new Dimension2DDouble(dim.getWidth() + imagePadding + image.getWidth(), dim.getHeight()); } } return dim; diff --git a/src/net/sourceforge/plantuml/graphic/USymbolCloud.java b/src/net/sourceforge/plantuml/graphic/USymbolCloud.java index 62396fcf5..2a1984ff1 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolCloud.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolCloud.java @@ -153,7 +153,11 @@ class USymbolCloud extends USymbol { private void bubbleLine(Random rnd, List points, Point2D p1, Point2D p2, double bubbleSize) { final CoordinateChange change = new CoordinateChange(p1, p2); final double length = change.getLength(); - final int nb = (int) (length / bubbleSize); + int nb = (int) (length / bubbleSize); + if (nb == 0) { + bubbleSize = length / 2; + nb = (int) (length / bubbleSize); + } for (int i = 0; i < nb; i++) { points.add(rnd(rnd, change.getTrueCoordinate(i * length / nb, 0), bubbleSize * .2)); } @@ -239,7 +243,8 @@ class USymbolCloud extends USymbol { @Override public TextBlock asBig(final TextBlock title, HorizontalAlignment labelAlignment, final TextBlock stereotype, - final double width, final double height, final SymbolContext symbolContext, final HorizontalAlignment stereoAlignment) { + final double width, final double height, final SymbolContext symbolContext, + final HorizontalAlignment stereoAlignment) { return new AbstractTextBlock() { public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/mindmap/FingerImpl.java b/src/net/sourceforge/plantuml/mindmap/FingerImpl.java index e0b531a8d..a077552ec 100644 --- a/src/net/sourceforge/plantuml/mindmap/FingerImpl.java +++ b/src/net/sourceforge/plantuml/mindmap/FingerImpl.java @@ -72,6 +72,7 @@ public class FingerImpl implements Finger, UDrawable { private final Display label; private final HtmlColor backColor; + private final String stereotype; private final ISkinParam skinParam; private final StyleBuilder styleBuilder; private final IdeaShape shape; @@ -83,23 +84,25 @@ public class FingerImpl implements Finger, UDrawable { private final List nail = new ArrayList(); private Tetris tetris = null; - public StyleSignature getDefaultStyleDefinitionNode() { + private StyleSignature getDefaultStyleDefinitionNode() { if (level == 0) { - return StyleSignature.of(SName.root, SName.element, SName.mindmapDiagram, SName.node, SName.rootNode); + return StyleSignature.of(SName.root, SName.element, SName.mindmapDiagram, SName.node, SName.rootNode).add( + stereotype); } if (nail.size() == 0) { - return StyleSignature.of(SName.root, SName.element, SName.mindmapDiagram, SName.node, SName.leafNode); + return StyleSignature.of(SName.root, SName.element, SName.mindmapDiagram, SName.node, SName.leafNode).add( + stereotype); } - return StyleSignature.of(SName.root, SName.element, SName.mindmapDiagram, SName.node); + return StyleSignature.of(SName.root, SName.element, SName.mindmapDiagram, SName.node).add(stereotype); } public StyleSignature getDefaultStyleDefinitionArrow() { - return StyleSignature.of(SName.root, SName.element, SName.mindmapDiagram, SName.arrow); + return StyleSignature.of(SName.root, SName.element, SName.mindmapDiagram, SName.arrow).add(stereotype); } public static FingerImpl build(Idea idea, ISkinParam skinParam, Direction direction) { final FingerImpl result = new FingerImpl(idea.getStyleBuilder(), idea.getBackColor(), idea.getLabel(), - skinParam, idea.getShape(), direction, idea.getLevel()); + skinParam, idea.getShape(), direction, idea.getLevel(), idea.getStereotype()); for (Idea child : idea.getChildren()) { result.addInNail(build(child, skinParam, direction)); } @@ -112,8 +115,9 @@ public class FingerImpl implements Finger, UDrawable { } private FingerImpl(StyleBuilder styleBuilder, HtmlColor backColor, Display label, ISkinParam skinParam, - IdeaShape shape, Direction direction, int level) { + IdeaShape shape, Direction direction, int level, String stereotype) { this.backColor = backColor; + this.stereotype = stereotype; this.level = level; this.label = label; this.skinParam = skinParam; diff --git a/src/net/sourceforge/plantuml/mindmap/Idea.java b/src/net/sourceforge/plantuml/mindmap/Idea.java index 42c9893e0..509ecea93 100644 --- a/src/net/sourceforge/plantuml/mindmap/Idea.java +++ b/src/net/sourceforge/plantuml/mindmap/Idea.java @@ -57,14 +57,15 @@ class Idea { private final IdeaShape shape; private final HtmlColor backColor; private final StyleBuilder styleBuilder; + private final String stereotype; - public Idea(StyleBuilder styleBuilder, Display label, IdeaShape shape) { - this(styleBuilder, null, 0, null, label, shape); + public Idea(StyleBuilder styleBuilder, Display label, IdeaShape shape, String stereotype) { + this(styleBuilder, null, 0, null, label, shape, stereotype); } public Idea createIdea(StyleBuilder styleBuilder, HtmlColor backColor, int newLevel, Display newDisplay, - IdeaShape newShape) { - final Idea result = new Idea(styleBuilder, backColor, newLevel, this, newDisplay, newShape); + IdeaShape newShape, String stereotype) { + final Idea result = new Idea(styleBuilder, backColor, newLevel, this, newDisplay, newShape, stereotype); this.children.add(result); return result; } @@ -77,13 +78,15 @@ class Idea { // return result; // } - private Idea(StyleBuilder styleBuilder, HtmlColor backColor, int level, Idea parent, Display label, IdeaShape shape) { + private Idea(StyleBuilder styleBuilder, HtmlColor backColor, int level, Idea parent, Display label, + IdeaShape shape, String stereotype) { this.backColor = backColor; this.styleBuilder = styleBuilder; this.label = label; this.level = level; this.parent = parent; this.shape = shape; + this.stereotype = stereotype; } @Override @@ -123,4 +126,8 @@ class Idea { return styleBuilder; } + public final String getStereotype() { + return stereotype; + } + } diff --git a/src/net/sourceforge/plantuml/mindmap/MindMapDiagram.java b/src/net/sourceforge/plantuml/mindmap/MindMapDiagram.java index 1da95f955..e7859dc14 100644 --- a/src/net/sourceforge/plantuml/mindmap/MindMapDiagram.java +++ b/src/net/sourceforge/plantuml/mindmap/MindMapDiagram.java @@ -49,6 +49,7 @@ import net.sourceforge.plantuml.Scale; import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.regex.Matcher2; import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.cucadiagram.Display; @@ -62,6 +63,7 @@ import net.sourceforge.plantuml.ugraphic.ImageBuilder; import net.sourceforge.plantuml.ugraphic.MinMax; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; +import net.sourceforge.plantuml.wbs.WBSDiagram; public class MindMapDiagram extends UmlDiagram { @@ -179,19 +181,25 @@ public class MindMapDiagram extends UmlDiagram { public CommandExecutionResult addIdea(HtmlColor backColor, int level, String label, IdeaShape shape, Direction direction) { + final Matcher2 m = WBSDiagram.patternStereotype.matcher(label); + String stereotype = null; + if (m.matches()) { + label = m.group(1); + stereotype = m.group(2); + } if (level == 0) { if (this.right.root != null) { return CommandExecutionResult .error("I don't know how to draw multi-root diagram. You should suggest an image so that the PlantUML team implements it :-)"); } - right.initRoot(getSkinParam().getCurrentStyleBuilder(), label, shape); - left.initRoot(getSkinParam().getCurrentStyleBuilder(), label, shape); + right.initRoot(getSkinParam().getCurrentStyleBuilder(), label, shape, stereotype); + left.initRoot(getSkinParam().getCurrentStyleBuilder(), label, shape, stereotype); return CommandExecutionResult.ok(); } if (direction == Direction.LEFT) { - return left.add(getSkinParam().getCurrentStyleBuilder(), backColor, level, label, shape); + return left.add(getSkinParam().getCurrentStyleBuilder(), backColor, level, label, shape, stereotype); } - return right.add(getSkinParam().getCurrentStyleBuilder(), backColor, level, label, shape); + return right.add(getSkinParam().getCurrentStyleBuilder(), backColor, level, label, shape, stereotype); } static class Branch { @@ -199,8 +207,8 @@ public class MindMapDiagram extends UmlDiagram { private Idea last; private Finger finger; - private void initRoot(StyleBuilder styleBuilder, String label, IdeaShape shape) { - root = new Idea(styleBuilder, Display.getWithNewlines(label), shape); + private void initRoot(StyleBuilder styleBuilder, String label, IdeaShape shape, String stereotype) { + root = new Idea(styleBuilder, Display.getWithNewlines(label), shape, stereotype); last = root; } @@ -213,17 +221,20 @@ public class MindMapDiagram extends UmlDiagram { } private CommandExecutionResult add(StyleBuilder styleBuilder, HtmlColor backColor, int level, String label, - IdeaShape shape) { + IdeaShape shape, String stereotype) { + if (last == null) { + return CommandExecutionResult.error("Check your indentation ?"); + } if (level == last.getLevel() + 1) { final Idea newIdea = last.createIdea(styleBuilder, backColor, level, Display.getWithNewlines(label), - shape); + shape, stereotype); last = newIdea; return CommandExecutionResult.ok(); } if (level <= last.getLevel()) { final int diff = last.getLevel() - level + 1; final Idea newIdea = getParentOfLast(diff).createIdea(styleBuilder, backColor, level, - Display.getWithNewlines(label), shape); + Display.getWithNewlines(label), shape, stereotype); last = newIdea; return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/preproc/FileWithSuffix.java b/src/net/sourceforge/plantuml/preproc/FileWithSuffix.java index b0010f7db..8e897f06d 100644 --- a/src/net/sourceforge/plantuml/preproc/FileWithSuffix.java +++ b/src/net/sourceforge/plantuml/preproc/FileWithSuffix.java @@ -58,6 +58,10 @@ public class FileWithSuffix { private final String entry; private final String description; + @Override + public String toString() { + return file.toString(); + } public Reader getReader(String charset) throws IOException { if (entry == null) { if (charset == null) { diff --git a/src/net/sourceforge/plantuml/sequencediagram/AbstractMessage.java b/src/net/sourceforge/plantuml/sequencediagram/AbstractMessage.java index adbdc25fb..4a9f5dfe4 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/AbstractMessage.java +++ b/src/net/sourceforge/plantuml/sequencediagram/AbstractMessage.java @@ -41,7 +41,6 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import net.sourceforge.plantuml.OptionFlags; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.skin.ArrowConfiguration; diff --git a/src/net/sourceforge/plantuml/sequencediagram/Englober.java b/src/net/sourceforge/plantuml/sequencediagram/Englober.java index a23c31463..f6b42e923 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/Englober.java +++ b/src/net/sourceforge/plantuml/sequencediagram/Englober.java @@ -57,7 +57,6 @@ import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.StyleBuilder; import net.sourceforge.plantuml.style.StyleSignature; -import net.sourceforge.plantuml.style.ValueImpl; import net.sourceforge.plantuml.style.WithStyle; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; @@ -78,7 +77,7 @@ public class Englober implements WithStyle { } public Style[] getUsedStyles() { - Style tmp = getDefaultStyleDefinition().getMergedStyle(styleBuilder); + Style tmp = getDefaultStyleDefinition().with(participantEnglober.getStereotype()).getMergedStyle(styleBuilder); final HtmlColor backColor = participantEnglober.getBoxColor(); if (tmp != null) { tmp = tmp.eventuallyOverride(PName.BackGroundColor, backColor); diff --git a/src/net/sourceforge/plantuml/sequencediagram/LinkAnchor.java b/src/net/sourceforge/plantuml/sequencediagram/LinkAnchor.java index 47f119ec0..513ee7321 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/LinkAnchor.java +++ b/src/net/sourceforge/plantuml/sequencediagram/LinkAnchor.java @@ -44,7 +44,6 @@ import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.HtmlColorAndStyle; import net.sourceforge.plantuml.graphic.Rainbow; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; diff --git a/src/net/sourceforge/plantuml/sequencediagram/MessageExo.java b/src/net/sourceforge/plantuml/sequencediagram/MessageExo.java index 321a2b3ad..4e2292654 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/MessageExo.java +++ b/src/net/sourceforge/plantuml/sequencediagram/MessageExo.java @@ -37,9 +37,7 @@ package net.sourceforge.plantuml.sequencediagram; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.skin.ArrowConfiguration; -import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.StyleBuilder; -import net.sourceforge.plantuml.style.StyleSignature; public class MessageExo extends AbstractMessage { diff --git a/src/net/sourceforge/plantuml/sequencediagram/Note.java b/src/net/sourceforge/plantuml/sequencediagram/Note.java index cfea80bdd..0b29e01b4 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/Note.java +++ b/src/net/sourceforge/plantuml/sequencediagram/Note.java @@ -38,7 +38,6 @@ package net.sourceforge.plantuml.sequencediagram; import java.util.List; import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.OptionFlags; import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.SpecificBackcolorable; import net.sourceforge.plantuml.Url; diff --git a/src/net/sourceforge/plantuml/sequencediagram/Participant.java b/src/net/sourceforge/plantuml/sequencediagram/Participant.java index 6c99bfb6c..2e8c87fdf 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/Participant.java +++ b/src/net/sourceforge/plantuml/sequencediagram/Participant.java @@ -50,7 +50,6 @@ import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.SymbolContext; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.Colors; -import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.StyleBuilder; import net.sourceforge.plantuml.style.StyleSignature; @@ -73,15 +72,16 @@ public class Participant implements SpecificBackcolorable, WithStyle { // private Style style; public StyleSignature getDefaultStyleDefinition() { - return type.getDefaultStyleDefinition(); + return type.getDefaultStyleDefinition().addClickable(getUrl()); } public Style[] getUsedStyles() { if (SkinParam.USE_STYLES() == false) { return null; } - Style tmp = getDefaultStyleDefinition().with(stereotype).getMergedStyle(styleBuilder) - .eventuallyOverride(getColors(null)); + final StyleSignature signature = getDefaultStyleDefinition().with(stereotype); + Style tmp = signature.getMergedStyle(styleBuilder); + tmp = tmp.eventuallyOverride(getColors(null)); Style stereo = getDefaultStyleDefinition().withStereotype(stereotype).getMergedStyle(styleBuilder); if (tmp != null) { stereo = tmp.mergeWith(stereo); diff --git a/src/net/sourceforge/plantuml/sequencediagram/ParticipantEnglober.java b/src/net/sourceforge/plantuml/sequencediagram/ParticipantEnglober.java index b1351b234..13c04dda9 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/ParticipantEnglober.java +++ b/src/net/sourceforge/plantuml/sequencediagram/ParticipantEnglober.java @@ -36,16 +36,19 @@ package net.sourceforge.plantuml.sequencediagram; import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.HtmlColor; public class ParticipantEnglober { final private Display title; final private HtmlColor boxColor; + final private Stereotype stereotype; - public ParticipantEnglober(Display title, HtmlColor boxColor) { + public ParticipantEnglober(Display title, HtmlColor boxColor, Stereotype stereotype) { this.title = title; this.boxColor = boxColor; + this.stereotype = stereotype; } public final Display getTitle() { @@ -56,5 +59,8 @@ public class ParticipantEnglober { return boxColor; } + public final Stereotype getStereotype() { + return stereotype; + } } diff --git a/src/net/sourceforge/plantuml/sequencediagram/ParticipantType.java b/src/net/sourceforge/plantuml/sequencediagram/ParticipantType.java index a4448c599..e906c6a43 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/ParticipantType.java +++ b/src/net/sourceforge/plantuml/sequencediagram/ParticipantType.java @@ -37,8 +37,8 @@ package net.sourceforge.plantuml.sequencediagram; import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.style.SName; -import net.sourceforge.plantuml.style.Styleable; import net.sourceforge.plantuml.style.StyleSignature; +import net.sourceforge.plantuml.style.Styleable; public enum ParticipantType implements Styleable { PARTICIPANT(ColorParam.participantBackground), // diff --git a/src/net/sourceforge/plantuml/sequencediagram/Reference.java b/src/net/sourceforge/plantuml/sequencediagram/Reference.java index 00265c0dd..041a6ad35 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/Reference.java +++ b/src/net/sourceforge/plantuml/sequencediagram/Reference.java @@ -42,7 +42,6 @@ import java.util.List; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.skin.ComponentType; import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.Style; diff --git a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java index 58dacff9d..281079d93 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java +++ b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java @@ -61,6 +61,7 @@ import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.EntityPortion; +import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.SymbolContext; import net.sourceforge.plantuml.sequencediagram.graphic.FileMaker; @@ -391,11 +392,11 @@ public class SequenceDiagram extends UmlDiagram { private ParticipantEnglober participantEnglober; - public void boxStart(Display comment, HtmlColor color) { + public void boxStart(Display comment, HtmlColor color, Stereotype stereotype) { if (participantEnglober != null) { throw new IllegalStateException(); } - this.participantEnglober = new ParticipantEnglober(comment, color); + this.participantEnglober = new ParticipantEnglober(comment, color, stereotype); } public void endBox() { diff --git a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java index dca3fa5f7..63947877d 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java +++ b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java @@ -75,7 +75,6 @@ import net.sourceforge.plantuml.sequencediagram.command.CommandParticipantA4; import net.sourceforge.plantuml.sequencediagram.command.CommandReferenceMultilinesOverSeveral; import net.sourceforge.plantuml.sequencediagram.command.CommandReferenceOverSeveral; import net.sourceforge.plantuml.sequencediagram.command.CommandReturn; -import net.sourceforge.plantuml.sequencediagram.command.CommandSkin; import net.sourceforge.plantuml.sequencediagram.command.CommandUrl; public class SequenceDiagramFactory extends UmlDiagramFactory { diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxStart.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxStart.java index 47d1bce72..76612495c 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxStart.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxStart.java @@ -35,6 +35,8 @@ */ package net.sourceforge.plantuml.sequencediagram.command; +import net.sourceforge.plantuml.FontParam; +import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; @@ -45,10 +47,12 @@ 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.Display; +import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; +import net.sourceforge.plantuml.ugraphic.UFont; public class CommandBoxStart extends SingleLineCommand2 { @@ -67,7 +71,9 @@ public class CommandBoxStart extends SingleLineCommand2 { RegexLeaf.spaceOneOrMore(), // new RegexLeaf("NAME2", "([^#]+)")))), // RegexLeaf.spaceZeroOrMore(), // - color().getRegex(), RegexLeaf.end()); + new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), // + color().getRegex(), // + RegexLeaf.end()); } private static ColorParser color() { @@ -75,16 +81,24 @@ public class CommandBoxStart extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg2) { + protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) { if (diagram.isBoxPending()) { return CommandExecutionResult.error("Box cannot be nested"); } - final String argTitle = arg2.getLazzy("NAME", 0); - final String argColor = arg2.get("COLOR", 0); + final String argTitle = arg.getLazzy("NAME", 0); + final String argColor = arg.get("COLOR", 0); + + final String stereo = arg.get("STEREO", 0); + Stereotype stereotype = null; + if (stereo != null) { + final ISkinParam skinParam = diagram.getSkinParam(); + stereotype = new Stereotype(stereo); + } + // final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(argColor); - Colors colors = color().getColor(arg2, diagram.getSkinParam().getIHtmlColorSet()); + Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet()); final String title = argTitle == null ? "" : argTitle; - diagram.boxStart(Display.getWithNewlines(title), colors.getColor(ColorType.BACK)); + diagram.boxStart(Display.getWithNewlines(title), colors.getColor(ColorType.BACK), stereotype); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Message.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Message.java index fc9d2617a..bc34be0a6 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Message.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Message.java @@ -264,7 +264,8 @@ class Step1Message extends Step1Abstract { } if (m.getArrowConfiguration().getDressing2().getHead() == ArrowHead.CROSSX) { result = result.withHead2(m.getArrowConfiguration().getDressing2().getHead()); - System.err.println("WARNING : CROSSX"); + // System.err.println("WARNING : CROSSX"); + // Thread.dumpStack(); // assert false; } result = result.withPart(m.getArrowConfiguration().getPart()); diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/NoteTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/NoteTile.java index 96bee772a..3df211f46 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/NoteTile.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/NoteTile.java @@ -103,7 +103,6 @@ public class NoteTile extends AbstractTile implements Tile { ug = ug.apply(new UTranslate(x, 0)); comp.drawU(ug, area, (Context2D) ug); - // ug.draw(new ULine(x2 - x1, 0)); } private double getUsedWidth(StringBounder stringBounder) { diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java index a8e1c1815..e9c87ab7a 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java @@ -76,9 +76,10 @@ public class ComponentRoseArrow extends AbstractComponentRoseArrow { boolean belowForResponse) { super(style, foregroundColor, font, stringsToDisplay, arrowConfiguration, spriteContainer, textHorizontalAlignment, maxMessageSize); - if (SkinParam.USE_STYLES()) { - messagePosition = style.getHorizontalAlignment(); - } + // Done in Rose::createComponentArrow + // if (SkinParam.USE_STYLES()) { + // messagePosition = style.getHorizontalAlignment(); + // } this.messagePosition = messagePosition; this.niceArrow = niceArrow; this.belowForResponse = belowForResponse; diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingElse.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingElse.java index 9d678a118..71fbe9cf5 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingElse.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingElse.java @@ -41,6 +41,7 @@ import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.OptionFlags; import net.sourceforge.plantuml.SkinParam; +import net.sourceforge.plantuml.SkinParamBackcolored; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HtmlColor; @@ -69,6 +70,10 @@ public class ComponentRoseGroupingElse extends AbstractTextualComponent { super(style, LineBreakStrategy.NONE, comment == null ? null : "[" + comment + "]", smallFont, HorizontalAlignment.LEFT, 5, 5, 1, spriteContainer, null, null); if (SkinParam.USE_STYLES()) { + if (spriteContainer instanceof SkinParamBackcolored) { + style = style.eventuallyOverride(PName.BackGroundColor, + ((SkinParamBackcolored) spriteContainer).getBackgroundColor()); + } this.groupBorder = style.value(PName.LineColor).asColor(getIHtmlColorSet()); this.backgroundColor = style.value(PName.BackGroundColor).asColor(getIHtmlColorSet()); } else { diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteBox.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteBox.java index b1dfcd763..2c35139c9 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteBox.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteBox.java @@ -36,6 +36,7 @@ package net.sourceforge.plantuml.skin.rose; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -43,6 +44,7 @@ import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.SymbolContext; import net.sourceforge.plantuml.skin.AbstractTextualComponent; import net.sourceforge.plantuml.skin.Area; +import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.URectangle; @@ -57,8 +59,13 @@ final public class ComponentRoseNoteBox extends AbstractTextualComponent { public ComponentRoseNoteBox(Style style, SymbolContext symbolContext, FontConfiguration font, Display strings, ISkinSimple spriteContainer, double roundCorner, HorizontalAlignment alignment) { super(style, spriteContainer.wrapWidth(), strings, font, alignment, 4, 4, 4, spriteContainer, false, null, null); - this.roundCorner = roundCorner; - this.symbolContext = symbolContext; + if (SkinParam.USE_STYLES()) { + this.symbolContext = style.getSymbolContext(getIHtmlColorSet()); + this.roundCorner = style.value(PName.RoundCorner).asInt(); + } else { + this.symbolContext = symbolContext; + this.roundCorner = roundCorner; + } } @Override diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteHexagonal.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteHexagonal.java index ebda7f86a..831c09610 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteHexagonal.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteHexagonal.java @@ -36,6 +36,7 @@ package net.sourceforge.plantuml.skin.rose; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -43,6 +44,7 @@ import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.SymbolContext; import net.sourceforge.plantuml.skin.AbstractTextualComponent; import net.sourceforge.plantuml.skin.Area; +import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UPolygon; @@ -57,7 +59,11 @@ final public class ComponentRoseNoteHexagonal extends AbstractTextualComponent { public ComponentRoseNoteHexagonal(Style style, SymbolContext symbolContext, FontConfiguration font, Display strings, ISkinSimple spriteContainer, HorizontalAlignment alignment) { super(style, spriteContainer.wrapWidth(), strings, font, alignment, 12, 12, 4, spriteContainer, false, null, null); - this.symbolContext = symbolContext; + if (SkinParam.USE_STYLES()) { + this.symbolContext = style.getSymbolContext(getIHtmlColorSet()); + } else { + this.symbolContext = symbolContext; + } } @Override diff --git a/src/net/sourceforge/plantuml/skin/rose/Rose.java b/src/net/sourceforge/plantuml/skin/rose/Rose.java index bbdc1d79c..55d712b6b 100644 --- a/src/net/sourceforge/plantuml/skin/rose/Rose.java +++ b/src/net/sourceforge/plantuml/skin/rose/Rose.java @@ -42,6 +42,7 @@ import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.PaddingParam; +import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Stereotype; @@ -55,7 +56,10 @@ import net.sourceforge.plantuml.skin.ArrowConfiguration; import net.sourceforge.plantuml.skin.ArrowDirection; import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.skin.ComponentType; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UStroke; @@ -307,10 +311,39 @@ public class Rose { FontParam.ARROW), stringsToDisplay, config, param, param.maxMessageSize(), param.strictUmlStyle() == false); } - final HorizontalAlignment messageHorizontalAlignment = param.getHorizontalAlignment( - AlignmentParam.sequenceMessageAlignment, config.getArrowDirection(), config.isReverseDefine()); - final HorizontalAlignment textHorizontalAlignment = param.getHorizontalAlignment( - AlignmentParam.sequenceMessageTextAlignment, config.getArrowDirection(), false); + HorizontalAlignment messageHorizontalAlignment; + final HorizontalAlignment textHorizontalAlignment; + final ArrowDirection arrowDirection = config.getArrowDirection(); + if (SkinParam.USE_STYLES()) { + final StyleSignature signature = StyleSignature.of(SName.root, SName.element, SName.sequenceDiagram, + SName.arrow); + final Style textStyle = signature.getMergedStyle(param.getCurrentStyleBuilder()); + final String value = textStyle.value(PName.HorizontalAlignment).asString(); + messageHorizontalAlignment = textStyle.getHorizontalAlignment(); + textHorizontalAlignment = textStyle.getHorizontalAlignment(); + if ("direction".equalsIgnoreCase(value)) { + if (arrowDirection == ArrowDirection.LEFT_TO_RIGHT_NORMAL) { + messageHorizontalAlignment = HorizontalAlignment.LEFT; + } else if (arrowDirection == ArrowDirection.RIGHT_TO_LEFT_REVERSE) { + messageHorizontalAlignment = HorizontalAlignment.RIGHT; + } else if (arrowDirection == ArrowDirection.BOTH_DIRECTION) { + messageHorizontalAlignment = HorizontalAlignment.CENTER; + } + } else if ("reversedirection".equalsIgnoreCase(value)) { + if (arrowDirection == ArrowDirection.LEFT_TO_RIGHT_NORMAL) { + messageHorizontalAlignment = HorizontalAlignment.RIGHT; + } else if (arrowDirection == ArrowDirection.RIGHT_TO_LEFT_REVERSE) { + messageHorizontalAlignment = HorizontalAlignment.LEFT; + } else if (arrowDirection == ArrowDirection.BOTH_DIRECTION) { + messageHorizontalAlignment = HorizontalAlignment.CENTER; + } + } + } else { + messageHorizontalAlignment = param.getHorizontalAlignment(AlignmentParam.sequenceMessageAlignment, + arrowDirection, config.isReverseDefine()); + textHorizontalAlignment = param.getHorizontalAlignment(AlignmentParam.sequenceMessageTextAlignment, + config.getArrowDirection(), false); + } return new ComponentRoseArrow(styles == null ? null : styles[0], sequenceArrow, getUFont2(param, FontParam.ARROW), stringsToDisplay, config, messageHorizontalAlignment, param, textHorizontalAlignment, param.maxMessageSize(), param.strictUmlStyle() == false, param.responseMessageBelowArrow()); diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowSpecificStereotype.java b/src/net/sourceforge/plantuml/style/CommandStyleImport.java similarity index 53% rename from src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowSpecificStereotype.java rename to src/net/sourceforge/plantuml/style/CommandStyleImport.java index e9c26de1d..e5a7f95e9 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowSpecificStereotype.java +++ b/src/net/sourceforge/plantuml/style/CommandStyleImport.java @@ -30,40 +30,62 @@ * * * Original Author: Arnaud Roques - * + * * */ -package net.sourceforge.plantuml.classdiagram.command; +package net.sourceforge.plantuml.style; +import java.io.File; +import java.io.IOException; + +import net.sourceforge.plantuml.FileSystem; import net.sourceforge.plantuml.LineLocation; +import net.sourceforge.plantuml.UmlDiagram; +import net.sourceforge.plantuml.command.BlocLines; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; -import net.sourceforge.plantuml.cucadiagram.CucaDiagram; -public class CommandHideShowSpecificStereotype extends SingleLineCommand2 { +public class CommandStyleImport extends SingleLineCommand2 { - public CommandHideShowSpecificStereotype() { + public CommandStyleImport() { super(getRegexConcat()); } static IRegex getRegexConcat() { - return RegexConcat.build(CommandHideShowSpecificStereotype.class.getName(), RegexLeaf.start(), // - new RegexLeaf("COMMAND", "(hide|show)"), // - RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)"), RegexLeaf.end()); + return RegexConcat.build(CommandStyleImport.class.getName(), // + RegexLeaf.start(), // + new RegexLeaf("\\"), RegexLeaf.end()); // } @Override - protected CommandExecutionResult executeArg(CucaDiagram diagram, LineLocation location, RegexResult arg) { - - // final String stereotype = arg.get("STEREOTYPE", 0); - // diagram.hideOrShow(new Stereotype(stereotype), arg.get("COMMAND", 0).equalsIgnoreCase("show")); - // - // return CommandExecutionResult.ok(); - throw new UnsupportedOperationException(); + protected CommandExecutionResult executeArg(UmlDiagram diagram, LineLocation location, RegexResult arg) { + final String path = arg.get("PATH", 0); + try { + final File f = FileSystem.getInstance().getFile(path); + if (f.exists() == false) { + return CommandExecutionResult.error("File does not exist: " + path); + } + final BlocLines lines = BlocLines.load(f, location); + final StyleBuilder styleBuilder = diagram.getSkinParam().getCurrentStyleBuilder(); + for (Style modifiedStyle : StyleLoader.getDeclaredStyles(lines, styleBuilder)) { + diagram.getSkinParam().muteStyle(modifiedStyle); + } + } catch (IOException e) { + return CommandExecutionResult.error("File does not exist: " + path); + } + return CommandExecutionResult.ok(); } } diff --git a/src/net/sourceforge/plantuml/style/CommandStyleMultilinesCSS.java b/src/net/sourceforge/plantuml/style/CommandStyleMultilinesCSS.java index 9547d2cbb..1a4f06baf 100644 --- a/src/net/sourceforge/plantuml/style/CommandStyleMultilinesCSS.java +++ b/src/net/sourceforge/plantuml/style/CommandStyleMultilinesCSS.java @@ -35,32 +35,18 @@ */ package net.sourceforge.plantuml.style; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.EnumMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - import net.sourceforge.plantuml.SkinParam; -import net.sourceforge.plantuml.StringLocated; import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.command.BlocLines; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandMultilines2; import net.sourceforge.plantuml.command.MultilinesStrategy; import net.sourceforge.plantuml.command.regex.IRegex; -import net.sourceforge.plantuml.command.regex.Matcher2; -import net.sourceforge.plantuml.command.regex.MyPattern; -import net.sourceforge.plantuml.command.regex.Pattern2; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; public class CommandStyleMultilinesCSS extends CommandMultilines2 { - public static final String STYLE_SELECTOR_SEPARATOR2 = "-&"; - public CommandStyleMultilinesCSS() { super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE); } @@ -77,96 +63,15 @@ public class CommandStyleMultilinesCSS extends CommandMultilines2 { ); } - private static final String NAME_USER = "[\\w()]+?"; - private final static Pattern2 userName = MyPattern.cmpile("^[.:]?(" + NAME_USER + ")([%s]+\\*)?[%s]*\\{$"); - private final static Pattern2 propertyAndValue = MyPattern.cmpile("^([\\w]+):?[%s]+(.*?);?$"); - private final static Pattern2 closeBracket = MyPattern.cmpile("^\\}$"); - protected CommandExecutionResult executeNow(UmlDiagram diagram, BlocLines lines) { if (SkinParam.USE_STYLES() == false) { return CommandExecutionResult.ok(); } final StyleBuilder styleBuilder = diagram.getSkinParam().getCurrentStyleBuilder(); - for (Style modifiedStyle : getDeclaredStyles(lines.subExtract(1, 1), styleBuilder)) { + for (Style modifiedStyle : StyleLoader.getDeclaredStyles(lines.subExtract(1, 1), styleBuilder)) { diagram.getSkinParam().muteStyle(modifiedStyle); } return CommandExecutionResult.ok(); } - public Collection