1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-24 13:57:33 +00:00

Version 6141

This commit is contained in:
Arnaud Roques 2011-02-23 22:14:39 +01:00
parent 2ce0511e80
commit 573aac6a1c
22 changed files with 601 additions and 176 deletions

View File

@ -36,7 +36,7 @@
<groupId>net.sourceforge.plantuml</groupId>
<artifactId>plantuml</artifactId>
<version>6121-SNAPSHOT</version>
<version>6141-SNAPSHOT</version>
<packaging>jar</packaging>
<name>PlantUML</name>

View File

@ -28,13 +28,13 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 5877 $
* Revision $Revision: 6130 $
*
*/
package net.sourceforge.plantuml;
public enum FileFormat {
PNG, SVG, EPS, EPS_VIA_SVG, ATXT, UTXT, XMI_STANDARD, XMI_STAR, XMI_ARGO;
PNG, SVG, EPS, EPS_VIA_SVG, ATXT, UTXT, DOT, XMI_STANDARD, XMI_STAR, XMI_ARGO;
public String getFileSuffix() {
if (this == EPS_VIA_SVG) {

View File

@ -64,5 +64,7 @@ public interface ISkinParam {
public boolean isMonochrome();
public int getDpi();
public boolean useOctagonForActivity();
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 5877 $
* Revision $Revision: 6130 $
*
*/
package net.sourceforge.plantuml;
@ -90,6 +90,9 @@ public class Option {
setFileFormat(FileFormat.XMI_STAR);
} else if (s.equalsIgnoreCase("-teps") || s.equalsIgnoreCase("-eps")) {
setFileFormat(FileFormat.EPS);
} else if (s.equalsIgnoreCase("-tdot") || s.equalsIgnoreCase("-dot")) {
setFileFormat(FileFormat.DOT);
OptionFlags.getInstance().setKeepTmpFiles(true);
} else if (s.equalsIgnoreCase("-ttxt") || s.equalsIgnoreCase("-txt")) {
setFileFormat(FileFormat.ATXT);
} else if (s.equalsIgnoreCase("-tutxt") || s.equalsIgnoreCase("-utxt")) {

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 5983 $
* Revision $Revision: 6141 $
*
*/
package net.sourceforge.plantuml;
@ -263,4 +263,13 @@ public class SkinParam implements ISkinParam {
return 96;
}
public boolean useOctagonForActivity() {
// activityShape roundedbox
final String value = getValue("activityshape");
if ("roundedbox".equalsIgnoreCase(value)) {
return false;
}
return true;
}
}

View File

@ -111,4 +111,8 @@ public class SkinParamBackcolored implements ISkinParam {
public int getDpi() {
return skinParam.getDpi();
}
public boolean useOctagonForActivity() {
return skinParam.useOctagonForActivity();
}
}

View File

@ -117,6 +117,14 @@ public class ActivityDiagram2 extends CucaDiagram {
this.waitings.add(act);
this.futureLength = 2;
}
public IEntity getLastEntityConsulted() {
if (waitings.size()==1) {
return waitings.iterator().next();
}
return null;
}
private String getAutoCode() {
return "ac" + UniqueSequence.getValue();
@ -207,4 +215,5 @@ public class ActivityDiagram2 extends CucaDiagram {
// TODO Auto-generated method stub
}
}

View File

@ -40,6 +40,7 @@ import net.sourceforge.plantuml.activitydiagram2.command.CommandEndif2;
import net.sourceforge.plantuml.activitydiagram2.command.CommandGoto2;
import net.sourceforge.plantuml.activitydiagram2.command.CommandIf2;
import net.sourceforge.plantuml.activitydiagram2.command.CommandLabel2;
import net.sourceforge.plantuml.activitydiagram2.command.CommandMultilinesNoteActivity2;
import net.sourceforge.plantuml.activitydiagram2.command.CommandNewActivity2;
import net.sourceforge.plantuml.activitydiagram2.command.CommandStart2;
import net.sourceforge.plantuml.command.AbstractUmlSystemCommandFactory;
@ -73,7 +74,7 @@ public class ActivityDiagramFactory2 extends AbstractUmlSystemCommandFactory {
// addCommand(new CommandLinkLongActivity(system));
//
// addCommand(new CommandNoteActivity(system));
// addCommand(new CommandMultilinesNoteActivity(system));
addCommand(new CommandMultilinesNoteActivity2(system));
//
// addCommand(new CommandNoteOnActivityLink(system));
// addCommand(new CommandMultilinesNoteActivityLink(system));

View File

@ -0,0 +1,94 @@
/* ========================================================================
* 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: 5751 $
*
*/
package net.sourceforge.plantuml.activitydiagram2.command;
import java.util.List;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.UniqueSequence;
import net.sourceforge.plantuml.activitydiagram2.ActivityDiagram2;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.CommandMultilines;
import net.sourceforge.plantuml.command.Position;
import net.sourceforge.plantuml.cucadiagram.Entity;
import net.sourceforge.plantuml.cucadiagram.EntityType;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType;
public class CommandMultilinesNoteActivity2 extends CommandMultilines<ActivityDiagram2> {
public CommandMultilinesNoteActivity2(final ActivityDiagram2 system) {
super(system, "(?i)^note\\s+(right|left|top|bottom)$", "(?i)^end ?note$");
}
public final CommandExecutionResult execute(List<String> lines) {
final List<String> line0 = StringUtils.getSplit(getStartingPattern(), lines.get(0).trim());
final String pos = line0.get(0);
IEntity activity = getSystem().getLastEntityConsulted();
if (activity == null) {
// activity = getSystem().getStart();
return CommandExecutionResult.error("No activity defined");
}
final List<String> strings = StringUtils.removeEmptyColumns(lines.subList(1, lines.size() - 1));
final String s = StringUtils.getMergedLines(strings);
final Entity note = getSystem().createEntity("GMN" + UniqueSequence.getValue(), s, EntityType.NOTE);
final Link link;
final Position position = Position.valueOf(pos.toUpperCase()).withRankdir(getSystem().getRankdir());
final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).getDashed();
if (position == Position.RIGHT) {
link = new Link(activity, note, type, null, 1);
} else if (position == Position.LEFT) {
link = new Link(note, activity, type, null, 1);
} else if (position == Position.BOTTOM) {
link = new Link(activity, note, type, null, 2);
} else if (position == Position.TOP) {
link = new Link(note, activity, type, null, 2);
} else {
throw new IllegalArgumentException();
}
getSystem().addLink(link);
return CommandExecutionResult.ok();
}
}

View File

@ -0,0 +1,52 @@
/* ========================================================================
* 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.command;
import java.util.List;
import net.sourceforge.plantuml.UmlDiagram;
public class CommandHideUnlinked extends SingleLineCommand<UmlDiagram> {
public CommandHideUnlinked(UmlDiagram diagram) {
super(diagram, "(?i)^(hide|show)\\s+unlinked$");
}
@Override
protected CommandExecutionResult executeArg(List<String> arg) {
getSystem().setHideUnlinkedData(arg.get(0).equalsIgnoreCase("hide"));
return CommandExecutionResult.ok();
}
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 5872 $
* Revision $Revision: 6130 $
*
*/
package net.sourceforge.plantuml.cucadiagram.dot;
@ -190,6 +190,8 @@ public final class CucaDiagramFileMaker {
return createEpsViaSvg(os, dotStrings, fileFormatOption);
} else if (fileFormat == FileFormat.EPS) {
return createEps(os, dotStrings, fileFormatOption);
} else if (fileFormat == FileFormat.DOT) {
return createDot(os, dotStrings, fileFormatOption);
} else {
throw new UnsupportedOperationException();
}
@ -214,9 +216,7 @@ public final class CucaDiagramFileMaker {
try {
deltaY = 0;
populateImages(diagram.getDpiFactor(fileFormatOption), diagram.getDpi(fileFormatOption));
populateImagesLink(diagram.getDpiFactor(fileFormatOption), diagram.getDpi(fileFormatOption));
final GraphvizMaker dotMaker = createDotMaker(dotStrings, fileFormatOption);
final GraphvizMaker dotMaker = populateImagesAndCreateGraphvizMaker(dotStrings, fileFormatOption);
final String dotString = dotMaker.createDotString();
if (OptionFlags.getInstance().isKeepTmpFiles()) {
@ -411,9 +411,7 @@ public final class CucaDiagramFileMaker {
final StringBuilder cmap = new StringBuilder();
try {
populateImages(diagram.getDpiFactor(fileFormatOption), diagram.getDpi(fileFormatOption));
populateImagesLink(diagram.getDpiFactor(fileFormatOption), diagram.getDpi(fileFormatOption));
final GraphvizMaker dotMaker = createDotMaker(dotStrings, fileFormatOption);
final GraphvizMaker dotMaker = populateImagesAndCreateGraphvizMaker(dotStrings, fileFormatOption);
final String dotString = dotMaker.createDotString();
if (OptionFlags.getInstance().isKeepTmpFiles()) {
@ -469,6 +467,14 @@ public final class CucaDiagramFileMaker {
return null;
}
private String createDot(OutputStream os, List<String> dotStrings, FileFormatOption fileFormatOption)
throws IOException, InterruptedException {
final GraphvizMaker dotMaker = populateImagesAndCreateGraphvizMaker(dotStrings, fileFormatOption);
final String dotString = dotMaker.createDotString();
os.write(dotString.getBytes());
return null;
}
private BufferedImage scaleImage(BufferedImage im, Scale scale) {
if (scale == null) {
return im;
@ -625,52 +631,6 @@ public final class CucaDiagramFileMaker {
}
}
private GraphvizMaker createDotMaker(List<String> dotStrings, FileFormatOption fileFormatOption)
throws IOException, InterruptedException {
final FileFormat fileFormat = fileFormatOption.getFileFormat();
if (diagram.getUmlDiagramType() == UmlDiagramType.STATE
|| diagram.getUmlDiagramType() == UmlDiagramType.ACTIVITY) {
new CucaDiagramSimplifier(diagram, dotStrings, fileFormat);
}
final DotData dotData = new DotData(null, diagram.getLinks(), diagram.entities(), diagram.getUmlDiagramType(),
diagram.getSkinParam(), diagram.getRankdir(), diagram, diagram);
dotData.setDpi(diagram.getDpi(fileFormatOption));
if (diagram.getUmlDiagramType() == UmlDiagramType.CLASS || diagram.getUmlDiagramType() == UmlDiagramType.OBJECT) {
dotData.setStaticImagesMap(staticFilesMap);
if (diagram.isVisibilityModifierPresent()) {
dotData.setVisibilityModifierPresent(true);
}
}
return new DotMaker(dotData, dotStrings, fileFormat);
}
private void populateImages(double dpiFactor, int dpi) throws IOException {
for (Entity entity : diagram.entities().values()) {
final DrawFile f = createImage(entity, dpiFactor, dpi);
if (f != null) {
entity.setImageFile(f);
}
}
}
private void populateImagesLink(double dpiFactor, int dpi) throws IOException {
for (Link link : diagram.getLinks()) {
final String note = link.getNote();
if (note == null) {
continue;
}
final DrawFile f = createImageForNote(note, null, dpiFactor, dpi);
if (f != null) {
link.setImageFile(f);
}
}
}
DrawFile createImage(Entity entity, double dpiFactor, int dpi) throws IOException {
if (entity.getType() == EntityType.NOTE) {
return createImageForNote(entity.getDisplay(), entity.getSpecificBackColor(), dpiFactor, dpi);
@ -688,7 +648,8 @@ public final class CucaDiagramFileMaker {
return null;
}
private DrawFile createImageForNote(String display, HtmlColor backColor, double dpiFactor, int dpi) throws IOException {
private DrawFile createImageForNoteOld2(String display, HtmlColor backColor, double dpiFactor, int dpi)
throws IOException {
final File fPng = FileUtils.createTempFile("plantumlB", ".png");
final Rose skin = new Rose();
@ -722,6 +683,58 @@ public final class CucaDiagramFileMaker {
return DrawFile.createFromFile(fPng, getSvg(ug), fEps);
}
private DrawFile createImageForNote(String display, HtmlColor backColor, final double dpiFactor, final int dpi)
throws IOException {
final Rose skin = new Rose();
final ISkinParam skinParam = new SkinParamBackcolored(getSkinParam(), backColor);
final Component comp = skin
.createComponent(ComponentType.NOTE, skinParam, StringUtils.getWithNewlines(display));
final int width = (int) (comp.getPreferredWidth(stringBounder) * dpiFactor);
final int height = (int) (comp.getPreferredHeight(stringBounder) * dpiFactor);
final Color background = diagram.getSkinParam().getBackgroundColor().getColor();
final Lazy<File> lpng = new Lazy<File>() {
public File getNow() throws IOException {
final File fPng = FileUtils.createTempFile("plantumlB", ".png");
final EmptyImageBuilder builder = new EmptyImageBuilder(width, height, background);
final BufferedImage im = builder.getBufferedImage();
final Graphics2D g2d = builder.getGraphics2D();
comp.drawU(new UGraphicG2d(g2d, null, dpiFactor), new Dimension(width, height), new SimpleContext2D(
false));
PngIO.write(im, fPng, dpi);
g2d.dispose();
return fPng;
}
};
final Lazy<String> lsvg = new Lazy<String>() {
public String getNow() throws IOException {
final UGraphicSvg ug = new UGraphicSvg(true);
comp.drawU(ug, new Dimension(width, height), new SimpleContext2D(false));
return getSvg(ug);
}
};
final Lazy<File> leps = new Lazy<File>() {
public File getNow() throws IOException {
final File fEps = FileUtils.createTempFile("plantumlB", ".eps");
final PrintWriter pw = new PrintWriter(fEps);
final UGraphicEps uEps = new UGraphicEps(EpsStrategy.getDefault());
comp.drawU(uEps, new Dimension(width, height), new SimpleContext2D(false));
pw.print(uEps.getEPSCode());
pw.close();
return fEps;
}
};
return DrawFile.create(lpng, lsvg, leps, null);
}
static public String getSvg(UGraphicSvg ug) throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
ug.createXml(baos);
@ -739,9 +752,10 @@ public final class CucaDiagramFileMaker {
private DrawFile createImageForCircleInterface(Entity entity, final double dpiFactor) throws IOException {
final String stereo = entity.getStereotype() == null ? null : entity.getStereotype().getLabel();
final Color interfaceBackground = rose.getHtmlColor(getSkinParam(), ColorParam.componentInterfaceBackground, stereo)
final Color interfaceBackground = rose.getHtmlColor(getSkinParam(), ColorParam.componentInterfaceBackground,
stereo).getColor();
final Color interfaceBorder = rose.getHtmlColor(getSkinParam(), ColorParam.componentInterfaceBorder, stereo)
.getColor();
final Color interfaceBorder = rose.getHtmlColor(getSkinParam(), ColorParam.componentInterfaceBorder, stereo).getColor();
final Color background = rose.getHtmlColor(getSkinParam(), ColorParam.background, stereo).getColor();
final CircleInterface circleInterface = new CircleInterface(interfaceBackground, interfaceBorder);
@ -785,7 +799,8 @@ public final class CucaDiagramFileMaker {
private DrawFile createImageForActor(Entity entity, final double dpiFactor) throws IOException {
final String stereo = entity.getStereotype() == null ? null : entity.getStereotype().getLabel();
final Color actorBackground = rose.getHtmlColor(getSkinParam(), ColorParam.usecaseActorBackground, stereo).getColor();
final Color actorBackground = rose.getHtmlColor(getSkinParam(), ColorParam.usecaseActorBackground, stereo)
.getColor();
final Color actorBorder = rose.getHtmlColor(getSkinParam(), ColorParam.usecaseActorBorder, stereo).getColor();
final Color background = rose.getHtmlColor(getSkinParam(), ColorParam.background, stereo).getColor();
final StickMan stickMan = new StickMan(actorBackground, actorBorder);
@ -853,9 +868,7 @@ public final class CucaDiagramFileMaker {
try {
deltaY = 0;
populateImages(diagram.getDpiFactor(fileFormatOption), diagram.getDpi(fileFormatOption));
populateImagesLink(diagram.getDpiFactor(fileFormatOption), diagram.getDpi(fileFormatOption));
final GraphvizMaker dotMaker = createDotMaker(dotStrings, fileFormatOption);
final GraphvizMaker dotMaker = populateImagesAndCreateGraphvizMaker(dotStrings, fileFormatOption);
final String dotString = dotMaker.createDotString();
if (OptionFlags.getInstance().isKeepTmpFiles()) {
@ -925,4 +938,58 @@ public final class CucaDiagramFileMaker {
return null;
}
private GraphvizMaker populateImagesAndCreateGraphvizMaker(List<String> dotStrings,
FileFormatOption fileFormatOption) throws IOException, InterruptedException {
populateImages(diagram.getDpiFactor(fileFormatOption), diagram.getDpi(fileFormatOption));
populateImagesLink(diagram.getDpiFactor(fileFormatOption), diagram.getDpi(fileFormatOption));
final GraphvizMaker dotMaker = createDotMaker(dotStrings, fileFormatOption);
return dotMaker;
}
private GraphvizMaker createDotMaker(List<String> dotStrings, FileFormatOption fileFormatOption)
throws IOException, InterruptedException {
final FileFormat fileFormat = fileFormatOption.getFileFormat();
if (diagram.getUmlDiagramType() == UmlDiagramType.STATE
|| diagram.getUmlDiagramType() == UmlDiagramType.ACTIVITY) {
new CucaDiagramSimplifier(diagram, dotStrings, fileFormat);
}
final DotData dotData = new DotData(null, diagram.getLinks(), diagram.entities(), diagram.getUmlDiagramType(),
diagram.getSkinParam(), diagram.getRankdir(), diagram, diagram);
dotData.setDpi(diagram.getDpi(fileFormatOption));
if (diagram.getUmlDiagramType() == UmlDiagramType.CLASS || diagram.getUmlDiagramType() == UmlDiagramType.OBJECT) {
dotData.setStaticImagesMap(staticFilesMap);
if (diagram.isVisibilityModifierPresent()) {
dotData.setVisibilityModifierPresent(true);
}
}
return new DotMaker(dotData, dotStrings, fileFormat);
}
private void populateImages(double dpiFactor, int dpi) throws IOException {
for (Entity entity : diagram.entities().values()) {
final DrawFile f = createImage(entity, dpiFactor, dpi);
if (f != null) {
entity.setImageFile(f);
}
}
}
private void populateImagesLink(double dpiFactor, int dpi) throws IOException {
for (Link link : diagram.getLinks()) {
final String note = link.getNote();
if (note == null) {
continue;
}
final DrawFile f = createImageForNote(note, null, dpiFactor, dpi);
if (f != null) {
link.setImageFile(f);
}
}
}
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 6121 $
* Revision $Revision: 6141 $
*
*/
package net.sourceforge.plantuml.cucadiagram.dot;
@ -838,7 +838,7 @@ final public class DotMaker implements GraphvizMaker {
sb.append(entity.getUid() + " [margin=0,pad=0," + label + ",shape=none,image=\"" + absolutePath + "\"];");
} else if (type == EntityType.ACTIVITY) {
String shape = "octagon";
if (entity.getImageFile() != null) {
if (data.getSkinParam().useOctagonForActivity()==false || entity.getImageFile() != null) {
shape = "rect";
}
sb.append(entity.getUid() + " [fontcolor=" + getFontColorString(FontParam.ACTIVITY, stereo) + ",fillcolor="

View File

@ -56,11 +56,16 @@ public class DrawFile {
private int heightPng = -1;
public static DrawFile create(Lazy<File> png, Lazy<String> svg, Lazy<File> eps, Object signature) {
DrawFile result = cache.get(signature);
DrawFile result = null;
if (signature != null) {
result = cache.get(signature);
}
if (result == null) {
result = new DrawFile(png, svg, eps);
cache.put(signature, result);
Log.info("DrawFile cache size = " + cache.size());
if (signature != null) {
cache.put(signature, result);
Log.info("DrawFile cache size = " + cache.size());
}
FileUtils.deleteOnExit(result);
}
return result;
@ -80,10 +85,10 @@ public class DrawFile {
private DrawFile(File fPng, String svg, File fEps) {
this(new Unlazy<File>(fPng), new Unlazy<String>(svg), new Unlazy<File>(fEps));
// if (svg.contains("\\")) {
// System.err.println("svg="+svg);
// throw new IllegalArgumentException();
// }
// if (svg.contains("\\")) {
// System.err.println("svg="+svg);
// throw new IllegalArgumentException();
// }
}
public File getPngOrEps(boolean isEps) throws IOException {

View File

@ -142,7 +142,7 @@ public class InGroupableList implements InGroupable {
public double getMinX(StringBounder stringBounder) {
final InGroupable min = getMin(stringBounder);
if (min == null) {
return 0;
return MARGIN10 + MARGIN5;
}
double m = min.getMinX(stringBounder);
if (min instanceof MessageExoArrow
@ -169,7 +169,7 @@ public class InGroupableList implements InGroupable {
private final double getMaxXInternal(StringBounder stringBounder) {
final InGroupable max = getMax(stringBounder);
if (max == null) {
return minWidth;
return MARGIN10 + MARGIN5 + minWidth;
}
double m = max.getMaxX(stringBounder);
if (max instanceof MessageExoArrow

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: 4836 $
*
*/
package net.sourceforge.plantuml.sequencediagram;
import java.util.ArrayList;
import java.util.List;
public class ParticipantEngloberContexted {
final private ParticipantEnglober participantEnglober;
final private List<Participant> participants = new ArrayList<Participant>();
public ParticipantEngloberContexted(ParticipantEnglober participantEnglober, Participant first) {
this.participantEnglober = participantEnglober;
this.participants.add(first);
}
public final ParticipantEnglober getParticipantEnglober() {
return participantEnglober;
}
public boolean contains(Participant p) {
return participants.contains(p);
}
public void add(Participant p) {
if (participants.contains(p)) {
throw new IllegalArgumentException();
}
participants.add(p);
}
public final Participant getFirst2() {
return participants.get(0);
}
public final Participant getLast2() {
return participants.get(participants.size() - 1);
}
@Override
public String toString() {
return super.toString()+" "+participants;
}
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 6097 $
* Revision $Revision: 6137 $
*
*/
package net.sourceforge.plantuml.sequencediagram;
@ -56,8 +56,9 @@ import net.sourceforge.plantuml.sequencediagram.command.CommandNewpage;
import net.sourceforge.plantuml.sequencediagram.command.CommandNoteOnArrow;
import net.sourceforge.plantuml.sequencediagram.command.CommandNoteOverSeveral;
import net.sourceforge.plantuml.sequencediagram.command.CommandNoteSequence;
import net.sourceforge.plantuml.sequencediagram.command.CommandParticipant;
import net.sourceforge.plantuml.sequencediagram.command.CommandParticipant2;
import net.sourceforge.plantuml.sequencediagram.command.CommandParticipantA;
import net.sourceforge.plantuml.sequencediagram.command.CommandParticipantA2;
import net.sourceforge.plantuml.sequencediagram.command.CommandParticipantA3;
import net.sourceforge.plantuml.sequencediagram.command.CommandSkin;
public class SequenceDiagramFactory extends AbstractUmlSystemCommandFactory {
@ -70,8 +71,9 @@ public class SequenceDiagramFactory extends AbstractUmlSystemCommandFactory {
addCommonCommands(system);
addCommand(new CommandParticipant(system));
addCommand(new CommandParticipant2(system));
addCommand(new CommandParticipantA(system));
addCommand(new CommandParticipantA2(system));
addCommand(new CommandParticipantA3(system));
addCommand(new CommandArrow(system));
addCommand(new CommandExoArrowLeft(system));
addCommand(new CommandExoArrowRight(system));

View File

@ -34,47 +34,51 @@
package net.sourceforge.plantuml.sequencediagram.command;
import java.util.List;
import java.util.Map;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand;
import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexPartialMatch;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.sequencediagram.Participant;
import net.sourceforge.plantuml.sequencediagram.ParticipantType;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
public class CommandParticipant extends SingleLineCommand<SequenceDiagram> {
public CommandParticipant(SequenceDiagram sequenceDiagram) {
super(sequenceDiagram,
"(?i)^(participant|actor)\\s+(?:\"([^\"]+)\"\\s+as\\s+)?([\\p{L}0-9_.]+)(?:\\s*(\\<\\<.*\\>\\>))?\\s*(#\\w+)?$");
public abstract class CommandParticipant extends SingleLineCommand2<SequenceDiagram> {
public CommandParticipant(SequenceDiagram sequenceDiagram, RegexConcat pattern) {
super(sequenceDiagram, pattern);
}
@Override
protected CommandExecutionResult executeArg(List<String> arg) {
final String code = arg.get(2);
final protected CommandExecutionResult executeArg(Map<String, RegexPartialMatch> arg2) {
final String code = arg2.get("CODE").get(0);
if (getSystem().participants().containsKey(code)) {
getSystem().putParticipantInLast(code);
return CommandExecutionResult.ok();
}
List<String> strings = null;
if (arg.get(1) != null) {
strings = StringUtils.getWithNewlines(arg.get(1));
if (arg2.get("FULL").get(0) != null) {
strings = StringUtils.getWithNewlines(arg2.get("FULL").get(0));
}
final ParticipantType type = ParticipantType.valueOf(arg.get(0).toUpperCase());
final ParticipantType type = ParticipantType.valueOf(arg2.get("TYPE").get(0).toUpperCase());
final Participant participant = getSystem().createNewParticipant(type, code, strings);
final String stereotype = arg.get(3);
final String stereotype = arg2.get("STEREO").get(0);
if (stereotype != null) {
participant.setStereotype(new Stereotype(stereotype,
getSystem().getSkinParam().getCircledCharacterRadius(), getSystem().getSkinParam().getFont(
FontParam.CIRCLED_CHARACTER, null)));
}
participant.setSpecificBackcolor(arg.get(4));
participant.setSpecificBackcolor(arg2.get("COLOR").get(0));
return CommandExecutionResult.ok();
}

View File

@ -1,79 +0,0 @@
/* ========================================================================
* 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.sequencediagram.command;
import java.util.List;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.sequencediagram.Participant;
import net.sourceforge.plantuml.sequencediagram.ParticipantType;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
public class CommandParticipant2 extends SingleLineCommand<SequenceDiagram> {
public CommandParticipant2(SequenceDiagram sequenceDiagram) {
super(sequenceDiagram,
"(?i)^(participant|actor)\\s+([\\p{L}0-9_.]+)\\s+as\\s+\"([^\"]+)\"(?:\\s*(\\<\\<.*\\>\\>))?\\s*(#\\w+)?$");
}
@Override
protected CommandExecutionResult executeArg(List<String> arg) {
final String code = arg.get(1);
if (getSystem().participants().containsKey(code)) {
getSystem().putParticipantInLast(code);
return CommandExecutionResult.ok();
}
final List<String> strings = StringUtils.getWithNewlines(arg.get(2));
final ParticipantType type = ParticipantType.valueOf(arg.get(0).toUpperCase());
final Participant participant = getSystem().createNewParticipant(type, code, strings);
final String stereotype = arg.get(3);
if (stereotype != null) {
participant.setStereotype(new Stereotype(stereotype,
getSystem().getSkinParam().getCircledCharacterRadius(), getSystem().getSkinParam().getFont(
FontParam.CIRCLED_CHARACTER, null)));
}
participant.setSpecificBackcolor(arg.get(4));
return CommandExecutionResult.ok();
}
}

View File

@ -0,0 +1,58 @@
/* ========================================================================
* 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: 6109 $
*
*/
package net.sourceforge.plantuml.sequencediagram.command;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
public class CommandParticipantA extends CommandParticipant {
public CommandParticipantA(SequenceDiagram sequenceDiagram) {
super(sequenceDiagram, getRegexConcat());
}
static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("TYPE", "(participant|actor)"), //
new RegexLeaf("\\s+"), //
new RegexLeaf("FULL", "(?:\"([^\"]+)\"\\s+as\\s+)?"), //
new RegexLeaf("CODE", "([\\p{L}0-9_.]+)"), //
new RegexLeaf("STEREO", "(?:\\s*(\\<\\<.*\\>\\>))?"), //
new RegexLeaf("\\s*"), //
new RegexLeaf("COLOR", "(#\\w+)?"), //
new RegexLeaf("$"));
}
}

View File

@ -0,0 +1,59 @@
/* ========================================================================
* 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: 6109 $
*
*/
package net.sourceforge.plantuml.sequencediagram.command;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
public class CommandParticipantA2 extends CommandParticipant {
public CommandParticipantA2(SequenceDiagram sequenceDiagram) {
super(sequenceDiagram, getRegexConcat());
}
static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("TYPE", "(participant|actor)"), //
new RegexLeaf("\\s+"), //
new RegexLeaf("CODE", "([\\p{L}0-9_.]+)"), //
new RegexLeaf("\\s+as\\s+"), //
new RegexLeaf("FULL", "\"([^\"]+)\""), //
new RegexLeaf("STEREO", "(?:\\s*(\\<\\<.*\\>\\>))?"), //
new RegexLeaf("\\s*"), //
new RegexLeaf("COLOR", "(#\\w+)?"), //
new RegexLeaf("$"));
}
}

View File

@ -0,0 +1,58 @@
/* ========================================================================
* 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: 6109 $
*
*/
package net.sourceforge.plantuml.sequencediagram.command;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
public class CommandParticipantA3 extends CommandParticipant {
public CommandParticipantA3(SequenceDiagram sequenceDiagram) {
super(sequenceDiagram, getRegexConcat());
}
static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("TYPE", "(participant|actor)"), //
new RegexLeaf("\\s+"), //
new RegexLeaf("FULL", "([\\p{L}0-9_.]+)\\s+as\\s+"), //
new RegexLeaf("CODE", "([\\p{L}0-9_.]+)"), //
new RegexLeaf("STEREO", "(?:\\s*(\\<\\<.*\\>\\>))?"), //
new RegexLeaf("\\s*"), //
new RegexLeaf("COLOR", "(#\\w+)?"), //
new RegexLeaf("$"));
}
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 6122 $
* Revision $Revision: 6142 $
*
*/
package net.sourceforge.plantuml.version;
@ -36,11 +36,11 @@ package net.sourceforge.plantuml.version;
public class Version {
public static int version() {
return 6121;
return 6141;
}
public static long compileTime() {
return 1297683757562L;
return 1298495043843L;
}
}