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:
parent
986393d90d
commit
1c70b9ea34
@ -77,7 +77,6 @@ import net.sourceforge.plantuml.ugraphic.PixelImage;
|
|||||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
import net.sourceforge.plantuml.ugraphic.UImage;
|
import net.sourceforge.plantuml.ugraphic.UImage;
|
||||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
|
||||||
import net.sourceforge.plantuml.version.Version;
|
import net.sourceforge.plantuml.version.Version;
|
||||||
|
|
||||||
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.plainImageBuilder;
|
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)
|
final protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
final HColor hover = getSkinParam().hoverPathColor();
|
|
||||||
if (fileFormatOption.getSvgLinkTarget() == null || fileFormatOption.getSvgLinkTarget().equals("_top")) {
|
if (fileFormatOption.getSvgLinkTarget() == null || fileFormatOption.getSvgLinkTarget().equals("_top")) {
|
||||||
fileFormatOption = fileFormatOption.withSvgLinkTarget(getSkinParam().getSvgLinkTarget());
|
fileFormatOption = fileFormatOption.withSvgLinkTarget(getSkinParam().getSvgLinkTarget());
|
||||||
}
|
}
|
||||||
fileFormatOption = fileFormatOption.withPreserveAspectRatio(getSkinParam().getPreserveAspectRatio());
|
fileFormatOption = fileFormatOption.withPreserveAspectRatio(getSkinParam().getPreserveAspectRatio());
|
||||||
fileFormatOption = fileFormatOption.withTikzFontDistortion(getSkinParam().getTikzFontDistortion());
|
fileFormatOption = fileFormatOption.withTikzFontDistortion(getSkinParam().getTikzFontDistortion());
|
||||||
if (hover != null) {
|
|
||||||
fileFormatOption = fileFormatOption.withHoverColor(getSkinParam().getColorMapper().toRGB(hover));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fileFormatOption.getFileFormat() == FileFormat.PDF) {
|
if (fileFormatOption.getFileFormat() == FileFormat.PDF) {
|
||||||
return exportDiagramInternalPdf(os, index);
|
return exportDiagramInternalPdf(os, index);
|
||||||
|
@ -118,6 +118,7 @@ public class ImageBuilder {
|
|||||||
private int dpi = 96;
|
private int dpi = 96;
|
||||||
private final FileFormatOption fileFormatOption;
|
private final FileFormatOption fileFormatOption;
|
||||||
private boolean handwritten;
|
private boolean handwritten;
|
||||||
|
private String hoverPathColorRGB;
|
||||||
private LengthAdjust lengthAdjust = LengthAdjust.defaultValue();
|
private LengthAdjust lengthAdjust = LengthAdjust.defaultValue();
|
||||||
private UDrawable udrawable;
|
private UDrawable udrawable;
|
||||||
private ClockwiseTopRightBottomLeft margin = ClockwiseTopRightBottomLeft.none();
|
private ClockwiseTopRightBottomLeft margin = ClockwiseTopRightBottomLeft.none();
|
||||||
@ -215,6 +216,7 @@ public class ImageBuilder {
|
|||||||
colorMapper = skinParam.getColorMapper();
|
colorMapper = skinParam.getColorMapper();
|
||||||
dpi = skinParam.getDpi();
|
dpi = skinParam.getDpi();
|
||||||
handwritten = skinParam.handwritten();
|
handwritten = skinParam.handwritten();
|
||||||
|
hoverPathColorRGB = calculateHoverPathColor(skinParam);
|
||||||
lengthAdjust = skinParam.getlengthAdjust();
|
lengthAdjust = skinParam.getlengthAdjust();
|
||||||
margin = calculateMargin(diagram);
|
margin = calculateMargin(diagram);
|
||||||
metadata = fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null;
|
metadata = fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null;
|
||||||
@ -398,7 +400,7 @@ public class ImageBuilder {
|
|||||||
option.getWatermark());
|
option.getWatermark());
|
||||||
case SVG:
|
case SVG:
|
||||||
return createUGraphicSVG(scaleFactor, dim, option.getSvgLinkTarget(),
|
return createUGraphicSVG(scaleFactor, dim, option.getSvgLinkTarget(),
|
||||||
option.getHoverColor(), option.getPreserveAspectRatio());
|
option.getPreserveAspectRatio());
|
||||||
case EPS:
|
case EPS:
|
||||||
return new UGraphicEps(colorMapper, EpsStrategy.getDefault2());
|
return new UGraphicEps(colorMapper, EpsStrategy.getDefault2());
|
||||||
case EPS_TEXT:
|
case EPS_TEXT:
|
||||||
@ -424,7 +426,7 @@ public class ImageBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private UGraphic2 createUGraphicSVG(double scaleFactor, Dimension2D dim,
|
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
|
HColor backColor = HColorUtils.WHITE; // TODO simplify backcolor some more in a future PR
|
||||||
if (this.backcolor instanceof HColorSimple) {
|
if (this.backcolor instanceof HColorSimple) {
|
||||||
backColor = this.backcolor;
|
backColor = this.backcolor;
|
||||||
@ -432,13 +434,13 @@ public class ImageBuilder {
|
|||||||
final UGraphicSvg ug;
|
final UGraphicSvg ug;
|
||||||
if (this.backcolor instanceof HColorGradient) {
|
if (this.backcolor instanceof HColorGradient) {
|
||||||
ug = new UGraphicSvg(svgDimensionStyle, dim, colorMapper, (HColorGradient) this.backcolor, false, scaleFactor,
|
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)) {
|
} 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);
|
preserveAspectRatio, svgCharSizeHack, lengthAdjust);
|
||||||
} else {
|
} else {
|
||||||
final String tmp = colorMapper.toSvg(backColor);
|
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);
|
preserveAspectRatio, svgCharSizeHack, lengthAdjust);
|
||||||
}
|
}
|
||||||
return ug;
|
return ug;
|
||||||
@ -491,6 +493,14 @@ public class ImageBuilder {
|
|||||||
return (thickness == null && borderColor != null) ? new UStroke() : thickness;
|
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) {
|
private static ClockwiseTopRightBottomLeft calculateMargin(TitledDiagram diagram) {
|
||||||
if (UseStyle.useBetaStyle()) {
|
if (UseStyle.useBetaStyle()) {
|
||||||
final Style style = StyleSignature.of(SName.root, SName.document)
|
final Style style = StyleSignature.of(SName.root, SName.document)
|
||||||
|
Loading…
Reference in New Issue
Block a user