1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-30 00:33:53 +00:00

Infer svgCharSizeHack instead of storing it in ImageBuilder.

This commit is contained in:
matthew16550 2021-04-07 18:27:57 +10:00
parent 66c7f9a92f
commit 9c865ab58b

View File

@ -127,7 +127,6 @@ public class ImageBuilder {
private long seed = 42; private long seed = 42;
private ISkinParam skinParam; private ISkinParam skinParam;
private int status = 0; private int status = 0;
private SvgCharSizeHack svgCharSizeHack = SvgCharSizeHack.NO_HACK;
private boolean svgDimensionStyle = true; private boolean svgDimensionStyle = true;
private String svgLinkTarget; private String svgLinkTarget;
private TitledDiagram titledDiagram; private TitledDiagram titledDiagram;
@ -209,6 +208,10 @@ public class ImageBuilder {
return this; return this;
} }
private SvgCharSizeHack getSvgCharSizeHack() {
return skinParam == null ? SvgCharSizeHack.NO_HACK : skinParam;
}
public ImageBuilder warningOrError(String warningOrError) { public ImageBuilder warningOrError(String warningOrError) {
this.warningOrError = warningOrError; this.warningOrError = warningOrError;
return this; return this;
@ -229,7 +232,6 @@ public class ImageBuilder {
preserveAspectRatio = calculatePreserveAspectRatio(fileFormatOption, skinParam); preserveAspectRatio = calculatePreserveAspectRatio(fileFormatOption, skinParam);
scale = diagram.getScale(); scale = diagram.getScale();
seed = diagram.seed(); seed = diagram.seed();
svgCharSizeHack = skinParam;
svgDimensionStyle = skinParam.svgDimensionStyle(); svgDimensionStyle = skinParam.svgDimensionStyle();
svgLinkTarget = (fileFormatOption.getSvgLinkTarget() != null) svgLinkTarget = (fileFormatOption.getSvgLinkTarget() != null)
? fileFormatOption.getSvgLinkTarget() : skinParam.getSvgLinkTarget(); ? fileFormatOption.getSvgLinkTarget() : skinParam.getSvgLinkTarget();
@ -267,7 +269,7 @@ public class ImageBuilder {
private ImageData writeImageInternal(FileFormatOption fileFormatOption, OutputStream os, private ImageData writeImageInternal(FileFormatOption fileFormatOption, OutputStream os,
Animation animationArg) throws IOException { Animation animationArg) throws IOException {
Dimension2D dim = (dimension == null) Dimension2D dim = (dimension == null)
? getFinalDimension(fileFormatOption.getDefaultStringBounder(svgCharSizeHack)) : dimension; ? getFinalDimension(fileFormatOption.getDefaultStringBounder(getSvgCharSizeHack())) : dimension;
double dx = 0; double dx = 0;
double dy = 0; double dy = 0;
if (animationArg != null) { if (animationArg != null) {
@ -334,7 +336,7 @@ public class ImageBuilder {
} }
private Dimension2D getFinalDimension() { private Dimension2D getFinalDimension() {
return getFinalDimension(fileFormatOption.getDefaultStringBounder(svgCharSizeHack)); return getFinalDimension(fileFormatOption.getDefaultStringBounder(getSvgCharSizeHack()));
} }
private UGraphic handwritten(UGraphic ug) { private UGraphic handwritten(UGraphic ug) {
@ -443,6 +445,7 @@ public class ImageBuilder {
} }
private UGraphic2 createUGraphicSVG(double scaleFactor, Dimension2D dim) { private UGraphic2 createUGraphicSVG(double scaleFactor, Dimension2D dim) {
final SvgCharSizeHack svgCharSizeHack = getSvgCharSizeHack();
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;