mirror of
https://github.com/octoleo/plantuml.git
synced 2024-11-30 00:33:53 +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 {
|
||||
final long now = System.currentTimeMillis();
|
||||
try {
|
||||
return exportDiagramNow(os, index, fileFormatOption, seed());
|
||||
return exportDiagramNow(os, index, fileFormatOption);
|
||||
} finally {
|
||||
if (OptionFlags.getInstance().isEnableStats()) {
|
||||
StatsUtilsIncrement.onceMoreGenerate(System.currentTimeMillis() - now, getClass(),
|
||||
@ -160,8 +160,8 @@ public abstract class AbstractPSystem implements Diagram {
|
||||
return scale;
|
||||
}
|
||||
|
||||
protected abstract ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption,
|
||||
long seed) throws IOException;
|
||||
protected abstract ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption
|
||||
) throws IOException;
|
||||
|
||||
public ClockwiseTopRightBottomLeft getDefaultMargins() {
|
||||
return ClockwiseTopRightBottomLeft.same(0);
|
||||
|
@ -102,7 +102,7 @@ public class NewpagedDiagram extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
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 {
|
||||
|
||||
@Override
|
||||
protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption, long seed)
|
||||
protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||
throws IOException {
|
||||
|
||||
final UDrawable drawable = getRootDrawable(fileFormatOption);
|
||||
|
||||
final ImageBuilder builder = plainImageBuilder(drawable, fileFormatOption, seed)
|
||||
final ImageBuilder builder = plainImageBuilder(drawable, fileFormatOption)
|
||||
.margin(getDefaultMargins())
|
||||
.metadata(fileFormatOption.isWithMetadata() ? getMetadata() : null);
|
||||
.metadata(fileFormatOption.isWithMetadata() ? getMetadata() : null)
|
||||
.seed(seed());
|
||||
|
||||
return adjustImageBuilder(builder).write(os);
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ public class SourceStringReader {
|
||||
public DiagramDescription outputImage(OutputStream os, int numImage, FileFormatOption fileFormatOption)
|
||||
throws IOException {
|
||||
if (blocks.size() == 0) {
|
||||
noStartumlFound(os, fileFormatOption, 42);
|
||||
noStartumlFound(os, fileFormatOption);
|
||||
return null;
|
||||
}
|
||||
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"),
|
||||
fileFormatOption.isUseRedForError());
|
||||
|
||||
return plainImageBuilder(error, fileFormatOption, seed)
|
||||
return plainImageBuilder(error, fileFormatOption)
|
||||
.write(os);
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot
|
||||
}
|
||||
|
||||
@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 {
|
||||
|
||||
final HColor hover = getSkinParam().hoverPathColor();
|
||||
@ -155,20 +155,20 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot
|
||||
return imageData;
|
||||
} catch (NoStyleAvailableException e) {
|
||||
// e.printStackTrace();
|
||||
exportDiagramError(os, e, fileFormatOption, seed, null);
|
||||
exportDiagramError(os, e, fileFormatOption, null);
|
||||
} catch (UnparsableGraphvizException e) {
|
||||
e.printStackTrace();
|
||||
exportDiagramError(os, e.getCause(), fileFormatOption, seed, e.getGraphvizVersion());
|
||||
exportDiagramError(os, e.getCause(), fileFormatOption, e.getGraphvizVersion());
|
||||
} catch (Throwable e) {
|
||||
//e.printStackTrace();
|
||||
exportDiagramError(os, e, fileFormatOption, seed, null);
|
||||
exportDiagramError(os, e, fileFormatOption, null);
|
||||
}
|
||||
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 {
|
||||
exportDiagramError(os, exception, fileFormat, seed, getMetadata(), getFlashData(),
|
||||
exportDiagramError(os, exception, fileFormat, seed(), getMetadata(), 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)
|
||||
.seed(seed)
|
||||
.write(os);
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ public class PSystemXearth extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
synchronized (PSystemXearth.class) {
|
||||
final ACearth earth = new ACearth(markers);
|
||||
|
@ -205,7 +205,7 @@ public class ActivityDiagram3 extends UmlDiagram {
|
||||
result = CompressionXorYBuilder.build(CompressionMode.ON_Y, result, stringBounder);
|
||||
|
||||
result = new TextBlockRecentred(result);
|
||||
return styledImageBuilder(this, result, index, fileFormatOption, seed())
|
||||
return styledImageBuilder(this, result, index, fileFormatOption)
|
||||
.write(os);
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ public class BoardDiagram extends UmlDiagram {
|
||||
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||
throws IOException {
|
||||
|
||||
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption, seed())
|
||||
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption)
|
||||
.write(os);
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ public class BpmDiagram extends UmlDiagram {
|
||||
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||
throws IOException {
|
||||
|
||||
return styledImageBuilder(this, getUDrawable(), index, fileFormatOption, seed())
|
||||
return styledImageBuilder(this, getUDrawable(), index, fileFormatOption)
|
||||
.annotations(false)
|
||||
.write(os);
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram {
|
||||
final RowLayout rawLayout = getRawLayout(i);
|
||||
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
|
||||
.write(os);
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public class PSystemDot extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final Graphviz graphviz = GraphvizUtils.createForSystemDot(null, data,
|
||||
StringUtils.goLowerCase(fileFormat.getFileFormat().name()));
|
||||
|
@ -88,7 +88,7 @@ public class PSystemDitaa extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
if (fileFormat.getFileFormat() == FileFormat.ATXT) {
|
||||
os.write(getSource().getPlainString().getBytes());
|
||||
|
@ -53,7 +53,7 @@ public class PSystemPath extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
return path.writeImage(os);
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ public abstract class PSystemError extends PlainDiagram {
|
||||
}
|
||||
|
||||
@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 {
|
||||
if (fileFormat.getFileFormat() == FileFormat.ATXT || fileFormat.getFileFormat() == FileFormat.UTXT) {
|
||||
final UGraphicTxt ugt = new UGraphicTxt();
|
||||
@ -232,7 +232,7 @@ public abstract class PSystemError extends PlainDiagram {
|
||||
return new ImageDataSimple(1, 1);
|
||||
|
||||
}
|
||||
return super.exportDiagramNow(os, num, fileFormat, seed);
|
||||
return super.exportDiagramNow(os, num, fileFormat);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -73,7 +73,7 @@ public class GitDiagram extends UmlDiagram {
|
||||
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||
throws IOException {
|
||||
|
||||
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption, 0)
|
||||
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption)
|
||||
.write(os);
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ public class Help extends UmlDiagram {
|
||||
final Sheet sheet = Parser.build(fontConfiguration, HorizontalAlignment.LEFT, getSkinParam(), CreoleMode.FULL)
|
||||
.createSheet(display);
|
||||
final SheetBlock1 sheetBlock = new SheetBlock1(sheet, LineBreakStrategy.NONE, 0);
|
||||
return styledImageBuilder(this, sheetBlock, 1, fileFormat, 0)
|
||||
return styledImageBuilder(this, sheetBlock, 1, fileFormat)
|
||||
.annotations(false)
|
||||
.write(os);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ public class PSystemJcckit extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||
|
||||
|
@ -86,10 +86,10 @@ public class JsonDiagram extends TitledDiagram {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption, long seed)
|
||||
protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||
throws IOException {
|
||||
|
||||
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption, 0)
|
||||
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption)
|
||||
.write(os);
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class PSystemLogo extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final int width = 640;
|
||||
final int height = 480;
|
||||
|
@ -63,7 +63,7 @@ public class PSystemLatex extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final ScientificEquationSafe asciiMath = ScientificEquationSafe.fromLatex(latex);
|
||||
return asciiMath.export(os, fileFormat, scale, color, backColor);
|
||||
|
@ -63,7 +63,7 @@ public class PSystemMath extends AbstractPSystem {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final ScientificEquationSafe asciiMath = ScientificEquationSafe.fromAsciiMath(math);
|
||||
return asciiMath.export(os, fileFormat, scale, color, backColor);
|
||||
|
@ -101,7 +101,7 @@ public class ScientificEquationSafe {
|
||||
printTrace(e);
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
try {
|
||||
dimSvg = plainImageBuilder(getRollback(), new FileFormatOption(FileFormat.SVG), 42)
|
||||
dimSvg = plainImageBuilder(getRollback(), new FileFormatOption(FileFormat.SVG))
|
||||
.write(baos);
|
||||
} catch (IOException e1) {
|
||||
return null;
|
||||
|
@ -84,7 +84,7 @@ public class MindMapDiagram extends UmlDiagram {
|
||||
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||
throws IOException {
|
||||
|
||||
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption, seed())
|
||||
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption)
|
||||
.write(os);
|
||||
}
|
||||
|
||||
|
@ -215,7 +215,7 @@ public class NwDiagram extends UmlDiagram {
|
||||
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||
throws IOException {
|
||||
|
||||
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption, 0)
|
||||
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption)
|
||||
.write(os);
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ public class PicoWebServer implements Runnable {
|
||||
system = PSystemErrorUtils.buildV2(null,
|
||||
new ErrorUml(SYNTAX_ERROR, "No @startuml/@enduml found", 0, new LineLocationImpl("", null)), null,
|
||||
Collections.<StringLocated>emptyList());
|
||||
imageData = ssr.noStartumlFound(os, option.getFileFormatOption(), 42);
|
||||
imageData = ssr.noStartumlFound(os, option.getFileFormatOption());
|
||||
} else {
|
||||
system = ssr.getBlocks().get(0).getDiagram();
|
||||
imageData = system.exportDiagram(os, 0, option.getFileFormatOption());
|
||||
|
@ -163,10 +163,10 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption, long seed)
|
||||
protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||
throws IOException {
|
||||
final StringBounder stringBounder = fileFormatOption.getDefaultStringBounder(getSkinParam());
|
||||
return styledImageBuilder(this, getTextBlock(stringBounder), index, fileFormatOption, seed())
|
||||
return styledImageBuilder(this, getTextBlock(stringBounder), index, fileFormatOption)
|
||||
.write(os);
|
||||
}
|
||||
|
||||
|
@ -112,17 +112,17 @@ public class PSystemSalt extends TitledDiagram implements WithSprite {
|
||||
}
|
||||
|
||||
@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 {
|
||||
try {
|
||||
final Element salt = createElement(manageSprite());
|
||||
final StringBounder stringBounder = fileFormatOption.getDefaultStringBounder(getSkinParam());
|
||||
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);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
UmlDiagram.exportDiagramError(os, e, fileFormatOption, seed, getMetadata(), "none",
|
||||
UmlDiagram.exportDiagramError(os, e, fileFormatOption, seed(), getMetadata(), "none",
|
||||
new ArrayList<String>());
|
||||
return ImageDataSimple.error();
|
||||
}
|
||||
|
@ -450,7 +450,7 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
|
||||
|
||||
// imageBuilder.setUDrawable(new Drawing(new YMirror(dim.getHeight())));
|
||||
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);
|
||||
} catch (Throwable e) {
|
||||
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
|
||||
.write(os);
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker {
|
||||
if (this.index != index) {
|
||||
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()
|
||||
.write(os);
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ public class ListSpriteDiagram extends UmlDiagram {
|
||||
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||
throws IOException {
|
||||
|
||||
return styledImageBuilder(this, getTable(), index, fileFormatOption, seed())
|
||||
return styledImageBuilder(this, getTable(), index, fileFormatOption)
|
||||
.annotations(false)
|
||||
.write(os);
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public class StdlibDiagram extends UmlDiagram {
|
||||
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||
throws IOException {
|
||||
|
||||
return styledImageBuilder(this, getTable(), index, fileFormatOption, seed())
|
||||
return styledImageBuilder(this, getTable(), index, fileFormatOption)
|
||||
.annotations(false)
|
||||
.write(os);
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class PSystemSudoku extends AbstractPSystem {
|
||||
final private ISudoku sudoku;
|
||||
|
||||
@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 {
|
||||
final GraphicsSudoku sud = new GraphicsSudoku(sudoku);
|
||||
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()
|
||||
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)
|
||||
.status(result instanceof GraphvizCrash ? 503 : 0)
|
||||
.warningOrError(warningOrError)
|
||||
|
@ -98,7 +98,7 @@ public class TimingDiagram extends UmlDiagram implements Clocks {
|
||||
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||
throws IOException {
|
||||
|
||||
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption, seed())
|
||||
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption)
|
||||
.write(os);
|
||||
}
|
||||
|
||||
|
@ -111,36 +111,36 @@ public class ImageBuilder {
|
||||
private final TitledDiagram titledDiagram;
|
||||
private UDrawable udrawable;
|
||||
private final FileFormatOption fileFormatOption;
|
||||
private final long seed;
|
||||
private long seed = 42;
|
||||
private int status = 0;
|
||||
private String metadata;
|
||||
private boolean randomPixel;
|
||||
private String warningOrError;
|
||||
|
||||
public static ImageBuilder plainImageBuilder(UDrawable drawable, FileFormatOption fileFormatOption, long seed) {
|
||||
return new ImageBuilder(drawable, null, fileFormatOption, seed, new ImageParameter());
|
||||
public static ImageBuilder plainImageBuilder(UDrawable drawable, FileFormatOption fileFormatOption) {
|
||||
return new ImageBuilder(drawable, null, fileFormatOption, new ImageParameter());
|
||||
}
|
||||
|
||||
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"
|
||||
public static ImageBuilder styledImageBuilder(TitledDiagram diagram, UDrawable drawable, int index,
|
||||
FileFormatOption fileFormatOption, long seed) {
|
||||
return new ImageBuilder(drawable, diagram, fileFormatOption, seed, new ImageParameter(diagram))
|
||||
FileFormatOption fileFormatOption) {
|
||||
return new ImageBuilder(drawable, diagram, fileFormatOption, new ImageParameter(diagram))
|
||||
.annotations(true)
|
||||
.backcolor(getBackgroundColor(diagram))
|
||||
.margin(calculateDiagramMargin(diagram))
|
||||
.metadata(fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null)
|
||||
.seed(diagram.seed())
|
||||
.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.titledDiagram = titledDiagram;
|
||||
this.fileFormatOption = fileFormatOption;
|
||||
this.seed = seed;
|
||||
this.param = param;
|
||||
|
||||
if (drawable instanceof TextBlockBackcolored) {
|
||||
@ -180,6 +180,11 @@ public class ImageBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ImageBuilder seed(long seed) {
|
||||
this.seed = seed;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ImageBuilder status(int status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
@ -198,7 +203,7 @@ public class ImageBuilder {
|
||||
final AnnotatedWorker annotatedWorker = new AnnotatedWorker(titledDiagram, skinParam, stringBounder);
|
||||
udrawable = annotatedWorker.addAdd((TextBlock) udrawable);
|
||||
}
|
||||
final ImageData imageData = writeImageTOBEMOVED(fileFormatOption, seed, os);
|
||||
final ImageData imageData = writeImageTOBEMOVED(fileFormatOption, os);
|
||||
((ImageDataAbstract) imageData).setStatus(status);
|
||||
return imageData;
|
||||
}
|
||||
@ -210,11 +215,11 @@ public class ImageBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
public ImageData writeImageTOBEMOVED(long seed, OutputStream os) throws IOException {
|
||||
return writeImageTOBEMOVED(fileFormatOption, seed, os);
|
||||
public ImageData writeImageTOBEMOVED(OutputStream os) throws IOException {
|
||||
return writeImageTOBEMOVED(fileFormatOption, os);
|
||||
}
|
||||
|
||||
public ImageData writeImageTOBEMOVED(FileFormatOption fileFormatOption, long seed, OutputStream os)
|
||||
public ImageData writeImageTOBEMOVED(FileFormatOption fileFormatOption, OutputStream os)
|
||||
throws IOException {
|
||||
final FileFormat fileFormat = fileFormatOption.getFileFormat();
|
||||
if (fileFormat == FileFormat.MJPEG) {
|
||||
@ -222,10 +227,10 @@ public class ImageBuilder {
|
||||
} else if (fileFormat == FileFormat.ANIMATED_GIF) {
|
||||
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 {
|
||||
Dimension2D dim = getFinalDimension(fileFormatOption.getDefaultStringBounder(param.getSvgCharSizeHack()));
|
||||
double dx = 0;
|
||||
@ -238,7 +243,7 @@ public class ImageBuilder {
|
||||
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;
|
||||
|
||||
final UStroke borderStroke = param.getBorderStroke();
|
||||
@ -361,7 +366,7 @@ public class ImageBuilder {
|
||||
|
||||
private Image getAviImage(AffineTransformation affineTransform) throws IOException {
|
||||
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();
|
||||
|
||||
final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
@ -370,7 +375,7 @@ public class ImageBuilder {
|
||||
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) {
|
||||
final ColorMapper colorMapper = param.getColorMapper();
|
||||
final double scaleFactor = (param.getScale() == null ? 1
|
||||
@ -382,7 +387,7 @@ public class ImageBuilder {
|
||||
option.getWatermark());
|
||||
case SVG:
|
||||
return createUGraphicSVG(colorMapper, scaleFactor, dim, backcolor, option.getSvgLinkTarget(),
|
||||
option.getHoverColor(), seed, option.getPreserveAspectRatio(), param.getlengthAdjust());
|
||||
option.getHoverColor(), option.getPreserveAspectRatio(), param.getlengthAdjust());
|
||||
case EPS:
|
||||
return new UGraphicEps(colorMapper, EpsStrategy.getDefault2());
|
||||
case EPS_TEXT:
|
||||
@ -408,7 +413,7 @@ public class ImageBuilder {
|
||||
}
|
||||
|
||||
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) {
|
||||
HColor backColor = HColorUtils.WHITE;
|
||||
if (suggested instanceof HColorSimple) {
|
||||
|
@ -77,7 +77,7 @@ public class WBSDiagram extends UmlDiagram {
|
||||
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||
throws IOException {
|
||||
|
||||
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption, seed())
|
||||
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption)
|
||||
.write(os);
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ public class WireDiagram extends UmlDiagram {
|
||||
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||
throws IOException {
|
||||
|
||||
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption, seed())
|
||||
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption)
|
||||
.write(os);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user