1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-23 05:22:05 +00:00

Add AbstractCommonUGraphic.stringBounder field

This commit is contained in:
matthew16550 2021-09-20 22:56:11 +10:00
parent 1da60d24dc
commit 16f9d973fa
12 changed files with 24 additions and 84 deletions

View File

@ -40,7 +40,6 @@ import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.posimo.DotPath; import net.sourceforge.plantuml.posimo.DotPath;
import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic; import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
import net.sourceforge.plantuml.ugraphic.AbstractUGraphic; import net.sourceforge.plantuml.ugraphic.AbstractUGraphic;
@ -98,7 +97,7 @@ public class UGraphicBraille extends AbstractUGraphic<BrailleGrid> implements Cl
// } // }
private UGraphicBraille(HColor defaultBackground, ColorMapper colorMapper, BrailleGrid grid) { private UGraphicBraille(HColor defaultBackground, ColorMapper colorMapper, BrailleGrid grid) {
super(defaultBackground, colorMapper, grid); super(defaultBackground, colorMapper, FileFormat.BRAILLE_PNG.getDefaultStringBounder(), grid);
this.grid = grid; this.grid = grid;
register(); register();
} }
@ -116,10 +115,6 @@ public class UGraphicBraille extends AbstractUGraphic<BrailleGrid> implements Cl
registerDriver(UCenteredCharacter.class, new DriverCenteredCharacterBraille()); registerDriver(UCenteredCharacter.class, new DriverCenteredCharacterBraille());
} }
public StringBounder getStringBounder() {
return FileFormat.BRAILLE_PNG.getDefaultStringBounder();
}
@Override @Override
public void writeToStream(OutputStream os, String metadata, int dpi) throws IOException { public void writeToStream(OutputStream os, String metadata, int dpi) throws IOException {
plainPngBuilder(new BrailleDrawer(getGraphicObject())) plainPngBuilder(new BrailleDrawer(getGraphicObject()))

View File

@ -38,6 +38,7 @@ package net.sourceforge.plantuml.ugraphic;
import java.util.Objects; import java.util.Objects;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.ugraphic.color.ColorMapper; import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperTransparentWrapper; import net.sourceforge.plantuml.ugraphic.color.ColorMapperTransparentWrapper;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
@ -52,6 +53,7 @@ public abstract class AbstractCommonUGraphic implements UGraphic {
private HColor color = null; private HColor color = null;
private boolean enlargeClip = false; private boolean enlargeClip = false;
private final StringBounder stringBounder;
private UTranslate translate = new UTranslate(); private UTranslate translate = new UTranslate();
private final ColorMapper colorMapper; private final ColorMapper colorMapper;
@ -107,15 +109,17 @@ public abstract class AbstractCommonUGraphic implements UGraphic {
this.enlargeClip = true; this.enlargeClip = true;
} }
public AbstractCommonUGraphic(HColor defaultBackground, ColorMapper colorMapper) { public AbstractCommonUGraphic(HColor defaultBackground, ColorMapper colorMapper, StringBounder stringBounder) {
this.colorMapper = colorMapper; this.colorMapper = colorMapper;
this.defaultBackground = defaultBackground; this.defaultBackground = defaultBackground;
this.stringBounder = stringBounder;
} }
protected AbstractCommonUGraphic(AbstractCommonUGraphic other) { protected AbstractCommonUGraphic(AbstractCommonUGraphic other) {
this.defaultBackground = other.defaultBackground; this.defaultBackground = other.defaultBackground;
this.enlargeClip = other.enlargeClip; this.enlargeClip = other.enlargeClip;
this.colorMapper = other.colorMapper; this.colorMapper = other.colorMapper;
this.stringBounder = other.stringBounder;
this.translate = other.translate; this.translate = other.translate;
this.clip = other.clip; this.clip = other.clip;
@ -158,6 +162,11 @@ public abstract class AbstractCommonUGraphic implements UGraphic {
}; };
} }
@Override
public StringBounder getStringBounder() {
return stringBounder;
}
final protected double getTranslateX() { final protected double getTranslateX() {
return translate.getDx(); return translate.getDx();
} }

View File

@ -40,6 +40,7 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
import net.sourceforge.plantuml.graphic.SpecialText; import net.sourceforge.plantuml.graphic.SpecialText;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.ugraphic.color.ColorMapper; import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
@ -49,8 +50,8 @@ public abstract class AbstractUGraphic<O> extends AbstractCommonUGraphic {
private final Map<Class<? extends UShape>, UDriver<O>> drivers = new HashMap<Class<? extends UShape>, UDriver<O>>(); private final Map<Class<? extends UShape>, UDriver<O>> drivers = new HashMap<Class<? extends UShape>, UDriver<O>>();
public AbstractUGraphic(HColor defaultBackground, ColorMapper colorMapper, O graphic) { public AbstractUGraphic(HColor defaultBackground, ColorMapper colorMapper, StringBounder stringBounder, O graphic) {
super(Objects.requireNonNull(defaultBackground), colorMapper); super(Objects.requireNonNull(defaultBackground), colorMapper, stringBounder);
this.graphic = graphic; this.graphic = graphic;
} }

View File

@ -40,7 +40,6 @@ import java.io.OutputStream;
import net.sourceforge.plantuml.EnsureVisible; import net.sourceforge.plantuml.EnsureVisible;
import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity; import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils; import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
@ -56,11 +55,7 @@ public class UGraphicNull extends AbstractUGraphic<String> implements EnsureVisi
} }
public UGraphicNull() { public UGraphicNull() {
super(HColorUtils.BLACK, new ColorMapperIdentity(), "foo"); super(HColorUtils.BLACK, new ColorMapperIdentity(), FileFormat.PNG.getDefaultStringBounder(), "foo");
}
public StringBounder getStringBounder() {
return FileFormat.PNG.getDefaultStringBounder();
} }
@Override @Override

