From 2ce0511e807566003bd9f90d6b16dd77852d062c Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Mon, 14 Feb 2011 12:56:34 +0100 Subject: [PATCH] Version 6121 --- pom.xml | 2 +- src/net/sourceforge/plantuml/FileUtils.java | 22 +++- src/net/sourceforge/plantuml/OptionFlags.java | 11 +- src/net/sourceforge/plantuml/StringUtils.java | 19 ++- src/net/sourceforge/plantuml/UmlDiagram.java | 11 +- .../activitydiagram/command/CommandIf.java | 4 +- .../command/CommandLinkActivity.java | 44 +++++-- .../command/CommandLinkLongActivity.java | 4 +- .../classdiagram/AbstractEntityDiagram.java | 4 +- .../command/CommandLinkClass2.java | 4 +- .../AbstractUmlSystemCommandFactory.java | 4 +- .../command/CommandLinkComponent2.java | 33 ++--- .../plantuml/cucadiagram/Entity.java | 13 +- .../plantuml/cucadiagram/EntityUtils.java | 8 ++ .../plantuml/cucadiagram/IEntity.java | 5 + .../cucadiagram/dot/AbstractGraphviz.java | 19 ++- .../plantuml/cucadiagram/dot/DotMaker.java | 24 +++- .../plantuml/cucadiagram/dot/DrawFile.java | 7 +- .../cucadiagram/dot/ProcessRunner.java | 13 +- .../plantuml/preproc/IfManager.java | 8 +- .../plantuml/preproc/Preprocessor.java | 6 +- .../plantuml/preproc/PreprocessorInclude.java | 4 +- .../plantuml/sequencediagram/Delay.java | 4 + .../plantuml/sequencediagram/Divider.java | 5 + .../plantuml/sequencediagram/Event.java | 4 +- .../sequencediagram/GroupingLeaf.java | 7 +- .../sequencediagram/GroupingStart.java | 5 + .../plantuml/sequencediagram/LifeEvent.java | 7 +- .../plantuml/sequencediagram/Message.java | 6 +- .../plantuml/sequencediagram/MessageExo.java | 4 + .../plantuml/sequencediagram/Newpage.java | 7 +- .../plantuml/sequencediagram/Note.java | 7 +- .../plantuml/sequencediagram/Participant.java | 7 +- .../sequencediagram/ParticipantEnglober.java | 18 +-- .../sequencediagram/SequenceDiagram.java | 121 +++++++++++------ .../SequenceDiagramFactory.java | 11 +- .../command/CommandParticipant.java | 5 +- .../command/CommandParticipant2.java | 3 +- .../sequencediagram/graphic/DrawableSet.java | 123 +++++++++++------- .../graphic/DrawableSetInitializer.java | 24 ++-- .../graphic/SequenceDiagramFileMaker.java | 10 +- .../graphic/SequenceDiagramTxtMaker.java | 2 +- .../graphic/Step1Abstract.java | 10 +- .../plantuml/statediagram/StateDiagram.java | 14 +- .../command/CommandLinkUsecase2.java | 2 +- .../sourceforge/plantuml/version/Version.java | 6 +- 46 files changed, 473 insertions(+), 208 deletions(-) diff --git a/pom.xml b/pom.xml index 0666e5c25..cc737cc6d 100644 --- a/pom.xml +++ b/pom.xml @@ -36,7 +36,7 @@ net.sourceforge.plantuml plantuml - 6085-SNAPSHOT + 6121-SNAPSHOT jar PlantUML diff --git a/src/net/sourceforge/plantuml/FileUtils.java b/src/net/sourceforge/plantuml/FileUtils.java index f4549cf9f..263f7c990 100644 --- a/src/net/sourceforge/plantuml/FileUtils.java +++ b/src/net/sourceforge/plantuml/FileUtils.java @@ -33,8 +33,14 @@ */ package net.sourceforge.plantuml; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.util.ArrayList; import java.util.Collection; @@ -79,7 +85,7 @@ public class FileUtils { Log.error("Cannot delete: " + f); } } - + static public File createTempFile(String prefix, String suffix) throws IOException { if (suffix.startsWith(".") == false) { throw new IllegalArgumentException(); @@ -92,6 +98,18 @@ public class FileUtils { return f; } - + static public void copyToFile(File src, File dest) throws IOException { + if (dest.isDirectory()) { + dest = new File(dest, src.getName()); + } + final InputStream fis = new BufferedInputStream(new FileInputStream(src)); + final OutputStream fos = new BufferedOutputStream(new FileOutputStream(dest)); + int lu; + while ((lu = fis.read()) != -1) { + fos.write(lu); + } + fos.close(); + fis.close(); + } } diff --git a/src/net/sourceforge/plantuml/OptionFlags.java b/src/net/sourceforge/plantuml/OptionFlags.java index 00d43a03e..d6a2fafbc 100644 --- a/src/net/sourceforge/plantuml/OptionFlags.java +++ b/src/net/sourceforge/plantuml/OptionFlags.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5977 $ + * Revision $Revision: 6096 $ * */ package net.sourceforge.plantuml; @@ -67,6 +67,7 @@ public class OptionFlags { private String dotExecutable = null; private boolean gui = false; private boolean quiet = false; + private boolean checkDotError = false; private OptionFlags() { reset(); @@ -164,4 +165,12 @@ public class OptionFlags { this.quiet = quiet; } + public final boolean isCheckDotError() { + return checkDotError; + } + + public final void setCheckDotError(boolean checkDotError) { + this.checkDotError = checkDotError; + } + } diff --git a/src/net/sourceforge/plantuml/StringUtils.java b/src/net/sourceforge/plantuml/StringUtils.java index df8df6c33..e55b2bd44 100644 --- a/src/net/sourceforge/plantuml/StringUtils.java +++ b/src/net/sourceforge/plantuml/StringUtils.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 6060 $ + * Revision $Revision: 6110 $ * */ package net.sourceforge.plantuml; @@ -329,7 +329,8 @@ public class StringUtils { public static String uncommentSource(String source) { final StringReader sr = new StringReader(source); - final UncommentReadLine un = new UncommentReadLine(new ReadLineReader(sr)); + final UncommentReadLine un = new UncommentReadLine(new ReadLineReader( + sr)); final StringBuilder sb = new StringBuilder(); String s = null; try { @@ -346,4 +347,18 @@ public class StringUtils { return sb.toString(); } + public static boolean isDiagramCacheable(String uml) { + uml = uml.toLowerCase(); + if (uml.startsWith("@startuml\nversion\n")) { + return false; + } + if (uml.startsWith("@startuml\ntestdot\n")) { + return false; + } + if (uml.startsWith("@startuml\nsudoku\n")) { + return false; + } + return true; + + } } diff --git a/src/net/sourceforge/plantuml/UmlDiagram.java b/src/net/sourceforge/plantuml/UmlDiagram.java index 67928e68c..0f1da7689 100644 --- a/src/net/sourceforge/plantuml/UmlDiagram.java +++ b/src/net/sourceforge/plantuml/UmlDiagram.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5811 $ + * Revision $Revision: 6097 $ * */ package net.sourceforge.plantuml; @@ -40,6 +40,7 @@ import net.sourceforge.plantuml.graphic.HorizontalAlignement; public abstract class UmlDiagram extends AbstractPSystem implements PSystem { private boolean rotation; + private boolean hideUnlinkedData; private int minwidth = Integer.MAX_VALUE; @@ -142,4 +143,12 @@ public abstract class UmlDiagram extends AbstractPSystem implements PSystem { return getSkinParam().getDpi(); } + public final boolean isHideUnlinkedData() { + return hideUnlinkedData; + } + + public final void setHideUnlinkedData(boolean hideUnlinkedData) { + this.hideUnlinkedData = hideUnlinkedData; + } + } diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java index ec3a00567..85fbdef9d 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java @@ -58,12 +58,12 @@ public class CommandIf extends SingleLineCommand2 { static RegexConcat getRegexConcat() { return new RegexConcat(new RegexLeaf("^"), new RegexOr("FIRST", true, - new RegexLeaf("STAR", "(\\(\\*\\))"), + new RegexLeaf("STAR", "(\\(\\*(top)?\\))"), new RegexLeaf("CODE", "([\\p{L}0-9_.]+)"), new RegexLeaf("BAR", "(?:==+)\\s*([\\p{L}0-9_.]+)\\s*(?:==+)"), new RegexLeaf("QUOTED", "\"([^\"]+)\"(?:\\s+as\\s+([\\p{L}0-9_.]+))?")), new RegexLeaf("\\s*"), - new RegexLeaf("ARROW", "([=-]+(?:left|right|up|down|le?|ri?|up?|do?)?[=-]*\\>)?"), + new RegexLeaf("ARROW", "([=-]+(?:(left|right|up|down|le?|ri?|up?|do?)(?=[-=.]))?[=-]*\\>)?"), new RegexLeaf("\\s*"), new RegexLeaf("BRACKET", "(?:\\[([^\\]*]+[^\\]]*)\\])?"), new RegexLeaf("\\s*"), diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java index d91b7f8c5..32e011ae7 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java @@ -58,20 +58,33 @@ public class CommandLinkActivity extends SingleLineCommand2 { } static RegexConcat getRegexConcat() { - return new RegexConcat(new RegexLeaf("^"), new RegexOr("FIRST", true, new RegexLeaf("STAR", "(\\(\\*\\))"), - new RegexLeaf("CODE", "([\\p{L}0-9_.]+)"), new RegexLeaf("BAR", - "(?:==+)\\s*([\\p{L}0-9_.]+)\\s*(?:==+)"), new RegexLeaf("QUOTED", - "\"([^\"]+)\"(?:\\s+as\\s+([\\p{L}0-9_.]+))?")), new RegexLeaf("\\s*"), new RegexLeaf( - "STEREOTYPE", "(\\<\\<.*\\>\\>)?"), new RegexLeaf("\\s*"), new RegexLeaf("BACKCOLOR", "(#\\w+)?"), - new RegexLeaf("\\s*"), - new RegexLeaf("ARROW", "([=-]+(?:left|right|up|down|le?|ri?|up?|do?)?[=-]*\\>)"), - new RegexLeaf("\\s*"), new RegexLeaf("BRACKET", "(?:\\[([^\\]*]+[^\\]]*)\\])?"), new RegexLeaf("\\s*"), - new RegexOr("FIRST2", new RegexLeaf("STAR2", "(\\(\\*\\))"), new RegexLeaf("OPENBRACKET2", "(\\{)"), - new RegexLeaf("CODE2", "([\\p{L}0-9_.]+)"), new RegexLeaf("BAR2", - "(?:==+)\\s*([\\p{L}0-9_.]+)\\s*(?:==+)"), new RegexLeaf("QUOTED2", - "\"([^\"]+)\"(?:\\s+as\\s+([\\p{L}0-9_.]+))?")), new RegexLeaf("\\s*"), new RegexLeaf( - "STEREOTYPE2", "(\\<\\<.*\\>\\>)?"), new RegexLeaf("\\s*"), new RegexLeaf("BACKCOLOR2", - "(#\\w+)?"), new RegexLeaf("$")); + return new RegexConcat( + new RegexLeaf("^"), // + new RegexOr("FIRST", true, // + new RegexLeaf("STAR", "(\\(\\*(top)?\\))"), // + new RegexLeaf("CODE", "([\\p{L}0-9_.]+)"), // + new RegexLeaf("BAR", "(?:==+)\\s*([\\p{L}0-9_.]+)\\s*(?:==+)"), // + new RegexLeaf("QUOTED", "\"([^\"]+)\"(?:\\s+as\\s+([\\p{L}0-9_.]+))?")), // + new RegexLeaf("\\s*"), // + new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), // + new RegexLeaf("\\s*"), // + new RegexLeaf("BACKCOLOR", "(#\\w+)?"), // + new RegexLeaf("\\s*"), // + new RegexLeaf("ARROW", "([=-]+(?:left|right|up|down|le?|ri?|up?|do?)?[=-]*\\>)"), // + new RegexLeaf("\\s*"), // + new RegexLeaf("BRACKET", "(?:\\[([^\\]*]+[^\\]]*)\\])?"), // + new RegexLeaf("\\s*"), // + new RegexOr("FIRST2", // + new RegexLeaf("STAR2", "(\\(\\*(top)?\\))"), // + new RegexLeaf("OPENBRACKET2", "(\\{)"), // + new RegexLeaf("CODE2", "([\\p{L}0-9_.]+)"), // + new RegexLeaf("BAR2", "(?:==+)\\s*([\\p{L}0-9_.]+)\\s*(?:==+)"), // + new RegexLeaf("QUOTED2", "\"([^\"]+)\"(?:\\s+as\\s+([\\p{L}0-9_.]+))?")), + new RegexLeaf("\\s*"), // + new RegexLeaf("STEREOTYPE2", "(\\<\\<.*\\>\\>)?"), // + new RegexLeaf("\\s*"), // + new RegexLeaf("BACKCOLOR2", "(#\\w+)?"), // + new RegexLeaf("$")); } @Override @@ -124,6 +137,9 @@ public class CommandLinkActivity extends SingleLineCommand2 { } if (arg.get("STAR" + suf).get(0) != null) { if (start) { + if (arg.get("STAR" + suf).get(1) != null) { + system.getStart().setTop(true); + } return system.getStart(); } return system.getEnd(); diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java index 4825d3095..f6bd37c58 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java @@ -65,7 +65,7 @@ public class CommandLinkLongActivity extends CommandMultilines2 static RegexConcat getRegexConcat() { return new RegexConcat(new RegexLeaf("^"), new RegexOr("FIRST", true, - new RegexLeaf("STAR", "(\\(\\*\\))"), + new RegexLeaf("STAR", "(\\(\\*(top)?\\))"), new RegexLeaf("CODE", "([\\p{L}0-9_.]+)"), new RegexLeaf("BAR", "(?:==+)\\s*([\\p{L}0-9_.]+)\\s*(?:==+)"), new RegexLeaf("QUOTED", "\"([^\"]+)\"(?:\\s+as\\s+([\\p{L}0-9_.]+))?")), @@ -74,7 +74,7 @@ public class CommandLinkLongActivity extends CommandMultilines2 new RegexLeaf("\\s*"), new RegexLeaf("BACKCOLOR", "(#\\w+)?"), new RegexLeaf("\\s*"), - new RegexLeaf("ARROW", "([=-]+(?:left|right|up|down|le?|ri?|up?|do?)?[=-]*\\>)"), + new RegexLeaf("ARROW", "([=-]+(?:(left|right|up|down|le?|ri?|up?|do?)(?=[-=]))?[=-]*\\>)"), new RegexLeaf("\\s*"), new RegexLeaf("BRACKET", "(?:\\[([^\\]*]+[^\\]]*)\\])?"), new RegexLeaf("\\s*"), diff --git a/src/net/sourceforge/plantuml/classdiagram/AbstractEntityDiagram.java b/src/net/sourceforge/plantuml/classdiagram/AbstractEntityDiagram.java index 7554bc8ae..be8839c4a 100644 --- a/src/net/sourceforge/plantuml/classdiagram/AbstractEntityDiagram.java +++ b/src/net/sourceforge/plantuml/classdiagram/AbstractEntityDiagram.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5350 $ + * Revision $Revision: 6095 $ * */ package net.sourceforge.plantuml.classdiagram; @@ -43,7 +43,7 @@ public abstract class AbstractEntityDiagram extends CucaDiagram { abstract public IEntity getOrCreateClass(String code); - final protected List getDotStrings() { + protected List getDotStrings() { // return Arrays.asList("nodesep=.5;", "ranksep=0.8;", "edge [fontsize=11,labelfontsize=11];", // "node [fontsize=11,height=.35,width=.55];"); return Arrays.asList("nodesep=.35;", "ranksep=0.8;", "edge [fontsize=11,labelfontsize=11];", diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass2.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass2.java index 2d938f2aa..7f63db8f7 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass2.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass2.java @@ -73,13 +73,13 @@ final public class CommandLinkClass2 extends SingleLineCommand2*+]|\\|[>\\]])?)"), + "(([-=.]+)(?:(left|right|up|down|le?|ri?|up?|do?)(?=[-=.]))?([-=.]*)(o +|[\\]>*+]|\\|[>\\]])?)"), new RegexLeaf("RIGHT_TO_LEFT", "(( +o|[\\[<*+]|[<\\[]\\|)?([-=.]*)(left|right|up|down|le?|ri?|up?|do?)?([-=.]+))"), new RegexLeaf("NAV_AGREG_OR_COMPO_INV", "(\\<([-=.]*)(left|right|up|down|le?|ri?|up?|do?[-=.]+)?([-=.]+)(o +|\\*))"), new RegexLeaf("NAV_AGREG_OR_COMPO", - "(( +o|\\*)([-=.]+)(left|right|up|down|le?|ri?|up?|do?)?([-=.]*)\\>)")), + "(( +o|\\*)([-=.]+)(?:(left|right|up|down|le?|ri?|up?|do?)(?=[-=.]))?([-=.]*)\\>)")), new RegexLeaf("\\s*"), new RegexLeaf("SECOND_LABEL", "(?:\"([^\"]+)\")?"), new RegexLeaf("\\s*"), diff --git a/src/net/sourceforge/plantuml/command/AbstractUmlSystemCommandFactory.java b/src/net/sourceforge/plantuml/command/AbstractUmlSystemCommandFactory.java index b2e069784..5deb62d4b 100644 --- a/src/net/sourceforge/plantuml/command/AbstractUmlSystemCommandFactory.java +++ b/src/net/sourceforge/plantuml/command/AbstractUmlSystemCommandFactory.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 6002 $ + * Revision $Revision: 6097 $ * */ package net.sourceforge.plantuml.command; @@ -99,6 +99,8 @@ public abstract class AbstractUmlSystemCommandFactory implements PSystemCommandF addCommand(new CommandScale(system)); addCommand(new CommandScaleWidthAndHeight(system)); addCommand(new CommandScaleWidthOrHeight(system)); + addCommand(new CommandHideUnlinked(system)); + } protected final void addCommand(Command cmd) { diff --git a/src/net/sourceforge/plantuml/componentdiagram/command/CommandLinkComponent2.java b/src/net/sourceforge/plantuml/componentdiagram/command/CommandLinkComponent2.java index f57370fc6..214e3f010 100644 --- a/src/net/sourceforge/plantuml/componentdiagram/command/CommandLinkComponent2.java +++ b/src/net/sourceforge/plantuml/componentdiagram/command/CommandLinkComponent2.java @@ -58,13 +58,20 @@ public class CommandLinkComponent2 extends SingleLineCommand2 } static RegexConcat getRegex() { - return new RegexConcat(new RegexLeaf("^"), getRegexGroup("G1"), new RegexLeaf("\\s*"), new RegexOr( - new RegexLeaf("AR_TO_RIGHT", - "(([-=.]+)(left|right|up|down|le?|ri?|up?|do?)?([-=.]*?\\.*)([\\]>]|\\|[>\\]])?)"), - new RegexLeaf("AR_TO_LEFT", - "(([\\[<]|[<\\[]\\|)?([-=.]*)(left|right|up|down|le?|ri?|up?|do?)?([-=.]+))")), - new RegexLeaf("\\s*"), getRegexGroup("G2"), new RegexLeaf("\\s*"), new RegexLeaf("END", - "(?::\\s*([^\"]+))?$")); + return new RegexConcat(new RegexLeaf("^"), // + getRegexGroup("G1"),// + new RegexLeaf("\\s*"),// + new RegexOr( + // + new RegexLeaf("AR_TO_RIGHT", + "(([-=.]+)(?:(left|right|up|down|le?|ri?|up?|do?)(?=[-=.]))?([-=.]*)([\\]>]|\\|[>\\]])?)"), + // "(([-=.]+)(left|right|up|down|le?|ri?|up?|do?)?([-=.]*?\\.*)([\\]>]|\\|[>\\]])?)"), + new RegexLeaf("AR_TO_LEFT", + "(([\\[<]|[<\\[]\\|)?([-=.]*)(left|right|up|down|le?|ri?|up?|do?)?([-=.]+))")), + new RegexLeaf("\\s*"),// + getRegexGroup("G2"),// + new RegexLeaf("\\s*"),// + new RegexLeaf("END", "(?::\\s*([^\"]+))?$")); } private static RegexLeaf getRegexGroup(String name) { @@ -86,8 +93,7 @@ public class CommandLinkComponent2 extends SingleLineCommand2 final IEntity cl1 = getSystem().getOrCreateClass(g1); final IEntity cl2 = getSystem().getOrCreateClass(g2); - - + if (arg.get("G1").get(1) != null) { cl1.setStereotype(new Stereotype(arg.get("G1").get(1))); } @@ -105,22 +111,21 @@ public class CommandLinkComponent2 extends SingleLineCommand2 linkType = getLinkTypeNormal(queue, arg.get("AR_TO_LEFT").get(1)).getInv(); } final Direction dir = getDirection(arg); - + if (dir == Direction.LEFT || dir == Direction.RIGHT) { queue = "-"; } Link link = new Link(cl1, cl2, linkType, arg.get("END").get(0), queue.length()); - + if (dir == Direction.LEFT || dir == Direction.UP) { link = link.getInv(); } - getSystem().addLink(link); return CommandExecutionResult.ok(); } - + private Direction getDirection(Map arg) { if (arg.get("AR_TO_RIGHT").get(2) != null) { return StringUtils.getQueueDirection(arg.get("AR_TO_RIGHT").get(2)); @@ -131,8 +136,6 @@ public class CommandLinkComponent2 extends SingleLineCommand2 return null; } - - private CommandExecutionResult executePackageLink(Map arg) { final String g1 = arg.get("G1").get(0); final String g2 = arg.get("G2").get(0); diff --git a/src/net/sourceforge/plantuml/cucadiagram/Entity.java b/src/net/sourceforge/plantuml/cucadiagram/Entity.java index 568ee0ed3..536bae4c7 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Entity.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Entity.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5694 $ + * Revision $Revision: 6121 $ * */ package net.sourceforge.plantuml.cucadiagram; @@ -60,10 +60,19 @@ public class Entity implements IEntity { private DrawFile imageFile; private String url; + + private boolean top; + + public final boolean isTop() { + return top; + } + + public final void setTop(boolean top) { + this.top = top; + } public Entity(String code, String display, EntityType type, Group entityPackage) { this("cl" + UniqueSequence.getValue(), code, display, type, entityPackage); - } public Entity(String uid, String code, String display, EntityType type, Group entityPackage) { diff --git a/src/net/sourceforge/plantuml/cucadiagram/EntityUtils.java b/src/net/sourceforge/plantuml/cucadiagram/EntityUtils.java index 5ee1e845a..e2a9b3937 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/EntityUtils.java +++ b/src/net/sourceforge/plantuml/cucadiagram/EntityUtils.java @@ -118,6 +118,14 @@ public abstract class EntityUtils { return ent.getImageFile(searched); } + public boolean isTop() { + return ent.isTop(); + } + + public void setTop(boolean top) { + ent.setTop(top); + } + }; } diff --git a/src/net/sourceforge/plantuml/cucadiagram/IEntity.java b/src/net/sourceforge/plantuml/cucadiagram/IEntity.java index 831ebd9ef..b81384971 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/IEntity.java +++ b/src/net/sourceforge/plantuml/cucadiagram/IEntity.java @@ -63,5 +63,10 @@ public interface IEntity extends Imaged, SpecificBackcolorable { public String getCode(); public DrawFile getImageFile(File searched) throws IOException; + + public boolean isTop(); + + public void setTop(boolean top); + } diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/AbstractGraphviz.java b/src/net/sourceforge/plantuml/cucadiagram/dot/AbstractGraphviz.java index 9da246209..0174c1416 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/AbstractGraphviz.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/AbstractGraphviz.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 6005 $ + * Revision $Revision: 6104 $ * */ package net.sourceforge.plantuml.cucadiagram.dot; @@ -90,10 +90,11 @@ abstract class AbstractGraphviz implements Graphviz { return; } final String cmd = getCommandLine(); + ProcessRunner p = null; try { Log.info("Starting Graphviz process " + cmd); Log.info("DotString size: " + dotString.length()); - final ProcessRunner p = new ProcessRunner(cmd); + p = new ProcessRunner(cmd); p.run(dotString.getBytes(), os); Log.info("Ending process ok"); } catch (Throwable e) { @@ -105,8 +106,20 @@ abstract class AbstractGraphviz implements Graphviz { Log.error(""); } finally { Log.info("Ending Graphviz process"); - } + if (OptionFlags.getInstance().isCheckDotError() && p != null && p.getError().length() > 0) { + Log.error("GraphViz error stream : " + p.getError()); + if (OptionFlags.getInstance().isCheckDotError()) { + throw new IllegalStateException("Dot error " + p.getError()); + } + } + if (OptionFlags.getInstance().isCheckDotError() && p != null && p.getOut().length() > 0) { + Log.error("GraphViz out stream : " + p.getOut()); + if (OptionFlags.getInstance().isCheckDotError()) { + throw new IllegalStateException("Dot out " + p.getOut()); + } + } + } private boolean illegalDotExe() { diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/DotMaker.java b/src/net/sourceforge/plantuml/cucadiagram/dot/DotMaker.java index 9ab2fa30f..709e11fe1 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/DotMaker.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/DotMaker.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 6035 $ + * Revision $Revision: 6121 $ * */ package net.sourceforge.plantuml.cucadiagram.dot; @@ -99,6 +99,8 @@ final public class DotMaker implements GraphvizMaker { private final Set hasAlreadyOneIncommingArrowLenghtOne; + final private Set rankMin = new HashSet(); + public static void goJunit() { isJunit = true; } @@ -123,6 +125,7 @@ final public class DotMaker implements GraphvizMaker { printGroups(sb, null); printEntities(sb, getUnpackagedEntities()); printLinks(sb, data.getLinks()); + printRanking(sb); sb.append("}"); // System.err.println(sb); @@ -132,6 +135,20 @@ final public class DotMaker implements GraphvizMaker { return sb.toString(); } + private void printRanking(StringBuilder sb) { + if (rankMin.size() == 0) { + return; + } + sb.append("{ rank = min;"); + for (String id : rankMin) { + sb.append(id); + sb.append(";"); + } + sb.append("}"); + + } + + private void initPrintWriter(StringBuilder sb) { Log.info("Entities = " + data.getEntities().size()); @@ -891,6 +908,11 @@ final public class DotMaker implements GraphvizMaker { } else { throw new IllegalStateException(type.toString() + " " + data.getUmlDiagramType()); } + + if (entity.isTop()) { + rankMin.add(entity.getUid()); + } + } private ColorParam getEndColorParam() { diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/DrawFile.java b/src/net/sourceforge/plantuml/cucadiagram/dot/DrawFile.java index cea2caa7c..0c9795133 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/DrawFile.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/DrawFile.java @@ -80,9 +80,10 @@ public class DrawFile { private DrawFile(File fPng, String svg, File fEps) { this(new Unlazy(fPng), new Unlazy(svg), new Unlazy(fEps)); - if (svg.contains("\\")) { - throw new IllegalArgumentException(); - } +// if (svg.contains("\\")) { +// System.err.println("svg="+svg); +// throw new IllegalArgumentException(); +// } } public File getPngOrEps(boolean isEps) throws IOException { diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/ProcessRunner.java b/src/net/sourceforge/plantuml/cucadiagram/dot/ProcessRunner.java index 5be6f45ef..d015956f2 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/ProcessRunner.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/ProcessRunner.java @@ -28,11 +28,12 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5650 $ + * Revision $Revision: 6107 $ * */ package net.sourceforge.plantuml.cucadiagram.dot; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -49,11 +50,15 @@ public class ProcessRunner { public ProcessRunner(String cmd) { this.cmd = cmd; } - + static private int cpt = 0; public void run(byte in[], OutputStream redirection) throws IOException, InterruptedException { - final Process process = Runtime.getRuntime().exec(cmd); + run(in, redirection, null); + } + + public void run(byte in[], OutputStream redirection, File dir) throws IOException, InterruptedException { + final Process process = Runtime.getRuntime().exec(cmd, null, dir); final ThreadStream errorStream = new ThreadStream(process.getErrorStream(), null); final ThreadStream outStream = new ThreadStream(process.getInputStream(), redirection); errorStream.start(); @@ -68,7 +73,7 @@ public class ProcessRunner { outStream.join(10000L); this.out = outStream.sb.toString(); this.error = errorStream.sb.toString(); - Log.info("RUN nb = "+(++cpt)); + Log.info("RUN nb = " + (++cpt)); } static class ThreadStream extends Thread { diff --git a/src/net/sourceforge/plantuml/preproc/IfManager.java b/src/net/sourceforge/plantuml/preproc/IfManager.java index e124081e1..0f0d67651 100644 --- a/src/net/sourceforge/plantuml/preproc/IfManager.java +++ b/src/net/sourceforge/plantuml/preproc/IfManager.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5200 $ + * Revision $Revision: 6107 $ * */ package net.sourceforge.plantuml.preproc; @@ -39,9 +39,9 @@ import java.util.regex.Pattern; class IfManager implements ReadLine { - protected static final Pattern ifdefPattern = Pattern.compile("^!if(n)?def\\s+([A-Za-z_][A-Za-z_0-9]*)$"); - protected static final Pattern elsePattern = Pattern.compile("^!else$"); - protected static final Pattern endifPattern = Pattern.compile("^!endif$"); + protected static final Pattern ifdefPattern = Pattern.compile("^\\s*!if(n)?def\\s+([A-Za-z_][A-Za-z_0-9]*)$"); + protected static final Pattern elsePattern = Pattern.compile("^\\s*!else$"); + protected static final Pattern endifPattern = Pattern.compile("^\\s*!endif$"); private final Defines defines; private final ReadLine source; diff --git a/src/net/sourceforge/plantuml/preproc/Preprocessor.java b/src/net/sourceforge/plantuml/preproc/Preprocessor.java index 121359f73..c2a497e21 100644 --- a/src/net/sourceforge/plantuml/preproc/Preprocessor.java +++ b/src/net/sourceforge/plantuml/preproc/Preprocessor.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 6070 $ + * Revision $Revision: 6107 $ * */ package net.sourceforge.plantuml.preproc; @@ -41,8 +41,8 @@ import java.util.regex.Pattern; public class Preprocessor implements ReadLine { - private static final Pattern definePattern = Pattern.compile("^!define\\s+([A-Za-z_][A-Za-z_0-9]*)(?:\\s+(.*))?$"); - private static final Pattern undefPattern = Pattern.compile("^!undef\\s+([A-Za-z_][A-Za-z_0-9]*)$"); + private static final Pattern definePattern = Pattern.compile("^\\s*!define\\s+([A-Za-z_][A-Za-z_0-9]*)(?:\\s+(.*))?$"); + private static final Pattern undefPattern = Pattern.compile("^\\s*!undef\\s+([A-Za-z_][A-Za-z_0-9]*)$"); private final Defines defines; private final PreprocessorInclude rawSource; diff --git a/src/net/sourceforge/plantuml/preproc/PreprocessorInclude.java b/src/net/sourceforge/plantuml/preproc/PreprocessorInclude.java index 8aa3e4bd7..50e56ca75 100644 --- a/src/net/sourceforge/plantuml/preproc/PreprocessorInclude.java +++ b/src/net/sourceforge/plantuml/preproc/PreprocessorInclude.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 6070 $ + * Revision $Revision: 6107 $ * */ package net.sourceforge.plantuml.preproc; @@ -45,7 +45,7 @@ import net.sourceforge.plantuml.FileSystem; class PreprocessorInclude implements ReadLine { - private static final Pattern includePattern = Pattern.compile("^!include\\s+\"?([^\"]+)\"?$"); + private static final Pattern includePattern = Pattern.compile("^\\s*!include\\s+\"?([^\"]+)\"?$"); private final ReadLine reader2; private int numLine = 0; diff --git a/src/net/sourceforge/plantuml/sequencediagram/Delay.java b/src/net/sourceforge/plantuml/sequencediagram/Delay.java index 8afafc2a3..470af5e87 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/Delay.java +++ b/src/net/sourceforge/plantuml/sequencediagram/Delay.java @@ -47,4 +47,8 @@ public class Delay implements Event { return text; } + public boolean dealWith(Participant someone) { + return false; + } + } diff --git a/src/net/sourceforge/plantuml/sequencediagram/Divider.java b/src/net/sourceforge/plantuml/sequencediagram/Divider.java index 6595899d1..bcf35858c 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/Divider.java +++ b/src/net/sourceforge/plantuml/sequencediagram/Divider.java @@ -46,5 +46,10 @@ public class Divider implements Event { public final List getText() { return text; } + + public boolean dealWith(Participant someone) { + return false; + } + } diff --git a/src/net/sourceforge/plantuml/sequencediagram/Event.java b/src/net/sourceforge/plantuml/sequencediagram/Event.java index 1880fce0e..15b55abe1 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/Event.java +++ b/src/net/sourceforge/plantuml/sequencediagram/Event.java @@ -28,11 +28,13 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 3835 $ + * Revision $Revision: 6097 $ * */ package net.sourceforge.plantuml.sequencediagram; public interface Event { + boolean dealWith(Participant someone); + } diff --git a/src/net/sourceforge/plantuml/sequencediagram/GroupingLeaf.java b/src/net/sourceforge/plantuml/sequencediagram/GroupingLeaf.java index 0cd8171d4..50d160357 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/GroupingLeaf.java +++ b/src/net/sourceforge/plantuml/sequencediagram/GroupingLeaf.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 4321 $ + * Revision $Revision: 6097 $ * */ package net.sourceforge.plantuml.sequencediagram; @@ -74,4 +74,9 @@ public class GroupingLeaf extends Grouping { } return backColorGeneral; } + + public boolean dealWith(Participant someone) { + return false; + } + } diff --git a/src/net/sourceforge/plantuml/sequencediagram/GroupingStart.java b/src/net/sourceforge/plantuml/sequencediagram/GroupingStart.java index 049f3ca74..f9978c525 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/GroupingStart.java +++ b/src/net/sourceforge/plantuml/sequencediagram/GroupingStart.java @@ -72,5 +72,10 @@ public class GroupingStart extends Grouping { public HtmlColor getBackColorGeneral() { return backColorGeneral; } + + public boolean dealWith(Participant someone) { + return false; + } + } diff --git a/src/net/sourceforge/plantuml/sequencediagram/LifeEvent.java b/src/net/sourceforge/plantuml/sequencediagram/LifeEvent.java index 987f16a6e..865c24240 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/LifeEvent.java +++ b/src/net/sourceforge/plantuml/sequencediagram/LifeEvent.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 4243 $ + * Revision $Revision: 6097 $ * */ package net.sourceforge.plantuml.sequencediagram; @@ -54,10 +54,13 @@ public class LifeEvent implements Event { public LifeEventType getType() { return type; } - + public HtmlColor getSpecificBackColor() { return backcolor; } + public boolean dealWith(Participant someone) { + return this.p == someone; + } } diff --git a/src/net/sourceforge/plantuml/sequencediagram/Message.java b/src/net/sourceforge/plantuml/sequencediagram/Message.java index 4577895a3..279010c08 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/Message.java +++ b/src/net/sourceforge/plantuml/sequencediagram/Message.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5923 $ + * Revision $Revision: 6097 $ * */ package net.sourceforge.plantuml.sequencediagram; @@ -57,4 +57,8 @@ public class Message extends AbstractMessage { return p2; } + public boolean dealWith(Participant someone) { + return someone == p1 || someone == p2; + } + } diff --git a/src/net/sourceforge/plantuml/sequencediagram/MessageExo.java b/src/net/sourceforge/plantuml/sequencediagram/MessageExo.java index 694c002eb..d8a2a9ae3 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/MessageExo.java +++ b/src/net/sourceforge/plantuml/sequencediagram/MessageExo.java @@ -57,4 +57,8 @@ public class MessageExo extends AbstractMessage { return type; } + public boolean dealWith(Participant someone) { + return participant == someone; + } + } diff --git a/src/net/sourceforge/plantuml/sequencediagram/Newpage.java b/src/net/sourceforge/plantuml/sequencediagram/Newpage.java index 12544faaa..7ff9f1ea4 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/Newpage.java +++ b/src/net/sourceforge/plantuml/sequencediagram/Newpage.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 3835 $ + * Revision $Revision: 6097 $ * */ package net.sourceforge.plantuml.sequencediagram; @@ -46,5 +46,10 @@ public class Newpage implements Event { public final List getTitle() { return title; } + + public boolean dealWith(Participant someone) { + return false; + } + } diff --git a/src/net/sourceforge/plantuml/sequencediagram/Note.java b/src/net/sourceforge/plantuml/sequencediagram/Note.java index 6132a9924..012bae833 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/Note.java +++ b/src/net/sourceforge/plantuml/sequencediagram/Note.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 4237 $ + * Revision $Revision: 6097 $ * */ package net.sourceforge.plantuml.sequencediagram; @@ -78,7 +78,7 @@ public class Note implements Event, SpecificBackcolorable { } private HtmlColor specificBackcolor; - + public HtmlColor getSpecificBackColor() { return specificBackcolor; } @@ -87,4 +87,7 @@ public class Note implements Event, SpecificBackcolorable { this.specificBackcolor = HtmlColor.getColorIfValid(s); } + public boolean dealWith(Participant someone) { + return p == someone || p2 == someone; + } } diff --git a/src/net/sourceforge/plantuml/sequencediagram/Participant.java b/src/net/sourceforge/plantuml/sequencediagram/Participant.java index 5d16106c3..2cbe665b7 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/Participant.java +++ b/src/net/sourceforge/plantuml/sequencediagram/Participant.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 4836 $ + * Revision $Revision: 6099 $ * */ package net.sourceforge.plantuml.sequencediagram; @@ -69,6 +69,11 @@ public class Participant implements SpecificBackcolorable { public String getCode() { return code; } + + @Override + public String toString() { + return getCode(); + } public List getDisplay() { return Collections.unmodifiableList(display); diff --git a/src/net/sourceforge/plantuml/sequencediagram/ParticipantEnglober.java b/src/net/sourceforge/plantuml/sequencediagram/ParticipantEnglober.java index 841f9b124..b1f5efd46 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/ParticipantEnglober.java +++ b/src/net/sourceforge/plantuml/sequencediagram/ParticipantEnglober.java @@ -40,28 +40,13 @@ import net.sourceforge.plantuml.graphic.HtmlColor; public class ParticipantEnglober { final private List title; - final private Participant first; - final private Participant last; final private HtmlColor boxColor; - public ParticipantEnglober(Participant first, Participant last, List title, HtmlColor boxColor) { - if (first == null || last == null) { - throw new IllegalArgumentException(); - } - this.first = first; - this.last = last; + public ParticipantEnglober(List title, HtmlColor boxColor) { this.title = title; this.boxColor = boxColor; } - public final Participant getFirst() { - return first; - } - - public final Participant getLast() { - return last; - } - public final List getTitle() { return title; } @@ -70,4 +55,5 @@ public class ParticipantEnglober { return boxColor; } + } diff --git a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java index 6d13d2292..ed950d0af 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java +++ b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java @@ -38,7 +38,7 @@ import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.Iterator; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -63,7 +63,7 @@ public class SequenceDiagram extends UmlDiagram { private final List events = new ArrayList(); - private final List participantEnglobers = new ArrayList(); + private final Map participantEnglobers2 = new HashMap(); private Skin skin = new ProtectedSkin(new Rose()); @@ -77,6 +77,7 @@ public class SequenceDiagram extends UmlDiagram { if (result == null) { result = new Participant(ParticipantType.PARTICIPANT, code, display); participants.put(code, result); + participantEnglobers2.put(result, participantEnglober); } return result; } @@ -96,6 +97,7 @@ public class SequenceDiagram extends UmlDiagram { } final Participant result = new Participant(type, code, display); participants.put(code, result); + participantEnglobers2.put(result, participantEnglober); return result; } @@ -266,65 +268,98 @@ public class SequenceDiagram extends UmlDiagram { return UmlDiagramType.SEQUENCE; } - private Participant boxStart; - private List boxStartComment; - private HtmlColor boxColor; - private boolean boxPending = false; +// private Participant boxStart; +// private List boxStartComment; +// private HtmlColor boxColor; +// private boolean boxPending = false; + + private ParticipantEnglober participantEnglober; public void boxStart(List comment, HtmlColor color) { - if (boxPending) { + if (participantEnglober != null) { throw new IllegalStateException(); } - this.boxStart = getLastParticipant(); - this.boxStartComment = comment; - this.boxColor = color; - this.boxPending = true; + this.participantEnglober = new ParticipantEnglober(comment, color); } public void endBox() { - if (boxPending == false) { + if (participantEnglober == null) { throw new IllegalStateException(); } - final Participant last = getLastParticipant(); - this.participantEnglobers.add(new ParticipantEnglober(next(boxStart), last, boxStartComment, boxColor)); - this.boxStart = null; - this.boxStartComment = null; - this.boxColor = null; - this.boxPending = false; + this.participantEnglober = null; } public boolean isBoxPending() { - return boxPending; + return participantEnglober != null; } - private Participant next(Participant p) { - if (p == null) { - return participants.values().iterator().next(); - } - for (final Iterator it = participants.values().iterator(); it.hasNext();) { - final Participant current = it.next(); - if (current == p && it.hasNext()) { - return it.next(); - } - } - throw new IllegalArgumentException("p=" + p.getCode()); - } - - private Participant getLastParticipant() { - Participant result = null; - for (Participant p : participants.values()) { - result = p; - } - return result; - } - - public final List getParticipantEnglobers() { - return Collections.unmodifiableList(participantEnglobers); - } +// private Participant next(Participant p) { +// if (p == null) { +// return participants.values().iterator().next(); +// } +// for (final Iterator it = participants.values().iterator(); it.hasNext();) { +// final Participant current = it.next(); +// if (current == p && it.hasNext()) { +// return it.next(); +// } +// } +// throw new IllegalArgumentException("p=" + p.getCode()); +// } +// +// private Participant getLastParticipant() { +// Participant result = null; +// for (Participant p : participants.values()) { +// result = p; +// } +// return result; +// } +// +// public final List getParticipantEnglobers() { +// return Collections.unmodifiableList(participantEnglobers); +// } @Override public int getNbImages() { return getSequenceDiagramPngMaker(new FileFormatOption(FileFormat.PNG)).getNbPages(); } + public void removeHiddenParticipants() { + for (Participant p : new ArrayList(participants.values())) { + if (isAlone(p)) { + remove(p); + } + } + } + + private void remove(Participant p) { + final boolean ok = participants.values().remove(p); + if (ok==false) { + throw new IllegalArgumentException(); + } + participantEnglobers2.remove(p); + } + + private boolean isAlone(Participant p) { + for (Event ev : events) { + if (ev.dealWith(p)) { + return false; + } + } + return true; + } + + public void putParticipantInLast(String code) { + final Participant p = participants.get(code); + if (p == null) { + throw new IllegalArgumentException(code); + } + participants.remove(code); + participants.put(code, p); + participantEnglobers2.put(p, participantEnglober); + } + + public ParticipantEnglober getEnglober(Participant p) { + return participantEnglobers2.get(p); + } + } diff --git a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java index aa1376816..ae5c10349 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java +++ b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5933 $ + * Revision $Revision: 6097 $ * */ package net.sourceforge.plantuml.sequencediagram; @@ -106,5 +106,14 @@ public class SequenceDiagramFactory extends AbstractUmlSystemCommandFactory { public SequenceDiagram getSystem() { return system; } + + + @Override + public String checkFinalError() { + if (system.isHideUnlinkedData()) { + system.removeHiddenParticipants(); + } + return super.checkFinalError(); + } } diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipant.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipant.java index c15eda68c..5dab852c4 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipant.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipant.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5728 $ + * Revision $Revision: 6109 $ * */ package net.sourceforge.plantuml.sequencediagram.command; @@ -55,7 +55,8 @@ public class CommandParticipant extends SingleLineCommand { protected CommandExecutionResult executeArg(List arg) { final String code = arg.get(2); if (getSystem().participants().containsKey(code)) { - return CommandExecutionResult.error("Duplicate participant : "+code); + getSystem().putParticipantInLast(code); + return CommandExecutionResult.ok(); } List strings = null; diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipant2.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipant2.java index 499480a8f..319c3f2c8 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipant2.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipant2.java @@ -55,7 +55,8 @@ public class CommandParticipant2 extends SingleLineCommand { protected CommandExecutionResult executeArg(List arg) { final String code = arg.get(1); if (getSystem().participants().containsKey(code)) { - return CommandExecutionResult.error("Duplicate participant : " + code); + getSystem().putParticipantInLast(code); + return CommandExecutionResult.ok(); } final List strings = StringUtils.getWithNewlines(arg.get(2)); diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSet.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSet.java index e051f197d..dbc0017ef 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSet.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSet.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5829 $ + * Revision $Revision: 6113 $ * */ package net.sourceforge.plantuml.sequencediagram.graphic; @@ -51,6 +51,7 @@ import net.sourceforge.plantuml.sequencediagram.Event; import net.sourceforge.plantuml.sequencediagram.Newpage; import net.sourceforge.plantuml.sequencediagram.Participant; import net.sourceforge.plantuml.sequencediagram.ParticipantEnglober; +import net.sourceforge.plantuml.sequencediagram.ParticipantEngloberContexted; import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.skin.ComponentType; import net.sourceforge.plantuml.skin.Context2D; @@ -63,7 +64,8 @@ class DrawableSet { private final Map participants = new LinkedHashMap(); private final Map events = new HashMap(); - private final List participantEnglobers = new ArrayList(); + private final Map participantEnglobers2 = new LinkedHashMap(); + private final List eventsList = new ArrayList(); private final Skin skin; private final ISkinParam skinParam; @@ -129,19 +131,41 @@ class DrawableSet { public double getHeadAndEngloberHeight(Participant p, StringBounder stringBounder) { final LivingParticipantBox box = participants.get(p); final double height = box.getParticipantBox().getHeadHeight(stringBounder); - final ParticipantEnglober englober = getParticipantEnglober(p); + final ParticipantEngloberContexted englober = getParticipantEnglober(p); if (englober == null) { return height; } - final Component comp = skin.createComponent(ComponentType.ENGLOBER, skinParam, englober.getTitle()); + final Component comp = skin.createComponent(ComponentType.ENGLOBER, skinParam, englober + .getParticipantEnglober().getTitle()); final double heightEnglober = comp.getPreferredHeight(stringBounder); return height + heightEnglober; } + public List getExistingParticipantEnglober2() { + final List result = new ArrayList(); + ParticipantEngloberContexted pending = null; + for (Map.Entry ent : participantEnglobers2.entrySet()) { + final ParticipantEnglober englober = ent.getValue(); + if (englober == null) { + pending = null; + continue; + } + assert englober != null; + if (pending != null && englober == pending.getParticipantEnglober()) { + pending.add(ent.getKey()); + continue; + } + pending = new ParticipantEngloberContexted(englober, ent.getKey()); + result.add(pending); + } + return Collections.unmodifiableList(result); + } + public double getOffsetForEnglobers(StringBounder stringBounder) { double result = 0; - for (ParticipantEnglober englober : participantEnglobers) { - final Component comp = skin.createComponent(ComponentType.ENGLOBER, skinParam, englober.getTitle()); + for (ParticipantEngloberContexted englober : getExistingParticipantEnglober2()) { + final Component comp = skin.createComponent(ComponentType.ENGLOBER, skinParam, englober + .getParticipantEnglober().getTitle()); final double height = comp.getPreferredHeight(stringBounder); if (height > result) { result = height; @@ -154,7 +178,7 @@ class DrawableSet { static private final int MARGIN_FOR_ENGLOBERS1 = 2; public double getTailHeight(StringBounder stringBounder, boolean showTail) { - final double marginForEnglobers = this.participantEnglobers.size() > 0 ? MARGIN_FOR_ENGLOBERS : 0; + final double marginForEnglobers = getExistingParticipantEnglober2().size() > 0 ? MARGIN_FOR_ENGLOBERS : 0; if (showTail == false) { return 1 + marginForEnglobers; @@ -167,7 +191,15 @@ class DrawableSet { return r + marginForEnglobers; } - public void addParticipant(Participant p, LivingParticipantBox box) { + public void addParticipant(Participant p, ParticipantEnglober participantEnglober) { + participants.put(p, null); + participantEnglobers2.put(p, participantEnglober); + } + + public void setLivingParticipantBox(Participant p, LivingParticipantBox box) { + if (participants.containsKey(p) == false) { + throw new IllegalArgumentException(); + } participants.put(p, box); } @@ -283,16 +315,17 @@ class DrawableSet { } private void drawEnglobers(UGraphic ug, double height, Context2D context) { - for (ParticipantEnglober englober : participantEnglobers) { + for (ParticipantEngloberContexted englober : getExistingParticipantEnglober2()) { double x1 = getX1(englober); final double x2 = getX2(ug.getStringBounder(), englober); - final Component comp = getEngloberComponent(englober); + final Component comp = getEngloberComponent(englober.getParticipantEnglober()); final double width = x2 - x1; - final double preferedWidth = getEngloberPreferedWidth(ug.getStringBounder(), englober); + final double preferedWidth = getEngloberPreferedWidth(ug.getStringBounder(), + englober.getParticipantEnglober()); if (preferedWidth > width) { - if (englober.getFirst() == englober.getLast()) { + if (englober.getFirst2() == englober.getLast2()) { x1 -= (preferedWidth - width) / 2; } final Dimension2DDouble dim = new Dimension2DDouble(preferedWidth, height); @@ -313,19 +346,19 @@ class DrawableSet { } private Component getEngloberComponent(ParticipantEnglober englober) { - final ISkinParam s = englober.getBoxColor() == null ? skinParam : new SkinParamBackcolored(skinParam, englober - .getBoxColor()); + final ISkinParam s = englober.getBoxColor() == null ? skinParam : new SkinParamBackcolored(skinParam, + englober.getBoxColor()); return skin.createComponent(ComponentType.ENGLOBER, s, englober.getTitle()); } - private double getX1(ParticipantEnglober englober) { - final Participant first = englober.getFirst(); + private double getX1(ParticipantEngloberContexted englober) { + final Participant first = englober.getFirst2(); final ParticipantBox firstBox = participants.get(first).getParticipantBox(); return firstBox.getStartingX() + 1; } - private double getX2(StringBounder stringBounder, ParticipantEnglober englober) { - final Participant last = englober.getLast(); + private double getX2(StringBounder stringBounder, ParticipantEngloberContexted englober) { + final Participant last = englober.getLast2(); final ParticipantBox lastBox = participants.get(last).getParticipantBox(); return lastBox.getMaxX(stringBounder) - 1; } @@ -337,32 +370,32 @@ class DrawableSet { line.drawU(ug, getSkin(), skinParam); } - public void addParticipantEnglober(ParticipantEnglober englober) { - participantEnglobers.add(englober); - } + // public void addParticipantEnglober(ParticipantEnglober englober) { + // participantEnglobers.add(englober); + // } - private boolean contains(ParticipantEnglober englober, Participant toTest) { - if (toTest == englober.getFirst() || toTest == englober.getLast()) { - return true; - } - boolean inside = false; - for (Participant p : participants.keySet()) { - if (p == englober.getFirst()) { - inside = true; - } - if (p == toTest) { - return inside; - } - if (p == englober.getLast()) { - inside = false; - } - } - throw new IllegalArgumentException(); - } + // private boolean contains(ParticipantEngloberContexted englober, Participant toTest) { + // if (toTest == englober.getFirst2() || toTest == englober.getLast2()) { + // return true; + // } + // boolean inside = false; + // for (Participant p : participants.keySet()) { + // if (p == englober.getFirst2()) { + // inside = true; + // } + // if (p == toTest) { + // return inside; + // } + // if (p == englober.getLast2()) { + // inside = false; + // } + // } + // throw new IllegalArgumentException(); + // } - private ParticipantEnglober getParticipantEnglober(Participant p) { - for (ParticipantEnglober pe : participantEnglobers) { - if (contains(pe, p)) { + private ParticipantEngloberContexted getParticipantEnglober(Participant p) { + for (ParticipantEngloberContexted pe : getExistingParticipantEnglober2()) { + if (pe.contains(p)) { return pe; } } @@ -373,8 +406,8 @@ class DrawableSet { this.topStartingY = topStartingY; } - public final List getParticipantEnglobers() { - return Collections.unmodifiableList(participantEnglobers); - } + // public final List getParticipantEnglobers() { + // return Collections.unmodifiableList(participantEnglobers); + // } } diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java index 8941e0570..f5569daa1 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 6046 $ + * Revision $Revision: 6113 $ * */ package net.sourceforge.plantuml.sequencediagram.graphic; @@ -57,6 +57,7 @@ import net.sourceforge.plantuml.sequencediagram.Newpage; import net.sourceforge.plantuml.sequencediagram.Note; import net.sourceforge.plantuml.sequencediagram.Participant; import net.sourceforge.plantuml.sequencediagram.ParticipantEnglober; +import net.sourceforge.plantuml.sequencediagram.ParticipantEngloberContexted; import net.sourceforge.plantuml.sequencediagram.ParticipantType; import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.skin.ComponentType; @@ -164,10 +165,11 @@ class DrawableSetInitializer { } private void takeParticipantEngloberTitleWidth(StringBounder stringBounder) { - for (ParticipantEnglober pe : drawableSet.getParticipantEnglobers()) { - final double preferredWidth = drawableSet.getEngloberPreferedWidth(stringBounder, pe); - final ParticipantBox first = drawableSet.getLivingParticipantBox(pe.getFirst()).getParticipantBox(); - final ParticipantBox last = drawableSet.getLivingParticipantBox(pe.getLast()).getParticipantBox(); + for (ParticipantEngloberContexted pe : drawableSet.getExistingParticipantEnglober2()) { + final double preferredWidth = drawableSet.getEngloberPreferedWidth(stringBounder, + pe.getParticipantEnglober()); + final ParticipantBox first = drawableSet.getLivingParticipantBox(pe.getFirst2()).getParticipantBox(); + final ParticipantBox last = drawableSet.getLivingParticipantBox(pe.getLast2()).getParticipantBox(); if (first == last) { final Constraint constraint1 = constraintSet.getConstraintBefore(first); final Constraint constraint2 = constraintSet.getConstraintAfter(last); @@ -420,21 +422,21 @@ class DrawableSetInitializer { drawableSet.getSkinParam(), null); final LifeLine lifeLine = new LifeLine(box, comp.getPreferredWidth(stringBounder)); - drawableSet.addParticipant(p, new LivingParticipantBox(box, lifeLine)); + drawableSet.setLivingParticipantBox(p, new LivingParticipantBox(box, lifeLine)); this.freeX = box.getMaxX(stringBounder); } - public void addParticipant(Participant p) { - drawableSet.addParticipant(p, null); + public void addParticipant(Participant p, ParticipantEnglober participantEnglober) { + drawableSet.addParticipant(p, participantEnglober); } public void addEvent(Event event) { drawableSet.addEvent(event, null); } - public void addParticipantEnglober(ParticipantEnglober englober) { - drawableSet.addParticipantEnglober(englober); - } + // public void addParticipantEnglober(ParticipantEnglober englober) { + // drawableSet.addParticipantEnglober(englober); + // } } diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMaker.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMaker.java index 7012fb104..d4bd3f23b 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMaker.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMaker.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5872 $ + * Revision $Revision: 6113 $ * */ package net.sourceforge.plantuml.sequencediagram.graphic; @@ -103,11 +103,11 @@ public class SequenceDiagramFileMaker implements FileMaker { sequenceDiagram.isShowFootbox(), sequenceDiagram.getAutonewpage()); for (Participant p : sequenceDiagram.participants().values()) { - initializer.addParticipant(p); - } - for (ParticipantEnglober englober : sequenceDiagram.getParticipantEnglobers()) { - initializer.addParticipantEnglober(englober); + initializer.addParticipant(p, sequenceDiagram.getEnglober(p)); } +// for (ParticipantEnglober englober : sequenceDiagram.getParticipantEnglobers()) { +// initializer.addParticipantEnglober(englober); +// } for (Event ev : sequenceDiagram.events()) { initializer.addEvent(ev); diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramTxtMaker.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramTxtMaker.java index 4e6770f4a..99dbab785 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramTxtMaker.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramTxtMaker.java @@ -73,7 +73,7 @@ public class SequenceDiagramTxtMaker implements FileMaker { sequenceDiagram.isShowFootbox(), sequenceDiagram.getAutonewpage()); for (Participant p : sequenceDiagram.participants().values()) { - initializer.addParticipant(p); + initializer.addParticipant(p, null); } for (Event ev : sequenceDiagram.events()) { initializer.addEvent(ev); diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Abstract.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Abstract.java index 4e4740e60..68283710c 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Abstract.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Abstract.java @@ -89,7 +89,12 @@ abstract class Step1Abstract { return; } assert n.getType() == LifeEventType.ACTIVATE; - line.addSegmentVariation(LifeSegmentVariation.LARGER, pos, n.getSpecificBackColor()); + + int delta = 0; + if (message.isCreate()) { + delta += 10; + } + line.addSegmentVariation(LifeSegmentVariation.LARGER, pos + delta, n.getSpecificBackColor()); } protected final void afterMessage(StringBounder stringBounder, LifeEvent n, final double pos) { @@ -150,7 +155,8 @@ abstract class Step1Abstract { freeY += v; } - protected final NoteBox createNoteBox(StringBounder stringBounder, Arrow arrow, Component noteComp, NotePosition notePosition) { + protected final NoteBox createNoteBox(StringBounder stringBounder, Arrow arrow, Component noteComp, + NotePosition notePosition) { final LivingParticipantBox p = arrow.getParticipantAt(stringBounder, notePosition); final NoteBox noteBox = new NoteBox(arrow.getStartingY(), noteComp, p, null, notePosition); diff --git a/src/net/sourceforge/plantuml/statediagram/StateDiagram.java b/src/net/sourceforge/plantuml/statediagram/StateDiagram.java index cd1da771b..6ddba18d5 100644 --- a/src/net/sourceforge/plantuml/statediagram/StateDiagram.java +++ b/src/net/sourceforge/plantuml/statediagram/StateDiagram.java @@ -28,11 +28,14 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 6085 $ + * Revision $Revision: 6095 $ * */ package net.sourceforge.plantuml.statediagram; +import java.util.Arrays; +import java.util.List; + import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.UniqueSequence; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; @@ -102,5 +105,14 @@ public class StateDiagram extends AbstractEntityDiagram { public UmlDiagramType getUmlDiagramType() { return UmlDiagramType.STATE; } + +// @Override +// final protected List getDotStrings() { +// return Arrays.asList("nodesep=1.95;", "ranksep=1.8;", "edge [fontsize=11,labelfontsize=11];", +// "node [fontsize=11,height=.35,width=.55];"); +// } + + + } diff --git a/src/net/sourceforge/plantuml/usecasediagram/command/CommandLinkUsecase2.java b/src/net/sourceforge/plantuml/usecasediagram/command/CommandLinkUsecase2.java index d719e085a..1c8a592a2 100644 --- a/src/net/sourceforge/plantuml/usecasediagram/command/CommandLinkUsecase2.java +++ b/src/net/sourceforge/plantuml/usecasediagram/command/CommandLinkUsecase2.java @@ -61,7 +61,7 @@ public class CommandLinkUsecase2 extends SingleLineCommand2 { getGroup("ENT1"), new RegexLeaf("\\s*"), new RegexOr( - new RegexLeaf("LEFT_TO_RIGHT", "(([-=.]+)(left|right|up|down|le?|ri?|up?|do?)?([-=.]*)([\\]>]|\\|[>\\]])?)"), + new RegexLeaf("LEFT_TO_RIGHT", "(([-=.]+)(?:(left|right|up|down|le?|ri?|up?|do?)(?=[-=.]))?([-=.]*)([\\]>]|\\|[>\\]])?)"), new RegexLeaf("RIGHT_TO_LEFT", "(([\\[<]|[<\\[]\\|)?([-=.]*)(left|right|up|down|le?|ri?|up?|do?)?([-=.]+))")), new RegexLeaf("\\s*"), getGroup("ENT2"), diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index 229f8ae8a..bfec2fd87 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 6086 $ + * Revision $Revision: 6122 $ * */ package net.sourceforge.plantuml.version; @@ -36,11 +36,11 @@ package net.sourceforge.plantuml.version; public class Version { public static int version() { - return 6085; + return 6121; } public static long compileTime() { - return 1296252260468L; + return 1297683757562L; } }