1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-12-23 11:29: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) { 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) { 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); 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) final protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException { 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()); fileFormatOption = fileFormatOption.withTikzFontDistortion(getSkinParam().getTikzFontDistortion());
if (fileFormatOption.getFileFormat() == FileFormat.PDF) { if (fileFormatOption.getFileFormat() == FileFormat.PDF) {

View File

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