From 03272b104a2c25ffe7c68ae0f9492e4e4b0b56e6 Mon Sep 17 00:00:00 2001 From: matthew16550 Date: Tue, 9 Nov 2021 00:56:52 +1100 Subject: [PATCH] Delete replaceTransparentByWhite parameter from ISkinParam.getBackgroundColor() --- .../sourceforge/plantuml/AnnotatedWorker.java | 2 +- src/net/sourceforge/plantuml/ISkinParam.java | 4 ++-- src/net/sourceforge/plantuml/SkinParam.java | 12 +++-------- .../plantuml/SkinParamBackcolored.java | 4 ++-- .../plantuml/SkinParamDelegator.java | 4 ++-- .../sourceforge/plantuml/TitledDiagram.java | 2 +- .../ftile/vcompact/VCompactFactory.java | 8 +++---- .../cucadiagram/entity/EntityFactory.java | 2 +- .../plantuml/salt/PSystemSalt.java | 2 +- .../plantuml/sdot/SmetanaPath.java | 4 ++-- .../command/CommandGrouping.java | 2 +- .../skin/rose/ComponentRoseGroupingElse.java | 2 +- .../sourceforge/plantuml/skin/rose/Rose.java | 4 ++-- .../plantuml/svek/AbstractEntityImage.java | 2 +- .../sourceforge/plantuml/svek/Cluster.java | 4 ++-- .../plantuml/svek/ConcurrentStateImage.java | 2 +- ...ucaDiagramFileMakerSvek2InternalImage.java | 2 +- .../plantuml/svek/GeneralImageBuilder.java | 4 ++-- .../sourceforge/plantuml/svek/SvekLine.java | 2 +- .../sourceforge/plantuml/svek/SvekResult.java | 2 +- .../sourceforge/plantuml/SkinParamTest.java | 21 +++++++++---------- 21 files changed, 42 insertions(+), 49 deletions(-) diff --git a/src/net/sourceforge/plantuml/AnnotatedWorker.java b/src/net/sourceforge/plantuml/AnnotatedWorker.java index 6500767d4..5a2c869da 100644 --- a/src/net/sourceforge/plantuml/AnnotatedWorker.java +++ b/src/net/sourceforge/plantuml/AnnotatedWorker.java @@ -138,7 +138,7 @@ public class AnnotatedWorker { } private HColor getBackgroundColor() { - return getSkinParam().getBackgroundColor(false); + return getSkinParam().getBackgroundColor(); } private TextBlock addLegend(TextBlock original) { diff --git a/src/net/sourceforge/plantuml/ISkinParam.java b/src/net/sourceforge/plantuml/ISkinParam.java index 0ec06098b..5d6f1778c 100644 --- a/src/net/sourceforge/plantuml/ISkinParam.java +++ b/src/net/sourceforge/plantuml/ISkinParam.java @@ -65,7 +65,7 @@ public interface ISkinParam extends ISkinSimple { public boolean useUnderlineForHyperlink(); - public HColor getBackgroundColor(boolean replaceTransparentByWhite); + public HColor getBackgroundColor(); public HColor getHtmlColor(ColorParam param, Stereotype stereotype, boolean clickable); @@ -196,4 +196,4 @@ public interface ISkinParam extends ISkinSimple { public void assumeTransparent(ThemeStyle style); -} \ No newline at end of file +} diff --git a/src/net/sourceforge/plantuml/SkinParam.java b/src/net/sourceforge/plantuml/SkinParam.java index 4913d42eb..c4847e3ea 100644 --- a/src/net/sourceforge/plantuml/SkinParam.java +++ b/src/net/sourceforge/plantuml/SkinParam.java @@ -283,15 +283,9 @@ public class SkinParam implements ISkinParam { return result; } - public HColor getBackgroundColor(boolean replaceTransparentByWhite) { + public HColor getBackgroundColor() { final HColor result = getHtmlColor(ColorParam.background, null, false); - if (result == null) { - return HColorUtils.WHITE; - } - if (replaceTransparentByWhite && HColorUtils.transparent().equals(result)) { - return HColorUtils.WHITE; - } - return result; + return result != null ? result : HColorUtils.WHITE; } public String getValue(String key) { @@ -356,7 +350,7 @@ public class SkinParam implements ISkinParam { assert param != ColorParam.background; // final boolean acceptTransparent = param == ColorParam.background // || param == ColorParam.sequenceGroupBodyBackground || param == ColorParam.sequenceBoxBackground; - return getIHtmlColorSet().getColorOrWhite(themeStyle, value, getBackgroundColor(false)); + return getIHtmlColorSet().getColorOrWhite(themeStyle, value, getBackgroundColor()); } public char getCircledCharacter(Stereotype stereotype) { diff --git a/src/net/sourceforge/plantuml/SkinParamBackcolored.java b/src/net/sourceforge/plantuml/SkinParamBackcolored.java index 4d21f8481..fe4e7a983 100644 --- a/src/net/sourceforge/plantuml/SkinParamBackcolored.java +++ b/src/net/sourceforge/plantuml/SkinParamBackcolored.java @@ -73,11 +73,11 @@ public class SkinParamBackcolored extends SkinParamDelegator { } @Override - public HColor getBackgroundColor(boolean replaceTransparentByWhite) { + public HColor getBackgroundColor() { if (backColorGeneral != null) { return backColorGeneral; } - return super.getBackgroundColor(replaceTransparentByWhite); + return super.getBackgroundColor(); } @Override diff --git a/src/net/sourceforge/plantuml/SkinParamDelegator.java b/src/net/sourceforge/plantuml/SkinParamDelegator.java index 1d465c86f..1ae639952 100644 --- a/src/net/sourceforge/plantuml/SkinParamDelegator.java +++ b/src/net/sourceforge/plantuml/SkinParamDelegator.java @@ -75,8 +75,8 @@ public class SkinParamDelegator implements ISkinParam { } @Override - public HColor getBackgroundColor(boolean replaceTransparentByWhite) { - return skinParam.getBackgroundColor(replaceTransparentByWhite); + public HColor getBackgroundColor() { + return skinParam.getBackgroundColor(); } @Override diff --git a/src/net/sourceforge/plantuml/TitledDiagram.java b/src/net/sourceforge/plantuml/TitledDiagram.java index e82ade424..ce079c780 100644 --- a/src/net/sourceforge/plantuml/TitledDiagram.java +++ b/src/net/sourceforge/plantuml/TitledDiagram.java @@ -267,7 +267,7 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram, return backgroundColor; } - return this.getSkinParam().getBackgroundColor(false); + return this.getSkinParam().getBackgroundColor(); } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java index 9648567a3..dd1081804 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java @@ -119,10 +119,10 @@ public class VCompactFactory implements FtileFactory { borderColor = style.value(PName.LineColor).asColor(skinParam.getThemeStyle(), skinParam.getIHtmlColorSet()); // backgroundColor = // style.value(PName.BackGroundColor).asColor(skinParam.getIHtmlColorSet()); - backgroundColor = skinParam.getBackgroundColor(false); + backgroundColor = skinParam.getBackgroundColor(); } else { borderColor = rose.getHtmlColor(skinParam, ColorParam.activityEnd); - backgroundColor = skinParam.getBackgroundColor(false); + backgroundColor = skinParam.getBackgroundColor(); } return new FtileCircleStop(skinParam(), backgroundColor, borderColor, swimlane, style); } @@ -143,10 +143,10 @@ public class VCompactFactory implements FtileFactory { borderColor = style.value(PName.LineColor).asColor(skinParam.getThemeStyle(), skinParam.getIHtmlColorSet()); // backgroundColor = // style.value(PName.BackGroundColor).asColor(skinParam.getIHtmlColorSet()); - backgroundColor = skinParam.getBackgroundColor(false); + backgroundColor = skinParam.getBackgroundColor(); } else { borderColor = rose.getHtmlColor(skinParam, ColorParam.activityEnd); - backgroundColor = skinParam.getBackgroundColor(false); + backgroundColor = skinParam.getBackgroundColor(); } return new FtileCircleEnd(skinParam(), backgroundColor, borderColor, swimlane, style); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/entity/EntityFactory.java b/src/net/sourceforge/plantuml/cucadiagram/entity/EntityFactory.java index 397d455c6..8ebcec045 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/entity/EntityFactory.java +++ b/src/net/sourceforge/plantuml/cucadiagram/entity/EntityFactory.java @@ -135,7 +135,7 @@ public final class EntityFactory { final ColorParam param = symbol == null ? ColorParam.packageBackground : symbol.getColorParamBack(); final HColor c1 = skinParam.getHtmlColor(param, g.getStereotype(), false); folder.setSpecificColorTOBEREMOVED(ColorType.BACK, - c1 == null ? skinParam.getBackgroundColor(false) : c1); + c1 == null ? skinParam.getBackgroundColor() : c1); } else { folder.setSpecificColorTOBEREMOVED(ColorType.BACK, g.getColors(skinParam).getColor(ColorType.BACK)); } diff --git a/src/net/sourceforge/plantuml/salt/PSystemSalt.java b/src/net/sourceforge/plantuml/salt/PSystemSalt.java index 496df65f0..63d5e6d01 100644 --- a/src/net/sourceforge/plantuml/salt/PSystemSalt.java +++ b/src/net/sourceforge/plantuml/salt/PSystemSalt.java @@ -150,7 +150,7 @@ public class PSystemSalt extends TitledDiagram implements WithSprite { } public HColor getBackcolor() { - return getSkinParam().getBackgroundColor(false); + return getSkinParam().getBackgroundColor(); } }; } diff --git a/src/net/sourceforge/plantuml/sdot/SmetanaPath.java b/src/net/sourceforge/plantuml/sdot/SmetanaPath.java index 10c877d3f..82f2e47db 100644 --- a/src/net/sourceforge/plantuml/sdot/SmetanaPath.java +++ b/src/net/sourceforge/plantuml/sdot/SmetanaPath.java @@ -164,7 +164,7 @@ public class SmetanaPath implements UDrawable { private void printExtremityAtStart(UGraphic ug) { final ExtremityFactory extremityFactory2 = link.getType().getDecor2() - .getExtremityFactoryComplete(diagram.getSkinParam().getBackgroundColor(false)); + .getExtremityFactoryComplete(diagram.getSkinParam().getBackgroundColor()); if (extremityFactory2 == null) { return; } @@ -188,7 +188,7 @@ public class SmetanaPath implements UDrawable { private void printExtremityAtEnd(UGraphic ug) { final ExtremityFactory extremityFactory1 = link.getType().getDecor1() - .getExtremityFactoryComplete(diagram.getSkinParam().getBackgroundColor(false)); + .getExtremityFactoryComplete(diagram.getSkinParam().getBackgroundColor()); if (extremityFactory1 == null) { return; } diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandGrouping.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandGrouping.java index 51dedbe8c..65618f43c 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandGrouping.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandGrouping.java @@ -85,7 +85,7 @@ public class CommandGrouping extends SingleLineCommand2 { HColor backColorGeneral = null; if (s2 != null) { backColorGeneral = colorSet.getColor(diagram.getSkinParam().getThemeStyle(), s2, - diagram.getSkinParam().getBackgroundColor(false)); + diagram.getSkinParam().getBackgroundColor()); } String comment = arg.get("COMMENT", 0); final GroupingType groupingType = GroupingType.getType(type); diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingElse.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingElse.java index 04d832e26..7a34baa5f 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingElse.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingElse.java @@ -75,7 +75,7 @@ public class ComponentRoseGroupingElse extends AbstractTextualComponent { this.roundCorner = style.value(PName.RoundCorner).asInt(); if (spriteContainer instanceof SkinParamBackcolored) { style = style.eventuallyOverride(PName.BackGroundColor, - ((SkinParamBackcolored) spriteContainer).getBackgroundColor(false)); + ((SkinParamBackcolored) spriteContainer).getBackgroundColor()); } this.groupBorder = style.value(PName.LineColor).asColor(spriteContainer.getThemeStyle(), getIHtmlColorSet()); diff --git a/src/net/sourceforge/plantuml/skin/rose/Rose.java b/src/net/sourceforge/plantuml/skin/rose/Rose.java index fa90e51bb..94336e81f 100644 --- a/src/net/sourceforge/plantuml/skin/rose/Rose.java +++ b/src/net/sourceforge/plantuml/skin/rose/Rose.java @@ -286,14 +286,14 @@ public class Rose { smallFont = smallFont.changeColor(smallColor); } return new ComponentRoseGroupingHeader(styles == null ? null : styles[0], styles == null ? null : styles[1], - param.getBackgroundColor(false), getSymbolContext(stereotype, param, ColorParam.sequenceGroupBorder), + param.getBackgroundColor(), getSymbolContext(stereotype, param, ColorParam.sequenceGroupBorder), bigFont, smallFont, stringsToDisplay, param, roundCorner); } if (type == ComponentType.GROUPING_ELSE) { return new ComponentRoseGroupingElse(styles == null ? null : styles[0], getHtmlColor(param, stereotype, ColorParam.sequenceGroupBorder), getUFont2(param, FontParam.SEQUENCE_GROUP), stringsToDisplay.get(0), param, - param.getBackgroundColor(false), roundCorner); + param.getBackgroundColor(), roundCorner); } if (type == ComponentType.GROUPING_SPACE) { return new ComponentRoseGroupingSpace(7); diff --git a/src/net/sourceforge/plantuml/svek/AbstractEntityImage.java b/src/net/sourceforge/plantuml/svek/AbstractEntityImage.java index ad437f4f0..a79cdf45d 100644 --- a/src/net/sourceforge/plantuml/svek/AbstractEntityImage.java +++ b/src/net/sourceforge/plantuml/svek/AbstractEntityImage.java @@ -67,7 +67,7 @@ public abstract class AbstractEntityImage extends AbstractTextBlock implements I } public final HColor getBackcolor() { - return skinParam.getBackgroundColor(false); + return skinParam.getBackgroundColor(); } protected final Stereotype getStereo() { diff --git a/src/net/sourceforge/plantuml/svek/Cluster.java b/src/net/sourceforge/plantuml/svek/Cluster.java index 5d324f662..4e254d7db 100644 --- a/src/net/sourceforge/plantuml/svek/Cluster.java +++ b/src/net/sourceforge/plantuml/svek/Cluster.java @@ -946,7 +946,7 @@ public class Cluster implements Moveable { skinParam.getIHtmlColorSet()); } if (backColor == null || backColor.equals(HColorUtils.transparent())) { - backColor = new HColorBackground(skinParam.getBackgroundColor(false)); + backColor = new HColorBackground(skinParam.getBackgroundColor()); } return backColor; } @@ -958,7 +958,7 @@ public class Cluster implements Moveable { } if (backColor == null || backColor.equals(HColorUtils.transparent()) /* || stateBack instanceof HtmlColorTransparent */) { - final HColor tmp = skinParam.getBackgroundColor(false); + final HColor tmp = skinParam.getBackgroundColor(); backColor = new HColorBackground(tmp); } return backColor; diff --git a/src/net/sourceforge/plantuml/svek/ConcurrentStateImage.java b/src/net/sourceforge/plantuml/svek/ConcurrentStateImage.java index caf59b673..4f8d421e3 100644 --- a/src/net/sourceforge/plantuml/svek/ConcurrentStateImage.java +++ b/src/net/sourceforge/plantuml/svek/ConcurrentStateImage.java @@ -109,7 +109,7 @@ public final class ConcurrentStateImage extends AbstractTextBlock implements IEn HColor backColor) { this.separator = Separator.fromChar(concurrentSeparator); this.skinParam = skinParam; - this.backColor = skinParam.getBackgroundColor(false); + this.backColor = skinParam.getBackgroundColor(); this.inners.addAll(images); } diff --git a/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek2InternalImage.java b/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek2InternalImage.java index b7fac7143..85ae8d800 100644 --- a/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek2InternalImage.java +++ b/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek2InternalImage.java @@ -139,7 +139,7 @@ public final class CucaDiagramFileMakerSvek2InternalImage extends AbstractTextBl } public HColor getBackcolor() { - return skinParam.getBackgroundColor(false); + return skinParam.getBackgroundColor(); } public double getOverscanX(StringBounder stringBounder) { diff --git a/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java b/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java index 193dbb441..104d67192 100644 --- a/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java +++ b/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java @@ -396,12 +396,12 @@ public final class GeneralImageBuilder { return style.value(PName.BackGroundColor).asColor(dotData.getSkinParam().getThemeStyle(), dotData.getSkinParam().getIHtmlColorSet()); } - return dotData.getSkinParam().getBackgroundColor(false); + return dotData.getSkinParam().getBackgroundColor(); } public IEntityImage buildImage(BaseFile basefile, String dotStrings[]) { if (dotData.isDegeneratedWithFewEntities(0)) { - return new EntityImageSimpleEmpty(dotData.getSkinParam().getBackgroundColor(false)); + return new EntityImageSimpleEmpty(dotData.getSkinParam().getBackgroundColor()); } if (dotData.isDegeneratedWithFewEntities(1) && dotData.getUmlDiagramType() != UmlDiagramType.STATE) { final ILeaf single = dotData.getLeafs().iterator().next(); diff --git a/src/net/sourceforge/plantuml/svek/SvekLine.java b/src/net/sourceforge/plantuml/svek/SvekLine.java index 7501720d1..46c25d0f8 100644 --- a/src/net/sourceforge/plantuml/svek/SvekLine.java +++ b/src/net/sourceforge/plantuml/svek/SvekLine.java @@ -229,7 +229,7 @@ public class SvekLine implements Moveable, Hideable, GuideLine { skinParam = link.getColors().mute(skinParam); font = font.mute(link.getColors()); } - this.backgroundColor = skinParam.getBackgroundColor(false); + this.backgroundColor = skinParam.getBackgroundColor(); this.defaultThickness = skinParam.getThickness(LineParam.arrow, null); this.arrowLollipopColor = skinParam.getHtmlColor(ColorParam.arrowLollipop, null, false); if (arrowLollipopColor == null) { diff --git a/src/net/sourceforge/plantuml/svek/SvekResult.java b/src/net/sourceforge/plantuml/svek/SvekResult.java index cb9a425c9..66e28f52e 100644 --- a/src/net/sourceforge/plantuml/svek/SvekResult.java +++ b/src/net/sourceforge/plantuml/svek/SvekResult.java @@ -147,7 +147,7 @@ public final class SvekResult extends AbstractTextBlock implements IEntityImage return style.value(PName.BackGroundColor).asColor(dotData.getSkinParam().getThemeStyle(), dotData.getSkinParam().getIHtmlColorSet()); } - return dotData.getSkinParam().getBackgroundColor(false); + return dotData.getSkinParam().getBackgroundColor(); } private MinMax minMax; diff --git a/test/net/sourceforge/plantuml/SkinParamTest.java b/test/net/sourceforge/plantuml/SkinParamTest.java index d111f718e..3892d20a7 100644 --- a/test/net/sourceforge/plantuml/SkinParamTest.java +++ b/test/net/sourceforge/plantuml/SkinParamTest.java @@ -1,5 +1,14 @@ package net.sourceforge.plantuml; +import static org.assertj.core.api.Assertions.assertThat; + +import java.awt.Color; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; +import org.junit.jupiter.params.provider.EnumSource; + import net.sourceforge.plantuml.cucadiagram.Rankdir; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.cucadiagram.dot.DotSplines; @@ -13,15 +22,6 @@ import net.sourceforge.plantuml.svg.LengthAdjust; import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity; import net.sourceforge.plantuml.ugraphic.color.HColorUtils; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.CsvSource; -import org.junit.jupiter.params.provider.EnumSource; - -import java.awt.Color; - -import static org.assertj.core.api.Assertions.assertThat; - class SkinParamTest { // @@ -43,8 +43,7 @@ class SkinParamTest { assertThat(skinParam.getAllSpriteNames()).isEmpty(); - assertThat(skinParam.getBackgroundColor(false)).isEqualTo(HColorUtils.WHITE); - assertThat(skinParam.getBackgroundColor(true)).isEqualTo(HColorUtils.WHITE); + assertThat(skinParam.getBackgroundColor()).isEqualTo(HColorUtils.WHITE); assertThat(skinParam.getCircledCharacter(fooStereotype)).isEqualTo('\0');