1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-12-23 03:19:06 +00:00

Move preserveAspectRatio & svgLinkTarget calculation to ImageBuilder class.

This commit is contained in:
matthew16550 2021-03-29 01:33:48 +11:00
parent 8496f821ca
commit 13a62c3884
3 changed files with 10 additions and 10 deletions

View File

@ -65,11 +65,11 @@ public final class FileFormatOption implements Serializable {
}
public FileFormatOption(FileFormat fileFormat) {
this(fileFormat, null, true, false, "_top", false, null, TikzFontDistortion.getDefault(), 1.0, "none", null);
this(fileFormat, null, true, false, null, false, null, TikzFontDistortion.getDefault(), 1.0, null, null);
}
public FileFormatOption(FileFormat fileFormat, boolean withMetadata) {
this(fileFormat, null, withMetadata, false, "_top", false, null, TikzFontDistortion.getDefault(), 1.0, "none",
this(fileFormat, null, withMetadata, false, null, false, null, TikzFontDistortion.getDefault(), 1.0, null,
null);
}

View File

@ -134,10 +134,6 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot
final protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException {
if (fileFormatOption.getSvgLinkTarget() == null || fileFormatOption.getSvgLinkTarget().equals("_top")) {
fileFormatOption = fileFormatOption.withSvgLinkTarget(getSkinParam().getSvgLinkTarget());
}
fileFormatOption = fileFormatOption.withPreserveAspectRatio(getSkinParam().getPreserveAspectRatio());
fileFormatOption = fileFormatOption.withTikzFontDistortion(getSkinParam().getTikzFontDistortion());
if (fileFormatOption.getFileFormat() == FileFormat.PDF) {

View File

@ -123,11 +123,13 @@ public class ImageBuilder {
private UDrawable udrawable;
private ClockwiseTopRightBottomLeft margin = ClockwiseTopRightBottomLeft.none();
private String metadata;
private String preserveAspectRatio;
private Scale scale;
private long seed = 42;
private int status = 0;
private SvgCharSizeHack svgCharSizeHack = SvgCharSizeHack.NO_HACK;
private boolean svgDimensionStyle = true;
private String svgLinkTarget;
private TitledDiagram titledDiagram;
private boolean randomPixel;
private String warningOrError;
@ -220,10 +222,14 @@ public class ImageBuilder {
lengthAdjust = skinParam.getlengthAdjust();
margin = calculateMargin(diagram);
metadata = fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null;
preserveAspectRatio = (fileFormatOption.getPreserveAspectRatio() != null)
? fileFormatOption.getPreserveAspectRatio() : skinParam.getPreserveAspectRatio();
scale = diagram.getScale();
seed = diagram.seed();
svgCharSizeHack = skinParam;
svgDimensionStyle = skinParam.svgDimensionStyle();
svgLinkTarget = (fileFormatOption.getSvgLinkTarget() != null)
? fileFormatOption.getSvgLinkTarget() : skinParam.getSvgLinkTarget();
titledDiagram = diagram;
warningOrError = diagram.getWarningOrError();
return this;
@ -399,8 +405,7 @@ public class ImageBuilder {
return createUGraphicPNG(scaleFactor, dim, animationArg, dx, dy,
option.getWatermark());
case SVG:
return createUGraphicSVG(scaleFactor, dim, option.getSvgLinkTarget(),
option.getPreserveAspectRatio());
return createUGraphicSVG(scaleFactor, dim);
case EPS:
return new UGraphicEps(colorMapper, EpsStrategy.getDefault2());
case EPS_TEXT:
@ -425,8 +430,7 @@ public class ImageBuilder {
}
}
private UGraphic2 createUGraphicSVG(double scaleFactor, Dimension2D dim,
String svgLinkTarget, String preserveAspectRatio) {
private UGraphic2 createUGraphicSVG(double scaleFactor, Dimension2D dim) {
HColor backColor = HColorUtils.WHITE; // TODO simplify backcolor some more in a future PR
if (this.backcolor instanceof HColorSimple) {
backColor = this.backcolor;