diff --git a/pom.xml b/pom.xml
index df51959cf..0666e5c25 100644
--- a/pom.xml
+++ b/pom.xml
@@ -36,7 +36,7 @@
net.sourceforge.plantuml
plantuml
- 1.0.6035-SNAPSHOT
+ 6085-SNAPSHOT
jar
PlantUML
@@ -76,8 +76,9 @@
- http://plantuml.svn.sourceforge.net/viewvc/plantuml
- https://plantuml.svn.sourceforge.net/svnroot/plantuml
+ scm:svn:https://plantuml.svn.sourceforge.net/svnroot/plantuml/trunk
+ scm:svn:https://plantuml.svn.sourceforge.net/svnroot/plantuml/trunk
+ http://plantuml.svn.sourceforge.net/viewvc/plantuml/trunk
@@ -154,34 +155,4 @@
-
-
-
- release-sign-artifacts
-
-
- performRelease
- true
-
-
-
-
-
- maven-gpg-plugin
- 1.1
-
-
- sign-artifacts
- verify
-
- sign
-
-
-
-
-
-
-
-
-
diff --git a/src/net/sourceforge/plantuml/BlockUmlBuilder.java b/src/net/sourceforge/plantuml/BlockUmlBuilder.java
index b142d5ca8..aeea7aa84 100644
--- a/src/net/sourceforge/plantuml/BlockUmlBuilder.java
+++ b/src/net/sourceforge/plantuml/BlockUmlBuilder.java
@@ -33,11 +33,14 @@
*/
package net.sourceforge.plantuml;
+import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import net.sourceforge.plantuml.preproc.Defines;
import net.sourceforge.plantuml.preproc.Preprocessor;
@@ -47,11 +50,12 @@ import net.sourceforge.plantuml.preproc.UncommentReadLine;
final public class BlockUmlBuilder {
private final List blocks = new ArrayList();
+ private final Set usedFiles = new HashSet();
public BlockUmlBuilder(List config, Defines defines, Reader reader) throws IOException {
Preprocessor includer = null;
try {
- includer = new Preprocessor(new UncommentReadLine(new ReadLineReader(reader)), defines);
+ includer = new Preprocessor(new UncommentReadLine(new ReadLineReader(reader)), defines, usedFiles);
init(includer, config);
} finally {
if (includer != null) {
@@ -98,6 +102,10 @@ final public class BlockUmlBuilder {
return Collections.unmodifiableList(blocks);
}
+ public final Set getIncludedFiles() {
+ return Collections.unmodifiableSet(usedFiles);
+ }
+
/*
* private List getStrings(Reader reader) throws IOException {
* final List result = new ArrayList(); Preprocessor
diff --git a/src/net/sourceforge/plantuml/DirWatcher.java b/src/net/sourceforge/plantuml/DirWatcher.java
index 41dec6669..48d8aca46 100644
--- a/src/net/sourceforge/plantuml/DirWatcher.java
+++ b/src/net/sourceforge/plantuml/DirWatcher.java
@@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
- * Revision $Revision: 5794 $
+ * Revision $Revision: 6070 $
*
*/
package net.sourceforge.plantuml;
@@ -38,8 +38,10 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import net.sourceforge.plantuml.preproc.Defines;
@@ -49,7 +51,7 @@ public class DirWatcher {
final private Option option;
final private String pattern;
- final private Map modifieds = new HashMap();
+ final private Map modifieds = new HashMap();
public DirWatcher(File dir, Option option, String pattern) {
this.dir = dir;
@@ -72,16 +74,17 @@ public class DirWatcher {
if (fileToProcess(f.getName()) == false) {
continue;
}
- final long modified = f.lastModified();
- final Long previousModified = modifieds.get(f);
+ final FileWatcher watcher = modifieds.get(f);
- if (previousModified == null || previousModified.longValue() != modified) {
+ if (watcher == null || watcher.hasChanged()) {
final SourceFileReader sourceFileReader = new SourceFileReader(new Defines(), f, option.getOutputDir(),
option.getConfig(), option.getCharset(), option.getFileFormatOption());
+ final Set files = new HashSet(sourceFileReader.getIncludedFiles());
+ files.add(f);
for (GeneratedImage g : sourceFileReader.getGeneratedImages()) {
result.add(g);
}
- modifieds.put(f, modified);
+ modifieds.put(f, new FileWatcher(files));
}
}
}
diff --git a/src/net/sourceforge/plantuml/FileWatcher.java b/src/net/sourceforge/plantuml/FileWatcher.java
new file mode 100644
index 000000000..010b62015
--- /dev/null
+++ b/src/net/sourceforge/plantuml/FileWatcher.java
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * 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 Lesser 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 5794 $
+ *
+ */
+package net.sourceforge.plantuml;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+public class FileWatcher {
+
+ private final Map modified2 = new HashMap();
+
+ public FileWatcher(Set files) {
+ for (File f : files) {
+ modified2.put(f, f.lastModified());
+ }
+ }
+
+ public boolean hasChanged() {
+ for (Map.Entry ent : modified2.entrySet()) {
+ final long nowModified = ent.getKey().lastModified();
+ if (ent.getValue().longValue() != nowModified) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/PSystemSingleBuilder.java b/src/net/sourceforge/plantuml/PSystemSingleBuilder.java
index 621f12d01..d6694bee4 100644
--- a/src/net/sourceforge/plantuml/PSystemSingleBuilder.java
+++ b/src/net/sourceforge/plantuml/PSystemSingleBuilder.java
@@ -207,7 +207,8 @@ final public class PSystemSingleBuilder {
lines.add(s);
final CommandControl commandControl = systemFactory.isValid(lines);
if (commandControl == CommandControl.NOT_OK) {
- throw new IllegalStateException();
+ // throw new IllegalStateException();
+ return false;
}
if (commandControl == CommandControl.OK) {
final Command cmd = systemFactory.createCommand(lines);
diff --git a/src/net/sourceforge/plantuml/SourceFileReader.java b/src/net/sourceforge/plantuml/SourceFileReader.java
index 17b970e3e..8328e042e 100644
--- a/src/net/sourceforge/plantuml/SourceFileReader.java
+++ b/src/net/sourceforge/plantuml/SourceFileReader.java
@@ -43,6 +43,7 @@ import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Set;
import net.sourceforge.plantuml.code.Transcoder;
import net.sourceforge.plantuml.code.TranscoderUtil;
@@ -148,5 +149,10 @@ public class SourceFileReader {
public final void setFileFormatOption(FileFormatOption fileFormatOption) {
this.fileFormatOption = fileFormatOption;
}
+
+ public final Set getIncludedFiles() {
+ return builder.getIncludedFiles();
+ }
+
}
diff --git a/src/net/sourceforge/plantuml/StringUtils.java b/src/net/sourceforge/plantuml/StringUtils.java
index f0a195162..df8df6c33 100644
--- a/src/net/sourceforge/plantuml/StringUtils.java
+++ b/src/net/sourceforge/plantuml/StringUtils.java
@@ -28,12 +28,14 @@
*
* Original Author: Arnaud Roques
*
- * Revision $Revision: 5957 $
+ * Revision $Revision: 6060 $
*
*/
package net.sourceforge.plantuml;
import java.io.File;
+import java.io.IOException;
+import java.io.StringReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
@@ -41,6 +43,9 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import net.sourceforge.plantuml.preproc.ReadLineReader;
+import net.sourceforge.plantuml.preproc.UncommentReadLine;
+
public class StringUtils {
public static String getPlateformDependentAbsolutePath(File file) {
@@ -322,4 +327,23 @@ public class StringUtils {
}
}
+ public static String uncommentSource(String source) {
+ final StringReader sr = new StringReader(source);
+ final UncommentReadLine un = new UncommentReadLine(new ReadLineReader(sr));
+ final StringBuilder sb = new StringBuilder();
+ String s = null;
+ try {
+ while ((s = un.readLine()) != null) {
+ sb.append(s);
+ sb.append('\n');
+ }
+ } catch (IOException e) {
+ Log.error("Error " + e);
+ throw new IllegalStateException(e.toString());
+ }
+
+ sr.close();
+ return sb.toString();
+ }
+
}
diff --git a/src/net/sourceforge/plantuml/activitydiagram2/ActivityDiagram2.java b/src/net/sourceforge/plantuml/activitydiagram2/ActivityDiagram2.java
index b251d32f3..6fa0d28db 100644
--- a/src/net/sourceforge/plantuml/activitydiagram2/ActivityDiagram2.java
+++ b/src/net/sourceforge/plantuml/activitydiagram2/ActivityDiagram2.java
@@ -39,6 +39,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@@ -55,9 +56,10 @@ import net.sourceforge.plantuml.cucadiagram.LinkType;
public class ActivityDiagram2 extends CucaDiagram {
- private Collection waitings = new ArrayList();
+ private Collection waitings = new LinkedHashSet();
private ConditionalContext2 currentContext;
private int futureLength = 2;
+ private String futureLabel = null;
private final Collection pendingLabels = new HashSet();
private final Map labels = new HashMap();
@@ -85,8 +87,25 @@ public class ActivityDiagram2 extends CucaDiagram {
throw new IllegalStateException();
}
final Entity act = createEntity(getAutoCode(), display, EntityType.ACTIVITY);
+ afterAdd(act);
+
+ }
+
+ public void bar(String bar) {
+ if (waitings.size() == 0) {
+ // throw new IllegalStateException(bar);
+ }
+ label(bar);
+ final Entity act = createEntity(getAutoCode(), bar, EntityType.SYNCHRO_BAR);
+ afterAdd(act);
+ }
+
+ private void afterAdd(final Entity act) {
for (IEntity last : this.waitings) {
- this.addLink(new Link(last, act, new LinkType(LinkDecor.ARROW, LinkDecor.NONE), null, futureLength));
+ System.err.println("last=" + last);
+ System.err.println("act=" + act);
+ this.addLink(new Link(last, act, new LinkType(LinkDecor.ARROW, LinkDecor.NONE), futureLabel, futureLength));
+ futureLabel = null;
}
for (String p : pendingLabels) {
@@ -97,7 +116,6 @@ public class ActivityDiagram2 extends CucaDiagram {
this.waitings.clear();
this.waitings.add(act);
this.futureLength = 2;
-
}
private String getAutoCode() {
@@ -111,37 +129,56 @@ public class ActivityDiagram2 extends CucaDiagram {
this.waitings.add(createEntity("start", "start", EntityType.CIRCLE_START));
}
- public void startIf(String test) {
+ public void startIf(String test, String when) {
final IEntity br = createEntity(getAutoCode(), "", EntityType.BRANCH);
- currentContext = new ConditionalContext2(currentContext, br, Direction.DOWN);
+ currentContext = new ConditionalContext2(currentContext, br, Direction.DOWN, when);
for (IEntity last : this.waitings) {
- this.addLink(new Link(last, br, new LinkType(LinkDecor.ARROW, LinkDecor.NONE), null, futureLength));
+ if (test == null) {
+ // this.addLink(new Link(last, br, new LinkType(LinkDecor.ARROW, LinkDecor.NONE), test, futureLength));
+ throw new IllegalArgumentException();
+ } else {
+ this.addLink(new Link(last, br, new LinkType(LinkDecor.ARROW, LinkDecor.NONE), this.futureLabel,
+ futureLength, null, test, getLabeldistance(), getLabelangle()));
+ }
+ test = null;
}
this.waitings.clear();
this.waitings.add(br);
this.futureLength = 2;
+ this.futureLabel = when;
}
- public Collection getLastEntityConsulted2() {
- return this.waitings;
- }
+ // public Collection getWaitings() {
+ // return this.waitings;
+ // }
public void endif() {
- this.waitings.add(currentContext.getPending());
+ final boolean hasElse = currentContext.isHasElse();
+ System.err.println("CALL endif hasElse " + hasElse);
+ this.waitings.addAll(currentContext.getPendings());
currentContext = currentContext.getParent();
+ if (currentContext == null) {
+ System.err.println("after endif " + currentContext);
+ } else {
+ System.err.println("after endif " + currentContext.getPendings());
+ }
}
- public void else2() {
- this.currentContext.setPending(this.waitings.iterator().next());
+ public void else2(String when) {
+ this.currentContext.executeElse(this.waitings);
this.waitings.clear();
this.waitings.add(currentContext.getBranch());
+ this.futureLabel = when;
}
public void label(String label) {
pendingLabels.add(label);
for (final Iterator it = pendingLinks.iterator(); it.hasNext();) {
final PendingLink pending = it.next();
- if (pending.getLabel().equals(label)) {
+ if (pending.getGotoLabel().equals(label)) {
+ if (pending.getLinkLabel() != null) {
+ this.futureLabel = pending.getLinkLabel();
+ }
waitings.add(pending.getEntityFrom());
it.remove();
}
@@ -150,16 +187,24 @@ public class ActivityDiagram2 extends CucaDiagram {
private final Collection pendingLinks = new ArrayList();
- public void callGoto(String label) {
- final IEntity dest = labels.get(label);
+ public void callGoto(String gotoLabel) {
+ System.err.println("CALL goto " + gotoLabel);
+ final IEntity dest = labels.get(gotoLabel);
for (IEntity last : this.waitings) {
if (dest == null) {
- this.pendingLinks.add(new PendingLink(last, label));
-
+ this.pendingLinks.add(new PendingLink(last, gotoLabel, this.futureLabel));
} else {
- this.addLink(new Link(last, dest, new LinkType(LinkDecor.ARROW, LinkDecor.NONE), null, futureLength));
+ this.addLink(new Link(last, dest, new LinkType(LinkDecor.ARROW, LinkDecor.NONE), this.futureLabel,
+ this.futureLength));
}
}
+ System.err.println("Avant fin goto, waitings=" + waitings);
this.waitings.clear();
+ // currentContext.clearPendingsButFirst();
+ }
+
+ public void end() {
+ // TODO Auto-generated method stub
+
}
}
diff --git a/src/net/sourceforge/plantuml/activitydiagram2/ActivityDiagramFactory2.java b/src/net/sourceforge/plantuml/activitydiagram2/ActivityDiagramFactory2.java
index 97df5c28a..afc628c73 100644
--- a/src/net/sourceforge/plantuml/activitydiagram2/ActivityDiagramFactory2.java
+++ b/src/net/sourceforge/plantuml/activitydiagram2/ActivityDiagramFactory2.java
@@ -33,7 +33,9 @@
*/
package net.sourceforge.plantuml.activitydiagram2;
+import net.sourceforge.plantuml.activitydiagram2.command.CommandBar2;
import net.sourceforge.plantuml.activitydiagram2.command.CommandElse2;
+import net.sourceforge.plantuml.activitydiagram2.command.CommandEnd2;
import net.sourceforge.plantuml.activitydiagram2.command.CommandEndif2;
import net.sourceforge.plantuml.activitydiagram2.command.CommandGoto2;
import net.sourceforge.plantuml.activitydiagram2.command.CommandIf2;
@@ -62,6 +64,8 @@ public class ActivityDiagramFactory2 extends AbstractUmlSystemCommandFactory {
addCommand(new CommandElse2(system));
addCommand(new CommandLabel2(system));
addCommand(new CommandGoto2(system));
+ addCommand(new CommandBar2(system));
+ addCommand(new CommandEnd2(system));
// addCommand(new CommandLinkActivity(system));
// addCommand(new CommandPartition(system));
diff --git a/src/net/sourceforge/plantuml/activitydiagram2/ConditionalContext2.java b/src/net/sourceforge/plantuml/activitydiagram2/ConditionalContext2.java
index 904c6791f..397e1b873 100644
--- a/src/net/sourceforge/plantuml/activitydiagram2/ConditionalContext2.java
+++ b/src/net/sourceforge/plantuml/activitydiagram2/ConditionalContext2.java
@@ -33,25 +33,32 @@
*/
package net.sourceforge.plantuml.activitydiagram2;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+
import net.sourceforge.plantuml.Direction;
import net.sourceforge.plantuml.cucadiagram.EntityType;
import net.sourceforge.plantuml.cucadiagram.IEntity;
public class ConditionalContext2 {
- private IEntity pending;
+ private final Collection pendings = new LinkedHashSet();
private final IEntity branch;
private final Direction direction;
private final ConditionalContext2 parent;
-
- public ConditionalContext2(ConditionalContext2 parent, IEntity branch, Direction direction) {
+ private final String when;
+
+ public ConditionalContext2(ConditionalContext2 parent, IEntity branch, Direction direction, String when) {
if (branch.getType() != EntityType.BRANCH) {
throw new IllegalArgumentException();
}
this.branch = branch;
this.direction = direction;
this.parent = parent;
- this.pending = branch;
+ this.when = when;
+ this.pendings.add(branch);
}
public Direction getDirection() {
@@ -62,16 +69,46 @@ public class ConditionalContext2 {
return parent;
}
- public final IEntity getPending() {
- return pending;
- }
-
- public final void setPending(IEntity pending) {
- this.pending = pending;
+ public final Collection getPendings() {
+ return Collections.unmodifiableCollection(pendings);
}
public final IEntity getBranch() {
return branch;
}
+ public void clearPendingsButFirst() {
+ System.err.println("ConditionalContext2::clearPendingsButFirst");
+ this.pendings.clear();
+ pendings.add(branch);
+ }
+
+ private boolean hasElse = false;
+
+ public void executeElse(Collection pendingsToAdd) {
+ if (this.hasElse) {
+ throw new IllegalStateException();
+ }
+ this.hasElse = true;
+ System.err.println("pend=" + pendings);
+ if (pendings.size() == 0) {
+ throw new IllegalStateException();
+ }
+ final Iterator it = pendings.iterator();
+ final IEntity toRemove = it.next();
+ if (toRemove.getType() != EntityType.BRANCH) {
+ throw new IllegalStateException();
+ }
+ it.remove();
+ this.pendings.addAll(pendingsToAdd);
+ }
+
+ public boolean isHasElse() {
+ return hasElse;
+ }
+
+ public final String getWhen() {
+ return when;
+ }
+
}
diff --git a/src/net/sourceforge/plantuml/activitydiagram2/PendingLink.java b/src/net/sourceforge/plantuml/activitydiagram2/PendingLink.java
index 1ec02098f..4fa8cfe41 100644
--- a/src/net/sourceforge/plantuml/activitydiagram2/PendingLink.java
+++ b/src/net/sourceforge/plantuml/activitydiagram2/PendingLink.java
@@ -38,19 +38,25 @@ import net.sourceforge.plantuml.cucadiagram.IEntity;
public class PendingLink {
private final IEntity entityFrom;
- private final String label;
+ private final String gotoLabel;
+ private final String linkLabel;
- public PendingLink(IEntity entityFrom, String label) {
+ public PendingLink(IEntity entityFrom, String gotoLabel, String linkLabel) {
this.entityFrom = entityFrom;
- this.label = label;
+ this.gotoLabel = gotoLabel;
+ this.linkLabel = linkLabel;
}
public final IEntity getEntityFrom() {
return entityFrom;
}
- public final String getLabel() {
- return label;
+ public final String getGotoLabel() {
+ return gotoLabel;
+ }
+
+ public final String getLinkLabel() {
+ return linkLabel;
}
}
diff --git a/src/net/sourceforge/plantuml/activitydiagram2/command/CommandBar2.java b/src/net/sourceforge/plantuml/activitydiagram2/command/CommandBar2.java
new file mode 100644
index 000000000..504719391
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram2/command/CommandBar2.java
@@ -0,0 +1,69 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * 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 Lesser 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4762 $
+ *
+ */
+package net.sourceforge.plantuml.activitydiagram2.command;
+
+import java.util.Map;
+
+import net.sourceforge.plantuml.activitydiagram2.ActivityDiagram2;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexPartialMatch;
+
+public class CommandBar2 extends SingleLineCommand2 {
+
+ public CommandBar2(ActivityDiagram2 diagram) {
+ super(diagram, getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("==+"), //
+ new RegexLeaf("BAR", "\\s*(.*?)\\s*"), //
+ new RegexLeaf("==+"),//
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(Map arg) {
+ // if (getSystem().getLastEntityConsulted() == null) {
+ // return CommandExecutionResult.error("No if for this endif");
+ // }
+ getSystem().bar(arg.get("BAR").get(0));
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram2/command/CommandElse2.java b/src/net/sourceforge/plantuml/activitydiagram2/command/CommandElse2.java
index c5099522f..1625e484b 100644
--- a/src/net/sourceforge/plantuml/activitydiagram2/command/CommandElse2.java
+++ b/src/net/sourceforge/plantuml/activitydiagram2/command/CommandElse2.java
@@ -50,7 +50,7 @@ public class CommandElse2 extends SingleLineCommand2 {
static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"),
- new RegexLeaf("else"),
+ new RegexLeaf("WHEN", "(?:else\\s*(?:when\\s+(.*))?)?"),
new RegexLeaf("$"));
}
@@ -60,7 +60,7 @@ public class CommandElse2 extends SingleLineCommand2 {
// if (getSystem().getLastEntityConsulted() == null) {
// return CommandExecutionResult.error("No if for this endif");
// }
- getSystem().else2();
+ getSystem().else2(arg.get("WHEN").get(0));
return CommandExecutionResult.ok();
}
diff --git a/src/net/sourceforge/plantuml/activitydiagram2/command/CommandEnd2.java b/src/net/sourceforge/plantuml/activitydiagram2/command/CommandEnd2.java
new file mode 100644
index 000000000..59510be43
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram2/command/CommandEnd2.java
@@ -0,0 +1,68 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * 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 Lesser 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4762 $
+ *
+ */
+package net.sourceforge.plantuml.activitydiagram2.command;
+
+import java.util.Map;
+
+import net.sourceforge.plantuml.activitydiagram2.ActivityDiagram2;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexPartialMatch;
+
+public class CommandEnd2 extends SingleLineCommand2 {
+
+ public CommandEnd2(ActivityDiagram2 diagram) {
+ super(diagram, getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"),
+ new RegexLeaf("end"),
+ new RegexLeaf("$"));
+ }
+
+
+ @Override
+ protected CommandExecutionResult executeArg(Map arg) {
+// if (getSystem().getLastEntityConsulted() == null) {
+// return CommandExecutionResult.error("No if for this endif");
+// }
+ getSystem().end();
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram2/command/CommandIf2.java b/src/net/sourceforge/plantuml/activitydiagram2/command/CommandIf2.java
index a8f01a794..895af0e45 100644
--- a/src/net/sourceforge/plantuml/activitydiagram2/command/CommandIf2.java
+++ b/src/net/sourceforge/plantuml/activitydiagram2/command/CommandIf2.java
@@ -54,7 +54,7 @@ public class CommandIf2 extends SingleLineCommand2 {
new RegexLeaf("\\s*"),
new RegexLeaf("TEST", "[\"(](.+)[\")]"),
new RegexLeaf("\\s*"),
- new RegexLeaf("(then)?"),
+ new RegexLeaf("WHEN", "(?:then\\s*(?:when\\s+(.*))?)?"),
new RegexLeaf("$"));
}
@@ -62,7 +62,7 @@ public class CommandIf2 extends SingleLineCommand2 {
@Override
protected CommandExecutionResult executeArg(Map arg) {
//
- getSystem().startIf(arg.get("TEST").get(0));
+ getSystem().startIf(arg.get("TEST").get(0), arg.get("WHEN").get(0));
//
// int lenght = 2;
//
diff --git a/src/net/sourceforge/plantuml/asciiart/TextSkin.java b/src/net/sourceforge/plantuml/asciiart/TextSkin.java
index 1facd04d4..6c8cbbb06 100644
--- a/src/net/sourceforge/plantuml/asciiart/TextSkin.java
+++ b/src/net/sourceforge/plantuml/asciiart/TextSkin.java
@@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
- * Revision $Revision: 6008 $
+ * Revision $Revision: 6046 $
*
*/
package net.sourceforge.plantuml.asciiart;
@@ -73,7 +73,16 @@ public class TextSkin implements Skin {
if (type == ComponentType.DELAY_LINE) {
return new ComponentTextLine(fileFormat);
}
- if (type == ComponentType.ALIVE_LINE) {
+ if (type == ComponentType.ALIVE_BOX_CLOSE_CLOSE) {
+ return new ComponentTextActiveLine(fileFormat);
+ }
+ if (type == ComponentType.ALIVE_BOX_CLOSE_OPEN) {
+ return new ComponentTextActiveLine(fileFormat);
+ }
+ if (type == ComponentType.ALIVE_BOX_OPEN_CLOSE) {
+ return new ComponentTextActiveLine(fileFormat);
+ }
+ if (type == ComponentType.ALIVE_BOX_OPEN_OPEN) {
return new ComponentTextActiveLine(fileFormat);
}
if (type == ComponentType.NOTE) {
diff --git a/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java b/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java
index b73b27d68..a4fefa3fc 100644
--- a/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java
+++ b/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java
@@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
- * Revision $Revision: 5877 $
+ * Revision $Revision: 6062 $
*
*/
package net.sourceforge.plantuml.cucadiagram;
@@ -332,9 +332,9 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
}
}
- private void createFilesTxt(OutputStream os, int index, FileFormat fileFormat) {
- throw new UnsupportedOperationException();
- // TODO Auto-generated method stub
+ private void createFilesTxt(OutputStream os, int index, FileFormat fileFormat) throws IOException {
+ final CucaDiagramTxtMaker maker = new CucaDiagramTxtMaker(this, fileFormat);
+ maker.createFiles(os, index);
}
public final Rankdir getRankdir() {
diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramTxtMaker.java b/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramTxtMaker.java
index a17b69cc0..1ef3ff628 100644
--- a/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramTxtMaker.java
+++ b/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramTxtMaker.java
@@ -37,6 +37,7 @@ import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D;
import java.io.File;
import java.io.IOException;
+import java.io.OutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collection;
@@ -176,4 +177,8 @@ public final class CucaDiagramTxtMaker {
return result + 2;
}
+ public void createFiles(OutputStream os, int index) {
+ ug.getCharArea().print(new PrintStream(os));
+ }
+
}
diff --git a/src/net/sourceforge/plantuml/preproc/Preprocessor.java b/src/net/sourceforge/plantuml/preproc/Preprocessor.java
index a0b7141e1..121359f73 100644
--- a/src/net/sourceforge/plantuml/preproc/Preprocessor.java
+++ b/src/net/sourceforge/plantuml/preproc/Preprocessor.java
@@ -28,12 +28,14 @@
*
* Original Author: Arnaud Roques
*
- * Revision $Revision: 5200 $
+ * Revision $Revision: 6070 $
*
*/
package net.sourceforge.plantuml.preproc;
+import java.io.File;
import java.io.IOException;
+import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -46,9 +48,9 @@ public class Preprocessor implements ReadLine {
private final PreprocessorInclude rawSource;
private final IfManager source;
- public Preprocessor(ReadLine reader, Defines defines) {
+ public Preprocessor(ReadLine reader, Defines defines, Set filesUsed) {
this.defines = defines;
- this.rawSource = new PreprocessorInclude(reader);
+ this.rawSource = new PreprocessorInclude(reader, filesUsed);
this.source = new IfManager(rawSource, defines);
}
diff --git a/src/net/sourceforge/plantuml/preproc/PreprocessorInclude.java b/src/net/sourceforge/plantuml/preproc/PreprocessorInclude.java
index fdf341aa9..8aa3e4bd7 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: 5207 $
+ * Revision $Revision: 6070 $
*
*/
package net.sourceforge.plantuml.preproc;
@@ -37,6 +37,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
+import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -50,9 +51,12 @@ class PreprocessorInclude implements ReadLine {
private int numLine = 0;
private PreprocessorInclude included = null;
+
+ private final Set filesUsed;
- public PreprocessorInclude(ReadLine reader) {
+ public PreprocessorInclude(ReadLine reader, Set filesUsed) {
this.reader2 = reader;
+ this.filesUsed = filesUsed;
}
public String readLine() throws IOException {
@@ -84,7 +88,8 @@ class PreprocessorInclude implements ReadLine {
final String fileName = m.group(1);
final File f = FileSystem.getInstance().getFile(fileName);
if (f.exists()) {
- included = new PreprocessorInclude(new ReadLineReader(new FileReader(f)));
+ filesUsed.add(f);
+ included = new PreprocessorInclude(new ReadLineReader(new FileReader(f)), filesUsed);
}
return this.readLine();
}
diff --git a/src/net/sourceforge/plantuml/preproc/UncommentReadLine.java b/src/net/sourceforge/plantuml/preproc/UncommentReadLine.java
index 7e5d9accf..9578ecee4 100644
--- a/src/net/sourceforge/plantuml/preproc/UncommentReadLine.java
+++ b/src/net/sourceforge/plantuml/preproc/UncommentReadLine.java
@@ -49,22 +49,6 @@ public class UncommentReadLine implements ReadLine {
}
public String readLine() throws IOException {
- String s = readLine2();
- if (s != null) {
- s = cleanLineFromSource(s);
- }
- return s;
- }
-
- public static String cleanLineFromSource(String s) {
-// s = s.trim();
-// while (s.startsWith(" ") || s.startsWith("\t")) {
-// s = s.substring(1).trim();
-// }
- return s;
- }
-
- private String readLine2() throws IOException {
final String result = raw.readLine();
if (result == null) {
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java
index c52c27747..8941e0570 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: 6016 $
+ * Revision $Revision: 6046 $
*
*/
package net.sourceforge.plantuml.sequencediagram.graphic;
@@ -416,7 +416,7 @@ class DrawableSetInitializer {
throw new IllegalArgumentException();
}
- final Component comp = drawableSet.getSkin().createComponent(ComponentType.ALIVE_LINE,
+ final Component comp = drawableSet.getSkin().createComponent(ComponentType.ALIVE_BOX_CLOSE_CLOSE,
drawableSet.getSkinParam(), null);
final LifeLine lifeLine = new LifeLine(box, comp.getPreferredWidth(stringBounder));
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeLine.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeLine.java
index 61e10ab21..b48430400 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeLine.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeLine.java
@@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
- * Revision $Revision: 6026 $
+ * Revision $Revision: 6054 $
*
*/
package net.sourceforge.plantuml.sequencediagram.graphic;
@@ -36,6 +36,7 @@ package net.sourceforge.plantuml.sequencediagram.graphic;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
import net.sourceforge.plantuml.ISkinParam;
@@ -168,21 +169,6 @@ class LifeLine {
return delta;
}
- Collection getSegments() {
- final Collection result = new ArrayList();
- for (int i = 0; i < events.size(); i++) {
- final SegmentColored seg = getSegment(i);
- if (seg != null) {
- result.addAll(cutSegmentIfNeed(seg, participant.getDelays()));
- }
- }
- return result;
- }
-
- static Collection cutSegmentIfNeed(SegmentColored seg, Collection delays) {
- return Collections.singleton(seg);
- }
-
private SegmentColored getSegment(int i) {
if (events.get(i).type != LifeSegmentVariation.LARGER) {
return null;
@@ -201,6 +187,14 @@ class LifeLine {
return new SegmentColored(events.get(i).y, events.get(events.size() - 1).y, events.get(i).backcolor);
}
+ private Collection getSegmentsCutted(StringBounder stringBounder, int i) {
+ final SegmentColored seg = getSegment(i);
+ if (seg != null) {
+ return seg.cutSegmentIfNeed(participant.getDelays(stringBounder));
+ }
+ return Collections.emptyList();
+ }
+
public void drawU(UGraphic ug, Skin skin, ISkinParam skinParam) {
final StringBounder stringBounder = ug.getStringBounder();
@@ -209,11 +203,20 @@ class LifeLine {
ug.translate(getStartingX(stringBounder), 0);
- for (SegmentColored seg : getSegments()) {
- final ISkinParam skinParam2 = new SkinParamBackcolored(skinParam, seg.getSpecificBackColor());
- final Component comp = skin.createComponent(ComponentType.ALIVE_LINE, skinParam2, null);
- final int currentLevel = getLevel(seg.getSegment().getPos1());
- seg.drawU(ug, comp, currentLevel);
+ for (int i = 0; i < events.size(); i++) {
+ ComponentType type = ComponentType.ALIVE_BOX_CLOSE_OPEN;
+ for (final Iterator it = getSegmentsCutted(stringBounder, i).iterator(); it.hasNext();) {
+ final SegmentColored seg = it.next();
+ final ISkinParam skinParam2 = new SkinParamBackcolored(skinParam, seg.getSpecificBackColor());
+ if (it.hasNext() == false) {
+ type = type == ComponentType.ALIVE_BOX_CLOSE_OPEN ? ComponentType.ALIVE_BOX_CLOSE_CLOSE
+ : ComponentType.ALIVE_BOX_OPEN_CLOSE;
+ }
+ final Component comp = skin.createComponent(type, skinParam2, null);
+ type = ComponentType.ALIVE_BOX_OPEN_OPEN;
+ final int currentLevel = getLevel(seg.getSegment().getPos1());
+ seg.drawU(ug, comp, currentLevel);
+ }
}
ug.setTranslate(atX, atY);
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBox.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBox.java
index 453a0109b..7c1766bd5 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBox.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBox.java
@@ -28,14 +28,15 @@
*
* Original Author: Arnaud Roques
*
- * Revision $Revision: 6016 $
+ * Revision $Revision: 6049 $
*
*/
package net.sourceforge.plantuml.sequencediagram.graphic;
+import java.util.AbstractCollection;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
import net.sourceforge.plantuml.Dimension2DDouble;
@@ -108,10 +109,8 @@ public class ParticipantBox implements Pushable {
final double y1 = topStartingY - head.getPreferredHeight(stringBounder)
- line.getPreferredHeight(stringBounder) / 2;
ug.translate(startingX + outMargin, y1);
- head.drawU(
- ug,
- new Dimension2DDouble(head.getPreferredWidth(stringBounder), head.getPreferredHeight(stringBounder)),
- new SimpleContext2D(false));
+ head.drawU(ug, new Dimension2DDouble(head.getPreferredWidth(stringBounder), head
+ .getPreferredHeight(stringBounder)), new SimpleContext2D(false));
ug.setTranslate(atX, atY);
}
@@ -123,10 +122,8 @@ public class ParticipantBox implements Pushable {
// throw new IllegalStateException();
// }
ug.translate(startingX + outMargin, positionTail);
- tail.drawU(
- ug,
- new Dimension2DDouble(tail.getPreferredWidth(stringBounder), tail.getPreferredHeight(stringBounder)),
- new SimpleContext2D(false));
+ tail.drawU(ug, new Dimension2DDouble(tail.getPreferredWidth(stringBounder), tail
+ .getPreferredHeight(stringBounder)), new SimpleContext2D(false));
ug.setTranslate(atX, atY);
}
}
@@ -134,9 +131,8 @@ public class ParticipantBox implements Pushable {
public void drawParticipantHead(UGraphic ug) {
ug.translate(outMargin, 0);
final StringBounder stringBounder = ug.getStringBounder();
- head.drawU(ug,
- new Dimension2DDouble(head.getPreferredWidth(stringBounder), head.getPreferredHeight(stringBounder)),
- new SimpleContext2D(false));
+ head.drawU(ug, new Dimension2DDouble(head.getPreferredWidth(stringBounder), head
+ .getPreferredHeight(stringBounder)), new SimpleContext2D(false));
ug.translate(-outMargin, 0);
}
@@ -184,8 +180,35 @@ public class ParticipantBox implements Pushable {
this.delays.add(delay);
}
- public Collection getDelays() {
- return Collections.unmodifiableCollection(delays);
+ public Collection getDelays(final StringBounder stringBounder) {
+ return new AbstractCollection() {
+
+ @Override
+ public Iterator iterator() {
+ return new Iterator() {
+
+ private final Iterator it = delays.iterator();
+
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ public Segment next() {
+ final GraphicalDelayText d = it.next();
+ return new Segment(d.getStartingY(), d.getEndingY(stringBounder));
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+ @Override
+ public int size() {
+ return delays.size();
+ }
+ };
}
}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBoxSimple.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBoxSimple.java
index 2ff325c03..a394cb538 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBoxSimple.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBoxSimple.java
@@ -28,12 +28,13 @@
*
* Original Author: Arnaud Roques
*
- * Revision $Revision: 6016 $
+ * Revision $Revision: 6049 $
*
*/
package net.sourceforge.plantuml.sequencediagram.graphic;
import java.util.Collection;
+import java.util.Collections;
import net.sourceforge.plantuml.graphic.StringBounder;
@@ -68,8 +69,8 @@ class ParticipantBoxSimple implements Pushable {
return 0;
}
- public Collection getDelays() {
- return null;
+ public Collection getDelays(StringBounder stringBounder) {
+ return Collections.emptyList();
}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Pushable.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Pushable.java
index b3ff81d01..bf3051962 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/graphic/Pushable.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Pushable.java
@@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
- * Revision $Revision: 6016 $
+ * Revision $Revision: 6049 $
*
*/
package net.sourceforge.plantuml.sequencediagram.graphic;
@@ -45,7 +45,7 @@ interface Pushable {
void pushToLeft(double deltaX);
- public Collection getDelays();
+ public Collection getDelays(StringBounder stringBounder);
}
\ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Segment.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Segment.java
index e959ac11d..4a10c608b 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/graphic/Segment.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Segment.java
@@ -93,23 +93,32 @@ class Segment {
return new Segment(Math.min(this.pos1, this2.pos1), Math.max(this.pos2, this2.pos2));
}
- public Collection cutSegmentIfNeed(Collection delays) {
- final List result = new ArrayList(delays);
- Collections.sort(result, new SortPos1());
- result.add(this);
- return Collections.unmodifiableCollection(result);
- }
-
- private Collection cutSegmentIfNeed(Segment other) {
- if (this.contains(other) == false) {
- throw new IllegalArgumentException();
+ public Collection cutSegmentIfNeed(Collection allDelays) {
+ final List sortedDelay = new ArrayList(allDelays);
+ Collections.sort(sortedDelay, new SortPos1());
+ final List result2 = new ArrayList();
+ double pendingStart = pos1;
+ for (Segment d : sortedDelay) {
+ if (d.pos1 <= pendingStart) {
+ continue;
+ }
+ if (d.pos1 > this.pos2) {
+ result2.add(new Segment(pendingStart, this.pos2));
+ return Collections.unmodifiableCollection(result2);
+ }
+ if (this.contains(d) == false) {
+ throw new IllegalStateException();
+ }
+ result2.add(new Segment(pendingStart, d.pos1));
+ pendingStart = d.pos2;
}
- return Arrays.asList(new Segment(this.pos1, other.pos1), new Segment(this.pos2, other.pos2));
+ result2.add(new Segment(pendingStart, this.pos2));
+ return Collections.unmodifiableCollection(result2);
}
static class SortPos1 implements Comparator {
public int compare(Segment segA, Segment segB) {
- return (int) Math.signum(segB.pos1 - segA.pos1);
+ return (int) Math.signum(segA.pos1 - segB.pos1);
}
}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/SegmentColored.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/SegmentColored.java
index 5a9fba82b..140827d73 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/graphic/SegmentColored.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/SegmentColored.java
@@ -28,12 +28,15 @@
*
* Original Author: Arnaud Roques
*
- * Revision $Revision: 6026 $
+ * Revision $Revision: 6049 $
*
*/
package net.sourceforge.plantuml.sequencediagram.graphic;
import java.awt.geom.Dimension2D;
+import java.util.AbstractCollection;
+import java.util.Collection;
+import java.util.Iterator;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.graphic.HtmlColor;
@@ -88,6 +91,10 @@ class SegmentColored {
ug.setTranslate(atX, atY);
}
+ public Collection cutSegmentIfNeed(Collection allDelays) {
+ return new Coll2(segment.cutSegmentIfNeed(allDelays));
+ }
+
public SegmentColored merge(SegmentColored this2) {
return new SegmentColored(this.segment.merge(this2.segment), backcolor);
}
@@ -96,4 +103,46 @@ class SegmentColored {
return segment;
}
+
+ class Iterator2 implements Iterator {
+
+ private final Iterator it;
+
+ public Iterator2(Iterator it) {
+ this.it = it;
+ }
+
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ public SegmentColored next() {
+ return new SegmentColored(it.next(), backcolor);
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ class Coll2 extends AbstractCollection {
+
+ private final Collection col;
+
+ public Coll2(Collection col) {
+ this.col = col;
+ }
+
+ @Override
+ public Iterator iterator() {
+ return new Iterator2(col.iterator());
+ }
+
+ @Override
+ public int size() {
+ return col.size();
+ }
+
+ }
+
}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramTxtMaker.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramTxtMaker.java
index 292dbd5e0..4e6770f4a 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramTxtMaker.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramTxtMaker.java
@@ -115,7 +115,12 @@ public class SequenceDiagramTxtMaker implements FileMaker {
}
public void createOne(OutputStream os, int index) throws IOException {
- throw new UnsupportedOperationException();
+ final PrintStream ps = new PrintStream(os);
+ if (fileFormat == FileFormat.UTXT) {
+ ug.getCharArea().print(ps);
+ } else {
+ ug.getCharArea().print(ps);
+ }
}
public int getNbPages() {
diff --git a/src/net/sourceforge/plantuml/skin/ComponentType.java b/src/net/sourceforge/plantuml/skin/ComponentType.java
index eeb1eb3a4..02eba46b9 100644
--- a/src/net/sourceforge/plantuml/skin/ComponentType.java
+++ b/src/net/sourceforge/plantuml/skin/ComponentType.java
@@ -49,7 +49,11 @@ public class ComponentType {
static public final ComponentType ACTOR_TAIL = new ComponentType("ACTOR_TAIL");
//
- static public final ComponentType ALIVE_LINE = new ComponentType("ALIVE_LINE");
+ static public final ComponentType ALIVE_BOX_CLOSE_CLOSE = new ComponentType("ALIVE_BOX_CLOSE_CLOSE");
+ static public final ComponentType ALIVE_BOX_CLOSE_OPEN = new ComponentType("ALIVE_BOX_CLOSE_OPEN");
+ static public final ComponentType ALIVE_BOX_OPEN_CLOSE = new ComponentType("ALIVE_BOX_OPEN_CLOSE");
+ static public final ComponentType ALIVE_BOX_OPEN_OPEN = new ComponentType("ALIVE_BOX_OPEN_OPEN");
+
static public final ComponentType DELAY_TEXT = new ComponentType("DELAY_TEXT");
static public final ComponentType DESTROY = new ComponentType("DESTROY");
diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/BlueModern.java b/src/net/sourceforge/plantuml/skin/bluemodern/BlueModern.java
index 723ee6dbd..4a18f73e7 100644
--- a/src/net/sourceforge/plantuml/skin/bluemodern/BlueModern.java
+++ b/src/net/sourceforge/plantuml/skin/bluemodern/BlueModern.java
@@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
- * Revision $Revision: 6008 $
+ * Revision $Revision: 6052 $
*
*/
package net.sourceforge.plantuml.skin.bluemodern;
@@ -94,8 +94,24 @@ public class BlueModern implements Skin {
if (type == ComponentType.NOTE) {
return new ComponentBlueModernNote(Color.WHITE, Color.BLACK, Color.BLACK, normalFont, stringsToDisplay);
}
- if (type == ComponentType.ALIVE_LINE) {
- return new ComponentBlueModernActiveLine(blue1);
+ if (type == ComponentType.ALIVE_BOX_CLOSE_CLOSE) {
+ return new ComponentBlueModernActiveLine(blue1, true, true);
+ }
+ if (type == ComponentType.ALIVE_BOX_CLOSE_OPEN) {
+ return new ComponentBlueModernActiveLine(blue1, true, false);
+ }
+ if (type == ComponentType.ALIVE_BOX_OPEN_CLOSE) {
+ return new ComponentBlueModernActiveLine(blue1, false, true);
+ }
+ if (type == ComponentType.ALIVE_BOX_OPEN_OPEN) {
+ return new ComponentBlueModernActiveLine(blue1, false, false);
+ }
+ if (type == ComponentType.DELAY_LINE) {
+ return new ComponentBlueModernDelayLine(lineColor);
+ }
+ if (type == ComponentType.DELAY_TEXT) {
+ return new ComponentBlueModernDelayText(Color.BLACK, param.getFont(FontParam.SEQUENCE_DELAY, null),
+ stringsToDisplay);
}
if (type == ComponentType.DESTROY) {
return new ComponentRoseDestroy(red);
diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernActiveLine.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernActiveLine.java
index 0a48b6907..0b1ab7411 100644
--- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernActiveLine.java
+++ b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernActiveLine.java
@@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
- * Revision $Revision: 4167 $
+ * Revision $Revision: 6053 $
*
*/
package net.sourceforge.plantuml.skin.bluemodern;
@@ -46,7 +46,7 @@ public class ComponentBlueModernActiveLine extends AbstractComponent {
private final int shadowview = 3;
private final Color foregroundColor;
- public ComponentBlueModernActiveLine(Color foregroundColor) {
+ public ComponentBlueModernActiveLine(Color foregroundColor, boolean closeUp, boolean closeDown) {
this.foregroundColor = foregroundColor;
}
@@ -62,7 +62,7 @@ public class ComponentBlueModernActiveLine extends AbstractComponent {
ug.getParam().setColor(foregroundColor);
ug.getParam().setBackcolor(foregroundColor);
- ug.draw(x, 0, new URectangle(getPreferredWidth(stringBounder), (dimensionToUse.getHeight() - shadowview)));
+ ug.draw(x, 0, new URectangle(getPreferredWidth(stringBounder), dimensionToUse.getHeight() - shadowview));
}
@Override
diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayLine.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayLine.java
new file mode 100644
index 000000000..0f10e5290
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayLine.java
@@ -0,0 +1,75 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * 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 Lesser 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 4169 $
+ *
+ */
+package net.sourceforge.plantuml.skin.bluemodern;
+
+import java.awt.Color;
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.AbstractComponent;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+public class ComponentBlueModernDelayLine extends AbstractComponent {
+
+ private final Color color;
+
+ public ComponentBlueModernDelayLine(Color color) {
+ this.color = color;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Dimension2D dimensionToUse) {
+ ug.getParam().setColor(color);
+ ug.getParam().setBackcolor(color);
+ stroke(ug, 1, 4);
+ final int x = (int) (dimensionToUse.getWidth() / 2);
+ ug.setAntiAliasing(false);
+ ug.draw(x + 1, 0, new ULine(0, dimensionToUse.getHeight()));
+ ug.setAntiAliasing(true);
+ ug.getParam().setStroke(new UStroke());
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return 20;
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return 2;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayText.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayText.java
new file mode 100644
index 000000000..7a990fea9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayText.java
@@ -0,0 +1,77 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * 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 Lesser 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.
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
+ * in the United States and other countries.]
+ *
+ * Original Author: Arnaud Roques
+ *
+ * Revision $Revision: 3837 $
+ *
+ */
+package net.sourceforge.plantuml.skin.bluemodern;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.geom.Dimension2D;
+import java.util.List;
+
+import net.sourceforge.plantuml.graphic.HorizontalAlignement;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.skin.AbstractTextualComponent;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class ComponentBlueModernDelayText extends AbstractTextualComponent {
+
+ public ComponentBlueModernDelayText(Color fontColor, Font font, List extends CharSequence> stringsToDisplay) {
+ super(stringsToDisplay, fontColor, font, HorizontalAlignement.CENTER, 4, 4, 4);
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Dimension2D dimensionToUse) {
+ final TextBlock textBlock = getTextBlock();
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double textWidth = getTextWidth(stringBounder);
+ final double textHeight = getTextHeight(stringBounder);
+
+ final double xpos = (dimensionToUse.getWidth() - textWidth) / 2;
+ final double ypos = (dimensionToUse.getHeight() - textHeight) / 2;
+
+ ug.getParam().setColor(getFontColor());
+ textBlock.drawU(ug, xpos, ypos + getMarginY());
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return getTextHeight(stringBounder) + 20;
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return getTextWidth(stringBounder) + 30;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseActiveLine.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseActiveLine.java
index eec8b1817..249ecf791 100644
--- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseActiveLine.java
+++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseActiveLine.java
@@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
- * Revision $Revision: 4169 $
+ * Revision $Revision: 6046 $
*
*/
package net.sourceforge.plantuml.skin.rose;
@@ -39,26 +39,50 @@ import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.skin.AbstractComponent;
import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.URectangle;
public class ComponentRoseActiveLine extends AbstractComponent {
private final Color foregroundColor;
private final Color lifeLineBackground;
+ private final boolean closeUp;
+ private final boolean closeDown;
- public ComponentRoseActiveLine(Color foregroundColor, Color lifeLineBackground) {
+ public ComponentRoseActiveLine(Color foregroundColor, Color lifeLineBackground, boolean closeUp, boolean closeDown) {
this.foregroundColor = foregroundColor;
this.lifeLineBackground = lifeLineBackground;
+ this.closeUp = closeUp;
+ this.closeDown = closeDown;
}
protected void drawInternalU(UGraphic ug, Dimension2D dimensionToUse) {
- ug.getParam().setBackcolor(lifeLineBackground);
- ug.getParam().setColor(foregroundColor);
final StringBounder stringBounder = ug.getStringBounder();
final int x = (int) (dimensionToUse.getWidth() - getPreferredWidth(stringBounder)) / 2;
final URectangle rect = new URectangle(getPreferredWidth(stringBounder), dimensionToUse.getHeight());
+ if (closeUp && closeDown) {
+ ug.getParam().setBackcolor(lifeLineBackground);
+ ug.getParam().setColor(foregroundColor);
+ ug.draw(x, 0, rect);
+ return;
+ }
+ ug.getParam().setBackcolor(lifeLineBackground);
+ ug.getParam().setColor(lifeLineBackground);
ug.draw(x, 0, rect);
+ ug.getParam().setColor(foregroundColor);
+
+ final ULine vline = new ULine(0, dimensionToUse.getHeight());
+ ug.draw(x, 0, vline);
+ ug.draw(x + getPreferredWidth(stringBounder), 0, vline);
+
+ final ULine hline = new ULine(getPreferredWidth(stringBounder), 0);
+ if (closeUp) {
+ ug.draw(x, 0, hline);
+ }
+ if (closeDown) {
+ ug.draw(x, dimensionToUse.getHeight(), hline);
+ }
}
@Override
diff --git a/src/net/sourceforge/plantuml/skin/rose/Rose.java b/src/net/sourceforge/plantuml/skin/rose/Rose.java
index 9963fec48..c34091198 100644
--- a/src/net/sourceforge/plantuml/skin/rose/Rose.java
+++ b/src/net/sourceforge/plantuml/skin/rose/Rose.java
@@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
- * Revision $Revision: 6008 $
+ * Revision $Revision: 6046 $
*
*/
package net.sourceforge.plantuml.skin.rose;
@@ -216,9 +216,21 @@ public class Rose implements Skin {
return new ComponentRoseGroupingElse(getFontColor(param, FontParam.SEQUENCE_GROUPING), fontGrouping,
stringsToDisplay.get(0));
}
- if (type == ComponentType.ALIVE_LINE) {
+ if (type == ComponentType.ALIVE_BOX_CLOSE_CLOSE) {
final Color borderColor = getHtmlColor(param, ColorParam.sequenceLifeLineBorder).getColor();
- return new ComponentRoseActiveLine(borderColor, lifeLineBackgroundColor);
+ return new ComponentRoseActiveLine(borderColor, lifeLineBackgroundColor, true, true);
+ }
+ if (type == ComponentType.ALIVE_BOX_CLOSE_OPEN) {
+ final Color borderColor = getHtmlColor(param, ColorParam.sequenceLifeLineBorder).getColor();
+ return new ComponentRoseActiveLine(borderColor, lifeLineBackgroundColor, true, false);
+ }
+ if (type == ComponentType.ALIVE_BOX_OPEN_CLOSE) {
+ final Color borderColor = getHtmlColor(param, ColorParam.sequenceLifeLineBorder).getColor();
+ return new ComponentRoseActiveLine(borderColor, lifeLineBackgroundColor, false, true);
+ }
+ if (type == ComponentType.ALIVE_BOX_OPEN_OPEN) {
+ final Color borderColor = getHtmlColor(param, ColorParam.sequenceLifeLineBorder).getColor();
+ return new ComponentRoseActiveLine(borderColor, lifeLineBackgroundColor, false, false);
}
if (type == ComponentType.DELAY_LINE) {
final Color borderColor = getHtmlColor(param, ColorParam.sequenceLifeLineBorder).getColor();
diff --git a/src/net/sourceforge/plantuml/statediagram/StateDiagram.java b/src/net/sourceforge/plantuml/statediagram/StateDiagram.java
index a16feb1f3..cd1da771b 100644
--- a/src/net/sourceforge/plantuml/statediagram/StateDiagram.java
+++ b/src/net/sourceforge/plantuml/statediagram/StateDiagram.java
@@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
- * Revision $Revision: 5190 $
+ * Revision $Revision: 6085 $
*
*/
package net.sourceforge.plantuml.statediagram;
@@ -91,6 +91,10 @@ public class StateDiagram extends AbstractEntityDiagram {
@Override
public void endGroup() {
+ final Group cur = getCurrentGroup();
+ if (cur != null && cur.getType() == GroupType.CONCURRENT_STATE) {
+ super.endGroup();
+ }
super.endGroup();
}
diff --git a/src/net/sourceforge/plantuml/swing/MainWindow.java b/src/net/sourceforge/plantuml/swing/MainWindow.java
index 6f74393f7..941fb6968 100644
--- a/src/net/sourceforge/plantuml/swing/MainWindow.java
+++ b/src/net/sourceforge/plantuml/swing/MainWindow.java
@@ -28,13 +28,14 @@
*
* Original Author: Arnaud Roques
*
- * Revision $Revision: 5885 $
+ * Revision $Revision: 6075 $
*
*/
package net.sourceforge.plantuml.swing;
import java.awt.BorderLayout;
import java.awt.Frame;
+import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
@@ -83,6 +84,7 @@ public class MainWindow extends JFrame {
private final JList jList1 = new JList();
private final JScrollPane scrollPane;
private final JButton changeDirButton = new JButton("Change Directory");
+ // private final JButton refreshButton = new JButton("Refresh");
private final JTextField extensions = new JTextField();
final private List currentDirectoryListing = new ArrayList();
@@ -128,6 +130,11 @@ public class MainWindow extends JFrame {
prefs.put(KEY_PATTERN, ext);
changeDir(dirWatcher.getDir());
}
+
+ private void refreshReloadDir() {
+ changeDir(dirWatcher.getDir());
+ }
+
private String getRegexpPattern(String ext) {
final Pattern p = Pattern.compile("\\w+");
@@ -166,6 +173,10 @@ public class MainWindow extends JFrame {
south.add(labelFileExtensions, BorderLayout.WEST);
south.add(extensions, BorderLayout.CENTER);
+// final JPanel southSouth = new JPanel(new GridLayout(1, 2));
+// southSouth.add(changeDirButton);
+// southSouth.add(refreshButton);
+// south.add(southSouth, BorderLayout.SOUTH);
south.add(changeDirButton, BorderLayout.SOUTH);
getContentPane().add(south, BorderLayout.SOUTH);
@@ -190,6 +201,11 @@ public class MainWindow extends JFrame {
displayDialogChangeDir();
}
});
+// refreshButton.addActionListener(new ActionListener() {
+// public void actionPerformed(ActionEvent e) {
+// refreshReloadDir();
+// }
+// });
extensions.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
diff --git a/src/net/sourceforge/plantuml/ugraphic/UClip.java b/src/net/sourceforge/plantuml/ugraphic/UClip.java
index 75f3771f6..ee9e7a083 100644
--- a/src/net/sourceforge/plantuml/ugraphic/UClip.java
+++ b/src/net/sourceforge/plantuml/ugraphic/UClip.java
@@ -31,6 +31,7 @@
*/
package net.sourceforge.plantuml.ugraphic;
+import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
public class UClip {
@@ -74,21 +75,71 @@ public class UClip {
public boolean isInside(double xp, double yp) {
if (xp < x) {
+ assert getClippedX(xp) != xp;
return false;
}
if (xp > x + width) {
+ assert getClippedX(xp) != xp;
return false;
}
if (yp < y) {
+ assert getClippedY(yp) != yp;
return false;
}
if (yp > y + height) {
+ assert getClippedY(yp) != yp;
return false;
}
+ assert getClippedX(xp) == xp;
+ assert getClippedY(yp) == yp;
return true;
}
public Rectangle2D.Double getClippedRectangle(Rectangle2D.Double r) {
return (Rectangle2D.Double) r.createIntersection(new Rectangle2D.Double(x, y, width, height));
}
+
+ public Line2D.Double getClippedLine(Line2D.Double line) {
+ if (isInside(line.x1, line.y1) && isInside(line.x2, line.y2)) {
+ return line;
+ }
+ if (isInside(line.x1, line.y1) == false && isInside(line.x2, line.y2) == false) {
+ return null;
+ }
+ if (line.x1 != line.x2 && line.y1 != line.y2) {
+ return null;
+ }
+ assert line.x1 == line.x2 || line.y1 == line.y2;
+ if (line.y1 == line.y2) {
+ final double newx1 = getClippedX(line.x1);
+ final double newx2 = getClippedX(line.x2);
+ return new Line2D.Double(newx1, line.y1, newx2, line.y2);
+ }
+ if (line.x1 == line.x2) {
+ final double newy1 = getClippedY(line.y1);
+ final double newy2 = getClippedY(line.y2);
+ return new Line2D.Double(line.x1, newy1, line.x2, newy2);
+ }
+ throw new IllegalStateException();
+ }
+
+ private double getClippedX(double xp) {
+ if (xp < x) {
+ return x;
+ }
+ if (xp > x + width) {
+ return x + width;
+ }
+ return xp;
+ }
+
+ private double getClippedY(double yp) {
+ if (yp < y) {
+ return y;
+ }
+ if (yp > y + height) {
+ return y + height;
+ }
+ return yp;
+ }
}
diff --git a/src/net/sourceforge/plantuml/ugraphic/eps/DriverLineEps.java b/src/net/sourceforge/plantuml/ugraphic/eps/DriverLineEps.java
index f30bd92f1..3dd70e78e 100644
--- a/src/net/sourceforge/plantuml/ugraphic/eps/DriverLineEps.java
+++ b/src/net/sourceforge/plantuml/ugraphic/eps/DriverLineEps.java
@@ -31,6 +31,8 @@
*/
package net.sourceforge.plantuml.ugraphic.eps;
+import java.awt.geom.Line2D;
+
import net.sourceforge.plantuml.eps.EpsGraphics;
import net.sourceforge.plantuml.ugraphic.ClipContainer;
import net.sourceforge.plantuml.ugraphic.UClip;
@@ -50,20 +52,23 @@ public class DriverLineEps implements UDriver {
public void draw(UShape ushape, double x, double y, UParam param, EpsGraphics eps) {
final ULine shape = (ULine) ushape;
+ double x2 = x + shape.getDX();
+ double y2 = y + shape.getDY();
+
final UClip clip = clipContainer.getClip();
-
if (clip != null) {
- if (clip.isInside(x, y) == false) {
- return;
- }
- if (clip.isInside(x + shape.getDX(), y + shape.getDY()) == false) {
+ final Line2D.Double line = clip.getClippedLine(new Line2D.Double(x, y, x2, y2));
+ if (line == null) {
return;
}
+ x = line.x1;
+ y = line.y1;
+ x2 = line.x2;
+ y2 = line.y2;
}
- //final String color = param.getColor() == null ? "none" : HtmlColor.getAsHtml(param.getColor());
eps.setStrokeColor(param.getColor());
eps.setStrokeWidth("" + param.getStroke().getThickness(), param.getStroke().getDasharrayEps());
- eps.epsLine(x, y, x + shape.getDX(), y + shape.getDY());
+ eps.epsLine(x, y, x2, y2);
}
}
diff --git a/src/net/sourceforge/plantuml/ugraphic/eps/DriverRectangleEps.java b/src/net/sourceforge/plantuml/ugraphic/eps/DriverRectangleEps.java
index 20290a188..923bfa856 100644
--- a/src/net/sourceforge/plantuml/ugraphic/eps/DriverRectangleEps.java
+++ b/src/net/sourceforge/plantuml/ugraphic/eps/DriverRectangleEps.java
@@ -31,8 +31,11 @@
*/
package net.sourceforge.plantuml.ugraphic.eps;
+import java.awt.geom.Rectangle2D;
+
import net.sourceforge.plantuml.eps.EpsGraphics;
import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.UClip;
import net.sourceforge.plantuml.ugraphic.UDriver;
import net.sourceforge.plantuml.ugraphic.UGradient;
import net.sourceforge.plantuml.ugraphic.UParam;
@@ -50,10 +53,20 @@ public class DriverRectangleEps implements UDriver {
public void draw(UShape ushape, double x, double y, UParam param, EpsGraphics eps) {
final URectangle rect = (URectangle) ushape;
+ double width = rect.getWidth();
+ double height = rect.getHeight();
+
+ final UClip clip = clipContainer.getClip();
+ if (clip != null) {
+ final Rectangle2D.Double r = clip.getClippedRectangle(new Rectangle2D.Double(x, y, width, height));
+ x = r.x;
+ y = r.y;
+ width = r.width;
+ height = r.height;
+ }
+
final double rx = rect.getRx();
final double ry = rect.getRy();
- final double width = rect.getWidth();
- final double height = rect.getHeight();
final UGradient gr = param.getGradient();
if (gr == null) {
diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverLineSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverLineSvg.java
index b5ff8a141..2fb0c7d7f 100644
--- a/src/net/sourceforge/plantuml/ugraphic/svg/DriverLineSvg.java
+++ b/src/net/sourceforge/plantuml/ugraphic/svg/DriverLineSvg.java
@@ -31,6 +31,8 @@
*/
package net.sourceforge.plantuml.ugraphic.svg;
+import java.awt.geom.Line2D;
+
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.svg.SvgGraphics;
import net.sourceforge.plantuml.ugraphic.ClipContainer;
@@ -51,15 +53,19 @@ public class DriverLineSvg implements UDriver {
public void draw(UShape ushape, double x, double y, UParam param, SvgGraphics svg) {
final ULine shape = (ULine) ushape;
- final UClip clip = clipContainer.getClip();
+ double x2 = x + shape.getDX();
+ double y2 = y + shape.getDY();
+ final UClip clip = clipContainer.getClip();
if (clip != null) {
- if (clip.isInside(x, y) == false) {
- return;
- }
- if (clip.isInside(x + shape.getDX(), y + shape.getDY()) == false) {
+ final Line2D.Double line = clip.getClippedLine(new Line2D.Double(x, y, x2, y2));
+ if (line == null) {
return;
}
+ x = line.x1;
+ y = line.y1;
+ x2 = line.x2;
+ y2 = line.y2;
}
// svg.setStroke(new BasicStroke((float)
@@ -67,6 +73,6 @@ public class DriverLineSvg implements UDriver {
final String color = param.getColor() == null ? "none" : HtmlColor.getAsHtml(param.getColor());
svg.setStrokeColor(color);
svg.setStrokeWidth("" + param.getStroke().getThickness(), param.getStroke().getDasharraySvg());
- svg.svgLine(x, y, x + shape.getDX(), y + shape.getDY());
+ svg.svgLine(x, y, x2, y2);
}
}
diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverRectangleSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverRectangleSvg.java
index c469afc2e..2b936cf72 100644
--- a/src/net/sourceforge/plantuml/ugraphic/svg/DriverRectangleSvg.java
+++ b/src/net/sourceforge/plantuml/ugraphic/svg/DriverRectangleSvg.java
@@ -75,10 +75,8 @@ public class DriverRectangleSvg implements UDriver {
svg.setStrokeWidth("" + param.getStroke().getThickness(), param.getStroke().getDasharraySvg());
final UClip clip = clipContainer.getClip();
-
if (clip != null) {
- Rectangle2D.Double r = new Rectangle2D.Double(x, y, width, height);
- r = clip.getClippedRectangle(r);
+ final Rectangle2D.Double r = clip.getClippedRectangle(new Rectangle2D.Double(x, y, width, height));
x = r.x;
y = r.y;
width = r.width;
diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java
index f9277db7f..229f8ae8a 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: 6036 $
+ * Revision $Revision: 6086 $
*
*/
package net.sourceforge.plantuml.version;
@@ -36,11 +36,11 @@ package net.sourceforge.plantuml.version;
public class Version {
public static int version() {
- return 6035;
+ return 6085;
}
public static long compileTime() {
- return 1295780772390L;
+ return 1296252260468L;
}
}