1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-12-22 02:49:06 +00:00

Version 6085

This commit is contained in:
Arnaud Roques 2011-01-29 16:09:35 +01:00
parent 5ddc03f92d
commit 27af4f85f3
44 changed files with 900 additions and 201 deletions

37
pom.xml
View File

@ -36,7 +36,7 @@
<groupId>net.sourceforge.plantuml</groupId>
<artifactId>plantuml</artifactId>
<version>1.0.6035-SNAPSHOT</version>
<version>6085-SNAPSHOT</version>
<packaging>jar</packaging>
<name>PlantUML</name>
@ -76,8 +76,9 @@
</licenses>
<scm>
<url>http://plantuml.svn.sourceforge.net/viewvc/plantuml</url>
<connection>https://plantuml.svn.sourceforge.net/svnroot/plantuml</connection>
<connection>scm:svn:https://plantuml.svn.sourceforge.net/svnroot/plantuml/trunk</connection>
<developerConnection>scm:svn:https://plantuml.svn.sourceforge.net/svnroot/plantuml/trunk</developerConnection>
<url>http://plantuml.svn.sourceforge.net/viewvc/plantuml/trunk</url>
</scm>
<issueManagement>
@ -154,34 +155,4 @@
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>release-sign-artifacts</id>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -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<BlockUml> blocks = new ArrayList<BlockUml>();
private final Set<File> usedFiles = new HashSet<File>();
public BlockUmlBuilder(List<String> 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<File> getIncludedFiles() {
return Collections.unmodifiableSet(usedFiles);
}
/*
* private List<String> getStrings(Reader reader) throws IOException {
* final List<String> result = new ArrayList<String>(); Preprocessor

View File

@ -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<File, Long> modifieds = new HashMap<File, Long>();
final private Map<File, FileWatcher> modifieds = new HashMap<File, FileWatcher>();
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<File> files = new HashSet<File>(sourceFileReader.getIncludedFiles());
files.add(f);
for (GeneratedImage g : sourceFileReader.getGeneratedImages()) {
result.add(g);
}
modifieds.put(f, modified);
modifieds.put(f, new FileWatcher(files));
}
}
}

View File

@ -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<File, Long> modified2 = new HashMap<File, Long>();
public FileWatcher(Set<File> files) {
for (File f : files) {
modified2.put(f, f.lastModified());
}
}
public boolean hasChanged() {
for (Map.Entry<File, Long> ent : modified2.entrySet()) {
final long nowModified = ent.getKey().lastModified();
if (ent.getValue().longValue() != nowModified) {
return true;
}
}
return false;
}
}

View File

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

View File

@ -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<File> getIncludedFiles() {
return builder.getIncludedFiles();
}
}

View File

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

View File

@ -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<IEntity> waitings = new ArrayList<IEntity>();
private Collection<IEntity> waitings = new LinkedHashSet<IEntity>();
private ConditionalContext2 currentContext;
private int futureLength = 2;
private String futureLabel = null;
private final Collection<String> pendingLabels = new HashSet<String>();
private final Map<String, IEntity> labels = new HashMap<String, IEntity>();
@ -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<IEntity> getLastEntityConsulted2() {
return this.waitings;
}
// public Collection<IEntity> 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<PendingLink> 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<PendingLink> pendingLinks = new ArrayList<PendingLink>();
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
}
}

View File

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

View File

@ -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<IEntity> pendings = new LinkedHashSet<IEntity>();
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<IEntity> 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<IEntity> pendingsToAdd) {
if (this.hasElse) {
throw new IllegalStateException();
}
this.hasElse = true;
System.err.println("pend=" + pendings);
if (pendings.size() == 0) {
throw new IllegalStateException();
}
final Iterator<IEntity> 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;
}
}

View File

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

View File

@ -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<ActivityDiagram2> {
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<String, RegexPartialMatch> arg) {
// if (getSystem().getLastEntityConsulted() == null) {
// return CommandExecutionResult.error("No if for this endif");
// }
getSystem().bar(arg.get("BAR").get(0));
return CommandExecutionResult.ok();
}
}

View File

@ -50,7 +50,7 @@ public class CommandElse2 extends SingleLineCommand2<ActivityDiagram2> {
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<ActivityDiagram2> {
// if (getSystem().getLastEntityConsulted() == null) {
// return CommandExecutionResult.error("No if for this endif");
// }
getSystem().else2();
getSystem().else2(arg.get("WHEN").get(0));
return CommandExecutionResult.ok();
}

View File

@ -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<ActivityDiagram2> {
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<String, RegexPartialMatch> arg) {
// if (getSystem().getLastEntityConsulted() == null) {
// return CommandExecutionResult.error("No if for this endif");
// }
getSystem().end();
return CommandExecutionResult.ok();
}
}

View File

@ -54,7 +54,7 @@ public class CommandIf2 extends SingleLineCommand2<ActivityDiagram2> {
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<ActivityDiagram2> {
@Override
protected CommandExecutionResult executeArg(Map<String, RegexPartialMatch> arg) {
//
getSystem().startIf(arg.get("TEST").get(0));
getSystem().startIf(arg.get("TEST").get(0), arg.get("WHEN").get(0));
//
// int lenght = 2;
//

View File

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

View File

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

View File

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

View File

@ -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<File> filesUsed) {
this.defines = defines;
this.rawSource = new PreprocessorInclude(reader);
this.rawSource = new PreprocessorInclude(reader, filesUsed);
this.source = new IfManager(rawSource, defines);
}

View File

@ -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<File> filesUsed;
public PreprocessorInclude(ReadLine reader) {
public PreprocessorInclude(ReadLine reader, Set<File> 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();
}

View File

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

View File

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

View File

@ -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<SegmentColored> getSegments() {
final Collection<SegmentColored> result = new ArrayList<SegmentColored>();
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<SegmentColored> cutSegmentIfNeed(SegmentColored seg, Collection<GraphicalDelayText> 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<SegmentColored> 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<SegmentColored> 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);

View File

@ -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<GraphicalDelayText> getDelays() {
return Collections.unmodifiableCollection(delays);
public Collection<Segment> getDelays(final StringBounder stringBounder) {
return new AbstractCollection<Segment>() {
@Override
public Iterator<Segment> iterator() {
return new Iterator<Segment>() {
private final Iterator<GraphicalDelayText> 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();
}
};
}
}

View File

@ -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<GraphicalDelayText> getDelays() {
return null;
public Collection<Segment> getDelays(StringBounder stringBounder) {
return Collections.emptyList();
}

View File

@ -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<GraphicalDelayText> getDelays();
public Collection<Segment> getDelays(StringBounder stringBounder);
}

View File

@ -93,23 +93,32 @@ class Segment {
return new Segment(Math.min(this.pos1, this2.pos1), Math.max(this.pos2, this2.pos2));
}
public Collection<Segment> cutSegmentIfNeed(Collection<Segment> delays) {
final List<Segment> result = new ArrayList<Segment>(delays);
Collections.sort(result, new SortPos1());
result.add(this);
return Collections.unmodifiableCollection(result);
}
private Collection<Segment> cutSegmentIfNeed(Segment other) {
if (this.contains(other) == false) {
throw new IllegalArgumentException();
public Collection<Segment> cutSegmentIfNeed(Collection<Segment> allDelays) {
final List<Segment> sortedDelay = new ArrayList<Segment>(allDelays);
Collections.sort(sortedDelay, new SortPos1());
final List<Segment> result2 = new ArrayList<Segment>();
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<Segment> {
public int compare(Segment segA, Segment segB) {
return (int) Math.signum(segB.pos1 - segA.pos1);
return (int) Math.signum(segA.pos1 - segB.pos1);
}
}

View File

@ -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<SegmentColored> cutSegmentIfNeed(Collection<Segment> 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<SegmentColored> {
private final Iterator<Segment> it;
public Iterator2(Iterator<Segment> 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<SegmentColored> {
private final Collection<Segment> col;
public Coll2(Collection<Segment> col) {
this.col = col;
}
@Override
public Iterator<SegmentColored> iterator() {
return new Iterator2(col.iterator());
}
@Override
public int size() {
return col.size();
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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<SimpleLine> currentDirectoryListing = new ArrayList<SimpleLine>();
@ -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) {

View File

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

View File

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

View File

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

View File

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

View File

@ -75,10 +75,8 @@ public class DriverRectangleSvg implements UDriver<SvgGraphics> {
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;

View File

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