1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-12-22 10:59:01 +00:00

version 2017.11

This commit is contained in:
Arnaud Roques 2017-04-19 20:30:16 +02:00
parent e3a5d8f744
commit 5c62d2c083
98 changed files with 887 additions and 458 deletions

View File

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

View File

@ -81,6 +81,13 @@ public abstract class AbstractPSystem implements Diagram {
return source; return source;
} }
final public long seed() {
if (source == null) {
return 42;
}
return getSource().seed();
}
final public void setSource(UmlSource source) { final public void setSource(UmlSource source) {
this.source = source; this.source = source;
} }
@ -124,7 +131,7 @@ public abstract class AbstractPSystem implements Diagram {
throws IOException { throws IOException {
final long now = System.currentTimeMillis(); final long now = System.currentTimeMillis();
try { try {
return exportDiagramNow(os, index, fileFormatOption); return exportDiagramNow(os, index, fileFormatOption, seed());
} finally { } finally {
if (OptionFlags.getInstance().isEnableStats()) { if (OptionFlags.getInstance().isEnableStats()) {
StatsUtilsIncrement.onceMoreGenerate(System.currentTimeMillis() - now, getClass(), StatsUtilsIncrement.onceMoreGenerate(System.currentTimeMillis() - now, getClass(),
@ -133,7 +140,7 @@ public abstract class AbstractPSystem implements Diagram {
} }
} }
protected abstract ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption) protected abstract ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption,
throws IOException; long seed) throws IOException;
} }

View File

@ -93,7 +93,7 @@ public class BlockUml {
this.data = new ArrayList<CharSequence2>(strings); this.data = new ArrayList<CharSequence2>(strings);
} }
public String getFileOrDirname(FileFormat defaultFileFormat) { public String getFileOrDirname() {
if (OptionFlags.getInstance().isWord()) { if (OptionFlags.getInstance().isWord()) {
return null; return null;
} }
@ -116,9 +116,7 @@ public class BlockUml {
if (result.startsWith("file://")) { if (result.startsWith("file://")) {
result = result.substring("file://".length()); result = result.substring("file://".length());
} }
if (result.contains(".") == false) { result = result.replaceAll("\\.\\w\\w\\w$", "");
result = result + defaultFileFormat.getFileSuffix();
}
return result; return result;
} }

View File

@ -44,6 +44,8 @@ public enum ColorParam {
background(HtmlColorUtils.WHITE, true, ColorType.BACK), background(HtmlColorUtils.WHITE, true, ColorType.BACK),
hyperlink(HtmlColorUtils.BLUE), hyperlink(HtmlColorUtils.BLUE),
activityDiamondBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK),
activityDiamondBorder(HtmlColorUtils.MY_RED, ColorType.LINE),
activityBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), activityBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK),
activityBorder(HtmlColorUtils.MY_RED, ColorType.LINE), activityBorder(HtmlColorUtils.MY_RED, ColorType.LINE),
activityStart(HtmlColorUtils.BLACK), activityStart(HtmlColorUtils.BLACK),

View File