View File

@ -47,7 +47,6 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.posimo.DotPath; import net.sourceforge.plantuml.posimo.DotPath;
import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic; import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
import net.sourceforge.plantuml.ugraphic.ClipContainer; import net.sourceforge.plantuml.ugraphic.ClipContainer;
@ -99,7 +98,7 @@ public class UGraphicDebug extends AbstractCommonUGraphic implements ClipContain
public UGraphicDebug(double scaleFactor, Dimension2D dim, String svgLinkTarget, String hoverPathColorRGB, long seed, public UGraphicDebug(double scaleFactor, Dimension2D dim, String svgLinkTarget, String hoverPathColorRGB, long seed,
String preserveAspectRatio) { String preserveAspectRatio) {
super(HColorUtils.WHITE, new ColorMapperIdentity()); super(HColorUtils.WHITE, new ColorMapperIdentity(), new StringBounderDebug());
this.output = new ArrayList<>(); this.output = new ArrayList<>();
this.scaleFactor = scaleFactor; this.scaleFactor = scaleFactor;
this.dim = dim; this.dim = dim;
@ -109,10 +108,6 @@ public class UGraphicDebug extends AbstractCommonUGraphic implements ClipContain
this.preserveAspectRatio = preserveAspectRatio; this.preserveAspectRatio = preserveAspectRatio;
} }
public StringBounder getStringBounder() {
return new StringBounderDebug();
}
public void draw(UShape shape) { public void draw(UShape shape) {
if (shape instanceof ULine) { if (shape instanceof ULine) {
outLine((ULine) shape); outLine((ULine) shape);

View File

@ -41,7 +41,6 @@ import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.eps.EpsGraphics; import net.sourceforge.plantuml.eps.EpsGraphics;
import net.sourceforge.plantuml.eps.EpsStrategy; import net.sourceforge.plantuml.eps.EpsStrategy;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.posimo.DotPath; import net.sourceforge.plantuml.posimo.DotPath;
import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic; import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
@ -60,8 +59,6 @@ import net.sourceforge.plantuml.ugraphic.color.HColor;
public class UGraphicEps extends AbstractUGraphic<EpsGraphics> implements ClipContainer { public class UGraphicEps extends AbstractUGraphic<EpsGraphics> implements ClipContainer {
private final StringBounder stringBounder;
private final EpsStrategy strategyTOBEREMOVED; private final EpsStrategy strategyTOBEREMOVED;
@Override @Override
@ -71,7 +68,6 @@ public class UGraphicEps extends AbstractUGraphic<EpsGraphics> implements ClipCo
protected UGraphicEps(UGraphicEps other) { protected UGraphicEps(UGraphicEps other) {
super(other); super(other);
this.stringBounder = other.stringBounder;
this.strategyTOBEREMOVED = other.strategyTOBEREMOVED; this.strategyTOBEREMOVED = other.strategyTOBEREMOVED;
register(strategyTOBEREMOVED); register(strategyTOBEREMOVED);
} }
@ -81,9 +77,8 @@ public class UGraphicEps extends AbstractUGraphic<EpsGraphics> implements ClipCo
} }
private UGraphicEps(HColor defaultBackground, ColorMapper colorMapper, EpsStrategy strategy, EpsGraphics eps) { private UGraphicEps(HColor defaultBackground, ColorMapper colorMapper, EpsStrategy strategy, EpsGraphics eps) {
super(defaultBackground, colorMapper, eps); super(defaultBackground, colorMapper, FileFormat.PNG.getDefaultStringBounder(), eps);
this.strategyTOBEREMOVED = strategy; this.strategyTOBEREMOVED = strategy;
this.stringBounder = FileFormat.PNG.getDefaultStringBounder();
register(strategy); register(strategy);
} }
@ -111,10 +106,6 @@ public class UGraphicEps extends AbstractUGraphic<EpsGraphics> implements ClipCo
return this.getGraphicObject(); return this.getGraphicObject();
} }
public StringBounder getStringBounder() {
return stringBounder;
}
public void drawEps(String eps, double x, double y) { public void drawEps(String eps, double x, double y) {
this.getGraphicObject().drawEps(eps, x, y); this.getGraphicObject().drawEps(eps, x, y);
} }

View File

@ -53,7 +53,6 @@ import net.sourceforge.plantuml.EnsureVisible;
import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.anim.AffineTransformation; import net.sourceforge.plantuml.anim.AffineTransformation;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.png.PngIO; import net.sourceforge.plantuml.png.PngIO;
import net.sourceforge.plantuml.posimo.DotPath; import net.sourceforge.plantuml.posimo.DotPath;
import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic; import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
@ -123,7 +122,7 @@ public class UGraphicG2d extends AbstractUGraphic<Graphics2D> implements EnsureV
public UGraphicG2d(HColor defaultBackground, ColorMapper colorMapper, Graphics2D g2d, double dpiFactor, public UGraphicG2d(HColor defaultBackground, ColorMapper colorMapper, Graphics2D g2d, double dpiFactor,
AffineTransformation affineTransform, double dx, double dy) { AffineTransformation affineTransform, double dx, double dy) {
super(defaultBackground, colorMapper, g2d); super(defaultBackground, colorMapper, FileFormat.PNG.getDefaultStringBounder(), g2d);
this.hasAffineTransform = affineTransform != null; this.hasAffineTransform = affineTransform != null;
this.dpiFactor = dpiFactor; this.dpiFactor = dpiFactor;
if (dpiFactor != 1.0) { if (dpiFactor != 1.0) {
@ -156,13 +155,6 @@ public class UGraphicG2d extends AbstractUGraphic<Graphics2D> implements EnsureV
registerDriver(UCenteredCharacter.class, new DriverCenteredCharacterG2d()); registerDriver(UCenteredCharacter.class, new DriverCenteredCharacterG2d());
} }
public StringBounder getStringBounder() {
// if (hasAffineTransform) {
// return TextBlockUtils.getDummyStringBounder();
// }
return FileFormat.PNG.getDefaultStringBounder();
}
@Override @Override
protected void beforeDraw() { protected void beforeDraw() {
super.beforeDraw(); super.beforeDraw();

View File

@ -38,7 +38,6 @@ import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic; import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
import net.sourceforge.plantuml.ugraphic.AbstractUGraphic; import net.sourceforge.plantuml.ugraphic.AbstractUGraphic;
import net.sourceforge.plantuml.ugraphic.ClipContainer; import net.sourceforge.plantuml.ugraphic.ClipContainer;
@ -51,16 +50,13 @@ import net.sourceforge.plantuml.ugraphic.color.HColor;
public class UGraphicHtml5 extends AbstractUGraphic<Html5Drawer> implements ClipContainer { public class UGraphicHtml5 extends AbstractUGraphic<Html5Drawer> implements ClipContainer {
private final StringBounder stringBounder;
@Override @Override
protected AbstractCommonUGraphic copyUGraphic() { protected AbstractCommonUGraphic copyUGraphic() {
return this; return this;
} }
public UGraphicHtml5(HColor defaultBackground, ColorMapper colorMapper) { public UGraphicHtml5(HColor defaultBackground, ColorMapper colorMapper) {
super(defaultBackground, colorMapper, new Html5Drawer()); super(defaultBackground, colorMapper, FileFormat.PNG.getDefaultStringBounder(), new Html5Drawer());
stringBounder = FileFormat.PNG.getDefaultStringBounder();
registerDriver(URectangle.class, new DriverRectangleHtml5(this)); registerDriver(URectangle.class, new DriverRectangleHtml5(this));
// registerDriver(UText.class, new DriverTextEps(imDummy, this, strategy)); // registerDriver(UText.class, new DriverTextEps(imDummy, this, strategy));
registerDriver(UText.class, new DriverNopHtml5()); registerDriver(UText.class, new DriverNopHtml5());
@ -73,10 +69,6 @@ public class UGraphicHtml5 extends AbstractUGraphic<Html5Drawer> implements Clip
// registerDriver(DotPath.class, new DriverDotPathEps()); // registerDriver(DotPath.class, new DriverDotPathEps());
} }
public StringBounder getStringBounder() {
return stringBounder;
}
// public void close() { // public void close() {
// getEpsGraphics().close(); // getEpsGraphics().close();
// } // }

View File

@ -44,7 +44,6 @@ import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.SvgCharSizeHack; import net.sourceforge.plantuml.SvgCharSizeHack;
import net.sourceforge.plantuml.TikzFontDistortion; import net.sourceforge.plantuml.TikzFontDistortion;
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;
@ -69,7 +68,6 @@ import net.sourceforge.plantuml.ugraphic.color.HColorGradient;
public class UGraphicSvg extends AbstractUGraphic<SvgGraphics> implements ClipContainer { public class UGraphicSvg extends AbstractUGraphic<SvgGraphics> implements ClipContainer {
private final StringBounder stringBounder;
private final boolean textAsPath2; private final boolean textAsPath2;
private final String target; private final String target;
@ -84,7 +82,6 @@ public class UGraphicSvg extends AbstractUGraphic<SvgGraphics> implements ClipCo
private UGraphicSvg(UGraphicSvg other) { private UGraphicSvg(UGraphicSvg other) {
super(other); super(other);
this.stringBounder = other.stringBounder;
this.textAsPath2 = other.textAsPath2; this.textAsPath2 = other.textAsPath2;
this.target = other.target; this.target = other.target;
register(); register();
@ -119,8 +116,7 @@ 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, SvgCharSizeHack charSizeHack) {
super(defaultBackground, colorMapper, svg); super(defaultBackground, colorMapper, FileFormat.SVG.getDefaultStringBounder(TikzFontDistortion.getDefault(), charSizeHack), svg);
this.stringBounder = FileFormat.SVG.getDefaultStringBounder(TikzFontDistortion.getDefault(), charSizeHack);
this.textAsPath2 = textAsPath; this.textAsPath2 = textAsPath;
this.target = linkTarget; this.target = linkTarget;
register(); register();
@ -148,10 +144,6 @@ public class UGraphicSvg extends AbstractUGraphic<SvgGraphics> implements ClipCo
return this.getGraphicObject(); return this.getGraphicObject();
} }
public StringBounder getStringBounder() {
return stringBounder;
}
@Override @Override
public void writeToStream(OutputStream os, String metadata, int dpi) throws IOException { public void writeToStream(OutputStream os, String metadata, int dpi) throws IOException {
try { try {

View File

@ -41,7 +41,6 @@ import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.TikzFontDistortion; import net.sourceforge.plantuml.TikzFontDistortion;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.creole.legacy.AtomText; import net.sourceforge.plantuml.creole.legacy.AtomText;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.posimo.DotPath; import net.sourceforge.plantuml.posimo.DotPath;
import net.sourceforge.plantuml.tikz.TikzGraphics; import net.sourceforge.plantuml.tikz.TikzGraphics;
import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic; import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
@ -61,14 +60,12 @@ import net.sourceforge.plantuml.ugraphic.color.HColor;
public class UGraphicTikz extends AbstractUGraphic<TikzGraphics> implements ClipContainer { public class UGraphicTikz extends AbstractUGraphic<TikzGraphics> implements ClipContainer {
private final StringBounder stringBounder;
private final TikzFontDistortion tikzFontDistortion; private final TikzFontDistortion tikzFontDistortion;
private UGraphicTikz(HColor defaultBackground, ColorMapper colorMapper, TikzGraphics tikz, private UGraphicTikz(HColor defaultBackground, ColorMapper colorMapper, TikzGraphics tikz,
TikzFontDistortion tikzFontDistortion) { TikzFontDistortion tikzFontDistortion) {
super(defaultBackground, colorMapper, tikz); super(defaultBackground, colorMapper, FileFormat.LATEX.getDefaultStringBounder(tikzFontDistortion), tikz);
this.tikzFontDistortion = tikzFontDistortion; this.tikzFontDistortion = tikzFontDistortion;
this.stringBounder = FileFormat.LATEX.getDefaultStringBounder(tikzFontDistortion);
register(); register();
} }
@ -87,7 +84,6 @@ public class UGraphicTikz extends AbstractUGraphic<TikzGraphics> implements Clip
private UGraphicTikz(UGraphicTikz other) { private UGraphicTikz(UGraphicTikz other) {
super(other); super(other);
this.tikzFontDistortion = other.tikzFontDistortion; this.tikzFontDistortion = other.tikzFontDistortion;
this.stringBounder = other.stringBounder;
register(); register();
} }
@ -106,10 +102,6 @@ public class UGraphicTikz extends AbstractUGraphic<TikzGraphics> implements Clip
registerDriver(UCenteredCharacter.class, new DriverCenteredCharacterTikz2()); registerDriver(UCenteredCharacter.class, new DriverCenteredCharacterTikz2());
} }
public StringBounder getStringBounder() {
return stringBounder;
}
public void startUrl(Url url) { public void startUrl(Url url) {
getGraphicObject().openLink(url.getUrl(), url.getTooltip()); getGraphicObject().openLink(url.getUrl(), url.getTooltip());
} }

View File

@ -47,7 +47,6 @@ import net.sourceforge.plantuml.asciiart.TranslatedCharArea;
import net.sourceforge.plantuml.asciiart.UmlCharArea; import net.sourceforge.plantuml.asciiart.UmlCharArea;
import net.sourceforge.plantuml.asciiart.UmlCharAreaImpl; import net.sourceforge.plantuml.asciiart.UmlCharAreaImpl;
import net.sourceforge.plantuml.graphic.FontStyle; import net.sourceforge.plantuml.graphic.FontStyle;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.security.SecurityUtils; import net.sourceforge.plantuml.security.SecurityUtils;
import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic; import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
import net.sourceforge.plantuml.ugraphic.ClipContainer; import net.sourceforge.plantuml.ugraphic.ClipContainer;
@ -72,14 +71,10 @@ public class UGraphicTxt extends AbstractCommonUGraphic implements ClipContainer
} }
public UGraphicTxt() { public UGraphicTxt() {
super(HColorUtils.BLACK, new ColorMapperIdentity()); super(HColorUtils.BLACK, new ColorMapperIdentity(), new TextStringBounder());
this.charArea = new UmlCharAreaImpl(); this.charArea = new UmlCharAreaImpl();
} }
public StringBounder getStringBounder() {
return new TextStringBounder();
}
public void draw(UShape shape) { public void draw(UShape shape) {
// final UClip clip = getClip(); // final UClip clip = getClip();
if (shape instanceof UText) { if (shape instanceof UText) {

View File

@ -39,7 +39,6 @@ import java.io.OutputStream;
import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.creole.legacy.AtomText; import net.sourceforge.plantuml.creole.legacy.AtomText;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.posimo.DotPath; import net.sourceforge.plantuml.posimo.DotPath;
import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic; import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
import net.sourceforge.plantuml.ugraphic.AbstractUGraphic; import net.sourceforge.plantuml.ugraphic.AbstractUGraphic;
@ -58,15 +57,12 @@ import net.sourceforge.plantuml.ugraphic.color.HColor;
public class UGraphicVdx extends AbstractUGraphic<VisioGraphics> implements ClipContainer { public class UGraphicVdx extends AbstractUGraphic<VisioGraphics> implements ClipContainer {
private final StringBounder stringBounder;
public double dpiFactor() { public double dpiFactor() {
return 1; return 1;
} }
private UGraphicVdx(HColor defaultBackground, ColorMapper colorMapper, VisioGraphics visio) { private UGraphicVdx(HColor defaultBackground, ColorMapper colorMapper, VisioGraphics visio) {
super(defaultBackground, colorMapper, visio); super(defaultBackground, colorMapper, FileFormat.PNG.getDefaultStringBounder(), visio);
this.stringBounder = FileFormat.PNG.getDefaultStringBounder();
register(); register();
} }
@ -83,13 +79,12 @@ public class UGraphicVdx extends AbstractUGraphic<VisioGraphics> implements Clip
private UGraphicVdx(UGraphicVdx other) { private UGraphicVdx(UGraphicVdx other) {
super(other); super(other);
this.stringBounder = other.stringBounder;
register(); register();
} }
private void register() { private void register() {
registerDriver(URectangle.class, new DriverRectangleVdx()); registerDriver(URectangle.class, new DriverRectangleVdx());
registerDriver(UText.class, new DriverTextVdx(stringBounder)); registerDriver(UText.class, new DriverTextVdx(getStringBounder()));
registerDriver(AtomText.class, new DriverNoneVdx()); registerDriver(AtomText.class, new DriverNoneVdx());
registerDriver(ULine.class, new DriverLineVdx()); registerDriver(ULine.class, new DriverLineVdx());
registerDriver(UPolygon.class, new DriverPolygonVdx()); registerDriver(UPolygon.class, new DriverPolygonVdx());
@ -101,10 +96,6 @@ public class UGraphicVdx extends AbstractUGraphic<VisioGraphics> implements Clip
registerDriver(UCenteredCharacter.class, new DriverNoneVdx()); registerDriver(UCenteredCharacter.class, new DriverNoneVdx());
} }
public StringBounder getStringBounder() {
return stringBounder;
}
@Override @Override
public void writeToStream(OutputStream os, String metadata, int dpi) throws IOException { public void writeToStream(OutputStream os, String metadata, int dpi) throws IOException {
getGraphicObject().createVsd(os); getGraphicObject().createVsd(os);