mirror of
https://github.com/octoleo/plantuml.git
synced 2024-12-28 04:55:58 +00:00
Merge pull request #678 from matthew16550/AbstractCommonUGraphic.stringBounder
Add AbstractCommonUGraphic.stringBounder field
This commit is contained in:
commit
c3a3744850
@ -40,7 +40,6 @@ import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import net.sourceforge.plantuml.FileFormat;
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.posimo.DotPath;
|
||||
import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
|
||||
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) {
|
||||
super(defaultBackground, colorMapper, grid);
|
||||
super(defaultBackground, colorMapper, FileFormat.BRAILLE_PNG.getDefaultStringBounder(), grid);
|
||||
this.grid = grid;
|
||||
register();
|
||||
}
|
||||
@ -116,10 +115,6 @@ public class UGraphicBraille extends AbstractUGraphic<BrailleGrid> implements Cl
|
||||
registerDriver(UCenteredCharacter.class, new DriverCenteredCharacterBraille());
|
||||
}
|
||||
|
||||
public StringBounder getStringBounder() {
|
||||
return FileFormat.BRAILLE_PNG.getDefaultStringBounder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(OutputStream os, String metadata, int dpi) throws IOException {
|
||||
plainPngBuilder(new BrailleDrawer(getGraphicObject()))
|
||||
|
@ -38,6 +38,7 @@ package net.sourceforge.plantuml.ugraphic;
|
||||
import java.util.Objects;
|
||||
|
||||
import net.sourceforge.plantuml.Url;
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
|
||||
import net.sourceforge.plantuml.ugraphic.color.ColorMapperTransparentWrapper;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||
@ -52,6 +53,7 @@ public abstract class AbstractCommonUGraphic implements UGraphic {
|
||||
private HColor color = null;
|
||||
private boolean enlargeClip = false;
|
||||
|
||||
private final StringBounder stringBounder;
|
||||
private UTranslate translate = new UTranslate();
|
||||
|
||||
private final ColorMapper colorMapper;
|
||||
@ -107,15 +109,17 @@ public abstract class AbstractCommonUGraphic implements UGraphic {
|
||||
this.enlargeClip = true;
|
||||
}
|
||||
|
||||
public AbstractCommonUGraphic(HColor defaultBackground, ColorMapper colorMapper) {
|
||||
public AbstractCommonUGraphic(HColor defaultBackground, ColorMapper colorMapper, StringBounder stringBounder) {
|
||||
this.colorMapper = colorMapper;
|
||||
this.defaultBackground = defaultBackground;
|
||||
this.stringBounder = stringBounder;
|
||||
}
|
||||
|
||||
protected AbstractCommonUGraphic(AbstractCommonUGraphic other) {
|
||||
this.defaultBackground = other.defaultBackground;
|
||||
this.enlargeClip = other.enlargeClip;
|
||||
this.colorMapper = other.colorMapper;
|
||||
this.stringBounder = other.stringBounder;
|
||||
this.translate = other.translate;
|
||||
this.clip = other.clip;
|
||||
|
||||
@ -158,6 +162,11 @@ public abstract class AbstractCommonUGraphic implements UGraphic {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringBounder getStringBounder() {
|
||||
return stringBounder;
|
||||
}
|
||||
|
||||
final protected double getTranslateX() {
|
||||
return translate.getDx();
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
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.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>>();
|
||||
|
||||
public AbstractUGraphic(HColor defaultBackground, ColorMapper colorMapper, O graphic) {
|
||||
super(Objects.requireNonNull(defaultBackground), colorMapper);
|
||||
public AbstractUGraphic(HColor defaultBackground, ColorMapper colorMapper, StringBounder stringBounder, O graphic) {
|
||||
super(Objects.requireNonNull(defaultBackground), colorMapper, stringBounder);
|
||||
this.graphic = graphic;
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,6 @@ import java.io.OutputStream;
|
||||
|
||||
import net.sourceforge.plantuml.EnsureVisible;
|
||||
import net.sourceforge.plantuml.FileFormat;
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
|
||||
|
||||
@ -56,11 +55,7 @@ public class UGraphicNull extends AbstractUGraphic<String> implements EnsureVisi
|
||||
}
|
||||
|
||||
public UGraphicNull() {
|
||||
super(HColorUtils.BLACK, new ColorMapperIdentity(), "foo");
|
||||
}
|
||||
|
||||
public StringBounder getStringBounder() {
|
||||
return FileFormat.PNG.getDefaultStringBounder();
|
||||
super(HColorUtils.BLACK, new ColorMapperIdentity(), FileFormat.PNG.getDefaultStringBounder(), "foo");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -47,7 +47,6 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.posimo.DotPath;
|
||||
import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
|
||||
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,
|
||||
String preserveAspectRatio) {
|
||||
super(HColorUtils.WHITE, new ColorMapperIdentity());
|
||||
super(HColorUtils.WHITE, new ColorMapperIdentity(), new StringBounderDebug());
|
||||
this.output = new ArrayList<>();
|
||||
this.scaleFactor = scaleFactor;
|
||||
this.dim = dim;
|
||||
@ -109,10 +108,6 @@ public class UGraphicDebug extends AbstractCommonUGraphic implements ClipContain
|
||||
this.preserveAspectRatio = preserveAspectRatio;
|
||||
}
|
||||
|
||||
public StringBounder getStringBounder() {
|
||||
return new StringBounderDebug();
|
||||
}
|
||||
|
||||
public void draw(UShape shape) {
|
||||
if (shape instanceof ULine) {
|
||||
outLine((ULine) shape);
|
||||
|
@ -41,7 +41,6 @@ import net.sourceforge.plantuml.FileFormat;
|
||||
import net.sourceforge.plantuml.Url;
|
||||
import net.sourceforge.plantuml.eps.EpsGraphics;
|
||||
import net.sourceforge.plantuml.eps.EpsStrategy;
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.graphic.UDrawable;
|
||||
import net.sourceforge.plantuml.posimo.DotPath;
|
||||
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 {
|
||||
|
||||
private final StringBounder stringBounder;
|
||||
|
||||
private final EpsStrategy strategyTOBEREMOVED;
|
||||
|
||||
@Override
|
||||
@ -71,7 +68,6 @@ public class UGraphicEps extends AbstractUGraphic<EpsGraphics> implements ClipCo
|
||||
|
||||
protected UGraphicEps(UGraphicEps other) {
|
||||
super(other);
|
||||
this.stringBounder = other.stringBounder;
|
||||
this.strategyTOBEREMOVED = other.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) {
|
||||
super(defaultBackground, colorMapper, eps);
|
||||
super(defaultBackground, colorMapper, FileFormat.PNG.getDefaultStringBounder(), eps);
|
||||
this.strategyTOBEREMOVED = strategy;
|
||||
this.stringBounder = FileFormat.PNG.getDefaultStringBounder();
|
||||
register(strategy);
|
||||
}
|
||||
|
||||
@ -111,10 +106,6 @@ public class UGraphicEps extends AbstractUGraphic<EpsGraphics> implements ClipCo
|
||||
return this.getGraphicObject();
|
||||
}
|
||||
|
||||
public StringBounder getStringBounder() {
|
||||
return stringBounder;
|
||||
}
|
||||
|
||||
public void drawEps(String eps, double x, double y) {
|
||||
this.getGraphicObject().drawEps(eps, x, y);
|
||||
}
|
||||
|
@ -53,7 +53,6 @@ import net.sourceforge.plantuml.EnsureVisible;
|
||||
import net.sourceforge.plantuml.FileFormat;
|
||||
import net.sourceforge.plantuml.Url;
|
||||
import net.sourceforge.plantuml.anim.AffineTransformation;
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.png.PngIO;
|
||||
import net.sourceforge.plantuml.posimo.DotPath;
|
||||
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,
|
||||
AffineTransformation affineTransform, double dx, double dy) {
|
||||
super(defaultBackground, colorMapper, g2d);
|
||||
super(defaultBackground, colorMapper, FileFormat.PNG.getDefaultStringBounder(), g2d);
|
||||
this.hasAffineTransform = affineTransform != null;
|
||||
this.dpiFactor = dpiFactor;
|
||||
if (dpiFactor != 1.0) {
|
||||
@ -156,13 +155,6 @@ public class UGraphicG2d extends AbstractUGraphic<Graphics2D> implements EnsureV
|
||||
registerDriver(UCenteredCharacter.class, new DriverCenteredCharacterG2d());
|
||||
}
|
||||
|
||||
public StringBounder getStringBounder() {
|
||||
// if (hasAffineTransform) {
|
||||
// return TextBlockUtils.getDummyStringBounder();
|
||||
// }
|
||||
return FileFormat.PNG.getDefaultStringBounder();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void beforeDraw() {
|
||||
super.beforeDraw();
|
||||
|
@ -38,7 +38,6 @@ import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import net.sourceforge.plantuml.FileFormat;
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.AbstractUGraphic;
|
||||
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 {
|
||||
|
||||
private final StringBounder stringBounder;
|
||||
|
||||
@Override
|
||||
protected AbstractCommonUGraphic copyUGraphic() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public UGraphicHtml5(HColor defaultBackground, ColorMapper colorMapper) {
|
||||
super(defaultBackground, colorMapper, new Html5Drawer());
|
||||
stringBounder = FileFormat.PNG.getDefaultStringBounder();
|
||||
super(defaultBackground, colorMapper, FileFormat.PNG.getDefaultStringBounder(), new Html5Drawer());
|
||||
registerDriver(URectangle.class, new DriverRectangleHtml5(this));
|
||||
// registerDriver(UText.class, new DriverTextEps(imDummy, this, strategy));
|
||||
registerDriver(UText.class, new DriverNopHtml5());
|
||||
@ -73,10 +69,6 @@ public class UGraphicHtml5 extends AbstractUGraphic<Html5Drawer> implements Clip
|
||||
// registerDriver(DotPath.class, new DriverDotPathEps());
|
||||
}
|
||||
|
||||
public StringBounder getStringBounder() {
|
||||
return stringBounder;
|
||||
}
|
||||
|
||||
// public void close() {
|
||||
// getEpsGraphics().close();
|
||||
// }
|
||||
|
@ -44,7 +44,6 @@ import net.sourceforge.plantuml.FileFormat;
|
||||
import net.sourceforge.plantuml.SvgCharSizeHack;
|
||||
import net.sourceforge.plantuml.TikzFontDistortion;
|
||||
import net.sourceforge.plantuml.Url;
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.posimo.DotPath;
|
||||
import net.sourceforge.plantuml.svg.LengthAdjust;
|
||||
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 {
|
||||
|
||||
private final StringBounder stringBounder;
|
||||
private final boolean textAsPath2;
|
||||
private final String target;
|
||||
|
||||
@ -84,7 +82,6 @@ public class UGraphicSvg extends AbstractUGraphic<SvgGraphics> implements ClipCo
|
||||
|
||||
private UGraphicSvg(UGraphicSvg other) {
|
||||
super(other);
|
||||
this.stringBounder = other.stringBounder;
|
||||
this.textAsPath2 = other.textAsPath2;
|
||||
this.target = other.target;
|
||||
register();
|
||||
@ -119,8 +116,7 @@ public class UGraphicSvg extends AbstractUGraphic<SvgGraphics> implements ClipCo
|
||||
|
||||
private UGraphicSvg(HColor defaultBackground, Dimension2D minDim, ColorMapper colorMapper, SvgGraphics svg,
|
||||
boolean textAsPath, String linkTarget, SvgCharSizeHack charSizeHack) {
|
||||
super(defaultBackground, colorMapper, svg);
|
||||
this.stringBounder = FileFormat.SVG.getDefaultStringBounder(TikzFontDistortion.getDefault(), charSizeHack);
|
||||
super(defaultBackground, colorMapper, FileFormat.SVG.getDefaultStringBounder(TikzFontDistortion.getDefault(), charSizeHack), svg);
|
||||
this.textAsPath2 = textAsPath;
|
||||
this.target = linkTarget;
|
||||
register();
|
||||
@ -148,10 +144,6 @@ public class UGraphicSvg extends AbstractUGraphic<SvgGraphics> implements ClipCo
|
||||
return this.getGraphicObject();
|
||||
}
|
||||
|
||||
public StringBounder getStringBounder() {
|
||||
return stringBounder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(OutputStream os, String metadata, int dpi) throws IOException {
|
||||
try {
|
||||
|
@ -41,7 +41,6 @@ import net.sourceforge.plantuml.FileFormat;
|
||||
import net.sourceforge.plantuml.TikzFontDistortion;
|
||||
import net.sourceforge.plantuml.Url;
|
||||
import net.sourceforge.plantuml.creole.legacy.AtomText;
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.posimo.DotPath;
|
||||
import net.sourceforge.plantuml.tikz.TikzGraphics;
|
||||
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 {
|
||||
|
||||
private final StringBounder stringBounder;
|
||||
private final TikzFontDistortion tikzFontDistortion;
|
||||
|
||||
private UGraphicTikz(HColor defaultBackground, ColorMapper colorMapper, TikzGraphics tikz,
|
||||
TikzFontDistortion tikzFontDistortion) {
|
||||
super(defaultBackground, colorMapper, tikz);
|
||||
super(defaultBackground, colorMapper, FileFormat.LATEX.getDefaultStringBounder(tikzFontDistortion), tikz);
|
||||
this.tikzFontDistortion = tikzFontDistortion;
|
||||
this.stringBounder = FileFormat.LATEX.getDefaultStringBounder(tikzFontDistortion);
|
||||
register();
|
||||
|
||||
}
|
||||
@ -87,7 +84,6 @@ public class UGraphicTikz extends AbstractUGraphic<TikzGraphics> implements Clip
|
||||
private UGraphicTikz(UGraphicTikz other) {
|
||||
super(other);
|
||||
this.tikzFontDistortion = other.tikzFontDistortion;
|
||||
this.stringBounder = other.stringBounder;
|
||||
register();
|
||||
}
|
||||
|
||||
@ -106,10 +102,6 @@ public class UGraphicTikz extends AbstractUGraphic<TikzGraphics> implements Clip
|
||||
registerDriver(UCenteredCharacter.class, new DriverCenteredCharacterTikz2());
|
||||
}
|
||||
|
||||
public StringBounder getStringBounder() {
|
||||
return stringBounder;
|
||||
}
|
||||
|
||||
public void startUrl(Url url) {
|
||||
getGraphicObject().openLink(url.getUrl(), url.getTooltip());
|
||||
}
|
||||
|
@ -47,7 +47,6 @@ import net.sourceforge.plantuml.asciiart.TranslatedCharArea;
|
||||
import net.sourceforge.plantuml.asciiart.UmlCharArea;
|
||||
import net.sourceforge.plantuml.asciiart.UmlCharAreaImpl;
|
||||
import net.sourceforge.plantuml.graphic.FontStyle;
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.security.SecurityUtils;
|
||||
import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.ClipContainer;
|
||||
@ -72,14 +71,10 @@ public class UGraphicTxt extends AbstractCommonUGraphic implements ClipContainer
|
||||
}
|
||||
|
||||
public UGraphicTxt() {
|
||||
super(HColorUtils.BLACK, new ColorMapperIdentity());
|
||||
super(HColorUtils.BLACK, new ColorMapperIdentity(), new TextStringBounder());
|
||||
this.charArea = new UmlCharAreaImpl();
|
||||
}
|
||||
|
||||
public StringBounder getStringBounder() {
|
||||
return new TextStringBounder();
|
||||
}
|
||||
|
||||
public void draw(UShape shape) {
|
||||
// final UClip clip = getClip();
|
||||
if (shape instanceof UText) {
|
||||
|
@ -39,7 +39,6 @@ import java.io.OutputStream;
|
||||
|
||||
import net.sourceforge.plantuml.FileFormat;
|
||||
import net.sourceforge.plantuml.creole.legacy.AtomText;
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.posimo.DotPath;
|
||||
import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
|
||||
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 {
|
||||
|
||||
private final StringBounder stringBounder;
|
||||
|
||||
public double dpiFactor() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
private UGraphicVdx(HColor defaultBackground, ColorMapper colorMapper, VisioGraphics visio) {
|
||||
super(defaultBackground, colorMapper, visio);
|
||||
this.stringBounder = FileFormat.PNG.getDefaultStringBounder();
|
||||
super(defaultBackground, colorMapper, FileFormat.PNG.getDefaultStringBounder(), visio);
|
||||
register();
|
||||
|
||||
}
|
||||
@ -83,13 +79,12 @@ public class UGraphicVdx extends AbstractUGraphic<VisioGraphics> implements Clip
|
||||
|
||||
private UGraphicVdx(UGraphicVdx other) {
|
||||
super(other);
|
||||
this.stringBounder = other.stringBounder;
|
||||
register();
|
||||
}
|
||||
|
||||
private void register() {
|
||||
registerDriver(URectangle.class, new DriverRectangleVdx());
|
||||
registerDriver(UText.class, new DriverTextVdx(stringBounder));
|
||||
registerDriver(UText.class, new DriverTextVdx(getStringBounder()));
|
||||
registerDriver(AtomText.class, new DriverNoneVdx());
|
||||
registerDriver(ULine.class, new DriverLineVdx());
|
||||
registerDriver(UPolygon.class, new DriverPolygonVdx());
|
||||
@ -101,10 +96,6 @@ public class UGraphicVdx extends AbstractUGraphic<VisioGraphics> implements Clip
|
||||
registerDriver(UCenteredCharacter.class, new DriverNoneVdx());
|
||||
}
|
||||
|
||||
public StringBounder getStringBounder() {
|
||||
return stringBounder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(OutputStream os, String metadata, int dpi) throws IOException {
|
||||
getGraphicObject().createVsd(os);
|
||||
|
Loading…
Reference in New Issue
Block a user