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:
parent
e3a5d8f744
commit
5c62d2c083
2
pom.xml
2
pom.xml
@ -35,7 +35,7 @@
|
||||
|
||||
<groupId>net.sourceforge.plantuml</groupId>
|
||||
<artifactId>plantuml</artifactId>
|
||||
<version>2017.10-SNAPSHOT</version>
|
||||
<version>2017.12-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>PlantUML</name>
|
||||
|
@ -81,6 +81,13 @@ public abstract class AbstractPSystem implements Diagram {
|
||||
return source;
|
||||
}
|
||||
|
||||
final public long seed() {
|
||||
if (source == null) {
|
||||
return 42;
|
||||
}
|
||||
return getSource().seed();
|
||||
}
|
||||
|
||||
final public void setSource(UmlSource source) {
|
||||
this.source = source;
|
||||
}
|
||||
@ -124,7 +131,7 @@ public abstract class AbstractPSystem implements Diagram {
|
||||
throws IOException {
|
||||
final long now = System.currentTimeMillis();
|
||||
try {
|
||||
return exportDiagramNow(os, index, fileFormatOption);
|
||||
return exportDiagramNow(os, index, fileFormatOption, seed());
|
||||
} finally {
|
||||
if (OptionFlags.getInstance().isEnableStats()) {
|
||||
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)
|
||||
throws IOException;
|
||||
protected abstract ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption,
|
||||
long seed) throws IOException;
|
||||
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public class BlockUml {
|
||||
this.data = new ArrayList<CharSequence2>(strings);
|
||||
}
|
||||
|
||||
public String getFileOrDirname(FileFormat defaultFileFormat) {
|
||||
public String getFileOrDirname() {
|
||||
if (OptionFlags.getInstance().isWord()) {
|
||||
return null;
|
||||
}
|
||||
@ -116,9 +116,7 @@ public class BlockUml {
|
||||
if (result.startsWith("file://")) {
|
||||
result = result.substring("file://".length());
|
||||
}
|
||||
if (result.contains(".") == false) {
|
||||
result = result + defaultFileFormat.getFileSuffix();
|
||||
}
|
||||
result = result.replaceAll("\\.\\w\\w\\w$", "");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,8 @@ public enum ColorParam {
|
||||
background(HtmlColorUtils.WHITE, true, ColorType.BACK),
|
||||
hyperlink(HtmlColorUtils.BLUE),
|
||||
|
||||
activityDiamondBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK),
|
||||
activityDiamondBorder(HtmlColorUtils.MY_RED, ColorType.LINE),
|
||||
activityBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK),
|
||||
activityBorder(HtmlColorUtils.MY_RED, ColorType.LINE),
|
||||
activityStart(HtmlColorUtils.BLACK),
|
||||
|
@ -131,6 +131,14 @@ public enum FileFormat {
|
||||
+ 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) {
|
||||
String result = fileName.replaceAll("\\.\\w+$", replacement);
|
||||
if (result.equals(fileName)) {
|
||||
@ -139,15 +147,7 @@ public enum FileFormat {
|
||||
return result;
|
||||
}
|
||||
|
||||
public File computeFilename(File pngFile, 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) {
|
||||
private String computeFilenameInternal(String name, int i) {
|
||||
if (i == 0) {
|
||||
return name;
|
||||
}
|
||||
|
@ -37,7 +37,6 @@ package net.sourceforge.plantuml;
|
||||
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.io.Serializable;
|
||||
import java.util.Random;
|
||||
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
|
||||
@ -52,14 +51,13 @@ public class FileFormatOption implements Serializable {
|
||||
|
||||
private final FileFormat fileFormat;
|
||||
private final AffineTransform affineTransform;
|
||||
private final boolean withMetadata;
|
||||
private boolean withMetadata;
|
||||
private final boolean useRedForError;
|
||||
private final String svgLinkTarget;
|
||||
private final String hoverColor;
|
||||
private final Random rnd;
|
||||
|
||||
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() {
|
||||
@ -74,16 +72,12 @@ public class FileFormatOption implements Serializable {
|
||||
return withMetadata;
|
||||
}
|
||||
|
||||
public final Random getRandom() {
|
||||
return rnd;
|
||||
}
|
||||
|
||||
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,
|
||||
String svgLinkTarget, boolean debugsvek, String hoverColor, Random rnd) {
|
||||
String svgLinkTarget, boolean debugsvek, String hoverColor) {
|
||||
this.hoverColor = hoverColor;
|
||||
this.fileFormat = fileFormat;
|
||||
this.affineTransform = at;
|
||||
@ -91,27 +85,21 @@ public class FileFormatOption implements Serializable {
|
||||
this.useRedForError = useRedForError;
|
||||
this.svgLinkTarget = svgLinkTarget;
|
||||
this.debugsvek = debugsvek;
|
||||
this.rnd = rnd;
|
||||
}
|
||||
|
||||
public FileFormatOption withUseRedForError() {
|
||||
return new FileFormatOption(fileFormat, affineTransform, withMetadata, true, svgLinkTarget, debugsvek,
|
||||
hoverColor, rnd);
|
||||
hoverColor);
|
||||
}
|
||||
|
||||
public FileFormatOption withSvgLinkTarget(String svgLinkTarget) {
|
||||
return new FileFormatOption(fileFormat, affineTransform, withMetadata, useRedForError, svgLinkTarget,
|
||||
debugsvek, hoverColor, rnd);
|
||||
debugsvek, hoverColor);
|
||||
}
|
||||
|
||||
public FileFormatOption withHoverColor(String hoverColor) {
|
||||
return new FileFormatOption(fileFormat, affineTransform, withMetadata, useRedForError, svgLinkTarget,
|
||||
debugsvek, hoverColor, rnd);
|
||||
}
|
||||
|
||||
public FileFormatOption withFixedRandom() {
|
||||
return new FileFormatOption(fileFormat, affineTransform, withMetadata, useRedForError, svgLinkTarget,
|
||||
debugsvek, hoverColor, new Random(42));
|
||||
debugsvek, hoverColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -145,4 +133,8 @@ public class FileFormatOption implements Serializable {
|
||||
return hoverColor;
|
||||
}
|
||||
|
||||
public void hideMetadata() {
|
||||
this.withMetadata = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ public class NewpagedDiagram extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
return diagrams.get(num).exportDiagram(os, 0, fileFormat);
|
||||
}
|
||||
|
@ -77,6 +77,7 @@ public class Option {
|
||||
private boolean textProgressBar = false;
|
||||
private int nbThreads = 0;
|
||||
private int ftpPort = -1;
|
||||
private boolean hideMetadata = false;
|
||||
|
||||
private File outputDir = null;
|
||||
private File outputFile = null;
|
||||
@ -107,7 +108,7 @@ public class Option {
|
||||
if (s.equalsIgnoreCase("-tsvg") || s.equalsIgnoreCase("-svg")) {
|
||||
setFileFormatOption(new FileFormatOption(FileFormat.SVG));
|
||||
} 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")) {
|
||||
setFileFormatOption(new FileFormatOption(FileFormat.HTML));
|
||||
} else if (s.equalsIgnoreCase("-tscxml") || s.equalsIgnoreCase("-scxml")) {
|
||||
@ -242,7 +243,7 @@ public class Option {
|
||||
} else if (s.equalsIgnoreCase("-keepfiles") || s.equalsIgnoreCase("-keepfile")) {
|
||||
System.err.println("-keepfiles option has been removed. Please consider -debugsvek instead");
|
||||
} else if (s.equalsIgnoreCase("-metadata")) {
|
||||
OptionFlags.getInstance().setMetadata(true);
|
||||
OptionFlags.getInstance().setExtractFromMetadata(true);
|
||||
} else if (s.equalsIgnoreCase("-logdata")) {
|
||||
i++;
|
||||
if (i == arg.length) {
|
||||
@ -305,6 +306,8 @@ public class Option {
|
||||
splash = true;
|
||||
} else if (s.equalsIgnoreCase("-progress")) {
|
||||
textProgressBar = true;
|
||||
} else if (s.equalsIgnoreCase("-nometadata")) {
|
||||
hideMetadata = true;
|
||||
} else if (StringUtils.goLowerCase(s).startsWith("-ftp")) {
|
||||
final int x = s.indexOf(':');
|
||||
if (x == -1) {
|
||||
@ -449,10 +452,12 @@ public class Option {
|
||||
}
|
||||
|
||||
public FileFormatOption getFileFormatOption() {
|
||||
// final FileFormatOption fileFormatOption = new FileFormatOption(getFileFormat());
|
||||
if (debugsvek) {
|
||||
fileFormatOption.setDebugSvek(true);
|
||||
}
|
||||
if (hideMetadata) {
|
||||
fileFormatOption.hideMetadata();
|
||||
}
|
||||
return fileFormatOption;
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ public class OptionFlags {
|
||||
private void reset(boolean exit) {
|
||||
// keepTmpFiles = false;
|
||||
verbose = false;
|
||||
metadata = false;
|
||||
extractFromMetadata = false;
|
||||
word = false;
|
||||
systemExit = exit;
|
||||
GraphvizUtils.setDotExecutable(null);
|
||||
@ -105,7 +105,7 @@ public class OptionFlags {
|
||||
|
||||
// private boolean keepTmpFiles;
|
||||
private boolean verbose;
|
||||
private boolean metadata;
|
||||
private boolean extractFromMetadata;
|
||||
private boolean word;
|
||||
private boolean systemExit;
|
||||
private boolean gui;
|
||||
@ -139,12 +139,12 @@ public class OptionFlags {
|
||||
this.verbose = verbose;
|
||||
}
|
||||
|
||||
public final boolean isMetadata() {
|
||||
return metadata;
|
||||
public final boolean isExtractFromMetadata() {
|
||||
return extractFromMetadata;
|
||||
}
|
||||
|
||||
public final void setMetadata(boolean metadata) {
|
||||
this.metadata = metadata;
|
||||
public final void setExtractFromMetadata(boolean extractFromMetadata) {
|
||||
this.extractFromMetadata = extractFromMetadata;
|
||||
}
|
||||
|
||||
public final boolean isWord() {
|
||||
|
@ -103,6 +103,7 @@ public class OptionPrint {
|
||||
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(" -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(" -checkversion\tTo check if a newer version is available for download");
|
||||
System.out.println(" -v[erbose]\t\tTo have log information");
|
||||
|
@ -105,6 +105,7 @@ public class PSystemBuilder {
|
||||
int cpt = 0;
|
||||
for (CharSequence2 s : strings2) {
|
||||
if (s.getPreprocessorError() != null) {
|
||||
Log.error("Preprocessor Error: " + s.getPreprocessorError());
|
||||
final ErrorUml singleError = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, s.getPreprocessorError(), cpt,
|
||||
s.getLocation());
|
||||
return new PSystemError(umlSource, singleError, Collections.<String> emptyList());
|
||||
|
@ -120,7 +120,7 @@ public class PSystemError extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
if (fileFormat.getFileFormat() == FileFormat.ATXT || fileFormat.getFileFormat() == FileFormat.UTXT) {
|
||||
final UGraphicTxt ugt = new UGraphicTxt();
|
||||
@ -146,7 +146,7 @@ public class PSystemError extends AbstractPSystem {
|
||||
// udrawable = addMessage(udrawable);
|
||||
// }
|
||||
imageBuilder.setUDrawable(udrawable);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed(), os);
|
||||
}
|
||||
|
||||
private TextBlockBackcolored getWelcome() throws IOException {
|
||||
|
@ -55,7 +55,7 @@ import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
|
||||
|
||||
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 {
|
||||
if (system instanceof NewpagedDiagram) {
|
||||
return exportDiagramsNewpaged((NewpagedDiagram) system, suggestedFile, fileFormatOption);
|
||||
@ -72,13 +72,13 @@ public class PSystemUtils {
|
||||
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 {
|
||||
final List<FileImageData> result = new ArrayList<FileImageData>();
|
||||
final int nbImages = system.getNbImages();
|
||||
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) {
|
||||
return result;
|
||||
}
|
||||
@ -113,18 +113,18 @@ public class PSystemUtils {
|
||||
return true;
|
||||
}
|
||||
|
||||
static private List<FileImageData> exportDiagramsDefault(Diagram system, File suggestedFile,
|
||||
static private List<FileImageData> exportDiagramsDefault(Diagram system, 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);
|
||||
}
|
||||
OutputStream os = null;
|
||||
ImageData imageData = null;
|
||||
try {
|
||||
if (canFileBeWritten(suggestedFile) == false) {
|
||||
if (PSystemUtils.canFileBeWritten(suggestedFile.getFile(0)) == false) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
os = new BufferedOutputStream(new FileOutputStream(suggestedFile));
|
||||
os = new BufferedOutputStream(new FileOutputStream(suggestedFile.getFile(0)));
|
||||
// system.exportDiagram(os, null, 0, fileFormat);
|
||||
imageData = system.exportDiagram(os, 0, fileFormat);
|
||||
} finally {
|
||||
@ -132,22 +132,22 @@ public class PSystemUtils {
|
||||
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,
|
||||
FileFormatOption fileFormat) throws IOException {
|
||||
if (suggestedFile.exists() && suggestedFile.isDirectory()) {
|
||||
static private List<FileImageData> exportDiagramsActivityDiagram3(ActivityDiagram3 system,
|
||||
SuggestedFile suggestedFile, FileFormatOption fileFormat) throws IOException {
|
||||
if (suggestedFile.getFile(0).exists() && suggestedFile.getFile(0).isDirectory()) {
|
||||
throw new IllegalArgumentException("File is a directory " + suggestedFile);
|
||||
}
|
||||
OutputStream os = null;
|
||||
ImageData cmap = null;
|
||||
ImageData imageData = null;
|
||||
try {
|
||||
if (canFileBeWritten(suggestedFile) == false) {
|
||||
if (PSystemUtils.canFileBeWritten(suggestedFile.getFile(0)) == false) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
os = new BufferedOutputStream(new FileOutputStream(suggestedFile));
|
||||
os = new BufferedOutputStream(new FileOutputStream(suggestedFile.getFile(0)));
|
||||
imageData = cmap = system.exportDiagram(os, 0, fileFormat);
|
||||
} finally {
|
||||
if (os != null) {
|
||||
@ -155,19 +155,19 @@ public class PSystemUtils {
|
||||
}
|
||||
}
|
||||
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 {
|
||||
final List<FileImageData> result = new ArrayList<FileImageData>();
|
||||
final int nbImages = system.getNbImages();
|
||||
for (int i = 0; i < nbImages; i++) {
|
||||
|
||||
final File f = fileFormat.getFileFormat().computeFilename(suggestedFile, i);
|
||||
if (canFileBeWritten(suggestedFile) == false) {
|
||||
final File f = suggestedFile.getFile(i);
|
||||
if (PSystemUtils.canFileBeWritten(suggestedFile.getFile(i)) == false) {
|
||||
return result;
|
||||
}
|
||||
final OutputStream fos = new BufferedOutputStream(new FileOutputStream(f));
|
||||
@ -178,7 +178,7 @@ public class PSystemUtils {
|
||||
fos.close();
|
||||
}
|
||||
if (cmap != null && cmap.containsCMapData()) {
|
||||
system.exportCmap(suggestedFile, cmap);
|
||||
system.exportCmap(suggestedFile, i, cmap);
|
||||
}
|
||||
Log.info("File size : " + f.length());
|
||||
result.add(new FileImageData(f, cmap));
|
||||
@ -186,9 +186,9 @@ public class PSystemUtils {
|
||||
return result;
|
||||
}
|
||||
|
||||
static private List<FileImageData> exportDiagramsCuca(CucaDiagram system, File suggestedFile,
|
||||
static private List<FileImageData> exportDiagramsCuca(CucaDiagram system, 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);
|
||||
}
|
||||
|
||||
@ -199,22 +199,22 @@ public class PSystemUtils {
|
||||
ImageData cmap = null;
|
||||
OutputStream os = null;
|
||||
try {
|
||||
if (canFileBeWritten(suggestedFile) == false) {
|
||||
if (PSystemUtils.canFileBeWritten(suggestedFile.getFile(0)) == false) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
// System.err.println("FOO11=" + suggestedFile);
|
||||
// os = new BufferedOutputStream(new FileOutputStream(suggestedFile));
|
||||
os = new NamedOutputStream(suggestedFile);
|
||||
os = new NamedOutputStream(suggestedFile.getFile(0));
|
||||
cmap = system.exportDiagram(os, 0, fileFormat);
|
||||
} finally {
|
||||
if (os != null) {
|
||||
os.close();
|
||||
}
|
||||
}
|
||||
List<File> result = Arrays.asList(suggestedFile);
|
||||
List<File> result = Arrays.asList(suggestedFile.getFile(0));
|
||||
|
||||
if (cmap != null && cmap.containsCMapData()) {
|
||||
system.exportCmap(suggestedFile, cmap);
|
||||
system.exportCmap(suggestedFile, 0, cmap);
|
||||
}
|
||||
|
||||
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 int idx = name.lastIndexOf('.');
|
||||
final File dir = new File(suggestedFile.getParentFile(), name.substring(0, idx));
|
||||
|
@ -90,7 +90,7 @@ public class Pipe {
|
||||
ps.println(result);
|
||||
} else {
|
||||
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())) {
|
||||
error = true;
|
||||
manageErrors(noStdErr ? ps : System.err, sourceStringReader);
|
||||
|
@ -306,7 +306,7 @@ public class Run {
|
||||
|
||||
private static boolean processArgs(Option option) throws IOException, InterruptedException {
|
||||
if (option.isDecodeurl() == false && option.getNbThreads() > 1 && option.isCheckOnly() == false
|
||||
&& OptionFlags.getInstance().isMetadata() == false) {
|
||||
&& OptionFlags.getInstance().isExtractFromMetadata() == false) {
|
||||
return multithread(option);
|
||||
}
|
||||
boolean errorGlobal = false;
|
||||
@ -384,7 +384,7 @@ public class Run {
|
||||
}
|
||||
|
||||
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(f);
|
||||
// new Metadata().readAndDisplayMetadata(f);
|
||||
|
@ -170,24 +170,28 @@ public class SourceFileReader implements ISourceFileReader {
|
||||
final List<GeneratedImage> result = new ArrayList<GeneratedImage>();
|
||||
|
||||
for (BlockUml blockUml : builder.getBlockUmls()) {
|
||||
String newName = blockUml.getFileOrDirname(fileFormatOption.getFileFormat());
|
||||
Log.info("name from block=" + newName);
|
||||
File suggested = null;
|
||||
final String newName = blockUml.getFileOrDirname();
|
||||
SuggestedFile suggested = null;
|
||||
if (newName != null) {
|
||||
Log.info("name from block=" + newName);
|
||||
final File dir = getDirIfDirectory(newName);
|
||||
if (dir == null) {
|
||||
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 {
|
||||
Log.info("We are going to create files in directory " + dir);
|
||||
newName = fileFormatOption.getFileFormat().changeName(file.getName(), cpt++);
|
||||
suggested = new File(dir, newName);
|
||||
// newName = fileFormatOption.getFileFormat().changeName(file.getName(), cpt++);
|
||||
// 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);
|
||||
}
|
||||
if (suggested == null) {
|
||||
newName = fileFormatOption.getFileFormat().changeName(file.getName(), cpt++);
|
||||
suggested = new File(outputDirectory, newName);
|
||||
// newName = fileFormatOption.getFileFormat().changeName(file.getName(), cpt++);
|
||||
suggested = SuggestedFile.fromOutputFile(new File(outputDirectory, file.getName()),
|
||||
fileFormatOption.getFileFormat(), cpt++);
|
||||
}
|
||||
suggested.getParentFile().mkdirs();
|
||||
|
||||
@ -195,11 +199,11 @@ public class SourceFileReader implements ISourceFileReader {
|
||||
try {
|
||||
system = blockUml.getDiagram();
|
||||
} 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;
|
||||
try {
|
||||
os = new BufferedOutputStream(new FileOutputStream(suggested));
|
||||
UmlDiagram.exportDiagramError(os, t, fileFormatOption, null, blockUml.getFlashData(),
|
||||
os = new BufferedOutputStream(new FileOutputStream(suggested.getFile(0)));
|
||||
UmlDiagram.exportDiagramError(os, t, fileFormatOption, 42, null, blockUml.getFlashData(),
|
||||
UmlDiagram.getFailureText2(t));
|
||||
} finally {
|
||||
if (os != null) {
|
||||
|
@ -90,7 +90,7 @@ public class SourceFileReader2 implements ISourceFileReader {
|
||||
final List<GeneratedImage> result = new ArrayList<GeneratedImage>();
|
||||
|
||||
for (BlockUml blockUml : builder.getBlockUmls()) {
|
||||
final File suggested = outputFile;
|
||||
final SuggestedFile suggested = SuggestedFile.fromOutputFile(outputFile, fileFormatOption.getFileFormat());
|
||||
|
||||
final Diagram system = blockUml.getDiagram();
|
||||
OptionFlags.getInstance().logData(file, system);
|
||||
|
@ -92,29 +92,58 @@ public class SourceStringReader {
|
||||
}
|
||||
}
|
||||
|
||||
public DiagramDescription generateImage(OutputStream os) throws IOException {
|
||||
return generateImage(os, 0);
|
||||
@Deprecated
|
||||
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 DiagramDescription result = generateImage(os, 0);
|
||||
os.close();
|
||||
DiagramDescription result = null;
|
||||
try {
|
||||
result = outputImage(os, 0);
|
||||
} finally {
|
||||
os.close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public DiagramDescription generateImage(OutputStream os, FileFormatOption fileFormatOption) throws IOException {
|
||||
return generateImage(os, 0, fileFormatOption);
|
||||
@Deprecated
|
||||
public String generateImage(OutputStream os, FileFormatOption fileFormatOption) throws IOException {
|
||||
return outputImage(os, fileFormatOption).getDescription();
|
||||
}
|
||||
|
||||
public DiagramDescription generateImage(OutputStream os, int numImage) throws IOException {
|
||||
return generateImage(os, numImage, new FileFormatOption(FileFormat.PNG));
|
||||
public DiagramDescription outputImage(OutputStream os, FileFormatOption fileFormatOption) throws IOException {
|
||||
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 {
|
||||
if (blocks.size() == 0) {
|
||||
noStartumlFound(os, fileFormatOption);
|
||||
noStartumlFound(os, fileFormatOption, 42);
|
||||
return null;
|
||||
}
|
||||
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 {
|
||||
if (blocks.size() == 0) {
|
||||
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"),
|
||||
fileFormatOption.isUseRedForError());
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, error.getBackcolor(), null,
|
||||
null, 0, 0, null, false);
|
||||
imageBuilder.setUDrawable(error);
|
||||
imageBuilder.writeImageTOBEMOVED(fileFormatOption, 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;
|
||||
|
||||
imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed, os);
|
||||
}
|
||||
|
||||
public final List<BlockUml> getBlocks() {
|
||||
|
@ -319,7 +319,7 @@ public class StringUtils {
|
||||
public static int getWidth(Display stringsToDisplay) {
|
||||
int result = 1;
|
||||
for (CharSequence s : stringsToDisplay) {
|
||||
if (result < s.length()) {
|
||||
if (s != null && result < s.length()) {
|
||||
result = s.length();
|
||||
}
|
||||
}
|
||||
|
81
src/net/sourceforge/plantuml/SuggestedFile.java
Normal file
81
src/net/sourceforge/plantuml/SuggestedFile.java
Normal 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");
|
||||
}
|
||||
|
||||
}
|
@ -218,7 +218,7 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Ann
|
||||
}
|
||||
|
||||
@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 {
|
||||
|
||||
final HtmlColor hover = getSkinParam().getHoverPathColor();
|
||||
@ -238,21 +238,21 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Ann
|
||||
return imageData;
|
||||
} catch (UnparsableGraphvizException e) {
|
||||
e.printStackTrace();
|
||||
exportDiagramError(os, e.getCause(), fileFormatOption, e.getGraphvizVersion());
|
||||
exportDiagramError(os, e.getCause(), fileFormatOption, seed, e.getGraphvizVersion());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
exportDiagramError(os, e, fileFormatOption, null);
|
||||
exportDiagramError(os, e, fileFormatOption, seed, null);
|
||||
}
|
||||
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 {
|
||||
exportDiagramError(os, exception, fileFormat, getMetadata(), getFlashData(),
|
||||
exportDiagramError(os, exception, fileFormat, seed, getMetadata(), getFlashData(),
|
||||
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 {
|
||||
|
||||
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) {
|
||||
@ -376,8 +376,9 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Ann
|
||||
protected abstract ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||
throws IOException;
|
||||
|
||||
final protected void exportCmap(File suggestedFile, final ImageData cmapdata) throws FileNotFoundException {
|
||||
final String name = changeName(suggestedFile.getAbsolutePath());
|
||||
final protected void exportCmap(SuggestedFile suggestedFile, int index, final ImageData cmapdata)
|
||||
throws FileNotFoundException {
|
||||
final String name = changeName(suggestedFile.getFile(index).getAbsolutePath());
|
||||
final File cmapFile = new File(name);
|
||||
PrintWriter pw = null;
|
||||
try {
|
||||
|
@ -79,7 +79,7 @@ public class PSystemXearth extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final ACearth earth = new ACearth(markers);
|
||||
final ConfigurationACearth conf = earth.getConf();
|
||||
|
@ -200,7 +200,7 @@ public class ActivityDiagram3 extends UmlDiagram {
|
||||
getAnimation());
|
||||
imageBuilder.setUDrawable(result);
|
||||
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed(), os);
|
||||
|
||||
}
|
||||
|
||||
@ -344,10 +344,10 @@ public class ActivityDiagram3 extends UmlDiagram {
|
||||
manageSwimlaneStrategy();
|
||||
if (current() instanceof InstructionRepeat) {
|
||||
final InstructionRepeat instructionRepeat = (InstructionRepeat) current();
|
||||
// final LinkRendering back = new LinkRendering(linkColor).withDisplay(linkLabel);
|
||||
// final LinkRendering back = new LinkRendering(linkColor).withDisplay(linkLabel);
|
||||
instructionRepeat.setBackward(label);
|
||||
// setCurrent(instructionRepeat.getParent());
|
||||
// this.setNextLinkRendererInternal(LinkRendering.none());
|
||||
// setCurrent(instructionRepeat.getParent());
|
||||
// this.setNextLinkRendererInternal(LinkRendering.none());
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
return CommandExecutionResult.error("Cannot find repeat");
|
||||
|
@ -69,9 +69,9 @@ public class FtileFactoryDelegatorIf extends FtileFactoryDelegator {
|
||||
final ConditionStyle conditionStyle = skinParam().getConditionStyle();
|
||||
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(),
|
||||
ColorParam.activityBackground) : branch0.getColor();
|
||||
ColorParam.activityDiamondBackground) : branch0.getColor();
|
||||
final Rainbow arrowColor = HtmlColorAndStyle.build(skinParam());
|
||||
|
||||
final FontConfiguration fcArrow = new FontConfiguration(skinParam(), FontParam.ARROW, null);
|
||||
|
@ -76,8 +76,8 @@ public class FtileFactoryDelegatorRepeat extends FtileFactoryDelegator {
|
||||
|
||||
final ConditionStyle conditionStyle = skinParam().getConditionStyle();
|
||||
|
||||
final HtmlColor borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityBorder);
|
||||
final HtmlColor backColor = color == null ? getRose().getHtmlColor(skinParam(), ColorParam.activityBackground)
|
||||
final HtmlColor borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBorder);
|
||||
final HtmlColor backColor = color == null ? getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBackground)
|
||||
: color;
|
||||
final Rainbow arrowColor = HtmlColorAndStyle.build(skinParam());
|
||||
|
||||
|
@ -59,8 +59,8 @@ public class FtileFactoryDelegatorWhile extends FtileFactoryDelegator {
|
||||
@Override
|
||||
public Ftile createWhile(Swimlane swimlane, Ftile whileBlock, Display test, Display yes, Display out,
|
||||
LinkRendering afterEndwhile, HtmlColor color, Instruction specialOut) {
|
||||
final HtmlColor borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityBorder);
|
||||
final HtmlColor backColor = color == null ? getRose().getHtmlColor(skinParam(), ColorParam.activityBackground)
|
||||
final HtmlColor borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBorder);
|
||||
final HtmlColor backColor = color == null ? getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBackground)
|
||||
: color;
|
||||
final Rainbow arrowColor = HtmlColorAndStyle.build(skinParam());
|
||||
|
||||
|
@ -93,8 +93,8 @@ public class ParallelBuilderMerge extends ParallelFtilesBuilder {
|
||||
|
||||
@Override
|
||||
protected Ftile doStep2(Ftile result) {
|
||||
final HtmlColor borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityBorder);
|
||||
final HtmlColor backColor = getRose().getHtmlColor(skinParam(), ColorParam.activityBackground);
|
||||
final HtmlColor borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBorder);
|
||||
final HtmlColor backColor = getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBackground);
|
||||
final Ftile out = new FtileDiamond(skinParam(), backColor, borderColor, swimlane());
|
||||
result = new FtileAssemblySimple(result, out);
|
||||
final List<Connection> conns = new ArrayList<Connection>();
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -53,8 +53,7 @@ public class ComponentTextGroupingHeader extends AbstractComponentText {
|
||||
private final Display stringsToDisplay;
|
||||
private final FileFormat fileFormat;
|
||||
|
||||
public ComponentTextGroupingHeader(ComponentType type, Display stringsToDisplay,
|
||||
FileFormat fileFormat) {
|
||||
public ComponentTextGroupingHeader(ComponentType type, Display stringsToDisplay, FileFormat fileFormat) {
|
||||
this.type = type;
|
||||
this.stringsToDisplay = stringsToDisplay;
|
||||
this.fileFormat = fileFormat;
|
||||
@ -92,7 +91,7 @@ public class ComponentTextGroupingHeader extends AbstractComponentText {
|
||||
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();
|
||||
charArea.drawStringLR(comment, text.length() + 7, 1);
|
||||
|
||||
|
@ -119,6 +119,9 @@ public class TextSkin implements Skin {
|
||||
if (type == ComponentType.DELAY_TEXT) {
|
||||
return new ComponentTextDelay(type, stringsToDisplay, fileFormat);
|
||||
}
|
||||
if (type == ComponentType.DESTROY) {
|
||||
return new ComponentTextDestroy();
|
||||
}
|
||||
throw new UnsupportedOperationException(type.toString());
|
||||
}
|
||||
|
||||
|
@ -53,6 +53,16 @@ import net.sourceforge.plantuml.ugraphic.ImageBuilder;
|
||||
|
||||
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 List<BpmEvent> events = new ArrayList<BpmEvent>();
|
||||
@ -77,7 +87,7 @@ public class BpmDiagram extends UmlDiagram {
|
||||
getAnimation());
|
||||
imageBuilder.setUDrawable(getUDrawable());
|
||||
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed(), os);
|
||||
}
|
||||
|
||||
private UDrawable getUDrawable() {
|
||||
@ -89,16 +99,6 @@ public class BpmDiagram extends UmlDiagram {
|
||||
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) {
|
||||
this.events.add(event);
|
||||
return CommandExecutionResult.ok();
|
||||
@ -144,7 +144,7 @@ public class BpmDiagram extends UmlDiagram {
|
||||
nav.insertAfter(newLine);
|
||||
final Col row = current.getCol();
|
||||
current = new Coord(newLine, row);
|
||||
src.addConnectionTo(last);
|
||||
src.addConnectionTo2(last.getData());
|
||||
} else {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
@ -164,7 +164,7 @@ public class BpmDiagram extends UmlDiagram {
|
||||
nav.insertAfter(newRow);
|
||||
current = new Coord(current.getLine(), newRow);
|
||||
grid.getCell(current).setData(element);
|
||||
last.addConnectionTo(grid.getCell(current));
|
||||
last.addConnectionTo2(grid.getCell(current).getData());
|
||||
last = grid.getCell(current);
|
||||
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ import java.util.List;
|
||||
public class Cell {
|
||||
|
||||
private Placeable data;
|
||||
private final List<Cell> destinations = new ArrayList<Cell>();
|
||||
private final List<Placeable> destinations = new ArrayList<Placeable>();
|
||||
|
||||
public final Placeable getData() {
|
||||
return data;
|
||||
@ -60,11 +60,15 @@ public class Cell {
|
||||
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);
|
||||
}
|
||||
|
||||
public List<Cell> getDestinations() {
|
||||
public List<Placeable> getDestinations2() {
|
||||
return Collections.unmodifiableList(destinations);
|
||||
}
|
||||
|
||||
|
@ -35,44 +35,120 @@
|
||||
*/
|
||||
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 boolean clean(Grid grid) {
|
||||
System.err.println("running CleanerInterleavingLines");
|
||||
boolean result = false;
|
||||
Line previous = null;
|
||||
// int i = 0;
|
||||
for (Line line : grid.lines().toList()) {
|
||||
// System.err.println("--------- LINE i=" + i);
|
||||
// i++;
|
||||
if (previous != null) {
|
||||
final Collection<Col> cols1 = grid.usedColsOf(previous);
|
||||
final Collection<Col> cols2 = grid.usedColsOf(line);
|
||||
if (Collections.disjoint(cols1, cols2)) {
|
||||
// final SortedSet<Col> used1 = grid.colsConnectedTo(previous);
|
||||
// final SortedSet<Col> used2 = grid.colsConnectedTo(line);
|
||||
// if (mergeable(used1, used2)) {
|
||||
// System.err.println("CAN BE MERGE!");
|
||||
// grid.mergeLines(previous, line);
|
||||
// result = true;
|
||||
// }
|
||||
if (mergeable(grid, previous, line)) {
|
||||
System.err.println("MERGEABLE! " + previous + " " + line);
|
||||
mergeLines(grid, previous, line);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
previous = line;
|
||||
}
|
||||
// }
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean mergeable(SortedSet<Col> used1, SortedSet<Col> used2) {
|
||||
final Comparator<? super Col> s = used1.comparator();
|
||||
assert s == used2.comparator();
|
||||
if (s.compare(used1.last(), used2.first()) <= 0) {
|
||||
private void mergeLines(Grid grid, Line line1, Line line2) {
|
||||
for (Col col : grid.cols().toList()) {
|
||||
final Cell cell1 = grid.getCell(line1, col);
|
||||
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;
|
||||
}
|
||||
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 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -169,6 +169,15 @@ public class Grid {
|
||||
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) {
|
||||
return lines.navigator(coord.getLine());
|
||||
}
|
||||
@ -191,11 +200,14 @@ public class Grid {
|
||||
final GridArray result = new GridArray(skinParam, lines.size(), cols.size());
|
||||
for (Map.Entry<Coord, Cell> ent : cells.entrySet()) {
|
||||
final int l = lines.indexOf(ent.getKey().getLine());
|
||||
final int r = cols.indexOf(ent.getKey().getCol());
|
||||
if (r == -1 || l == -1) {
|
||||
throw new IllegalStateException();
|
||||
final int c = cols.indexOf(ent.getKey().getCol());
|
||||
if (c == -1) {
|
||||
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;
|
||||
}
|
||||
@ -244,7 +256,21 @@ public class Grid {
|
||||
}
|
||||
|
||||
public void removeLine(Line line) {
|
||||
System.err.println("REMOVING " + line);
|
||||
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);
|
||||
if (done == false) {
|
||||
throw new IllegalArgumentException();
|
||||
@ -255,36 +281,36 @@ public class Grid {
|
||||
// this.edges.addAll(other);
|
||||
// }
|
||||
|
||||
public void mergeLines(Line source, Line dest) {
|
||||
final Map<Coord, Cell> supp = new HashMap<Coord, Cell>();
|
||||
|
||||
for (Iterator<Map.Entry<Coord, Cell>> it = cells.entrySet().iterator(); it.hasNext();) {
|
||||
final Map.Entry<Coord, Cell> ent = it.next();
|
||||
final Cell cell = ent.getValue();
|
||||
if (cell == null || cell.getData() == null) {
|
||||
continue;
|
||||
}
|
||||
if (ent.getKey().getLine() == source) {
|
||||
supp.put(new Coord(dest, ent.getKey().getCol()), cell);
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
cells.putAll(supp);
|
||||
removeLine(source);
|
||||
}
|
||||
// public void mergeLines(Line line1, Line line2) {
|
||||
// final Map<Coord, Cell> supp = new HashMap<Coord, Cell>();
|
||||
//
|
||||
// for (Iterator<Map.Entry<Coord, Cell>> it = cells.entrySet().iterator(); it.hasNext();) {
|
||||
// final Map.Entry<Coord, Cell> ent = it.next();
|
||||
// final Cell cell = ent.getValue();
|
||||
// if (cell == null || cell.getData() == null) {
|
||||
// continue;
|
||||
// }
|
||||
// if (ent.getKey().getLine() == source) {
|
||||
// supp.put(new Coord(dest, ent.getKey().getCol()), cell);
|
||||
// it.remove();
|
||||
// }
|
||||
// }
|
||||
// cells.putAll(supp);
|
||||
// removeLine(source);
|
||||
// }
|
||||
|
||||
public void addConnections() {
|
||||
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();
|
||||
for (int i = 0; i < dests.size(); i++) {
|
||||
final Coord dest = getCoord(dests.get(i));
|
||||
for (int i = 0; i < dests2.size(); i++) {
|
||||
final Coord dest = getCoord(dests2.get(i));
|
||||
final boolean startHorizontal = i == 0;
|
||||
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);
|
||||
} else {
|
||||
// drawVertical(src, dest);
|
||||
drawVertical(src, dest);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -295,15 +321,25 @@ public class Grid {
|
||||
.getLine();) {
|
||||
final Line cur = itLine.next();
|
||||
if (cur != dest.getLine()) {
|
||||
Cell tmp = getCell(cur, src.getCol());
|
||||
addPuzzle(tmp, "NS");
|
||||
addPuzzle(cur, src.getCol(), "NS");
|
||||
}
|
||||
}
|
||||
for (Navigator<Col> itCol = Navigators.iterate(cols, src.getCol(), dest.getCol()); itCol.get() != dest.getCol();) {
|
||||
final Col cur = itCol.next();
|
||||
if (cur != dest.getCol()) {
|
||||
Cell tmp = getCell(dest.getLine(), cur);
|
||||
addPuzzle(tmp, "EW");
|
||||
addPuzzle(dest.getLine(), cur, "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();) {
|
||||
final Col cur = itCol.next();
|
||||
if (cur != dest.getCol()) {
|
||||
Cell tmp = getCell(src.getLine(), cur);
|
||||
addPuzzle(tmp, "EW");
|
||||
addPuzzle(src.getLine(), cur, "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
|
||||
.getLine();) {
|
||||
final Line cur = itLine.next();
|
||||
if (cur != dest.getLine()) {
|
||||
Cell tmp = getCell(cur, src.getCol());
|
||||
addPuzzle(tmp, "NS");
|
||||
addPuzzle(cur, dest.getCol(), "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);
|
||||
final ConnectorPuzzle before = (ConnectorPuzzle) tmp.getData();
|
||||
final ConnectorPuzzle before = (ConnectorPuzzle) cell.getData();
|
||||
if (before != null) {
|
||||
after = after.append(before);
|
||||
}
|
||||
tmp.setData(after);
|
||||
cell.setData(after);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public final class Navigators {
|
||||
if (orig.compare(from, to) <= 0) {
|
||||
return orig.navigator(from);
|
||||
}
|
||||
return reverse(orig.navigator(to));
|
||||
return reverse(orig.navigator(from));
|
||||
}
|
||||
|
||||
public static <O> Navigator<O> reverse(final Navigator<O> orig) {
|
||||
|
@ -131,7 +131,7 @@ public class UGraphicBraille extends AbstractUGraphic<BrailleGrid> implements Cl
|
||||
metadata, null, 0, 0, null, false);
|
||||
imageBuilder.setUDrawable(new BrailleDrawer(getGraphicObject()));
|
||||
|
||||
imageBuilder.writeImageTOBEMOVED(new FileFormatOption(FileFormat.PNG), os);
|
||||
imageBuilder.writeImageTOBEMOVED(new FileFormatOption(FileFormat.PNG), 42, os);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -59,14 +59,14 @@ public abstract class AbstractEntityDiagram extends CucaDiagram {
|
||||
|
||||
final public DiagramDescription getDescription() {
|
||||
final StringBuilder result = new StringBuilder("(" + getLeafssize() + " entities");
|
||||
final String id = getSource().getId();
|
||||
if (id == null) {
|
||||
result.append(")");
|
||||
} else {
|
||||
result.append(", ");
|
||||
result.append(id);
|
||||
result.append(")");
|
||||
if (getSource() != null) {
|
||||
final String id = getSource().getId();
|
||||
if (id != null) {
|
||||
result.append(", ");
|
||||
result.append(id);
|
||||
}
|
||||
}
|
||||
result.append(")");
|
||||
return new DiagramDescription(result.toString());
|
||||
}
|
||||
|
||||
|
@ -216,7 +216,7 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram {
|
||||
}
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(getSkinParam(), 1, null, null, 0, 10, null);
|
||||
imageBuilder.setUDrawable(fullLayout);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed(), os);
|
||||
}
|
||||
|
||||
private RowLayout getRawLayout(int raw) {
|
||||
|
@ -59,7 +59,7 @@ import net.sourceforge.plantuml.version.IteratorCounter2Impl;
|
||||
* So the diagram does not have to be a UML one.
|
||||
*
|
||||
* @author Arnaud Roques
|
||||
*
|
||||
*
|
||||
*/
|
||||
final public class UmlSource {
|
||||
|
||||
@ -134,6 +134,17 @@ final public class UmlSource {
|
||||
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.
|
||||
*
|
||||
|
@ -69,7 +69,7 @@ public class PSystemCreole extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final Display display = Display.create(lines);
|
||||
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,
|
||||
false);
|
||||
builder.setUDrawable(sheetBlock);
|
||||
return builder.writeImageTOBEMOVED(fileFormat, os);
|
||||
return builder.writeImageTOBEMOVED(fileFormat, seed, os);
|
||||
|
||||
// final Dimension2D dim = TextBlockUtils.getDimension(sheetBlock);
|
||||
// final UGraphic2 ug = fileFormat.createUGraphic(new ColorMapperIdentity(), 1, dim, null, false);
|
||||
|
@ -82,6 +82,9 @@ public class GraphvizVersionFinder {
|
||||
}
|
||||
|
||||
public boolean useProtectionWhenThereALinkFromOrToGroup() {
|
||||
if (v == 239 || v == 240) {
|
||||
return false;
|
||||
}
|
||||
// return v < 238;
|
||||
return true;
|
||||
}
|
||||
|
@ -84,11 +84,11 @@ public class PSystemCute extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final ImageBuilder builder = new ImageBuilder(new ColorMapperIdentity(), 1.0, null, null, null, 10, 10, null,
|
||||
false);
|
||||
builder.setUDrawable(root);
|
||||
return builder.writeImageTOBEMOVED(fileFormat, os);
|
||||
return builder.writeImageTOBEMOVED(fileFormat, seed, os);
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public class PSystemDedication extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE,
|
||||
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() {
|
||||
|
@ -69,13 +69,13 @@ public class PSystemDefinition extends AbstractPSystem implements UDrawable {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1, null, "", "", 0, 0, null,
|
||||
false);
|
||||
imageBuilder.setUDrawable(this);
|
||||
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed, os);
|
||||
}
|
||||
|
||||
public void drawU(UGraphic ug) {
|
||||
|
@ -68,14 +68,15 @@ public class PSystemDot extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final Graphviz graphviz = GraphvizUtils.create(null, data,
|
||||
StringUtils.goLowerCase(fileFormat.getFileFormat().name()));
|
||||
if (graphviz.getExeState() != ExeState.OK) {
|
||||
final TextBlock result = GraphicStrings.createForError(
|
||||
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();
|
||||
}
|
||||
final CounterOutputStream counter = new CounterOutputStream(os);
|
||||
@ -85,7 +86,8 @@ public class PSystemDot extends AbstractPSystem {
|
||||
}
|
||||
if (counter.getLength() == 0) {
|
||||
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();
|
||||
|
@ -77,7 +77,7 @@ public class PSystemDitaa extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
if (fileFormat.getFileFormat() == FileFormat.ATXT) {
|
||||
os.write(getSource().getPlainString().getBytes());
|
||||
|
@ -64,27 +64,27 @@ import net.sourceforge.plantuml.version.PSystemVersion;
|
||||
|
||||
public class PSystemDonors extends AbstractPSystem {
|
||||
|
||||
public static final String DONORS = "UDfbL4jksp0GtSyfk1RIGoXsxDI_17QQ0jcDfR75c29TKd8ghOAUeK3NlKABB8eMsVG2oeqwSYkJIWa8"
|
||||
+ "q8Z3uNipxobMqRz55gwf82jYNHWjCO4RYlmoESoC3ws3k3kAQnXRlqKLh6YDhf2enS9a6cAT6Yl6XegQ"
|
||||
+ "sjVDXZEwTDGmm-0YNS1GTe5K4FlIvW2hqaEeO2oZ_j869XtAqi6ge7r6MWoCsJE_ONSFEPZchuuQ2mEZ"
|
||||
+ "f1PBKpg2IVbgFxetJAGBzXBc0MhCmv2lYXLzH9roEmUPvAfRj1KpNPvewoqiGlH53LTA7lZ0K2OxHdxQ"
|
||||
+ "aHektAcq3a14T81XdSl2LcA6cKaH9ctJxpBaya5UHCgFYzUkuZPfB3YFyJ6koL_mjEknqYc7Dk6UZ71j"
|
||||
+ "gvrvS3l9XHGVkxA5hE7IPwS6vZB9I8bpbAeA6QWw1ECSJ0Zrcmac7qfoObYkBV8ibUTxQ-uBIZ8njUZG"
|
||||
+ "GzeIIpIOs4EhB4uHKtEGeL2EKddd2Kk4PI3UzegGPtJFf_U1hCokxSoviQXHxS_47HLezWwMJ11jAgQo"
|
||||
+ "7IsCbB5jl-U_Vobr7BeNX0h4oNAQdUHaiUjsE_MipyZ1DNRoMCeUu5X9iK9CsJfsI-8zwItPCp6FRzwk"
|
||||
+ "OY_jo6WOKyyo8NETi4HoSSkeXopQgS-qr4wMpJ8ZWej3gFm3mi8NeRm36GKqngLaNPGvYP4fgV3zJHoC"
|
||||
+ "miaSkNWrw3fi6yDTo2rhQ2LpRq46n4xUj9r6TdK0Eb8Aci_DKr2-UMf-m23hMRjYuvNhuu_0QlR2fUd1"
|
||||
+ "6PFPR2nLOY5p7jm4__-hB763IimhfzWZpTVcwUMn-TvU9PelpNFpitb--SJF8t_w1XUMQZ55bREpBiDP"
|
||||
+ "jt8brkivgNPJmny9r86N";
|
||||
public static final String DONORS = "UDfbL4jksp0GtSyfk1RIGoXsxDI_17QQ0jcDfR75c29TKd8ghOAUeK3NlKABB8eMsVG2oeqwSYkJIWaO"
|
||||
+ "CCNXp7ipxp5MqRz55gwf82jYNHWjCO4RYlmoESoCtre7SNSLrp2s_eWgMD4QNI5HYuN9DCGwDLQC3HKr"
|
||||
+ "jNyt6uxemb7338D2ke2Xx3PIGUnJcmEiIW-XWh6C-aiRc7GeImUhWlOPQJ4mPi_yXbqTSZ3DNrqr5WP6"
|
||||
+ "IIsMfdG4a_BLUNHlc4YtsKkO1wWn3xTSAbRq4NNAxHnaahDkqLRCT7cYhRUm2D4NDLmfUU0BGvdi6Fdf"
|
||||
+ "H6guSAVKEW0HqG66TIuBMuaPPYP5cBHDlykGqmTn4Ia_BbwxYjkaiU0uniUu9d_1qwx7IgUyjGdtP8Hh"
|
||||
+ "M-tCWzj9JgJusfKjP0sNFZerC9T9HagSerHLo43L8HZdO4Aetqmm-L2I4yDoRP5dgJpVMtDVK9A9gKM7"
|
||||
+ "7jAMMAB1n1vQPN68c9g338LobCexJrWYB0FnjYL2dj4ztzu7iZAxjZFdng96jJyJTrIWsJjOCa6qgPZA"
|
||||
+ "ThGmKiQs_Px__gNKSUXU42eG9yjfTfAJnQxRxTIpFYC7rzZ9OobxW6CbnGenPUlOBOdtfBTapyGyldcx"
|
||||
+ "Yhsq8wDXJ3tBXCnrmXB9nIsZ7h9efpxIKZjPDikC22uEeV8F20kVXF8EP1JG69UITL7c94QcfCBtDt4m"
|
||||
+ "2YTpvEBLeEkmRGnt8RUiePNClGKP43jvqtOQsTK1w4WfQ3utJq7wvgdv0OEiP-sAZLUkZm-1rUo5IzE3"
|
||||
+ "CoQpsLYgn4BcFBW9_l-gB763IimhfzWZpTVcwUMn-TwM4isNvhdvsJo_VEBV8t_w1XUMQZ55bREpBiDP"
|
||||
+ "jt8brkivgVPG1sFZAZ9u5QE87ya-2nRO7yKAYtS0";
|
||||
|
||||
@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 {
|
||||
final UDrawable result = getGraphicStrings();
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE,
|
||||
getMetadata(), null, 0, 0, null, false);
|
||||
imageBuilder.setUDrawable(result);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
|
||||
}
|
||||
|
||||
private UDrawable getGraphicStrings() throws IOException {
|
||||
|
@ -70,13 +70,13 @@ public class PSystemAppleTwo extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final TextBlockBackcolored result = getGraphicStrings();
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
|
||||
getMetadata(), null, 0, 0, null, false);
|
||||
imageBuilder.setUDrawable(result);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
|
||||
}
|
||||
|
||||
private TextBlockBackcolored getGraphicStrings() throws IOException {
|
||||
|
@ -59,7 +59,7 @@ public class PSystemCharlie extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.BLACK,
|
||||
getMetadata(), null, 0, 0, null, false);
|
||||
@ -70,7 +70,7 @@ public class PSystemCharlie extends AbstractPSystem {
|
||||
ug.draw(im);
|
||||
}
|
||||
});
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
|
||||
}
|
||||
|
||||
public DiagramDescription getDescription() {
|
||||
|
@ -35,7 +35,6 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.eggs;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.io.IOException;
|
||||
@ -90,12 +89,12 @@ public class PSystemColors extends AbstractPSystem implements UDrawable {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE,
|
||||
getMetadata(), null, 0, 0, null, false);
|
||||
imageBuilder.setUDrawable(this);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
|
||||
}
|
||||
|
||||
public DiagramDescription getDescription() {
|
||||
|
@ -62,13 +62,13 @@ public class PSystemEgg extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final TextBlockBackcolored result = getGraphicStrings();
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
|
||||
getMetadata(), null, 0, 0, null, false);
|
||||
imageBuilder.setUDrawable(result);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
|
||||
}
|
||||
|
||||
private TextBlockBackcolored getGraphicStrings() throws IOException {
|
||||
|
@ -57,12 +57,14 @@ public class PSystemLost extends AbstractPSystem {
|
||||
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 ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
|
||||
getMetadata(), null, 0, 0, null, false);
|
||||
imageBuilder.setUDrawable(result);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
|
||||
}
|
||||
|
||||
private TextBlockBackcolored getGraphicStrings() throws IOException {
|
||||
|
@ -53,7 +53,7 @@ public class PSystemPath extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
return path.writeImage(os);
|
||||
}
|
||||
|
@ -78,13 +78,13 @@ public class PSystemRIP extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final TextBlockBackcolored result = getGraphicStrings();
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
|
||||
getMetadata(), null, 0, 0, null, false);
|
||||
imageBuilder.setUDrawable(result);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
|
||||
}
|
||||
|
||||
private TextBlockBackcolored getGraphicStrings() throws IOException {
|
||||
|
@ -81,14 +81,14 @@ public class PSystemWelcome extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final TextBlockBackcolored result = getGraphicStrings();
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
|
||||
getMetadata(), null, 0, 0, null, false);
|
||||
imageBuilder.setUDrawable(result);
|
||||
// imageBuilder.setUDrawable(TextBlockUtils.withMargin(result, 4, 4));
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
|
||||
}
|
||||
|
||||
public TextBlockBackcolored getGraphicStrings() throws IOException {
|
||||
|
@ -123,8 +123,10 @@ public class FlowDiagram extends UmlDiagram implements TextBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) throws IOException {
|
||||
UGraphicUtils.writeImage(os, null, fileFormatOption, new ColorMapperIdentity(), HtmlColorUtils.WHITE, this);
|
||||
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||
throws IOException {
|
||||
UGraphicUtils.writeImage(os, null, fileFormatOption, seed(), new ColorMapperIdentity(),
|
||||
HtmlColorUtils.WHITE, this);
|
||||
return new ImageDataSimple();
|
||||
}
|
||||
|
||||
@ -144,8 +146,8 @@ public class FlowDiagram extends UmlDiagram implements TextBlock {
|
||||
final Dimension2D dimBox = box.calculateDimension(stringBounder);
|
||||
final double deltaX = SINGLE_SIZE_X * 2 - dimBox.getWidth();
|
||||
final double deltaY = SINGLE_SIZE_Y * 2 - dimBox.getHeight();
|
||||
box.drawU(ug.apply(new UTranslate((x + xmin * SINGLE_SIZE_X + deltaX / 2), (y + ymin
|
||||
* SINGLE_SIZE_Y + deltaY / 2))));
|
||||
box.drawU(ug.apply(new UTranslate((x + xmin * SINGLE_SIZE_X + deltaX / 2),
|
||||
(y + ymin * SINGLE_SIZE_Y + deltaY / 2))));
|
||||
}
|
||||
ug = ug.apply(new UChangeColor(HtmlColorUtils.MY_RED));
|
||||
ug = ug.apply(new UChangeBackColor(HtmlColorUtils.MY_RED));
|
||||
|
@ -70,13 +70,13 @@ public class PSystemListFonts extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final TextBlockBackcolored result = getGraphicStrings();
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
|
||||
getMetadata(), null, 0, 0, null, false);
|
||||
imageBuilder.setUDrawable(result);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
|
||||
}
|
||||
|
||||
private TextBlockBackcolored getGraphicStrings() throws IOException {
|
||||
|
@ -171,7 +171,7 @@ public class FtpConnexion {
|
||||
done = true;
|
||||
if (desc.getDescription().startsWith("(Error)")) {
|
||||
final ByteArrayOutputStream errBaos = new ByteArrayOutputStream();
|
||||
sourceStringReader.generateImage(errBaos, new FileFormatOption(FileFormat.ATXT));
|
||||
sourceStringReader.outputImage(errBaos, new FileFormatOption(FileFormat.ATXT));
|
||||
errBaos.close();
|
||||
outgoing.put(errorFileName, errBaos.toByteArray());
|
||||
}
|
||||
|
@ -229,7 +229,11 @@ public class QuoteUtils {
|
||||
"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.",
|
||||
"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() {
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ public class PSystemJcckit extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||
|
||||
|
@ -310,7 +310,8 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker {
|
||||
final IEntityImage image = printEntityInternal(ent);
|
||||
final Dimension2D dim = image.calculateDimension(stringBounder);
|
||||
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);
|
||||
getBibliotekon().putShape(ent, shape);
|
||||
}
|
||||
@ -433,19 +434,19 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker {
|
||||
|
||||
final double scale = 1;
|
||||
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(diagram.getSkinParam(),
|
||||
scale, fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null, null, 0,
|
||||
10, diagram.getAnimation());
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(diagram.getSkinParam(), scale,
|
||||
fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null, null, 0, 10,
|
||||
diagram.getAnimation());
|
||||
|
||||
imageBuilder.setUDrawable(new Drawing(null));
|
||||
final Dimension2D dim = imageBuilder.getFinalDimension(stringBounder);
|
||||
|
||||
imageBuilder.setUDrawable(new Drawing(new YMirror(dim.getHeight())));
|
||||
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, diagram.seed(), os);
|
||||
} catch (Throwable e) {
|
||||
UmlDiagram.exportDiagramError(os, e, fileFormatOption, diagram.getMetadata(), diagram.getFlashData(),
|
||||
getFailureText3(e));
|
||||
UmlDiagram.exportDiagramError(os, e, fileFormatOption, diagram.seed(), diagram.getMetadata(),
|
||||
diagram.getFlashData(), getFailureText3(e));
|
||||
return new ImageDataSimple();
|
||||
} finally {
|
||||
Z.close();
|
||||
@ -568,7 +569,8 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker {
|
||||
final IEntityImage image = printEntityInternal(ent);
|
||||
final Dimension2D dim = image.calculateDimension(stringBounder);
|
||||
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);
|
||||
getBibliotekon().putShape(ent, shape);
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public class PSystemTree extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final ImageBuilder builder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE, null, null,
|
||||
5, 5, null, false);
|
||||
@ -76,7 +76,7 @@ public class PSystemTree extends AbstractPSystem {
|
||||
} else {
|
||||
builder.setUDrawable(new GTileOneLevelFactory().createGTile(root));
|
||||
}
|
||||
return builder.writeImageTOBEMOVED(fileFormat, os);
|
||||
return builder.writeImageTOBEMOVED(fileFormat, seed, os);
|
||||
}
|
||||
|
||||
public CommandExecutionResult addParagraph(int level, String label) {
|
||||
|
@ -61,7 +61,7 @@ public class PSystemLogo extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final int width = 640;
|
||||
final int height = 480;
|
||||
|
@ -56,7 +56,7 @@ public class PSystemLatex extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final ScientificEquationSafe asciiMath = ScientificEquationSafe.fromLatex(latex);
|
||||
return asciiMath.export(os, fileFormat, 1, Color.BLACK, Color.WHITE);
|
||||
|
@ -56,7 +56,7 @@ public class PSystemMath extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final ScientificEquationSafe asciiMath = ScientificEquationSafe.fromAsciiMath(math);
|
||||
return asciiMath.export(os, fileFormat, 1, Color.BLACK, Color.WHITE);
|
||||
|
@ -99,7 +99,7 @@ public class ScientificEquationSafe {
|
||||
final ImageBuilder imageBuilder = getRollback();
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
try {
|
||||
dimSvg = imageBuilder.writeImageTOBEMOVED(new FileFormatOption(FileFormat.SVG), baos);
|
||||
dimSvg = imageBuilder.writeImageTOBEMOVED(new FileFormatOption(FileFormat.SVG), 42, baos);
|
||||
} catch (IOException e1) {
|
||||
return null;
|
||||
}
|
||||
@ -115,7 +115,7 @@ public class ScientificEquationSafe {
|
||||
final ImageBuilder imageBuilder = getRollback();
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
try {
|
||||
imageBuilder.writeImageTOBEMOVED(new FileFormatOption(FileFormat.PNG), baos);
|
||||
imageBuilder.writeImageTOBEMOVED(new FileFormatOption(FileFormat.PNG), 42, baos);
|
||||
return ImageIO.read(new ByteArrayInputStream(baos.toByteArray()));
|
||||
} catch (IOException e1) {
|
||||
return null;
|
||||
|
@ -60,13 +60,13 @@ import net.sourceforge.plantuml.ugraphic.ImageBuilder;
|
||||
public class PSystemListOpenIconic extends AbstractPSystem {
|
||||
|
||||
@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 {
|
||||
final UDrawable result = getGraphicStrings();
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE,
|
||||
getMetadata(), null, 0, 0, null, false);
|
||||
imageBuilder.setUDrawable(result);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
|
||||
}
|
||||
|
||||
private UDrawable getGraphicStrings() throws IOException {
|
||||
|
@ -57,7 +57,7 @@ public class PSystemOpenIconic extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final OpenIcon icon = OpenIcon.retrieve(iconName);
|
||||
// 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,
|
||||
null, false);
|
||||
imageBuilder.setUDrawable(icon.asTextBlock(HtmlColorUtils.BLACK, factor));
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
|
||||
|
||||
// UGraphic2 ug = fileFormat.createUGraphic(dim);
|
||||
// ug = (UGraphic2) ug.apply(new UTranslate(10, 10));
|
||||
|
@ -95,13 +95,13 @@ public class PSystemOregon extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final TextBlockBackcolored result = getGraphicStrings();
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
|
||||
getMetadata(), null, 0, 0, null, false);
|
||||
imageBuilder.setUDrawable(result);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
|
||||
}
|
||||
|
||||
private TextBlockBackcolored getGraphicStrings() throws IOException {
|
||||
|
@ -45,38 +45,27 @@ import java.util.List;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import net.sourceforge.plantuml.FileFormat;
|
||||
import net.sourceforge.plantuml.FileUtils;
|
||||
import net.sourceforge.plantuml.Log;
|
||||
import net.sourceforge.plantuml.SplitParam;
|
||||
import net.sourceforge.plantuml.SuggestedFile;
|
||||
|
||||
public class PngSplitter {
|
||||
|
||||
private final List<File> files = new ArrayList<File>();
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
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,
|
||||
public PngSplitter(SuggestedFile pngFile, int horizontalPages, int verticalPages, String source, int dpi,
|
||||
boolean isWithMetadata, SplitParam splitParam) throws IOException {
|
||||
if (horizontalPages == 1 && verticalPages == 1) {
|
||||
this.files.add(pngFile);
|
||||
this.files.add(pngFile.getFile(0));
|
||||
return;
|
||||
}
|
||||
|
||||
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();
|
||||
full.delete();
|
||||
// Thread.yield();
|
||||
final boolean ok = pngFile.renameTo(full);
|
||||
final boolean ok = pngFile.getFile(0).renameTo(full);
|
||||
// Thread.yield();
|
||||
if (ok == false) {
|
||||
throw new IOException("Cannot rename");
|
||||
@ -91,7 +80,7 @@ public class PngSplitter {
|
||||
int x = 0;
|
||||
for (int i = 0; i < horizontalPages; i++) {
|
||||
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);
|
||||
final int width = horizontalSegment.getLen(i);
|
||||
final int height = verticalSegment.getLen(j);
|
||||
|
@ -96,7 +96,7 @@ class PrintSkin extends AbstractPSystem {
|
||||
// }
|
||||
|
||||
@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 {
|
||||
final BufferedImage im = createImage();
|
||||
final ImageData imageData = new ImageDataSimple(im.getWidth(), (int) maxYpos);
|
||||
|
@ -73,7 +73,7 @@ public class PSystemProject extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final GanttDiagramUnused diagram = new GanttDiagramUnused(project);
|
||||
final FileFormat fileFormat = fileFormatOption.getFileFormat();
|
||||
@ -82,7 +82,7 @@ public class PSystemProject extends AbstractPSystem {
|
||||
PngIO.write(im, os, fileFormatOption.isWithMetadata() ? getMetadata() : null, 96);
|
||||
} else if (fileFormat == FileFormat.SVG) {
|
||||
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);
|
||||
svg.createXml(os, fileFormatOption.isWithMetadata() ? getMetadata() : null);
|
||||
} else if (fileFormat == FileFormat.EPS) {
|
||||
|
@ -72,7 +72,7 @@ public class PSystemProject2 extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final GanttDiagram2 diagram = new GanttDiagram2(project);
|
||||
final FileFormat fileFormat = fileFormatOption.getFileFormat();
|
||||
@ -81,7 +81,7 @@ public class PSystemProject2 extends AbstractPSystem {
|
||||
PngIO.write(im, os, fileFormatOption.isWithMetadata() ? getMetadata() : null, 96);
|
||||
} else if (fileFormat == FileFormat.SVG) {
|
||||
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);
|
||||
svg.createXml(os, fileFormatOption.isWithMetadata() ? getMetadata() : null);
|
||||
} else if (fileFormat == FileFormat.EPS) {
|
||||
|
@ -83,7 +83,7 @@ public class GanttDiagram extends AbstractPSystem implements Subject {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||
protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption, long seed)
|
||||
throws IOException {
|
||||
final double dpiFactor = 1;
|
||||
final double margin = 10;
|
||||
@ -97,7 +97,7 @@ public class GanttDiagram extends AbstractPSystem implements Subject {
|
||||
false);
|
||||
imageBuilder.setUDrawable(getUDrawable());
|
||||
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed, os);
|
||||
}
|
||||
|
||||
private void sortTasks() {
|
||||
|
@ -74,7 +74,7 @@ public class PSystemSalt extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
try {
|
||||
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()));
|
||||
}
|
||||
});
|
||||
return builder.writeImageTOBEMOVED(fileFormat, os);
|
||||
return builder.writeImageTOBEMOVED(fileFormat, seed, os);
|
||||
} catch (Exception e) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -178,7 +178,7 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker {
|
||||
|
||||
}
|
||||
});
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, diagram.seed(), os);
|
||||
|
||||
}
|
||||
|
||||
|
@ -58,13 +58,13 @@ public class PSystemStats extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final TextBlockBackcolored result = getGraphicStrings();
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
|
||||
getMetadata(), null, 0, 0, null, false);
|
||||
imageBuilder.setUDrawable(result);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
|
||||
}
|
||||
|
||||
public static PSystemStats create() throws IOException {
|
||||
|
@ -48,7 +48,7 @@ public class PSystemSudoku extends AbstractPSystem {
|
||||
final private ISudoku sudoku;
|
||||
|
||||
@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 {
|
||||
return new GraphicsSudoku(sudoku).writeImage(os);
|
||||
}
|
||||
|
@ -117,11 +117,11 @@ public final class CucaDiagramFileMakerSvek implements CucaDiagramFileMaker {
|
||||
final Dimension2D dim = result.calculateDimension(fileFormatOption.getDefaultStringBounder());
|
||||
final double scale = getScale(fileFormatOption, dim);
|
||||
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(diagram.getSkinParam(),
|
||||
scale, fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null, warningOrError, 0,
|
||||
10, diagram.getAnimation(), result.getBackcolor());
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(diagram.getSkinParam(), scale,
|
||||
fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null, warningOrError, 0, 10,
|
||||
diagram.getAnimation(), result.getBackcolor());
|
||||
imageBuilder.setUDrawable(result);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, diagram.seed(), os);
|
||||
|
||||
}
|
||||
|
||||
|
@ -116,11 +116,11 @@ public class SvgGraphics {
|
||||
}
|
||||
}
|
||||
|
||||
public SvgGraphics(double scale, String hover, Random rnd) {
|
||||
this(null, scale, hover, rnd);
|
||||
public SvgGraphics(double scale, String hover, long seed) {
|
||||
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 {
|
||||
this.scale = scale;
|
||||
this.document = getDocument();
|
||||
@ -133,10 +133,9 @@ public class SvgGraphics {
|
||||
defs = simpleElement("defs");
|
||||
gRoot = simpleElement("g");
|
||||
strokeWidth = "" + scale;
|
||||
// final Random rnd = new Random();
|
||||
this.filterUid = "b" + getRandomString(rnd);
|
||||
this.shadowId = "f" + getRandomString(rnd);
|
||||
this.gradientId = "g" + getRandomString(rnd);
|
||||
this.filterUid = "b" + getSeed(seed);
|
||||
this.shadowId = "f" + getSeed(seed);
|
||||
this.gradientId = "g" + getSeed(seed);
|
||||
if (hover != null) {
|
||||
defs.appendChild(getPathHover(hover));
|
||||
}
|
||||
@ -154,16 +153,8 @@ public class SvgGraphics {
|
||||
return style;
|
||||
}
|
||||
|
||||
private static String getRandomString(final Random rnd) {
|
||||
String result = Integer.toString(Math.abs(rnd.nextInt()), 36);
|
||||
while (result.length() < 6) {
|
||||
result = "0" + result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.err.println(getRandomString(new Random()));
|
||||
private static String getSeed(final long seed) {
|
||||
return Long.toString(Math.abs(seed), 36);
|
||||
}
|
||||
|
||||
private Element pendingBackground;
|
||||
|
@ -310,7 +310,7 @@ class ImageWindow2 extends JFrame {
|
||||
imageBuilder.setUDrawable(error);
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
try {
|
||||
imageBuilder.writeImageTOBEMOVED(new FileFormatOption(FileFormat.PNG), baos);
|
||||
imageBuilder.writeImageTOBEMOVED(new FileFormatOption(FileFormat.PNG), 42, baos);
|
||||
baos.close();
|
||||
image = ImageIO.read(new ByteArrayInputStream(baos.toByteArray()));
|
||||
} catch (IOException e) {
|
||||
|
@ -81,7 +81,7 @@ class AcceptTelnetClient extends Thread {
|
||||
final String uml = runInternal();
|
||||
Log.println("UML=" + uml);
|
||||
final SourceStringReader s = new SourceStringReader(uml);
|
||||
s.generateImage(os, new FileFormatOption(FileFormat.ATXT));
|
||||
s.outputImage(os, new FileFormatOption(FileFormat.ATXT));
|
||||
os.close();
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
@ -34,20 +34,22 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.timingdiagram;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public final int getTime() {
|
||||
public final BigDecimal getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public int compareTo(TimeTick other) {
|
||||
return this.time - other.time;
|
||||
return this.time.compareTo(other.time);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,12 +34,14 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.timingdiagram;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import net.sourceforge.plantuml.command.regex.RegexLeaf;
|
||||
import net.sourceforge.plantuml.command.regex.RegexResult;
|
||||
|
||||
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;
|
||||
|
||||
public static RegexLeaf expressionAtWithoutArobase(String name) {
|
||||
@ -60,9 +62,9 @@ public class TimeTickBuilder {
|
||||
return clock.getNow();
|
||||
}
|
||||
final boolean isRelative = "+".equals(arg.get(name, 0));
|
||||
int value = Integer.parseInt(number);
|
||||
BigDecimal value = new BigDecimal(number);
|
||||
if (isRelative) {
|
||||
value += clock.getNow().getTime();
|
||||
value = clock.getNow().getTime().add(value);
|
||||
}
|
||||
return new TimeTick(value);
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public class TimingDiagram extends UmlDiagram implements Clock {
|
||||
getAnimation());
|
||||
imageBuilder.setUDrawable(getUDrawable());
|
||||
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed(), os);
|
||||
}
|
||||
|
||||
private UDrawable getUDrawable() {
|
||||
@ -207,4 +207,8 @@ public class TimingDiagram extends UmlDiagram implements Clock {
|
||||
return lastPlayer;
|
||||
}
|
||||
|
||||
public void scaleInPixels(long tick, long pixel) {
|
||||
ruler.scaleInPixels(tick, pixel);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ public class TimingDiagramFactory extends UmlDiagramFactory {
|
||||
cmds.add(new CommandAtPlayer());
|
||||
cmds.add(new CommandTimeMessage());
|
||||
cmds.add(new CommandConstraint());
|
||||
cmds.add(new CommandScalePixel());
|
||||
|
||||
return cmds;
|
||||
}
|
||||
|
@ -35,6 +35,9 @@
|
||||
package net.sourceforge.plantuml.timingdiagram;
|
||||
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
@ -43,7 +46,9 @@ import net.sourceforge.plantuml.ISkinParam;
|
||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||
import net.sourceforge.plantuml.ugraphic.UChangeColor;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.ULine;
|
||||
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||
@ -52,10 +57,36 @@ import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
public class TimingRuler {
|
||||
|
||||
private final SortedSet<TimeTick> times = new TreeSet<TimeTick>();
|
||||
private int highestCommonFactor = -1;
|
||||
private long highestCommonFactor = -1;
|
||||
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) {
|
||||
this.skinParam = skinParam;
|
||||
@ -64,12 +95,12 @@ public class TimingRuler {
|
||||
public void addTime(TimeTick time) {
|
||||
final boolean added = times.add(time);
|
||||
if (added) {
|
||||
int tick = time.getTime();
|
||||
long tick = time.getTime().longValue();
|
||||
if (tick > 0) {
|
||||
if (highestCommonFactor == -1) {
|
||||
highestCommonFactor = time.getTime();
|
||||
highestCommonFactor = time.getTime().longValue();
|
||||
} 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);
|
||||
}
|
||||
|
||||
private TextBlock getTimeTextBlock(TimeTick time) {
|
||||
final Display display = Display.getWithNewlines("" + time.getTime());
|
||||
private TextBlock getTimeTextBlock(long time) {
|
||||
final Display display = Display.getWithNewlines("" + time);
|
||||
return display.create(getFontConfiguration(), HorizontalAlignment.LEFT, skinParam);
|
||||
}
|
||||
|
||||
public void draw(UGraphic ug) {
|
||||
ug = ug.apply(new UStroke(2.0));
|
||||
final int nb = getNbTick();
|
||||
// System.err.println("nb=" + nb);
|
||||
ug = ug.apply(new UStroke(2.0)).apply(new UChangeColor(HtmlColorUtils.BLACK));
|
||||
final double tickHeight = 5;
|
||||
final ULine line = new ULine(0, tickHeight);
|
||||
final int nb = getNbTick();
|
||||
for (int i = 0; i <= nb; i++) {
|
||||
ug.apply(new UTranslate(tickIntervalInPixels * i, 0)).draw(line);
|
||||
}
|
||||
ug.draw(new ULine(nb * tickIntervalInPixels, 0));
|
||||
|
||||
for (TimeTick tick : times) {
|
||||
final TextBlock text = getTimeTextBlock(tick);
|
||||
for (long round : roundValues()) {
|
||||
final TextBlock text = getTimeTextBlock(round);
|
||||
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() {
|
||||
return 1 + getMax().getTime() / highestCommonFactor;
|
||||
}
|
||||
|
||||
public double getWidth() {
|
||||
return getPosInPixel((getNbTick()) * highestCommonFactor);
|
||||
private Collection<Long> roundValues() {
|
||||
final Set<Long> result = new TreeSet<Long>();
|
||||
if (tickUnitary == 0) {
|
||||
for (TimeTick tick : times) {
|
||||
final long round = tick.getTime().longValue();
|
||||
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() {
|
||||
@ -118,8 +156,8 @@ public class TimingRuler {
|
||||
return times.last();
|
||||
}
|
||||
|
||||
private static int computeHighestCommonFactor(int a, int b) {
|
||||
int r = a;
|
||||
private static long computeHighestCommonFactor(long a, long b) {
|
||||
long r = a;
|
||||
while (r != 0) {
|
||||
r = a % b;
|
||||
a = b;
|
||||
@ -128,15 +166,15 @@ public class TimingRuler {
|
||||
return (Math.abs(a));
|
||||
}
|
||||
|
||||
public final double getPosInPixel(int time) {
|
||||
return 1.0 * time / highestCommonFactor * tickIntervalInPixels;
|
||||
public final double getPosInPixel(BigDecimal time) {
|
||||
return getPosInPixel(time.doubleValue());
|
||||
}
|
||||
|
||||
public double getPosInPixel(TimeTick when) {
|
||||
public final double getPosInPixel(TimeTick when) {
|
||||
return getPosInPixel(when.getTime());
|
||||
}
|
||||
|
||||
public double getMaxPosInPixel() {
|
||||
public final double getMaxPosInPixel() {
|
||||
return getPosInPixel(getMax());
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ public class FontChecker {
|
||||
}
|
||||
|
||||
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.svgImage(getBufferedImage(c), 0, 0);
|
||||
final ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
@ -183,7 +183,7 @@ public class FontChecker {
|
||||
}
|
||||
});
|
||||
final ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
imageBuilder.writeImageTOBEMOVED(new FileFormatOption(FileFormat.PNG), os);
|
||||
imageBuilder.writeImageTOBEMOVED(new FileFormatOption(FileFormat.PNG), 42, os);
|
||||
os.close();
|
||||
return ImageIO.read(new ByteArrayInputStream(os.toByteArray()));
|
||||
}
|
||||
|
@ -46,7 +46,6 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
@ -162,14 +161,15 @@ public class ImageBuilder {
|
||||
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();
|
||||
if (fileFormat == FileFormat.MJPEG) {
|
||||
return writeImageMjpeg(os, fileFormat.getDefaultStringBounder());
|
||||
} else if (fileFormat == FileFormat.ANIMATED_GIF) {
|
||||
return writeImageAnimatedGif(os, fileFormat.getDefaultStringBounder());
|
||||
}
|
||||
return writeImageInternal(fileFormatOption, os, animation);
|
||||
return writeImageInternal(fileFormatOption, seed, os, animation);
|
||||
}
|
||||
|
||||
private static Semaphore SEMAPHORE_SMALL;
|
||||
@ -204,8 +204,8 @@ public class ImageBuilder {
|
||||
return SEMAPHORE_SMALL;
|
||||
}
|
||||
|
||||
private ImageData writeImageInternal(FileFormatOption fileFormatOption, OutputStream os, Animation animationArg)
|
||||
throws IOException {
|
||||
private ImageData writeImageInternal(FileFormatOption fileFormatOption, long seed, OutputStream os,
|
||||
Animation animationArg) throws IOException {
|
||||
Dimension2D dim = getFinalDimension(fileFormatOption.getDefaultStringBounder());
|
||||
double dx = 0;
|
||||
double dy = 0;
|
||||
@ -228,7 +228,7 @@ public class ImageBuilder {
|
||||
}
|
||||
}
|
||||
try {
|
||||
final UGraphic2 ug = createUGraphic(fileFormatOption, dim, animationArg, dx, dy);
|
||||
final UGraphic2 ug = createUGraphic(fileFormatOption, seed, dim, animationArg, dx, dy);
|
||||
UGraphic ug2 = ug;
|
||||
if (externalMargin1 > 0) {
|
||||
ug2 = ug2.apply(new UTranslate(externalMargin1, externalMargin1));
|
||||
@ -349,7 +349,7 @@ public class ImageBuilder {
|
||||
|
||||
private Image getAviImage(AffineTransformation affineTransform) throws IOException {
|
||||
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();
|
||||
|
||||
final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
@ -358,15 +358,15 @@ public class ImageBuilder {
|
||||
return im;
|
||||
}
|
||||
|
||||
private UGraphic2 createUGraphic(FileFormatOption fileFormatOption, final Dimension2D dim, Animation animationArg,
|
||||
double dx, double dy) {
|
||||
private UGraphic2 createUGraphic(FileFormatOption fileFormatOption, long seed, final Dimension2D dim,
|
||||
Animation animationArg, double dx, double dy) {
|
||||
final FileFormat fileFormat = fileFormatOption.getFileFormat();
|
||||
switch (fileFormat) {
|
||||
case PNG:
|
||||
return createUGraphicPNG(colorMapper, dpiFactor, dim, mybackcolor, animationArg, dx, dy);
|
||||
case SVG:
|
||||
return createUGraphicSVG(colorMapper, dpiFactor, dim, mybackcolor, fileFormatOption.getSvgLinkTarget(),
|
||||
fileFormatOption.getHoverColor(), fileFormatOption.getRandom());
|
||||
fileFormatOption.getHoverColor(), seed);
|
||||
case EPS:
|
||||
return new UGraphicEps(colorMapper, EpsStrategy.getDefault2());
|
||||
case EPS_TEXT:
|
||||
@ -387,20 +387,19 @@ public class ImageBuilder {
|
||||
}
|
||||
|
||||
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;
|
||||
if (mybackcolor instanceof HtmlColorSimple) {
|
||||
backColor = colorMapper.getMappedColor(mybackcolor);
|
||||
}
|
||||
final UGraphicSvg ug;
|
||||
if (mybackcolor instanceof HtmlColorGradient) {
|
||||
ug = new UGraphicSvg(colorMapper, (HtmlColorGradient) mybackcolor, false, scale, svgLinkTarget, hover,
|
||||
random);
|
||||
ug = new UGraphicSvg(colorMapper, (HtmlColorGradient) mybackcolor, false, scale, svgLinkTarget, hover, seed);
|
||||
} 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 {
|
||||
ug = new UGraphicSvg(colorMapper, StringUtils.getAsHtml(backColor), false, scale, svgLinkTarget, hover,
|
||||
random);
|
||||
seed);
|
||||
}
|
||||
return ug;
|
||||
|
||||
|
@ -55,16 +55,7 @@ import net.sourceforge.plantuml.ugraphic.svg.UGraphicSvg;
|
||||
|
||||
public abstract class UGraphicUtils {
|
||||
|
||||
// public static UDrawable translate(final UDrawable d, final double dx, final double dy) {
|
||||
// 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,
|
||||
public static void writeImage(OutputStream os, String metadata, FileFormatOption fileFormatOption, long seed,
|
||||
ColorMapper colorMapper, HtmlColor background, TextBlock image) throws IOException {
|
||||
final FileFormat fileFormat = fileFormatOption.getFileFormat();
|
||||
if (fileFormat == FileFormat.PNG) {
|
||||
@ -73,7 +64,7 @@ public abstract class UGraphicUtils {
|
||||
} else if (fileFormat == FileFormat.SVG) {
|
||||
final UGraphicSvg svg = new UGraphicSvg(colorMapper, StringUtils.getAsHtml(colorMapper
|
||||
.getMappedColor(background)), false, 1.0, fileFormatOption.getSvgLinkTarget(),
|
||||
fileFormatOption.getHoverColor(), fileFormatOption.getRandom());
|
||||
fileFormatOption.getHoverColor(), seed);
|
||||
image.drawU(svg);
|
||||
svg.createXml(os, fileFormatOption.isWithMetadata() ? metadata : null);
|
||||
} else if (fileFormat == FileFormat.EPS) {
|
||||
|
@ -56,13 +56,13 @@ import net.sourceforge.plantuml.ugraphic.ImageBuilder;
|
||||
public class PSystemListInternalSprites extends AbstractPSystem {
|
||||
|
||||
@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 {
|
||||
final UDrawable result = getGraphicStrings();
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE,
|
||||
getMetadata(), null, 0, 0, null, false);
|
||||
imageBuilder.setUDrawable(result);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
|
||||
}
|
||||
|
||||
private UDrawable getGraphicStrings() throws IOException {
|
||||
|
@ -83,18 +83,18 @@ public class UGraphicSvg extends AbstractUGraphic<SvgGraphics> implements ClipCo
|
||||
}
|
||||
|
||||
public UGraphicSvg(ColorMapper colorMapper, String backcolor, boolean textAsPath, double scale, String linkTarget,
|
||||
String hover, Random rnd) {
|
||||
this(colorMapper, new SvgGraphics(backcolor, scale, hover, rnd), textAsPath, linkTarget);
|
||||
String hover, long seed) {
|
||||
this(colorMapper, new SvgGraphics(backcolor, scale, hover, seed), textAsPath, linkTarget);
|
||||
}
|
||||
|
||||
public UGraphicSvg(ColorMapper colorMapper, boolean textAsPath, double scale, String linkTarget, String hover,
|
||||
Random rnd) {
|
||||
this(colorMapper, new SvgGraphics(scale, hover, rnd), textAsPath, linkTarget);
|
||||
long seed) {
|
||||
this(colorMapper, new SvgGraphics(scale, hover, seed), textAsPath, linkTarget);
|
||||
}
|
||||
|
||||
public UGraphicSvg(ColorMapper mapper, HtmlColorGradient gr, boolean textAsPath, double scale, String linkTarget,
|
||||
String hover, Random rnd) {
|
||||
this(mapper, new SvgGraphics(scale, hover, rnd), textAsPath, linkTarget);
|
||||
String hover, long seed) {
|
||||
this(mapper, new SvgGraphics(scale, hover, seed), textAsPath, linkTarget);
|
||||
|
||||
final SvgGraphics svg = getGraphicObject();
|
||||
svg.paintBackcolorGradient(mapper, gr);
|
||||
|
@ -57,13 +57,13 @@ public class PSystemLicense extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final TextBlockBackcolored result = getGraphicStrings();
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
|
||||
getMetadata(), null, 0, 0, null, false);
|
||||
imageBuilder.setUDrawable(result);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
|
||||
}
|
||||
|
||||
public static PSystemLicense create() throws IOException {
|
||||
|
@ -151,14 +151,14 @@ public class PSystemVersion extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final TextBlockBackcolored result = GraphicStrings.createBlackOnWhite(strings, image,
|
||||
GraphicPosition.BACKGROUND_CORNER_BOTTOM_RIGHT);
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
|
||||
getMetadata(), null, 0, 0, null, false);
|
||||
imageBuilder.setUDrawable(result);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
|
||||
}
|
||||
|
||||
public static PSystemVersion createShowVersion() {
|
||||
|
@ -41,7 +41,7 @@ import java.util.Date;
|
||||
public class Version {
|
||||
|
||||
public static int version() {
|
||||
return 201709;
|
||||
return 201711;
|
||||
}
|
||||
|
||||
public static String versionString() {
|
||||
@ -78,7 +78,7 @@ public class Version {
|
||||
}
|
||||
|
||||
public static long compileTime() {
|
||||
return 1491408431708L;
|
||||
return 1492618739962L;
|
||||
}
|
||||
|
||||
public static String compileTimeString() {
|
||||
|
@ -57,6 +57,7 @@ import net.sourceforge.plantuml.cucadiagram.IEntity;
|
||||
import net.sourceforge.plantuml.cucadiagram.LeafType;
|
||||
import net.sourceforge.plantuml.cucadiagram.LongCode;
|
||||
import net.sourceforge.plantuml.cucadiagram.Member;
|
||||
import net.sourceforge.plantuml.cucadiagram.Stereotype;
|
||||
import net.sourceforge.plantuml.skin.VisibilityModifier;
|
||||
import net.sourceforge.plantuml.utils.UniqueSequence;
|
||||
|
||||
@ -158,6 +159,17 @@ abstract class XmiClassDiagramAbstract implements IXmiClassDiagram {
|
||||
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();
|
||||
if (type == LeafType.ABSTRACT_CLASS) {
|
||||
cla.setAttribute("isAbstract", "true");
|
||||
|
Loading…
Reference in New Issue
Block a user