1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-12-22 19:09:03 +00:00
This commit is contained in:
Arnaud Roques 2021-09-20 18:38:45 +02:00
commit 3d7aa78624
20 changed files with 91 additions and 188 deletions

View File

@ -80,7 +80,7 @@
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.20.2</version>
<version>3.21.0</version>
<scope>test</scope>
</dependency>
<dependency>

View File

@ -34,18 +34,18 @@
*/
package net.sourceforge.plantuml.braille;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.plainPngBuilder;
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;
import net.sourceforge.plantuml.ugraphic.ClipContainer;
import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
import net.sourceforge.plantuml.ugraphic.UEllipse;
import net.sourceforge.plantuml.ugraphic.UGraphic2;
import net.sourceforge.plantuml.ugraphic.UImage;
import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.UPath;
@ -55,10 +55,8 @@ import net.sourceforge.plantuml.ugraphic.UText;
import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.plainPngBuilder;
// https://www.branah.com/braille-translator
public class UGraphicBraille extends AbstractUGraphic<BrailleGrid> implements ClipContainer, UGraphic2 {
public class UGraphicBraille extends AbstractUGraphic<BrailleGrid> implements ClipContainer {
public static final int QUANTA = 4;
private final BrailleGrid grid;
@ -99,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();
}
@ -117,11 +115,8 @@ public class UGraphicBraille extends AbstractUGraphic<BrailleGrid> implements Cl
registerDriver(UCenteredCharacter.class, new DriverCenteredCharacterBraille());
}
public StringBounder getStringBounder() {
return FileFormat.BRAILLE_PNG.getDefaultStringBounder();
}
public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException {
@Override
public void writeToStream(OutputStream os, String metadata, int dpi) throws IOException {
plainPngBuilder(new BrailleDrawer(getGraphicObject()))
.metadata(metadata)
.write(os);

View File

@ -43,6 +43,9 @@ import net.sourceforge.plantuml.ugraphic.UShape;
import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import java.io.IOException;
import java.io.OutputStream;
public abstract class UGraphicDelegator implements UGraphic {
final private UGraphic ug;
@ -105,4 +108,8 @@ public abstract class UGraphicDelegator implements UGraphic {
return ug.getDefaultBackground();
}
}
@Override
public void writeToStream(OutputStream os, String metadata, int dpi) throws IOException {
ug.writeToStream(os, metadata, dpi);
}
}

View File

@ -93,7 +93,7 @@ public class GraphicsSudoku {
new ColorMapperIdentity(), false, 1.0, null, null, 0, "none", SvgCharSizeHack.NO_HACK,
LengthAdjust.defaultValue());
drawInternal(ug);
ug.createXml(os, null);
ug.writeToStream(os, null, -1); // dpi param is not used
return ImageDataSimple.ok();
}
@ -101,7 +101,7 @@ public class GraphicsSudoku {
final UGraphicTikz ug = new UGraphicTikz(HColorUtils.WHITE, new ColorMapperIdentity(), 1,
fileFormat == FileFormat.LATEX, TikzFontDistortion.getDefault());
drawInternal(ug);
ug.createTikz(os);
ug.writeToStream(os, null, -1); // dpi param is not used
return ImageDataSimple.ok();
}

View File

@ -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();
}

View File

@ -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;
}

View File

