mirror of
https://github.com/octoleo/plantuml.git
synced 2024-12-02 01:48:27 +00:00
Simplify passing around of seed value.
This commit is contained in:
parent
437a3b08f0
commit
68be6ae4a0
@ -143,7 +143,7 @@ public abstract class AbstractPSystem implements Diagram {
|
|||||||
throws IOException {
|
throws IOException {
|
||||||
final long now = System.currentTimeMillis();
|
final long now = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
return exportDiagramNow(os, index, fileFormatOption, seed());
|
return exportDiagramNow(os, index, fileFormatOption);
|
||||||
} finally {
|
} finally {
|
||||||
if (OptionFlags.getInstance().isEnableStats()) {
|
if (OptionFlags.getInstance().isEnableStats()) {
|
||||||
StatsUtilsIncrement.onceMoreGenerate(System.currentTimeMillis() - now, getClass(),
|
StatsUtilsIncrement.onceMoreGenerate(System.currentTimeMillis() - now, getClass(),
|
||||||
@ -160,8 +160,8 @@ public abstract class AbstractPSystem implements Diagram {
|
|||||||
return scale;
|
return scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption,
|
protected abstract ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption
|
||||||
long seed) throws IOException;
|
) throws IOException;
|
||||||
|
|
||||||
public ClockwiseTopRightBottomLeft getDefaultMargins() {
|
public ClockwiseTopRightBottomLeft getDefaultMargins() {
|
||||||
return ClockwiseTopRightBottomLeft.same(0);
|
return ClockwiseTopRightBottomLeft.same(0);
|
||||||
|
@ -102,7 +102,7 @@ public class NewpagedDiagram extends AbstractPSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
|
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
return diagrams.get(num).exportDiagram(os, 0, fileFormat);
|
return diagrams.get(num).exportDiagram(os, 0, fileFormat);
|
||||||
}
|
}
|
||||||
|
@ -47,14 +47,15 @@ import static net.sourceforge.plantuml.ugraphic.ImageBuilder.plainImageBuilder;
|
|||||||
public abstract class PlainDiagram extends AbstractPSystem {
|
public abstract class PlainDiagram extends AbstractPSystem {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption, long seed)
|
protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
final UDrawable drawable = getRootDrawable(fileFormatOption);
|
final UDrawable drawable = getRootDrawable(fileFormatOption);
|
||||||
|
|
||||||
final ImageBuilder builder = plainImageBuilder(drawable, fileFormatOption, seed)
|
final ImageBuilder builder = plainImageBuilder(drawable, fileFormatOption)
|
||||||
.margin(getDefaultMargins())
|
.margin(getDefaultMargins())
|
||||||
.metadata(fileFormatOption.isWithMetadata() ? getMetadata() : null);
|
.metadata(fileFormatOption.isWithMetadata() ? getMetadata() : null)
|
||||||
|
.seed(seed());
|
||||||
|
|
||||||
return adjustImageBuilder(builder).write(os);
|
return adjustImageBuilder(builder).write(os);
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ public class SourceStringReader {
|
|||||||
public DiagramDescription outputImage(OutputStream os, int numImage, FileFormatOption fileFormatOption)
|
public DiagramDescription outputImage(OutputStream os, int numImage, FileFormatOption fileFormatOption)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
if (blocks.size() == 0) {
|
if (blocks.size() == 0) {
|
||||||
noStartumlFound(os, fileFormatOption, 42);
|
noStartumlFound(os, fileFormatOption);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
for (BlockUml b : blocks) {
|
for (BlockUml b : blocks) {
|
||||||
@ -222,11 +222,11 @@ public class SourceStringReader {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImageData noStartumlFound(OutputStream os, FileFormatOption fileFormatOption, long seed) throws IOException {
|
public ImageData noStartumlFound(OutputStream os, FileFormatOption fileFormatOption) throws IOException {
|
||||||
final TextBlockBackcolored error = GraphicStrings.createForError(Arrays.asList("No @startuml/@enduml found"),
|
final TextBlockBackcolored error = GraphicStrings.createForError(Arrays.asList("No @startuml/@enduml found"),
|
||||||
fileFormatOption.isUseRedForError());
|
fileFormatOption.isUseRedForError());
|
||||||
|
|
||||||
return plainImageBuilder(error, fileFormatOption, seed)
|
return plainImageBuilder(error, fileFormatOption)
|
||||||
.write(os);
|
.write(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption, long seed)
|
final protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
final HColor hover = getSkinParam().hoverPathColor();
|
final HColor hover = getSkinParam().hoverPathColor();
|
||||||
@ -155,20 +155,20 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot
|
|||||||
return imageData;
|
return imageData;
|
||||||
} catch (NoStyleAvailableException e) {
|
} catch (NoStyleAvailableException e) {
|
||||||
// e.printStackTrace();
|
// e.printStackTrace();
|
||||||
exportDiagramError(os, e, fileFormatOption, seed, null);
|
exportDiagramError(os, e, fileFormatOption, null);
|
||||||
} catch (UnparsableGraphvizException e) {
|
} catch (UnparsableGraphvizException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
exportDiagramError(os, e.getCause(), fileFormatOption, seed, e.getGraphvizVersion());
|
exportDiagramError(os, e.getCause(), fileFormatOption, e.getGraphvizVersion());
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
//e.printStackTrace();
|
//e.printStackTrace();
|
||||||
exportDiagramError(os, e, fileFormatOption, seed, null);
|
exportDiagramError(os, e, fileFormatOption, null);
|
||||||
}
|
}
|
||||||
return ImageDataSimple.error();
|
return ImageDataSimple.error();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void exportDiagramError(OutputStream os, Throwable exception, FileFormatOption fileFormat, long seed,
|
private void exportDiagramError(OutputStream os, Throwable exception, FileFormatOption fileFormat,
|
||||||
String graphvizVersion) throws IOException {
|
String graphvizVersion) throws IOException {
|
||||||
exportDiagramError(os, exception, fileFormat, seed, getMetadata(), getFlashData(),
|
exportDiagramError(os, exception, fileFormat, seed(), getMetadata(), getFlashData(),
|
||||||
getFailureText1(exception, graphvizVersion, getFlashData()));
|
getFailureText1(exception, graphvizVersion, getFlashData()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,8 +208,9 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
plainImageBuilder(drawable, fileFormat, seed)
|
plainImageBuilder(drawable, fileFormat)
|
||||||
.metadata(metadata)
|
.metadata(metadata)
|
||||||
|
.seed(seed)
|
||||||
.write(os);
|
.write(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ public class PSystemXearth extends AbstractPSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
|
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
synchronized (PSystemXearth.class) {
|
synchronized (PSystemXearth.class) {
|
||||||
final ACearth earth = new ACearth(markers);
|
final ACearth earth = new ACearth(markers);
|
||||||
|
@ -205,7 +205,7 @@ public class ActivityDiagram3 extends UmlDiagram {
|
|||||||
result = CompressionXorYBuilder.build(CompressionMode.ON_Y, result, stringBounder);
|
result = CompressionXorYBuilder.build(CompressionMode.ON_Y, result, stringBounder);
|
||||||
|
|
||||||
result = new TextBlockRecentred(result);
|
result = new TextBlockRecentred(result);
|
||||||
return styledImageBuilder(this, result, index, fileFormatOption, seed())
|
return styledImageBuilder(this, result, index, fileFormatOption)
|
||||||
.write(os);
|
.write(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ public class BoardDiagram extends UmlDiagram {
|
|||||||
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption, seed())
|
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption)
|
||||||
.write(os);
|
.write(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public class BpmDiagram extends UmlDiagram {
|
|||||||
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
return styledImageBuilder(this, getUDrawable(), index, fileFormatOption, seed())
|
return styledImageBuilder(this, getUDrawable(), index, fileFormatOption)
|
||||||
.annotations(false)
|
.annotations(false)
|
||||||
.write(os);
|
.write(os);
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram {
|
|||||||
final RowLayout rawLayout = getRawLayout(i);
|
final RowLayout rawLayout = getRawLayout(i);
|
||||||
fullLayout.addRowLayout(rawLayout);
|
fullLayout.addRowLayout(rawLayout);
|
||||||
}
|
}
|
||||||
return styledImageBuilder(this, fullLayout, index, fileFormatOption, seed())
|
return styledImageBuilder(this, fullLayout, index, fileFormatOption)
|
||||||
.annotations(false) // Backwards compatibility - this only applies when "layout_new_line" is used
|
.annotations(false) // Backwards compatibility - this only applies when "layout_new_line" is used
|
||||||
.write(os);
|
.write(os);
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ public class PSystemDot extends AbstractPSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
|
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
final Graphviz graphviz = GraphvizUtils.createForSystemDot(null, data,
|
final Graphviz graphviz = GraphvizUtils.createForSystemDot(null, data,
|
||||||
StringUtils.goLowerCase(fileFormat.getFileFormat().name()));
|
StringUtils.goLowerCase(fileFormat.getFileFormat().name()));
|
||||||
|
@ -88,7 +88,7 @@ public class PSystemDitaa extends AbstractPSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
|
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
if (fileFormat.getFileFormat() == FileFormat.ATXT) {
|
if (fileFormat.getFileFormat() == FileFormat.ATXT) {
|
||||||
os.write(getSource().getPlainString().getBytes());
|
os.write(getSource().getPlainString().getBytes());
|
||||||
|
@ -53,7 +53,7 @@ public class PSystemPath extends AbstractPSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
|
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
return path.writeImage(os);
|
return path.writeImage(os);
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ public abstract class PSystemError extends PlainDiagram {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
|
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
if (fileFormat.getFileFormat() == FileFormat.ATXT || fileFormat.getFileFormat() == FileFormat.UTXT) {
|
if (fileFormat.getFileFormat() == FileFormat.ATXT || fileFormat.getFileFormat() == FileFormat.UTXT) {
|
||||||
final UGraphicTxt ugt = new UGraphicTxt();
|
final UGraphicTxt ugt = new UGraphicTxt();
|
||||||
@ -232,7 +232,7 @@ public abstract class PSystemError extends PlainDiagram {
|
|||||||
return new ImageDataSimple(1, 1);
|
return new ImageDataSimple(1, 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
return super.exportDiagramNow(os, num, fileFormat, seed);
|
return super.exportDiagramNow(os, num, fileFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -73,7 +73,7 @@ public class GitDiagram extends UmlDiagram {
|
|||||||
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption, 0)
|
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption)
|
||||||
.write(os);
|
.write(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ public class Help extends UmlDiagram {
|
|||||||
final Sheet sheet = Parser.build(fontConfiguration, HorizontalAlignment.LEFT, getSkinParam(), CreoleMode.FULL)
|
final Sheet sheet = Parser.build(fontConfiguration, HorizontalAlignment.LEFT, getSkinParam(), CreoleMode.FULL)
|
||||||
.createSheet(display);
|
.createSheet(display);
|
||||||
final SheetBlock1 sheetBlock = new SheetBlock1(sheet, LineBreakStrategy.NONE, 0);
|
final SheetBlock1 sheetBlock = new SheetBlock1(sheet, LineBreakStrategy.NONE, 0);
|
||||||
return styledImageBuilder(this, sheetBlock, 1, fileFormat, 0)
|
return styledImageBuilder(this, sheetBlock, 1, fileFormat)
|
||||||
.annotations(false)
|
.annotations(false)
|
||||||
.write(os);
|
.write(os);
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ public class PSystemJcckit extends AbstractPSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
|
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||||
|
|
||||||
|
@ -86,10 +86,10 @@ public class JsonDiagram extends TitledDiagram {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption, long seed)
|
protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption, 0)
|
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption)
|
||||||
.write(os);
|
.write(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ public class PSystemLogo extends AbstractPSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
|
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
final int width = 640;
|
final int width = 640;
|
||||||
final int height = 480;
|
final int height = 480;
|
||||||
|
@ -63,7 +63,7 @@ public class PSystemLatex extends AbstractPSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
|
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
final ScientificEquationSafe asciiMath = ScientificEquationSafe.fromLatex(latex);
|
final ScientificEquationSafe asciiMath = ScientificEquationSafe.fromLatex(latex);
|
||||||
return asciiMath.export(os, fileFormat, scale, color, backColor);
|
return asciiMath.export(os, fileFormat, scale, color, backColor);
|
||||||
|
@ -63,7 +63,7 @@ public class PSystemMath extends AbstractPSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
|
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
final ScientificEquationSafe asciiMath = ScientificEquationSafe.fromAsciiMath(math);
|
final ScientificEquationSafe asciiMath = ScientificEquationSafe.fromAsciiMath(math);
|
||||||
return asciiMath.export(os, fileFormat, scale, color, backColor);
|
return asciiMath.export(os, fileFormat, scale, color, backColor);
|
||||||
|
@ -101,7 +101,7 @@ public class ScientificEquationSafe {
|
|||||||
printTrace(e);
|
printTrace(e);
|
||||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
try {
|
try {
|
||||||
dimSvg = plainImageBuilder(getRollback(), new FileFormatOption(FileFormat.SVG), 42)
|
dimSvg = plainImageBuilder(getRollback(), new FileFormatOption(FileFormat.SVG))
|
||||||
.write(baos);
|
.write(baos);
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -84,7 +84,7 @@ public class MindMapDiagram extends UmlDiagram {
|
|||||||
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption, seed())
|
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption)
|
||||||
.write(os);
|
.write(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ public class NwDiagram extends UmlDiagram {
|
|||||||
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption, 0)
|
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption)
|
||||||
.write(os);
|
.write(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ public class PicoWebServer implements Runnable {
|
|||||||
system = PSystemErrorUtils.buildV2(null,
|
system = PSystemErrorUtils.buildV2(null,
|
||||||
new ErrorUml(SYNTAX_ERROR, "No @startuml/@enduml found", 0, new LineLocationImpl("", null)), null,
|
new ErrorUml(SYNTAX_ERROR, "No @startuml/@enduml found", 0, new LineLocationImpl("", null)), null,
|
||||||
Collections.<StringLocated>emptyList());
|
Collections.<StringLocated>emptyList());
|
||||||
imageData = ssr.noStartumlFound(os, option.getFileFormatOption(), 42);
|
imageData = ssr.noStartumlFound(os, option.getFileFormatOption());
|
||||||
} else {
|
} else {
|
||||||
system = ssr.getBlocks().get(0).getDiagram();
|
system = ssr.getBlocks().get(0).getDiagram();
|
||||||
imageData = system.exportDiagram(os, 0, option.getFileFormatOption());
|
imageData = system.exportDiagram(os, 0, option.getFileFormatOption());
|
||||||
|
@ -163,10 +163,10 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption, long seed)
|
protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
final StringBounder stringBounder = fileFormatOption.getDefaultStringBounder(getSkinParam());
|
final StringBounder stringBounder = fileFormatOption.getDefaultStringBounder(getSkinParam());
|
||||||
return styledImageBuilder(this, getTextBlock(stringBounder), index, fileFormatOption, seed())
|
return styledImageBuilder(this, getTextBlock(stringBounder), index, fileFormatOption)
|
||||||
.write(os);
|
.write(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,17 +112,17 @@ public class PSystemSalt extends TitledDiagram implements WithSprite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption, long seed)
|
final protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
try {
|
try {
|
||||||
final Element salt = createElement(manageSprite());
|
final Element salt = createElement(manageSprite());
|
||||||
final StringBounder stringBounder = fileFormatOption.getDefaultStringBounder(getSkinParam());
|
final StringBounder stringBounder = fileFormatOption.getDefaultStringBounder(getSkinParam());
|
||||||
final Dimension2D size = salt.getPreferredDimension(stringBounder, 0, 0);
|
final Dimension2D size = salt.getPreferredDimension(stringBounder, 0, 0);
|
||||||
return styledImageBuilder(this, getTextBlock(salt, size), index, fileFormatOption, seed())
|
return styledImageBuilder(this, getTextBlock(salt, size), index, fileFormatOption)
|
||||||
.write(os);
|
.write(os);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
UmlDiagram.exportDiagramError(os, e, fileFormatOption, seed, getMetadata(), "none",
|
UmlDiagram.exportDiagramError(os, e, fileFormatOption, seed(), getMetadata(), "none",
|
||||||
new ArrayList<String>());
|
new ArrayList<String>());
|
||||||
return ImageDataSimple.error();
|
return ImageDataSimple.error();
|
||||||
}
|
}
|
||||||
|
@ -450,7 +450,7 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
|
|||||||
|
|
||||||
// imageBuilder.setUDrawable(new Drawing(new YMirror(dim.getHeight())));
|
// imageBuilder.setUDrawable(new Drawing(new YMirror(dim.getHeight())));
|
||||||
final TextBlock drawable = new Drawing(new YMirror(minMax.getMaxY()), minMax);
|
final TextBlock drawable = new Drawing(new YMirror(minMax.getMaxY()), minMax);
|
||||||
return styledImageBuilder(diagram, drawable, 1, fileFormatOption, diagram.seed())
|
return styledImageBuilder(diagram, drawable, 1, fileFormatOption)
|
||||||
.write(os);
|
.write(os);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
SmetanaDebug.printMe();
|
SmetanaDebug.printMe();
|
||||||
|
@ -220,7 +220,7 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
return styledImageBuilder(diagram, drawable, index, fileFormatOption, diagram.seed())
|
return styledImageBuilder(diagram, drawable, index, fileFormatOption)
|
||||||
.annotations(false) // they are managed above
|
.annotations(false) // they are managed above
|
||||||
.write(os);
|
.write(os);
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker {
|
|||||||
if (this.index != index) {
|
if (this.index != index) {
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
return styledImageBuilder(diagram, new Foo(index), index, fileFormatOption, diagram.seed())
|
return styledImageBuilder(diagram, new Foo(index), index, fileFormatOption)
|
||||||
.annotations(false) // they are managed in drawInternal()
|
.annotations(false) // they are managed in drawInternal()
|
||||||
.write(os);
|
.write(os);
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ public class ListSpriteDiagram extends UmlDiagram {
|
|||||||
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
return styledImageBuilder(this, getTable(), index, fileFormatOption, seed())
|
return styledImageBuilder(this, getTable(), index, fileFormatOption)
|
||||||
.annotations(false)
|
.annotations(false)
|
||||||
.write(os);
|
.write(os);
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ public class StdlibDiagram extends UmlDiagram {
|
|||||||
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
return styledImageBuilder(this, getTable(), index, fileFormatOption, seed())
|
return styledImageBuilder(this, getTable(), index, fileFormatOption)
|
||||||
.annotations(false)
|
.annotations(false)
|
||||||
.write(os);
|
.write(os);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ public class PSystemSudoku extends AbstractPSystem {
|
|||||||
final private ISudoku sudoku;
|
final private ISudoku sudoku;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
|
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
final GraphicsSudoku sud = new GraphicsSudoku(sudoku);
|
final GraphicsSudoku sud = new GraphicsSudoku(sudoku);
|
||||||
if (fileFormat.getFileFormat() == FileFormat.EPS) {
|
if (fileFormat.getFileFormat() == FileFormat.EPS) {
|
||||||
|
@ -120,7 +120,7 @@ public final class CucaDiagramFileMakerSvek implements CucaDiagramFileMaker {
|
|||||||
// Sorry about this hack. There is a side effect in SvekResult::calculateDimension()
|
// Sorry about this hack. There is a side effect in SvekResult::calculateDimension()
|
||||||
result.calculateDimension(stringBounder); // Ensure text near the margins is not cut off
|
result.calculateDimension(stringBounder); // Ensure text near the margins is not cut off
|
||||||
|
|
||||||
return styledImageBuilder(diagram, result, 1, fileFormatOption, diagram.seed())
|
return styledImageBuilder(diagram, result, 1, fileFormatOption)
|
||||||
.annotations(false) // backwards compatibility (AnnotatedWorker is used above)
|
.annotations(false) // backwards compatibility (AnnotatedWorker is used above)
|
||||||
.status(result instanceof GraphvizCrash ? 503 : 0)
|
.status(result instanceof GraphvizCrash ? 503 : 0)
|
||||||
.warningOrError(warningOrError)
|
.warningOrError(warningOrError)
|
||||||
|
@ -98,7 +98,7 @@ public class TimingDiagram extends UmlDiagram implements Clocks {
|
|||||||
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption, seed())
|
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption)
|
||||||
.write(os);
|
.write(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,36 +111,36 @@ public class ImageBuilder {
|
|||||||
private final TitledDiagram titledDiagram;
|
private final TitledDiagram titledDiagram;
|
||||||
private UDrawable udrawable;
|
private UDrawable udrawable;
|
||||||
private final FileFormatOption fileFormatOption;
|
private final FileFormatOption fileFormatOption;
|
||||||
private final long seed;
|
private long seed = 42;
|
||||||
private int status = 0;
|
private int status = 0;
|
||||||
private String metadata;
|
private String metadata;
|
||||||
private boolean randomPixel;
|
private boolean randomPixel;
|
||||||
private String warningOrError;
|
private String warningOrError;
|
||||||
|
|
||||||
public static ImageBuilder plainImageBuilder(UDrawable drawable, FileFormatOption fileFormatOption, long seed) {
|
public static ImageBuilder plainImageBuilder(UDrawable drawable, FileFormatOption fileFormatOption) {
|
||||||
return new ImageBuilder(drawable, null, fileFormatOption, seed, new ImageParameter());
|
return new ImageBuilder(drawable, null, fileFormatOption, new ImageParameter());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ImageBuilder plainPngBuilder(UDrawable drawable) {
|
public static ImageBuilder plainPngBuilder(UDrawable drawable) {
|
||||||
return plainImageBuilder(drawable, new FileFormatOption(FileFormat.PNG), 42);
|
return plainImageBuilder(drawable, new FileFormatOption(FileFormat.PNG));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO do something with "index"
|
// TODO do something with "index"
|
||||||
public static ImageBuilder styledImageBuilder(TitledDiagram diagram, UDrawable drawable, int index,
|
public static ImageBuilder styledImageBuilder(TitledDiagram diagram, UDrawable drawable, int index,
|
||||||
FileFormatOption fileFormatOption, long seed) {
|
FileFormatOption fileFormatOption) {
|
||||||
return new ImageBuilder(drawable, diagram, fileFormatOption, seed, new ImageParameter(diagram))
|
return new ImageBuilder(drawable, diagram, fileFormatOption, new ImageParameter(diagram))
|
||||||
.annotations(true)
|
.annotations(true)
|
||||||
.backcolor(getBackgroundColor(diagram))
|
.backcolor(getBackgroundColor(diagram))
|
||||||
.margin(calculateDiagramMargin(diagram))
|
.margin(calculateDiagramMargin(diagram))
|
||||||
.metadata(fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null)
|
.metadata(fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null)
|
||||||
|
.seed(diagram.seed())
|
||||||
.warningOrError(diagram.getWarningOrError());
|
.warningOrError(diagram.getWarningOrError());
|
||||||
}
|
}
|
||||||
|
|
||||||
private ImageBuilder(UDrawable drawable, TitledDiagram titledDiagram, FileFormatOption fileFormatOption, long seed, ImageParameter param) {
|
private ImageBuilder(UDrawable drawable, TitledDiagram titledDiagram, FileFormatOption fileFormatOption, ImageParameter param) {
|
||||||
this.udrawable = drawable;
|
this.udrawable = drawable;
|
||||||
this.titledDiagram = titledDiagram;
|
this.titledDiagram = titledDiagram;
|
||||||
this.fileFormatOption = fileFormatOption;
|
this.fileFormatOption = fileFormatOption;
|
||||||
this.seed = seed;
|
|
||||||
this.param = param;
|
this.param = param;
|
||||||
|
|
||||||
if (drawable instanceof TextBlockBackcolored) {
|
if (drawable instanceof TextBlockBackcolored) {
|
||||||
@ -180,6 +180,11 @@ public class ImageBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ImageBuilder seed(long seed) {
|
||||||
|
this.seed = seed;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public ImageBuilder status(int status) {
|
public ImageBuilder status(int status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
return this;
|
return this;
|
||||||
@ -198,7 +203,7 @@ public class ImageBuilder {
|
|||||||
final AnnotatedWorker annotatedWorker = new AnnotatedWorker(titledDiagram, skinParam, stringBounder);
|
final AnnotatedWorker annotatedWorker = new AnnotatedWorker(titledDiagram, skinParam, stringBounder);
|
||||||
udrawable = annotatedWorker.addAdd((TextBlock) udrawable);
|
udrawable = annotatedWorker.addAdd((TextBlock) udrawable);
|
||||||
}
|
}
|
||||||
final ImageData imageData = writeImageTOBEMOVED(fileFormatOption, seed, os);
|
final ImageData imageData = writeImageTOBEMOVED(fileFormatOption, os);
|
||||||
((ImageDataAbstract) imageData).setStatus(status);
|
((ImageDataAbstract) imageData).setStatus(status);
|
||||||
return imageData;
|
return imageData;
|
||||||
}
|
}
|
||||||
@ -210,11 +215,11 @@ public class ImageBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImageData writeImageTOBEMOVED(long seed, OutputStream os) throws IOException {
|
public ImageData writeImageTOBEMOVED(OutputStream os) throws IOException {
|
||||||
return writeImageTOBEMOVED(fileFormatOption, seed, os);
|
return writeImageTOBEMOVED(fileFormatOption, os);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImageData writeImageTOBEMOVED(FileFormatOption fileFormatOption, long seed, OutputStream os)
|
public ImageData writeImageTOBEMOVED(FileFormatOption fileFormatOption, OutputStream os)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
final FileFormat fileFormat = fileFormatOption.getFileFormat();
|
final FileFormat fileFormat = fileFormatOption.getFileFormat();
|
||||||
if (fileFormat == FileFormat.MJPEG) {
|
if (fileFormat == FileFormat.MJPEG) {
|
||||||
@ -222,10 +227,10 @@ public class ImageBuilder {
|
|||||||
} else if (fileFormat == FileFormat.ANIMATED_GIF) {
|
} else if (fileFormat == FileFormat.ANIMATED_GIF) {
|
||||||
return writeImageAnimatedGif(os, fileFormatOption.getDefaultStringBounder(param.getSvgCharSizeHack()));
|
return writeImageAnimatedGif(os, fileFormatOption.getDefaultStringBounder(param.getSvgCharSizeHack()));
|
||||||
}
|
}
|
||||||
return writeImageInternal(fileFormatOption, seed, os, param.getAnimation());
|
return writeImageInternal(fileFormatOption, os, param.getAnimation());
|
||||||
}
|
}
|
||||||
|
|
||||||
private ImageData writeImageInternal(FileFormatOption fileFormatOption, long seed, OutputStream os,
|
private ImageData writeImageInternal(FileFormatOption fileFormatOption, OutputStream os,
|
||||||
Animation animationArg) throws IOException {
|
Animation animationArg) throws IOException {
|
||||||
Dimension2D dim = getFinalDimension(fileFormatOption.getDefaultStringBounder(param.getSvgCharSizeHack()));
|
Dimension2D dim = getFinalDimension(fileFormatOption.getDefaultStringBounder(param.getSvgCharSizeHack()));
|
||||||
double dx = 0;
|
double dx = 0;
|
||||||
@ -238,7 +243,7 @@ public class ImageBuilder {
|
|||||||
dy = -minmax.getMinY();
|
dy = -minmax.getMinY();
|
||||||
}
|
}
|
||||||
|
|
||||||
final UGraphic2 ug = createUGraphic(fileFormatOption, seed, dim, animationArg, dx, dy);
|
final UGraphic2 ug = createUGraphic(fileFormatOption, dim, animationArg, dx, dy);
|
||||||
UGraphic ug2 = ug;
|
UGraphic ug2 = ug;
|
||||||
|
|
||||||
final UStroke borderStroke = param.getBorderStroke();
|
final UStroke borderStroke = param.getBorderStroke();
|
||||||
@ -361,7 +366,7 @@ public class ImageBuilder {
|
|||||||
|
|
||||||
private Image getAviImage(AffineTransformation affineTransform) throws IOException {
|
private Image getAviImage(AffineTransformation affineTransform) throws IOException {
|
||||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
writeImageInternal(new FileFormatOption(FileFormat.PNG), 42, baos, Animation.singleton(affineTransform));
|
writeImageInternal(new FileFormatOption(FileFormat.PNG), baos, Animation.singleton(affineTransform));
|
||||||
baos.close();
|
baos.close();
|
||||||
|
|
||||||
final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||||
@ -370,7 +375,7 @@ public class ImageBuilder {
|
|||||||
return im;
|
return im;
|
||||||
}
|
}
|
||||||
|
|
||||||
private UGraphic2 createUGraphic(FileFormatOption option, long seed, final Dimension2D dim, Animation animationArg,
|
private UGraphic2 createUGraphic(FileFormatOption option, final Dimension2D dim, Animation animationArg,
|
||||||
double dx, double dy) {
|
double dx, double dy) {
|
||||||
final ColorMapper colorMapper = param.getColorMapper();
|
final ColorMapper colorMapper = param.getColorMapper();
|
||||||
final double scaleFactor = (param.getScale() == null ? 1
|
final double scaleFactor = (param.getScale() == null ? 1
|
||||||
@ -382,7 +387,7 @@ public class ImageBuilder {
|
|||||||
option.getWatermark());
|
option.getWatermark());
|
||||||
case SVG:
|
case SVG:
|
||||||
return createUGraphicSVG(colorMapper, scaleFactor, dim, backcolor, option.getSvgLinkTarget(),
|
return createUGraphicSVG(colorMapper, scaleFactor, dim, backcolor, option.getSvgLinkTarget(),
|
||||||
option.getHoverColor(), seed, option.getPreserveAspectRatio(), param.getlengthAdjust());
|
option.getHoverColor(), option.getPreserveAspectRatio(), param.getlengthAdjust());
|
||||||
case EPS:
|
case EPS:
|
||||||
return new UGraphicEps(colorMapper, EpsStrategy.getDefault2());
|
return new UGraphicEps(colorMapper, EpsStrategy.getDefault2());
|
||||||
case EPS_TEXT:
|
case EPS_TEXT:
|
||||||
@ -408,7 +413,7 @@ public class ImageBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private UGraphic2 createUGraphicSVG(ColorMapper colorMapper, double scaleFactor, Dimension2D dim,
|
private UGraphic2 createUGraphicSVG(ColorMapper colorMapper, double scaleFactor, Dimension2D dim,
|
||||||
final HColor suggested, String svgLinkTarget, String hover, long seed, String preserveAspectRatio,
|
final HColor suggested, String svgLinkTarget, String hover, String preserveAspectRatio,
|
||||||
LengthAdjust lengthAdjust) {
|
LengthAdjust lengthAdjust) {
|
||||||
HColor backColor = HColorUtils.WHITE;
|
HColor backColor = HColorUtils.WHITE;
|
||||||
if (suggested instanceof HColorSimple) {
|
if (suggested instanceof HColorSimple) {
|
||||||
|
@ -77,7 +77,7 @@ public class WBSDiagram extends UmlDiagram {
|
|||||||
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption, seed())
|
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption)
|
||||||
.write(os);
|
.write(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ public class WireDiagram extends UmlDiagram {
|
|||||||
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption, seed())
|
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption)
|
||||||
.write(os);
|
.write(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user