1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-26 06:46:45 +00:00

Infer hoverPathColorRGB instead of storing it in ImageBuilder.

This commit is contained in:
matthew16550 2021-04-07 19:32:14 +10:00
parent 5c2634cf4e
commit 5b970db545

View File

@ -115,7 +115,6 @@ public class ImageBuilder {
private ColorMapper colorMapper = new ColorMapperIdentity(); private ColorMapper colorMapper = new ColorMapperIdentity();
private Dimension2D dimension; private Dimension2D dimension;
private final FileFormatOption fileFormatOption; private final FileFormatOption fileFormatOption;
private String hoverPathColorRGB;
private UDrawable udrawable; private UDrawable udrawable;
private ClockwiseTopRightBottomLeft margin = ClockwiseTopRightBottomLeft.none(); private ClockwiseTopRightBottomLeft margin = ClockwiseTopRightBottomLeft.none();
private String metadata; private String metadata;
@ -223,7 +222,6 @@ public class ImageBuilder {
annotations = true; annotations = true;
backcolor = calculateBackColor(diagram); backcolor = calculateBackColor(diagram);
colorMapper = skinParam.getColorMapper(); colorMapper = skinParam.getColorMapper();
hoverPathColorRGB = calculateHoverPathColor(skinParam);
margin = calculateMargin(diagram); margin = calculateMargin(diagram);
metadata = fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null; metadata = fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null;
preserveAspectRatio = calculatePreserveAspectRatio(fileFormatOption, skinParam); preserveAspectRatio = calculatePreserveAspectRatio(fileFormatOption, skinParam);
@ -431,13 +429,14 @@ public class ImageBuilder {
case ATXT: case ATXT:
return new UGraphicTxt(); return new UGraphicTxt();
case DEBUG: case DEBUG:
return new UGraphicDebug(scaleFactor, dim, svgLinkTarget, hoverPathColorRGB, seed, preserveAspectRatio); return new UGraphicDebug(scaleFactor, dim, svgLinkTarget, getHoverPathColorRGB(), seed, preserveAspectRatio);
default: default:
throw new UnsupportedOperationException(option.getFileFormat().toString()); throw new UnsupportedOperationException(option.getFileFormat().toString());
} }
} }
private UGraphic2 createUGraphicSVG(double scaleFactor, Dimension2D dim) { private UGraphic2 createUGraphicSVG(double scaleFactor, Dimension2D dim) {
final String hoverPathColorRGB = getHoverPathColorRGB();
final LengthAdjust lengthAdjust = skinParam == null ? LengthAdjust.defaultValue() : skinParam.getlengthAdjust(); final LengthAdjust lengthAdjust = skinParam == null ? LengthAdjust.defaultValue() : skinParam.getlengthAdjust();
final SvgCharSizeHack svgCharSizeHack = getSvgCharSizeHack(); final SvgCharSizeHack svgCharSizeHack = getSvgCharSizeHack();
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
@ -501,12 +500,16 @@ public class ImageBuilder {
return diagram.getSkinParam().getBackgroundColor(false); return diagram.getSkinParam().getBackgroundColor(false);
} }
private String calculateHoverPathColor(ISkinParam skinParam) { private String getHoverPathColorRGB() {
if (fileFormatOption.getHoverColor() != null) { if (fileFormatOption.getHoverColor() != null) {
return fileFormatOption.getHoverColor(); 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 null;
return color == null ? null : colorMapper.toRGB(color);
} }
private static ClockwiseTopRightBottomLeft calculateMargin(TitledDiagram diagram) { private static ClockwiseTopRightBottomLeft calculateMargin(TitledDiagram diagram) {