mirror of
https://github.com/octoleo/plantuml.git
synced 2024-12-22 02:49:06 +00:00
Remove imports and push up Pragma to higher in call chain
This commit is contained in:
parent
61b0f7b138
commit
6d0f6302ef
@ -43,7 +43,10 @@ import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.*;
|
||||
import net.sourceforge.plantuml.Dimension2DDouble;
|
||||
import net.sourceforge.plantuml.EmptyImageBuilder;
|
||||
import net.sourceforge.plantuml.FileFormat;
|
||||
import net.sourceforge.plantuml.SpriteContainerEmpty;
|
||||
import net.sourceforge.plantuml.api.ImageDataSimple;
|
||||
import net.sourceforge.plantuml.core.ImageData;
|
||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||
@ -87,7 +90,7 @@ public class GraphicsSudoku {
|
||||
public ImageData writeImageSvg(OutputStream os) throws IOException {
|
||||
final UGraphicSvg ug = new UGraphicSvg(HColorUtils.WHITE, true, new Dimension2DDouble(0, 0),
|
||||
new ColorMapperIdentity(), false, 1.0, null, null, 0, "none", FileFormat.SVG.getDefaultStringBounder(),
|
||||
LengthAdjust.defaultValue(), new Pragma());
|
||||
LengthAdjust.defaultValue(), false);
|
||||
drawInternal(ug);
|
||||
ug.writeToStream(os, null, -1); // dpi param is not used
|
||||
return ImageDataSimple.ok();
|
||||
|
@ -62,7 +62,6 @@ import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
|
||||
import net.sourceforge.plantuml.Pragma;
|
||||
import org.w3c.dom.CDATASection;
|
||||
import org.w3c.dom.Comment;
|
||||
import org.w3c.dom.Document;
|
||||
@ -130,7 +129,6 @@ public class SvgGraphics {
|
||||
private final boolean svgDimensionStyle;
|
||||
private final LengthAdjust lengthAdjust;
|
||||
|
||||
private final Pragma pragma;
|
||||
private final boolean INTERACTIVE;
|
||||
|
||||
final protected void ensureVisible(double x, double y) {
|
||||
@ -143,7 +141,7 @@ public class SvgGraphics {
|
||||
}
|
||||
|
||||
public SvgGraphics(String backcolor, boolean svgDimensionStyle, Dimension2D minDim, double scale, String hover,
|
||||
long seed, String preserveAspectRatio, LengthAdjust lengthAdjust, DarkStrategy darkStrategy, Pragma pragma) {
|
||||
long seed, String preserveAspectRatio, LengthAdjust lengthAdjust, DarkStrategy darkStrategy, boolean interactive) {
|
||||
try {
|
||||
this.lengthAdjust = lengthAdjust;
|
||||
this.svgDimensionStyle = svgDimensionStyle;
|
||||
@ -151,7 +149,7 @@ public class SvgGraphics {
|
||||
this.document = getDocument();
|
||||
this.backcolor = backcolor;
|
||||
this.preserveAspectRatio = preserveAspectRatio;
|
||||
this.pragma = pragma;
|
||||
this.INTERACTIVE = interactive;
|
||||
ensureVisible(minDim.getWidth(), minDim.getHeight());
|
||||
|
||||
this.root = getRootNode();
|
||||
@ -167,12 +165,6 @@ public class SvgGraphics {
|
||||
if (hover != null)
|
||||
defs.appendChild(getPathHover(hover));
|
||||
|
||||
if (!pragma.isDefine("svginteractive"))
|
||||
INTERACTIVE = false;
|
||||
else {
|
||||
INTERACTIVE = Boolean.valueOf(pragma.getValue("svginteractive"));
|
||||
}
|
||||
|
||||
if (INTERACTIVE) {
|
||||
final Element styles = getStylesForInteractiveMode();
|
||||
if (styles != null)
|
||||
|
@ -54,7 +54,6 @@ import java.util.Set;
|
||||
import javax.xml.transform.TransformerException;
|
||||
|
||||
import net.sourceforge.plantuml.Dimension2DDouble;
|
||||
import net.sourceforge.plantuml.Pragma;
|
||||
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||
import net.sourceforge.plantuml.graphic.UDrawable;
|
||||
import net.sourceforge.plantuml.security.SImageIO;
|
||||
@ -160,7 +159,7 @@ public class FontChecker {
|
||||
|
||||
private String getSvgImage(char c) throws IOException, TransformerException {
|
||||
final SvgGraphics svg = new SvgGraphics(null, true, new Dimension2DDouble(0, 0), 1.0, null, 42, "none",
|
||||
LengthAdjust.defaultValue(), DarkStrategy.IGNORE_DARK_COLOR, new Pragma());
|
||||
LengthAdjust.defaultValue(), DarkStrategy.IGNORE_DARK_COLOR, false);
|
||||
svg.setStrokeColor("black");
|
||||
svg.svgImage(getBufferedImage(c), 0, 0);
|
||||
final ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
|
@ -51,7 +51,25 @@ import java.util.Set;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import net.sourceforge.plantuml.*;
|
||||
import net.sourceforge.plantuml.AnimatedGifEncoder;
|
||||
import net.sourceforge.plantuml.AnnotatedWorker;
|
||||
import net.sourceforge.plantuml.CMapData;
|
||||
import net.sourceforge.plantuml.ColorParam;
|
||||
import net.sourceforge.plantuml.CornerParam;
|
||||
import net.sourceforge.plantuml.Dimension2DDouble;
|
||||
import net.sourceforge.plantuml.EmptyImageBuilder;
|
||||
import net.sourceforge.plantuml.FileFormat;
|
||||
import net.sourceforge.plantuml.FileFormatOption;
|
||||
import net.sourceforge.plantuml.FileUtils;
|
||||
import net.sourceforge.plantuml.ISkinParam;
|
||||
import net.sourceforge.plantuml.LineParam;
|
||||
import net.sourceforge.plantuml.OptionFlags;
|
||||
import net.sourceforge.plantuml.Scale;
|
||||
import net.sourceforge.plantuml.SvgCharSizeHack;
|
||||
import net.sourceforge.plantuml.Pragma;
|
||||
import net.sourceforge.plantuml.TitledDiagram;
|
||||
import net.sourceforge.plantuml.Url;
|
||||
import net.sourceforge.plantuml.UseStyle;
|
||||
import net.sourceforge.plantuml.anim.AffineTransformation;
|
||||
import net.sourceforge.plantuml.anim.Animation;
|
||||
import net.sourceforge.plantuml.api.ImageDataComplex;
|
||||
@ -389,7 +407,13 @@ public class ImageBuilder {
|
||||
case PNG:
|
||||
return createUGraphicPNG(scaleFactor, dim, animationArg, dx, dy, option.getWatermark());
|
||||
case SVG:
|
||||
return createUGraphicSVG(scaleFactor, dim, pragma);
|
||||
final boolean interactive;
|
||||
if (!pragma.isDefine("svginteractive"))
|
||||
interactive = false;
|
||||
else {
|
||||
interactive = Boolean.valueOf(pragma.getValue("svginteractive"));
|
||||
}
|
||||
return createUGraphicSVG(scaleFactor, dim, interactive);
|
||||
case EPS:
|
||||
return new UGraphicEps(backcolor, colorMapper, stringBounder, EpsStrategy.getDefault2());
|
||||
case EPS_TEXT:
|
||||
@ -415,14 +439,14 @@ public class ImageBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private UGraphic createUGraphicSVG(double scaleFactor, Dimension2D dim, Pragma pragma) {
|
||||
private UGraphic createUGraphicSVG(double scaleFactor, Dimension2D dim, boolean interactive) {
|
||||
final String hoverPathColorRGB = getHoverPathColorRGB();
|
||||
final LengthAdjust lengthAdjust = skinParam == null ? LengthAdjust.defaultValue() : skinParam.getlengthAdjust();
|
||||
final String preserveAspectRatio = getPreserveAspectRatio();
|
||||
final boolean svgDimensionStyle = skinParam == null || skinParam.svgDimensionStyle();
|
||||
final String svgLinkTarget = getSvgLinkTarget();
|
||||
final UGraphicSvg ug = new UGraphicSvg(backcolor, svgDimensionStyle, dim, colorMapper, false, scaleFactor,
|
||||
svgLinkTarget, hoverPathColorRGB, seed, preserveAspectRatio, stringBounder, lengthAdjust, pragma);
|
||||
svgLinkTarget, hoverPathColorRGB, seed, preserveAspectRatio, stringBounder, lengthAdjust, interactive);
|
||||
return ug;
|
||||
|
||||
}
|
||||
|
@ -41,7 +41,6 @@ import java.util.Map;
|
||||
|
||||
import javax.xml.transform.TransformerException;
|
||||
|
||||
import net.sourceforge.plantuml.Pragma;
|
||||
import net.sourceforge.plantuml.Url;
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.posimo.DotPath;
|
||||
@ -71,7 +70,7 @@ public class UGraphicSvg extends AbstractUGraphic<SvgGraphics> implements ClipCo
|
||||
|
||||
private final boolean textAsPath2;
|
||||
private final String target;
|
||||
private final Pragma pragma;
|
||||
private final boolean interactive;
|
||||
|
||||
public double dpiFactor() {
|
||||
return 1;
|
||||
@ -86,17 +85,17 @@ public class UGraphicSvg extends AbstractUGraphic<SvgGraphics> implements ClipCo
|
||||
super(other);
|
||||
this.textAsPath2 = other.textAsPath2;
|
||||
this.target = other.target;
|
||||
this.pragma = other.pragma;
|
||||
this.interactive = other.interactive;
|
||||
register();
|
||||
}
|
||||
|
||||
public UGraphicSvg(HColor defaultBackground, boolean svgDimensionStyle, Dimension2D minDim, ColorMapper colorMapper,
|
||||
boolean textAsPath, double scale, String linkTarget, String hover, long seed, String preserveAspectRatio,
|
||||
StringBounder stringBounder, LengthAdjust lengthAdjust, Pragma pragma) {
|
||||
StringBounder stringBounder, LengthAdjust lengthAdjust, boolean interactive) {
|
||||
this(defaultBackground, minDim, colorMapper,
|
||||
new SvgGraphics(colorMapper.toSvg(defaultBackground), svgDimensionStyle, minDim, scale, hover, seed,
|
||||
preserveAspectRatio, lengthAdjust, DarkStrategy.IGNORE_DARK_COLOR, pragma),
|
||||
textAsPath, linkTarget, stringBounder, pragma);
|
||||
preserveAspectRatio, lengthAdjust, DarkStrategy.IGNORE_DARK_COLOR, interactive),
|
||||
textAsPath, linkTarget, stringBounder, interactive);
|
||||
if (defaultBackground instanceof HColorGradient) {
|
||||
final SvgGraphics svg = getGraphicObject();
|
||||
svg.paintBackcolorGradient(colorMapper, (HColorGradient) defaultBackground);
|
||||
@ -119,11 +118,11 @@ public class UGraphicSvg extends AbstractUGraphic<SvgGraphics> implements ClipCo
|
||||
}
|
||||
|
||||
private UGraphicSvg(HColor defaultBackground, Dimension2D minDim, ColorMapper colorMapper, SvgGraphics svg,
|
||||
boolean textAsPath, String linkTarget, StringBounder stringBounder, Pragma pragma) {
|
||||
boolean textAsPath, String linkTarget, StringBounder stringBounder, boolean interactive) {
|
||||
super(defaultBackground, colorMapper, stringBounder, svg);
|
||||
this.textAsPath2 = textAsPath;
|
||||
this.target = linkTarget;
|
||||
this.pragma = pragma;
|
||||
this.interactive = interactive;
|
||||
register();
|
||||
}
|
||||
|
||||
@ -155,7 +154,7 @@ public class UGraphicSvg extends AbstractUGraphic<SvgGraphics> implements ClipCo
|
||||
if (metadata != null)
|
||||
getGraphicObject().addComment(metadata);
|
||||
|
||||
if (pragma.isDefine("svginteractive") && Boolean.valueOf(pragma.getValue("svginteractive"))) {
|
||||
if (interactive) {
|
||||
// For performance reasons and also because we want the entire graph DOM to be create so we can register
|
||||
// the event handlers on them we will append to the end of the document
|
||||
getGraphicObject().addStyle("onmouseinteractivefooter.css");
|
||||
|
Loading…
Reference in New Issue
Block a user