1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-26 14:56:28 +00:00

Pass a StringBounder into UGraphicSvg

This commit is contained in:
matthew16550 2021-10-03 04:54:37 +11:00
parent 2b2a47b9f0
commit d3a4fc6fe0
3 changed files with 7 additions and 10 deletions

View File

@ -47,7 +47,6 @@ import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.EmptyImageBuilder; import net.sourceforge.plantuml.EmptyImageBuilder;
import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.SpriteContainerEmpty; import net.sourceforge.plantuml.SpriteContainerEmpty;
import net.sourceforge.plantuml.SvgCharSizeHack;
import net.sourceforge.plantuml.api.ImageDataSimple; import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
@ -89,7 +88,7 @@ public class GraphicsSudoku {
public ImageData writeImageSvg(OutputStream os) throws IOException { public ImageData writeImageSvg(OutputStream os) throws IOException {
final UGraphicSvg ug = new UGraphicSvg(HColorUtils.WHITE, true, new Dimension2DDouble(0, 0), final UGraphicSvg ug = new UGraphicSvg(HColorUtils.WHITE, true, new Dimension2DDouble(0, 0),
new ColorMapperIdentity(), false, 1.0, null, null, 0, "none", SvgCharSizeHack.NO_HACK, new ColorMapperIdentity(), false, 1.0, null, null, 0, "none", FileFormat.SVG.getDefaultStringBounder(),
LengthAdjust.defaultValue()); LengthAdjust.defaultValue());
drawInternal(ug); drawInternal(ug);
ug.writeToStream(os, null, -1); // dpi param is not used ug.writeToStream(os, null, -1); // dpi param is not used

View File

@ -438,11 +438,10 @@ public class ImageBuilder {
final String hoverPathColorRGB = getHoverPathColorRGB(); final String hoverPathColorRGB = getHoverPathColorRGB();
final LengthAdjust lengthAdjust = skinParam == null ? LengthAdjust.defaultValue() : skinParam.getlengthAdjust(); final LengthAdjust lengthAdjust = skinParam == null ? LengthAdjust.defaultValue() : skinParam.getlengthAdjust();
final String preserveAspectRatio = getPreserveAspectRatio(); final String preserveAspectRatio = getPreserveAspectRatio();
final SvgCharSizeHack svgCharSizeHack = getSvgCharSizeHack();
final boolean svgDimensionStyle = skinParam == null || skinParam.svgDimensionStyle(); final boolean svgDimensionStyle = skinParam == null || skinParam.svgDimensionStyle();
final String svgLinkTarget = getSvgLinkTarget(); final String svgLinkTarget = getSvgLinkTarget();
final UGraphicSvg ug = new UGraphicSvg(backcolor, svgDimensionStyle, dim, colorMapper, false, scaleFactor, final UGraphicSvg ug = new UGraphicSvg(backcolor, svgDimensionStyle, dim, colorMapper, false, scaleFactor,
svgLinkTarget, hoverPathColorRGB, seed, preserveAspectRatio, svgCharSizeHack, lengthAdjust); svgLinkTarget, hoverPathColorRGB, seed, preserveAspectRatio, FileFormat.SVG.getDefaultStringBounder(getSvgCharSizeHack()), lengthAdjust);
return ug; return ug;
} }

View File

@ -40,9 +40,8 @@ import java.io.OutputStream;
import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerException;
import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.SvgCharSizeHack;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.posimo.DotPath; import net.sourceforge.plantuml.posimo.DotPath;
import net.sourceforge.plantuml.svg.LengthAdjust; import net.sourceforge.plantuml.svg.LengthAdjust;
import net.sourceforge.plantuml.svg.SvgGraphics; import net.sourceforge.plantuml.svg.SvgGraphics;
@ -88,10 +87,10 @@ public class UGraphicSvg extends AbstractUGraphic<SvgGraphics> implements ClipCo
public UGraphicSvg(HColor defaultBackground, boolean svgDimensionStyle, Dimension2D minDim, ColorMapper colorMapper, public UGraphicSvg(HColor defaultBackground, boolean svgDimensionStyle, Dimension2D minDim, ColorMapper colorMapper,
boolean textAsPath, double scale, String linkTarget, String hover, long seed, String preserveAspectRatio, boolean textAsPath, double scale, String linkTarget, String hover, long seed, String preserveAspectRatio,
SvgCharSizeHack charSizeHack, LengthAdjust lengthAdjust) { StringBounder stringBounder, LengthAdjust lengthAdjust) {
this(defaultBackground, minDim, colorMapper, new SvgGraphics(colorMapper.toSvg(defaultBackground), this(defaultBackground, minDim, colorMapper, new SvgGraphics(colorMapper.toSvg(defaultBackground),
svgDimensionStyle, minDim, scale, hover, seed, preserveAspectRatio, lengthAdjust), textAsPath, svgDimensionStyle, minDim, scale, hover, seed, preserveAspectRatio, lengthAdjust), textAsPath,
linkTarget, charSizeHack); linkTarget, stringBounder);
if (defaultBackground instanceof HColorGradient) { if (defaultBackground instanceof HColorGradient) {
final SvgGraphics svg = getGraphicObject(); final SvgGraphics svg = getGraphicObject();
svg.paintBackcolorGradient(colorMapper, (HColorGradient) defaultBackground); svg.paintBackcolorGradient(colorMapper, (HColorGradient) defaultBackground);
@ -114,8 +113,8 @@ public class UGraphicSvg extends AbstractUGraphic<SvgGraphics> implements ClipCo
} }
private UGraphicSvg(HColor defaultBackground, Dimension2D minDim, ColorMapper colorMapper, SvgGraphics svg, private UGraphicSvg(HColor defaultBackground, Dimension2D minDim, ColorMapper colorMapper, SvgGraphics svg,
boolean textAsPath, String linkTarget, SvgCharSizeHack charSizeHack) { boolean textAsPath, String linkTarget, StringBounder stringBounder) {
super(defaultBackground, colorMapper, FileFormat.SVG.getDefaultStringBounder(charSizeHack), svg); super(defaultBackground, colorMapper, stringBounder, svg);
this.textAsPath2 = textAsPath; this.textAsPath2 = textAsPath;
this.target = linkTarget; this.target = linkTarget;
register(); register();