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

version 1.2018.4

This commit is contained in:
Arnaud Roques 2018-05-01 19:26:04 +02:00
parent e3bdf19745
commit cfacbc1f97
59 changed files with 555 additions and 634 deletions

View File

@ -30,7 +30,8 @@
Script Author: Julien Eluard Script Author: Julien Eluard
--> -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>net.sourceforge.plantuml</groupId> <groupId>net.sourceforge.plantuml</groupId>

View File

@ -64,13 +64,13 @@ public class AnnotatedWorker {
} }
private TextBlock addLegend(TextBlock original) { private TextBlock addLegend(TextBlock original) {
if (DisplayPositionned.isNull(annotated.getLegend())) { final DisplayPositionned legend = annotated.getLegend();
if (DisplayPositionned.isNull(legend)) {
return original; return original;
} }
final TextBlock text = EntityImageLegend.create(annotated.getLegend().getDisplay(), getSkinParam()); final TextBlock text = EntityImageLegend.create(legend.getDisplay(), getSkinParam());
return DecorateEntityImage.add(original, text, annotated.getLegend().getHorizontalAlignment(), annotated return DecorateEntityImage.add(original, text, legend.getHorizontalAlignment(), legend.getVerticalAlignment());
.getLegend().getVerticalAlignment());
} }
private ISkinParam getSkinParam() { private ISkinParam getSkinParam() {
@ -78,7 +78,8 @@ public class AnnotatedWorker {
} }
private TextBlock addCaption(TextBlock original) { private TextBlock addCaption(TextBlock original) {
if (DisplayPositionned.isNull(annotated.getCaption())) { final DisplayPositionned caption = annotated.getCaption();
if (DisplayPositionned.isNull(caption)) {
return original; return original;
} }
final TextBlock text = getCaption(); final TextBlock text = getCaption();
@ -87,14 +88,12 @@ public class AnnotatedWorker {
} }
public TextBlock getCaption() { public TextBlock getCaption() {
if (DisplayPositionned.isNull(annotated.getCaption())) { final DisplayPositionned caption = annotated.getCaption();
if (DisplayPositionned.isNull(caption)) {
return TextBlockUtils.empty(0, 0); return TextBlockUtils.empty(0, 0);
} }
return annotated return caption.getDisplay().create(new FontConfiguration(getSkinParam(), FontParam.CAPTION, null),
.getCaption() HorizontalAlignment.CENTER, getSkinParam());
.getDisplay()
.create(new FontConfiguration(getSkinParam(), FontParam.CAPTION, null), HorizontalAlignment.CENTER,
getSkinParam());
} }
private TextBlock addTitle(TextBlock original) { private TextBlock addTitle(TextBlock original) {
@ -110,22 +109,23 @@ public class AnnotatedWorker {
} }
private TextBlock addHeaderAndFooter(TextBlock original) { private TextBlock addHeaderAndFooter(TextBlock original) {
if (DisplayPositionned.isNull(annotated.getFooter()) && DisplayPositionned.isNull(annotated.getHeader())) { final DisplayPositionned footer = annotated.getFooter();
final DisplayPositionned header = annotated.getHeader();
if (DisplayPositionned.isNull(footer) && DisplayPositionned.isNull(header)) {
return original; return original;
} }
final TextBlock textFooter = DisplayPositionned.isNull(annotated.getFooter()) ? null : annotated TextBlock textFooter = null;
.getFooter() if (DisplayPositionned.isNull(footer) == false) {
.getDisplay() textFooter = footer.getDisplay().create(new FontConfiguration(getSkinParam(), FontParam.FOOTER, null),
.create(new FontConfiguration(getSkinParam(), FontParam.FOOTER, null), footer.getHorizontalAlignment(), getSkinParam());
annotated.getFooter().getHorizontalAlignment(), getSkinParam()); }
final TextBlock textHeader = DisplayPositionned.isNull(annotated.getHeader()) ? null : annotated TextBlock textHeader = null;
.getHeader() if (DisplayPositionned.isNull(header) == false) {
.getDisplay() textHeader = header.getDisplay().create(new FontConfiguration(getSkinParam(), FontParam.HEADER, null),
.create(new FontConfiguration(getSkinParam(), FontParam.HEADER, null), header.getHorizontalAlignment(), getSkinParam());
annotated.getHeader().getHorizontalAlignment(), getSkinParam());
return new DecorateEntityImage(original, textHeader, annotated.getHeader().getHorizontalAlignment(),
textFooter, annotated.getFooter().getHorizontalAlignment());
} }
return DecorateEntityImage.addTopAndBottom(original, textHeader, header.getHorizontalAlignment(), textFooter,
footer.getHorizontalAlignment());
}
} }

View File

@ -36,7 +36,7 @@
package net.sourceforge.plantuml; package net.sourceforge.plantuml;
public enum CornerParam { public enum CornerParam {
DEFAULT, diagramBorder, titleBorder, rectangle, component; DEFAULT, diagramBorder, titleBorder, rectangle, component, card, agent;
public String getRoundKey() { public String getRoundKey() {
if (this == DEFAULT) { if (this == DEFAULT) {

View File

@ -45,4 +45,6 @@ public interface GeneratedImage extends Comparable<GeneratedImage> {
public int lineErrorRaw(); public int lineErrorRaw();
public int getStatus();
} }

View File

@ -44,11 +44,17 @@ public class GeneratedImageImpl implements GeneratedImage {
private final File pngFile; private final File pngFile;
private final String description; private final String description;
private final BlockUml blockUml; private final BlockUml blockUml;
private final int status;
public GeneratedImageImpl(File pngFile, String description, BlockUml blockUml) { public final int getStatus() {
return status;
}
public GeneratedImageImpl(File pngFile, String description, BlockUml blockUml, int status) {
this.blockUml = blockUml; this.blockUml = blockUml;
this.pngFile = pngFile; this.pngFile = pngFile;
this.description = description; this.description = description;
this.status = status;
} }
public File getPngFile() { public File getPngFile() {

View File

@ -48,5 +48,6 @@ public interface ISourceFileReader {
public void setFileFormatOption(FileFormatOption fileFormatOption); public void setFileFormatOption(FileFormatOption fileFormatOption);
public void setCheckMetadata(boolean checkMetadata);
} }

View File

@ -55,7 +55,9 @@ public enum LineParam {
titleBorder, titleBorder,
diagramBorder, diagramBorder,
rectangleBorder, rectangleBorder,
componentBorder; componentBorder,
cardBorder,
agentBorder;
// sequenceBoxBorder(0.1); // sequenceBoxBorder(0.1);
} }

View File

@ -78,6 +78,7 @@ public class Option {
private int nbThreads = 0; private int nbThreads = 0;
private int ftpPort = -1; private int ftpPort = -1;
private boolean hideMetadata = false; private boolean hideMetadata = false;
private boolean checkMetadata = false;
private int imageIndex = 0; private int imageIndex = 0;
private File outputDir = null; private File outputDir = null;
@ -319,6 +320,8 @@ public class Option {
textProgressBar = true; textProgressBar = true;
} else if (s.equalsIgnoreCase("-nometadata")) { } else if (s.equalsIgnoreCase("-nometadata")) {
hideMetadata = true; hideMetadata = true;
} else if (s.equalsIgnoreCase("-checkmetadata")) {
checkMetadata = true;
} else if (s.equalsIgnoreCase("-pipeimageindex")) { } else if (s.equalsIgnoreCase("-pipeimageindex")) {
i++; i++;
if (i == arg.length) { if (i == arg.length) {
@ -406,7 +409,7 @@ public class Option {
} }
public final static String getPattern() { public final static String getPattern() {
return "(?i)^.*\\.(txt|tex|java|htm|html|c|h|cpp|apt|pu)$"; return "(?i)^.*\\.(txt|tex|java|htm|html|c|h|cpp|apt|pu|pump|hpp|hh)$";
} }
public void setOutputDir(File f) { public void setOutputDir(File f) {
@ -569,4 +572,8 @@ public class Option {
this.filename = filename; this.filename = filename;
} }
public final boolean isCheckMetadata() {
return checkMetadata;
}
} }

View File

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

View File

@ -47,6 +47,7 @@ import java.util.Iterator;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.api.ImageDataAbstract;
import net.sourceforge.plantuml.api.ImageDataSimple; import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.asciiart.UmlCharArea; import net.sourceforge.plantuml.asciiart.UmlCharArea;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
@ -148,7 +149,9 @@ public class PSystemError extends AbstractPSystem {
udrawable = addMessage(udrawable); udrawable = addMessage(udrawable);
} }
imageBuilder.setUDrawable(udrawable); imageBuilder.setUDrawable(udrawable);
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed(), os); final ImageData imageData = imageBuilder.writeImageTOBEMOVED(fileFormat, seed(), os);
((ImageDataAbstract) imageData).setStatus(400);
return imageData;
} }
private TextBlockBackcolored getWelcome() throws IOException { private TextBlockBackcolored getWelcome() throws IOException {

View File

@ -51,14 +51,37 @@ import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.CucaDiagram; import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.html.CucaDiagramHtmlMaker; import net.sourceforge.plantuml.html.CucaDiagramHtmlMaker;
import net.sourceforge.plantuml.png.MetadataTag;
import net.sourceforge.plantuml.png.PngSplitter; import net.sourceforge.plantuml.png.PngSplitter;
import net.sourceforge.plantuml.project3.GanttDiagram; import net.sourceforge.plantuml.project3.GanttDiagram;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
public class PSystemUtils { public class PSystemUtils {
public static List<FileImageData> exportDiagrams(Diagram system, SuggestedFile suggestedFile, public static List<FileImageData> exportDiagrams(Diagram system, SuggestedFile suggested,
FileFormatOption fileFormatOption) throws IOException { FileFormatOption fileFormatOption) throws IOException {
return exportDiagrams(system, suggested, fileFormatOption, false);
}
public static List<FileImageData> exportDiagrams(Diagram system, SuggestedFile suggestedFile,
FileFormatOption fileFormatOption, boolean checkMetadata) throws IOException {
final File existing = suggestedFile.getFile(0);
if (checkMetadata && existing.exists() && system.getNbImages() == 1) {
final MetadataTag tag = new MetadataTag(existing, "plantuml");
final String previousMetadata = tag.getData();
// final String version = Version.versionString();
// System.out.println(system.getMetadata());
// System.out.println(data);
// System.out.println(version);
// System.out.println(data.contains(version));
final boolean sameMetadata = system.getMetadata().equals(previousMetadata);
if (sameMetadata) {
Log.info("Skipping " + existing.getAbsolutePath() + " because metadata has not changed.");
return Arrays.asList(new FileImageData(existing, null));
}
}
if (system instanceof NewpagedDiagram) { if (system instanceof NewpagedDiagram) {
return exportDiagramsNewpaged((NewpagedDiagram) system, suggestedFile, fileFormatOption); return exportDiagramsNewpaged((NewpagedDiagram) system, suggestedFile, fileFormatOption);
} }

View File

@ -406,6 +406,7 @@ public class Run {
sourceFileReader = new SourceFileReader2(option.getDefaultDefines(f), f, option.getOutputFile(), sourceFileReader = new SourceFileReader2(option.getDefaultDefines(f), f, option.getOutputFile(),
option.getConfig(), option.getCharset(), option.getFileFormatOption()); option.getConfig(), option.getCharset(), option.getFileFormatOption());
} }
sourceFileReader.setCheckMetadata(option.isCheckMetadata());
if (option.isComputeurl()) { if (option.isComputeurl()) {
for (BlockUml s : sourceFileReader.getBlocks()) { for (BlockUml s : sourceFileReader.getBlocks()) {
System.out.println(s.getEncodedUrl()); System.out.println(s.getEncodedUrl());

View File

@ -420,6 +420,15 @@ public class SkinParam implements ISkinParam {
result.add("TabSize"); result.add("TabSize");
result.add("MaxAsciiMessageLength"); result.add("MaxAsciiMessageLength");
result.add("ColorArrowSeparationSpace"); result.add("ColorArrowSeparationSpace");
result.add("ResponseMessageBelowArrow");
result.add("GenericDisplay");
result.add("PathHoverColor");
result.add("SwimlaneWidth");
result.add("PageBorderColor");
result.add("PageExternalColor");
result.add("PageMargin");
for (FontParam p : EnumSet.allOf(FontParam.class)) { for (FontParam p : EnumSet.allOf(FontParam.class)) {
final String h = humanName(p.name()); final String h = humanName(p.name());
result.add(h + "FontStyle"); result.add(h + "FontStyle");

View File

@ -35,33 +35,14 @@
*/ */
package net.sourceforge.plantuml; package net.sourceforge.plantuml;
import java.io.BufferedOutputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Set;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.preproc.Defines; import net.sourceforge.plantuml.preproc.Defines;
import net.sourceforge.plantuml.preproc.FileWithSuffix;
public class SourceFileReader implements ISourceFileReader { public class SourceFileReader extends SourceFileReaderAbstract implements ISourceFileReader {
private final File file;
private final File outputDirectory;
private final BlockUmlBuilder builder;
private FileFormatOption fileFormatOption;
public SourceFileReader(File file) throws IOException { public SourceFileReader(File file) throws IOException {
this(file, file.getAbsoluteFile().getParentFile()); this(file, file.getAbsoluteFile().getParentFile());
@ -105,15 +86,6 @@ public class SourceFileReader implements ISourceFileReader {
.getParentFile(), file.getAbsolutePath()); .getParentFile(), file.getAbsolutePath());
} }
public boolean hasError() {
for (final BlockUml b : builder.getBlockUmls()) {
if (b.getDiagram() instanceof PSystemError) {
return true;
}
}
return false;
}
private File getDirIfDirectory(String newName) { private File getDirIfDirectory(String newName) {
Log.info("Checking=" + newName); Log.info("Checking=" + newName);
if (endsWithSlashOrAntislash(newName)) { if (endsWithSlashOrAntislash(newName)) {
@ -161,13 +133,8 @@ public class SourceFileReader implements ISourceFileReader {
} }
public List<GeneratedImage> getGeneratedImages() throws IOException { @Override
Log.info("Reading file: " + file); protected SuggestedFile getSuggestedFile(BlockUml blockUml) {
int cpt = 0;
final List<GeneratedImage> result = new ArrayList<GeneratedImage>();
for (BlockUml blockUml : builder.getBlockUmls()) {
final String newName = blockUml.getFileOrDirname(); final String newName = blockUml.getFileOrDirname();
SuggestedFile suggested = null; SuggestedFile suggested = null;
if (newName != null) { if (newName != null) {
@ -189,79 +156,8 @@ public class SourceFileReader implements ISourceFileReader {
fileFormatOption.getFileFormat(), cpt++); fileFormatOption.getFileFormat(), cpt++);
} }
suggested.getParentFile().mkdirs(); suggested.getParentFile().mkdirs();
return suggested;
final Diagram system;
try {
system = blockUml.getDiagram();
} catch (Throwable t) {
final GeneratedImage image = new GeneratedImageImpl(suggested.getFile(0), "Crash Error", blockUml);
OutputStream os = null;
try {
os = new BufferedOutputStream(new FileOutputStream(suggested.getFile(0)));
UmlDiagram.exportDiagramError(os, t, fileFormatOption, 42, null, blockUml.getFlashData(),
UmlDiagram.getFailureText2(t, blockUml.getFlashData()));
} finally {
if (os != null) {
os.close();
}
} }
return Collections.singletonList(image);
}
final List<FileImageData> exportDiagrams = PSystemUtils.exportDiagrams(system, suggested, fileFormatOption);
if (exportDiagrams.size() > 1) {
cpt += exportDiagrams.size() - 1;
}
OptionFlags.getInstance().logData(file, system);
for (FileImageData fdata : exportDiagrams) {
final String desc = "[" + file.getName() + "] " + system.getDescription();
final File f = fdata.getFile();
if (OptionFlags.getInstance().isWord()) {
final String warnOrError = system.getWarningOrError();
if (warnOrError != null) {
final String name = f.getName().substring(0, f.getName().length() - 4) + ".err";
final File errorFile = new File(f.getParentFile(), name);
final PrintStream ps = new PrintStream(new FileOutputStream(errorFile));
ps.print(warnOrError);
ps.close();
}
}
final GeneratedImage generatedImage = new GeneratedImageImpl(f, desc, blockUml);
result.add(generatedImage);
}
}
Log.info("Number of image(s): " + result.size());
return Collections.unmodifiableList(result);
}
private boolean endsWithSlashOrAntislash(String newName) {
return newName.endsWith("/") || newName.endsWith("\\");
}
public List<BlockUml> getBlocks() {
return builder.getBlockUmls();
}
private Reader getReader(String charset) throws FileNotFoundException, UnsupportedEncodingException {
if (charset == null) {
Log.info("Using default charset");
return new InputStreamReader(new FileInputStream(file));
}
Log.info("Using charset " + charset);
return new InputStreamReader(new FileInputStream(file), charset);
}
public final void setFileFormatOption(FileFormatOption fileFormatOption) {
this.fileFormatOption = fileFormatOption;
}
public final Set<FileWithSuffix> getIncludedFiles() {
return builder.getIncludedFiles();
}
} }

View File

@ -36,28 +36,12 @@
package net.sourceforge.plantuml; package net.sourceforge.plantuml;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Set;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.preproc.Defines; import net.sourceforge.plantuml.preproc.Defines;
import net.sourceforge.plantuml.preproc.FileWithSuffix;
public class SourceFileReader2 implements ISourceFileReader { public class SourceFileReader2 extends SourceFileReaderAbstract implements ISourceFileReader {
private final File file;
private final File outputFile;
private final BlockUmlBuilder builder;
private FileFormatOption fileFormatOption;
public SourceFileReader2(Defines defines, final File file, File outputFile, List<String> config, String charset, public SourceFileReader2(Defines defines, final File file, File outputFile, List<String> config, String charset,
FileFormatOption fileFormatOption) throws IOException { FileFormatOption fileFormatOption) throws IOException {
@ -73,58 +57,10 @@ public class SourceFileReader2 implements ISourceFileReader {
.getParentFile(), file.getAbsolutePath()); .getParentFile(), file.getAbsolutePath());
} }
public boolean hasError() { @Override
for (final BlockUml b : builder.getBlockUmls()) { protected SuggestedFile getSuggestedFile(BlockUml blockUml) {
if (b.getDiagram() instanceof PSystemError) {
return true;
}
}
return false;
}
public List<GeneratedImage> getGeneratedImages() throws IOException {
Log.info("Reading file: " + file);
final List<GeneratedImage> result = new ArrayList<GeneratedImage>();
for (BlockUml blockUml : builder.getBlockUmls()) {
final SuggestedFile suggested = SuggestedFile.fromOutputFile(outputFile, fileFormatOption.getFileFormat()); final SuggestedFile suggested = SuggestedFile.fromOutputFile(outputFile, fileFormatOption.getFileFormat());
return suggested;
final Diagram system = blockUml.getDiagram();
OptionFlags.getInstance().logData(file, system);
for (FileImageData fdata : PSystemUtils.exportDiagrams(system, suggested, fileFormatOption)) {
final String desc = "[" + file.getName() + "] " + system.getDescription();
final GeneratedImage generatedImage = new GeneratedImageImpl(fdata.getFile(), desc, blockUml);
result.add(generatedImage);
}
}
Log.info("Number of image(s): " + result.size());
return Collections.unmodifiableList(result);
}
private Reader getReader(String charset) throws FileNotFoundException, UnsupportedEncodingException {
if (charset == null) {
Log.info("Using default charset");
return new InputStreamReader(new FileInputStream(file));
}
Log.info("Using charset " + charset);
return new InputStreamReader(new FileInputStream(file), charset);
}
public final void setFileFormatOption(FileFormatOption fileFormatOption) {
this.fileFormatOption = fileFormatOption;
}
public final Set<FileWithSuffix> getIncludedFiles2() {
return builder.getIncludedFiles();
}
public List<BlockUml> getBlocks() {
return builder.getBlockUmls();
} }
} }

View File

@ -54,7 +54,7 @@ import java.util.Set;
import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.preproc.FileWithSuffix; import net.sourceforge.plantuml.preproc.FileWithSuffix;
public abstract class ZSourceFileReaderAbstract { public abstract class SourceFileReaderAbstract {
protected File file; protected File file;
protected File outputDirectory; protected File outputDirectory;
@ -62,6 +62,11 @@ public abstract class ZSourceFileReaderAbstract {
protected BlockUmlBuilder builder; protected BlockUmlBuilder builder;
protected FileFormatOption fileFormatOption; protected FileFormatOption fileFormatOption;
private boolean checkMetadata;
public void setCheckMetadata(boolean checkMetadata) {
this.checkMetadata = checkMetadata;
}
public boolean hasError() { public boolean hasError() {
for (final BlockUml b : builder.getBlockUmls()) { for (final BlockUml b : builder.getBlockUmls()) {
@ -97,8 +102,8 @@ public abstract class ZSourceFileReaderAbstract {
return newName.endsWith("/") || newName.endsWith("\\"); return newName.endsWith("/") || newName.endsWith("\\");
} }
protected List<GeneratedImage> getCrashedImage(BlockUml blockUml, Throwable t, File outputFile) throws IOException { private List<GeneratedImage> getCrashedImage(BlockUml blockUml, Throwable t, File outputFile) throws IOException {
final GeneratedImage image = new GeneratedImageImpl(outputFile, "Crash Error", blockUml); final GeneratedImage image = new GeneratedImageImpl(outputFile, "Crash Error", blockUml, 503);
OutputStream os = null; OutputStream os = null;
try { try {
os = new BufferedOutputStream(new FileOutputStream(outputFile)); os = new BufferedOutputStream(new FileOutputStream(outputFile));
@ -145,7 +150,7 @@ public abstract class ZSourceFileReaderAbstract {
} }
OptionFlags.getInstance().logData(file, system); OptionFlags.getInstance().logData(file, system);
final List<FileImageData> exportDiagrams = PSystemUtils.exportDiagrams(system, suggested, fileFormatOption); final List<FileImageData> exportDiagrams = PSystemUtils.exportDiagrams(system, suggested, fileFormatOption, checkMetadata);
if (exportDiagrams.size() > 1) { if (exportDiagrams.size() > 1) {
cpt += exportDiagrams.size() - 1; cpt += exportDiagrams.size() - 1;
} }
@ -154,7 +159,7 @@ public abstract class ZSourceFileReaderAbstract {
final String desc = "[" + file.getName() + "] " + system.getDescription(); final String desc = "[" + file.getName() + "] " + system.getDescription();
final File f = fdata.getFile(); final File f = fdata.getFile();
exportWarnOrErrIfWord(f, system); exportWarnOrErrIfWord(f, system);
final GeneratedImage generatedImage = new GeneratedImageImpl(f, desc, blockUml); final GeneratedImage generatedImage = new GeneratedImageImpl(f, desc, blockUml, fdata.getImageData().getStatus());
result.add(generatedImage); result.add(generatedImage);
} }

View File

@ -238,7 +238,7 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Ann
e.printStackTrace(); e.printStackTrace();
exportDiagramError(os, e, fileFormatOption, seed, null); exportDiagramError(os, e, fileFormatOption, seed, null);
} }
return new ImageDataSimple(); return ImageDataSimple.error();
} }
private void exportDiagramError(OutputStream os, Throwable exception, FileFormatOption fileFormat, long seed, private void exportDiagramError(OutputStream os, Throwable exception, FileFormatOption fileFormat, long seed,

View File

@ -1,162 +0,0 @@
/* ========================================================================
* 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;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import net.sourceforge.plantuml.preproc.Defines;
public class ZSourceFileReader extends ZSourceFileReaderAbstract implements ISourceFileReader {
public ZSourceFileReader(File file) throws IOException {
this(file, file.getAbsoluteFile().getParentFile());
}
public ZSourceFileReader(File file, File outputDirectory, String charset) throws IOException {
this(Defines.createWithFileName(file), file, outputDirectory, Collections.<String> emptyList(), charset,
new FileFormatOption(FileFormat.PNG));
}
public ZSourceFileReader(final File file, File outputDirectory) throws IOException {
this(Defines.createWithFileName(file), file, outputDirectory, Collections.<String> emptyList(), null,
new FileFormatOption(FileFormat.PNG));
}
public ZSourceFileReader(final File file, File outputDirectory, FileFormatOption fileFormatOption)
throws IOException {
this(Defines.createWithFileName(file), file, outputDirectory, Collections.<String> emptyList(), null,
fileFormatOption);
}
public ZSourceFileReader(Defines defines, final File file, File outputDirectory, List<String> config,
String charset, FileFormatOption fileFormatOption) throws IOException {
this.file = file;
this.fileFormatOption = fileFormatOption;
if (file.exists() == false) {
throw new IllegalArgumentException();
}
FileSystem.getInstance().setCurrentDir(file.getAbsoluteFile().getParentFile());
if (outputDirectory == null) {
outputDirectory = file.getAbsoluteFile().getParentFile();
} else if (outputDirectory.isAbsolute() == false) {
outputDirectory = FileSystem.getInstance().getFile(outputDirectory.getPath());
}
if (outputDirectory.exists() == false) {
outputDirectory.mkdirs();
}
this.outputDirectory = outputDirectory;
builder = new BlockUmlBuilder(config, charset, defines, getReader(charset), file.getAbsoluteFile()
.getParentFile(), file.getAbsolutePath());
}
private File getDirIfDirectory(String newName) {
Log.info("Checking=" + newName);
if (endsWithSlashOrAntislash(newName)) {
Log.info("It ends with / so it looks like a directory");
newName = newName.substring(0, newName.length() - 1);
File f = new File(newName);
Log.info("f=" + f);
if (f.isAbsolute() == false) {
Log.info("It's relative, so let's change it");
f = new File(outputDirectory, newName);
Log.info("f=" + f);
}
if (f.exists() == false) {
Log.info("It does not exist: let's create it");
try {
f.mkdirs();
} catch (Exception e) {
Log.info("Error " + e);
}
if (f.exists() && f.isDirectory()) {
Log.info("Creation ok");
return f;
}
Log.info("We cannot create it");
} else if (f.isDirectory() == false) {
Log.info("It exists, but is not a directory: we ignore it");
return null;
}
return f;
}
File f = new File(newName);
Log.info("f=" + f);
if (f.isAbsolute() == false) {
Log.info("Relative, so let's change it");
f = new File(outputDirectory, newName);
Log.info("f=" + f);
}
if (f.exists() && f.isDirectory()) {
Log.info("It's an existing directory");
return f;
}
Log.info("It's not a directory");
return null;
}
@Override
protected SuggestedFile getSuggestedFile(BlockUml blockUml) {
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 = SuggestedFile.fromOutputFile(new File(outputDirectory, newName),
fileFormatOption.getFileFormat(), 0);
} else {
Log.info("We are going to create files in directory " + dir);
suggested = SuggestedFile.fromOutputFile(new File(dir, file.getName()),
fileFormatOption.getFileFormat(), 0);
}
Log.info("We are going to put data in " + suggested);
}
if (suggested == null) {
suggested = SuggestedFile.fromOutputFile(new File(outputDirectory, file.getName()),
fileFormatOption.getFileFormat(), cpt++);
}
suggested.getParentFile().mkdirs();
return suggested;
}
}

View File

@ -1,66 +0,0 @@
/* ========================================================================
* 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;
import java.io.IOException;
import java.util.List;
import net.sourceforge.plantuml.preproc.Defines;
public class ZSourceFileReader2 extends ZSourceFileReaderAbstract implements ISourceFileReader {
public ZSourceFileReader2(Defines defines, final File file, File outputFile, List<String> config, String charset,
FileFormatOption fileFormatOption) throws IOException {
this.file = file;
this.fileFormatOption = fileFormatOption;
this.outputFile = outputFile;
if (file.exists() == false) {
throw new IllegalArgumentException();
}
FileSystem.getInstance().setCurrentDir(file.getAbsoluteFile().getParentFile());
builder = new BlockUmlBuilder(config, charset, defines, getReader(charset), file.getAbsoluteFile()
.getParentFile(), file.getAbsolutePath());
}
@Override
protected SuggestedFile getSuggestedFile(BlockUml blockUml) {
final SuggestedFile suggested = SuggestedFile.fromOutputFile(outputFile, fileFormatOption.getFileFormat());
return suggested;
}
}

View File

@ -63,24 +63,27 @@ public class CommandPartition3 extends SingleLineCommand2<ActivityDiagram3> {
new RegexLeaf("[%s]+"), // new RegexLeaf("[%s]+"), //
new RegexOptional(// new RegexOptional(//
new RegexConcat( // new RegexConcat( //
color().getRegex(),// color("BACK1").getRegex(),//
new RegexLeaf("[%s]+"))), // new RegexLeaf("[%s]+"))), //
new RegexLeaf("TITLECOLOR", "(?:(#\\w+)[%s]+)?"), //
new RegexLeaf("NAME", "([%g][^%g]+[%g]|\\S+)"), // new RegexLeaf("NAME", "([%g][^%g]+[%g]|\\S+)"), //
new RegexOptional(//
new RegexConcat( //
new RegexLeaf("[%s]+"), //
color("BACK2").getRegex())), //
new RegexLeaf("[%s]*\\{?$")); new RegexLeaf("[%s]*\\{?$"));
} }
private static ColorParser color() { private static ColorParser color(String id) {
return ColorParser.simpleColor(ColorType.BACK); return ColorParser.simpleColor(ColorType.BACK, id);
} }
@Override @Override
protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) { protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
final String partitionTitle = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("NAME", 0)); final String partitionTitle = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("NAME", 0));
final HtmlColor titleColor = diagram.getSkinParam().getIHtmlColorSet()
.getColorIfValid(arg.get("TITLECOLOR", 0));
final Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet()); final String b1 = arg.get("BACK1", 0);
final Colors colors = color(b1 == null ? "BACK2" : "BACK1").getColor(arg,
diagram.getSkinParam().getIHtmlColorSet());
final HtmlColor backColorInSkinparam = diagram.getSkinParam().getHtmlColor(ColorParam.partitionBackground, final HtmlColor backColorInSkinparam = diagram.getSkinParam().getHtmlColor(ColorParam.partitionBackground,
null, false); null, false);
@ -89,9 +92,10 @@ public class CommandPartition3 extends SingleLineCommand2<ActivityDiagram3> {
backColor = colors.getColor(ColorType.BACK); backColor = colors.getColor(ColorType.BACK);
} else { } else {
backColor = backColorInSkinparam; backColor = backColorInSkinparam;
} }
final HtmlColor titleColor = colors.getColor(ColorType.HEADER);
// Warning : titleColor unused in FTileGroupW
HtmlColor borderColor = diagram.getSkinParam().getHtmlColor(ColorParam.partitionBorder, null, false); HtmlColor borderColor = diagram.getSkinParam().getHtmlColor(ColorParam.partitionBorder, null, false);
if (borderColor == null) { if (borderColor == null) {
borderColor = HtmlColorUtils.BLACK; borderColor = HtmlColorUtils.BLACK;

View File

@ -125,7 +125,7 @@ class FtileRepeat extends AbstractFtile {
final Ftile diamond1; final Ftile diamond1;
if (backStart == null) { if (backStart == null) {
diamond1 = new FtileDiamond(repeat.skinParam(), backColor, borderColor, swimlane); diamond1 = new FtileDiamond(repeat.skinParam(), backColor, borderColor, repeat.getSwimlaneIn());
} else { } else {
diamond1 = backStart; diamond1 = backStart;
} }

View File

@ -33,24 +33,41 @@
* *
* *
*/ */
package net.sourceforge.plantuml.project3; package net.sourceforge.plantuml.api;
public class Solver2 { import java.awt.geom.Dimension2D;
public Instant solveEnd(Instant start, int fullLoad, LoadPlanable plan) { import net.sourceforge.plantuml.core.ImageData;
while (fullLoad > 0) {
fullLoad -= plan.getLoadAt(start); public abstract class ImageDataAbstract implements ImageData {
start = start.increment();
} private final int width;
return start; private final int height;
private int status;
public ImageDataAbstract(int width, int height) {
this.width = width;
this.height = height;
} }
public Instant solveStart(Instant end, int fullLoad, LoadPlanable plan) { public ImageDataAbstract(Dimension2D dim) {
while (fullLoad > 0) { this((int) dim.getWidth(), (int) dim.getHeight());
fullLoad -= plan.getLoadAt(end);
end = end.decrement();
} }
return end;
public final int getWidth() {
return width;
}
public final int getHeight() {
return height;
}
public final int getStatus() {
return status;
}
public final void setStatus(int status) {
this.status = status;
} }
} }

View File

@ -38,35 +38,18 @@ package net.sourceforge.plantuml.api;
import java.awt.geom.Dimension2D; import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.CMapData; import net.sourceforge.plantuml.CMapData;
import net.sourceforge.plantuml.core.ImageData;
public class ImageDataComplex implements ImageData { public class ImageDataComplex extends ImageDataAbstract {
private final Dimension2D info;
private final CMapData cmap; private final CMapData cmap;
private final String warningOrError; private final String warningOrError;
// public ImageDataComplex(Dimension2D info, CMapData cmap) {
// this(info, cmap, null);
// }
public ImageDataComplex(Dimension2D info, CMapData cmap, String warningOrError) { public ImageDataComplex(Dimension2D info, CMapData cmap, String warningOrError) {
if (info==null) { super(info);
throw new IllegalArgumentException();
}
this.info = info;
this.cmap = cmap; this.cmap = cmap;
this.warningOrError = warningOrError; this.warningOrError = warningOrError;
} }
public int getWidth() {
return (int) info.getWidth();
}
public int getHeight() {
return (int) info.getHeight();
}
public boolean containsCMapData() { public boolean containsCMapData() {
return cmap != null && cmap.containsData(); return cmap != null && cmap.containsData();
} }

View File

@ -39,30 +39,18 @@ import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.ImageData;
public class ImageDataSimple implements ImageData { public class ImageDataSimple extends ImageDataAbstract {
private final int width;
private final int height;
public ImageDataSimple(int width, int height) { public ImageDataSimple(int width, int height) {
this.width = width; super(width, height);
this.height = height;
}
public ImageDataSimple() {
this(0, 0);
} }
public ImageDataSimple(Dimension2D dim) { public ImageDataSimple(Dimension2D dim) {
this((int) dim.getWidth(), (int) dim.getHeight()); super(dim);
} }
public int getWidth() { private ImageDataSimple() {
return width; this(0, 0);
}
public int getHeight() {
return height;
} }
public boolean containsCMapData() { public boolean containsCMapData() {
@ -77,4 +65,14 @@ public class ImageDataSimple implements ImageData {
return null; return null;
} }
public static ImageData error() {
final ImageDataSimple result = new ImageDataSimple();
result.setStatus(503);
return result;
}
public static ImageData ok() {
return new ImageDataSimple();
}
} }

View File

@ -0,0 +1,147 @@
/* ========================================================================
* 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.code;
public class AsciiEncoderBase64 implements URLEncoder {
final static private char encode6bit[] = new char[64];
final static private byte decode6bit[] = new byte[128];
static {
for (byte b = 0; b < 64; b++) {
encode6bit[b] = encode6bit(b);
decode6bit[encode6bit[b]] = b;
}
}
public String encode(byte data[]) {
if (data == null) {
return "";
}
final StringBuilder result = new StringBuilder((data.length * 4 + 2) / 3);
for (int i = 0; i < data.length; i += 3) {
append3bytes(result, data[i] & 0xFF, i + 1 < data.length ? data[i + 1] & 0xFF : 0,
i + 2 < data.length ? data[i + 2] & 0xFF : 0);
}
return result.toString();
}
public byte[] decode(String s) {
// if (s.length() % 4 != 0) {
// throw new IllegalArgumentException("Cannot decode " + s);
// }
final byte data[] = new byte[computeSize(s.length())];
int pos = 0;
for (int i = 0; i < s.length(); i += 4) {
decode3bytes(data, pos, scharAt(s, i), scharAt(s, i + 1), scharAt(s, i + 2), scharAt(s, i + 3));
pos += 3;
}
return data;
}
private int computeSize(int length) {
// while (length % 4 != 0) {
// length++;
// }
final int r = length % 4;
if (r != 0) {
length += 4 - r;
}
// System.err.println("length=" + length);
// System.err.println("length1=" + (length % 4));
// length += length % 4;
// System.err.println("length2=" + length);
assert length % 4 == 0 : "length=" + length;
return (length * 3 + 3) / 4;
}
private char scharAt(String s, int i) {
if (i >= s.length()) {
return 'A';
}
return s.charAt(i);
}
public static int decode6bit(char c) {
return decode6bit[c];
}
public static char encode6bit(byte b) {
assert b >= 0 && b < 64;
if (b < 26) {
return (char) ('A' + b);
}
b -= 26;
if (b < 26) {
return (char) ('a' + b);
}
b -= 26;
if (b < 10) {
return (char) ('0' + b);
}
b -= 10;
if (b == 0) {
return '-';
}
if (b == 1) {
return '_';
}
assert false;
return '?';
}
private void append3bytes(StringBuilder sb, int b1, int b2, int b3) {
final int c1 = b1 >> 2;
final int c2 = ((b1 & 0x3) << 4) | (b2 >> 4);
final int c3 = ((b2 & 0xF) << 2) | (b3 >> 6);
final int c4 = b3 & 0x3F;
sb.append(encode6bit[c1 & 0x3F]);
sb.append(encode6bit[c2 & 0x3F]);
sb.append(encode6bit[c3 & 0x3F]);
sb.append(encode6bit[c4 & 0x3F]);
}
private void decode3bytes(byte r[], int pos, char cc1, char cc2, char cc3, char cc4) {
final int c1 = decode6bit[cc1];
final int c2 = decode6bit[cc2];
final int c3 = decode6bit[cc3];
final int c4 = decode6bit[cc4];
r[pos] = (byte) ((c1 << 2) | (c2 >> 4));
r[pos + 1] = (byte) (((c2 & 0x0F) << 4) | (c3 >> 2));
r[pos + 2] = (byte) (((c3 & 0x3) << 6) | c4);
}
}

View File

@ -96,6 +96,9 @@ public class CompressionZlib implements Compression {
} }
private byte[] tryDecompress(byte[] in, final int len) throws IOException { private byte[] tryDecompress(byte[] in, final int len) throws IOException {
if (len > 200000) {
throw new IOException("OutOfMemory");
}
// Decompress the bytes // Decompress the bytes
final byte[] tmp = new byte[len]; final byte[] tmp = new byte[len];
final Inflater decompresser = new Inflater(true); final Inflater decompresser = new Inflater(true);

View File

@ -43,11 +43,11 @@ public class TranscoderImpl implements Transcoder {
private final URLEncoder urlEncoder; private final URLEncoder urlEncoder;
private final StringCompressor stringCompressor; private final StringCompressor stringCompressor;
public TranscoderImpl() { private TranscoderImpl() {
this(new AsciiEncoder(), new StringCompressorNone(), new CompressionHuffman()); this(new AsciiEncoder(), new StringCompressorNone(), new CompressionHuffman());
} }
public TranscoderImpl(Compression compression) { private TranscoderImpl(Compression compression) {
this(new AsciiEncoder(), new StringCompressorNone(), compression); this(new AsciiEncoder(), new StringCompressorNone(), compression);
} }

View File

@ -40,12 +40,16 @@ import java.io.IOException;
public class TranscoderSmart implements Transcoder { public class TranscoderSmart implements Transcoder {
private final Transcoder oldOne = new TranscoderImpl(new AsciiEncoder(), new CompressionHuffman()); private final Transcoder oldOne = new TranscoderImpl(new AsciiEncoder(), new CompressionHuffman());
private final Transcoder zlibBase64 = new TranscoderImpl(new AsciiEncoderBase64(), new CompressionZlib());
private final Transcoder zlib = new TranscoderImpl(new AsciiEncoder(), new CompressionZlib()); private final Transcoder zlib = new TranscoderImpl(new AsciiEncoder(), new CompressionZlib());
private final Transcoder brotli = new TranscoderImpl(new AsciiEncoder(), new CompressionBrotli()); private final Transcoder brotliBase64 = new TranscoderImpl(new AsciiEncoderBase64(), new CompressionBrotli());
public String decode(String code) throws IOException { public String decode(String code) throws IOException {
if (code.startsWith("0")) { if (code.startsWith("0")) {
return brotli.decode(code.substring(1)); return zlibBase64.decode(code.substring(1));
}
if (code.startsWith("1")) {
return brotliBase64.decode(code.substring(1));
} }
try { try {
return zlib.decode(code); return zlib.decode(code);

View File

@ -49,8 +49,15 @@ public class CommandScale extends SingleLineCommand<AbstractPSystem> {
@Override @Override
protected CommandExecutionResult executeArg(AbstractPSystem diagram, List<String> arg) { protected CommandExecutionResult executeArg(AbstractPSystem diagram, List<String> arg) {
double scale = Double.parseDouble(arg.get(0)); double scale = Double.parseDouble(arg.get(0));
if (scale == 0) {
return CommandExecutionResult.error("Scale cannot be zero");
}
if (arg.get(1) != null) { if (arg.get(1) != null) {
scale /= Double.parseDouble(arg.get(1)); final double div = Double.parseDouble(arg.get(1));
if (div == 0) {
return CommandExecutionResult.error("Scale cannot be zero");
}
scale /= div;
} }
diagram.setScale(new ScaleSimple(scale)); diagram.setScale(new ScaleSimple(scale));
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();

View File

@ -85,5 +85,7 @@ public interface ImageData {
public String getWarningOrError(); public String getWarningOrError();
public int getStatus();
} }

View File

@ -289,7 +289,6 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
this.horizontalPages = horizontalPages; this.horizontalPages = horizontalPages;
} }
final public int getVerticalPages() { final public int getVerticalPages() {
return verticalPages; return verticalPages;
} }
@ -303,8 +302,6 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
return this.horizontalPages * this.verticalPages; return this.horizontalPages * this.verticalPages;
} }
// final public List<File> createPng2(File pngFile) throws IOException, // final public List<File> createPng2(File pngFile) throws IOException,
// InterruptedException { // InterruptedException {
// final CucaDiagramPngMaker3 maker = new CucaDiagramPngMaker3(this); // final CucaDiagramPngMaker3 maker = new CucaDiagramPngMaker3(this);
@ -357,17 +354,17 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
} catch (Throwable t) { } catch (Throwable t) {
t.printStackTrace(new PrintStream(os)); t.printStackTrace(new PrintStream(os));
} }
return new ImageDataSimple(); return ImageDataSimple.ok();
} }
if (fileFormat.name().startsWith("XMI")) { if (fileFormat.name().startsWith("XMI")) {
createFilesXmi(os, fileFormat); createFilesXmi(os, fileFormat);
return new ImageDataSimple(); return ImageDataSimple.ok();
} }
if (fileFormat == FileFormat.SCXML) { if (fileFormat == FileFormat.SCXML) {
createFilesScxml(os); createFilesScxml(os);
return new ImageDataSimple(); return ImageDataSimple.ok();
} }
if (getUmlDiagramType() == UmlDiagramType.COMPOSITE) { if (getUmlDiagramType() == UmlDiagramType.COMPOSITE) {
@ -382,7 +379,7 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
final ImageData result = maker.createFile(os, getDotStrings(), fileFormatOption); final ImageData result = maker.createFile(os, getDotStrings(), fileFormatOption);
if (result == null) { if (result == null) {
return new ImageDataSimple(); return ImageDataSimple.error();
} }
this.warningOrError = result.getWarningOrError(); this.warningOrError = result.getWarningOrError();
return result; return result;

View File

@ -119,9 +119,9 @@ public class Link implements Hideable, Removeable {
this.type = type; this.type = type;
if (Display.isNull(label)) { if (Display.isNull(label)) {
this.label = Display.NULL; this.label = Display.NULL;
// } else if (doWeHaveToRemoveUrlAtStart(label)) { // } else if (doWeHaveToRemoveUrlAtStart(label)) {
// this.url = label.initUrl(); // this.url = label.initUrl();
// this.label = label.removeHeadingUrl(url).manageGuillemet(); // this.label = label.removeHeadingUrl(url).manageGuillemet();
} else { } else {
this.label = label.manageGuillemet(); this.label = label.manageGuillemet();
} }
@ -142,16 +142,16 @@ public class Link implements Hideable, Removeable {
// } // }
} }
// private static boolean doWeHaveToRemoveUrlAtStart(Display label) { // private static boolean doWeHaveToRemoveUrlAtStart(Display label) {
// if (label.size() == 0) { // if (label.size() == 0) {
// return false; // return false;
// } // }
// final String s = label.get(0).toString(); // final String s = label.get(0).toString();
// if (s.matches("^\\[\\[\\S+\\]\\].+$")) { // if (s.matches("^\\[\\[\\S+\\]\\].+$")) {
// return true; // return true;
// } // }
// return false; // return false;
// } // }
public Link getInv() { public Link getInv() {
// if (getLength() == 1) { // if (getLength() == 1) {
@ -392,6 +392,20 @@ public class Link implements Hideable, Removeable {
return false; return false;
} }
// public boolean containsWithDecors(ILeaf leaf) {
// LinkType linkType = this.getType();
// if (isInverted()) {
// linkType = linkType.getInversed();
// }
// if (getEntity2() == leaf && linkType.getDecor1() != LinkDecor.NONE) {
// return true;
// }
// if (getEntity1() == leaf && linkType.getDecor2() != LinkDecor.NONE) {
// return true;
// }
// return false;
// }
public IEntity getOther(IEntity entity) { public IEntity getOther(IEntity entity) {
if (getEntity1() == entity) { if (getEntity1() == entity) {
return getEntity2(); return getEntity2();

View File

@ -40,10 +40,10 @@ public interface GraphvizVersion {
public boolean useProtectionWhenThereALinkFromOrToGroup(); public boolean useProtectionWhenThereALinkFromOrToGroup();
public boolean modeSafe(); public boolean useXLabelInsteadOfLabel();
public boolean isVizjs(); public boolean isVizjs();
// COMMON, V2_34_0 public boolean ignoreHorizontalLinks();
} }

View File

@ -53,13 +53,17 @@ public class GraphvizVersionFinder {
return true; return true;
} }
public boolean modeSafe() { public boolean useXLabelInsteadOfLabel() {
return false; return false;
} }
public boolean isVizjs() { public boolean isVizjs() {
return false; return false;
} }
public boolean ignoreHorizontalLinks() {
return false;
}
}; };
public GraphvizVersionFinder(File dotExe) { public GraphvizVersionFinder(File dotExe) {
@ -89,7 +93,7 @@ public class GraphvizVersionFinder {
return true; return true;
} }
public boolean modeSafe() { public boolean useXLabelInsteadOfLabel() {
return false; return false;
} }
@ -97,6 +101,13 @@ public class GraphvizVersionFinder {
return false; return false;
} }
public boolean ignoreHorizontalLinks() {
if (v == 230) {
return true;
}
return false;
}
}; };
} }

View File

@ -109,9 +109,9 @@ public class CommandCreateElementFull extends SingleLineCommand2<DescriptionDiag
private static final String CODE_CORE = "[\\p{L}0-9_.]+|\\(\\)[%s]*[\\p{L}0-9_.]+|\\(\\)[%s]*[%g][^%g]+[%g]|:[^:]+:|\\([^()]+\\)|\\[[^\\[\\]]+\\]"; private static final String CODE_CORE = "[\\p{L}0-9_.]+|\\(\\)[%s]*[\\p{L}0-9_.]+|\\(\\)[%s]*[%g][^%g]+[%g]|:[^:]+:|\\([^()]+\\)|\\[[^\\[\\]]+\\]";
public static final String CODE = "(" + CODE_CORE + ")"; public static final String CODE = "(" + CODE_CORE + ")";
public static final String CODE_WITH_QUOTE = "(" + CODE_CORE + "|[%g][^%g]+[%g])"; public static final String CODE_WITH_QUOTE = "(" + CODE_CORE + "|[%g].+?[%g])";
private static final String DISPLAY_CORE = "[%g][^%g]+[%g]|:[^:]+:|\\([^()]+\\)|\\[[^\\[\\]]+\\]"; private static final String DISPLAY_CORE = "[%g].+?[%g]|:[^:]+:|\\([^()]+\\)|\\[[^\\[\\]]+\\]";
public static final String DISPLAY = "(" + DISPLAY_CORE + ")"; public static final String DISPLAY = "(" + DISPLAY_CORE + ")";
public static final String DISPLAY_WITHOUT_QUOTE = "(" + DISPLAY_CORE + "|[\\p{L}0-9_.]+)"; public static final String DISPLAY_WITHOUT_QUOTE = "(" + DISPLAY_CORE + "|[\\p{L}0-9_.]+)";

View File

@ -72,7 +72,7 @@ public class CommandPackageWithUSymbol extends SingleLineCommand2<AbstractEntity
new RegexLeaf("[%s]+"), // new RegexLeaf("[%s]+"), //
new RegexOr(// new RegexOr(//
new RegexConcat( // new RegexConcat( //
new RegexLeaf("DISPLAY1", "([%g][^%g]+[%g])"), // new RegexLeaf("DISPLAY1", "([%g].+?[%g])"), //
new RegexLeaf("STEREOTYPE1", "(?:[%s]+(\\<\\<.+\\>\\>))?"), // new RegexLeaf("STEREOTYPE1", "(?:[%s]+(\\<\\<.+\\>\\>))?"), //
new RegexLeaf("[%s]*as[%s]+"), // new RegexLeaf("[%s]*as[%s]+"), //
new RegexLeaf("CODE1", "([^#%s{}]+)") // new RegexLeaf("CODE1", "([^#%s{}]+)") //
@ -81,7 +81,7 @@ public class CommandPackageWithUSymbol extends SingleLineCommand2<AbstractEntity
new RegexLeaf("CODE2", "([^#%s{}%g]+)"), // new RegexLeaf("CODE2", "([^#%s{}%g]+)"), //
new RegexLeaf("STEREOTYPE2", "(?:[%s]+(\\<\\<.+\\>\\>))?"), // new RegexLeaf("STEREOTYPE2", "(?:[%s]+(\\<\\<.+\\>\\>))?"), //
new RegexLeaf("[%s]*as[%s]+"), // new RegexLeaf("[%s]*as[%s]+"), //
new RegexLeaf("DISPLAY2", "([%g][^%g]+[%g])") // new RegexLeaf("DISPLAY2", "([%g].+?[%g])") //
), // ), //
new RegexConcat( // new RegexConcat( //
new RegexLeaf("DISPLAY3", "([^#%s{}%g]+)"), // new RegexLeaf("DISPLAY3", "([^#%s{}%g]+)"), //

View File

@ -75,21 +75,22 @@ public class PSystemDot extends AbstractPSystem {
if (graphviz.getExeState() != ExeState.OK) { if (graphviz.getExeState() != ExeState.OK) {
final TextBlock result = GraphicStrings.createForError( final TextBlock result = GraphicStrings.createForError(
Arrays.asList("There is an issue with your Dot/Graphviz installation"), false); Arrays.asList("There is an issue with your Dot/Graphviz installation"), false);
UGraphicUtils.writeImage(os, null, fileFormat, seed(), new ColorMapperIdentity(), UGraphicUtils.writeImage(os, null, fileFormat, seed(), new ColorMapperIdentity(), HtmlColorUtils.WHITE,
HtmlColorUtils.WHITE, result); result);
return new ImageDataSimple(); return ImageDataSimple.error();
} }
final CounterOutputStream counter = new CounterOutputStream(os); final CounterOutputStream counter = new CounterOutputStream(os);
final ProcessState state = graphviz.createFile3(counter); final ProcessState state = graphviz.createFile3(counter);
if (state.differs(ProcessState.TERMINATED_OK())) { // if (state.differs(ProcessState.TERMINATED_OK())) {
throw new IllegalStateException("Timeout1 " + state); // throw new IllegalStateException("Timeout1 " + state);
} // }
if (counter.getLength() == 0) { if (counter.getLength() == 0 || state.differs(ProcessState.TERMINATED_OK())) {
final TextBlock result = GraphicStrings.createForError(Arrays.asList("Graphivz has crashed"), false); final TextBlock result = GraphicStrings.createForError(Arrays.asList("Graphivz has crashed"), false);
UGraphicUtils.writeImage(os, null, fileFormat, seed(), new ColorMapperIdentity(), UGraphicUtils.writeImage(os, null, fileFormat, seed(), new ColorMapperIdentity(), HtmlColorUtils.WHITE,
HtmlColorUtils.WHITE, result); result);
return ImageDataSimple.error();
} }
return new ImageDataSimple(); return ImageDataSimple.ok();
} }
} }

View File

@ -69,8 +69,8 @@ public class PSystemDitaa extends AbstractPSystem {
} }
PSystemDitaa add(String line) { PSystemDitaa add(String line) {
return new PSystemDitaa(data + line + BackSlash.NEWLINE, processingOptions.performSeparationOfCommonEdges(), dropShadows, return new PSystemDitaa(data + line + BackSlash.NEWLINE, processingOptions.performSeparationOfCommonEdges(),
scale); dropShadows, scale);
} }
public DiagramDescription getDescription() { public DiagramDescription getDescription() {
@ -82,7 +82,7 @@ public class PSystemDitaa extends AbstractPSystem {
throws IOException { throws IOException {
if (fileFormat.getFileFormat() == FileFormat.ATXT) { if (fileFormat.getFileFormat() == FileFormat.ATXT) {
os.write(getSource().getPlainString().getBytes()); os.write(getSource().getPlainString().getBytes());
return new ImageDataSimple(); return ImageDataSimple.ok();
} }
// ditaa can only export png so file format is mostly ignored // ditaa can only export png so file format is mostly ignored
final ConversionOptions options = new ConversionOptions(); final ConversionOptions options = new ConversionOptions();

View File

@ -46,6 +46,7 @@ import java.util.StringTokenizer;
import net.sourceforge.plantuml.AbstractPSystem; import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.BackSlash; import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.code.AsciiEncoder;
import net.sourceforge.plantuml.code.CompressionBrotli; import net.sourceforge.plantuml.code.CompressionBrotli;
import net.sourceforge.plantuml.code.Transcoder; import net.sourceforge.plantuml.code.Transcoder;
import net.sourceforge.plantuml.code.TranscoderImpl; import net.sourceforge.plantuml.code.TranscoderImpl;
@ -126,7 +127,7 @@ public class PSystemDonors extends AbstractPSystem {
private List<String> getDonors() throws IOException { private List<String> getDonors() throws IOException {
final List<String> lines = new ArrayList<String>(); final List<String> lines = new ArrayList<String>();
final Transcoder t = new TranscoderImpl(new CompressionBrotli()); final Transcoder t = new TranscoderImpl(new AsciiEncoder(), new CompressionBrotli());
final String s = t.decode(DONORS).replace('*', '.'); final String s = t.decode(DONORS).replace('*', '.');
final StringTokenizer st = new StringTokenizer(s, BackSlash.NEWLINE); final StringTokenizer st = new StringTokenizer(s, BackSlash.NEWLINE);
while (st.hasMoreTokens()) { while (st.hasMoreTokens()) {

View File

@ -126,9 +126,9 @@ public class FlowDiagram extends UmlDiagram implements TextBlock {
@Override @Override
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException { throws IOException {
UGraphicUtils.writeImage(os, null, fileFormatOption, seed(), new ColorMapperIdentity(), UGraphicUtils.writeImage(os, null, fileFormatOption, seed(), new ColorMapperIdentity(), HtmlColorUtils.WHITE,
HtmlColorUtils.WHITE, this); this);
return new ImageDataSimple(); return ImageDataSimple.ok();
} }
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {

View File

@ -79,7 +79,7 @@ public class SkinParameter {
CornerParam.component); CornerParam.component);
public static final SkinParameter AGENT = new SkinParameter("AGENT", ColorParam.agentBackground, public static final SkinParameter AGENT = new SkinParameter("AGENT", ColorParam.agentBackground,
ColorParam.agentBorder, FontParam.AGENT, FontParam.AGENT_STEREOTYPE); ColorParam.agentBorder, FontParam.AGENT, FontParam.AGENT_STEREOTYPE, LineParam.agentBorder, CornerParam.agent);
public static final SkinParameter FOLDER = new SkinParameter("FOLDER", ColorParam.folderBackground, public static final SkinParameter FOLDER = new SkinParameter("FOLDER", ColorParam.folderBackground,
ColorParam.folderBorder, FontParam.FOLDER, FontParam.FOLDER_STEREOTYPE); ColorParam.folderBorder, FontParam.FOLDER, FontParam.FOLDER_STEREOTYPE);
@ -91,7 +91,8 @@ public class SkinParameter {
ColorParam.packageBorder, FontParam.FOLDER, FontParam.FOLDER_STEREOTYPE); ColorParam.packageBorder, FontParam.FOLDER, FontParam.FOLDER_STEREOTYPE);
public static final SkinParameter CARD = new SkinParameter("CARD", ColorParam.cardBackground, public static final SkinParameter CARD = new SkinParameter("CARD", ColorParam.cardBackground,
ColorParam.cardBorder, FontParam.CARD, FontParam.CARD_STEREOTYPE); ColorParam.cardBorder, FontParam.CARD, FontParam.CARD_STEREOTYPE, LineParam.cardBorder,
CornerParam.card);
public static final SkinParameter RECTANGLE = new SkinParameter("RECTANGLE", ColorParam.rectangleBackground, public static final SkinParameter RECTANGLE = new SkinParameter("RECTANGLE", ColorParam.rectangleBackground,
ColorParam.rectangleBorder, FontParam.RECTANGLE, FontParam.RECTANGLE_STEREOTYPE, LineParam.rectangleBorder, ColorParam.rectangleBorder, FontParam.RECTANGLE, FontParam.RECTANGLE_STEREOTYPE, LineParam.rectangleBorder,

View File

@ -449,7 +449,7 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker {
} catch (Throwable e) { } catch (Throwable e) {
UmlDiagram.exportDiagramError(os, e, fileFormatOption, diagram.seed(), diagram.getMetadata(), UmlDiagram.exportDiagramError(os, e, fileFormatOption, diagram.seed(), diagram.getMetadata(),
diagram.getFlashData(), getFailureText3(e)); diagram.getFlashData(), getFailureText3(e));
return new ImageDataSimple(); return ImageDataSimple.error();
} finally { } finally {
Z.close(); Z.close();
} }

View File

@ -85,7 +85,7 @@ public class PostItDiagram extends UmlDiagram {
final UGraphicEps eps = (UGraphicEps) ug; final UGraphicEps eps = (UGraphicEps) ug;
os.write(eps.getEPSCode().getBytes()); os.write(eps.getEPSCode().getBytes());
} }
return new ImageDataSimple(); return ImageDataSimple.ok();
} }
public DiagramDescription getDescription() { public DiagramDescription getDescription() {

View File

@ -82,8 +82,9 @@ public class PSystemProject extends AbstractPSystem {
final BufferedImage im = createImage(diagram); final BufferedImage im = createImage(diagram);
PngIO.write(im, os, fileFormatOption.isWithMetadata() ? getMetadata() : null, 96); PngIO.write(im, os, fileFormatOption.isWithMetadata() ? getMetadata() : null, 96);
} else if (fileFormat == FileFormat.SVG) { } else if (fileFormat == FileFormat.SVG) {
final UGraphicSvg svg = new UGraphicSvg(true, new Dimension2DDouble(0, 0), colorMapper, StringUtils.getAsHtml(background), false, 1.0, final UGraphicSvg svg = new UGraphicSvg(true, new Dimension2DDouble(0, 0), colorMapper,
fileFormatOption.getSvgLinkTarget(), fileFormatOption.getHoverColor(), seed()); StringUtils.getAsHtml(background), false, 1.0, fileFormatOption.getSvgLinkTarget(),
fileFormatOption.getHoverColor(), seed());
diagram.draw(svg, 0, 0); diagram.draw(svg, 0, 0);
svg.createXml(os, fileFormatOption.isWithMetadata() ? getMetadata() : null); svg.createXml(os, fileFormatOption.isWithMetadata() ? getMetadata() : null);
} else if (fileFormat == FileFormat.EPS) { } else if (fileFormat == FileFormat.EPS) {
@ -97,7 +98,7 @@ public class PSystemProject extends AbstractPSystem {
} else { } else {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
return new ImageDataSimple(); return ImageDataSimple.ok();
} }
private BufferedImage createImage(GanttDiagramUnused diagram) { private BufferedImage createImage(GanttDiagramUnused diagram) {

View File

@ -81,8 +81,9 @@ public class PSystemProject2 extends AbstractPSystem {
final BufferedImage im = createImage(diagram); final BufferedImage im = createImage(diagram);
PngIO.write(im, os, fileFormatOption.isWithMetadata() ? getMetadata() : null, 96); PngIO.write(im, os, fileFormatOption.isWithMetadata() ? getMetadata() : null, 96);
} else if (fileFormat == FileFormat.SVG) { } else if (fileFormat == FileFormat.SVG) {
final UGraphicSvg svg = new UGraphicSvg(true, new Dimension2DDouble(0, 0),colorMapper, StringUtils.getAsHtml(background), false, 1.0, final UGraphicSvg svg = new UGraphicSvg(true, new Dimension2DDouble(0, 0), colorMapper,
fileFormatOption.getSvgLinkTarget(), fileFormatOption.getHoverColor(), seed()); StringUtils.getAsHtml(background), false, 1.0, fileFormatOption.getSvgLinkTarget(),
fileFormatOption.getHoverColor(), seed());
diagram.draw(svg, 0, 0); diagram.draw(svg, 0, 0);
svg.createXml(os, fileFormatOption.isWithMetadata() ? getMetadata() : null); svg.createXml(os, fileFormatOption.isWithMetadata() ? getMetadata() : null);
} else if (fileFormat == FileFormat.EPS) { } else if (fileFormat == FileFormat.EPS) {
@ -96,7 +97,7 @@ public class PSystemProject2 extends AbstractPSystem {
} else { } else {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
return new ImageDataSimple(); return ImageDataSimple.ok();
} }
private BufferedImage createImage(GanttDiagram2 diagram) { private BufferedImage createImage(GanttDiagram2 diagram) {

View File

@ -51,7 +51,13 @@ public class Solver3 {
} }
public void setData(TaskAttribute attribute, Value value) { public void setData(TaskAttribute attribute, Value value) {
values.remove(attribute); final Value previous = values.remove(attribute);
if (previous != null && attribute == TaskAttribute.START) {
final Instant previousInstant = (Instant) previous;
if (previousInstant.compareTo((Instant) value) > 0) {
value = previous;
}
}
values.put(attribute, value); values.put(attribute, value);
if (values.size() > 2) { if (values.size() > 2) {
removeFirstElement(); removeFirstElement();

View File

@ -94,7 +94,7 @@ public class PSystemSalt extends AbstractPSystem {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
UmlDiagram.exportDiagramError(os, e, fileFormat, seed, getMetadata(), "none", new ArrayList<String>()); UmlDiagram.exportDiagramError(os, e, fileFormat, seed, getMetadata(), "none", new ArrayList<String>());
return new ImageDataSimple(); return ImageDataSimple.error();
} }
} }

View File

@ -46,12 +46,14 @@ class ArrowAndParticipant extends Arrow implements InGroupable {
private final Arrow arrow; private final Arrow arrow;
private final ParticipantBox participantBox; private final ParticipantBox participantBox;
private final double paddingParticipant;
public ArrowAndParticipant(StringBounder stringBounder, Arrow arrow, ParticipantBox participantBox, public ArrowAndParticipant(StringBounder stringBounder, Arrow arrow, ParticipantBox participantBox,
double paddingParticipant) { double paddingParticipant) {
super(arrow.getStartingY(), arrow.getSkin(), arrow.getArrowComponent(), arrow.getUrl()); super(arrow.getStartingY(), arrow.getSkin(), arrow.getArrowComponent(), arrow.getUrl());
this.arrow = arrow; this.arrow = arrow;
this.participantBox = participantBox; this.participantBox = participantBox;
this.paddingParticipant = paddingParticipant;
arrow.setPaddingArrowHead(participantBox.getPreferredWidth(stringBounder) / 2 - paddingParticipant); arrow.setPaddingArrowHead(participantBox.getPreferredWidth(stringBounder) / 2 - paddingParticipant);
} }
@ -95,7 +97,7 @@ class ArrowAndParticipant extends Arrow implements InGroupable {
arrow.drawInternalU(ug, maxX, context); arrow.drawInternalU(ug, maxX, context);
} else { } else {
final double boxWidth = participantBox.getPreferredWidth(ug.getStringBounder()); final double boxWidth = participantBox.getPreferredWidth(ug.getStringBounder());
arrow.drawInternalU(ug.apply(new UTranslate(boxWidth / 2, 0)), maxX, context); arrow.drawInternalU(ug.apply(new UTranslate(boxWidth / 2 - paddingParticipant, 0)), maxX, context);
} }
final double arrowHeight = arrow.getPreferredHeight(ug.getStringBounder()); final double arrowHeight = arrow.getPreferredHeight(ug.getStringBounder());

View File

@ -149,53 +149,53 @@ public class Rose implements Skin {
} }
if (type == ComponentType.BOUNDARY_HEAD) { if (type == ComponentType.BOUNDARY_HEAD) {
return new ComponentRoseBoundary(getSymbolContext(param, ColorParam.boundaryBorder), getUFont2(param, return new ComponentRoseBoundary(getSymbolContext(param, ColorParam.boundaryBorder), getUFont2(param,
FontParam.ACTOR), stringsToDisplay, true, param, newFontForStereotype, getFontColor(param, FontParam.BOUNDARY), stringsToDisplay, true, param, newFontForStereotype, getFontColor(param,
FontParam.SEQUENCE_STEREOTYPE)); FontParam.BOUNDARY_STEREOTYPE));
} }
if (type == ComponentType.BOUNDARY_TAIL) { if (type == ComponentType.BOUNDARY_TAIL) {
return new ComponentRoseBoundary(getSymbolContext(param, ColorParam.boundaryBorder), getUFont2(param, return new ComponentRoseBoundary(getSymbolContext(param, ColorParam.boundaryBorder), getUFont2(param,
FontParam.ACTOR), stringsToDisplay, false, param, newFontForStereotype, getFontColor(param, FontParam.BOUNDARY), stringsToDisplay, false, param, newFontForStereotype, getFontColor(param,
FontParam.SEQUENCE_STEREOTYPE)); FontParam.BOUNDARY_STEREOTYPE));
} }
if (type == ComponentType.CONTROL_HEAD) { if (type == ComponentType.CONTROL_HEAD) {
return new ComponentRoseControl(getSymbolContext(param, ColorParam.controlBorder), getUFont2(param, return new ComponentRoseControl(getSymbolContext(param, ColorParam.controlBorder), getUFont2(param,
FontParam.ACTOR), stringsToDisplay, true, param, newFontForStereotype, getFontColor(param, FontParam.CONTROL), stringsToDisplay, true, param, newFontForStereotype, getFontColor(param,
FontParam.SEQUENCE_STEREOTYPE)); FontParam.CONTROL_STEREOTYPE));
} }
if (type == ComponentType.CONTROL_TAIL) { if (type == ComponentType.CONTROL_TAIL) {
return new ComponentRoseControl(getSymbolContext(param, ColorParam.controlBorder), getUFont2(param, return new ComponentRoseControl(getSymbolContext(param, ColorParam.controlBorder), getUFont2(param,
FontParam.ACTOR), stringsToDisplay, false, param, newFontForStereotype, getFontColor(param, FontParam.CONTROL), stringsToDisplay, false, param, newFontForStereotype, getFontColor(param,
FontParam.SEQUENCE_STEREOTYPE)); FontParam.CONTROL_STEREOTYPE));
} }
if (type == ComponentType.ENTITY_HEAD) { if (type == ComponentType.ENTITY_HEAD) {
return new ComponentRoseEntity(getSymbolContext(param, ColorParam.entityBorder), getUFont2(param, return new ComponentRoseEntity(getSymbolContext(param, ColorParam.entityBorder), getUFont2(param,
FontParam.ACTOR), stringsToDisplay, true, param, newFontForStereotype, getFontColor(param, FontParam.ENTITY), stringsToDisplay, true, param, newFontForStereotype, getFontColor(param,
FontParam.SEQUENCE_STEREOTYPE)); FontParam.ENTITY_STEREOTYPE));
} }
if (type == ComponentType.ENTITY_TAIL) { if (type == ComponentType.ENTITY_TAIL) {
return new ComponentRoseEntity(getSymbolContext(param, ColorParam.entityBorder), getUFont2(param, return new ComponentRoseEntity(getSymbolContext(param, ColorParam.entityBorder), getUFont2(param,
FontParam.ACTOR), stringsToDisplay, false, param, newFontForStereotype, getFontColor(param, FontParam.ENTITY), stringsToDisplay, false, param, newFontForStereotype, getFontColor(param,
FontParam.SEQUENCE_STEREOTYPE)); FontParam.ENTITY_STEREOTYPE));
} }
if (type == ComponentType.QUEUE_HEAD) { if (type == ComponentType.QUEUE_HEAD) {
return new ComponentRoseQueue(getSymbolContext(param, ColorParam.entityBorder), getUFont2(param, return new ComponentRoseQueue(getSymbolContext(param, ColorParam.entityBorder), getUFont2(param,
FontParam.ACTOR), stringsToDisplay, true, param, newFontForStereotype, getFontColor(param, FontParam.QUEUE), stringsToDisplay, true, param, newFontForStereotype, getFontColor(param,
FontParam.SEQUENCE_STEREOTYPE)); FontParam.QUEUE_STEREOTYPE));
} }
if (type == ComponentType.QUEUE_TAIL) { if (type == ComponentType.QUEUE_TAIL) {
return new ComponentRoseQueue(getSymbolContext(param, ColorParam.entityBorder), getUFont2(param, return new ComponentRoseQueue(getSymbolContext(param, ColorParam.entityBorder), getUFont2(param,
FontParam.ACTOR), stringsToDisplay, false, param, newFontForStereotype, getFontColor(param, FontParam.QUEUE), stringsToDisplay, false, param, newFontForStereotype, getFontColor(param,
FontParam.SEQUENCE_STEREOTYPE)); FontParam.QUEUE_STEREOTYPE));
} }
if (type == ComponentType.DATABASE_HEAD) { if (type == ComponentType.DATABASE_HEAD) {
return new ComponentRoseDatabase(getSymbolContext(param, ColorParam.databaseBorder), getUFont2(param, return new ComponentRoseDatabase(getSymbolContext(param, ColorParam.databaseBorder), getUFont2(param,
FontParam.ACTOR), stringsToDisplay, true, param, newFontForStereotype, getFontColor(param, FontParam.DATABASE), stringsToDisplay, true, param, newFontForStereotype, getFontColor(param,
FontParam.SEQUENCE_STEREOTYPE)); FontParam.DATABASE_STEREOTYPE));
} }
if (type == ComponentType.DATABASE_TAIL) { if (type == ComponentType.DATABASE_TAIL) {
return new ComponentRoseDatabase(getSymbolContext(param, ColorParam.databaseBorder), getUFont2(param, return new ComponentRoseDatabase(getSymbolContext(param, ColorParam.databaseBorder), getUFont2(param,
FontParam.ACTOR), stringsToDisplay, false, param, newFontForStereotype, getFontColor(param, FontParam.DATABASE), stringsToDisplay, false, param, newFontForStereotype, getFontColor(param,
FontParam.SEQUENCE_STEREOTYPE)); FontParam.DATABASE_STEREOTYPE));
} }
if (type == ComponentType.NOTE) { if (type == ComponentType.NOTE) {
return new ComponentRoseNote(getSymbolContext(param, ColorParam.noteBorder), getUFont2(param, return new ComponentRoseNote(getSymbolContext(param, ColorParam.noteBorder), getUFont2(param,

View File

@ -582,7 +582,8 @@ public class Cluster implements Moveable {
added = true; added = true;
} }
if (skinParam.useRankSame() && dotMode != DotMode.NO_LEFT_RIGHT_AND_XLABEL) { if (skinParam.useRankSame() && dotMode != DotMode.NO_LEFT_RIGHT_AND_XLABEL
&& graphvizVersion.ignoreHorizontalLinks() == false) {
appendRankSame(sb, lines); appendRankSame(sb, lines);
} }

View File

@ -47,6 +47,7 @@ import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.NamedOutputStream; import net.sourceforge.plantuml.NamedOutputStream;
import net.sourceforge.plantuml.Scale; import net.sourceforge.plantuml.Scale;
import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.api.ImageDataAbstract;
import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.CucaDiagram; import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
@ -107,6 +108,7 @@ public final class CucaDiagramFileMakerSvek implements CucaDiagramFileMaker {
fileFormatOption.getDefaultStringBounder()); fileFormatOption.getDefaultStringBounder());
result = svek2.buildImage(basefile, diagram.getDotStringSkek()); result = svek2.buildImage(basefile, diagram.getDotStringSkek());
} }
final boolean isGraphvizCrash = result instanceof GraphvizCrash;
result = new AnnotatedWorker(diagram, diagram.getSkinParam()).addAdd(result); result = new AnnotatedWorker(diagram, diagram.getSkinParam()).addAdd(result);
final String widthwarning = diagram.getSkinParam().getValue("widthwarning"); final String widthwarning = diagram.getSkinParam().getValue("widthwarning");
@ -121,8 +123,11 @@ public final class CucaDiagramFileMakerSvek implements CucaDiagramFileMaker {
fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null, warningOrError, 0, 10, fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null, warningOrError, 0, 10,
diagram.getAnimation(), result.getBackcolor()); diagram.getAnimation(), result.getBackcolor());
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, diagram.seed(), os); final ImageData imageData = imageBuilder.writeImageTOBEMOVED(fileFormatOption, diagram.seed(), os);
if (isGraphvizCrash) {
((ImageDataAbstract) imageData).setStatus(503);
}
return imageData;
} }
private List<Link> getOrderedLinks() { private List<Link> getOrderedLinks() {

View File

@ -59,15 +59,15 @@ public class DecorateEntityImage extends AbstractTextBlock implements TextBlockB
private double deltaX; private double deltaX;
private double deltaY; private double deltaY;
public static DecorateEntityImage addTop(TextBlock original, TextBlock text, HorizontalAlignment horizontal) { public static TextBlock addTop(TextBlock original, TextBlock text, HorizontalAlignment horizontal) {
return new DecorateEntityImage(original, text, horizontal, null, null); return new DecorateEntityImage(original, text, horizontal, null, null);
} }
public static DecorateEntityImage addBottom(TextBlock original, TextBlock text, HorizontalAlignment horizontal) { public static TextBlock addBottom(TextBlock original, TextBlock text, HorizontalAlignment horizontal) {
return new DecorateEntityImage(original, null, null, text, horizontal); return new DecorateEntityImage(original, null, null, text, horizontal);
} }
public static DecorateEntityImage add(TextBlock original, TextBlock text, HorizontalAlignment horizontal, public static TextBlock add(TextBlock original, TextBlock text, HorizontalAlignment horizontal,
VerticalAlignment verticalAlignment) { VerticalAlignment verticalAlignment) {
if (verticalAlignment == VerticalAlignment.TOP) { if (verticalAlignment == VerticalAlignment.TOP) {
return addTop(original, text, horizontal); return addTop(original, text, horizontal);
@ -75,7 +75,12 @@ public class DecorateEntityImage extends AbstractTextBlock implements TextBlockB
return addBottom(original, text, horizontal); return addBottom(original, text, horizontal);
} }
public DecorateEntityImage(TextBlock original, TextBlock text1, HorizontalAlignment horizontal1, TextBlock text2, public static TextBlock addTopAndBottom(TextBlock original, TextBlock text1, HorizontalAlignment horizontal1,
TextBlock text2, HorizontalAlignment horizontal2) {
return new DecorateEntityImage(original, text1, horizontal1, text2, horizontal2);
}
private DecorateEntityImage(TextBlock original, TextBlock text1, HorizontalAlignment horizontal1, TextBlock text2,
HorizontalAlignment horizontal2) { HorizontalAlignment horizontal2) {
this.original = original; this.original = original;
this.horizontal1 = horizontal1; this.horizontal1 = horizontal1;

View File

@ -356,9 +356,9 @@ public class Line implements Moveable, Hideable {
sb.append(decoration); sb.append(decoration);
int length = link.getLength(); int length = link.getLength();
// if (graphvizVersion == GraphvizVersion.V2_34_0 && length == 1) { if (graphvizVersion.ignoreHorizontalLinks() && length == 1) {
// length = 2; length = 2;
// } }
if (useRankSame) { if (useRankSame) {
if (pragma.horizontalLineBetweenDifferentPackageAllowed() || link.isInvis() || length != 1) { if (pragma.horizontalLineBetweenDifferentPackageAllowed() || link.isInvis() || length != 1) {
// if (graphvizVersion.isJs() == false) { // if (graphvizVersion.isJs() == false) {
@ -373,7 +373,7 @@ public class Line implements Moveable, Hideable {
sb.append("color=\"" + StringUtils.getAsHtml(lineColor) + "\""); sb.append("color=\"" + StringUtils.getAsHtml(lineColor) + "\"");
if (labelText != null) { if (labelText != null) {
sb.append(","); sb.append(",");
if (graphvizVersion.modeSafe() || dotMode == DotMode.NO_LEFT_RIGHT_AND_XLABEL) { if (graphvizVersion.useXLabelInsteadOfLabel() || dotMode == DotMode.NO_LEFT_RIGHT_AND_XLABEL) {
sb.append("xlabel=<"); sb.append("xlabel=<");
} else { } else {
sb.append("label=<"); sb.append("label=<");

View File

@ -38,6 +38,7 @@ package net.sourceforge.plantuml.svek.extremity;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.ugraphic.UChangeBackColor; import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
import net.sourceforge.plantuml.ugraphic.UEllipse; import net.sourceforge.plantuml.ugraphic.UEllipse;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
@ -47,19 +48,31 @@ import net.sourceforge.plantuml.ugraphic.UTranslate;
class ExtremityCircle extends Extremity { class ExtremityCircle extends Extremity {
private final Point2D dest; private final Point2D dest;
private final double radius = 6; private static final double radius = 6;
@Override @Override
public Point2D somePoint() { public Point2D somePoint() {
return dest; return dest;
} }
public ExtremityCircle(Point2D p1) { // public static UDrawable createContact(Point2D p1, double angle) {
this.dest = new Point2D.Double(p1.getX(), p1.getY()); // final double x = p1.getX() - radius + radius * Math.sin(angle);
// final double y = p1.getY() - radius - radius * Math.cos(angle);
// return new ExtremityCircle(x, y);
// }
public static UDrawable create(Point2D center) {
return new ExtremityCircle(center.getX(), center.getY());
}
private ExtremityCircle(double x, double y) {
this.dest = new Point2D.Double(x, y);
} }
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
ug.apply(new UStroke(1.5)).apply(new UChangeBackColor(HtmlColorUtils.WHITE)).apply(new UTranslate(dest.getX() - radius, dest.getY() - radius)).draw(new UEllipse(radius * 2, radius * 2)); ug.apply(new UStroke(1.5)).apply(new UChangeBackColor(HtmlColorUtils.WHITE))
.apply(new UTranslate(dest.getX() - radius, dest.getY() - radius))
.draw(new UEllipse(radius * 2, radius * 2));
} }
} }

View File

@ -43,9 +43,14 @@ import net.sourceforge.plantuml.svek.Side;
public class ExtremityFactoryCircle extends AbstractExtremityFactory implements ExtremityFactory { public class ExtremityFactoryCircle extends AbstractExtremityFactory implements ExtremityFactory {
@Override
public UDrawable createUDrawable(Point2D center, double angle, Side side) {
// return ExtremityCircle.createContact(center, angle);
return ExtremityCircle.create(center);
}
public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2, Side side) { public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2, Side side) {
// final double ortho = atan2(p0, p2); return ExtremityCircle.create(p1);
return new ExtremityCircle(p1);
} }
} }

View File

@ -38,6 +38,8 @@ package net.sourceforge.plantuml.svek.image;
import java.awt.geom.Dimension2D; import java.awt.geom.Dimension2D;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
@ -46,6 +48,7 @@ import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.cucadiagram.BodyEnhanced; import net.sourceforge.plantuml.cucadiagram.BodyEnhanced;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.EntityPortion; import net.sourceforge.plantuml.cucadiagram.EntityPortion;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.ILeaf;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.PortionShower; import net.sourceforge.plantuml.cucadiagram.PortionShower;
@ -171,7 +174,13 @@ public class EntityImageDescription extends AbstractEntityImage {
if (hideText == false) { if (hideText == false) {
return Margins.NONE; return Margins.NONE;
} }
if (useRankSame && hasSomeHorizontalLink((ILeaf) getEntity(), links)) { // if (useRankSame && hasSomeHorizontalLink((ILeaf) getEntity(), links)) {
// return Margins.NONE;
// }
if (isThereADoubleLink((ILeaf) getEntity(), links)) {
return Margins.NONE;
}
if (hasSomeHorizontalLinkVisible((ILeaf) getEntity(), links)) {
return Margins.NONE; return Margins.NONE;
} }
if (hasSomeHorizontalLinkDoubleDecorated((ILeaf) getEntity(), links)) { if (hasSomeHorizontalLinkDoubleDecorated((ILeaf) getEntity(), links)) {
@ -189,15 +198,29 @@ public class EntityImageDescription extends AbstractEntityImage {
return new Margins(suppX / 2, suppX / 2, y, y); return new Margins(suppX / 2, suppX / 2, y, y);
} }
private boolean hasSomeHorizontalLink(ILeaf leaf, Collection<Link> links) { private boolean hasSomeHorizontalLinkVisible(ILeaf leaf, Collection<Link> links) {
for (Link link : links) { for (Link link : links) {
if (link.getLength() == 1 && link.contains(leaf)) { if (link.getLength() == 1 && link.contains(leaf) && link.isInvis() == false) {
return true; return true;
} }
} }
return false; return false;
} }
private boolean isThereADoubleLink(ILeaf leaf, Collection<Link> links) {
final Set<IEntity> others = new HashSet<IEntity>();
for (Link link : links) {
if (link.contains(leaf)) {
final IEntity other = link.getOther(leaf);
final boolean changed = others.add(other);
if (changed == false) {
return true;
}
}
}
return false;
}
private boolean hasSomeHorizontalLinkDoubleDecorated(ILeaf leaf, Collection<Link> links) { private boolean hasSomeHorizontalLinkDoubleDecorated(ILeaf leaf, Collection<Link> links) {
for (Link link : links) { for (Link link : links) {
if (link.getLength() == 1 && link.contains(leaf) && link.getType().isDoubleDecorated()) { if (link.getLength() == 1 && link.contains(leaf) && link.getType().isDoubleDecorated()) {

View File

@ -108,7 +108,7 @@ public class MainWindow2 extends JFrame {
} }
private String getDefaultFileExtensions() { private String getDefaultFileExtensions() {
return "txt, tex, java, htm, html, c, h, cpp, apt, pu, puml"; return "txt, tex, java, htm, html, c, h, cpp, apt, pu, puml, hpp, hh";
} }
private void changeExtensions(String ext) { private void changeExtensions(String ext) {

View File

@ -43,7 +43,7 @@ public class Version {
private static final int MAJOR_SEPARATOR = 1000000; private static final int MAJOR_SEPARATOR = 1000000;
public static int version() { public static int version() {
return 1201803; return 1201804;
} }
public static int versionPatched() { public static int versionPatched() {
@ -88,7 +88,7 @@ public class Version {
} }
public static long compileTime() { public static long compileTime() {
return 1522947555139L; return 1525191499228L;
} }
public static String compileTimeString() { public static String compileTimeString() {

View File

@ -129,13 +129,17 @@ public class GraphvizJs implements Graphviz {
return true; return true;
} }
public boolean modeSafe() { public boolean useXLabelInsteadOfLabel() {
return modeSafe; return modeSafe;
} }
public boolean isVizjs() { public boolean isVizjs() {
return true; return true;
} }
public boolean ignoreHorizontalLinks() {
return false;
}
}; };
} }