@ -175,8 +175,8 @@ public class FontChecker {
public void drawU(UGraphic ug) {
ug = ug.apply(HColorUtils.BLACK);
ug.draw(new URectangle(dim - 1, dim - 1));
if (ug instanceof UGraphic2) {
ug = (UGraphic2) ug.apply(new UTranslate(dim / 3, 2 * dim / 3));
if (!(ug instanceof LimitFinder)) {
ug = ug.apply(new UTranslate(dim / 3, 2 * dim / 3));
final UText text = new UText("" + c, FontConfiguration.blackBlueTrue(font));
ug.draw(text);
}

View File

@ -273,16 +273,15 @@ public class ImageBuilder {
final Scale scale = titledDiagram == null ? null : titledDiagram.getScale();
final double scaleFactor = (scale == null ? 1 : scale.getScale(dim.getWidth(), dim.getHeight())) * getDpi()
/ 96.0;
final UGraphic2 ug = createUGraphic(fileFormatOption, dim, animationArg, dx, dy, scaleFactor);
UGraphic ug2 = ug;
UGraphic ug = createUGraphic(fileFormatOption, dim, animationArg, dx, dy, scaleFactor);
maybeDrawBorder(ug, dim);
if (randomPixel) {
drawRandomPoint(ug2);
drawRandomPoint(ug);
}
ug2 = handwritten(ug2.apply(new UTranslate(margin.getLeft(), margin.getTop())));
udrawable.drawU(ug2);
ug2.flushUg();
ug.writeImageTOBEMOVED(os, metadata, 96);
ug = handwritten(ug.apply(new UTranslate(margin.getLeft(), margin.getTop())));
udrawable.drawU(ug);
ug.flushUg();
ug.writeToStream(os, metadata, 96);
os.flush();
if (ug instanceof UGraphicG2d) {
@ -403,7 +402,7 @@ public class ImageBuilder {
return ImageIO.read(baos.toByteArray());
}
private UGraphic2 createUGraphic(FileFormatOption option, final Dimension2D dim, Animation animationArg, double dx,
private UGraphic createUGraphic(FileFormatOption option, final Dimension2D dim, Animation animationArg, double dx,
double dy, double scaleFactor) {
switch (option.getFileFormat()) {
case PNG:
@ -435,7 +434,7 @@ public class ImageBuilder {
}
}
private UGraphic2 createUGraphicSVG(double scaleFactor, Dimension2D dim) {
private UGraphic createUGraphicSVG(double scaleFactor, Dimension2D dim) {
final String hoverPathColorRGB = getHoverPathColorRGB();
final LengthAdjust lengthAdjust = skinParam == null ? LengthAdjust.defaultValue() : skinParam.getlengthAdjust();
final String preserveAspectRatio = getPreserveAspectRatio();
@ -448,7 +447,7 @@ public class ImageBuilder {
}
private UGraphic2 createUGraphicPNG(double scaleFactor, final Dimension2D dim, Animation affineTransforms,
private UGraphic createUGraphicPNG(double scaleFactor, final Dimension2D dim, Animation affineTransforms,
double dx, double dy, String watermark) {
Color backColor = getDefaultBackColor();

View File

@ -40,6 +40,9 @@ import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import java.io.IOException;
import java.io.OutputStream;
public interface UGraphic {
public StringBounder getStringBounder();
@ -66,4 +69,5 @@ public interface UGraphic {
public HColor getDefaultBackground();
public void writeToStream(OutputStream os, String metadata, int dpi) throws IOException;
}

View File

@ -1,44 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.ugraphic;
import java.io.IOException;
import java.io.OutputStream;
public interface UGraphic2 extends UGraphic {
public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException;
}

View File

@ -41,6 +41,9 @@ import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
import java.io.IOException;
import java.io.OutputStream;
public abstract class UGraphicNo implements UGraphic {
private final StringBounder stringBounder;
@ -104,7 +107,12 @@ public abstract class UGraphicNo implements UGraphic {
public boolean matchesProperty(String propertyName) {
return false;
}
@Override
public void writeToStream(OutputStream os, String metadata, int dpi) throws IOException {
throw new UnsupportedOperationException();
}
//
// Internal things
//

View File

@ -40,11 +40,10 @@ 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;
public class UGraphicNull extends AbstractUGraphic<String> implements EnsureVisible, UGraphic2 {
public class UGraphicNull extends AbstractUGraphic<String> implements EnsureVisible {
@Override
protected AbstractCommonUGraphic copyUGraphic() {
@ -56,14 +55,11 @@ public class UGraphicNull extends AbstractUGraphic<String> implements EnsureVisi
}
public UGraphicNull() {
super(HColorUtils.BLACK, new ColorMapperIdentity(), "foo");
super(HColorUtils.BLACK, new ColorMapperIdentity(), FileFormat.PNG.getDefaultStringBounder(), "foo");
}
public StringBounder getStringBounder() {
return FileFormat.PNG.getDefaultStringBounder();
}
public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException {
@Override
public void writeToStream(OutputStream os, String metadata, int dpi) throws IOException {
}
public void ensureVisible(double x, double y) {

View File

@ -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;
@ -55,7 +54,6 @@ import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
import net.sourceforge.plantuml.ugraphic.UComment;
import net.sourceforge.plantuml.ugraphic.UEllipse;
import net.sourceforge.plantuml.ugraphic.UEmpty;
import net.sourceforge.plantuml.ugraphic.UGraphic2;
import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.UPath;
import net.sourceforge.plantuml.ugraphic.UPolygon;
@ -70,7 +68,7 @@ import net.sourceforge.plantuml.ugraphic.color.HColorMiddle;
import net.sourceforge.plantuml.ugraphic.color.HColorSimple;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
public class UGraphicDebug extends AbstractCommonUGraphic implements ClipContainer, UGraphic2 {
public class UGraphicDebug extends AbstractCommonUGraphic implements ClipContainer {
private final List<String> output;
private final double scaleFactor;
@ -100,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;
@ -110,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);
@ -280,7 +274,8 @@ public class UGraphicDebug extends AbstractCommonUGraphic implements ClipContain
return color.getClass().getSimpleName() + " " + new Date();
}
public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException {
@Override
public void writeToStream(OutputStream os, String metadata, int dpi) throws IOException {
print(os, "DPI: " + dpi);
print(os, "dimension: " + pointd(dim.getWidth(), dim.getHeight()));
print(os, "scaleFactor: " + String.format(Locale.US, "%.4f", scaleFactor));

View File

@ -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;
@ -49,7 +48,6 @@ import net.sourceforge.plantuml.ugraphic.AbstractUGraphic;
import net.sourceforge.plantuml.ugraphic.ClipContainer;
import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
import net.sourceforge.plantuml.ugraphic.UEllipse;
import net.sourceforge.plantuml.ugraphic.UGraphic2;
import net.sourceforge.plantuml.ugraphic.UImage;
import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.UPath;
@ -59,9 +57,7 @@ import net.sourceforge.plantuml.ugraphic.UText;
import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
import net.sourceforge.plantuml.ugraphic.color.HColor;
public class UGraphicEps extends AbstractUGraphic<EpsGraphics> implements ClipContainer, UGraphic2 {
private final StringBounder stringBounder;
public class UGraphicEps extends AbstractUGraphic<EpsGraphics> implements ClipContainer {
private final EpsStrategy strategyTOBEREMOVED;
@ -72,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);
}
@ -82,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);
}
@ -112,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);
}
@ -135,7 +125,8 @@ public class UGraphicEps extends AbstractUGraphic<EpsGraphics> implements ClipCo
getGraphicObject().closeLink();
}
public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException {
@Override
public void writeToStream(OutputStream os, String metadata, int dpi) throws IOException {
os.write(getEPSCode().getBytes());
}

View File

@ -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;
@ -64,7 +63,6 @@ import net.sourceforge.plantuml.ugraphic.UChange;
import net.sourceforge.plantuml.ugraphic.UClip;
import net.sourceforge.plantuml.ugraphic.UEllipse;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UGraphic2;
import net.sourceforge.plantuml.ugraphic.UImage;
import net.sourceforge.plantuml.ugraphic.UImageSvg;
import net.sourceforge.plantuml.ugraphic.ULine;
@ -76,7 +74,7 @@ import net.sourceforge.plantuml.ugraphic.UText;
import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
import net.sourceforge.plantuml.ugraphic.color.HColor;
public class UGraphicG2d extends AbstractUGraphic<Graphics2D> implements EnsureVisible, UGraphic2 {
public class UGraphicG2d extends AbstractUGraphic<Graphics2D> implements EnsureVisible {
private BufferedImage bufferedImage;
@ -124,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) {
@ -157,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();
@ -214,7 +205,8 @@ public class UGraphicG2d extends AbstractUGraphic<Graphics2D> implements EnsureV
return getGraphicObject();
}
public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException {
@Override
public void writeToStream(OutputStream os, String metadata, int dpi) throws IOException {
final BufferedImage im = getBufferedImage();
PngIO.write(im, os, metadata, dpi);
}

View File

@ -38,11 +38,9 @@ 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;
import net.sourceforge.plantuml.ugraphic.UGraphic2;
import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.UPolygon;
import net.sourceforge.plantuml.ugraphic.URectangle;
@ -50,9 +48,7 @@ import net.sourceforge.plantuml.ugraphic.UText;
import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
import net.sourceforge.plantuml.ugraphic.color.HColor;
public class UGraphicHtml5 extends AbstractUGraphic<Html5Drawer> implements ClipContainer, UGraphic2 {
private final StringBounder stringBounder;
public class UGraphicHtml5 extends AbstractUGraphic<Html5Drawer> implements ClipContainer {
@Override
protected AbstractCommonUGraphic copyUGraphic() {
@ -60,8 +56,7 @@ public class UGraphicHtml5 extends AbstractUGraphic<Html5Drawer> implements Clip
}
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());
@ -74,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();
// }
@ -86,7 +77,8 @@ public class UGraphicHtml5 extends AbstractUGraphic<Html5Drawer> implements Clip
return getGraphicObject().generateHtmlCode();
}
public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException {
@Override
public void writeToStream(OutputStream os, String metadata, int dpi) throws IOException {
os.write(generateHtmlCode().getBytes());
}

View File

@ -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;
@ -54,7 +53,6 @@ import net.sourceforge.plantuml.ugraphic.ClipContainer;
import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
import net.sourceforge.plantuml.ugraphic.UComment;
import net.sourceforge.plantuml.ugraphic.UEllipse;
import net.sourceforge.plantuml.ugraphic.UGraphic2;
import net.sourceforge.plantuml.ugraphic.UGroupType;
import net.sourceforge.plantuml.ugraphic.UImage;
import net.sourceforge.plantuml.ugraphic.UImageSvg;
@ -68,9 +66,8 @@ import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorGradient;
public class UGraphicSvg extends AbstractUGraphic<SvgGraphics> implements ClipContainer, UGraphic2 {
public class UGraphicSvg extends AbstractUGraphic<SvgGraphics> implements ClipContainer {
private final StringBounder stringBounder;
private final boolean textAsPath2;
private final String target;
@ -85,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();
@ -120,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();
@ -149,11 +144,8 @@ public class UGraphicSvg extends AbstractUGraphic<SvgGraphics> implements ClipCo
return this.getGraphicObject();
}
public StringBounder getStringBounder() {
return stringBounder;
}
public void createXml(OutputStream os, String metadata) throws IOException {
@Override
public void writeToStream(OutputStream os, String metadata, int dpi) throws IOException {
try {
if (metadata != null) {
getGraphicObject().addComment(metadata);
@ -184,10 +176,6 @@ public class UGraphicSvg extends AbstractUGraphic<SvgGraphics> implements ClipCo
getGraphicObject().closeLink();
}
public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException {
createXml(os, metadata);
}
@Override
protected void drawComment(UComment comment) {
getGraphicObject().addComment(comment.getComment());

View File

@ -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;
@ -49,7 +48,6 @@ import net.sourceforge.plantuml.ugraphic.AbstractUGraphic;
import net.sourceforge.plantuml.ugraphic.ClipContainer;
import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
import net.sourceforge.plantuml.ugraphic.UEllipse;
import net.sourceforge.plantuml.ugraphic.UGraphic2;
import net.sourceforge.plantuml.ugraphic.UImage;
import net.sourceforge.plantuml.ugraphic.UImageSvg;
import net.sourceforge.plantuml.ugraphic.ULine;
@ -60,16 +58,14 @@ import net.sourceforge.plantuml.ugraphic.UText;
import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
import net.sourceforge.plantuml.ugraphic.color.HColor;
public class UGraphicTikz extends AbstractUGraphic<TikzGraphics> implements ClipContainer, UGraphic2 {
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();
}
@ -88,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();
}
@ -107,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());
}
@ -119,11 +110,8 @@ public class UGraphicTikz extends AbstractUGraphic<TikzGraphics> implements Clip
getGraphicObject().closeLink();
}
public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException {
createTikz(os);
}
public void createTikz(OutputStream os) throws IOException {
@Override
public void writeToStream(OutputStream os, String metadata, int dpi) throws IOException {
getGraphicObject().createData(os);
}

View File

@ -47,18 +47,16 @@ 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;
import net.sourceforge.plantuml.ugraphic.UGraphic2;
import net.sourceforge.plantuml.ugraphic.UImage;
import net.sourceforge.plantuml.ugraphic.UShape;
import net.sourceforge.plantuml.ugraphic.UText;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
public class UGraphicTxt extends AbstractCommonUGraphic implements ClipContainer, UGraphic2 {
public class UGraphicTxt extends AbstractCommonUGraphic implements ClipContainer {
private final UmlCharArea charArea;
@ -73,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) {
@ -116,7 +110,8 @@ public class UGraphicTxt extends AbstractCommonUGraphic implements ClipContainer
return new Dimension2DDouble(0, 0);
}
public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException {
@Override
public void writeToStream(OutputStream os, String metadata, int dpi) throws IOException {
final PrintStream ps = SecurityUtils.createPrintStream(os, true, UTF_8);
getCharArea().print(ps);
}

View File

@ -39,14 +39,12 @@ 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;
import net.sourceforge.plantuml.ugraphic.ClipContainer;
import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
import net.sourceforge.plantuml.ugraphic.UEllipse;
import net.sourceforge.plantuml.ugraphic.UGraphic2;
import net.sourceforge.plantuml.ugraphic.UImage;
import net.sourceforge.plantuml.ugraphic.UImageSvg;
import net.sourceforge.plantuml.ugraphic.ULine;
@ -57,17 +55,14 @@ import net.sourceforge.plantuml.ugraphic.UText;
import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
import net.sourceforge.plantuml.ugraphic.color.HColor;
public class UGraphicVdx extends AbstractUGraphic<VisioGraphics> implements ClipContainer, UGraphic2 {
private final StringBounder stringBounder;
public class UGraphicVdx extends AbstractUGraphic<VisioGraphics> implements ClipContainer {
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();
}
@ -84,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());
@ -102,15 +96,8 @@ public class UGraphicVdx extends AbstractUGraphic<VisioGraphics> implements Clip
registerDriver(UCenteredCharacter.class, new DriverNoneVdx());
}
public StringBounder getStringBounder() {
return stringBounder;
}
public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException {
createVsd(os);
}
public void createVsd(OutputStream os) throws IOException {
@Override
public void writeToStream(OutputStream os, String metadata, int dpi) throws IOException {
getGraphicObject().createVsd(os);
}