@ -131,6 +131,14 @@ public enum FileFormat {
+ getFileSuffix()); + getFileSuffix());
} }
private File computeFilename(File pngFile, int i) {
if (i == 0) {
return pngFile;
}
final File dir = pngFile.getParentFile();
return new File(dir, computeFilenameInternal(pngFile.getName(), i));
}
private String changeName(String fileName, String replacement) { private String changeName(String fileName, String replacement) {
String result = fileName.replaceAll("\\.\\w+$", replacement); String result = fileName.replaceAll("\\.\\w+$", replacement);
if (result.equals(fileName)) { if (result.equals(fileName)) {
@ -139,15 +147,7 @@ public enum FileFormat {
return result; return result;
} }
public File computeFilename(File pngFile, int i) { private String computeFilenameInternal(String name, int i) {
if (i == 0) {
return pngFile;
}
final File dir = pngFile.getParentFile();
return new File(dir, computeFilename(pngFile.getName(), i));
}
public String computeFilename(String name, int i) {
if (i == 0) { if (i == 0) {
return name; return name;
} }

View File

@ -37,7 +37,6 @@ package net.sourceforge.plantuml;
import java.awt.geom.AffineTransform; import java.awt.geom.AffineTransform;
import java.io.Serializable; import java.io.Serializable;
import java.util.Random;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
@ -52,14 +51,13 @@ public class FileFormatOption implements Serializable {
private final FileFormat fileFormat; private final FileFormat fileFormat;
private final AffineTransform affineTransform; private final AffineTransform affineTransform;
private final boolean withMetadata; private boolean withMetadata;
private final boolean useRedForError; private final boolean useRedForError;
private final String svgLinkTarget; private final String svgLinkTarget;
private final String hoverColor; private final String hoverColor;
private final Random rnd;
public FileFormatOption(FileFormat fileFormat) { public FileFormatOption(FileFormat fileFormat) {
this(fileFormat, null, true, false, "_top", false, null, new Random()); this(fileFormat, null, true, false, "_top", false, null);
} }
public StringBounder getDefaultStringBounder() { public StringBounder getDefaultStringBounder() {
@ -74,16 +72,12 @@ public class FileFormatOption implements Serializable {
return withMetadata; return withMetadata;
} }
public final Random getRandom() {
return rnd;
}
public FileFormatOption(FileFormat fileFormat, boolean withMetadata) { public FileFormatOption(FileFormat fileFormat, boolean withMetadata) {
this(fileFormat, null, false, false, "_top", false, null, new Random()); this(fileFormat, null, false, false, "_top", false, null);
} }
private FileFormatOption(FileFormat fileFormat, AffineTransform at, boolean withMetadata, boolean useRedForError, private FileFormatOption(FileFormat fileFormat, AffineTransform at, boolean withMetadata, boolean useRedForError,
String svgLinkTarget, boolean debugsvek, String hoverColor, Random rnd) { String svgLinkTarget, boolean debugsvek, String hoverColor) {
this.hoverColor = hoverColor; this.hoverColor = hoverColor;
this.fileFormat = fileFormat; this.fileFormat = fileFormat;
this.affineTransform = at; this.affineTransform = at;
@ -91,27 +85,21 @@ public class FileFormatOption implements Serializable {
this.useRedForError = useRedForError; this.useRedForError = useRedForError;
this.svgLinkTarget = svgLinkTarget; this.svgLinkTarget = svgLinkTarget;
this.debugsvek = debugsvek; this.debugsvek = debugsvek;
this.rnd = rnd;
} }
public FileFormatOption withUseRedForError() { public FileFormatOption withUseRedForError() {
return new FileFormatOption(fileFormat, affineTransform, withMetadata, true, svgLinkTarget, debugsvek, return new FileFormatOption(fileFormat, affineTransform, withMetadata, true, svgLinkTarget, debugsvek,
hoverColor, rnd); hoverColor);
} }
public FileFormatOption withSvgLinkTarget(String svgLinkTarget) { public FileFormatOption withSvgLinkTarget(String svgLinkTarget) {
return new FileFormatOption(fileFormat, affineTransform, withMetadata, useRedForError, svgLinkTarget, return new FileFormatOption(fileFormat, affineTransform, withMetadata, useRedForError, svgLinkTarget,
debugsvek, hoverColor, rnd); debugsvek, hoverColor);
} }
public FileFormatOption withHoverColor(String hoverColor) { public FileFormatOption withHoverColor(String hoverColor) {
return new FileFormatOption(fileFormat, affineTransform, withMetadata, useRedForError, svgLinkTarget, return new FileFormatOption(fileFormat, affineTransform, withMetadata, useRedForError, svgLinkTarget,
debugsvek, hoverColor, rnd); debugsvek, hoverColor);
}
public FileFormatOption withFixedRandom() {
return new FileFormatOption(fileFormat, affineTransform, withMetadata, useRedForError, svgLinkTarget,
debugsvek, hoverColor, new Random(42));
} }
@Override @Override
@ -145,4 +133,8 @@ public class FileFormatOption implements Serializable {
return hoverColor; return hoverColor;
} }
public void hideMetadata() {
this.withMetadata = false;
}
} }

View File

@ -97,7 +97,7 @@ public class NewpagedDiagram extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
return diagrams.get(num).exportDiagram(os, 0, fileFormat); return diagrams.get(num).exportDiagram(os, 0, fileFormat);
} }

View File

@ -77,6 +77,7 @@ public class Option {
private boolean textProgressBar = false; private boolean textProgressBar = false;
private int nbThreads = 0; private int nbThreads = 0;
private int ftpPort = -1; private int ftpPort = -1;
private boolean hideMetadata = false;
private File outputDir = null; private File outputDir = null;
private File outputFile = null; private File outputFile = null;
@ -107,7 +108,7 @@ public class Option {
if (s.equalsIgnoreCase("-tsvg") || s.equalsIgnoreCase("-svg")) { if (s.equalsIgnoreCase("-tsvg") || s.equalsIgnoreCase("-svg")) {
setFileFormatOption(new FileFormatOption(FileFormat.SVG)); setFileFormatOption(new FileFormatOption(FileFormat.SVG));
} else if (s.equalsIgnoreCase("-tsvg:nornd") || s.equalsIgnoreCase("-svg:nornd")) { } else if (s.equalsIgnoreCase("-tsvg:nornd") || s.equalsIgnoreCase("-svg:nornd")) {
setFileFormatOption(new FileFormatOption(FileFormat.SVG).withFixedRandom()); setFileFormatOption(new FileFormatOption(FileFormat.SVG));
} else if (s.equalsIgnoreCase("-thtml") || s.equalsIgnoreCase("-html")) { } else if (s.equalsIgnoreCase("-thtml") || s.equalsIgnoreCase("-html")) {
setFileFormatOption(new FileFormatOption(FileFormat.HTML)); setFileFormatOption(new FileFormatOption(FileFormat.HTML));
} else if (s.equalsIgnoreCase("-tscxml") || s.equalsIgnoreCase("-scxml")) { } else if (s.equalsIgnoreCase("-tscxml") || s.equalsIgnoreCase("-scxml")) {
@ -242,7 +243,7 @@ public class Option {
} else if (s.equalsIgnoreCase("-keepfiles") || s.equalsIgnoreCase("-keepfile")) { } else if (s.equalsIgnoreCase("-keepfiles") || s.equalsIgnoreCase("-keepfile")) {
System.err.println("-keepfiles option has been removed. Please consider -debugsvek instead"); System.err.println("-keepfiles option has been removed. Please consider -debugsvek instead");
} else if (s.equalsIgnoreCase("-metadata")) { } else if (s.equalsIgnoreCase("-metadata")) {
OptionFlags.getInstance().setMetadata(true); OptionFlags.getInstance().setExtractFromMetadata(true);
} else if (s.equalsIgnoreCase("-logdata")) { } else if (s.equalsIgnoreCase("-logdata")) {
i++; i++;
if (i == arg.length) { if (i == arg.length) {
@ -305,6 +306,8 @@ public class Option {
splash = true; splash = true;
} else if (s.equalsIgnoreCase("-progress")) { } else if (s.equalsIgnoreCase("-progress")) {
textProgressBar = true; textProgressBar = true;
} else if (s.equalsIgnoreCase("-nometadata")) {
hideMetadata = true;
} else if (StringUtils.goLowerCase(s).startsWith("-ftp")) { } else if (StringUtils.goLowerCase(s).startsWith("-ftp")) {
final int x = s.indexOf(':'); final int x = s.indexOf(':');
if (x == -1) { if (x == -1) {
@ -449,10 +452,12 @@ public class Option {
} }
public FileFormatOption getFileFormatOption() { public FileFormatOption getFileFormatOption() {
// final FileFormatOption fileFormatOption = new FileFormatOption(getFileFormat());
if (debugsvek) { if (debugsvek) {
fileFormatOption.setDebugSvek(true); fileFormatOption.setDebugSvek(true);
} }
if (hideMetadata) {
fileFormatOption.hideMetadata();
}
return fileFormatOption; return fileFormatOption;
} }

View File

@ -83,7 +83,7 @@ public class OptionFlags {
private void reset(boolean exit) { private void reset(boolean exit) {
// keepTmpFiles = false; // keepTmpFiles = false;
verbose = false; verbose = false;
metadata = false; extractFromMetadata = false;
word = false; word = false;
systemExit = exit; systemExit = exit;
GraphvizUtils.setDotExecutable(null); GraphvizUtils.setDotExecutable(null);
@ -105,7 +105,7 @@ public class OptionFlags {
// private boolean keepTmpFiles; // private boolean keepTmpFiles;
private boolean verbose; private boolean verbose;
private boolean metadata; private boolean extractFromMetadata;
private boolean word; private boolean word;
private boolean systemExit; private boolean systemExit;
private boolean gui; private boolean gui;
@ -139,12 +139,12 @@ public class OptionFlags {
this.verbose = verbose; this.verbose = verbose;
} }
public final boolean isMetadata() { public final boolean isExtractFromMetadata() {
return metadata; return extractFromMetadata;
} }
public final void setMetadata(boolean metadata) { public final void setExtractFromMetadata(boolean extractFromMetadata) {
this.metadata = metadata; this.extractFromMetadata = extractFromMetadata;
} }
public final boolean isWord() { public final boolean isWord() {

View File

@ -103,6 +103,7 @@ public class OptionPrint {
System.out.println(" -charset xxx\tTo use a specific charset (default is " + charset + ")"); System.out.println(" -charset xxx\tTo use a specific charset (default is " + charset + ")");
System.out.println(" -e[x]clude pattern\tTo exclude files that match the provided pattern"); System.out.println(" -e[x]clude pattern\tTo exclude files that match the provided pattern");
System.out.println(" -metadata\t\tTo retrieve PlantUML sources from PNG images"); System.out.println(" -metadata\t\tTo retrieve PlantUML sources from PNG images");
System.out.println(" -nometadata\t\tTo NOT export metadata in PNG/SVG generated files");
System.out.println(" -version\t\tTo display information about PlantUML and Java versions"); System.out.println(" -version\t\tTo display information about PlantUML and Java versions");
System.out.println(" -checkversion\tTo check if a newer version is available for download"); System.out.println(" -checkversion\tTo check if a newer version is available for download");
System.out.println(" -v[erbose]\t\tTo have log information"); System.out.println(" -v[erbose]\t\tTo have log information");

View File

@ -105,6 +105,7 @@ public class PSystemBuilder {
int cpt = 0; int cpt = 0;
for (CharSequence2 s : strings2) { for (CharSequence2 s : strings2) {
if (s.getPreprocessorError() != null) { if (s.getPreprocessorError() != null) {
Log.error("Preprocessor Error: " + s.getPreprocessorError());
final ErrorUml singleError = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, s.getPreprocessorError(), cpt, final ErrorUml singleError = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, s.getPreprocessorError(), cpt,
s.getLocation()); s.getLocation());
return new PSystemError(umlSource, singleError, Collections.<String> emptyList()); return new PSystemError(umlSource, singleError, Collections.<String> emptyList());

View File

@ -120,7 +120,7 @@ public class PSystemError extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
if (fileFormat.getFileFormat() == FileFormat.ATXT || fileFormat.getFileFormat() == FileFormat.UTXT) { if (fileFormat.getFileFormat() == FileFormat.ATXT || fileFormat.getFileFormat() == FileFormat.UTXT) {
final UGraphicTxt ugt = new UGraphicTxt(); final UGraphicTxt ugt = new UGraphicTxt();
@ -146,7 +146,7 @@ public class PSystemError extends AbstractPSystem {
// udrawable = addMessage(udrawable); // udrawable = addMessage(udrawable);
// } // }
imageBuilder.setUDrawable(udrawable); imageBuilder.setUDrawable(udrawable);
return imageBuilder.writeImageTOBEMOVED(fileFormat, os); return imageBuilder.writeImageTOBEMOVED(fileFormat, seed(), os);
} }
private TextBlockBackcolored getWelcome() throws IOException { private TextBlockBackcolored getWelcome() throws IOException {

View File

@ -55,7 +55,7 @@ import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
public class PSystemUtils { public class PSystemUtils {
public static List<FileImageData> exportDiagrams(Diagram system, File suggestedFile, public static List<FileImageData> exportDiagrams(Diagram system, SuggestedFile suggestedFile,
FileFormatOption fileFormatOption) throws IOException { FileFormatOption fileFormatOption) throws IOException {
if (system instanceof NewpagedDiagram) { if (system instanceof NewpagedDiagram) {
return exportDiagramsNewpaged((NewpagedDiagram) system, suggestedFile, fileFormatOption); return exportDiagramsNewpaged((NewpagedDiagram) system, suggestedFile, fileFormatOption);
@ -72,13 +72,13 @@ public class PSystemUtils {
return exportDiagramsDefault(system, suggestedFile, fileFormatOption); return exportDiagramsDefault(system, suggestedFile, fileFormatOption);
} }
private static List<FileImageData> exportDiagramsNewpaged(NewpagedDiagram system, File suggestedFile, private static List<FileImageData> exportDiagramsNewpaged(NewpagedDiagram system, SuggestedFile suggestedFile,
FileFormatOption fileFormat) throws IOException { FileFormatOption fileFormat) throws IOException {
final List<FileImageData> result = new ArrayList<FileImageData>(); final List<FileImageData> result = new ArrayList<FileImageData>();
final int nbImages = system.getNbImages(); final int nbImages = system.getNbImages();
for (int i = 0; i < nbImages; i++) { for (int i = 0; i < nbImages; i++) {
final File f = fileFormat.getFileFormat().computeFilename(suggestedFile, i); final File f = suggestedFile.getFile(i);
if (canFileBeWritten(f) == false) { if (canFileBeWritten(f) == false) {
return result; return result;
} }
@ -113,18 +113,18 @@ public class PSystemUtils {
return true; return true;
} }
static private List<FileImageData> exportDiagramsDefault(Diagram system, File suggestedFile, static private List<FileImageData> exportDiagramsDefault(Diagram system, SuggestedFile suggestedFile,
FileFormatOption fileFormat) throws IOException { FileFormatOption fileFormat) throws IOException {
if (suggestedFile.exists() && suggestedFile.isDirectory()) { if (suggestedFile.getFile(0).exists() && suggestedFile.getFile(0).isDirectory()) {
throw new IllegalArgumentException("File is a directory " + suggestedFile); throw new IllegalArgumentException("File is a directory " + suggestedFile);
} }
OutputStream os = null; OutputStream os = null;
ImageData imageData = null; ImageData imageData = null;
try { try {
if (canFileBeWritten(suggestedFile) == false) { if (PSystemUtils.canFileBeWritten(suggestedFile.getFile(0)) == false) {
return Collections.emptyList(); return Collections.emptyList();
} }
os = new BufferedOutputStream(new FileOutputStream(suggestedFile)); os = new BufferedOutputStream(new FileOutputStream(suggestedFile.getFile(0)));
// system.exportDiagram(os, null, 0, fileFormat); // system.exportDiagram(os, null, 0, fileFormat);
imageData = system.exportDiagram(os, 0, fileFormat); imageData = system.exportDiagram(os, 0, fileFormat);
} finally { } finally {
@ -132,22 +132,22 @@ public class PSystemUtils {
os.close(); os.close();
} }
} }
return Arrays.asList(new FileImageData(suggestedFile, imageData)); return Arrays.asList(new FileImageData(suggestedFile.getFile(0), imageData));
} }
static private List<FileImageData> exportDiagramsActivityDiagram3(ActivityDiagram3 system, File suggestedFile, static private List<FileImageData> exportDiagramsActivityDiagram3(ActivityDiagram3 system,
FileFormatOption fileFormat) throws IOException { SuggestedFile suggestedFile, FileFormatOption fileFormat) throws IOException {
if (suggestedFile.exists() && suggestedFile.isDirectory()) { if (suggestedFile.getFile(0).exists() && suggestedFile.getFile(0).isDirectory()) {
throw new IllegalArgumentException("File is a directory " + suggestedFile); throw new IllegalArgumentException("File is a directory " + suggestedFile);
} }
OutputStream os = null; OutputStream os = null;
ImageData cmap = null; ImageData cmap = null;
ImageData imageData = null; ImageData imageData = null;
try { try {
if (canFileBeWritten(suggestedFile) == false) { if (PSystemUtils.canFileBeWritten(suggestedFile.getFile(0)) == false) {
return Collections.emptyList(); return Collections.emptyList();
} }
os = new BufferedOutputStream(new FileOutputStream(suggestedFile)); os = new BufferedOutputStream(new FileOutputStream(suggestedFile.getFile(0)));
imageData = cmap = system.exportDiagram(os, 0, fileFormat); imageData = cmap = system.exportDiagram(os, 0, fileFormat);
} finally { } finally {
if (os != null) { if (os != null) {
@ -155,19 +155,19 @@ public class PSystemUtils {
} }
} }
if (cmap != null && cmap.containsCMapData()) { if (cmap != null && cmap.containsCMapData()) {
system.exportCmap(suggestedFile, cmap); system.exportCmap(suggestedFile, 0, cmap);
} }
return Arrays.asList(new FileImageData(suggestedFile, imageData)); return Arrays.asList(new FileImageData(suggestedFile.getFile(0), imageData));
} }
private static List<FileImageData> exportDiagramsSequence(SequenceDiagram system, File suggestedFile, private static List<FileImageData> exportDiagramsSequence(SequenceDiagram system, SuggestedFile suggestedFile,
FileFormatOption fileFormat) throws IOException { FileFormatOption fileFormat) throws IOException {
final List<FileImageData> result = new ArrayList<FileImageData>(); final List<FileImageData> result = new ArrayList<FileImageData>();
final int nbImages = system.getNbImages(); final int nbImages = system.getNbImages();
for (int i = 0; i < nbImages; i++) { for (int i = 0; i < nbImages; i++) {
final File f = fileFormat.getFileFormat().computeFilename(suggestedFile, i); final File f = suggestedFile.getFile(i);
if (canFileBeWritten(suggestedFile) == false) { if (PSystemUtils.canFileBeWritten(suggestedFile.getFile(i)) == false) {
return result; return result;
} }
final OutputStream fos = new BufferedOutputStream(new FileOutputStream(f)); final OutputStream fos = new BufferedOutputStream(new FileOutputStream(f));
@ -178,7 +178,7 @@ public class PSystemUtils {
fos.close(); fos.close();
} }
if (cmap != null && cmap.containsCMapData()) { if (cmap != null && cmap.containsCMapData()) {
system.exportCmap(suggestedFile, cmap); system.exportCmap(suggestedFile, i, cmap);
} }
Log.info("File size : " + f.length()); Log.info("File size : " + f.length());
result.add(new FileImageData(f, cmap)); result.add(new FileImageData(f, cmap));
@ -186,9 +186,9 @@ public class PSystemUtils {
return result; return result;
} }
static private List<FileImageData> exportDiagramsCuca(CucaDiagram system, File suggestedFile, static private List<FileImageData> exportDiagramsCuca(CucaDiagram system, SuggestedFile suggestedFile,
FileFormatOption fileFormat) throws IOException { FileFormatOption fileFormat) throws IOException {
if (suggestedFile.exists() && suggestedFile.isDirectory()) { if (suggestedFile.getFile(0).exists() && suggestedFile.getFile(0).isDirectory()) {
throw new IllegalArgumentException("File is a directory " + suggestedFile); throw new IllegalArgumentException("File is a directory " + suggestedFile);
} }
@ -199,22 +199,22 @@ public class PSystemUtils {
ImageData cmap = null; ImageData cmap = null;
OutputStream os = null; OutputStream os = null;
try { try {
if (canFileBeWritten(suggestedFile) == false) { if (PSystemUtils.canFileBeWritten(suggestedFile.getFile(0)) == false) {
return Collections.emptyList(); return Collections.emptyList();
} }
// System.err.println("FOO11=" + suggestedFile); // System.err.println("FOO11=" + suggestedFile);
// os = new BufferedOutputStream(new FileOutputStream(suggestedFile)); // os = new BufferedOutputStream(new FileOutputStream(suggestedFile));
os = new NamedOutputStream(suggestedFile); os = new NamedOutputStream(suggestedFile.getFile(0));
cmap = system.exportDiagram(os, 0, fileFormat); cmap = system.exportDiagram(os, 0, fileFormat);
} finally { } finally {
if (os != null) { if (os != null) {
os.close(); os.close();
} }
} }
List<File> result = Arrays.asList(suggestedFile); List<File> result = Arrays.asList(suggestedFile.getFile(0));
if (cmap != null && cmap.containsCMapData()) { if (cmap != null && cmap.containsCMapData()) {
system.exportCmap(suggestedFile, cmap); system.exportCmap(suggestedFile, 0, cmap);
} }
if (fileFormat.getFileFormat() == FileFormat.PNG) { if (fileFormat.getFileFormat() == FileFormat.PNG) {
@ -230,7 +230,8 @@ public class PSystemUtils {
} }
private static List<FileImageData> createFilesHtml(CucaDiagram system, File suggestedFile) throws IOException { private static List<FileImageData> createFilesHtml(CucaDiagram system, SuggestedFile suggestedFile)
throws IOException {
final String name = suggestedFile.getName(); final String name = suggestedFile.getName();
final int idx = name.lastIndexOf('.'); final int idx = name.lastIndexOf('.');
final File dir = new File(suggestedFile.getParentFile(), name.substring(0, idx)); final File dir = new File(suggestedFile.getParentFile(), name.substring(0, idx));

View File

@ -90,7 +90,7 @@ public class Pipe {
ps.println(result); ps.println(result);
} else { } else {
final OutputStream os = noStdErr ? new ByteArrayOutputStream() : ps; final OutputStream os = noStdErr ? new ByteArrayOutputStream() : ps;
final DiagramDescription result = sourceStringReader.generateImage(os, 0, option.getFileFormatOption()); final DiagramDescription result = sourceStringReader.outputImage(os, 0, option.getFileFormatOption());
if (result != null && "(error)".equalsIgnoreCase(result.getDescription())) { if (result != null && "(error)".equalsIgnoreCase(result.getDescription())) {
error = true; error = true;
manageErrors(noStdErr ? ps : System.err, sourceStringReader); manageErrors(noStdErr ? ps : System.err, sourceStringReader);

View File

@ -306,7 +306,7 @@ public class Run {
private static boolean processArgs(Option option) throws IOException, InterruptedException { private static boolean processArgs(Option option) throws IOException, InterruptedException {
if (option.isDecodeurl() == false && option.getNbThreads() > 1 && option.isCheckOnly() == false if (option.isDecodeurl() == false && option.getNbThreads() > 1 && option.isCheckOnly() == false
&& OptionFlags.getInstance().isMetadata() == false) { && OptionFlags.getInstance().isExtractFromMetadata() == false) {
return multithread(option); return multithread(option);
} }
boolean errorGlobal = false; boolean errorGlobal = false;
@ -384,7 +384,7 @@ public class Run {
} }
private static boolean manageFileInternal(File f, Option option) throws IOException, InterruptedException { private static boolean manageFileInternal(File f, Option option) throws IOException, InterruptedException {
if (OptionFlags.getInstance().isMetadata()) { if (OptionFlags.getInstance().isExtractFromMetadata()) {
System.out.println("------------------------"); System.out.println("------------------------");
System.out.println(f); System.out.println(f);
// new Metadata().readAndDisplayMetadata(f); // new Metadata().readAndDisplayMetadata(f);

View File

@ -170,24 +170,28 @@ public class SourceFileReader implements ISourceFileReader {
final List<GeneratedImage> result = new ArrayList<GeneratedImage>(); final List<GeneratedImage> result = new ArrayList<GeneratedImage>();
for (BlockUml blockUml : builder.getBlockUmls()) { for (BlockUml blockUml : builder.getBlockUmls()) {
String newName = blockUml.getFileOrDirname(fileFormatOption.getFileFormat()); final String newName = blockUml.getFileOrDirname();
Log.info("name from block=" + newName); SuggestedFile suggested = null;
File suggested = null;
if (newName != null) { if (newName != null) {
Log.info("name from block=" + newName);
final File dir = getDirIfDirectory(newName); final File dir = getDirIfDirectory(newName);
if (dir == null) { if (dir == null) {
Log.info(newName + " is not taken as a directory"); Log.info(newName + " is not taken as a directory");
suggested = new File(outputDirectory, newName); suggested = SuggestedFile.fromOutputFile(new File(outputDirectory, newName),
fileFormatOption.getFileFormat(), cpt++);
} else { } else {
Log.info("We are going to create files in directory " + dir); Log.info("We are going to create files in directory " + dir);
newName = fileFormatOption.getFileFormat().changeName(file.getName(), cpt++); // newName = fileFormatOption.getFileFormat().changeName(file.getName(), cpt++);
suggested = new File(dir, newName); // suggested = new File(dir, newName);
suggested = SuggestedFile.fromOutputFile(new File(dir, file.getName()),
fileFormatOption.getFileFormat(), cpt++);
} }
Log.info("We are going to put data in " + suggested); Log.info("We are going to put data in " + suggested);
} }
if (suggested == null) { if (suggested == null) {
newName = fileFormatOption.getFileFormat().changeName(file.getName(), cpt++); // newName = fileFormatOption.getFileFormat().changeName(file.getName(), cpt++);
suggested = new File(outputDirectory, newName); suggested = SuggestedFile.fromOutputFile(new File(outputDirectory, file.getName()),
fileFormatOption.getFileFormat(), cpt++);
} }
suggested.getParentFile().mkdirs(); suggested.getParentFile().mkdirs();
@ -195,11 +199,11 @@ public class SourceFileReader implements ISourceFileReader {
try { try {
system = blockUml.getDiagram(); system = blockUml.getDiagram();
} catch (Throwable t) { } catch (Throwable t) {
final GeneratedImage image = new GeneratedImageImpl(suggested, "Crash Error", blockUml); final GeneratedImage image = new GeneratedImageImpl(suggested.getFile(0), "Crash Error", blockUml);
OutputStream os = null; OutputStream os = null;
try { try {
os = new BufferedOutputStream(new FileOutputStream(suggested)); os = new BufferedOutputStream(new FileOutputStream(suggested.getFile(0)));
UmlDiagram.exportDiagramError(os, t, fileFormatOption, null, blockUml.getFlashData(), UmlDiagram.exportDiagramError(os, t, fileFormatOption, 42, null, blockUml.getFlashData(),
UmlDiagram.getFailureText2(t)); UmlDiagram.getFailureText2(t));
} finally { } finally {
if (os != null) { if (os != null) {

View File

@ -90,7 +90,7 @@ public class SourceFileReader2 implements ISourceFileReader {
final List<GeneratedImage> result = new ArrayList<GeneratedImage>(); final List<GeneratedImage> result = new ArrayList<GeneratedImage>();
for (BlockUml blockUml : builder.getBlockUmls()) { for (BlockUml blockUml : builder.getBlockUmls()) {
final File suggested = outputFile; final SuggestedFile suggested = SuggestedFile.fromOutputFile(outputFile, fileFormatOption.getFileFormat());
final Diagram system = blockUml.getDiagram(); final Diagram system = blockUml.getDiagram();
OptionFlags.getInstance().logData(file, system); OptionFlags.getInstance().logData(file, system);

View File

@ -92,29 +92,58 @@ public class SourceStringReader {
} }
} }
public DiagramDescription generateImage(OutputStream os) throws IOException { @Deprecated
return generateImage(os, 0); public String generateImage(OutputStream os) throws IOException {
return outputImage(os).getDescription();
} }
public DiagramDescription generateImage(File f) throws IOException { public DiagramDescription outputImage(OutputStream os) throws IOException {
return outputImage(os, 0);
}
@Deprecated
public String generateImage(File f) throws IOException {
return outputImage(f).getDescription();
}
public DiagramDescription outputImage(File f) throws IOException {
final OutputStream os = new BufferedOutputStream(new FileOutputStream(f)); final OutputStream os = new BufferedOutputStream(new FileOutputStream(f));
final DiagramDescription result = generateImage(os, 0); DiagramDescription result = null;
os.close(); try {
result = outputImage(os, 0);
} finally {
os.close();
}
return result; return result;
} }
public DiagramDescription generateImage(OutputStream os, FileFormatOption fileFormatOption) throws IOException { @Deprecated
return generateImage(os, 0, fileFormatOption); public String generateImage(OutputStream os, FileFormatOption fileFormatOption) throws IOException {
return outputImage(os, fileFormatOption).getDescription();
} }
public DiagramDescription generateImage(OutputStream os, int numImage) throws IOException { public DiagramDescription outputImage(OutputStream os, FileFormatOption fileFormatOption) throws IOException {
return generateImage(os, numImage, new FileFormatOption(FileFormat.PNG)); return outputImage(os, 0, fileFormatOption);
} }
public DiagramDescription generateImage(OutputStream os, int numImage, FileFormatOption fileFormatOption) @Deprecated
public String generateImage(OutputStream os, int numImage) throws IOException {
return outputImage(os, numImage).getDescription();
}
public DiagramDescription outputImage(OutputStream os, int numImage) throws IOException {
return outputImage(os, numImage, new FileFormatOption(FileFormat.PNG));
}
@Deprecated
public String generateImage(OutputStream os, int numImage, FileFormatOption fileFormatOption) throws IOException {
return outputImage(os, numImage, fileFormatOption).getDescription();
}
public DiagramDescription outputImage(OutputStream os, int numImage, FileFormatOption fileFormatOption)
throws IOException { throws IOException {
if (blocks.size() == 0) { if (blocks.size() == 0) {
noStartumlFound(os, fileFormatOption); noStartumlFound(os, fileFormatOption, 42);
return null; return null;
} }
for (BlockUml b : blocks) { for (BlockUml b : blocks) {
@ -135,6 +164,38 @@ public class SourceStringReader {
} }
public DiagramDescription generateDiagramDescription(int numImage, FileFormatOption fileFormatOption) {
if (blocks.size() == 0) {
return null;
}
for (BlockUml b : blocks) {
final Diagram system = b.getDiagram();
final int nbInSystem = system.getNbImages();
if (numImage < nbInSystem) {
// final ImageData imageData = system.exportDiagram(os, numImage, fileFormatOption);
// if (imageData.containsCMapData()) {
// return system.getDescription().withCMapData(imageData.getCMapData("plantuml"));
// }
return system.getDescription();
}
numImage -= nbInSystem;
}
Log.error("numImage is too big = " + numImage);
return null;
}
public DiagramDescription generateDiagramDescription() {
return generateDiagramDescription(0);
}
public DiagramDescription generateDiagramDescription(FileFormatOption fileFormatOption) {
return generateDiagramDescription(0, fileFormatOption);
}
public DiagramDescription generateDiagramDescription(int numImage) {
return generateDiagramDescription(numImage, new FileFormatOption(FileFormat.PNG));
}
public String getCMapData(int numImage, FileFormatOption fileFormatOption) throws IOException { public String getCMapData(int numImage, FileFormatOption fileFormatOption) throws IOException {
if (blocks.size() == 0) { if (blocks.size() == 0) {
return null; return null;
@ -155,54 +216,13 @@ public class SourceStringReader {
} }
private void noStartumlFound(OutputStream os, FileFormatOption fileFormatOption) throws IOException { private void noStartumlFound(OutputStream os, FileFormatOption fileFormatOption, long seed) throws IOException {
final TextBlockBackcolored error = GraphicStrings.createForError(Arrays.asList("No @startuml found"), final TextBlockBackcolored error = GraphicStrings.createForError(Arrays.asList("No @startuml found"),
fileFormatOption.isUseRedForError()); fileFormatOption.isUseRedForError());
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, error.getBackcolor(), null, final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, error.getBackcolor(), null,
null, 0, 0, null, false); null, 0, 0, null, false);
imageBuilder.setUDrawable(error); imageBuilder.setUDrawable(error);
imageBuilder.writeImageTOBEMOVED(fileFormatOption, os); imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed, os);
}
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(FileFormatOption fileFormatOption) {
return generateDiagramDescription(0, fileFormatOption);
}
public DiagramDescription generateDiagramDescription(int numImage) {
return generateDiagramDescription(numImage, new FileFormatOption(FileFormat.PNG));
}
public DiagramDescription generateDiagramDescription(int numImage, FileFormatOption fileFormatOption) {
if (blocks.size() == 0) {
// noStartumlFound(os, fileFormatOption);
return null;
}
for (BlockUml b : blocks) {
final Diagram system = b.getDiagram();
final int nbInSystem = system.getNbImages();
if (numImage < nbInSystem) {
// final ImageData imageData = system.exportDiagram(os, numImage, fileFormatOption);
// if (imageData.containsCMapData()) {
// return system.getDescription().withCMapData(imageData.getCMapData("plantuml"));
// }
return system.getDescription();
}
numImage -= nbInSystem;
}
Log.error("numImage is too big = " + numImage);
return null;
} }
public final List<BlockUml> getBlocks() { public final List<BlockUml> getBlocks() {

View File

@ -319,7 +319,7 @@ public class StringUtils {
public static int getWidth(Display stringsToDisplay) { public static int getWidth(Display stringsToDisplay) {
int result = 1; int result = 1;
for (CharSequence s : stringsToDisplay) { for (CharSequence s : stringsToDisplay) {
if (result < s.length()) { if (s != null && result < s.length()) {
result = s.length(); result = s.length();
} }
} }

View File

@ -0,0 +1,81 @@
/* ========================================================================
* 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.File;
public class SuggestedFile {
private final FileFormat fileFormat;
private final int initialCpt;
private final File outputFile;
private SuggestedFile(File outputFile, FileFormat fileFormat, int initialCpt) {
if (outputFile.getName().endsWith(fileFormat.getFileSuffix())) {
throw new IllegalArgumentException();
}
this.outputFile = outputFile;
this.fileFormat = fileFormat;
this.initialCpt = initialCpt;
}
public static SuggestedFile fromOutputFile(File outputFile, FileFormat fileFormat) {
return fromOutputFile(outputFile, fileFormat, 0);
}
public File getParentFile() {
return outputFile.getParentFile();
}
public String getName() {
return outputFile.getName();
}
public File getFile(int cpt) {
final String newName = fileFormat.changeName(outputFile.getName(), initialCpt + cpt);
return new File(outputFile.getParentFile(), newName);
}
public static SuggestedFile fromOutputFile(File outputFile, FileFormat fileFormat, int initialCpt) {
return new SuggestedFile(outputFile, fileFormat, initialCpt);
}
public File getTmpFile() {
return new File(getParentFile(), getName() + ".tmp");
}
}

View File

@ -218,7 +218,7 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Ann
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption) final protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption, long seed)
throws IOException { throws IOException {
final HtmlColor hover = getSkinParam().getHoverPathColor(); final HtmlColor hover = getSkinParam().getHoverPathColor();
@ -238,21 +238,21 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Ann
return imageData; return imageData;
} catch (UnparsableGraphvizException e) { } catch (UnparsableGraphvizException e) {
e.printStackTrace(); e.printStackTrace();
exportDiagramError(os, e.getCause(), fileFormatOption, e.getGraphvizVersion()); exportDiagramError(os, e.getCause(), fileFormatOption, seed, e.getGraphvizVersion());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
exportDiagramError(os, e, fileFormatOption, null); exportDiagramError(os, e, fileFormatOption, seed, null);
} }
return new ImageDataSimple(); return new ImageDataSimple();
} }
private void exportDiagramError(OutputStream os, Throwable exception, FileFormatOption fileFormat, private void exportDiagramError(OutputStream os, Throwable exception, FileFormatOption fileFormat, long seed,
String graphvizVersion) throws IOException { String graphvizVersion) throws IOException {
exportDiagramError(os, exception, fileFormat, getMetadata(), getFlashData(), exportDiagramError(os, exception, fileFormat, seed, getMetadata(), getFlashData(),
getFailureText1(exception, graphvizVersion)); getFailureText1(exception, graphvizVersion));
} }
public static void exportDiagramError(OutputStream os, Throwable exception, FileFormatOption fileFormat, public static void exportDiagramError(OutputStream os, Throwable exception, FileFormatOption fileFormat, long seed,
String metadata, String flash, List<String> strings) throws IOException { String metadata, String flash, List<String> strings) throws IOException {
if (fileFormat.getFileFormat() == FileFormat.ATXT || fileFormat.getFileFormat() == FileFormat.UTXT) { if (fileFormat.getFileFormat() == FileFormat.ATXT || fileFormat.getFileFormat() == FileFormat.UTXT) {
@ -286,7 +286,7 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Ann
} }
}); });
} }
imageBuilder.writeImageTOBEMOVED(fileFormat, os); imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
} }
private static void exportDiagramErrorText(OutputStream os, Throwable exception, List<String> strings) { private static void exportDiagramErrorText(OutputStream os, Throwable exception, List<String> strings) {
@ -376,8 +376,9 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Ann
protected abstract ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) protected abstract ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException; throws IOException;
final protected void exportCmap(File suggestedFile, final ImageData cmapdata) throws FileNotFoundException { final protected void exportCmap(SuggestedFile suggestedFile, int index, final ImageData cmapdata)
final String name = changeName(suggestedFile.getAbsolutePath()); throws FileNotFoundException {
final String name = changeName(suggestedFile.getFile(index).getAbsolutePath());
final File cmapFile = new File(name); final File cmapFile = new File(name);
PrintWriter pw = null; PrintWriter pw = null;
try { try {

View File

@ -79,7 +79,7 @@ public class PSystemXearth extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
final ACearth earth = new ACearth(markers); final ACearth earth = new ACearth(markers);
final ConfigurationACearth conf = earth.getConf(); final ConfigurationACearth conf = earth.getConf();

View File

@ -200,7 +200,7 @@ public class ActivityDiagram3 extends UmlDiagram {
getAnimation()); getAnimation());
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os); return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed(), os);
} }
@ -344,10 +344,10 @@ public class ActivityDiagram3 extends UmlDiagram {
manageSwimlaneStrategy(); manageSwimlaneStrategy();
if (current() instanceof InstructionRepeat) { if (current() instanceof InstructionRepeat) {
final InstructionRepeat instructionRepeat = (InstructionRepeat) current(); final InstructionRepeat instructionRepeat = (InstructionRepeat) current();
// final LinkRendering back = new LinkRendering(linkColor).withDisplay(linkLabel); // final LinkRendering back = new LinkRendering(linkColor).withDisplay(linkLabel);
instructionRepeat.setBackward(label); instructionRepeat.setBackward(label);
// setCurrent(instructionRepeat.getParent()); // setCurrent(instructionRepeat.getParent());
// this.setNextLinkRendererInternal(LinkRendering.none()); // this.setNextLinkRendererInternal(LinkRendering.none());
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();
} }
return CommandExecutionResult.error("Cannot find repeat"); return CommandExecutionResult.error("Cannot find repeat");

View File

@ -69,9 +69,9 @@ public class FtileFactoryDelegatorIf extends FtileFactoryDelegator {
final ConditionStyle conditionStyle = skinParam().getConditionStyle(); final ConditionStyle conditionStyle = skinParam().getConditionStyle();
final Branch branch0 = thens.get(0); final Branch branch0 = thens.get(0);
final HtmlColor borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityBorder); final HtmlColor borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBorder);
final HtmlColor backColor = branch0.getColor() == null ? getRose().getHtmlColor(skinParam(), final HtmlColor backColor = branch0.getColor() == null ? getRose().getHtmlColor(skinParam(),
ColorParam.activityBackground) : branch0.getColor(); ColorParam.activityDiamondBackground) : branch0.getColor();
final Rainbow arrowColor = HtmlColorAndStyle.build(skinParam()); final Rainbow arrowColor = HtmlColorAndStyle.build(skinParam());
final FontConfiguration fcArrow = new FontConfiguration(skinParam(), FontParam.ARROW, null); final FontConfiguration fcArrow = new FontConfiguration(skinParam(), FontParam.ARROW, null);

View File

@ -76,8 +76,8 @@ public class FtileFactoryDelegatorRepeat extends FtileFactoryDelegator {
final ConditionStyle conditionStyle = skinParam().getConditionStyle(); final ConditionStyle conditionStyle = skinParam().getConditionStyle();
final HtmlColor borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityBorder); final HtmlColor borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBorder);
final HtmlColor backColor = color == null ? getRose().getHtmlColor(skinParam(), ColorParam.activityBackground) final HtmlColor backColor = color == null ? getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBackground)
: color; : color;
final Rainbow arrowColor = HtmlColorAndStyle.build(skinParam()); final Rainbow arrowColor = HtmlColorAndStyle.build(skinParam());

View File

@ -59,8 +59,8 @@ public class FtileFactoryDelegatorWhile extends FtileFactoryDelegator {
@Override @Override
public Ftile createWhile(Swimlane swimlane, Ftile whileBlock, Display test, Display yes, Display out, public Ftile createWhile(Swimlane swimlane, Ftile whileBlock, Display test, Display yes, Display out,
LinkRendering afterEndwhile, HtmlColor color, Instruction specialOut) { LinkRendering afterEndwhile, HtmlColor color, Instruction specialOut) {
final HtmlColor borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityBorder); final HtmlColor borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBorder);
final HtmlColor backColor = color == null ? getRose().getHtmlColor(skinParam(), ColorParam.activityBackground) final HtmlColor backColor = color == null ? getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBackground)
: color; : color;
final Rainbow arrowColor = HtmlColorAndStyle.build(skinParam()); final Rainbow arrowColor = HtmlColorAndStyle.build(skinParam());

View File

@ -93,8 +93,8 @@ public class ParallelBuilderMerge extends ParallelFtilesBuilder {
@Override @Override
protected Ftile doStep2(Ftile result) { protected Ftile doStep2(Ftile result) {
final HtmlColor borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityBorder); final HtmlColor borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBorder);
final HtmlColor backColor = getRose().getHtmlColor(skinParam(), ColorParam.activityBackground); final HtmlColor backColor = getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBackground);
final Ftile out = new FtileDiamond(skinParam(), backColor, borderColor, swimlane()); final Ftile out = new FtileDiamond(skinParam(), backColor, borderColor, swimlane());
result = new FtileAssemblySimple(result, out); result = new FtileAssemblySimple(result, out);
final List<Connection> conns = new ArrayList<Connection>(); final List<Connection> conns = new ArrayList<Connection>();

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.asciiart;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.skin.Area;
import net.sourceforge.plantuml.skin.Context2D;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt;
public class ComponentTextDestroy extends AbstractComponentText {
public ComponentTextDestroy() {
}
public void drawU(UGraphic ug, Area area, Context2D context) {
final UmlCharArea charArea = ((UGraphicTxt) ug).getCharArea();
charArea.drawStringLR("/", 2, 0);
charArea.drawStringLR("\\", 0, 0);
charArea.drawStringLR("X", 1, 1);
charArea.drawStringLR("\\", 2, 2);
charArea.drawStringLR("/", 0, 2);
}
public double getPreferredHeight(StringBounder stringBounder) {
return 5;
}
public double getPreferredWidth(StringBounder stringBounder) {
return 3;
}
}

View File

@ -53,8 +53,7 @@ public class ComponentTextGroupingHeader extends AbstractComponentText {
private final Display stringsToDisplay; private final Display stringsToDisplay;
private final FileFormat fileFormat; private final FileFormat fileFormat;
public ComponentTextGroupingHeader(ComponentType type, Display stringsToDisplay, public ComponentTextGroupingHeader(ComponentType type, Display stringsToDisplay, FileFormat fileFormat) {
FileFormat fileFormat) {
this.type = type; this.type = type;
this.stringsToDisplay = stringsToDisplay; this.stringsToDisplay = stringsToDisplay;
this.fileFormat = fileFormat; this.fileFormat = fileFormat;
@ -92,7 +91,7 @@ public class ComponentTextGroupingHeader extends AbstractComponentText {
charArea.drawHLine('~', height - 1, 1, width - 1); charArea.drawHLine('~', height - 1, 1, width - 1);
} }
if (stringsToDisplay.size() > 1) { if (stringsToDisplay.size() > 1 && stringsToDisplay.get(1) != null) {
final String comment = stringsToDisplay.get(1).toString(); final String comment = stringsToDisplay.get(1).toString();
charArea.drawStringLR(comment, text.length() + 7, 1); charArea.drawStringLR(comment, text.length() + 7, 1);

View File

@ -119,6 +119,9 @@ public class TextSkin implements Skin {
if (type == ComponentType.DELAY_TEXT) { if (type == ComponentType.DELAY_TEXT) {
return new ComponentTextDelay(type, stringsToDisplay, fileFormat); return new ComponentTextDelay(type, stringsToDisplay, fileFormat);
} }
if (type == ComponentType.DESTROY) {
return new ComponentTextDestroy();
}
throw new UnsupportedOperationException(type.toString()); throw new UnsupportedOperationException(type.toString());
} }

View File

@ -53,6 +53,16 @@ import net.sourceforge.plantuml.ugraphic.ImageBuilder;
public class BpmDiagram extends UmlDiagram { public class BpmDiagram extends UmlDiagram {
private void cleanGrid(Grid grid) {
while (true) {
final boolean v1 = new CleanerEmptyLine().clean(grid);
final boolean v2 = new CleanerInterleavingLines().clean(grid);
if (v1 == false && v2 == false) {
return;
}
}
}
private final BpmElement start = new BpmElement(null, BpmElementType.START); private final BpmElement start = new BpmElement(null, BpmElementType.START);
private List<BpmEvent> events = new ArrayList<BpmEvent>(); private List<BpmEvent> events = new ArrayList<BpmEvent>();
@ -77,7 +87,7 @@ public class BpmDiagram extends UmlDiagram {
getAnimation()); getAnimation());
imageBuilder.setUDrawable(getUDrawable()); imageBuilder.setUDrawable(getUDrawable());
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os); return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed(), os);
} }
private UDrawable getUDrawable() { private UDrawable getUDrawable() {
@ -89,16 +99,6 @@ public class BpmDiagram extends UmlDiagram {
return gridArray; return gridArray;
} }
private void cleanGrid(Grid grid) {
// while (true) {
// final boolean v1 = new CleanerEmptyLine().clean(grid);
// final boolean v2 = new CleanerInterleavingLines().clean(grid);
// if (v1 == false && v2 == false) {
// return;
// }
// }
}
public CommandExecutionResult addEvent(BpmEvent event) { public CommandExecutionResult addEvent(BpmEvent event) {
this.events.add(event); this.events.add(event);
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();
@ -144,7 +144,7 @@ public class BpmDiagram extends UmlDiagram {
nav.insertAfter(newLine); nav.insertAfter(newLine);
final Col row = current.getCol(); final Col row = current.getCol();
current = new Coord(newLine, row); current = new Coord(newLine, row);
src.addConnectionTo(last); src.addConnectionTo2(last.getData());
} else { } else {
throw new IllegalStateException(); throw new IllegalStateException();
} }
@ -164,7 +164,7 @@ public class BpmDiagram extends UmlDiagram {
nav.insertAfter(newRow); nav.insertAfter(newRow);
current = new Coord(current.getLine(), newRow); current = new Coord(current.getLine(), newRow);
grid.getCell(current).setData(element); grid.getCell(current).setData(element);
last.addConnectionTo(grid.getCell(current)); last.addConnectionTo2(grid.getCell(current).getData());
last = grid.getCell(current); last = grid.getCell(current);
} }

View File

@ -42,7 +42,7 @@ import java.util.List;
public class Cell { public class Cell {
private Placeable data; private Placeable data;
private final List<Cell> destinations = new ArrayList<Cell>(); private final List<Placeable> destinations = new ArrayList<Placeable>();
public final Placeable getData() { public final Placeable getData() {
return data; return data;
@ -60,11 +60,15 @@ public class Cell {
return super.toString() + " " + data; return super.toString() + " " + data;
} }
public void addConnectionTo(Cell other) { public void addConnectionTo2(Placeable other) {
// Should be an assert
if (other instanceof BpmElement == false) {
throw new IllegalArgumentException();
}
this.destinations.add(other); this.destinations.add(other);
} }
public List<Cell> getDestinations() { public List<Placeable> getDestinations2() {
return Collections.unmodifiableList(destinations); return Collections.unmodifiableList(destinations);
} }

View File

@ -35,44 +35,120 @@
*/ */
package net.sourceforge.plantuml.bpm; package net.sourceforge.plantuml.bpm;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.SortedSet;
public class CleanerInterleavingLines implements GridCleaner { public class CleanerInterleavingLines implements GridCleaner {
public boolean clean(Grid grid) { public boolean clean(Grid grid) {
System.err.println("running CleanerInterleavingLines");
boolean result = false; boolean result = false;
Line previous = null; Line previous = null;
// int i = 0;
for (Line line : grid.lines().toList()) { for (Line line : grid.lines().toList()) {
// System.err.println("--------- LINE i=" + i);
// i++;
if (previous != null) { if (previous != null) {
final Collection<Col> cols1 = grid.usedColsOf(previous); if (mergeable(grid, previous, line)) {
final Collection<Col> cols2 = grid.usedColsOf(line); System.err.println("MERGEABLE! " + previous + " " + line);
if (Collections.disjoint(cols1, cols2)) { mergeLines(grid, previous, line);
// final SortedSet<Col> used1 = grid.colsConnectedTo(previous); return true;
// final SortedSet<Col> used2 = grid.colsConnectedTo(line);
// if (mergeable(used1, used2)) {
// System.err.println("CAN BE MERGE!");
// grid.mergeLines(previous, line);
// result = true;
// }
} }
} }
previous = line; previous = line;
} }
// }
return result; return result;
} }
private boolean mergeable(SortedSet<Col> used1, SortedSet<Col> used2) { private void mergeLines(Grid grid, Line line1, Line line2) {
final Comparator<? super Col> s = used1.comparator(); for (Col col : grid.cols().toList()) {
assert s == used2.comparator(); final Cell cell1 = grid.getCell(line1, col);
if (s.compare(used1.last(), used2.first()) <= 0) { final Cell cell2 = grid.getCell(line2, col);
cell1.setData(merge(cell1.getData(), cell2.getData()));
cell2.setData(null);
}
grid.removeLine(line2);
}
private boolean mergeable(Grid grid, Line line1, Line line2) {
// int c = 0;
for (Col col : grid.cols().toList()) {
// System.err.println("c=" + c);
// c++;
final Placeable cell1 = grid.getCell(line1, col).getData();
final Placeable cell2 = grid.getCell(line2, col).getData();
// System.err.println("cells=" + cell1 + " " + cell2 + " " + mergeable(cell1, cell2));
if (mergeable(cell1, cell2) == false) {
return false;
}
}
return true;
}
private Placeable merge(Placeable data1, Placeable data2) {
if (data1 == null) {
return data2;
}
if (data2 == null) {
return data1;
}
assert data1 != null && data2 != null;
if (data1 instanceof BpmElement) {
return data1;
}
if (data2 instanceof BpmElement) {
return data2;
}
assert data1 instanceof ConnectorPuzzle && data2 instanceof ConnectorPuzzle;
final ConnectorPuzzle puz1 = (ConnectorPuzzle) data1;
final ConnectorPuzzle puz2 = (ConnectorPuzzle) data2;
return puz2;
}
private boolean mergeable(Placeable data1, Placeable data2) {
if (data1 == null || data2 == null) {
return true; return true;
} }
if (s.compare(used2.last(), used1.first()) <= 0) { assert data1 != null && data2 != null;
if (data1 instanceof ConnectorPuzzle && data2 instanceof ConnectorPuzzle) {
return mergeableCC((ConnectorPuzzle) data1, (ConnectorPuzzle) data2);
}
if (data1 instanceof ConnectorPuzzle && data2 instanceof BpmElement) {
final boolean result = mergeablePuzzleSingle((ConnectorPuzzle) data1);
System.err.println("OTHER2=" + data2 + " " + data1 + " " + result);
return result;
}
if (data2 instanceof ConnectorPuzzle && data1 instanceof BpmElement) {
final boolean result = mergeablePuzzleSingle((ConnectorPuzzle) data2);
System.err.println("OTHER1=" + data1 + " " + data2 + " " + result);
return result;
}
return false;
}
private boolean mergeablePuzzleSingle(ConnectorPuzzle puz) {
if (puz == ConnectorPuzzle.get("NS")) {
return true;
}
if (puz == ConnectorPuzzle.get("NE")) {
return true;
}
if (puz == ConnectorPuzzle.get("NW")) {
return true; return true;
} }
return false; return false;
} }
private boolean mergeableCC(ConnectorPuzzle puz1, ConnectorPuzzle puz2) {
if (puz1 == ConnectorPuzzle.get("NS") && puz2 == ConnectorPuzzle.get("NS")) {
return true;
}
if (puz1 == ConnectorPuzzle.get("NS") && puz2 == ConnectorPuzzle.get("NE")) {
return true;
}
if (puz1 == ConnectorPuzzle.get("NS") && puz2 == ConnectorPuzzle.get("NW")) {
return true;
}
return false;
}
} }

View File

@ -169,6 +169,15 @@ public class Grid {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
private Coord getCoord(Placeable placeable) {
for (Map.Entry<Coord, Cell> ent : cells.entrySet()) {
if (ent.getValue().getData() == placeable) {
return ent.getKey();
}
}
throw new IllegalArgumentException();
}
public final Navigator<Line> linesOf(Coord coord) { public final Navigator<Line> linesOf(Coord coord) {
return lines.navigator(coord.getLine()); return lines.navigator(coord.getLine());
} }
@ -191,11 +200,14 @@ public class Grid {
final GridArray result = new GridArray(skinParam, lines.size(), cols.size()); final GridArray result = new GridArray(skinParam, lines.size(), cols.size());
for (Map.Entry<Coord, Cell> ent : cells.entrySet()) { for (Map.Entry<Coord, Cell> ent : cells.entrySet()) {
final int l = lines.indexOf(ent.getKey().getLine()); final int l = lines.indexOf(ent.getKey().getLine());
final int r = cols.indexOf(ent.getKey().getCol()); final int c = cols.indexOf(ent.getKey().getCol());
if (r == -1 || l == -1) { if (c == -1) {
throw new IllegalStateException(); throw new IllegalStateException("col=" + ent.getKey().getCol());
} }
result.setData(l, r, ent.getValue().getData()); if (l == -1) {
throw new IllegalStateException("line=" + ent.getKey().getLine());
}
result.setData(l, c, ent.getValue().getData());
} }
return result; return result;
} }
@ -244,7 +256,21 @@ public class Grid {
} }
public void removeLine(Line line) { public void removeLine(Line line) {
System.err.println("REMOVING " + line);
assert usedColsOf(line).isEmpty(); assert usedColsOf(line).isEmpty();
for (final Iterator<Map.Entry<Coord, Cell>> it = cells.entrySet().iterator(); it.hasNext();) {
final Map.Entry<Coord, Cell> ent = it.next();
if (ent.getKey().getLine() != line) {
continue;
}
final Cell cell = ent.getValue();
if (cell == null || cell.getData() == null) {
it.remove();
} else {
throw new IllegalStateException();
}
}
final boolean done = lines.remove(line); final boolean done = lines.remove(line);
if (done == false) { if (done == false) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
@ -255,36 +281,36 @@ public class Grid {
// this.edges.addAll(other); // this.edges.addAll(other);
// } // }
public void mergeLines(Line source, Line dest) { // public void mergeLines(Line line1, Line line2) {
final Map<Coord, Cell> supp = new HashMap<Coord, Cell>(); // final Map<Coord, Cell> supp = new HashMap<Coord, Cell>();
//
for (Iterator<Map.Entry<Coord, Cell>> it = cells.entrySet().iterator(); it.hasNext();) { // for (Iterator<Map.Entry<Coord, Cell>> it = cells.entrySet().iterator(); it.hasNext();) {
final Map.Entry<Coord, Cell> ent = it.next(); // final Map.Entry<Coord, Cell> ent = it.next();
final Cell cell = ent.getValue(); // final Cell cell = ent.getValue();
if (cell == null || cell.getData() == null) { // if (cell == null || cell.getData() == null) {
continue; // continue;
} // }
if (ent.getKey().getLine() == source) { // if (ent.getKey().getLine() == source) {
supp.put(new Coord(dest, ent.getKey().getCol()), cell); // supp.put(new Coord(dest, ent.getKey().getCol()), cell);
it.remove(); // it.remove();
} // }
} // }
cells.putAll(supp); // cells.putAll(supp);
removeLine(source); // removeLine(source);
} // }
public void addConnections() { public void addConnections() {
for (Map.Entry<Coord, Cell> ent : new HashMap<Coord, Cell>(cells).entrySet()) { for (Map.Entry<Coord, Cell> ent : new HashMap<Coord, Cell>(cells).entrySet()) {
final List<Cell> dests = ent.getValue().getDestinations(); final List<Placeable> dests2 = ent.getValue().getDestinations2();
final Coord src = ent.getKey(); final Coord src = ent.getKey();
for (int i = 0; i < dests.size(); i++) { for (int i = 0; i < dests2.size(); i++) {
final Coord dest = getCoord(dests.get(i)); final Coord dest = getCoord(dests2.get(i));
final boolean startHorizontal = i == 0; final boolean startHorizontal = i == 0;
if (startHorizontal) { if (startHorizontal) {
System.err.println("DrawingHorizontal " + ent.getValue() + " --> " + dests.get(i) + " " + i); // System.err.println("DrawingHorizontal " + ent.getValue() + " --> " + dests.get(i) + " " + i);
drawHorizontal(src, dest); drawHorizontal(src, dest);
} else { } else {
// drawVertical(src, dest); drawVertical(src, dest);
} }
} }
} }
@ -295,15 +321,25 @@ public class Grid {
.getLine();) { .getLine();) {
final Line cur = itLine.next(); final Line cur = itLine.next();
if (cur != dest.getLine()) { if (cur != dest.getLine()) {
Cell tmp = getCell(cur, src.getCol()); addPuzzle(cur, src.getCol(), "NS");
addPuzzle(tmp, "NS");
} }
} }
for (Navigator<Col> itCol = Navigators.iterate(cols, src.getCol(), dest.getCol()); itCol.get() != dest.getCol();) { for (Navigator<Col> itCol = Navigators.iterate(cols, src.getCol(), dest.getCol()); itCol.get() != dest.getCol();) {
final Col cur = itCol.next(); final Col cur = itCol.next();
if (cur != dest.getCol()) { if (cur != dest.getCol()) {
Cell tmp = getCell(dest.getLine(), cur); addPuzzle(dest.getLine(), cur, "EW");
addPuzzle(tmp, "EW"); }
}
if (src.getLine() != dest.getLine() && src.getCol() != dest.getCol()) {
if (lines.compare(dest.getLine(), src.getLine()) > 0) {
addPuzzle(dest.getLine(), src.getCol(), "N");
} else {
addPuzzle(dest.getLine(), src.getCol(), "S");
}
if (cols.compare(dest.getCol(), src.getCol()) > 0) {
addPuzzle(dest.getLine(), src.getCol(), "E");
} else {
addPuzzle(dest.getLine(), src.getCol(), "W");
} }
} }
@ -313,29 +349,38 @@ public class Grid {
for (Navigator<Col> itCol = Navigators.iterate(cols, src.getCol(), dest.getCol()); itCol.get() != dest.getCol();) { for (Navigator<Col> itCol = Navigators.iterate(cols, src.getCol(), dest.getCol()); itCol.get() != dest.getCol();) {
final Col cur = itCol.next(); final Col cur = itCol.next();
if (cur != dest.getCol()) { if (cur != dest.getCol()) {
Cell tmp = getCell(src.getLine(), cur); addPuzzle(src.getLine(), cur, "EW");
addPuzzle(tmp, "EW");
} }
} }
System.err.println("src=" + src + " " + getCell(src));
System.err.println("dest=" + dest + " " + getCell(dest));
for (Navigator<Line> itLine = Navigators.iterate(lines, src.getLine(), dest.getLine()); itLine.get() != dest for (Navigator<Line> itLine = Navigators.iterate(lines, src.getLine(), dest.getLine()); itLine.get() != dest
.getLine();) { .getLine();) {
final Line cur = itLine.next(); final Line cur = itLine.next();
if (cur != dest.getLine()) { if (cur != dest.getLine()) {
Cell tmp = getCell(cur, src.getCol()); addPuzzle(cur, dest.getCol(), "NS");
addPuzzle(tmp, "NS"); }
}
if (src.getLine() != dest.getLine() && src.getCol() != dest.getCol()) {
if (cols.compare(dest.getCol(), src.getCol()) > 0) {
addPuzzle(src.getLine(), dest.getCol(), "W");
} else {
addPuzzle(src.getLine(), dest.getCol(), "E");
}
if (lines.compare(dest.getLine(), src.getLine()) > 0) {
addPuzzle(src.getLine(), dest.getCol(), "S");
} else {
addPuzzle(src.getLine(), dest.getCol(), "N");
} }
} }
} }
private void addPuzzle(Cell tmp, String direction) { private void addPuzzle(Line line, Col col, String direction) {
final Cell cell = getCell(line, col);
ConnectorPuzzle after = ConnectorPuzzle.get(direction); ConnectorPuzzle after = ConnectorPuzzle.get(direction);
final ConnectorPuzzle before = (ConnectorPuzzle) tmp.getData(); final ConnectorPuzzle before = (ConnectorPuzzle) cell.getData();
if (before != null) { if (before != null) {
after = after.append(before); after = after.append(before);
} }
tmp.setData(after); cell.setData(after);
} }
} }

View File

@ -45,7 +45,7 @@ public final class Navigators {
if (orig.compare(from, to) <= 0) { if (orig.compare(from, to) <= 0) {
return orig.navigator(from); return orig.navigator(from);
} }
return reverse(orig.navigator(to)); return reverse(orig.navigator(from));
} }
public static <O> Navigator<O> reverse(final Navigator<O> orig) { public static <O> Navigator<O> reverse(final Navigator<O> orig) {

View File

@ -131,7 +131,7 @@ public class UGraphicBraille extends AbstractUGraphic<BrailleGrid> implements Cl
metadata, null, 0, 0, null, false); metadata, null, 0, 0, null, false);
imageBuilder.setUDrawable(new BrailleDrawer(getGraphicObject())); imageBuilder.setUDrawable(new BrailleDrawer(getGraphicObject()));
imageBuilder.writeImageTOBEMOVED(new FileFormatOption(FileFormat.PNG), os); imageBuilder.writeImageTOBEMOVED(new FileFormatOption(FileFormat.PNG), 42, os);
} }
} }

View File

@ -59,14 +59,14 @@ public abstract class AbstractEntityDiagram extends CucaDiagram {
final public DiagramDescription getDescription() { final public DiagramDescription getDescription() {
final StringBuilder result = new StringBuilder("(" + getLeafssize() + " entities"); final StringBuilder result = new StringBuilder("(" + getLeafssize() + " entities");
final String id = getSource().getId(); if (getSource() != null) {
if (id == null) { final String id = getSource().getId();
result.append(")"); if (id != null) {
} else { result.append(", ");
result.append(", "); result.append(id);
result.append(id); }
result.append(")");
} }
result.append(")");
return new DiagramDescription(result.toString()); return new DiagramDescription(result.toString());
} }

View File

@ -216,7 +216,7 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram {
} }
final ImageBuilder imageBuilder = new ImageBuilder(getSkinParam(), 1, null, null, 0, 10, null); final ImageBuilder imageBuilder = new ImageBuilder(getSkinParam(), 1, null, null, 0, 10, null);
imageBuilder.setUDrawable(fullLayout); imageBuilder.setUDrawable(fullLayout);
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os); return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed(), os);
} }
private RowLayout getRawLayout(int raw) { private RowLayout getRawLayout(int raw) {

View File

@ -59,7 +59,7 @@ import net.sourceforge.plantuml.version.IteratorCounter2Impl;
* So the diagram does not have to be a UML one. * So the diagram does not have to be a UML one.
* *
* @author Arnaud Roques * @author Arnaud Roques
* *
*/ */
final public class UmlSource { final public class UmlSource {
@ -134,6 +134,17 @@ final public class UmlSource {
return sb.toString(); return sb.toString();
} }
public long seed() {
long h = 1125899906842597L; // prime
final String string = getPlainString();
final int len = string.length();
for (int i = 0; i < len; i++) {
h = 31 * h + string.charAt(i);
}
return h;
}
/** /**
* Return a specific line of the diagram description. * Return a specific line of the diagram description.
* *

View File

@ -69,7 +69,7 @@ public class PSystemCreole extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
final Display display = Display.create(lines); final Display display = Display.create(lines);
final UFont font = UFont.serif(14); final UFont font = UFont.serif(14);
@ -81,7 +81,7 @@ public class PSystemCreole extends AbstractPSystem {
final ImageBuilder builder = new ImageBuilder(new ColorMapperIdentity(), 1.0, null, null, null, 0, 0, null, final ImageBuilder builder = new ImageBuilder(new ColorMapperIdentity(), 1.0, null, null, null, 0, 0, null,
false); false);
builder.setUDrawable(sheetBlock); builder.setUDrawable(sheetBlock);
return builder.writeImageTOBEMOVED(fileFormat, os); return builder.writeImageTOBEMOVED(fileFormat, seed, os);
// final Dimension2D dim = TextBlockUtils.getDimension(sheetBlock); // final Dimension2D dim = TextBlockUtils.getDimension(sheetBlock);
// final UGraphic2 ug = fileFormat.createUGraphic(new ColorMapperIdentity(), 1, dim, null, false); // final UGraphic2 ug = fileFormat.createUGraphic(new ColorMapperIdentity(), 1, dim, null, false);

View File

@ -82,6 +82,9 @@ public class GraphvizVersionFinder {
} }
public boolean useProtectionWhenThereALinkFromOrToGroup() { public boolean useProtectionWhenThereALinkFromOrToGroup() {
if (v == 239 || v == 240) {
return false;
}
// return v < 238; // return v < 238;
return true; return true;
} }

View File

@ -84,11 +84,11 @@ public class PSystemCute extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
final ImageBuilder builder = new ImageBuilder(new ColorMapperIdentity(), 1.0, null, null, null, 10, 10, null, final ImageBuilder builder = new ImageBuilder(new ColorMapperIdentity(), 1.0, null, null, null, 10, 10, null,
false); false);
builder.setUDrawable(root); builder.setUDrawable(root);
return builder.writeImageTOBEMOVED(fileFormat, os); return builder.writeImageTOBEMOVED(fileFormat, seed, os);
} }
} }

View File

@ -61,7 +61,7 @@ public class PSystemDedication extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE, final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE,
getMetadata(), null, 0, 0, null, false); getMetadata(), null, 0, 0, null, false);
@ -73,7 +73,7 @@ public class PSystemDedication extends AbstractPSystem {
} }
} }
}); });
return imageBuilder.writeImageTOBEMOVED(fileFormat, os); return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
} }
public DiagramDescription getDescription() { public DiagramDescription getDescription() {

View File

@ -69,13 +69,13 @@ public class PSystemDefinition extends AbstractPSystem implements UDrawable {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormatOption) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormatOption, long seed)
throws IOException { throws IOException {
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1, null, "", "", 0, 0, null, final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1, null, "", "", 0, 0, null,
false); false);
imageBuilder.setUDrawable(this); imageBuilder.setUDrawable(this);
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os); return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed, os);
} }
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {

View File

@ -68,14 +68,15 @@ public class PSystemDot extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
final Graphviz graphviz = GraphvizUtils.create(null, data, final Graphviz graphviz = GraphvizUtils.create(null, data,
StringUtils.goLowerCase(fileFormat.getFileFormat().name())); StringUtils.goLowerCase(fileFormat.getFileFormat().name()));
if (graphviz.getExeState() != ExeState.OK) { if (graphviz.getExeState() != ExeState.OK) {
final TextBlock result = GraphicStrings.createForError( final TextBlock result = GraphicStrings.createForError(
Arrays.asList("There is an issue with your Dot/Graphviz installation"), false); Arrays.asList("There is an issue with your Dot/Graphviz installation"), false);
UGraphicUtils.writeImage(os, null, fileFormat, new ColorMapperIdentity(), HtmlColorUtils.WHITE, result); UGraphicUtils.writeImage(os, null, fileFormat, seed(), new ColorMapperIdentity(),
HtmlColorUtils.WHITE, result);
return new ImageDataSimple(); return new ImageDataSimple();
} }
final CounterOutputStream counter = new CounterOutputStream(os); final CounterOutputStream counter = new CounterOutputStream(os);
@ -85,7 +86,8 @@ public class PSystemDot extends AbstractPSystem {
} }
if (counter.getLength() == 0) { if (counter.getLength() == 0) {
final TextBlock result = GraphicStrings.createForError(Arrays.asList("Graphivz has crashed"), false); final TextBlock result = GraphicStrings.createForError(Arrays.asList("Graphivz has crashed"), false);
UGraphicUtils.writeImage(os, null, fileFormat, new ColorMapperIdentity(), HtmlColorUtils.WHITE, result); UGraphicUtils.writeImage(os, null, fileFormat, seed(), new ColorMapperIdentity(),
HtmlColorUtils.WHITE, result);
} }
return new ImageDataSimple(); return new ImageDataSimple();

View File

@ -77,7 +77,7 @@ public class PSystemDitaa extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
if (fileFormat.getFileFormat() == FileFormat.ATXT) { if (fileFormat.getFileFormat() == FileFormat.ATXT) {
os.write(getSource().getPlainString().getBytes()); os.write(getSource().getPlainString().getBytes());

View File

@ -64,27 +64,27 @@ import net.sourceforge.plantuml.version.PSystemVersion;
public class PSystemDonors extends AbstractPSystem { public class PSystemDonors extends AbstractPSystem {
public static final String DONORS = "UDfbL4jksp0GtSyfk1RIGoXsxDI_17QQ0jcDfR75c29TKd8ghOAUeK3NlKABB8eMsVG2oeqwSYkJIWa8" public static final String DONORS = "UDfbL4jksp0GtSyfk1RIGoXsxDI_17QQ0jcDfR75c29TKd8ghOAUeK3NlKABB8eMsVG2oeqwSYkJIWaO"
+ "q8Z3uNipxobMqRz55gwf82jYNHWjCO4RYlmoESoC3ws3k3kAQnXRlqKLh6YDhf2enS9a6cAT6Yl6XegQ" + "CCNXp7ipxp5MqRz55gwf82jYNHWjCO4RYlmoESoCtre7SNSLrp2s_eWgMD4QNI5HYuN9DCGwDLQC3HKr"
+ "sjVDXZEwTDGmm-0YNS1GTe5K4FlIvW2hqaEeO2oZ_j869XtAqi6ge7r6MWoCsJE_ONSFEPZchuuQ2mEZ" + "jNyt6uxemb7338D2ke2Xx3PIGUnJcmEiIW-XWh6C-aiRc7GeImUhWlOPQJ4mPi_yXbqTSZ3DNrqr5WP6"
+ "f1PBKpg2IVbgFxetJAGBzXBc0MhCmv2lYXLzH9roEmUPvAfRj1KpNPvewoqiGlH53LTA7lZ0K2OxHdxQ" + "IIsMfdG4a_BLUNHlc4YtsKkO1wWn3xTSAbRq4NNAxHnaahDkqLRCT7cYhRUm2D4NDLmfUU0BGvdi6Fdf"
+ "aHektAcq3a14T81XdSl2LcA6cKaH9ctJxpBaya5UHCgFYzUkuZPfB3YFyJ6koL_mjEknqYc7Dk6UZ71j" + "H6guSAVKEW0HqG66TIuBMuaPPYP5cBHDlykGqmTn4Ia_BbwxYjkaiU0uniUu9d_1qwx7IgUyjGdtP8Hh"
+ "gvrvS3l9XHGVkxA5hE7IPwS6vZB9I8bpbAeA6QWw1ECSJ0Zrcmac7qfoObYkBV8ibUTxQ-uBIZ8njUZG" + "M-tCWzj9JgJusfKjP0sNFZerC9T9HagSerHLo43L8HZdO4Aetqmm-L2I4yDoRP5dgJpVMtDVK9A9gKM7"
+ "GzeIIpIOs4EhB4uHKtEGeL2EKddd2Kk4PI3UzegGPtJFf_U1hCokxSoviQXHxS_47HLezWwMJ11jAgQo" + "7jAMMAB1n1vQPN68c9g338LobCexJrWYB0FnjYL2dj4ztzu7iZAxjZFdng96jJyJTrIWsJjOCa6qgPZA"
+ "7IsCbB5jl-U_Vobr7BeNX0h4oNAQdUHaiUjsE_MipyZ1DNRoMCeUu5X9iK9CsJfsI-8zwItPCp6FRzwk" + "ThGmKiQs_Px__gNKSUXU42eG9yjfTfAJnQxRxTIpFYC7rzZ9OobxW6CbnGenPUlOBOdtfBTapyGyldcx"
+ "OY_jo6WOKyyo8NETi4HoSSkeXopQgS-qr4wMpJ8ZWej3gFm3mi8NeRm36GKqngLaNPGvYP4fgV3zJHoC" + "Yhsq8wDXJ3tBXCnrmXB9nIsZ7h9efpxIKZjPDikC22uEeV8F20kVXF8EP1JG69UITL7c94QcfCBtDt4m"
+ "miaSkNWrw3fi6yDTo2rhQ2LpRq46n4xUj9r6TdK0Eb8Aci_DKr2-UMf-m23hMRjYuvNhuu_0QlR2fUd1" + "2YTpvEBLeEkmRGnt8RUiePNClGKP43jvqtOQsTK1w4WfQ3utJq7wvgdv0OEiP-sAZLUkZm-1rUo5IzE3"
+ "6PFPR2nLOY5p7jm4__-hB763IimhfzWZpTVcwUMn-TvU9PelpNFpitb--SJF8t_w1XUMQZ55bREpBiDP" + "CoQpsLYgn4BcFBW9_l-gB763IimhfzWZpTVcwUMn-TwM4isNvhdvsJo_VEBV8t_w1XUMQZ55bREpBiDP"
+ "jt8brkivgNPJmny9r86N"; + "jt8brkivgVPG1sFZAZ9u5QE87ya-2nRO7yKAYtS0";
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
final UDrawable result = getGraphicStrings(); final UDrawable result = getGraphicStrings();
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE, final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE,
getMetadata(), null, 0, 0, null, false); getMetadata(), null, 0, 0, null, false);
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormat, os); return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
} }
private UDrawable getGraphicStrings() throws IOException { private UDrawable getGraphicStrings() throws IOException {

View File

@ -70,13 +70,13 @@ public class PSystemAppleTwo extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
final TextBlockBackcolored result = getGraphicStrings(); final TextBlockBackcolored result = getGraphicStrings();
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(), final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
getMetadata(), null, 0, 0, null, false); getMetadata(), null, 0, 0, null, false);
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormat, os); return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
} }
private TextBlockBackcolored getGraphicStrings() throws IOException { private TextBlockBackcolored getGraphicStrings() throws IOException {

View File

@ -59,7 +59,7 @@ public class PSystemCharlie extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.BLACK, final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.BLACK,
getMetadata(), null, 0, 0, null, false); getMetadata(), null, 0, 0, null, false);
@ -70,7 +70,7 @@ public class PSystemCharlie extends AbstractPSystem {
ug.draw(im); ug.draw(im);
} }
}); });
return imageBuilder.writeImageTOBEMOVED(fileFormat, os); return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
} }
public DiagramDescription getDescription() { public DiagramDescription getDescription() {

View File

@ -35,7 +35,6 @@
*/ */
package net.sourceforge.plantuml.eggs; package net.sourceforge.plantuml.eggs;
import java.awt.Font;
import java.awt.geom.Dimension2D; import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import java.io.IOException; import java.io.IOException;
@ -90,12 +89,12 @@ public class PSystemColors extends AbstractPSystem implements UDrawable {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE, final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE,
getMetadata(), null, 0, 0, null, false); getMetadata(), null, 0, 0, null, false);
imageBuilder.setUDrawable(this); imageBuilder.setUDrawable(this);
return imageBuilder.writeImageTOBEMOVED(fileFormat, os); return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
} }
public DiagramDescription getDescription() { public DiagramDescription getDescription() {

View File

@ -62,13 +62,13 @@ public class PSystemEgg extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
final TextBlockBackcolored result = getGraphicStrings(); final TextBlockBackcolored result = getGraphicStrings();
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(), final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
getMetadata(), null, 0, 0, null, false); getMetadata(), null, 0, 0, null, false);
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormat, os); return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
} }
private TextBlockBackcolored getGraphicStrings() throws IOException { private TextBlockBackcolored getGraphicStrings() throws IOException {

View File

@ -57,12 +57,14 @@ public class PSystemLost extends AbstractPSystem {
strings.add("Thank you for choosing Oceanic Airlines."); strings.add("Thank you for choosing Oceanic Airlines.");
} }
@Override final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) throws IOException { @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException {
final TextBlockBackcolored result = getGraphicStrings(); final TextBlockBackcolored result = getGraphicStrings();
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(), final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
getMetadata(), null, 0, 0, null, false); getMetadata(), null, 0, 0, null, false);
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormat, os); return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
} }
private TextBlockBackcolored getGraphicStrings() throws IOException { private TextBlockBackcolored getGraphicStrings() throws IOException {

View File

@ -53,7 +53,7 @@ public class PSystemPath extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
return path.writeImage(os); return path.writeImage(os);
} }

View File

@ -78,13 +78,13 @@ public class PSystemRIP extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
final TextBlockBackcolored result = getGraphicStrings(); final TextBlockBackcolored result = getGraphicStrings();
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(), final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
getMetadata(), null, 0, 0, null, false); getMetadata(), null, 0, 0, null, false);
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormat, os); return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
} }
private TextBlockBackcolored getGraphicStrings() throws IOException { private TextBlockBackcolored getGraphicStrings() throws IOException {

View File

@ -81,14 +81,14 @@ public class PSystemWelcome extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
final TextBlockBackcolored result = getGraphicStrings(); final TextBlockBackcolored result = getGraphicStrings();
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(), final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
getMetadata(), null, 0, 0, null, false); getMetadata(), null, 0, 0, null, false);
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
// imageBuilder.setUDrawable(TextBlockUtils.withMargin(result, 4, 4)); // imageBuilder.setUDrawable(TextBlockUtils.withMargin(result, 4, 4));
return imageBuilder.writeImageTOBEMOVED(fileFormat, os); return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
} }
public TextBlockBackcolored getGraphicStrings() throws IOException { public TextBlockBackcolored getGraphicStrings() throws IOException {

View File

@ -123,8 +123,10 @@ public class FlowDiagram extends UmlDiagram implements TextBlock {
} }
@Override @Override
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) throws IOException { protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
UGraphicUtils.writeImage(os, null, fileFormatOption, new ColorMapperIdentity(), HtmlColorUtils.WHITE, this); throws IOException {
UGraphicUtils.writeImage(os, null, fileFormatOption, seed(), new ColorMapperIdentity(),
HtmlColorUtils.WHITE, this);
return new ImageDataSimple(); return new ImageDataSimple();
} }
@ -144,8 +146,8 @@ public class FlowDiagram extends UmlDiagram implements TextBlock {
final Dimension2D dimBox = box.calculateDimension(stringBounder); final Dimension2D dimBox = box.calculateDimension(stringBounder);
final double deltaX = SINGLE_SIZE_X * 2 - dimBox.getWidth(); final double deltaX = SINGLE_SIZE_X * 2 - dimBox.getWidth();
final double deltaY = SINGLE_SIZE_Y * 2 - dimBox.getHeight(); final double deltaY = SINGLE_SIZE_Y * 2 - dimBox.getHeight();
box.drawU(ug.apply(new UTranslate((x + xmin * SINGLE_SIZE_X + deltaX / 2), (y + ymin box.drawU(ug.apply(new UTranslate((x + xmin * SINGLE_SIZE_X + deltaX / 2),
* SINGLE_SIZE_Y + deltaY / 2)))); (y + ymin * SINGLE_SIZE_Y + deltaY / 2))));
} }
ug = ug.apply(new UChangeColor(HtmlColorUtils.MY_RED)); ug = ug.apply(new UChangeColor(HtmlColorUtils.MY_RED));
ug = ug.apply(new UChangeBackColor(HtmlColorUtils.MY_RED)); ug = ug.apply(new UChangeBackColor(HtmlColorUtils.MY_RED));

View File

@ -70,13 +70,13 @@ public class PSystemListFonts extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
final TextBlockBackcolored result = getGraphicStrings(); final TextBlockBackcolored result = getGraphicStrings();
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(), final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
getMetadata(), null, 0, 0, null, false); getMetadata(), null, 0, 0, null, false);
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormat, os); return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
} }
private TextBlockBackcolored getGraphicStrings() throws IOException { private TextBlockBackcolored getGraphicStrings() throws IOException {

View File

@ -171,7 +171,7 @@ public class FtpConnexion {
done = true; done = true;
if (desc.getDescription().startsWith("(Error)")) { if (desc.getDescription().startsWith("(Error)")) {
final ByteArrayOutputStream errBaos = new ByteArrayOutputStream(); final ByteArrayOutputStream errBaos = new ByteArrayOutputStream();
sourceStringReader.generateImage(errBaos, new FileFormatOption(FileFormat.ATXT)); sourceStringReader.outputImage(errBaos, new FileFormatOption(FileFormat.ATXT));
errBaos.close(); errBaos.close();
outgoing.put(errorFileName, errBaos.toByteArray()); outgoing.put(errorFileName, errBaos.toByteArray());
} }

View File

@ -229,7 +229,11 @@ public class QuoteUtils {
"Znvf vy pbaanvg cnf Enbhy, pr zrp! vy in nibve ha erirvy cravoyr.", "Znvf vy pbaanvg cnf Enbhy, pr zrp! vy in nibve ha erirvy cravoyr.",
"W'nv ibhyh rger qvcybzngr n pnhfr qr ibhf gbhf, rivgre dhr yr fnat pbhyr.", "W'nv ibhyh rger qvcybzngr n pnhfr qr ibhf gbhf, rivgre dhr yr fnat pbhyr.",
"Vtabenapr oevatf punbf, abg xabjyrqtr.", "Yrneavat vf nyjnlf n cnvashy cebprff.", "Vtabenapr oevatf punbf, abg xabjyrqtr.", "Yrneavat vf nyjnlf n cnvashy cebprff.",
"V'z fbeel, ner lbh sebz gur cnfg ?", "Unir lbh gevrq gheavat vg bss naq ba ntnva ?"); "V'z fbeel, ner lbh sebz gur cnfg ?", "Unir lbh gevrq gheavat vg bss naq ba ntnva ?",
"Vs lbh qba'g xabj jurer lbh ner tbvat nal ebnq pna gnxr lbh gurer",
"Ortva ng gur ortvaavat, naq tb ba gvyy lbh pbzr gb gur raq: gura fgbc"
);
private QuoteUtils() { private QuoteUtils() {
} }

View File

@ -65,7 +65,7 @@ public class PSystemJcckit extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);

View File

@ -310,7 +310,8 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker {
final IEntityImage image = printEntityInternal(ent); final IEntityImage image = printEntityInternal(ent);
final Dimension2D dim = image.calculateDimension(stringBounder); final Dimension2D dim = image.calculateDimension(stringBounder);
final Shape shape = new Shape(image, image.getShapeType(), dim.getWidth(), dim.getHeight(), final Shape shape = new Shape(image, image.getShapeType(), dim.getWidth(), dim.getHeight(),
dotStringFactory.getColorSequence(), ent.isTop(), image.getShield(stringBounder), ent.getEntityPosition()); dotStringFactory.getColorSequence(), ent.isTop(), image.getShield(stringBounder),
ent.getEntityPosition());
dotStringFactory.addShape(shape); dotStringFactory.addShape(shape);
getBibliotekon().putShape(ent, shape); getBibliotekon().putShape(ent, shape);
} }
@ -433,19 +434,19 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker {
final double scale = 1; final double scale = 1;
final ImageBuilder imageBuilder = new ImageBuilder(diagram.getSkinParam(), final ImageBuilder imageBuilder = new ImageBuilder(diagram.getSkinParam(), scale,
scale, fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null, null, 0, fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null, null, 0, 10,
10, diagram.getAnimation()); diagram.getAnimation());
imageBuilder.setUDrawable(new Drawing(null)); imageBuilder.setUDrawable(new Drawing(null));
final Dimension2D dim = imageBuilder.getFinalDimension(stringBounder); final Dimension2D dim = imageBuilder.getFinalDimension(stringBounder);
imageBuilder.setUDrawable(new Drawing(new YMirror(dim.getHeight()))); imageBuilder.setUDrawable(new Drawing(new YMirror(dim.getHeight())));
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os); return imageBuilder.writeImageTOBEMOVED(fileFormatOption, diagram.seed(), os);
} catch (Throwable e) { } catch (Throwable e) {
UmlDiagram.exportDiagramError(os, e, fileFormatOption, diagram.getMetadata(), diagram.getFlashData(), UmlDiagram.exportDiagramError(os, e, fileFormatOption, diagram.seed(), diagram.getMetadata(),
getFailureText3(e)); diagram.getFlashData(), getFailureText3(e));
return new ImageDataSimple(); return new ImageDataSimple();
} finally { } finally {
Z.close(); Z.close();
@ -568,7 +569,8 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker {
final IEntityImage image = printEntityInternal(ent); final IEntityImage image = printEntityInternal(ent);
final Dimension2D dim = image.calculateDimension(stringBounder); final Dimension2D dim = image.calculateDimension(stringBounder);
final Shape shape = new Shape(image, image.getShapeType(), dim.getWidth(), dim.getHeight(), final Shape shape = new Shape(image, image.getShapeType(), dim.getWidth(), dim.getHeight(),
dotStringFactory.getColorSequence(), ent.isTop(), image.getShield(stringBounder), ent.getEntityPosition()); dotStringFactory.getColorSequence(), ent.isTop(), image.getShield(stringBounder),
ent.getEntityPosition());
// dotStringFactory.addShape(shape); // dotStringFactory.addShape(shape);
getBibliotekon().putShape(ent, shape); getBibliotekon().putShape(ent, shape);
} }

View File

@ -63,7 +63,7 @@ public class PSystemTree extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
final ImageBuilder builder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE, null, null, final ImageBuilder builder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE, null, null,
5, 5, null, false); 5, 5, null, false);
@ -76,7 +76,7 @@ public class PSystemTree extends AbstractPSystem {
} else { } else {
builder.setUDrawable(new GTileOneLevelFactory().createGTile(root)); builder.setUDrawable(new GTileOneLevelFactory().createGTile(root));
} }
return builder.writeImageTOBEMOVED(fileFormat, os); return builder.writeImageTOBEMOVED(fileFormat, seed, os);
} }
public CommandExecutionResult addParagraph(int level, String label) { public CommandExecutionResult addParagraph(int level, String label) {

View File

@ -61,7 +61,7 @@ public class PSystemLogo extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
final int width = 640; final int width = 640;
final int height = 480; final int height = 480;

View File

@ -56,7 +56,7 @@ public class PSystemLatex extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
final ScientificEquationSafe asciiMath = ScientificEquationSafe.fromLatex(latex); final ScientificEquationSafe asciiMath = ScientificEquationSafe.fromLatex(latex);
return asciiMath.export(os, fileFormat, 1, Color.BLACK, Color.WHITE); return asciiMath.export(os, fileFormat, 1, Color.BLACK, Color.WHITE);

View File

@ -56,7 +56,7 @@ public class PSystemMath extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
final ScientificEquationSafe asciiMath = ScientificEquationSafe.fromAsciiMath(math); final ScientificEquationSafe asciiMath = ScientificEquationSafe.fromAsciiMath(math);
return asciiMath.export(os, fileFormat, 1, Color.BLACK, Color.WHITE); return asciiMath.export(os, fileFormat, 1, Color.BLACK, Color.WHITE);

View File

@ -99,7 +99,7 @@ public class ScientificEquationSafe {
final ImageBuilder imageBuilder = getRollback(); final ImageBuilder imageBuilder = getRollback();
final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ByteArrayOutputStream baos = new ByteArrayOutputStream();
try { try {
dimSvg = imageBuilder.writeImageTOBEMOVED(new FileFormatOption(FileFormat.SVG), baos); dimSvg = imageBuilder.writeImageTOBEMOVED(new FileFormatOption(FileFormat.SVG), 42, baos);
} catch (IOException e1) { } catch (IOException e1) {
return null; return null;
} }
@ -115,7 +115,7 @@ public class ScientificEquationSafe {
final ImageBuilder imageBuilder = getRollback(); final ImageBuilder imageBuilder = getRollback();
final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ByteArrayOutputStream baos = new ByteArrayOutputStream();
try { try {
imageBuilder.writeImageTOBEMOVED(new FileFormatOption(FileFormat.PNG), baos); imageBuilder.writeImageTOBEMOVED(new FileFormatOption(FileFormat.PNG), 42, baos);
return ImageIO.read(new ByteArrayInputStream(baos.toByteArray())); return ImageIO.read(new ByteArrayInputStream(baos.toByteArray()));
} catch (IOException e1) { } catch (IOException e1) {
return null; return null;

View File

@ -60,13 +60,13 @@ import net.sourceforge.plantuml.ugraphic.ImageBuilder;
public class PSystemListOpenIconic extends AbstractPSystem { public class PSystemListOpenIconic extends AbstractPSystem {
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
final UDrawable result = getGraphicStrings(); final UDrawable result = getGraphicStrings();
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE, final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE,
getMetadata(), null, 0, 0, null, false); getMetadata(), null, 0, 0, null, false);
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormat, os); return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
} }
private UDrawable getGraphicStrings() throws IOException { private UDrawable getGraphicStrings() throws IOException {

View File

@ -57,7 +57,7 @@ public class PSystemOpenIconic extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
final OpenIcon icon = OpenIcon.retrieve(iconName); final OpenIcon icon = OpenIcon.retrieve(iconName);
// final Dimension2D dim = new Dimension2DDouble(100, 100); // final Dimension2D dim = new Dimension2DDouble(100, 100);
@ -65,7 +65,7 @@ public class PSystemOpenIconic extends AbstractPSystem {
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, null, null, null, 5, 5, final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, null, null, null, 5, 5,
null, false); null, false);
imageBuilder.setUDrawable(icon.asTextBlock(HtmlColorUtils.BLACK, factor)); imageBuilder.setUDrawable(icon.asTextBlock(HtmlColorUtils.BLACK, factor));
return imageBuilder.writeImageTOBEMOVED(fileFormat, os); return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
// UGraphic2 ug = fileFormat.createUGraphic(dim); // UGraphic2 ug = fileFormat.createUGraphic(dim);
// ug = (UGraphic2) ug.apply(new UTranslate(10, 10)); // ug = (UGraphic2) ug.apply(new UTranslate(10, 10));

View File

@ -95,13 +95,13 @@ public class PSystemOregon extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
final TextBlockBackcolored result = getGraphicStrings(); final TextBlockBackcolored result = getGraphicStrings();
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(), final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
getMetadata(), null, 0, 0, null, false); getMetadata(), null, 0, 0, null, false);
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormat, os); return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
} }
private TextBlockBackcolored getGraphicStrings() throws IOException { private TextBlockBackcolored getGraphicStrings() throws IOException {

View File

@ -45,38 +45,27 @@ import java.util.List;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileUtils;
import net.sourceforge.plantuml.Log; import net.sourceforge.plantuml.Log;
import net.sourceforge.plantuml.SplitParam; import net.sourceforge.plantuml.SplitParam;
import net.sourceforge.plantuml.SuggestedFile;
public class PngSplitter { public class PngSplitter {
private final List<File> files = new ArrayList<File>(); private final List<File> files = new ArrayList<File>();
public static void main(String[] args) throws IOException { public PngSplitter(SuggestedFile pngFile, int horizontalPages, int verticalPages, String source, int dpi,
final File f = new File(args[0]);
final int x = Integer.parseInt(args[1]);
final int y = Integer.parseInt(args[2]);
final File cp = new File(f.getParent(), f.getName().replaceAll("\\.png$", "_000.png"));
FileUtils.copyToFile(f, cp);
new PngSplitter(cp, x, y, "", 96, false, new SplitParam());
}
public PngSplitter(File pngFile, int horizontalPages, int verticalPages, String source, int dpi,
boolean isWithMetadata, SplitParam splitParam) throws IOException { boolean isWithMetadata, SplitParam splitParam) throws IOException {
if (horizontalPages == 1 && verticalPages == 1) { if (horizontalPages == 1 && verticalPages == 1) {
this.files.add(pngFile); this.files.add(pngFile.getFile(0));
return; return;
} }
Log.info("Splitting " + horizontalPages + " x " + verticalPages); Log.info("Splitting " + horizontalPages + " x " + verticalPages);
final File full = new File(pngFile.getParentFile(), pngFile.getName() + ".tmp"); final File full = pngFile.getTmpFile(); // new File(pngFile.getParentFile(), pngFile.getName() + ".tmp");
// Thread.yield(); // Thread.yield();
full.delete(); full.delete();
// Thread.yield(); // Thread.yield();
final boolean ok = pngFile.renameTo(full); final boolean ok = pngFile.getFile(0).renameTo(full);
// Thread.yield(); // Thread.yield();
if (ok == false) { if (ok == false) {
throw new IOException("Cannot rename"); throw new IOException("Cannot rename");
@ -91,7 +80,7 @@ public class PngSplitter {
int x = 0; int x = 0;
for (int i = 0; i < horizontalPages; i++) { for (int i = 0; i < horizontalPages; i++) {
for (int j = 0; j < verticalPages; j++) { for (int j = 0; j < verticalPages; j++) {
final File f = FileFormat.PNG.computeFilename(pngFile, x++); final File f = pngFile.getFile(x++);
this.files.add(f); this.files.add(f);
final int width = horizontalSegment.getLen(i); final int width = horizontalSegment.getLen(i);
final int height = verticalSegment.getLen(j); final int height = verticalSegment.getLen(j);

View File

@ -96,7 +96,7 @@ class PrintSkin extends AbstractPSystem {
// } // }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormatOption) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormatOption, long seed)
throws IOException { throws IOException {
final BufferedImage im = createImage(); final BufferedImage im = createImage();
final ImageData imageData = new ImageDataSimple(im.getWidth(), (int) maxYpos); final ImageData imageData = new ImageDataSimple(im.getWidth(), (int) maxYpos);

View File

@ -73,7 +73,7 @@ public class PSystemProject extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormatOption) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormatOption, long seed)
throws IOException { throws IOException {
final GanttDiagramUnused diagram = new GanttDiagramUnused(project); final GanttDiagramUnused diagram = new GanttDiagramUnused(project);
final FileFormat fileFormat = fileFormatOption.getFileFormat(); final FileFormat fileFormat = fileFormatOption.getFileFormat();
@ -82,7 +82,7 @@ public class PSystemProject extends AbstractPSystem {
PngIO.write(im, os, fileFormatOption.isWithMetadata() ? getMetadata() : null, 96); PngIO.write(im, os, fileFormatOption.isWithMetadata() ? getMetadata() : null, 96);
} else if (fileFormat == FileFormat.SVG) { } else if (fileFormat == FileFormat.SVG) {
final UGraphicSvg svg = new UGraphicSvg(colorMapper, StringUtils.getAsHtml(background), false, 1.0, final UGraphicSvg svg = new UGraphicSvg(colorMapper, StringUtils.getAsHtml(background), false, 1.0,
fileFormatOption.getSvgLinkTarget(), fileFormatOption.getHoverColor(), fileFormatOption.getRandom()); fileFormatOption.getSvgLinkTarget(), fileFormatOption.getHoverColor(), seed());
diagram.draw(svg, 0, 0); diagram.draw(svg, 0, 0);
svg.createXml(os, fileFormatOption.isWithMetadata() ? getMetadata() : null); svg.createXml(os, fileFormatOption.isWithMetadata() ? getMetadata() : null);
} else if (fileFormat == FileFormat.EPS) { } else if (fileFormat == FileFormat.EPS) {

View File

@ -72,7 +72,7 @@ public class PSystemProject2 extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormatOption) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormatOption, long seed)
throws IOException { throws IOException {
final GanttDiagram2 diagram = new GanttDiagram2(project); final GanttDiagram2 diagram = new GanttDiagram2(project);
final FileFormat fileFormat = fileFormatOption.getFileFormat(); final FileFormat fileFormat = fileFormatOption.getFileFormat();
@ -81,7 +81,7 @@ public class PSystemProject2 extends AbstractPSystem {
PngIO.write(im, os, fileFormatOption.isWithMetadata() ? getMetadata() : null, 96); PngIO.write(im, os, fileFormatOption.isWithMetadata() ? getMetadata() : null, 96);
} else if (fileFormat == FileFormat.SVG) { } else if (fileFormat == FileFormat.SVG) {
final UGraphicSvg svg = new UGraphicSvg(colorMapper, StringUtils.getAsHtml(background), false, 1.0, final UGraphicSvg svg = new UGraphicSvg(colorMapper, StringUtils.getAsHtml(background), false, 1.0,
fileFormatOption.getSvgLinkTarget(), fileFormatOption.getHoverColor(), fileFormatOption.getRandom()); fileFormatOption.getSvgLinkTarget(), fileFormatOption.getHoverColor(), seed());
diagram.draw(svg, 0, 0); diagram.draw(svg, 0, 0);
svg.createXml(os, fileFormatOption.isWithMetadata() ? getMetadata() : null); svg.createXml(os, fileFormatOption.isWithMetadata() ? getMetadata() : null);
} else if (fileFormat == FileFormat.EPS) { } else if (fileFormat == FileFormat.EPS) {

View File

@ -83,7 +83,7 @@ public class GanttDiagram extends AbstractPSystem implements Subject {
} }
@Override @Override
protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption) protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption, long seed)
throws IOException { throws IOException {
final double dpiFactor = 1; final double dpiFactor = 1;
final double margin = 10; final double margin = 10;
@ -97,7 +97,7 @@ public class GanttDiagram extends AbstractPSystem implements Subject {
false); false);
imageBuilder.setUDrawable(getUDrawable()); imageBuilder.setUDrawable(getUDrawable());
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os); return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed, os);
} }
private void sortTasks() { private void sortTasks() {

View File

@ -74,7 +74,7 @@ public class PSystemSalt extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
try { try {
final Element salt = SaltUtils.createElement(data); final Element salt = SaltUtils.createElement(data);
@ -90,10 +90,10 @@ public class PSystemSalt extends AbstractPSystem {
salt.drawU(ug, 1, new Dimension2DDouble(size.getWidth(), size.getHeight())); salt.drawU(ug, 1, new Dimension2DDouble(size.getWidth(), size.getHeight()));
} }
}); });
return builder.writeImageTOBEMOVED(fileFormat, os); return builder.writeImageTOBEMOVED(fileFormat, seed, os);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
UmlDiagram.exportDiagramError(os, e, fileFormat, getMetadata(), "none", new ArrayList<String>()); UmlDiagram.exportDiagramError(os, e, fileFormat, seed, getMetadata(), "none", new ArrayList<String>());
return new ImageDataSimple(); return new ImageDataSimple();
} }
} }

View File

@ -231,7 +231,7 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker {
} }
}); });
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os); return imageBuilder.writeImageTOBEMOVED(fileFormatOption, diagram.seed(), os);
} }
private void drawFooter(SequenceDiagramArea area, UGraphic ug) { private void drawFooter(SequenceDiagramArea area, UGraphic ug) {

View File

@ -178,7 +178,7 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker {
} }
}); });
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os); return imageBuilder.writeImageTOBEMOVED(fileFormatOption, diagram.seed(), os);
} }

View File

@ -58,13 +58,13 @@ public class PSystemStats extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
final TextBlockBackcolored result = getGraphicStrings(); final TextBlockBackcolored result = getGraphicStrings();
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(), final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
getMetadata(), null, 0, 0, null, false); getMetadata(), null, 0, 0, null, false);
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormat, os); return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
} }
public static PSystemStats create() throws IOException { public static PSystemStats create() throws IOException {

View File

@ -48,7 +48,7 @@ public class PSystemSudoku extends AbstractPSystem {
final private ISudoku sudoku; final private ISudoku sudoku;
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
return new GraphicsSudoku(sudoku).writeImage(os); return new GraphicsSudoku(sudoku).writeImage(os);
} }

View File

@ -117,11 +117,11 @@ public final class CucaDiagramFileMakerSvek implements CucaDiagramFileMaker {
final Dimension2D dim = result.calculateDimension(fileFormatOption.getDefaultStringBounder()); final Dimension2D dim = result.calculateDimension(fileFormatOption.getDefaultStringBounder());
final double scale = getScale(fileFormatOption, dim); final double scale = getScale(fileFormatOption, dim);
final ImageBuilder imageBuilder = new ImageBuilder(diagram.getSkinParam(), final ImageBuilder imageBuilder = new ImageBuilder(diagram.getSkinParam(), scale,
scale, fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null, warningOrError, 0, fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null, warningOrError, 0, 10,
10, diagram.getAnimation(), result.getBackcolor()); diagram.getAnimation(), result.getBackcolor());
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os); return imageBuilder.writeImageTOBEMOVED(fileFormatOption, diagram.seed(), os);
} }

View File

@ -116,11 +116,11 @@ public class SvgGraphics {
} }
} }
public SvgGraphics(double scale, String hover, Random rnd) { public SvgGraphics(double scale, String hover, long seed) {
this(null, scale, hover, rnd); this(null, scale, hover, seed);
} }
public SvgGraphics(String backcolor, double scale, String hover, Random rnd) { public SvgGraphics(String backcolor, double scale, String hover, long seed) {
try { try {
this.scale = scale; this.scale = scale;
this.document = getDocument(); this.document = getDocument();
@ -133,10 +133,9 @@ public class SvgGraphics {
defs = simpleElement("defs"); defs = simpleElement("defs");
gRoot = simpleElement("g"); gRoot = simpleElement("g");
strokeWidth = "" + scale; strokeWidth = "" + scale;
// final Random rnd = new Random(); this.filterUid = "b" + getSeed(seed);
this.filterUid = "b" + getRandomString(rnd); this.shadowId = "f" + getSeed(seed);
this.shadowId = "f" + getRandomString(rnd); this.gradientId = "g" + getSeed(seed);
this.gradientId = "g" + getRandomString(rnd);
if (hover != null) { if (hover != null) {
defs.appendChild(getPathHover(hover)); defs.appendChild(getPathHover(hover));
} }
@ -154,16 +153,8 @@ public class SvgGraphics {
return style; return style;
} }
private static String getRandomString(final Random rnd) { private static String getSeed(final long seed) {
String result = Integer.toString(Math.abs(rnd.nextInt()), 36); return Long.toString(Math.abs(seed), 36);
while (result.length() < 6) {
result = "0" + result;
}
return result;
}
public static void main(String[] args) {
System.err.println(getRandomString(new Random()));
} }
private Element pendingBackground; private Element pendingBackground;

View File

@ -310,7 +310,7 @@ class ImageWindow2 extends JFrame {
imageBuilder.setUDrawable(error); imageBuilder.setUDrawable(error);
final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ByteArrayOutputStream baos = new ByteArrayOutputStream();
try { try {
imageBuilder.writeImageTOBEMOVED(new FileFormatOption(FileFormat.PNG), baos); imageBuilder.writeImageTOBEMOVED(new FileFormatOption(FileFormat.PNG), 42, baos);
baos.close(); baos.close();
image = ImageIO.read(new ByteArrayInputStream(baos.toByteArray())); image = ImageIO.read(new ByteArrayInputStream(baos.toByteArray()));
} catch (IOException e) { } catch (IOException e) {

View File

@ -81,7 +81,7 @@ class AcceptTelnetClient extends Thread {
final String uml = runInternal(); final String uml = runInternal();
Log.println("UML=" + uml); Log.println("UML=" + uml);
final SourceStringReader s = new SourceStringReader(uml); final SourceStringReader s = new SourceStringReader(uml);
s.generateImage(os, new FileFormatOption(FileFormat.ATXT)); s.outputImage(os, new FileFormatOption(FileFormat.ATXT));
os.close(); os.close();
br.close(); br.close();
} catch (IOException e) { } catch (IOException e) {

View File

@ -0,0 +1,69 @@
/* ========================================================================
* 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.timingdiagram;
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 CommandScalePixel extends SingleLineCommand2<TimingDiagram> {
public CommandScalePixel() {
super(getRegexConcat());
}
private static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("scale"), //
new RegexLeaf("[%s]+"), //
new RegexLeaf("TICK", "(\\d+)"), //
new RegexLeaf("[%s]+as[%s]+"), //
new RegexLeaf("PIXEL", "(\\d+)"), //
new RegexLeaf("[%s]+pixels?"), //
new RegexLeaf("[%s]*$"));
}
@Override
final protected CommandExecutionResult executeArg(TimingDiagram diagram, RegexResult arg) {
final long tick = Long.parseLong(arg.get("TICK", 0));
final long pixel = Long.parseLong(arg.get("PIXEL", 0));
diagram.scaleInPixels(tick, pixel);
return CommandExecutionResult.ok();
}
}

View File

@ -34,20 +34,22 @@
*/ */
package net.sourceforge.plantuml.timingdiagram; package net.sourceforge.plantuml.timingdiagram;
import java.math.BigDecimal;
public class TimeTick implements Comparable<TimeTick> { public class TimeTick implements Comparable<TimeTick> {
private final int time; private final BigDecimal time;
public TimeTick(int time) { public TimeTick(BigDecimal time) {
this.time = time; this.time = time;
} }
public final int getTime() { public final BigDecimal getTime() {
return time; return time;
} }
public int compareTo(TimeTick other) { public int compareTo(TimeTick other) {
return this.time - other.time; return this.time.compareTo(other.time);
} }
} }

View File

@ -34,12 +34,14 @@
*/ */
package net.sourceforge.plantuml.timingdiagram; package net.sourceforge.plantuml.timingdiagram;
import java.math.BigDecimal;
import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
public class TimeTickBuilder { public class TimeTickBuilder {
private static final String WITHOUT_AROBASE = "(\\+?)(\\d+)"; private static final String WITHOUT_AROBASE = "(\\+?)(\\d+\\.?\\d*)";
private static final String WITH_AROBASE = "@" + WITHOUT_AROBASE; private static final String WITH_AROBASE = "@" + WITHOUT_AROBASE;
public static RegexLeaf expressionAtWithoutArobase(String name) { public static RegexLeaf expressionAtWithoutArobase(String name) {
@ -60,9 +62,9 @@ public class TimeTickBuilder {
return clock.getNow(); return clock.getNow();
} }
final boolean isRelative = "+".equals(arg.get(name, 0)); final boolean isRelative = "+".equals(arg.get(name, 0));
int value = Integer.parseInt(number); BigDecimal value = new BigDecimal(number);
if (isRelative) { if (isRelative) {
value += clock.getNow().getTime(); value = clock.getNow().getTime().add(value);
} }
return new TimeTick(value); return new TimeTick(value);
} }

View File

@ -84,7 +84,7 @@ public class TimingDiagram extends UmlDiagram implements Clock {
getAnimation()); getAnimation());
imageBuilder.setUDrawable(getUDrawable()); imageBuilder.setUDrawable(getUDrawable());
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os); return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed(), os);
} }
private UDrawable getUDrawable() { private UDrawable getUDrawable() {
@ -207,4 +207,8 @@ public class TimingDiagram extends UmlDiagram implements Clock {
return lastPlayer; return lastPlayer;
} }
public void scaleInPixels(long tick, long pixel) {
ruler.scaleInPixels(tick, pixel);
}
} }

View File

@ -62,6 +62,7 @@ public class TimingDiagramFactory extends UmlDiagramFactory {
cmds.add(new CommandAtPlayer()); cmds.add(new CommandAtPlayer());
cmds.add(new CommandTimeMessage()); cmds.add(new CommandTimeMessage());
cmds.add(new CommandConstraint()); cmds.add(new CommandConstraint());
cmds.add(new CommandScalePixel());
return cmds; return cmds;
} }

View File

@ -35,6 +35,9 @@
package net.sourceforge.plantuml.timingdiagram; package net.sourceforge.plantuml.timingdiagram;
import java.awt.geom.Dimension2D; import java.awt.geom.Dimension2D;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.Set;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.TreeSet; import java.util.TreeSet;
@ -43,7 +46,9 @@ import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.ULine; import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UStroke;
@ -52,10 +57,36 @@ import net.sourceforge.plantuml.ugraphic.UTranslate;
public class TimingRuler { public class TimingRuler {
private final SortedSet<TimeTick> times = new TreeSet<TimeTick>(); private final SortedSet<TimeTick> times = new TreeSet<TimeTick>();
private int highestCommonFactor = -1; private long highestCommonFactor = -1;
private final ISkinParam skinParam; private final ISkinParam skinParam;
private final double tickIntervalInPixels = 50; private long tickIntervalInPixels = 50;
private long tickUnitary;
public void scaleInPixels(long tick, long pixel) {
this.tickIntervalInPixels = pixel;
this.tickUnitary = tick;
}
private long tickUnitary() {
if (tickUnitary == 0) {
return highestCommonFactor;
}
return tickUnitary;
}
private int getNbTick() {
return (int) (1 + getMax().getTime().longValue() / tickUnitary());
}
public double getWidth() {
return getPosInPixel(new BigDecimal((getNbTick()) * tickUnitary()));
}
private double getPosInPixel(double time) {
return time / tickUnitary() * tickIntervalInPixels;
}
public TimingRuler(ISkinParam skinParam) { public TimingRuler(ISkinParam skinParam) {
this.skinParam = skinParam; this.skinParam = skinParam;
@ -64,12 +95,12 @@ public class TimingRuler {
public void addTime(TimeTick time) { public void addTime(TimeTick time) {
final boolean added = times.add(time); final boolean added = times.add(time);
if (added) { if (added) {
int tick = time.getTime(); long tick = time.getTime().longValue();
if (tick > 0) { if (tick > 0) {
if (highestCommonFactor == -1) { if (highestCommonFactor == -1) {
highestCommonFactor = time.getTime(); highestCommonFactor = time.getTime().longValue();
} else { } else {
highestCommonFactor = computeHighestCommonFactor(highestCommonFactor, time.getTime()); highestCommonFactor = computeHighestCommonFactor(highestCommonFactor, time.getTime().longValue());
} }
} }
} }
@ -79,36 +110,43 @@ public class TimingRuler {
return new FontConfiguration(skinParam, FontParam.ACTIVITY, null); return new FontConfiguration(skinParam, FontParam.ACTIVITY, null);
} }
private TextBlock getTimeTextBlock(TimeTick time) { private TextBlock getTimeTextBlock(long time) {
final Display display = Display.getWithNewlines("" + time.getTime()); final Display display = Display.getWithNewlines("" + time);
return display.create(getFontConfiguration(), HorizontalAlignment.LEFT, skinParam); return display.create(getFontConfiguration(), HorizontalAlignment.LEFT, skinParam);
} }
public void draw(UGraphic ug) { public void draw(UGraphic ug) {
ug = ug.apply(new UStroke(2.0)); ug = ug.apply(new UStroke(2.0)).apply(new UChangeColor(HtmlColorUtils.BLACK));
final int nb = getNbTick();
// System.err.println("nb=" + nb);
final double tickHeight = 5; final double tickHeight = 5;
final ULine line = new ULine(0, tickHeight); final ULine line = new ULine(0, tickHeight);
final int nb = getNbTick();
for (int i = 0; i <= nb; i++) { for (int i = 0; i <= nb; i++) {
ug.apply(new UTranslate(tickIntervalInPixels * i, 0)).draw(line); ug.apply(new UTranslate(tickIntervalInPixels * i, 0)).draw(line);
} }
ug.draw(new ULine(nb * tickIntervalInPixels, 0)); ug.draw(new ULine(nb * tickIntervalInPixels, 0));
for (TimeTick tick : times) { for (long round : roundValues()) {
final TextBlock text = getTimeTextBlock(tick); final TextBlock text = getTimeTextBlock(round);
final Dimension2D dim = text.calculateDimension(ug.getStringBounder()); final Dimension2D dim = text.calculateDimension(ug.getStringBounder());
text.drawU(ug.apply(new UTranslate(getPosInPixel(tick) - dim.getWidth() / 2, tickHeight + 1))); text.drawU(ug.apply(new UTranslate(getPosInPixel(round) - dim.getWidth() / 2, tickHeight + 1)));
} }
} }
private int getNbTick() { private Collection<Long> roundValues() {
return 1 + getMax().getTime() / highestCommonFactor; final Set<Long> result = new TreeSet<Long>();
} if (tickUnitary == 0) {
for (TimeTick tick : times) {
public double getWidth() { final long round = tick.getTime().longValue();
return getPosInPixel((getNbTick()) * highestCommonFactor); result.add(round);
}
} else {
final int nb = getNbTick();
for (int i = 0; i <= nb; i++) {
final long round = tickUnitary * i;
result.add(round);
}
}
return result;
} }
private TimeTick getMax() { private TimeTick getMax() {
@ -118,8 +156,8 @@ public class TimingRuler {
return times.last(); return times.last();
} }
private static int computeHighestCommonFactor(int a, int b) { private static long computeHighestCommonFactor(long a, long b) {
int r = a; long r = a;
while (r != 0) { while (r != 0) {
r = a % b; r = a % b;
a = b; a = b;
@ -128,15 +166,15 @@ public class TimingRuler {
return (Math.abs(a)); return (Math.abs(a));
} }
public final double getPosInPixel(int time) { public final double getPosInPixel(BigDecimal time) {
return 1.0 * time / highestCommonFactor * tickIntervalInPixels; return getPosInPixel(time.doubleValue());
} }
public double getPosInPixel(TimeTick when) { public final double getPosInPixel(TimeTick when) {
return getPosInPixel(when.getTime()); return getPosInPixel(when.getTime());
} }
public double getMaxPosInPixel() { public final double getMaxPosInPixel() {
return getPosInPixel(getMax()); return getPosInPixel(getMax());
} }

View File

@ -157,7 +157,7 @@ public class FontChecker {
} }
private String getSvgImage(char c) throws IOException, TransformerException { private String getSvgImage(char c) throws IOException, TransformerException {
final SvgGraphics svg = new SvgGraphics(1.0, null, new Random()); final SvgGraphics svg = new SvgGraphics(1.0, null, 42);
svg.setStrokeColor("black"); svg.setStrokeColor("black");
svg.svgImage(getBufferedImage(c), 0, 0); svg.svgImage(getBufferedImage(c), 0, 0);
final ByteArrayOutputStream os = new ByteArrayOutputStream(); final ByteArrayOutputStream os = new ByteArrayOutputStream();
@ -183,7 +183,7 @@ public class FontChecker {
} }
}); });
final ByteArrayOutputStream os = new ByteArrayOutputStream(); final ByteArrayOutputStream os = new ByteArrayOutputStream();
imageBuilder.writeImageTOBEMOVED(new FileFormatOption(FileFormat.PNG), os); imageBuilder.writeImageTOBEMOVED(new FileFormatOption(FileFormat.PNG), 42, os);
os.close(); os.close();
return ImageIO.read(new ByteArrayInputStream(os.toByteArray())); return ImageIO.read(new ByteArrayInputStream(os.toByteArray()));
} }

View File

@ -46,7 +46,6 @@ import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Random;
import java.util.Set; import java.util.Set;
import java.util.concurrent.Semaphore; import java.util.concurrent.Semaphore;
@ -162,14 +161,15 @@ public class ImageBuilder {
this.udrawable = udrawable; this.udrawable = udrawable;
} }
public ImageData writeImageTOBEMOVED(FileFormatOption fileFormatOption, OutputStream os) throws IOException { public ImageData writeImageTOBEMOVED(FileFormatOption fileFormatOption, long seed, OutputStream os)
throws IOException {
final FileFormat fileFormat = fileFormatOption.getFileFormat(); final FileFormat fileFormat = fileFormatOption.getFileFormat();
if (fileFormat == FileFormat.MJPEG) { if (fileFormat == FileFormat.MJPEG) {
return writeImageMjpeg(os, fileFormat.getDefaultStringBounder()); return writeImageMjpeg(os, fileFormat.getDefaultStringBounder());
} else if (fileFormat == FileFormat.ANIMATED_GIF) { } else if (fileFormat == FileFormat.ANIMATED_GIF) {
return writeImageAnimatedGif(os, fileFormat.getDefaultStringBounder()); return writeImageAnimatedGif(os, fileFormat.getDefaultStringBounder());
} }
return writeImageInternal(fileFormatOption, os, animation); return writeImageInternal(fileFormatOption, seed, os, animation);
} }
private static Semaphore SEMAPHORE_SMALL; private static Semaphore SEMAPHORE_SMALL;
@ -204,8 +204,8 @@ public class ImageBuilder {
return SEMAPHORE_SMALL; return SEMAPHORE_SMALL;
} }
private ImageData writeImageInternal(FileFormatOption fileFormatOption, OutputStream os, Animation animationArg) private ImageData writeImageInternal(FileFormatOption fileFormatOption, long seed, OutputStream os,
throws IOException { Animation animationArg) throws IOException {
Dimension2D dim = getFinalDimension(fileFormatOption.getDefaultStringBounder()); Dimension2D dim = getFinalDimension(fileFormatOption.getDefaultStringBounder());
double dx = 0; double dx = 0;
double dy = 0; double dy = 0;
@ -228,7 +228,7 @@ public class ImageBuilder {
} }
} }
try { try {
final UGraphic2 ug = createUGraphic(fileFormatOption, dim, animationArg, dx, dy); final UGraphic2 ug = createUGraphic(fileFormatOption, seed, dim, animationArg, dx, dy);
UGraphic ug2 = ug; UGraphic ug2 = ug;
if (externalMargin1 > 0) { if (externalMargin1 > 0) {
ug2 = ug2.apply(new UTranslate(externalMargin1, externalMargin1)); ug2 = ug2.apply(new UTranslate(externalMargin1, externalMargin1));
@ -349,7 +349,7 @@ public class ImageBuilder {
private Image getAviImage(AffineTransformation affineTransform) throws IOException { private Image getAviImage(AffineTransformation affineTransform) throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ByteArrayOutputStream baos = new ByteArrayOutputStream();
writeImageInternal(new FileFormatOption(FileFormat.PNG), baos, Animation.singleton(affineTransform)); writeImageInternal(new FileFormatOption(FileFormat.PNG), 42, baos, Animation.singleton(affineTransform));
baos.close(); baos.close();
final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
@ -358,15 +358,15 @@ public class ImageBuilder {
return im; return im;
} }
private UGraphic2 createUGraphic(FileFormatOption fileFormatOption, final Dimension2D dim, Animation animationArg, private UGraphic2 createUGraphic(FileFormatOption fileFormatOption, long seed, final Dimension2D dim,
double dx, double dy) { Animation animationArg, double dx, double dy) {
final FileFormat fileFormat = fileFormatOption.getFileFormat(); final FileFormat fileFormat = fileFormatOption.getFileFormat();
switch (fileFormat) { switch (fileFormat) {
case PNG: case PNG:
return createUGraphicPNG(colorMapper, dpiFactor, dim, mybackcolor, animationArg, dx, dy); return createUGraphicPNG(colorMapper, dpiFactor, dim, mybackcolor, animationArg, dx, dy);
case SVG: case SVG:
return createUGraphicSVG(colorMapper, dpiFactor, dim, mybackcolor, fileFormatOption.getSvgLinkTarget(), return createUGraphicSVG(colorMapper, dpiFactor, dim, mybackcolor, fileFormatOption.getSvgLinkTarget(),
fileFormatOption.getHoverColor(), fileFormatOption.getRandom()); fileFormatOption.getHoverColor(), seed);
case EPS: case EPS:
return new UGraphicEps(colorMapper, EpsStrategy.getDefault2()); return new UGraphicEps(colorMapper, EpsStrategy.getDefault2());
case EPS_TEXT: case EPS_TEXT:
@ -387,20 +387,19 @@ public class ImageBuilder {
} }
private UGraphic2 createUGraphicSVG(ColorMapper colorMapper, double scale, Dimension2D dim, HtmlColor mybackcolor, private UGraphic2 createUGraphicSVG(ColorMapper colorMapper, double scale, Dimension2D dim, HtmlColor mybackcolor,
String svgLinkTarget, String hover, Random random) { String svgLinkTarget, String hover, long seed) {
Color backColor = Color.WHITE; Color backColor = Color.WHITE;
if (mybackcolor instanceof HtmlColorSimple) { if (mybackcolor instanceof HtmlColorSimple) {
backColor = colorMapper.getMappedColor(mybackcolor); backColor = colorMapper.getMappedColor(mybackcolor);
} }
final UGraphicSvg ug; final UGraphicSvg ug;
if (mybackcolor instanceof HtmlColorGradient) { if (mybackcolor instanceof HtmlColorGradient) {
ug = new UGraphicSvg(colorMapper, (HtmlColorGradient) mybackcolor, false, scale, svgLinkTarget, hover, ug = new UGraphicSvg(colorMapper, (HtmlColorGradient) mybackcolor, false, scale, svgLinkTarget, hover, seed);
random);
} else if (backColor == null || backColor.equals(Color.WHITE)) { } else if (backColor == null || backColor.equals(Color.WHITE)) {
ug = new UGraphicSvg(colorMapper, false, scale, svgLinkTarget, hover, random); ug = new UGraphicSvg(colorMapper, false, scale, svgLinkTarget, hover, seed);
} else { } else {
ug = new UGraphicSvg(colorMapper, StringUtils.getAsHtml(backColor), false, scale, svgLinkTarget, hover, ug = new UGraphicSvg(colorMapper, StringUtils.getAsHtml(backColor), false, scale, svgLinkTarget, hover,
random); seed);
} }
return ug; return ug;

View File

@ -55,16 +55,7 @@ import net.sourceforge.plantuml.ugraphic.svg.UGraphicSvg;
public abstract class UGraphicUtils { public abstract class UGraphicUtils {
// public static UDrawable translate(final UDrawable d, final double dx, final double dy) { public static void writeImage(OutputStream os, String metadata, FileFormatOption fileFormatOption, long seed,
// return new UDrawable() {
// public void drawU(UGraphic ug) {
// d.drawU(ug.apply(new UTranslate(dx, dy)));
// }
// };
//
// }
public static void writeImage(OutputStream os, String metadata, FileFormatOption fileFormatOption,
ColorMapper colorMapper, HtmlColor background, TextBlock image) throws IOException { ColorMapper colorMapper, HtmlColor background, TextBlock image) throws IOException {
final FileFormat fileFormat = fileFormatOption.getFileFormat(); final FileFormat fileFormat = fileFormatOption.getFileFormat();
if (fileFormat == FileFormat.PNG) { if (fileFormat == FileFormat.PNG) {
@ -73,7 +64,7 @@ public abstract class UGraphicUtils {
} else if (fileFormat == FileFormat.SVG) { } else if (fileFormat == FileFormat.SVG) {
final UGraphicSvg svg = new UGraphicSvg(colorMapper, StringUtils.getAsHtml(colorMapper final UGraphicSvg svg = new UGraphicSvg(colorMapper, StringUtils.getAsHtml(colorMapper
.getMappedColor(background)), false, 1.0, fileFormatOption.getSvgLinkTarget(), .getMappedColor(background)), false, 1.0, fileFormatOption.getSvgLinkTarget(),
fileFormatOption.getHoverColor(), fileFormatOption.getRandom()); fileFormatOption.getHoverColor(), seed);
image.drawU(svg); image.drawU(svg);
svg.createXml(os, fileFormatOption.isWithMetadata() ? metadata : null); svg.createXml(os, fileFormatOption.isWithMetadata() ? metadata : null);
} else if (fileFormat == FileFormat.EPS) { } else if (fileFormat == FileFormat.EPS) {

View File

@ -56,13 +56,13 @@ import net.sourceforge.plantuml.ugraphic.ImageBuilder;
public class PSystemListInternalSprites extends AbstractPSystem { public class PSystemListInternalSprites extends AbstractPSystem {
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
final UDrawable result = getGraphicStrings(); final UDrawable result = getGraphicStrings();
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE, final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE,
getMetadata(), null, 0, 0, null, false); getMetadata(), null, 0, 0, null, false);
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormat, os); return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
} }
private UDrawable getGraphicStrings() throws IOException { private UDrawable getGraphicStrings() throws IOException {

View File

@ -83,18 +83,18 @@ public class UGraphicSvg extends AbstractUGraphic<SvgGraphics> implements ClipCo
} }
public UGraphicSvg(ColorMapper colorMapper, String backcolor, boolean textAsPath, double scale, String linkTarget, public UGraphicSvg(ColorMapper colorMapper, String backcolor, boolean textAsPath, double scale, String linkTarget,
String hover, Random rnd) { String hover, long seed) {
this(colorMapper, new SvgGraphics(backcolor, scale, hover, rnd), textAsPath, linkTarget); this(colorMapper, new SvgGraphics(backcolor, scale, hover, seed), textAsPath, linkTarget);
} }
public UGraphicSvg(ColorMapper colorMapper, boolean textAsPath, double scale, String linkTarget, String hover, public UGraphicSvg(ColorMapper colorMapper, boolean textAsPath, double scale, String linkTarget, String hover,
Random rnd) { long seed) {
this(colorMapper, new SvgGraphics(scale, hover, rnd), textAsPath, linkTarget); this(colorMapper, new SvgGraphics(scale, hover, seed), textAsPath, linkTarget);
} }
public UGraphicSvg(ColorMapper mapper, HtmlColorGradient gr, boolean textAsPath, double scale, String linkTarget, public UGraphicSvg(ColorMapper mapper, HtmlColorGradient gr, boolean textAsPath, double scale, String linkTarget,
String hover, Random rnd) { String hover, long seed) {
this(mapper, new SvgGraphics(scale, hover, rnd), textAsPath, linkTarget); this(mapper, new SvgGraphics(scale, hover, seed), textAsPath, linkTarget);
final SvgGraphics svg = getGraphicObject(); final SvgGraphics svg = getGraphicObject();
svg.paintBackcolorGradient(mapper, gr); svg.paintBackcolorGradient(mapper, gr);

View File

@ -57,13 +57,13 @@ public class PSystemLicense extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
final TextBlockBackcolored result = getGraphicStrings(); final TextBlockBackcolored result = getGraphicStrings();
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(), final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
getMetadata(), null, 0, 0, null, false); getMetadata(), null, 0, 0, null, false);
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormat, os); return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
} }
public static PSystemLicense create() throws IOException { public static PSystemLicense create() throws IOException {

View File

@ -151,14 +151,14 @@ public class PSystemVersion extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat) final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException { throws IOException {
final TextBlockBackcolored result = GraphicStrings.createBlackOnWhite(strings, image, final TextBlockBackcolored result = GraphicStrings.createBlackOnWhite(strings, image,
GraphicPosition.BACKGROUND_CORNER_BOTTOM_RIGHT); GraphicPosition.BACKGROUND_CORNER_BOTTOM_RIGHT);
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(), final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
getMetadata(), null, 0, 0, null, false); getMetadata(), null, 0, 0, null, false);
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormat, os); return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
} }
public static PSystemVersion createShowVersion() { public static PSystemVersion createShowVersion() {

View File

@ -41,7 +41,7 @@ import java.util.Date;
public class Version { public class Version {
public static int version() { public static int version() {
return 201709; return 201711;
} }
public static String versionString() { public static String versionString() {
@ -78,7 +78,7 @@ public class Version {
} }
public static long compileTime() { public static long compileTime() {
return 1491408431708L; return 1492618739962L;
} }
public static String compileTimeString() { public static String compileTimeString() {

View File

@ -57,6 +57,7 @@ import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.LongCode; import net.sourceforge.plantuml.cucadiagram.LongCode;
import net.sourceforge.plantuml.cucadiagram.Member; import net.sourceforge.plantuml.cucadiagram.Member;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.skin.VisibilityModifier; import net.sourceforge.plantuml.skin.VisibilityModifier;
import net.sourceforge.plantuml.utils.UniqueSequence; import net.sourceforge.plantuml.utils.UniqueSequence;
@ -158,6 +159,17 @@ abstract class XmiClassDiagramAbstract implements IXmiClassDiagram {
cla.setAttribute("namespace", parentCode.getFullName()); cla.setAttribute("namespace", parentCode.getFullName());
} }
final Stereotype stereotype = entity.getStereotype();
if (stereotype != null) {
final Element stereo = document.createElement("UML:ModelElement.stereotype");
for (String s : stereotype.getMultipleLabels()) {
final Element name = document.createElement("UML:Stereotype");
name.setAttribute("name", s);
stereo.appendChild(name);
}
cla.appendChild(stereo);
}
final LeafType type = entity.getLeafType(); final LeafType type = entity.getLeafType();
if (type == LeafType.ABSTRACT_CLASS) { if (type == LeafType.ABSTRACT_CLASS) {
cla.setAttribute("isAbstract", "true"); cla.setAttribute("isAbstract", "true");