From 5b970db545bf72fe94be3a61df0005bb4c35cab8 Mon Sep 17 00:00:00 2001 From: matthew16550 Date: Wed, 7 Apr 2021 19:32:14 +1000 Subject: [PATCH] Infer hoverPathColorRGB instead of storing it in ImageBuilder. --- .../plantuml/ugraphic/ImageBuilder.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java b/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java index 8eb222f81..e07d6b4ee 100644 --- a/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java +++ b/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java @@ -115,7 +115,6 @@ public class ImageBuilder { private ColorMapper colorMapper = new ColorMapperIdentity(); private Dimension2D dimension; private final FileFormatOption fileFormatOption; - private String hoverPathColorRGB; private UDrawable udrawable; private ClockwiseTopRightBottomLeft margin = ClockwiseTopRightBottomLeft.none(); private String metadata; @@ -223,7 +222,6 @@ public class ImageBuilder { annotations = true; backcolor = calculateBackColor(diagram); colorMapper = skinParam.getColorMapper(); - hoverPathColorRGB = calculateHoverPathColor(skinParam); margin = calculateMargin(diagram); metadata = fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null; preserveAspectRatio = calculatePreserveAspectRatio(fileFormatOption, skinParam); @@ -431,13 +429,14 @@ public class ImageBuilder { case ATXT: return new UGraphicTxt(); case DEBUG: - return new UGraphicDebug(scaleFactor, dim, svgLinkTarget, hoverPathColorRGB, seed, preserveAspectRatio); + return new UGraphicDebug(scaleFactor, dim, svgLinkTarget, getHoverPathColorRGB(), seed, preserveAspectRatio); default: throw new UnsupportedOperationException(option.getFileFormat().toString()); } } private UGraphic2 createUGraphicSVG(double scaleFactor, Dimension2D dim) { + final String hoverPathColorRGB = getHoverPathColorRGB(); final LengthAdjust lengthAdjust = skinParam == null ? LengthAdjust.defaultValue() : skinParam.getlengthAdjust(); final SvgCharSizeHack svgCharSizeHack = getSvgCharSizeHack(); HColor backColor = HColorUtils.WHITE; // TODO simplify backcolor some more in a future PR @@ -501,12 +500,16 @@ public class ImageBuilder { return diagram.getSkinParam().getBackgroundColor(false); } - private String calculateHoverPathColor(ISkinParam skinParam) { + private String getHoverPathColorRGB() { if (fileFormatOption.getHoverColor() != null) { return fileFormatOption.getHoverColor(); + } else if (skinParam != null) { + final HColor color = skinParam.hoverPathColor(); + if (color != null) { + return colorMapper.toRGB(color); + } } - final HColor color = skinParam.hoverPathColor(); - return color == null ? null : colorMapper.toRGB(color); + return null; } private static ClockwiseTopRightBottomLeft calculateMargin(TitledDiagram diagram) {