mirror of
https://github.com/octoleo/plantuml.git
synced 2025-04-07 02:31:51 +00:00
Merge pull request #734 from matthew16550/more-StringBounder-injection
Inject StringBounder into UGraphicBraille, UGraphicEps, UGraphicHtml5, UGraphicVdx
This commit is contained in:
commit
eb7c4c7a6d
@ -39,7 +39,7 @@ import static net.sourceforge.plantuml.ugraphic.ImageBuilder.plainPngBuilder;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
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.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;
|
||||||
@ -59,20 +59,19 @@ import net.sourceforge.plantuml.ugraphic.color.HColor;
|
|||||||
public class UGraphicBraille extends AbstractUGraphic<BrailleGrid> implements ClipContainer {
|
public class UGraphicBraille extends AbstractUGraphic<BrailleGrid> implements ClipContainer {
|
||||||
|
|
||||||
public static final int QUANTA = 4;
|
public static final int QUANTA = 4;
|
||||||
private final BrailleGrid grid;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AbstractCommonUGraphic copyUGraphic() {
|
protected AbstractCommonUGraphic copyUGraphic() {
|
||||||
return new UGraphicBraille(this);
|
return new UGraphicBraille(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UGraphicBraille(HColor defaultBackground, ColorMapper colorMapper) {
|
public UGraphicBraille(HColor defaultBackground, ColorMapper colorMapper, StringBounder stringBounder) {
|
||||||
this(defaultBackground, colorMapper, new BrailleGrid(QUANTA));
|
super(defaultBackground, colorMapper, stringBounder, new BrailleGrid(QUANTA));
|
||||||
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
private UGraphicBraille(UGraphicBraille other) {
|
private UGraphicBraille(UGraphicBraille other) {
|
||||||
super(other);
|
super(other);
|
||||||
this.grid = other.grid;
|
|
||||||
register();
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,12 +95,6 @@ public class UGraphicBraille extends AbstractUGraphic<BrailleGrid> implements Cl
|
|||||||
// svg.paintBackcolorGradient(mapper, gr);
|
// svg.paintBackcolorGradient(mapper, gr);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private UGraphicBraille(HColor defaultBackground, ColorMapper colorMapper, BrailleGrid grid) {
|
|
||||||
super(defaultBackground, colorMapper, FileFormat.BRAILLE_PNG.getDefaultStringBounder(), grid);
|
|
||||||
this.grid = grid;
|
|
||||||
register();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void register() {
|
private void register() {
|
||||||
ignoreShape(URectangle.class);
|
ignoreShape(URectangle.class);
|
||||||
registerDriver(URectangle.class, new DriverRectangleBraille(this));
|
registerDriver(URectangle.class, new DriverRectangleBraille(this));
|
||||||
|
@ -81,7 +81,7 @@ public class GraphicsSudoku {
|
|||||||
|
|
||||||
public ImageData writeImageEps(OutputStream os) throws IOException {
|
public ImageData writeImageEps(OutputStream os) throws IOException {
|
||||||
final UGraphicEps ug = new UGraphicEps(HColorUtils.WHITE, new ColorMapperIdentity(),
|
final UGraphicEps ug = new UGraphicEps(HColorUtils.WHITE, new ColorMapperIdentity(),
|
||||||
EpsStrategy.WITH_MACRO_AND_TEXT);
|
FileFormat.EPS_TEXT.getDefaultStringBounder(), EpsStrategy.WITH_MACRO_AND_TEXT);
|
||||||
drawInternal(ug);
|
drawInternal(ug);
|
||||||
os.write(ug.getEPSCode().getBytes());
|
os.write(ug.getEPSCode().getBytes());
|
||||||
return ImageDataSimple.ok();
|
return ImageDataSimple.ok();
|
||||||
|
@ -406,19 +406,19 @@ public class ImageBuilder {
|
|||||||
case SVG:
|
case SVG:
|
||||||
return createUGraphicSVG(scaleFactor, dim);
|
return createUGraphicSVG(scaleFactor, dim);
|
||||||
case EPS:
|
case EPS:
|
||||||
return new UGraphicEps(backcolor, colorMapper, EpsStrategy.getDefault2());
|
return new UGraphicEps(backcolor, colorMapper, stringBounder, EpsStrategy.getDefault2());
|
||||||
case EPS_TEXT:
|
case EPS_TEXT:
|
||||||
return new UGraphicEps(backcolor, colorMapper, EpsStrategy.WITH_MACRO_AND_TEXT);
|
return new UGraphicEps(backcolor, colorMapper, stringBounder, EpsStrategy.WITH_MACRO_AND_TEXT);
|
||||||
case HTML5:
|
case HTML5:
|
||||||
return new UGraphicHtml5(backcolor, colorMapper);
|
return new UGraphicHtml5(backcolor, colorMapper, stringBounder);
|
||||||
case VDX:
|
case VDX:
|
||||||
return new UGraphicVdx(backcolor, colorMapper);
|
return new UGraphicVdx(backcolor, colorMapper, stringBounder);
|
||||||
case LATEX:
|
case LATEX:
|
||||||
return new UGraphicTikz(backcolor, colorMapper, stringBounder, scaleFactor, true);
|
return new UGraphicTikz(backcolor, colorMapper, stringBounder, scaleFactor, true);
|
||||||
case LATEX_NO_PREAMBLE:
|
case LATEX_NO_PREAMBLE:
|
||||||
return new UGraphicTikz(backcolor, colorMapper, stringBounder, scaleFactor, false);
|
return new UGraphicTikz(backcolor, colorMapper, stringBounder, scaleFactor, false);
|
||||||
case BRAILLE_PNG:
|
case BRAILLE_PNG:
|
||||||
return new UGraphicBraille(backcolor, colorMapper);
|
return new UGraphicBraille(backcolor, colorMapper, stringBounder);
|
||||||
case UTXT:
|
case UTXT:
|
||||||
case ATXT:
|
case ATXT:
|
||||||
return new UGraphicTxt();
|
return new UGraphicTxt();
|
||||||
|
@ -41,6 +41,7 @@ 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;
|
||||||
@ -69,22 +70,18 @@ public class UGraphicEps extends AbstractUGraphic<EpsGraphics> implements ClipCo
|
|||||||
protected UGraphicEps(UGraphicEps other) {
|
protected UGraphicEps(UGraphicEps other) {
|
||||||
super(other);
|
super(other);
|
||||||
this.strategyTOBEREMOVED = other.strategyTOBEREMOVED;
|
this.strategyTOBEREMOVED = other.strategyTOBEREMOVED;
|
||||||
register(strategyTOBEREMOVED);
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
public UGraphicEps(HColor defaultBackground, ColorMapper colorMapper, EpsStrategy strategy) {
|
public UGraphicEps(HColor defaultBackground, ColorMapper colorMapper, StringBounder stringBounder, EpsStrategy strategy) {
|
||||||
this(defaultBackground, colorMapper, strategy, strategy.creatEpsGraphics());
|
super(defaultBackground, colorMapper, stringBounder, strategy.creatEpsGraphics());
|
||||||
}
|
|
||||||
|
|
||||||
private UGraphicEps(HColor defaultBackground, ColorMapper colorMapper, EpsStrategy strategy, EpsGraphics eps) {
|
|
||||||
super(defaultBackground, colorMapper, FileFormat.PNG.getDefaultStringBounder(), eps);
|
|
||||||
this.strategyTOBEREMOVED = strategy;
|
this.strategyTOBEREMOVED = strategy;
|
||||||
register(strategy);
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void register(EpsStrategy strategy) {
|
private void register() {
|
||||||
registerDriver(URectangle.class, new DriverRectangleEps(this));
|
registerDriver(URectangle.class, new DriverRectangleEps(this));
|
||||||
registerDriver(UText.class, new DriverTextEps(this, strategy));
|
registerDriver(UText.class, new DriverTextEps(this, strategyTOBEREMOVED));
|
||||||
registerDriver(ULine.class, new DriverLineEps(this));
|
registerDriver(ULine.class, new DriverLineEps(this));
|
||||||
registerDriver(UPolygon.class, new DriverPolygonEps(this));
|
registerDriver(UPolygon.class, new DriverPolygonEps(this));
|
||||||
registerDriver(UEllipse.class, new DriverEllipseEps(this));
|
registerDriver(UEllipse.class, new DriverEllipseEps(this));
|
||||||
@ -112,7 +109,7 @@ public class UGraphicEps extends AbstractUGraphic<EpsGraphics> implements ClipCo
|
|||||||
|
|
||||||
static public String getEpsString(HColor defaultBackground, ColorMapper colorMapper, EpsStrategy epsStrategy,
|
static public String getEpsString(HColor defaultBackground, ColorMapper colorMapper, EpsStrategy epsStrategy,
|
||||||
UDrawable udrawable) throws IOException {
|
UDrawable udrawable) throws IOException {
|
||||||
final UGraphicEps ug = new UGraphicEps(defaultBackground, colorMapper, epsStrategy);
|
final UGraphicEps ug = new UGraphicEps(defaultBackground, colorMapper, FileFormat.EPS_TEXT.getDefaultStringBounder(), epsStrategy);
|
||||||
udrawable.drawU(ug);
|
udrawable.drawU(ug);
|
||||||
return ug.getEPSCode();
|
return ug.getEPSCode();
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ package net.sourceforge.plantuml.ugraphic.html5;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
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.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;
|
||||||
@ -55,8 +55,8 @@ public class UGraphicHtml5 extends AbstractUGraphic<Html5Drawer> implements Clip
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UGraphicHtml5(HColor defaultBackground, ColorMapper colorMapper) {
|
public UGraphicHtml5(HColor defaultBackground, ColorMapper colorMapper, StringBounder stringBounder) {
|
||||||
super(defaultBackground, colorMapper, FileFormat.PNG.getDefaultStringBounder(), new Html5Drawer());
|
super(defaultBackground, colorMapper, stringBounder, new Html5Drawer());
|
||||||
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));
|
||||||
ignoreShape(UText.class);
|
ignoreShape(UText.class);
|
||||||
|
@ -37,8 +37,8 @@ package net.sourceforge.plantuml.ugraphic.visio;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
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;
|
||||||
@ -61,15 +61,9 @@ public class UGraphicVdx extends AbstractUGraphic<VisioGraphics> implements Clip
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private UGraphicVdx(HColor defaultBackground, ColorMapper colorMapper, VisioGraphics visio) {
|
public UGraphicVdx(HColor defaultBackground, ColorMapper colorMapper, StringBounder stringBounder) {
|
||||||
super(defaultBackground, colorMapper, FileFormat.PNG.getDefaultStringBounder(), visio);
|
super(defaultBackground, colorMapper, stringBounder, new VisioGraphics());
|
||||||
register();
|
register();
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public UGraphicVdx(HColor defaultBackground, ColorMapper colorMapper) {
|
|
||||||
this(defaultBackground, colorMapper, new VisioGraphics());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user