1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-05-28 14:10:48 +00:00

version 2017.08

This commit is contained in:
Arnaud Roques 2017-03-21 22:37:59 +01:00
parent 69ea262d5d
commit 091a95bd82
47 changed files with 2439 additions and 130 deletions

View File

@ -35,7 +35,7 @@
<groupId>net.sourceforge.plantuml</groupId>
<artifactId>plantuml</artifactId>
<version>8060-SNAPSHOT</version>
<version>2017.09-SNAPSHOT</version>
<packaging>jar</packaging>
<name>PlantUML</name>

View File

@ -46,7 +46,7 @@ public abstract class Log {
public synchronized static void info(String s) {
if (OptionFlags.getInstance().isVerbose()) {
ProgressBar.clear();
System.out.println(format(s));
System.err.println(format(s));
}
}

View File

@ -62,6 +62,7 @@ public class Option {
private boolean computeurl = false;
private boolean decodeurl = false;
private boolean pipe = false;
private String pipeDelimitor;
private boolean pipeMap = false;
private boolean syntax = false;
private boolean checkOnly = false;
@ -204,6 +205,12 @@ public class Option {
OptionFlags.getInstance().setVerbose(true);
} else if (s.equalsIgnoreCase("-pipe") || s.equalsIgnoreCase("-p")) {
pipe = true;
} else if (s.equalsIgnoreCase("-pipedelimitor")) {
i++;
if (i == arg.length) {
continue;
}
pipeDelimitor = arg[i];
} else if (s.equalsIgnoreCase("-pipemap")) {
pipeMap = true;
} else if (s.equalsIgnoreCase("-pattern")) {
@ -496,4 +503,8 @@ public class Option {
return textProgressBar;
}
public String getPipeDelimitor() {
return pipeDelimitor;
}
}

View File

@ -43,6 +43,7 @@ import net.sourceforge.plantuml.acearth.PSystemXearthFactory;
import net.sourceforge.plantuml.activitydiagram.ActivityDiagramFactory;
import net.sourceforge.plantuml.activitydiagram3.ActivityDiagramFactory3;
import net.sourceforge.plantuml.api.PSystemFactory;
import net.sourceforge.plantuml.bpm.BpmDiagramFactory;
import net.sourceforge.plantuml.classdiagram.ClassDiagramFactory;
import net.sourceforge.plantuml.compositediagram.CompositeDiagramFactory;
import net.sourceforge.plantuml.core.Diagram;
@ -59,10 +60,10 @@ import net.sourceforge.plantuml.eggs.PSystemAppleTwoFactory;
import net.sourceforge.plantuml.eggs.PSystemCharlieFactory;
import net.sourceforge.plantuml.eggs.PSystemColorsFactory;
import net.sourceforge.plantuml.eggs.PSystemEggFactory;
import net.sourceforge.plantuml.eggs.PSystemWelcomeFactory;
import net.sourceforge.plantuml.eggs.PSystemLostFactory;
import net.sourceforge.plantuml.eggs.PSystemPathFactory;
import net.sourceforge.plantuml.eggs.PSystemRIPFactory;
import net.sourceforge.plantuml.eggs.PSystemWelcomeFactory;
import net.sourceforge.plantuml.flowdiagram.FlowDiagramFactory;
import net.sourceforge.plantuml.font.PSystemListFontsFactory;
import net.sourceforge.plantuml.jcckit.PSystemJcckitFactory;
@ -148,6 +149,7 @@ public class PSystemBuilder {
factories.add(new ActivityDiagramFactory3());
factories.add(new CompositeDiagramFactory());
// factories.add(new ObjectDiagramFactory());
factories.add(new BpmDiagramFactory(DiagramType.BPM));
factories.add(new PostIdDiagramFactory());
factories.add(new PrintSkinFactory());
factories.add(new PSystemLicenseFactory());

View File

@ -0,0 +1,166 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.preproc.Defines;
public class Pipe {
private final Option option;
private final InputStream is;
private final PrintStream ps;
private boolean closed = false;
private final String charset;
public Pipe(Option option, PrintStream ps, InputStream is, String charset) {
this.option = option;
this.is = is;
this.ps = ps;
this.charset = charset;
}
public boolean managePipe() throws IOException {
boolean error = false;
do {
final String source = readOneDiagram();
if (source == null) {
ps.flush();
return error;
}
final SourceStringReader sourceStringReader = new SourceStringReader(new Defines(), source,
option.getConfig());
if (option.isSyntax()) {
final Diagram system = sourceStringReader.getBlocks().get(0).getDiagram();
if (system instanceof UmlDiagram) {
ps.println(((UmlDiagram) system).getUmlDiagramType().name());
ps.println(system.getDescription());
} else if (system instanceof PSystemError) {
error = true;
ps.println("ERROR");
final PSystemError sys = (PSystemError) system;
ps.println(sys.getHigherErrorPosition());
for (ErrorUml er : sys.getErrorsUml()) {
ps.println(er.getError());
}
} else {
ps.println("OTHER");
ps.println(system.getDescription());
}
} else if (option.isPipeMap()) {
final String result = sourceStringReader.getCMapData(0, option.getFileFormatOption());
ps.println(result);
} else {
final DiagramDescription result = sourceStringReader.generateImage(ps, 0, option.getFileFormatOption());
if (option.getPipeDelimitor() != null) {
ps.println(option.getPipeDelimitor());
}
if (result != null && "(error)".equalsIgnoreCase(result.getDescription())) {
error = true;
System.err.println("ERROR");
final Diagram system = sourceStringReader.getBlocks().get(0).getDiagram();
final PSystemError sys = (PSystemError) system;
System.err.println(sys.getHigherErrorPosition());
for (ErrorUml er : sys.getErrorsUml()) {
System.err.println(er.getError());
}
}
}
ps.flush();
} while (closed == false);
return error;
}
private boolean isFinished(String s) {
return s == null || s.startsWith("@end");
}
private String readOneDiagram() throws IOException {
final StringBuilder sb = new StringBuilder();
while (true) {
final String s = readOneLine();
if (s == null) {
closed = true;
} else {
sb.append(s);
sb.append("\n");
}
if (isFinished(s)) {
break;
}
}
if (sb.length() == 0) {
return null;
}
String source = sb.toString();
if (source.startsWith("@start") == false) {
source = "@startuml\n" + source + "\n@enduml";
}
return source;
}
private String readOneLine() throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
while (true) {
final int read = is.read();
if (read == -1) {
if (baos.size() == 0) {
return null;
}
break;
}
if (read != '\r') {
baos.write(read);
}
if (read == '\n') {
break;
}
}
if (charset == null) {
return new String(baos.toByteArray());
}
return new String(baos.toByteArray(), charset);
}
}

View File

@ -41,11 +41,8 @@ import java.awt.Graphics2D;
import java.awt.GraphicsEnvironment;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
@ -61,12 +58,10 @@ import net.sourceforge.plantuml.classdiagram.ClassDiagramFactory;
import net.sourceforge.plantuml.code.Transcoder;
import net.sourceforge.plantuml.code.TranscoderUtil;
import net.sourceforge.plantuml.command.UmlDiagramFactory;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.descdiagram.DescriptionDiagramFactory;
import net.sourceforge.plantuml.ftp.FtpServer;
import net.sourceforge.plantuml.objectdiagram.ObjectDiagramFactory;
import net.sourceforge.plantuml.png.MetadataTag;
import net.sourceforge.plantuml.preproc.Defines;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagramFactory;
import net.sourceforge.plantuml.statediagram.StateDiagramFactory;
import net.sourceforge.plantuml.stats.StatsUtils;
@ -271,63 +266,7 @@ public class Run {
private static boolean managePipe(Option option) throws IOException {
final String charset = option.getCharset();
final BufferedReader br;
if (charset == null) {
br = new BufferedReader(new InputStreamReader(System.in));
} else {
br = new BufferedReader(new InputStreamReader(System.in, charset));
}
return managePipe(option, br, System.out);
}
static public boolean managePipe(Option option, final BufferedReader br, final PrintStream ps) throws IOException {
boolean error = false;
final StringBuilder sb = new StringBuilder();
String s = null;
while ((s = br.readLine()) != null) {
sb.append(s);
sb.append("\n");
}
String source = sb.toString();
if (source.contains("@startuml") == false) {
source = "@startuml\n" + source + "\n@enduml";
}
final SourceStringReader sourceStringReader = new SourceStringReader(new Defines(), source, option.getConfig());
if (option.isSyntax()) {
final Diagram system = sourceStringReader.getBlocks().get(0).getDiagram();
if (system instanceof UmlDiagram) {
ps.println(((UmlDiagram) system).getUmlDiagramType().name());
ps.println(system.getDescription());
} else if (system instanceof PSystemError) {
error = true;
ps.println("ERROR");
final PSystemError sys = (PSystemError) system;
ps.println(sys.getHigherErrorPosition());
for (ErrorUml er : sys.getErrorsUml()) {
ps.println(er.getError());
}
} else {
ps.println("OTHER");
ps.println(system.getDescription());
}
} else if (option.isPipeMap()) {
final String result = sourceStringReader.getCMapData(0, option.getFileFormatOption());
ps.println(result);
} else if (option.isPipe()) {
final String result = sourceStringReader.generateImage(ps, 0, option.getFileFormatOption());
if ("(error)".equalsIgnoreCase(result)) {
error = true;
System.err.println("ERROR");
final Diagram system = sourceStringReader.getBlocks().get(0).getDiagram();
final PSystemError sys = (PSystemError) system;
System.err.println(sys.getHigherErrorPosition());
for (ErrorUml er : sys.getErrorsUml()) {
System.err.println(er.getError());
}
}
}
return error;
return new Pipe(option, System.out, System.in, charset).managePipe();
}
private static boolean manageAllFiles(Option option) throws IOException, InterruptedException {

View File

@ -92,26 +92,27 @@ public class SourceStringReader {
}
}
public String generateImage(OutputStream os) throws IOException {
public DiagramDescription generateImage(OutputStream os) throws IOException {
return generateImage(os, 0);
}
public String generateImage(File f) throws IOException {
public DiagramDescription generateImage(File f) throws IOException {
final OutputStream os = new BufferedOutputStream(new FileOutputStream(f));
final String result = generateImage(os, 0);
final DiagramDescription result = generateImage(os, 0);
os.close();
return result;
}
public String generateImage(OutputStream os, FileFormatOption fileFormatOption) throws IOException {
public DiagramDescription generateImage(OutputStream os, FileFormatOption fileFormatOption) throws IOException {
return generateImage(os, 0, fileFormatOption);
}
public String generateImage(OutputStream os, int numImage) throws IOException {
public DiagramDescription generateImage(OutputStream os, int numImage) throws IOException {
return generateImage(os, numImage, new FileFormatOption(FileFormat.PNG));
}
public String generateImage(OutputStream os, int numImage, FileFormatOption fileFormatOption) throws IOException {
public DiagramDescription generateImage(OutputStream os, int numImage, FileFormatOption fileFormatOption)
throws IOException {
if (blocks.size() == 0) {
noStartumlFound(os, fileFormatOption);
return null;
@ -122,10 +123,10 @@ public class SourceStringReader {
if (numImage < nbInSystem) {
// final CMapData cmap = new CMapData();
final ImageData imageData = system.exportDiagram(os, numImage, fileFormatOption);
if (imageData.containsCMapData()) {
return system.getDescription().getDescription() + "\n" + imageData.getCMapData("plantuml");
}
return system.getDescription().getDescription();
// if (imageData.containsCMapData()) {
// return system.getDescription().getDescription() + "\n" + imageData.getCMapData("plantuml");
// }
return system.getDescription();
}
numImage -= nbInSystem;
}
@ -163,30 +164,28 @@ public class SourceStringReader {
imageBuilder.writeImageTOBEMOVED(fileFormatOption, os);
}
public DiagramDescription generateDiagramDescription(OutputStream os) throws IOException {
return generateDiagramDescription(os, 0);
public DiagramDescription generateDiagramDescription() {
return generateDiagramDescription(0);
}
public DiagramDescription generateDiagramDescription(File f) throws IOException {
final OutputStream os = new BufferedOutputStream(new FileOutputStream(f));
final DiagramDescription result = generateDiagramDescription(os, 0);
os.close();
return result;
// public DiagramDescription generateDiagramDescription(File f) throws IOException {
// final OutputStream os = new BufferedOutputStream(new FileOutputStream(f));
// final DiagramDescription result = generateDiagramDescription(os, 0);
// os.close();
// return result;
// }
public DiagramDescription generateDiagramDescription(FileFormatOption fileFormatOption) {
return generateDiagramDescription(0, fileFormatOption);
}
public DiagramDescription generateDiagramDescription(OutputStream os, FileFormatOption fileFormatOption)
throws IOException {
return generateDiagramDescription(os, 0, fileFormatOption);
public DiagramDescription generateDiagramDescription(int numImage) {
return generateDiagramDescription(numImage, new FileFormatOption(FileFormat.PNG));
}
public DiagramDescription generateDiagramDescription(OutputStream os, int numImage) throws IOException {
return generateDiagramDescription(os, numImage, new FileFormatOption(FileFormat.PNG));
}
public DiagramDescription generateDiagramDescription(OutputStream os, int numImage,
FileFormatOption fileFormatOption) throws IOException {
public DiagramDescription generateDiagramDescription(int numImage, FileFormatOption fileFormatOption) {
if (blocks.size() == 0) {
noStartumlFound(os, fileFormatOption);
// noStartumlFound(os, fileFormatOption);
return null;
}
for (BlockUml b : blocks) {

View File

@ -36,5 +36,5 @@
package net.sourceforge.plantuml;
public enum UmlDiagramType {
SEQUENCE, STATE, CLASS, OBJECT, ACTIVITY, DESCRIPTION, COMPOSITE, FLOW, TIMING
SEQUENCE, STATE, CLASS, OBJECT, ACTIVITY, DESCRIPTION, COMPOSITE, FLOW, TIMING, BPM
}

View File

@ -75,7 +75,7 @@ public class FtileFactoryDelegatorCreateParallel extends FtileFactoryDelegator {
ParallelFtilesBuilder builder;
if (style == ForkStyle.SPLIT) {
builder = new ParallelBuilderSplit(skinParam(), getStringBounder(), list, inner, swimlane);
builder = new ParallelBuilderSplit2(skinParam(), getStringBounder(), list, inner, swimlane);
} else if (style == ForkStyle.MERGE) {
builder = new ParallelBuilderMerge(skinParam(), getStringBounder(), list, inner, swimlane);
} else if (style == ForkStyle.FORK) {

View File

@ -0,0 +1,247 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection;
import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
import net.sourceforge.plantuml.activitydiagram3.ftile.ConnectionTranslatable;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileAssemblySimple;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileKilled;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils;
import net.sourceforge.plantuml.activitydiagram3.ftile.Snake;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileThinSplit;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.HtmlColorAndStyle;
import net.sourceforge.plantuml.graphic.Rainbow;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public class ParallelBuilderSplit2 extends ParallelFtilesBuilder {
public ParallelBuilderSplit2(ISkinParam skinParam, StringBounder stringBounder, final List<Ftile> list,
Ftile inner, Swimlane swimlane) {
super(skinParam, stringBounder, list, inner, swimlane);
}
@Override
protected Ftile doStep1() {
Ftile result = getMiddle();
final List<Connection> conns = new ArrayList<Connection>();
final Rainbow thinColor = result.getInLinkRendering().getRainbow(HtmlColorAndStyle.build(skinParam()));
final Ftile thin = new FtileThinSplit(skinParam(), thinColor.getColor(), getList().get(0).getSwimlaneIn());
double x = 0;
double first = 0;
double last = 0;
for (Ftile tmp : getList()) {
final FtileGeometry dim = tmp.calculateDimension(getStringBounder());
if (first == 0) {
first = dim.getLeft();
}
last = x + dim.getLeft();
conns.add(new ConnectionIn(thin, tmp, x, tmp.getInLinkRendering().getRainbow(
HtmlColorAndStyle.build(skinParam()))));
x += dim.getWidth();
}
result = FtileUtils.addConnection(result, conns);
((FtileThinSplit) thin).setGeom(first, last, result.calculateDimension(getStringBounder()).getWidth());
return new FtileAssemblySimple(thin, result);
}
private boolean hasOut() {
for (Ftile tmp : getList()) {
final boolean hasOutTmp = tmp.calculateDimension(getStringBounder()).hasPointOut();
if (hasOutTmp) {
return true;
}
}
return false;
}
@Override
protected Ftile doStep2(Ftile result) {
final FtileGeometry geom = result.calculateDimension(getStringBounder());
if (hasOut() == false) {
return new FtileKilled(result);
}
final Rainbow thinColor = result.getInLinkRendering().getRainbow(HtmlColorAndStyle.build(skinParam()));
final Ftile out = new FtileThinSplit(skinParam(), thinColor.getColor(), getList().get(0).getSwimlaneIn());
result = new FtileAssemblySimple(result, out);
final List<Connection> conns = new ArrayList<Connection>();
double x = 0;
double first = 0;
double last = 0;
for (Ftile tmp : getList()) {
final UTranslate translate0 = new UTranslate(0, 1.5);
final FtileGeometry dim = tmp.calculateDimension(getStringBounder());
if (dim.hasPointOut()) {
if (first == 0) {
first = dim.getLeft();
}
last = x + dim.getLeft();
}
conns.add(new ConnectionOut(translate0, tmp, out, x, tmp.getOutLinkRendering().getRainbow(
HtmlColorAndStyle.build(skinParam())), getHeightOfMiddle()));
x += dim.getWidth();
}
if (last < geom.getLeft()) {
last = geom.getLeft();
}
((FtileThinSplit) out).setGeom(first, last, geom.getWidth());
result = FtileUtils.addConnection(result, conns);
return result;
}
class ConnectionIn extends AbstractConnection implements ConnectionTranslatable {
private final double x;
private final Rainbow arrowColor;
private final Display label;
public ConnectionIn(Ftile ftile1, Ftile ftile2, double x, Rainbow arrowColor) {
super(ftile1, ftile2);
label = ftile2.getInLinkRendering().getDisplay();
this.x = x;
this.arrowColor = arrowColor;
}
public void drawU(UGraphic ug) {
ug = ug.apply(new UTranslate(x, 0));
final FtileGeometry geo = getFtile2().calculateDimension(getStringBounder());
final Snake snake = new Snake(arrowColor, Arrows.asToDown());
if (Display.isNull(label) == false) {
snake.setLabel(getTextBlock(label));
}
snake.addPoint(geo.getLeft(), 0);
snake.addPoint(geo.getLeft(), geo.getInY());
ug.draw(snake);
}
public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) {
ug = ug.apply(new UTranslate(x, 0));
final FtileGeometry geo = getFtile2().calculateDimension(getStringBounder());
final Point2D p1 = new Point2D.Double(geo.getLeft(), 0);
final Point2D p2 = new Point2D.Double(geo.getLeft(), geo.getInY());
final Snake snake = new Snake(arrowColor, Arrows.asToDown());
if (Display.isNull(label) == false) {
snake.setLabel(getTextBlock(label));
}
final Point2D mp1a = translate1.getTranslated(p1);
final Point2D mp2b = translate2.getTranslated(p2);
final double middle = mp1a.getY() + 4;
snake.addPoint(mp1a);
snake.addPoint(mp1a.getX(), middle);
snake.addPoint(mp2b.getX(), middle);
snake.addPoint(mp2b);
ug.draw(snake);
}
}
class ConnectionOut extends AbstractConnection implements ConnectionTranslatable {
private final double x;
private final Rainbow arrowColor;
private final double height;
private final Display label;
private final UTranslate translate0;
public ConnectionOut(UTranslate translate0, Ftile ftile1, Ftile ftile2, double x, Rainbow arrowColor,
double height) {
super(ftile1, ftile2);
this.translate0 = translate0;
this.label = ftile1.getOutLinkRendering().getDisplay();
this.x = x;
this.arrowColor = arrowColor;
this.height = height;
}
public void drawU(UGraphic ug) {
ug = ug.apply(new UTranslate(x, 0));
final FtileGeometry geo = getFtile1().calculateDimension(getStringBounder());
if (geo.hasPointOut() == false) {
return;
}
final Snake snake = new Snake(arrowColor, Arrows.asToDown());
if (Display.isNull(label) == false) {
snake.setLabel(getTextBlock(label));
}
final Point2D p1 = translate0.getTranslated(new Point2D.Double(geo.getLeft(), geo.getOutY()));
final Point2D p2 = translate0.getTranslated(new Point2D.Double(geo.getLeft(), height));
snake.addPoint(p1);
snake.addPoint(p2);
ug.draw(snake);
}
public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) {
ug = ug.apply(new UTranslate(x, 0));
final FtileGeometry geo = getFtile1().calculateDimension(getStringBounder());
if (geo.hasPointOut() == false) {
return;
}
final Point2D p1 = translate0.getTranslated(new Point2D.Double(geo.getLeft(), geo.getOutY()));
final Point2D p2 = translate0.getTranslated(new Point2D.Double(geo.getLeft(), height));
final Snake snake = new Snake(arrowColor, Arrows.asToDown());
if (Display.isNull(label) == false) {
snake.setLabel(getTextBlock(label));
}
final Point2D mp1a = translate1.getTranslated(p1);
final Point2D mp2b = translate2.getTranslated(p2);
final double middle = mp2b.getY() - 14;
snake.addPoint(mp1a);
snake.addPoint(mp1a.getX(), middle);
snake.addPoint(mp2b.getX(), middle);
snake.addPoint(mp2b);
ug.draw(snake);
}
}
}

View File

@ -0,0 +1,99 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.activitydiagram3.ftile.vertical;
import java.util.Collections;
import java.util.Set;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.UShape;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public class FtileThinSplit extends AbstractFtile {
private double width;
private double first;
private double last;
private final double height = 1.5;
private final HtmlColor colorBar;
private final Swimlane swimlane;
public FtileThinSplit(ISkinParam skinParam, HtmlColor colorBar, Swimlane swimlane) {
super(skinParam);
this.colorBar = colorBar;
this.swimlane = swimlane;
}
public void setGeom(double first, double last, double width) {
this.width = width;
this.first = first;
this.last = last;
}
public FtileGeometry calculateDimension(StringBounder stringBounder) {
return new FtileGeometry(width, height, width / 2, 0, height);
}
public void drawU(UGraphic ug) {
// final URectangle rect = new URectangle(width, height);
final UShape rect = new ULine(last - first, 0);
ug = ug.apply(new UTranslate(first, 0));
ug.apply(new UChangeColor(colorBar)).apply(new UStroke(1.5)).draw(rect);
}
public Set<Swimlane> getSwimlanes() {
return Collections.singleton(swimlane);
}
public Swimlane getSwimlaneIn() {
return swimlane;
}
public Swimlane getSwimlaneOut() {
return swimlane;
}
}

View File

@ -0,0 +1,148 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*/
package net.sourceforge.plantuml.bpm;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.SkinParam;
import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
public class BpmDiagram extends UmlDiagram {
private final BpmElement start = new BpmElement(null, BpmElementType.START);
private BpmElement last = start;
private List<BpmEvent> events = new ArrayList<BpmEvent>();
public DiagramDescription getDescription() {
return new DiagramDescription("(Bpm Diagram)");
}
@Override
public UmlDiagramType getUmlDiagramType() {
return UmlDiagramType.BPM;
}
@Override
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException {
final double dpiFactor = 1;
final double margin = 10;
final ImageBuilder imageBuilder = new ImageBuilder(getSkinParam(), dpiFactor,
fileFormatOption.isWithMetadata() ? getMetadata() : null, getWarningOrError(), margin, margin,
getAnimation());
imageBuilder.setUDrawable(getUDrawable());
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os);
}
private UDrawable getUDrawable() {
final Grid grid = createGrid();
final GridArray gridArray = grid.toArray(SkinParam.create(getUmlDiagramType()));
gridArray.addEdges(edges);
System.err.println("gridArray=" + gridArray);
return gridArray;
}
public CommandExecutionResult addEvent(BpmEvent event) {
this.events.add(event);
return CommandExecutionResult.ok();
}
private Coord current;
private final List<BpmEdge> edges = new ArrayList<BpmEdge>();
private Grid createGrid() {
final Grid grid = new Grid();
this.current = grid.getRoot();
this.edges.clear();
grid.getCell(current).setData(start);
for (BpmEvent event : events) {
if (event instanceof BpmEventAdd) {
addInGrid(grid, ((BpmEventAdd) event).getElement());
} else if (event instanceof BpmEventResume) {
final String idDestination = ((BpmEventResume) event).getId();
current = grid.getById(idDestination);
last = (BpmElement) grid.getCell(current).getData();
if (last == null) {
throw new IllegalStateException();
}
final Navigator<Line> nav = grid.linesOf(current);
final Line newLine = new Line();
nav.insertAfter(newLine);
final Row row = current.getRow();
current = new Coord(row, newLine);
} else if (event instanceof BpmEventGoto) {
final String idDestination = ((BpmEventGoto) event).getId();
edges.add(new BpmEdge(last, (BpmElement) grid.getCell(grid.getById(idDestination)).getData()));
current = grid.getById(idDestination);
last = (BpmElement) grid.getCell(current).getData();
if (last == null) {
throw new IllegalStateException();
}
final Navigator<Line> nav = grid.linesOf(current);
final Line newLine = new Line();
nav.insertAfter(newLine);
final Row row = current.getRow();
current = new Coord(row, newLine);
} else {
throw new IllegalStateException();
}
}
return grid;
}
private void addInGrid(Grid grid, BpmElement element) {
final Navigator<Row> nav = grid.rowsOf(current);
final Row newRow = new Row();
nav.insertAfter(newRow);
current = new Coord(newRow, current.getLine());
grid.getCell(current).setData(element);
edges.add(new BpmEdge(last, element));
last = element;
}
}

View File

@ -0,0 +1,67 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.bpm;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.command.Command;
import net.sourceforge.plantuml.command.UmlDiagramFactory;
import net.sourceforge.plantuml.core.DiagramType;
public class BpmDiagramFactory extends UmlDiagramFactory {
public BpmDiagramFactory(DiagramType type) {
super(DiagramType.BPM);
}
@Override
protected List<Command> createCommands() {
final List<Command> result = new ArrayList<Command>();
result.add(new CommandDockedEvent());
result.add(new CommandMerge());
result.add(new CommandResume());
result.add(new CommandGoto());
return result;
}
@Override
public AbstractPSystem createEmptyDiagram() {
return new BpmDiagram();
}
}

View File

@ -0,0 +1,63 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*/
package net.sourceforge.plantuml.bpm;
public class BpmEdge {
private final BpmElement from;
private final BpmElement to;
public BpmEdge(BpmElement from, BpmElement to) {
if (from == null || to == null) {
throw new IllegalArgumentException();
}
this.from = from;
this.to = to;
}
public final BpmElement getFrom() {
return from;
}
public final BpmElement getTo() {
return to;
}
@Override
public String toString() {
return from.toString() + "-->" + to.toString();
}
}

View File

@ -0,0 +1,118 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*/
package net.sourceforge.plantuml.bpm;
import java.awt.Font;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.SkinParamUtils;
import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle;
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileBox;
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileCircleStart;
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamond;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.ugraphic.UFont;
public class BpmElement implements Placeable {
private final String id;
private final BpmElementType type;
private final Display display;
public BpmElement(String id, BpmElementType type, String label) {
this.id = id;
this.type = type;
this.display = Display.getWithNewlines(label);
}
public BpmElement(String id, BpmElementType type) {
this(id, type, null);
}
@Override
public String toString() {
return type.toString() + "(" + id + ")";
}
public BpmElementType getType() {
return type;
}
public final Display getDisplay() {
return display;
}
public TextBlock toTextBlock(ISkinParam skinParam) {
if (type == BpmElementType.START) {
return new FtileCircleStart(skinParam, HtmlColorUtils.BLACK, null);
}
if (type == BpmElementType.MERGE) {
final HtmlColor borderColor = SkinParamUtils.getColor(skinParam, ColorParam.activityBorder, null);
final HtmlColor backColor = SkinParamUtils.getColor(skinParam, ColorParam.activityBackground, null);
return new FtileDiamond(skinParam, backColor, borderColor, null);
}
if (type == BpmElementType.DOCKED_EVENT) {
final UFont font = new UFont("Serif", Font.PLAIN, 14);
return new FtileBox(skinParam, display, font, null, BoxStyle.PLAIN);
}
final UFont font = new UFont("Serif", Font.PLAIN, 14);
final FontConfiguration fc = new FontConfiguration(font, HtmlColorUtils.RED, HtmlColorUtils.RED, false);
if (Display.isNull(display)) {
return Display.getWithNewlines(type.toString()).create(fc, HorizontalAlignment.LEFT, skinParam);
}
return display.create(fc, HorizontalAlignment.LEFT, skinParam);
}
private Dimension2D dimension;
public Dimension2D getDimension(StringBounder stringBounder, ISkinParam skinParam) {
if (dimension == null) {
dimension = toTextBlock(skinParam).calculateDimension(stringBounder);
}
return dimension;
}
public final String getId() {
return id;
}
}

View File

@ -0,0 +1,41 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*/
package net.sourceforge.plantuml.bpm;
public enum BpmElementType {
START, END, MERGE, DOCKED_EVENT
}

View File

@ -0,0 +1,38 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*/
package net.sourceforge.plantuml.bpm;
public interface BpmEvent {
}

View File

@ -0,0 +1,48 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*/
package net.sourceforge.plantuml.bpm;
public class BpmEventAdd implements BpmEvent {
private final BpmElement element;
public BpmEventAdd(BpmElement element) {
this.element = element;
}
public final BpmElement getElement() {
return element;
}
}

View File

@ -0,0 +1,48 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*/
package net.sourceforge.plantuml.bpm;
public class BpmEventGoto implements BpmEvent {
private final String id;
public BpmEventGoto(String id) {
this.id = id;
}
public final String getId() {
return id;
}
}

View File

@ -0,0 +1,48 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*/
package net.sourceforge.plantuml.bpm;
public class BpmEventResume implements BpmEvent {
private final String id;
public BpmEventResume(String id) {
this.id = id;
}
public final String getId() {
return id;
}
}

View File

@ -0,0 +1,58 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.bpm;
public class Cell {
private Placeable data;
public final Placeable getData() {
return data;
}
public final void setData(Placeable data) {
this.data = data;
}
@Override
public String toString() {
if (data == null) {
return super.toString();
}
return super.toString() + " " + data;
}
}

View File

@ -0,0 +1,49 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.bpm;
import java.util.Comparator;
import java.util.List;
public interface Chain<O> extends Comparator<O> {
public Navigator<O> navigator(O data);
public boolean contains(O data);
public List<O> toList();
}

View File

@ -0,0 +1,214 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.bpm;
import java.util.ArrayList;
import java.util.Collections;
import java.util.ConcurrentModificationException;
import java.util.List;
public class ChainImpl<O> implements Chain<O> {
private final List<O> positive = new ArrayList<O>();
private final List<O> negative = new ArrayList<O>();
private int currentVersion;
public List<O> toList() {
final List<O> result = new ArrayList<O>();
for (O element : negative) {
if (element != null) {
result.add(0, element);
}
}
for (O element : positive) {
if (element != null) {
result.add(element);
}
}
return Collections.unmodifiableList(result);
}
public ChainImpl(O root) {
if (root == null) {
throw new IllegalArgumentException();
}
this.positive.add(root);
}
private int updateStructuralVersion() {
currentVersion++;
return currentVersion;
}
public boolean contains(O data) {
if (data == null) {
throw new IllegalArgumentException();
}
for (int i = 0; i < Math.max(positive.size(), negative.size()); i++) {
if (i < positive.size() && data == positive.get(i)) {
return true;
}
if (i < negative.size() && data == negative.get(i)) {
return true;
}
}
return false;
}
public Navigator<O> navigator(O data) {
if (data == null) {
throw new IllegalArgumentException();
}
for (int i = 0; i < Math.max(positive.size(), negative.size()); i++) {
if (i < positive.size() && data == positive.get(i)) {
final InternalNavigator result = new InternalNavigator(i, currentVersion);
assert result.get() == data;
return result;
}
if (i < negative.size() && data == negative.get(i)) {
final InternalNavigator result = new InternalNavigator(-i - 1, currentVersion);
assert result.get() == data;
return result;
}
}
throw new IllegalArgumentException();
}
private O getInternal(int position) {
ensure(position);
if (position >= 0) {
return positive.get(position);
} else {
return negative.get(-position - 1);
}
}
private void setInternal(int position, O data) {
if (data == null) {
throw new IllegalArgumentException();
}
ensure(position);
if (position >= 0) {
positive.set(position, data);
} else {
negative.set(-position - 1, data);
}
}
private void insertInternal(int position, O data) {
if (data == null) {
throw new IllegalArgumentException();
}
ensure(position);
if (position >= 0) {
positive.add(position, data);
} else {
negative.add(-position - 1, data);
}
}
private void ensure(int position) {
if (position >= 0) {
ensureInternal(position, positive);
} else {
ensureInternal(-position - 1, negative);
}
}
private void ensureInternal(int position, List<O> list) {
assert position >= 0 : "position=" + position;
while (list.size() <= position) {
list.add(null);
}
assert list.size() > position;
// Just check that list.get(position) does not throw Exception
assert list.get(position) != this;
}
class InternalNavigator implements Navigator<O> {
private int position = 0;
private int version;
private InternalNavigator(int position, int version) {
this.position = position;
this.version = version;
}
private void checkConsistency() {
if (version != currentVersion) {
throw new ConcurrentModificationException();
}
}
public O next() {
checkConsistency();
position++;
return get();
}
public O previous() {
checkConsistency();
position--;
return get();
}
public O get() {
checkConsistency();
return getInternal(position);
}
public void set(O data) {
checkConsistency();
setInternal(position, data);
}
public void insertBefore(O data) {
version = updateStructuralVersion();
insertInternal(position, data);
}
public void insertAfter(O data) {
version = updateStructuralVersion();
insertInternal(position + 1, data);
}
}
public int compare(O a, O b) {
throw new UnsupportedOperationException();
}
}

View File

@ -0,0 +1,66 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.bpm;
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.RegexResult;
public class CommandDockedEvent extends SingleLineCommand2<BpmDiagram> {
public CommandDockedEvent() {
super(getRegexConcat());
}
static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf(":"), //
new RegexLeaf("LABEL", "(.*)"), //
new RegexLeaf("STYLE", ";"), //
new RegexLeaf("$"));
}
@Override
protected CommandExecutionResult executeArg(BpmDiagram diagram, RegexResult arg) {
final String label = arg.get("LABEL", 0);
final BpmEvent event = new BpmEventAdd(new BpmElement(null, BpmElementType.DOCKED_EVENT, label));
return diagram.addEvent(event);
}
}

View File

@ -0,0 +1,64 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.bpm;
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.RegexResult;
public class CommandGoto extends SingleLineCommand2<BpmDiagram> {
public CommandGoto() {
super(getRegexConcat());
}
static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("goto"), //
new RegexLeaf("[%s]+"), //
new RegexLeaf("ID", "([\\p{L}0-9_.@]+)"), //
new RegexLeaf("$"));
}
@Override
protected CommandExecutionResult executeArg(BpmDiagram diagram, RegexResult arg) {
final BpmEvent event = new BpmEventGoto(arg.get("ID", 0));
return diagram.addEvent(event);
}
}

View File

@ -0,0 +1,64 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.bpm;
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.RegexResult;
public class CommandMerge extends SingleLineCommand2<BpmDiagram> {
public CommandMerge() {
super(getRegexConcat());
}
static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("ID", "([\\p{L}0-9_.@]+)"), //
new RegexLeaf(":?"), //
new RegexLeaf("\\<\\+\\>"), //
new RegexLeaf("$"));
}
@Override
protected CommandExecutionResult executeArg(BpmDiagram diagram, RegexResult arg) {
final BpmEvent event = new BpmEventAdd(new BpmElement(arg.get("ID", 0), BpmElementType.MERGE, null));
return diagram.addEvent(event);
}
}

View File

@ -0,0 +1,64 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.bpm;
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.RegexResult;
public class CommandResume extends SingleLineCommand2<BpmDiagram> {
public CommandResume() {
super(getRegexConcat());
}
static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("resume"), //
new RegexLeaf("[%s]+"), //
new RegexLeaf("ID", "([\\p{L}0-9_.@]+)"), //
new RegexLeaf("$"));
}
@Override
protected CommandExecutionResult executeArg(BpmDiagram diagram, RegexResult arg) {
final BpmEvent event = new BpmEventResume(arg.get("ID", 0));
return diagram.addEvent(event);
}
}

View File

@ -0,0 +1,70 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.bpm;
public class Coord {
private final Row row;
private final Line line;
public Coord(Row row, Line line) {
if (line == null || row == null) {
throw new IllegalArgumentException();
}
this.line = line;
this.row = row;
}
public final Row getRow() {
return row;
}
public final Line getLine() {
return line;
}
@Override
public int hashCode() {
return row.hashCode() + line.hashCode();
}
@Override
public boolean equals(Object obj) {
final Coord other = (Coord) obj;
return this.row == other.row && this.line == other.line;
}
}

View File

@ -0,0 +1,143 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.bpm;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sourceforge.plantuml.ISkinParam;
public class Grid {
private final Chain<Row> rows;
private final Chain<Line> lines;
private final Coord root;
private final Map<Coord, Cell> cells = new HashMap<Coord, Cell>();
public Grid() {
this.root = new Coord(new Row(), new Line());
this.rows = new ChainImpl<Row>(root.getRow());
this.lines = new ChainImpl<Line>(root.getLine());
this.cells.put(root, new Cell());
}
public Cell getCell(Coord coord) {
return getCell(coord.getRow(), coord.getLine());
}
public Cell getCell(Row row, Line line) {
if (rows.contains(row) == false) {
throw new IllegalArgumentException();
}
if (lines.contains(line) == false) {
throw new IllegalArgumentException();
}
final Coord coord = new Coord(row, line);
Cell result = cells.get(coord);
if (result == null) {
result = new Cell();
cells.put(coord, result);
}
return result;
}
public Coord getById(String id) {
for (Map.Entry<Coord, Cell> ent : cells.entrySet()) {
final Cell cell = ent.getValue();
if (cell == null || cell.getData() == null) {
continue;
}
if (id.equals(cell.getData().getId())) {
return ent.getKey();
}
}
return null;
}
public final Coord getRoot() {
return root;
}
public final Chain<Row> rows() {
return rows;
}
public final Chain<Line> lines() {
return lines;
}
private final Coord getCoord(Cell cell) {
for (Map.Entry<Coord, Cell> ent : cells.entrySet()) {
if (ent.getValue() == cell) {
return ent.getKey();
}
}
throw new IllegalArgumentException();
}
public final Navigator<Row> rowsOf(Coord coord) {
return rows.navigator(coord.getRow());
}
public final Navigator<Line> linesOf(Coord coord) {
return lines.navigator(coord.getLine());
}
public final Navigator<Row> rowsOf(Cell cell) {
return rowsOf(getCoord(cell));
}
public final Navigator<Line> linesOf(Cell cell) {
return linesOf(getCoord(cell));
}
public final GridArray toArray(ISkinParam skinParam) {
final List<Row> rows = this.rows.toList();
final List<Line> lines = this.lines.toList();
final GridArray result = new GridArray(skinParam, rows.size(), lines.size());
for (Map.Entry<Coord, Cell> ent : cells.entrySet()) {
final int r = rows.indexOf(ent.getKey().getRow());
final int l = lines.indexOf(ent.getKey().getLine());
if (r == -1 || l == -1) {
throw new IllegalStateException();
}
result.setData(r, l, ent.getValue().getData());
}
return result;
}
}

View File

@ -0,0 +1,194 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.bpm;
import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public class GridArray implements UDrawable {
private final int rows;
private final int lines;
private final Placeable data[][];
private final ISkinParam skinParam;
private final List<BpmEdge> edges = new ArrayList<BpmEdge>();
public GridArray(ISkinParam skinParam, int rows, int lines) {
this.skinParam = skinParam;
this.rows = rows;
this.lines = lines;
this.data = new Placeable[rows][lines];
}
@Override
public String toString() {
return "" + lines + "x" + rows;
}
public void setData(int r, int l, Placeable element) {
data[r][l] = element;
}
public Placeable getData(int r, int l) {
return data[r][l];
}
public final int getRows() {
return rows;
}
public final int getLines() {
return lines;
}
private double getHeightOfLine(StringBounder stringBounder, int line) {
double height = 0;
for (int i = 0; i < rows; i++) {
final Placeable cell = data[i][line];
if (cell == null) {
continue;
}
height = Math.max(height, cell.getDimension(stringBounder, skinParam).getHeight());
}
return height;
}
private double getWidthOfRow(StringBounder stringBounder, int row) {
double width = 0;
for (int i = 0; i < lines; i++) {
final Placeable cell = data[row][i];
if (cell == null) {
continue;
}
width = Math.max(width, cell.getDimension(stringBounder, skinParam).getWidth());
}
return width;
}
private final double margin = 30;
public void drawU(UGraphic ug) {
// printMe();
final StringBounder stringBounder = ug.getStringBounder();
for (BpmEdge edge : edges) {
// System.err.println("Drawing " + edge);
final int from[] = getCoord(edge.getFrom());
final int to[] = getCoord(edge.getTo());
final Point2D pt1 = getCenterOf(stringBounder, from[0], from[1]);
final Point2D pt2 = getCenterOf(stringBounder, to[0], to[1]);
drawArrow(ug, pt1, pt2);
}
double dy = 0;
for (int l = 0; l < lines; l++) {
double dx = 0;
final double heightOfLine = getHeightOfLine(stringBounder, l);
for (int r = 0; r < rows; r++) {
final double widthOfRow = getWidthOfRow(stringBounder, r);
final Placeable cell = data[r][l];
if (cell != null) {
final Dimension2D dim = cell.getDimension(stringBounder, skinParam);
cell.toTextBlock(skinParam).drawU(
ug.apply(new UTranslate(dx + (widthOfRow - dim.getWidth()) / 2, dy
+ (heightOfLine - dim.getHeight()) / 2)));
}
dx += widthOfRow + margin;
}
dy += heightOfLine + margin;
}
}
private void drawArrow(UGraphic ug, Point2D pt1, Point2D pt2) {
ug = ug.apply(new UChangeColor(HtmlColorUtils.BLUE));
final ULine line = new ULine(pt2.getX() - pt1.getX(), pt2.getY() - pt1.getY());
ug.apply(new UTranslate(pt1)).draw(line);
}
private Point2D getCenterOf(StringBounder stringBounder, int r, int l) {
double x = getWidthOfRow(stringBounder, r) / 2;
for (int i = 0; i < r; i++) {
final double widthOfRow = getWidthOfRow(stringBounder, i);
x += widthOfRow + margin;
}
double y = getHeightOfLine(stringBounder, l) / 2;
for (int i = 0; i < l; i++) {
final double heightOfLine = getHeightOfLine(stringBounder, i);
y += heightOfLine + margin;
}
return new Point2D.Double(x, y);
}
private int[] getCoord(Placeable element) {
for (int l = 0; l < lines; l++) {
for (int r = 0; r < rows; r++) {
final Placeable cell = data[r][l];
if (cell == element) {
return new int[] { r, l };
}
}
}
throw new IllegalArgumentException();
}
private void printMe() {
for (int l = 0; l < lines; l++) {
for (int r = 0; r < rows; r++) {
final Placeable cell = data[r][l];
System.err.print(cell);
System.err.print(" ; ");
}
System.err.println();
}
}
public void addEdges(List<BpmEdge> edges) {
this.edges.addAll(edges);
}
}

View File

@ -0,0 +1,39 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.bpm;
public class Line {
}

View File

@ -0,0 +1,52 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.bpm;
public interface Navigator<O> {
public O next();
public O previous();
public O get();
public void set(O data);
public void insertBefore(O data);
public void insertAfter(O data);
}

View File

@ -0,0 +1,52 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.bpm;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
public interface Placeable {
public Dimension2D getDimension(StringBounder stringBounder, ISkinParam skinParam);
public TextBlock toTextBlock(ISkinParam skinParam);
public String getId();
}

View File

@ -0,0 +1,40 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.bpm;
public class Row {
}

View File

@ -86,7 +86,7 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
new RegexConcat(
//
new RegexLeaf("ARROW_HEAD1", "([%s]+[ox]|[#\\[<*+^}]|[<\\[]\\||\\}o|\\}\\||\\|o|\\|\\|)?"), //
new RegexLeaf("ARROW_HEAD1", "([%s]+[ox]|[)#\\[<*+^}]|[<\\[]\\||\\}o|\\}\\||\\|o|\\|\\|)?"), //
new RegexLeaf("ARROW_BODY1", "([-=.]+)"), //
new RegexLeaf("ARROW_STYLE1",
"(?:\\[((?:#\\w+|dotted|dashed|plain|bold|hidden|norank)(?:,#\\w+|,dotted|,dashed|,plain|,bold|,hidden|,norank)*)\\])?"),
@ -95,7 +95,7 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
new RegexLeaf("ARROW_STYLE2",
"(?:\\[((?:#\\w+|dotted|dashed|plain|bold|hidden|norank)(?:,#\\w+|,dotted|,dashed|,plain|,bold|,hidden|,norank)*)\\])?"),
new RegexLeaf("ARROW_BODY2", "([-=.]*)"), //
new RegexLeaf("ARROW_HEAD2", "([ox][%s]+|[#\\]>*+^\\{]|\\|[>\\]]|o\\{|\\|\\{|o\\||\\|\\|)?")), //
new RegexLeaf("ARROW_HEAD2", "([ox][%s]+|[(#\\]>*+^\\{]|\\|[>\\]]|o\\{|\\|\\{|o\\||\\|\\|)?")), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("SECOND_LABEL", "(?:[%g]([^%g]+)[%g])?"), new RegexLeaf("[%s]*"), //
@ -445,6 +445,9 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
if ("#".equals(s)) {
return LinkDecor.SQUARRE;
}
if (")".equals(s)) {
return LinkDecor.PARENTHESIS;
}
return LinkDecor.NONE;
}
@ -492,6 +495,9 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
if ("#".equals(s)) {
return LinkDecor.SQUARRE;
}
if ("(".equals(s)) {
return LinkDecor.PARENTHESIS;
}
return LinkDecor.NONE;
}

View File

@ -35,6 +35,9 @@
*/
package net.sourceforge.plantuml.command;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
import net.sourceforge.plantuml.classdiagram.ClassDiagram;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
@ -60,6 +63,8 @@ public class CommandNamespace extends SingleLineCommand2<ClassDiagram> {
new RegexLeaf("[%s]*"), //
new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
new RegexLeaf("[%s]*"), //
ColorParser.exp1(), //
new RegexLeaf("[%s]*\\{$"));
}
@ -74,9 +79,18 @@ public class CommandNamespace extends SingleLineCommand2<ClassDiagram> {
if (stereotype != null) {
p.setStereotype(new Stereotype(stereotype));
}
final String urlString = arg.get("URL", 0);
if (urlString != null) {
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
final Url url = urlBuilder.getUrl(urlString);
p.addUrl(url);
}
final String color = arg.get("COLOR", 0);
if (color != null) {
p.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(color));
p.setSpecificColorTOBEREMOVED(ColorType.BACK,
diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(color));
}
return CommandExecutionResult.ok();
}

View File

@ -38,13 +38,16 @@ package net.sourceforge.plantuml.core;
import net.sourceforge.plantuml.utils.StartUtils;
public enum DiagramType {
UML, DITAA, DOT, PROJECT, JCCKIT, SALT, FLOW, CREOLE, JUNGLE, CUTE, MATH, LATEX, UNKNOWN;
UML, BPM, DITAA, DOT, PROJECT, JCCKIT, SALT, FLOW, CREOLE, JUNGLE, CUTE, MATH, LATEX, UNKNOWN;
static public DiagramType getTypeFromArobaseStart(String s) {
s = s.toLowerCase();
// if (s.startsWith("@startuml2")) {
// return UML2;
// }
if (StartUtils.startsWithSymbolAnd("startbpm", s)) {
return BPM;
}
if (StartUtils.startsWithSymbolAnd("startuml", s)) {
return UML;
}

View File

@ -82,7 +82,12 @@ public class AtomMath implements Atom {
public void drawU(UGraphic ug) {
final boolean isSvg = ug.matchesProperty("SVG");
final Color back = getColor(background == null ? ug.getParam().getBackcolor() : background, Color.WHITE);
final Color back;
if (isSvg && background == null) {
back = null;
} else {
back = getColor(background == null ? ug.getParam().getBackcolor() : background, Color.WHITE);
}
final Color fore = getColor(foreground, Color.BLACK);
if (isSvg) {
final String svg = math.getSvg(fore, back);

View File

@ -103,10 +103,10 @@ public class PSystemColors extends AbstractPSystem implements UDrawable {
}
public void drawU(UGraphic ug) {
if (paletteCentralColor == null) {
drawFull(ug);
} else {
if (colors.getColorIfValid(paletteCentralColor) instanceof HtmlColorSimple) {
drawPalette(ug);
} else {
drawFull(ug);
}
}

View File

@ -74,7 +74,7 @@ public class EpsGraphics {
public EpsGraphics() {
header.append("%!PS-Adobe-3.0 EPSF-3.0\n");
header.append("%%Creator: PlantUML v" + Version.versionString(10) + "\n");
header.append("%%Creator: PlantUML v" + Version.versionString(15) + "\n");
header.append("%%Title: noTitle\n");
// header.append("%%CreationDate: " + new Date() + "\n");
setcolorgradient.add(new PostScriptCommandRaw("3 index 7 index sub 1 index mul 7 index add", true));

View File

@ -46,6 +46,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import net.sourceforge.plantuml.BlockUml;
import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.SourceStringReader;
@ -80,6 +81,7 @@ public class FtpConnexion {
public synchronized Collection<String> getFiles() {
final List<String> result = new ArrayList<String>(incoming.keySet());
result.addAll(outgoing.keySet());
result.addAll(futureOutgoing);
return Collections.unmodifiableCollection(result);
}
@ -96,6 +98,16 @@ public class FtpConnexion {
return false;
}
public synchronized boolean doesExist(String fileName) {
if (incoming.containsKey(fileName)) {
return true;
}
if (outgoing.containsKey(fileName)) {
return true;
}
return false;
}
public synchronized byte[] getData(String fileName) throws InterruptedException {
if (fileName.startsWith("/")) {
throw new IllegalArgumentException();
@ -104,16 +116,19 @@ public class FtpConnexion {
if (data != null) {
return data.getBytes();
}
do {
if (willExist(fileName) == false) {
return null;
}
final byte data2[] = outgoing.get(fileName);
if (data2 != null) {
return data2;
}
Thread.sleep(200L);
} while (true);
// do {
// if (willExist(fileName) == false) {
// return null;
// }
final byte data2[] = outgoing.get(fileName);
if (data2 == null) {
return new byte[1];
}
// if (data2 != null) {
return data2;
// }
// Thread.sleep(200L);
// } while (true);
}
public synchronized int getSize(String fileName) {
@ -141,8 +156,11 @@ public class FtpConnexion {
final SourceStringReader sourceStringReader = new SourceStringReader(incoming.get(fileName));
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final FileFormat format = getFileFormat();
final DiagramDescription desc = sourceStringReader.generateDiagramDescription(baos, new FileFormatOption(
format));
final DiagramDescription desc = sourceStringReader.generateDiagramDescription(new FileFormatOption(format));
final List<BlockUml> blocks = sourceStringReader.getBlocks();
if (blocks.size() > 0) {
blocks.get(0).getDiagram().exportDiagram(baos, 0, new FileFormatOption(format));
}
final String errorFileName = pngFileName.substring(0, pngFileName.length() - 4) + ".err";
synchronized (this) {
outgoing.remove(pngFileName);

View File

@ -199,12 +199,22 @@ class FtpLoop implements Runnable {
return;
}
myOut("150 Opening");
waitForMe(fileName);
final ServerSocket ss = new ServerSocket(port);
final Socket incoming = ss.accept();
retr(fileName, incoming);
ss.close();
}
private void waitForMe(String fileName) throws InterruptedException {
do {
if (connexion.doesExist(fileName)) {
return;
}
Thread.sleep(200L);
} while (true);
}
private void retrActif(final String s) throws UnknownHostException, IOException, InterruptedException {
String fileName = s.substring("STOR ".length());
fileName = removeStartingsSlash(fileName);
@ -213,6 +223,7 @@ class FtpLoop implements Runnable {
return;
}
myOut("150 Opening");
waitForMe(fileName);
final Socket soc = new Socket(ipClient, port);
retr(fileName, soc);
}

View File

@ -106,7 +106,7 @@ public class FtpServer {
System.out.println("Server Started...");
System.out.println("Waiting for connections...");
System.out.println(" ");
new FtpServer(24242, FileFormat.SVG).go();
new FtpServer(4242, FileFormat.PNG).go();
}
public void processImage(final FtpConnexion connexion, final String name) {

View File

@ -88,13 +88,13 @@ public class GraphvizCrash extends AbstractTextBlock implements IEntityImage {
final long days = (System.currentTimeMillis() - Version.compileTime()) / 1000L / 3600 / 24;
if (days >= 90) {
strings.add("This version of PlantUML is " + days + " days old, so you should");
strings.add(" consider upgrading from http://plantuml.com/download.html");
strings.add(" consider upgrading from http://plantuml.com/download");
}
}
public static void pleaseGoTo(final List<String> strings) {
strings.add(" ");
strings.add("Please go to http://plantuml.com/graphvizdot.html to check your GraphViz version.");
strings.add("Please go to http://plantuml.com/graphviz-dot to check your GraphViz version.");
strings.add(" ");
}

View File

@ -85,7 +85,7 @@ public class EntityImageUseCase extends AbstractEntityImage {
this.desc = tmp;
} else {
final TextBlock stereo = Display.getWithNewlines(stereotype.getLabel(getSkinParam().useGuillemet()))
.create(new FontConfiguration(getSkinParam(), FontParam.ACTOR_STEREOTYPE, stereotype),
.create(new FontConfiguration(getSkinParam(), FontParam.USECASE_STEREOTYPE, stereotype),
HorizontalAlignment.CENTER, skinParam);
this.desc = TextBlockUtils.mergeTB(stereo, tmp, HorizontalAlignment.CENTER);
}

View File

@ -98,7 +98,7 @@ public class TikzGraphics {
}
out(os, "\\begin{document}");
}
out(os, "% generated by Plantuml " + Version.versionString(10));
out(os, "% generated by Plantuml " + Version.versionString(15));
if (hasUrl && withPreamble) {
out(os, "\\tikzset{");
out(os, " href node/.style={");

View File

@ -41,14 +41,19 @@ import java.util.Date;
public class Version {
public static int version() {
return 8059;
return 201708;
}
public static String versionString() {
if (beta() != 0) {
return "" + (version() + 1) + "beta" + beta();
return dotted(version() + 1) + "beta" + beta();
}
return "" + version();
return dotted(version());
}
private static String dotted(int nb) {
final String s = "" + nb;
return s.substring(0, 4) + "." + s.substring(4);
}
public static String versionString(int size) {
@ -65,19 +70,15 @@ public class Version {
}
public static String etag() {
return Integer.toString(version(), 36) + Integer.toString(beta(), 36);
}
private static String int2shortString(int v) {
return Integer.toString(v % 36, 36);
return Integer.toString(version() - 201670, 36) + Integer.toString(beta(), 36);
}
public static String turningId() {
return int2shortString(version()) + int2shortString(beta());
return etag();
}
public static long compileTime() {
return 1489599427097L;
return 1490118065248L;
}
public static String compileTimeString() {