1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-26 14:56:28 +00:00

Move hoverpathcolor calculation to ImageBuilder class.

This commit is contained in:
matthew16550 2021-03-28 12:05:48 +11:00
parent 986393d90d
commit 1c70b9ea34
2 changed files with 15 additions and 10 deletions

View File

@ -77,7 +77,6 @@ import net.sourceforge.plantuml.ugraphic.PixelImage;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UImage;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.version.Version;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.plainImageBuilder;
@ -135,15 +134,11 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot
final protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException {
final HColor hover = getSkinParam().hoverPathColor();
if (fileFormatOption.getSvgLinkTarget() == null || fileFormatOption.getSvgLinkTarget().equals("_top")) {
fileFormatOption = fileFormatOption.withSvgLinkTarget(getSkinParam().getSvgLinkTarget());
}
fileFormatOption = fileFormatOption.withPreserveAspectRatio(getSkinParam().getPreserveAspectRatio());
fileFormatOption = fileFormatOption.withTikzFontDistortion(getSkinParam().getTikzFontDistortion());
if (hover != null) {
fileFormatOption = fileFormatOption.withHoverColor(getSkinParam().getColorMapper().toRGB(hover));
}
if (fileFormatOption.getFileFormat() == FileFormat.PDF) {
return exportDiagramInternalPdf(os, index);

View File

@ -118,6 +118,7 @@ public class ImageBuilder {
private int dpi = 96;
private final FileFormatOption fileFormatOption;
private boolean handwritten;
private String hoverPathColorRGB;
private LengthAdjust lengthAdjust = LengthAdjust.defaultValue();
private UDrawable udrawable;
private ClockwiseTopRightBottomLeft margin = ClockwiseTopRightBottomLeft.none();
@ -215,6 +216,7 @@ public class ImageBuilder {
colorMapper = skinParam.getColorMapper();
dpi = skinParam.getDpi();
handwritten = skinParam.handwritten();
hoverPathColorRGB = calculateHoverPathColor(skinParam);
lengthAdjust = skinParam.getlengthAdjust();
margin = calculateMargin(diagram);
metadata = fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null;
@ -398,7 +400,7 @@ public class ImageBuilder {
option.getWatermark());
case SVG:
return createUGraphicSVG(scaleFactor, dim, option.getSvgLinkTarget(),
option.getHoverColor(), option.getPreserveAspectRatio());
option.getPreserveAspectRatio());
case EPS:
return new UGraphicEps(colorMapper, EpsStrategy.getDefault2());
case EPS_TEXT:
@ -424,7 +426,7 @@ public class ImageBuilder {
}
private UGraphic2 createUGraphicSVG(double scaleFactor, Dimension2D dim,
String svgLinkTarget, String hover, String preserveAspectRatio) {
String svgLinkTarget, String preserveAspectRatio) {
HColor backColor = HColorUtils.WHITE; // TODO simplify backcolor some more in a future PR
if (this.backcolor instanceof HColorSimple) {
backColor = this.backcolor;
@ -432,13 +434,13 @@ public class ImageBuilder {
final UGraphicSvg ug;
if (this.backcolor instanceof HColorGradient) {
ug = new UGraphicSvg(svgDimensionStyle, dim, colorMapper, (HColorGradient) this.backcolor, false, scaleFactor,
svgLinkTarget, hover, seed, preserveAspectRatio, svgCharSizeHack, lengthAdjust);
svgLinkTarget, hoverPathColorRGB, seed, preserveAspectRatio, svgCharSizeHack, lengthAdjust);
} else if (backColor == null || colorMapper.toColor(backColor).equals(Color.WHITE)) {
ug = new UGraphicSvg(svgDimensionStyle, dim, colorMapper, false, scaleFactor, svgLinkTarget, hover, seed,
ug = new UGraphicSvg(svgDimensionStyle, dim, colorMapper, false, scaleFactor, svgLinkTarget, hoverPathColorRGB, seed,
preserveAspectRatio, svgCharSizeHack, lengthAdjust);
} else {
final String tmp = colorMapper.toSvg(backColor);
ug = new UGraphicSvg(svgDimensionStyle, dim, colorMapper, tmp, false, scaleFactor, svgLinkTarget, hover, seed,
ug = new UGraphicSvg(svgDimensionStyle, dim, colorMapper, tmp, false, scaleFactor, svgLinkTarget, hoverPathColorRGB, seed,
preserveAspectRatio, svgCharSizeHack, lengthAdjust);
}
return ug;
@ -491,6 +493,14 @@ public class ImageBuilder {
return (thickness == null && borderColor != null) ? new UStroke() : thickness;
}
private String calculateHoverPathColor(ISkinParam skinParam) {
if (fileFormatOption.getHoverColor() != null) {
return fileFormatOption.getHoverColor();
}
final HColor color = skinParam.hoverPathColor();
return color == null ? null : colorMapper.toRGB(color);
}
private static ClockwiseTopRightBottomLeft calculateMargin(TitledDiagram diagram) {
if (UseStyle.useBetaStyle()) {
final Style style = StyleSignature.of(SName.root, SName.document)