From b4d191a365587c4c5341c50171f95b0febf07fb1 Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Tue, 23 Aug 2022 18:39:27 +0200 Subject: [PATCH] Import version 1.2022.7 --- src/jcckit/util/ConfigParameters.java | 2 +- .../plantuml/EmptyImageBuilder.java | 4 +- src/net/sourceforge/plantuml/SkinParam.java | 19 ++- src/net/sourceforge/plantuml/SplitParam.java | 8 +- .../activitydiagram/command/CommandIf.java | 6 +- .../command/CommandLinkActivity.java | 4 +- .../command/CommandLinkLongActivity.java | 4 +- .../command/CommandCreateClassMultilines.java | 6 +- .../command/CommandLinkClass.java | 33 ++++- .../command/CommandLinkLollipop.java | 6 +- .../note/CommandFactoryNoteActivity.java | 8 +- .../note/CommandFactoryNoteOnEntity.java | 8 +- .../note/CommandFactoryTipOnEntity.java | 8 +- .../command/CommandLinkBlock.java | 4 +- .../plantuml/creole/atom/AtomMath.java | 4 +- .../plantuml/creole/legacy/AtomText.java | 7 +- .../plantuml/cucadiagram/Link.java | 26 ++-- .../plantuml/cucadiagram/LinkArg.java | 118 ++++++++++++++++++ .../plantuml/cucadiagram/Magma.java | 16 +-- .../command/CommandLinkElement.java | 6 +- .../plantuml/eggs/PSystemColors.java | 50 ++++---- .../plantuml/error/PSystemError.java | 8 +- .../plantuml/graphic/SymbolContext.java | 9 -- .../AbstractClassOrObjectDiagram.java | 78 ++++++------ .../command/CommandCreateMap.java | 4 +- .../plantuml/openiconic/OpenIcon.java | 9 +- .../salt/element/AbstractElement.java | 3 +- .../command/CommandGrouping.java | 5 +- .../skin/rose/ComponentRoseEnglober.java | 2 +- .../skin/rose/ComponentRoseGroupingElse.java | 4 - .../rose/ComponentRoseGroupingHeader.java | 4 - .../plantuml/sprite/ColorPalette.java | 11 +- .../plantuml/sprite/ColorPalette4096.java | 23 ++-- .../plantuml/sprite/SpriteMonochrome.java | 5 +- .../command/CommandLinkStateCommon.java | 2 +- .../sourceforge/plantuml/style/ValueImpl.java | 3 +- .../plantuml/tim/stdlib/HslColor.java | 6 +- .../plantuml/ugraphic/ImageBuilder.java | 47 ++++--- .../ugraphic/color/AbstractColorMapper.java | 6 - .../ugraphic/color/ColorMapperForceDark.java | 26 ++-- .../ugraphic/color/ColorMapperIdentity.java | 26 ++-- .../color/ColorMapperLightnessInverse.java | 18 +-- .../ugraphic/color/ColorMapperReverse.java | 11 +- .../color/ColorMapperTransparentWrapper.java | 11 +- .../plantuml/ugraphic/color/ColorUtils.java | 23 +++- .../plantuml/ugraphic/color/HColor.java | 4 + .../ugraphic/color/HColorAbstract.java | 12 +- .../ugraphic/color/HColorBackground.java | 60 --------- .../plantuml/ugraphic/color/HColorSet.java | 41 +++--- .../plantuml/ugraphic/color/HColorSimple.java | 58 ++++----- .../plantuml/ugraphic/color/HColors.java | 28 +++-- .../ugraphic/debug/UGraphicDebug.java | 2 - .../sourceforge/plantuml/version/Version.java | 6 +- test/nonreg/simple/A0002_TestResult.java | 2 +- test/nonreg/simple/A0005_TestResult.java | 8 +- test/nonreg/simple/A0006_TestResult.java | 8 +- 56 files changed, 486 insertions(+), 434 deletions(-) create mode 100644 src/net/sourceforge/plantuml/cucadiagram/LinkArg.java delete mode 100644 src/net/sourceforge/plantuml/ugraphic/color/HColorBackground.java diff --git a/src/jcckit/util/ConfigParameters.java b/src/jcckit/util/ConfigParameters.java index 151e68954..60a953b40 100644 --- a/src/jcckit/util/ConfigParameters.java +++ b/src/jcckit/util/ConfigParameters.java @@ -306,7 +306,7 @@ static private HColorSet colors = HColorSet.instance(); private Color decodeInternal(String value) { if (value!=null) { try { - return new ColorMapperIdentity().toColor(colors.getColor(ThemeStyle.LIGHT_REGULAR, value, null)); + return new ColorMapperIdentity().toColor(colors.getColor(ThemeStyle.LIGHT_REGULAR, value)); } catch (NoSuchColorException e) { return Color.WHITE; } diff --git a/src/net/sourceforge/plantuml/EmptyImageBuilder.java b/src/net/sourceforge/plantuml/EmptyImageBuilder.java index ed7e32d0a..7eea9a260 100644 --- a/src/net/sourceforge/plantuml/EmptyImageBuilder.java +++ b/src/net/sourceforge/plantuml/EmptyImageBuilder.java @@ -50,7 +50,7 @@ import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.ugraphic.UAntiAliasing; import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity; import net.sourceforge.plantuml.ugraphic.color.HColor; -import net.sourceforge.plantuml.ugraphic.color.HColorSimple; +import net.sourceforge.plantuml.ugraphic.color.HColors; import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d; public class EmptyImageBuilder { @@ -169,7 +169,7 @@ public class EmptyImageBuilder { } public UGraphicG2d getUGraphicG2d() { - final HColor back = new HColorSimple(background, false); + final HColor back = HColors.simple(background); final UGraphicG2d result = new UGraphicG2d(back, new ColorMapperIdentity(), stringBounder, g2d, 1.0); result.setBufferedImage(im); return result; diff --git a/src/net/sourceforge/plantuml/SkinParam.java b/src/net/sourceforge/plantuml/SkinParam.java index f4f5250ce..03c9b3f95 100644 --- a/src/net/sourceforge/plantuml/SkinParam.java +++ b/src/net/sourceforge/plantuml/SkinParam.java @@ -311,20 +311,19 @@ public class SkinParam implements ISkinParam { } } final String value = getValue(getParamName(param, clickable)); - if (value == null) { + if (value == null) return null; - } + if ((param == ColorParam.background || param == ColorParam.arrowHead) - && (value.equalsIgnoreCase("transparent") || value.equalsIgnoreCase("none"))) { + && (value.equalsIgnoreCase("transparent") || value.equalsIgnoreCase("none"))) return HColors.transparent(); - } - if (param == ColorParam.background) { + + if (param == ColorParam.background) return getIHtmlColorSet().getColorOrWhite(themeStyle, value); - } + assert param != ColorParam.background; -// final boolean acceptTransparent = param == ColorParam.background -// || param == ColorParam.sequenceGroupBodyBackground || param == ColorParam.sequenceBoxBackground; - return getIHtmlColorSet().getColorOrWhite(themeStyle, value, getBackgroundColor()); + + return getIHtmlColorSet().getColorOrWhite(themeStyle, value); } public char getCircledCharacter(Stereotype stereotype) { @@ -1040,7 +1039,7 @@ public class SkinParam implements ISkinParam { if (value == null) return null; - return getIHtmlColorSet().getColorOrWhite(themeStyle, value, null); + return getIHtmlColorSet().getColorOrWhite(themeStyle, value); } public double getPadding() { diff --git a/src/net/sourceforge/plantuml/SplitParam.java b/src/net/sourceforge/plantuml/SplitParam.java index 87c895f09..6b8366204 100644 --- a/src/net/sourceforge/plantuml/SplitParam.java +++ b/src/net/sourceforge/plantuml/SplitParam.java @@ -68,16 +68,16 @@ public class SplitParam { } public Color getBorderColor() { - if (borderColor == null) { + if (borderColor == null) return null; - } + return ((HColorSimple) borderColor).getColor999(); } public Color getExternalColor() { - if (externalColor == null) { + if (externalColor == null) return null; - } + return ((HColorSimple) externalColor).getColor999(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java index c0cb17691..5e644b133 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java @@ -123,9 +123,9 @@ public class CommandIf extends SingleLineCommand2 { final IEntity branch = diagram.getCurrentContext().getBranch(); - Link link = new Link(entity1, branch, new LinkType(LinkDecor.ARROW, LinkDecor.NONE), - Display.getWithNewlines(arg.get("BRACKET", 0)), lenght, null, ifLabel, diagram.getLabeldistance(), - diagram.getLabelangle(), diagram.getSkinParam().getCurrentStyleBuilder()); + Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), entity1, branch, + new LinkType(LinkDecor.ARROW, LinkDecor.NONE), Display.getWithNewlines(arg.get("BRACKET", 0)), lenght, null, ifLabel, + diagram.getLabeldistance(), diagram.getLabelangle()); if (arg.get("ARROW", 0) != null) { final Direction direction = StringUtils.getArrowDirection(arg.get("ARROW", 0)); if (direction == Direction.LEFT || direction == Direction.UP) { diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java index 0f92352fc..45ba50399 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java @@ -167,8 +167,8 @@ public class CommandLinkActivity extends SingleLineCommand2 { type = type.goDotted(); } - Link link = new Link(entity1, entity2, type, linkLabel, lenght, - diagram.getSkinParam().getCurrentStyleBuilder()); + Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), entity1, entity2, type, linkLabel, + lenght); if (arrowDirection.contains("*")) { link.setConstraint(false); } diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java index 2bb065365..c46f411c1 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java @@ -218,8 +218,8 @@ public class CommandLinkLongActivity extends CommandMultilines2 if (arrow.contains(".")) { type = type.goDotted(); } - Link link = new Link(entity1, entity2, type, linkLabel, lenght, - diagram.getSkinParam().getCurrentStyleBuilder()); + Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), entity1, entity2, type, linkLabel, + lenght); final Direction direction = StringUtils.getArrowDirection(arrowBody1 + arrowDirection + arrowBody2 + ">"); if (direction == Direction.LEFT || direction == Direction.UP) { link = link.getInv(); diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java index ee891ebce..b3d7b42db 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java @@ -214,9 +214,9 @@ public class CommandCreateClassMultilines extends CommandMultilines2\\>?|_\\>|[(#\\]>*+^\\{]|[\\|\\:]\\|\\>|\\|[>\\]]|o\\{|\\|\\{|o\\||\\|\\|)?")), // - RegexLeaf.spaceZeroOrMore(), new RegexOptional(new RegexLeaf("SECOND_LABEL", "[%g]([^%g]+)[%g]")), // + RegexLeaf.spaceZeroOrMore(), // + + new RegexOptional(new RegexLeaf("SECOND_LABEL", "[%g]([^%g]+)[%g]")), // + new RegexOptional(new RegexConcat( // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("[\\[]"), // + new RegexLeaf("QUALIFIER2", "([^\\[\\]]+)"), // + new RegexLeaf("[\\]]"), // + RegexLeaf.spaceOneOrMore() // + )), // + + RegexLeaf.spaceZeroOrMore(), // + new RegexOr( // new RegexLeaf("ENT2", getClassIdentifier()), // new RegexLeaf("COUPLE2", COUPLE)), // @@ -210,9 +231,9 @@ final public class CommandLinkClass extends SingleLineCommand2 { final String queue = arg.get("QUEUE", 0); - final Link link = new Link(cl1, cl2, linkType, Display.getWithNewlines(arg.get("DISPLAY", 0)), queue.length(), - diagram.getSkinParam().getCurrentStyleBuilder()); + final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, Display.getWithNewlines(arg.get("DISPLAY", 0)), + queue.length()); diagram.addLink(link); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/creole/atom/AtomMath.java b/src/net/sourceforge/plantuml/creole/atom/AtomMath.java index a886afead..8300b1189 100644 --- a/src/net/sourceforge/plantuml/creole/atom/AtomMath.java +++ b/src/net/sourceforge/plantuml/creole/atom/AtomMath.java @@ -101,9 +101,9 @@ public class AtomMath extends AbstractAtom implements Atom { } private Color getColor(HColor color, Color defaultValue) { - if (color instanceof HColorSimple) { + if (color instanceof HColorSimple) return colorMapper.toColor(color); - } + return defaultValue; } diff --git a/src/net/sourceforge/plantuml/creole/legacy/AtomText.java b/src/net/sourceforge/plantuml/creole/legacy/AtomText.java index e322ea406..05059015a 100644 --- a/src/net/sourceforge/plantuml/creole/legacy/AtomText.java +++ b/src/net/sourceforge/plantuml/creole/legacy/AtomText.java @@ -35,7 +35,6 @@ */ package net.sourceforge.plantuml.creole.legacy; -import net.sourceforge.plantuml.awt.geom.Dimension2D; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -49,6 +48,7 @@ import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.Log; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.awt.geom.Dimension2D; import net.sourceforge.plantuml.creole.atom.AbstractAtom; import net.sourceforge.plantuml.creole.atom.Atom; import net.sourceforge.plantuml.graphic.FontConfiguration; @@ -58,9 +58,8 @@ import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UText; import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.color.HColor; -import net.sourceforge.plantuml.ugraphic.color.HColorScheme; import net.sourceforge.plantuml.ugraphic.color.HColorAutomagic; -import net.sourceforge.plantuml.ugraphic.color.HColorSimple; +import net.sourceforge.plantuml.ugraphic.color.HColorScheme; import net.sourceforge.plantuml.utils.CharHidder; public final class AtomText extends AbstractAtom implements Atom { @@ -144,7 +143,7 @@ public final class AtomText extends AbstractAtom implements Atom { HColor textColor = fontConfiguration.getColor(); FontConfiguration useFontConfiguration = fontConfiguration; if (textColor instanceof HColorAutomagic && ug.getParam().getBackcolor() != null) { - textColor = ((HColorSimple) ug.getParam().getBackcolor()).opposite(); + textColor = ug.getParam().getBackcolor().opposite(); useFontConfiguration = fontConfiguration.changeColor(textColor); } if (textColor instanceof HColorScheme) { diff --git a/src/net/sourceforge/plantuml/cucadiagram/Link.java b/src/net/sourceforge/plantuml/cucadiagram/Link.java index 873a3a9e5..9e84e5939 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Link.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Link.java @@ -121,21 +121,20 @@ public class Link extends WithLinkType implements Hideable, Removeable { return new UComment("link " + getEntity1().getCodeGetName() + " to " + getEntity2().getCodeGetName()); } - public Link(IEntity cl1, IEntity cl2, LinkType type, Display label, int length, StyleBuilder styleBuilder) { - this(cl1, cl2, type, label, length, null, null, null, null, null, styleBuilder); + public Link(StyleBuilder styleBuilder, IEntity cl1, IEntity cl2, LinkType type, Display label, int length) { + this(styleBuilder, cl1, cl2, type, label, length, null, null, null, null, null); } - public Link(IEntity cl1, IEntity cl2, LinkType type, Display label, int length, String qualifier1, - String qualifier2, String labeldistance, String labelangle, StyleBuilder styleBuilder) { - this(cl1, cl2, type, label, length, qualifier1, qualifier2, labeldistance, labelangle, null, styleBuilder); + public Link(StyleBuilder styleBuilder, IEntity cl1, IEntity cl2, LinkType type, Display label, int length, + String qualifier1, String qualifier2, String labeldistance, String labelangle) { + this(styleBuilder, cl1, cl2, type, label, length, qualifier1, qualifier2, labeldistance, labelangle, null); } - public Link(IEntity cl1, IEntity cl2, LinkType type, Display label, int length, String qualifier1, - String qualifier2, String labeldistance, String labelangle, HColor specificColor, - StyleBuilder styleBuilder) { - if (length < 1) + public Link(StyleBuilder styleBuilder, IEntity cl1, IEntity cl2, LinkType type, Display label, int length, + String qualifier1, String qualifier2, String labeldistance, String labelangle, HColor specificColor) { + if (length < 1) throw new IllegalArgumentException(); - + this.styleBuilder = styleBuilder; this.cl1 = Objects.requireNonNull(cl1); this.cl2 = Objects.requireNonNull(cl2); @@ -144,9 +143,8 @@ public class Link extends WithLinkType implements Hideable, Removeable { this.label = Display.NULL; } else { this.label = label.manageGuillemet(); - if (VisibilityModifier.isVisibilityCharacter(label.get(0))) { + if (VisibilityModifier.isVisibilityCharacter(label.get(0))) visibilityModifier = VisibilityModifier.getVisibilityModifier(label.get(0), false); - } } this.length = length; @@ -164,8 +162,8 @@ public class Link extends WithLinkType implements Hideable, Removeable { } public Link getInv() { - final Link result = new Link(cl2, cl1, getType().getInversed(), label, length, qualifier2, qualifier1, - labeldistance, labelangle, getSpecificColor(), styleBuilder); + final Link result = new Link(styleBuilder, cl2, cl1, getType().getInversed(), label, length, qualifier2, + qualifier1, labeldistance, labelangle, getSpecificColor()); result.inverted = !this.inverted; result.port1 = this.port2; result.port2 = this.port1; diff --git a/src/net/sourceforge/plantuml/cucadiagram/LinkArg.java b/src/net/sourceforge/plantuml/cucadiagram/LinkArg.java new file mode 100644 index 000000000..28db293df --- /dev/null +++ b/src/net/sourceforge/plantuml/cucadiagram/LinkArg.java @@ -0,0 +1,118 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2023, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.cucadiagram; + +import net.sourceforge.plantuml.skin.VisibilityModifier; +import net.sourceforge.plantuml.ugraphic.color.HColor; + +public class LinkArg { + + private final Display label; + private final int length; + private final String qualifier1; + private final String qualifier2; + private final String labeldistance; + private final String labelangle; + private final HColor specificColor; + private VisibilityModifier visibilityModifier; + + public LinkArg(Display label, int length) { + this(label, length, null, null, null, null, null); + } + + public LinkArg withQualifier(String qualifier1, String qualifier2) { + return new LinkArg(label, length, qualifier1, qualifier2, labeldistance, labelangle, specificColor); + } + + public LinkArg withDistanceAngle(String labeldistance, String labelangle) { + return new LinkArg(label, length, qualifier1, qualifier2, labeldistance, labelangle, specificColor); + } + + public LinkArg withColor(HColor specificColor) { + return new LinkArg(label, length, qualifier1, qualifier2, labeldistance, labelangle, specificColor); + } + + private LinkArg(Display label, int length, String qualifier1, String qualifier2, String labeldistance, + String labelangle, HColor specificColor) { + + if (Display.isNull(label)) { + this.label = Display.NULL; + } else { + this.label = label.manageGuillemet(); + if (VisibilityModifier.isVisibilityCharacter(label.get(0))) + visibilityModifier = VisibilityModifier.getVisibilityModifier(label.get(0), false); + } + + this.length = length; + this.qualifier1 = qualifier1; + this.qualifier2 = qualifier2; + this.labeldistance = labeldistance; + this.labelangle = labelangle; + this.specificColor = specificColor; + } + + public final Display getLabel() { + return label; + } + + public final int getLength() { + return length; + } + + public final String getQualifier1() { + return qualifier1; + } + + public final String getQualifier2() { + return qualifier2; + } + + public final String getLabeldistance() { + return labeldistance; + } + + public final String getLabelangle() { + return labelangle; + } + + public final HColor getSpecificColor() { + return specificColor; + } + + public final VisibilityModifier getVisibilityModifier() { + return visibilityModifier; + } +} diff --git a/src/net/sourceforge/plantuml/cucadiagram/Magma.java b/src/net/sourceforge/plantuml/cucadiagram/Magma.java index f6b99da60..6bad64009 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Magma.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Magma.java @@ -51,13 +51,13 @@ class Magma { public void putInSquare() { final SquareLinker linker = new SquareLinker() { public void topDown(ILeaf top, ILeaf down) { - diagram.addLink(new Link(top, down, linkType, Display.NULL, 2, diagram.getSkinParam() - .getCurrentStyleBuilder())); + diagram.addLink(new Link(diagram.getSkinParam() + .getCurrentStyleBuilder(), top, down, linkType, Display.NULL, 2)); } public void leftRight(ILeaf left, ILeaf right) { - diagram.addLink(new Link(left, right, linkType, Display.NULL, 1, diagram.getSkinParam() - .getCurrentStyleBuilder())); + diagram.addLink(new Link(diagram.getSkinParam() + .getCurrentStyleBuilder(), left, right, linkType, Display.NULL, 1)); } }; new SquareMaker().putInSquare(standalones, linker); @@ -103,14 +103,14 @@ class Magma { } public void linkToDown(Magma down) { - diagram.addLink(new Link(this.getBottomLeft(), down.getTopLeft(), linkType, Display.NULL, 2, diagram - .getSkinParam().getCurrentStyleBuilder())); + diagram.addLink(new Link(diagram + .getSkinParam().getCurrentStyleBuilder(), this.getBottomLeft(), down.getTopLeft(), linkType, Display.NULL, 2)); } public void linkToRight(Magma right) { - diagram.addLink(new Link(this.getTopRight(), right.getTopLeft(), linkType, Display.NULL, 1, diagram - .getSkinParam().getCurrentStyleBuilder())); + diagram.addLink(new Link(diagram + .getSkinParam().getCurrentStyleBuilder(), this.getTopRight(), right.getTopLeft(), linkType, Display.NULL, 1)); } } diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java index 1688a95c6..681de92dc 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java @@ -258,9 +258,9 @@ public class CommandLinkElement extends SingleLineCommand2 { cl1 = getFoo1(diagram, code1, ident1, ident1pure); cl2 = getFoo1(diagram, code2, ident2, ident2pure); } - Link link = new Link(cl1, cl2, linkType, Display.getWithNewlines(labels.getLabelLink()), queue.length(), - labels.getFirstLabel(), labels.getSecondLabel(), diagram.getLabeldistance(), diagram.getLabelangle(), - diagram.getSkinParam().getCurrentStyleBuilder()); + Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, Display.getWithNewlines(labels.getLabelLink()), + queue.length(), labels.getFirstLabel(), labels.getSecondLabel(), diagram.getLabeldistance(), + diagram.getLabelangle()); link.setLinkArrow(labels.getLinkArrow()); if (dir == Direction.LEFT || dir == Direction.UP) link = link.getInv(); diff --git a/src/net/sourceforge/plantuml/eggs/PSystemColors.java b/src/net/sourceforge/plantuml/eggs/PSystemColors.java index a674e48c4..ee1b8d11f 100644 --- a/src/net/sourceforge/plantuml/eggs/PSystemColors.java +++ b/src/net/sourceforge/plantuml/eggs/PSystemColors.java @@ -77,11 +77,11 @@ public class PSystemColors extends PlainDiagram implements UDrawable { public PSystemColors(UmlSource source, String option) { super(source); - if (option == null) { + if (option == null) this.paletteCentralColor = null; - } else { + else this.paletteCentralColor = option.replaceAll("\\#", ""); - } + } @Override @@ -94,11 +94,10 @@ public class PSystemColors extends PlainDiagram implements UDrawable { } public void drawU(UGraphic ug) { - if (paletteCentralColor != null && colors.getColorOrWhite(paletteCentralColor) instanceof HColorSimple) { + if (paletteCentralColor != null && colors.getColorOrWhite(paletteCentralColor) instanceof HColorSimple) drawPalette(ug); - } else { + else drawFull(ug); - } } private void drawPalette(UGraphic ug) { @@ -145,7 +144,7 @@ public class PSystemColors extends PlainDiagram implements UDrawable { } private void drawOneHexa(UGraphic ug, String colorName, int i, int j, UPolygon hexa) { - final HColorSimple color = (HColorSimple) colors.getColorOrWhite(colorName); + final HColor color = colors.getColorOrWhite(colorName); ug = applyColor(ug, color); ug = ug.apply(new UTranslate(centerHexa(i, j))); ug.draw(hexa); @@ -165,9 +164,9 @@ public class PSystemColors extends PlainDiagram implements UDrawable { String result = null; double min = Double.MAX_VALUE; for (int i = 1; i < colorName.length() - 1; i++) { - if (Character.isLowerCase(colorName.charAt(i))) { + if (Character.isLowerCase(colorName.charAt(i))) continue; - } + final String candidat = colorName.substring(0, i) + BackSlash.BS_BS_N + colorName.substring(i); final TextBlock tt = getTextName(font, candidat, (HColorSimple) HColors.BLACK); final double width = tt.calculateDimension(stringBounder).getWidth(); @@ -191,9 +190,9 @@ public class PSystemColors extends PlainDiagram implements UDrawable { private UPolygon getHexa() { final UPolygon result = new UPolygon(); - for (int i = 0; i < 6; i++) { + for (int i = 0; i < 6; i++) result.addPoint(corner(i)); - } + return result; } @@ -202,26 +201,25 @@ public class PSystemColors extends PlainDiagram implements UDrawable { for (Iterator it = result.iterator(); it.hasNext();) { final String candidat = it.next(); final String similar = candidat.replaceAll("Gray", "Grey"); - if (candidat.equals(similar)) { + if (candidat.equals(similar)) continue; - } - if (result.contains(similar)) { + + if (result.contains(similar)) it.remove(); - } + } - if (containsCaseInsensitive(result, other) == false) { + if (containsCaseInsensitive(result, other) == false) result.add(other); - } + Collections.sort(result, closeComparator(paletteCentralColor)); return result; } private boolean containsCaseInsensitive(Collection source, String target) { - for (String s : source) { - if (s.equalsIgnoreCase(target)) { + for (String s : source) + if (s.equalsIgnoreCase(target)) return true; - } - } + return false; } @@ -229,8 +227,8 @@ public class PSystemColors extends PlainDiagram implements UDrawable { final HColorSimple centerColor = (HColorSimple) colors.getColorOrWhite(center); return new Comparator() { public int compare(String col1, String col2) { - final double dist1 = centerColor.distance((HColorSimple) colors.getColorOrWhite(col1)); - final double dist2 = centerColor.distance((HColorSimple) colors.getColorOrWhite(col2)); + final int dist1 = centerColor.distanceTo((HColorSimple) colors.getColorOrWhite(col1)); + final int dist2 = centerColor.distanceTo((HColorSimple) colors.getColorOrWhite(col2)); return (int) Math.signum(dist1 - dist2); } }; @@ -244,7 +242,7 @@ public class PSystemColors extends PlainDiagram implements UDrawable { int j = 0; for (String name : colors.names()) { UGraphic tmp = getPositioned(ug, i, j); - final HColorSimple color = (HColorSimple) colors.getColorOrWhite(name); + final HColor color = colors.getColorOrWhite(name); applyColor(tmp, color).draw(new URectangle(rectangleWidth, rectangleHeight)); final TextBlock tt = getTextName(font, name, color); final Dimension2D dimText = tt.calculateDimension(ug.getStringBounder()); @@ -258,8 +256,8 @@ public class PSystemColors extends PlainDiagram implements UDrawable { } } - private TextBlock getTextName(final UFont font, String name, final HColorSimple color) { - final HColorSimple opposite = color.opposite(); + private TextBlock getTextName(final UFont font, String name, final HColor color) { + final HColor opposite = color.opposite(); final FontConfiguration fc = FontConfiguration.create(font, opposite, HColors.BLUE, true); final TextBlock tt = Display.getWithNewlines(name).create(fc, HorizontalAlignment.CENTER, new SpriteContainerEmpty()); diff --git a/src/net/sourceforge/plantuml/error/PSystemError.java b/src/net/sourceforge/plantuml/error/PSystemError.java index 1274ceaec..376d7874c 100644 --- a/src/net/sourceforge/plantuml/error/PSystemError.java +++ b/src/net/sourceforge/plantuml/error/PSystemError.java @@ -35,7 +35,6 @@ package net.sourceforge.plantuml.error; import java.awt.Color; -import net.sourceforge.plantuml.awt.geom.Dimension2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.IOException; @@ -58,6 +57,7 @@ import net.sourceforge.plantuml.SpriteContainerEmpty; import net.sourceforge.plantuml.StringLocated; import net.sourceforge.plantuml.api.ImageDataSimple; import net.sourceforge.plantuml.asciiart.UmlCharArea; +import net.sourceforge.plantuml.awt.geom.Dimension2D; import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.UmlSource; @@ -368,7 +368,7 @@ public abstract class PSystemError extends PlainDiagram { } private TextBlockBackcolored getMessageAdopt() { - final HColorSimple backColor = (HColorSimple) HColorSet.instance().getColorOrWhite("#eff4d2"); + final HColor backColor = HColorSet.instance().getColorOrWhite("#eff4d2"); final Display disp = Display.create("Adopt-a-Word and put your message here!", " ", "Details on [[http://plantuml.com/adopt]]", " "); @@ -387,7 +387,7 @@ public abstract class PSystemError extends PlainDiagram { final UImage message = new UImage( new PixelImage(PSystemVersion.getTime01(), AffineTransformType.TYPE_BILINEAR)); final Color back = new Color(message.getImage(1).getRGB(0, 0)); - final HColor backColor = new HColorSimple(back, false); + final HColor backColor = HColors.simple(back); final FlashCodeUtils utils = FlashCodeFactory.getFlashCodeUtils(); final BufferedImage qrcode = smaller( @@ -434,7 +434,7 @@ public abstract class PSystemError extends PlainDiagram { final UImage message = new UImage( new PixelImage(PSystemVersion.getTime15(), AffineTransformType.TYPE_BILINEAR)); final Color back = new Color(message.getImage(1).getRGB(0, 0)); - final HColor backColor = new HColorSimple(back, false); + final HColor backColor = HColors.simple(back); final FlashCodeUtils utils = FlashCodeFactory.getFlashCodeUtils(); final BufferedImage qrcode = smaller(utils.exportFlashcode("http://plantuml.com/lp", Color.BLACK, Color.WHITE)); diff --git a/src/net/sourceforge/plantuml/graphic/SymbolContext.java b/src/net/sourceforge/plantuml/graphic/SymbolContext.java index 92363d508..330a17e23 100644 --- a/src/net/sourceforge/plantuml/graphic/SymbolContext.java +++ b/src/net/sourceforge/plantuml/graphic/SymbolContext.java @@ -38,7 +38,6 @@ package net.sourceforge.plantuml.graphic; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.color.HColor; -import net.sourceforge.plantuml.ugraphic.color.HColorBackground; import net.sourceforge.plantuml.ugraphic.color.HColors; public class SymbolContext { @@ -88,14 +87,6 @@ public class SymbolContext { return ug.apply(stroke); } - public SymbolContext transparentBackColorToNull() { - if (backColor instanceof HColorBackground) { - return new SymbolContext(((HColorBackground) backColor).getNull(), foreColor, stroke, deltaShadow, - roundCorner, diagonalCorner); - } - return this; - } - public SymbolContext(HColor backColor, HColor foreColor) { this(backColor, foreColor, new UStroke(), 0, 0, 0); } diff --git a/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java b/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java index 47cd1a8b8..b10b79cbb 100644 --- a/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java +++ b/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java @@ -78,11 +78,11 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram if (link == null) { return false; } - final Link l1 = new Link(entity1, node, link.getType(), link.getLabel(), link.getLength(), link.getQualifier1(), - null, link.getLabeldistance(), link.getLabelangle(), getSkinParam().getCurrentStyleBuilder()); - final Link l2 = new Link(node, entity2, link.getType(), link.getLabel(), link.getLength(), null, - link.getQualifier2(), link.getLabeldistance(), link.getLabelangle(), - getSkinParam().getCurrentStyleBuilder()); + final Link l1 = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, node, link.getType(), link.getLabel(), link.getLength(), + link.getQualifier1(), null, link.getLabeldistance(), link.getLabelangle()); + final Link l2 = new Link(getSkinParam().getCurrentStyleBuilder(), node, entity2, link.getType(), link.getLabel(), link.getLength(), + null, link.getQualifier2(), link.getLabeldistance(), + link.getLabelangle()); addLink(l1); addLink(l2); removeLink(link); @@ -147,8 +147,8 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram insertPointBetween(entity2A, entity2B, point2); final int length = 1; - final Link point1ToPoint2 = new Link(point1, point2, linkType, label, length, - getSkinParam().getCurrentStyleBuilder()); + final Link point1ToPoint2 = new Link(getSkinParam().getCurrentStyleBuilder(), point1, point2, linkType, label, + length); addLink(point1ToPoint2); return CommandExecutionResult.ok(); @@ -159,8 +159,8 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram private void insertPointBetween(final IEntity entity1A, final IEntity entity1B, final IEntity point1) { Link existingLink1 = foundLink(entity1A, entity1B); if (existingLink1 == null) { - existingLink1 = new Link(entity1A, entity1B, new LinkType(LinkDecor.NONE, LinkDecor.NONE), Display.NULL, 2, - getSkinParam().getCurrentStyleBuilder()); + existingLink1 = new Link(getSkinParam().getCurrentStyleBuilder(), entity1A, entity1B, new LinkType(LinkDecor.NONE, LinkDecor.NONE), Display.NULL, + 2); } else { removeLink(existingLink1); } @@ -170,14 +170,14 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram final IEntity entity2real = existingLink1.isInverted() ? existingLink1.getEntity1() : existingLink1.getEntity2(); - final Link entity1ToPoint = new Link(entity1real, point1, existingLink1.getType().getPart2(), - existingLink1.getLabel(), existingLink1.getLength(), existingLink1.getQualifier1(), null, - existingLink1.getLabeldistance(), existingLink1.getLabelangle(), - getSkinParam().getCurrentStyleBuilder()); + final Link entity1ToPoint = new Link(getSkinParam().getCurrentStyleBuilder(), entity1real, point1, + existingLink1.getType().getPart2(), existingLink1.getLabel(), existingLink1.getLength(), existingLink1.getQualifier1(), + null, existingLink1.getLabeldistance(), + existingLink1.getLabelangle()); entity1ToPoint.setLinkArrow(existingLink1.getLinkArrow()); - final Link pointToEntity2 = new Link(point1, entity2real, existingLink1.getType().getPart1(), Display.NULL, - existingLink1.getLength(), null, existingLink1.getQualifier2(), existingLink1.getLabeldistance(), - existingLink1.getLabelangle(), getSkinParam().getCurrentStyleBuilder()); + final Link pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point1, entity2real, existingLink1.getType().getPart1(), + Display.NULL, existingLink1.getLength(), null, existingLink1.getQualifier2(), + existingLink1.getLabeldistance(), existingLink1.getLabelangle()); // int length = 1; // if (existingLink.getLength() == 1 && entity1A != entity1B) { @@ -268,8 +268,8 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram void createNew(int mode, LinkType linkType, Display label) { existingLink = foundLink(entity1, entity2); if (existingLink == null) { - existingLink = new Link(entity1, entity2, new LinkType(LinkDecor.NONE, LinkDecor.NONE), Display.NULL, 2, - getSkinParam().getCurrentStyleBuilder()); + existingLink = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, entity2, new LinkType(LinkDecor.NONE, LinkDecor.NONE), Display.NULL, + 2); } else { removeLink(existingLink); } @@ -279,13 +279,13 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram final IEntity entity2real = existingLink.isInverted() ? existingLink.getEntity1() : existingLink.getEntity2(); - entity1ToPoint = new Link(entity1real, point, existingLink.getType().getPart2(), existingLink.getLabel(), - existingLink.getLength(), existingLink.getQualifier1(), null, existingLink.getLabeldistance(), - existingLink.getLabelangle(), getSkinParam().getCurrentStyleBuilder()); + entity1ToPoint = new Link(getSkinParam().getCurrentStyleBuilder(), entity1real, point, existingLink.getType().getPart2(), + existingLink.getLabel(), existingLink.getLength(), existingLink.getQualifier1(), null, + existingLink.getLabeldistance(), existingLink.getLabelangle()); entity1ToPoint.setLinkArrow(existingLink.getLinkArrow()); - pointToEntity2 = new Link(point, entity2real, existingLink.getType().getPart1(), Display.NULL, - existingLink.getLength(), null, existingLink.getQualifier2(), existingLink.getLabeldistance(), - existingLink.getLabelangle(), getSkinParam().getCurrentStyleBuilder()); + pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point, entity2real, existingLink.getType().getPart1(), + Display.NULL, existingLink.getLength(), null, existingLink.getQualifier2(), + existingLink.getLabeldistance(), existingLink.getLabelangle()); int length = 1; if (existingLink.getLength() == 1 && entity1 != entity2) { @@ -304,11 +304,11 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram addLink(pointToEntity2); if (mode == 1) { - pointToAssocied = new Link(point, associed, linkType, label, length, - getSkinParam().getCurrentStyleBuilder()); + pointToAssocied = new Link(getSkinParam().getCurrentStyleBuilder(), point, associed, linkType, label, + length); } else { - pointToAssocied = new Link(associed, point, linkType, label, length, - getSkinParam().getCurrentStyleBuilder()); + pointToAssocied = new Link(getSkinParam().getCurrentStyleBuilder(), associed, point, linkType, label, + length); } addLink(pointToAssocied); } @@ -316,18 +316,18 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram void createInSecond(LinkType linkType, Display label) { existingLink = foundLink(entity1, entity2); if (existingLink == null) { - existingLink = new Link(entity1, entity2, new LinkType(LinkDecor.NONE, LinkDecor.NONE), Display.NULL, 2, - getSkinParam().getCurrentStyleBuilder()); + existingLink = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, entity2, new LinkType(LinkDecor.NONE, LinkDecor.NONE), Display.NULL, + 2); } else { removeLink(existingLink); } - entity1ToPoint = new Link(entity1, point, existingLink.getType().getPart2(), existingLink.getLabel(), 2, - existingLink.getQualifier1(), null, existingLink.getLabeldistance(), existingLink.getLabelangle(), - getSkinParam().getCurrentStyleBuilder()); - pointToEntity2 = new Link(point, entity2, existingLink.getType().getPart1(), Display.NULL, 2, null, - existingLink.getQualifier2(), existingLink.getLabeldistance(), existingLink.getLabelangle(), - getSkinParam().getCurrentStyleBuilder()); + entity1ToPoint = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, point, existingLink.getType().getPart2(), existingLink.getLabel(), + 2, existingLink.getQualifier1(), null, existingLink.getLabeldistance(), + existingLink.getLabelangle()); + pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point, entity2, existingLink.getType().getPart1(), Display.NULL, 2, + null, existingLink.getQualifier2(), existingLink.getLabeldistance(), + existingLink.getLabelangle()); // entity1ToPoint = new Link(entity1, point, existingLink.getType(), // null, 2); // pointToEntity2 = new Link(point, entity2, existingLink.getType(), @@ -339,11 +339,11 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram other.pointToAssocied = other.pointToAssocied.getInv(); addLink(other.pointToAssocied); } - pointToAssocied = new Link(point, associed, linkType, label, 1, getSkinParam().getCurrentStyleBuilder()); + pointToAssocied = new Link(getSkinParam().getCurrentStyleBuilder(), point, associed, linkType, label, 1); addLink(pointToAssocied); - final Link lnode = new Link(other.point, this.point, new LinkType(LinkDecor.NONE, LinkDecor.NONE), - Display.NULL, 1, getSkinParam().getCurrentStyleBuilder()); + final Link lnode = new Link(getSkinParam().getCurrentStyleBuilder(), other.point, this.point, + new LinkType(LinkDecor.NONE, LinkDecor.NONE), Display.NULL, 1); lnode.setInvis(true); addLink(lnode); diff --git a/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateMap.java b/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateMap.java index 6ce1adad3..7aa9577dc 100644 --- a/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateMap.java +++ b/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateMap.java @@ -128,8 +128,8 @@ public class CommandCreateMap extends CommandMultilines2 final LinkType linkType = new LinkType(LinkDecor.ARROW, LinkDecor.NONE); final int length = linkStr.length() - 2; - final Link link = new Link(entity1, entity2, linkType, Display.NULL, length, - diagram.getSkinParam().getCurrentStyleBuilder()); + final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), entity1, entity2, linkType, Display.NULL, + length); link.setPortMembers(key, null); diagram.addLink(link); } diff --git a/src/net/sourceforge/plantuml/openiconic/OpenIcon.java b/src/net/sourceforge/plantuml/openiconic/OpenIcon.java index cd77973b3..1e68afab6 100644 --- a/src/net/sourceforge/plantuml/openiconic/OpenIcon.java +++ b/src/net/sourceforge/plantuml/openiconic/OpenIcon.java @@ -54,7 +54,6 @@ import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorAutomagic; -import net.sourceforge.plantuml.ugraphic.color.HColorSimple; public class OpenIcon { @@ -103,7 +102,7 @@ public class OpenIcon { } void saveCopy(SFile fnew) throws IOException { - try(PrintWriter pw = fnew.createPrintWriter()) { + try (PrintWriter pw = fnew.createPrintWriter()) { pw.println(rawData.get(0)); pw.println(svgPath.toSvg()); pw.println(rawData.get(rawData.size() - 1)); @@ -136,9 +135,9 @@ public class OpenIcon { return new AbstractTextBlock() { public void drawU(UGraphic ug) { HColor textColor = color; - if (textColor instanceof HColorAutomagic && ug.getParam().getBackcolor() != null) { - textColor = ((HColorSimple) ug.getParam().getBackcolor()).opposite(); - } + if (textColor instanceof HColorAutomagic && ug.getParam().getBackcolor() != null) + textColor = ug.getParam().getBackcolor().opposite(); + svgPath.drawMe(ug.apply(textColor), factor); } diff --git a/src/net/sourceforge/plantuml/salt/element/AbstractElement.java b/src/net/sourceforge/plantuml/salt/element/AbstractElement.java index 2cd0334e3..f65cd4400 100644 --- a/src/net/sourceforge/plantuml/salt/element/AbstractElement.java +++ b/src/net/sourceforge/plantuml/salt/element/AbstractElement.java @@ -39,7 +39,6 @@ import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorSet; -import net.sourceforge.plantuml.ugraphic.color.HColorSimple; import net.sourceforge.plantuml.ugraphic.color.HColors; public abstract class AbstractElement implements Element { @@ -73,7 +72,7 @@ public abstract class AbstractElement implements Element { } private HColor buildColor(String color1, String color2) { - final HColorSimple tmp1 = (HColorSimple) HColorSet.instance().getColorOrWhite(null, color1); + final HColor tmp1 = HColorSet.instance().getColorOrWhite(null, color1); final HColor tmp2 = HColorSet.instance().getColorOrWhite(null, color2); return tmp1.withDark(tmp2); } diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandGrouping.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandGrouping.java index 859c29bda..7815b7a28 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandGrouping.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandGrouping.java @@ -79,13 +79,12 @@ public class CommandGrouping extends SingleLineCommand2 { final HColorSet colorSet = diagram.getSkinParam().getIHtmlColorSet(); HColor backColorElement = null; if (s != null) { - backColorElement = colorSet.getColor(diagram.getSkinParam().getThemeStyle(), s, null); + backColorElement = colorSet.getColor(diagram.getSkinParam().getThemeStyle(), s); } final String s2 = arg.get("COLORS", 1); HColor backColorGeneral = null; if (s2 != null) { - backColorGeneral = colorSet.getColor(diagram.getSkinParam().getThemeStyle(), s2, - diagram.getSkinParam().getBackgroundColor()); + backColorGeneral = colorSet.getColor(diagram.getSkinParam().getThemeStyle(), s2); } String comment = arg.get("COMMENT", 0); final GroupingType groupingType = GroupingType.getType(type); diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseEnglober.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseEnglober.java index d423776cc..7814eda48 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseEnglober.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseEnglober.java @@ -63,7 +63,7 @@ public class ComponentRoseEnglober extends AbstractTextualComponent { @Override protected void drawBackgroundInternalU(UGraphic ug, Area area) { final Dimension2D dimensionToUse = area.getDimensionToUse(); - ug = symbolContext.transparentBackColorToNull().apply(ug); + ug = symbolContext.apply(ug); ug.draw(new URectangle(dimensionToUse.getWidth(), dimensionToUse.getHeight()).rounded(roundCorner)); final double xpos = (dimensionToUse.getWidth() - getPureTextWidth(ug.getStringBounder())) / 2; getTextBlock().drawU(ug.apply(UTranslate.dx(xpos))); diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingElse.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingElse.java index b33105467..0dadff702 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingElse.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingElse.java @@ -52,7 +52,6 @@ import net.sourceforge.plantuml.ugraphic.UShape; import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.color.HColor; -import net.sourceforge.plantuml.ugraphic.color.HColorBackground; import net.sourceforge.plantuml.ugraphic.color.HColors; public class ComponentRoseGroupingElse extends AbstractTextualComponent { @@ -72,9 +71,6 @@ public class ComponentRoseGroupingElse extends AbstractTextualComponent { @Override protected void drawBackgroundInternalU(UGraphic ug, Area area) { - if (backgroundColor instanceof HColorBackground) - return; - if (HColors.isTransparent(backgroundColor)) return; diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingHeader.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingHeader.java index 93fe458e7..c234e3e07 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingHeader.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingHeader.java @@ -56,7 +56,6 @@ import net.sourceforge.plantuml.ugraphic.URectangle; import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.color.HColor; -import net.sourceforge.plantuml.ugraphic.color.HColorBackground; public class ComponentRoseGroupingHeader extends AbstractTextualComponent { @@ -123,9 +122,6 @@ public class ComponentRoseGroupingHeader extends AbstractTextualComponent { @Override protected void drawBackgroundInternalU(UGraphic ug, Area area) { - if (background instanceof HColorBackground) - return; - final Dimension2D dimensionToUse = area.getDimensionToUse(); ug = symbolContext.applyStroke(ug).apply(symbolContext.getForeColor()); final URectangle rect = new URectangle(dimensionToUse.getWidth(), dimensionToUse.getHeight()) diff --git a/src/net/sourceforge/plantuml/sprite/ColorPalette.java b/src/net/sourceforge/plantuml/sprite/ColorPalette.java index 1dc4ce4db..936e7bc95 100644 --- a/src/net/sourceforge/plantuml/sprite/ColorPalette.java +++ b/src/net/sourceforge/plantuml/sprite/ColorPalette.java @@ -40,21 +40,22 @@ import java.util.Objects; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorSimple; +import net.sourceforge.plantuml.ugraphic.color.HColors; public class ColorPalette { private static final String colorValue = "!#$%&*+-:;<=>?@^_~GHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; public char getCharFor(Color dest) { - return getCharFor(new HColorSimple(dest, false)); + return getCharFor(HColors.simple(dest)); } public char getCharFor(HColor dest) { char result = 0; - double resultDist = Double.MAX_VALUE; + int resultDist = Integer.MAX_VALUE; for (int i = 0; i < colorValue.length(); i++) { final char c = colorValue.charAt(i); - final double dist = ((HColorSimple) dest).distance(getHtmlColorSimpleFor(c)); + final int dist = ((HColorSimple) dest).distanceTo((HColorSimple) getHtmlColorSimpleFor(c)); if (dist < resultDist) { result = c; resultDist = dist; @@ -64,9 +65,9 @@ public class ColorPalette { return result; } - private HColorSimple getHtmlColorSimpleFor(char c) { + private HColor getHtmlColorSimpleFor(char c) { final Color color = Objects.requireNonNull(getColorFor(c)); - return new HColorSimple(color, false); + return HColors.simple(color); } public Color getColorFor(char c) { diff --git a/src/net/sourceforge/plantuml/sprite/ColorPalette4096.java b/src/net/sourceforge/plantuml/sprite/ColorPalette4096.java index 09a9398ba..1159f01e2 100644 --- a/src/net/sourceforge/plantuml/sprite/ColorPalette4096.java +++ b/src/net/sourceforge/plantuml/sprite/ColorPalette4096.java @@ -40,20 +40,21 @@ import java.util.Objects; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorSimple; +import net.sourceforge.plantuml.ugraphic.color.HColors; public class ColorPalette4096 { private static final String colorValue = "!#$%&*+-:;<=>?@^_~GHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; public String getStringFor(Color dest) { - return getStringFor(new HColorSimple(dest, false)); + return getStringFor(HColors.simple(dest)); } public String getStringFor(HColor dest) { int result = 0; - double resultDist = Double.MAX_VALUE; + int resultDist = Integer.MAX_VALUE; for (int i = 0; i < 4096; i++) { - final double dist = ((HColorSimple) dest).distance(getHtmlColorSimpleFor(i)); + final int dist = ((HColorSimple) dest).distanceTo((HColorSimple) getHtmlColorSimpleFor(i)); if (dist < resultDist) { result = i; resultDist = dist; @@ -69,23 +70,23 @@ public class ColorPalette4096 { return "" + colorValue.charAt(v1) + colorValue.charAt(v2); } - private HColorSimple getHtmlColorSimpleFor(int s) { + private HColor getHtmlColorSimpleFor(int s) { final Color color = Objects.requireNonNull(getColorFor(s)); - return new HColorSimple(color, false); + return HColors.simple(color); } public Color getColorFor(String s) { - if (s.length() != 2) { + if (s.length() != 2) throw new IllegalArgumentException(); - } + final int v1 = colorValue.indexOf(s.charAt(0)); - if (v1 == -1) { + if (v1 == -1) return null; - } + final int v2 = colorValue.indexOf(s.charAt(1)); - if (v2 == -1) { + if (v2 == -1) return null; - } + final int code = v1 * 64 + v2; return getColorFor(code); } diff --git a/src/net/sourceforge/plantuml/sprite/SpriteMonochrome.java b/src/net/sourceforge/plantuml/sprite/SpriteMonochrome.java index d5f054443..408d250e5 100644 --- a/src/net/sourceforge/plantuml/sprite/SpriteMonochrome.java +++ b/src/net/sourceforge/plantuml/sprite/SpriteMonochrome.java @@ -52,7 +52,6 @@ import net.sourceforge.plantuml.ugraphic.UImage; import net.sourceforge.plantuml.ugraphic.color.ColorMapper; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorGradient; -import net.sourceforge.plantuml.ugraphic.color.HColorSimple; import net.sourceforge.plantuml.ugraphic.color.HColors; public class SpriteMonochrome implements Sprite { @@ -202,8 +201,8 @@ public class SpriteMonochrome implements Sprite { final BufferedImage im = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); for (int col = 0; col < width; col++) { for (int line = 0; line < height; line++) { - final HColor backColorLocal = new HColorSimple(backcolor.getColor(colorMapper, 1.0 * line / height), - false); + final HColor backColorLocal = HColors + .simple(backcolor.getColor(colorMapper, 1.0 * line / height)); final HColorGradient gradient = HColors.gradient(backColorLocal, color, '\0'); final double coef = 1.0 * gray[line][col] / (grayLevel - 1); final Color c = gradient.getColor(colorMapper, coef); diff --git a/src/net/sourceforge/plantuml/statediagram/command/CommandLinkStateCommon.java b/src/net/sourceforge/plantuml/statediagram/command/CommandLinkStateCommon.java index 3dd258a8c..a55d84f7d 100644 --- a/src/net/sourceforge/plantuml/statediagram/command/CommandLinkStateCommon.java +++ b/src/net/sourceforge/plantuml/statediagram/command/CommandLinkStateCommon.java @@ -118,7 +118,7 @@ abstract class CommandLinkStateCommon extends SingleLineCommand2 { crossStart ? LinkDecor.CIRCLE_CROSS : LinkDecor.NONE); final Display label = Display.getWithNewlines(arg.get("LABEL", 0)); - Link link = new Link(cl1, cl2, linkType, label, lenght, diagram.getSkinParam().getCurrentStyleBuilder()); + Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, label, lenght); if (dir == Direction.LEFT || dir == Direction.UP) { link = link.getInv(); } diff --git a/src/net/sourceforge/plantuml/style/ValueImpl.java b/src/net/sourceforge/plantuml/style/ValueImpl.java index 8b2cfadfb..46168daa1 100644 --- a/src/net/sourceforge/plantuml/style/ValueImpl.java +++ b/src/net/sourceforge/plantuml/style/ValueImpl.java @@ -42,7 +42,6 @@ import net.sourceforge.plantuml.api.ThemeStyle; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorSet; -import net.sourceforge.plantuml.ugraphic.color.HColorSimple; import net.sourceforge.plantuml.ugraphic.color.HColors; public class ValueImpl implements Value { @@ -105,7 +104,7 @@ public class ValueImpl implements Value { final HColor result = set.getColorOrWhite(themeStyle, value1); if (value.getValue2() != null) { final HColor dark = set.getColorOrWhite(themeStyle, value.getValue2()); - return ((HColorSimple) result).withDark(dark); + return result.withDark(dark); } return result; } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/HslColor.java b/src/net/sourceforge/plantuml/tim/stdlib/HslColor.java index 6fbc85519..f781958cc 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/HslColor.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/HslColor.java @@ -46,7 +46,7 @@ import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.ugraphic.color.HColorSimple; +import net.sourceforge.plantuml.ugraphic.color.HColors; import net.sourceforge.plantuml.ugraphic.color.HSLColor; public class HslColor extends SimpleReturnFunction { @@ -67,12 +67,12 @@ public class HslColor extends SimpleReturnFunction { if (values.size() == 3) { final HSLColor color = new HSLColor(h, s, l); final Color rgb = color.getRGB(); - return TValue.fromString(new HColorSimple(rgb, false).asString()); + return TValue.fromString(HColors.simple(rgb).asString()); } final int a = values.get(3).toInt(); final HSLColor color = new HSLColor(h, s, l, (float) (a / 100.0)); final Color rgb = color.getRGB(); - return TValue.fromString(new HColorSimple(rgb, false).asString()); + return TValue.fromString(HColors.simple(rgb).asString()); } } diff --git a/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java b/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java index 808b99994..8b39860fa 100644 --- a/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java +++ b/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java @@ -93,7 +93,6 @@ import net.sourceforge.plantuml.svg.LengthAdjust; import net.sourceforge.plantuml.ugraphic.color.ColorMapper; import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity; import net.sourceforge.plantuml.ugraphic.color.HColor; -import net.sourceforge.plantuml.ugraphic.color.HColorBackground; import net.sourceforge.plantuml.ugraphic.color.HColorGradient; import net.sourceforge.plantuml.ugraphic.color.HColorNone; import net.sourceforge.plantuml.ugraphic.color.HColorSimple; @@ -169,9 +168,9 @@ public class ImageBuilder { public ImageBuilder drawable(UDrawable drawable) { this.udrawable = drawable; - if (backcolor == null && drawable instanceof TextBlockBackcolored) { + if (backcolor == null && drawable instanceof TextBlockBackcolored) backcolor = ((TextBlockBackcolored) drawable).getBackcolor(); - } + return this; } @@ -201,13 +200,13 @@ public class ImageBuilder { } private String getSvgLinkTarget() { - if (fileFormatOption.getSvgLinkTarget() != null) { + if (fileFormatOption.getSvgLinkTarget() != null) return fileFormatOption.getSvgLinkTarget(); - } else if (skinParam != null) { + else if (skinParam != null) return skinParam.getSvgLinkTarget(); - } else { + else return null; - } + } public ImageBuilder warningOrError(String warningOrError) { @@ -272,12 +271,13 @@ public class ImageBuilder { / 96.0; if (scaleFactor <= 0) throw new IllegalStateException("Bad scaleFactor"); + UGraphic ug = createUGraphic(fileFormatOption, dim, animationArg, dx, dy, scaleFactor, titledDiagram == null ? new Pragma() : titledDiagram.getPragma()); maybeDrawBorder(ug, dim); - if (randomPixel) { + if (randomPixel) drawRandomPoint(ug); - } + ug = handwritten(ug.apply(new UTranslate(margin.getLeft(), margin.getTop()))); udrawable.drawU(ug); ug.flushUg(); @@ -319,7 +319,7 @@ public class ImageBuilder { final int green = rnd.nextInt(40); final int blue = rnd.nextInt(40); final Color c = new Color(red, green, blue); - final HColor color = new HColorSimple(c, false); + final HColor color = HColors.simple(c); ug2.apply(color).apply(color.bg()).draw(new URectangle(1, 1)); } @@ -334,9 +334,9 @@ public class ImageBuilder { } private UGraphic handwritten(UGraphic ug) { - if (skinParam != null && skinParam.handwritten()) { + if (skinParam != null && skinParam.handwritten()) return new UGraphicHandwritten(ug); - } + // if (OptionFlags.OMEGA_CROSSING) { // return new UGraphicCrossing(ug); // } else { @@ -450,16 +450,14 @@ public class ImageBuilder { double dy, String watermark) { Color backColor = getDefaultBackColor(); - if (this.backcolor instanceof HColorSimple) { + if (this.backcolor instanceof HColorSimple) backColor = colorMapper.toColor(this.backcolor); - } else if (this.backcolor instanceof HColorBackground || this.backcolor instanceof HColorNone) { + else if (this.backcolor instanceof HColorNone) backColor = null; - } if (OptionFlags.getInstance().isReplaceWhiteBackgroundByTransparent() && backColor != null - && backColor.equals(Color.WHITE)) { + && backColor.equals(Color.WHITE)) backColor = new Color(0, 0, 0, 0); - } final EmptyImageBuilder builder = new EmptyImageBuilder(watermark, (int) (dim.getWidth() * scaleFactor), (int) (dim.getHeight() * scaleFactor), backColor, stringBounder); @@ -469,10 +467,9 @@ public class ImageBuilder { affineTransforms == null ? null : affineTransforms.getFirst(), dx, dy); ug.setBufferedImage(builder.getBufferedImage()); final BufferedImage im = ug.getBufferedImage(); - if (this.backcolor instanceof HColorGradient) { + if (this.backcolor instanceof HColorGradient) ug.apply(this.backcolor.bg()) .draw(new URectangle(im.getWidth() / scaleFactor, im.getHeight() / scaleFactor)); - } return ug; } @@ -490,9 +487,9 @@ public class ImageBuilder { return fileFormatOption.getHoverColor(); } else if (skinParam != null) { final HColor color = skinParam.hoverPathColor(); - if (color != null) { + if (color != null) return colorMapper.toRGB(color); - } + } return null; } @@ -507,13 +504,13 @@ public class ImageBuilder { } public String getPreserveAspectRatio() { - if (fileFormatOption.getPreserveAspectRatio() != null) { + if (fileFormatOption.getPreserveAspectRatio() != null) return fileFormatOption.getPreserveAspectRatio(); - } else if (skinParam != null) { + else if (skinParam != null) return skinParam.getPreserveAspectRatio(); - } else { + else return DEFAULT_PRESERVE_ASPECT_RATIO; - } + } private ImageDataSimple createImageData(Dimension2D dim) { diff --git a/src/net/sourceforge/plantuml/ugraphic/color/AbstractColorMapper.java b/src/net/sourceforge/plantuml/ugraphic/color/AbstractColorMapper.java index 8958c5474..862a55b76 100644 --- a/src/net/sourceforge/plantuml/ugraphic/color/AbstractColorMapper.java +++ b/src/net/sourceforge/plantuml/ugraphic/color/AbstractColorMapper.java @@ -53,12 +53,6 @@ public abstract class AbstractColorMapper implements ColorMapper { if (hcolor == null) return "none"; - if (hcolor instanceof HColorBackground) { - hcolor = ((HColorBackground) hcolor).getBack(); -// Thread.dumpStack(); -// System.exit(0); -// return toHtml(result); - } if (HColors.isTransparent(hcolor)) return "#00000000"; diff --git a/src/net/sourceforge/plantuml/ugraphic/color/ColorMapperForceDark.java b/src/net/sourceforge/plantuml/ugraphic/color/ColorMapperForceDark.java index 7a72544b0..cdff43b90 100644 --- a/src/net/sourceforge/plantuml/ugraphic/color/ColorMapperForceDark.java +++ b/src/net/sourceforge/plantuml/ugraphic/color/ColorMapperForceDark.java @@ -40,24 +40,24 @@ import java.awt.Color; public class ColorMapperForceDark extends AbstractColorMapper implements ColorMapper { public Color toColor(HColor color) { - if (color == null) { + if (color == null) return null; - } - if (color instanceof HColorBackground) { - throw new UnsupportedOperationException(); - } - if (color instanceof HColorGradient) { + + if (color instanceof HColorNone) + return new Color(0, 0, 0, 0); + + if (color instanceof HColorGradient) return toColor(((HColorGradient) color).getColor1()); - } - if (color instanceof HColorMiddle) { + + if (color instanceof HColorMiddle) return ((HColorMiddle) color).getMappedColor(this); - } - if (color instanceof HColorScheme) { + + if (color instanceof HColorScheme) throw new IllegalStateException(); - } - if (color instanceof HColorAutomagic) { + + if (color instanceof HColorAutomagic) throw new IllegalStateException(); - } + final HColor tmp = ((HColorSimple) color).darkSchemeTheme(); return ((HColorSimple) tmp).getColor999(); } diff --git a/src/net/sourceforge/plantuml/ugraphic/color/ColorMapperIdentity.java b/src/net/sourceforge/plantuml/ugraphic/color/ColorMapperIdentity.java index 0e5ce7fa2..088425c96 100644 --- a/src/net/sourceforge/plantuml/ugraphic/color/ColorMapperIdentity.java +++ b/src/net/sourceforge/plantuml/ugraphic/color/ColorMapperIdentity.java @@ -40,24 +40,24 @@ import java.awt.Color; public class ColorMapperIdentity extends AbstractColorMapper implements ColorMapper { public Color toColor(HColor color) { - if (color == null) { + if (color == null) return null; - } - if (color instanceof HColorBackground) { - throw new UnsupportedOperationException(); - } - if (color instanceof HColorGradient) { + + if (color instanceof HColorNone) + return new Color(0, 0, 0, 0); + + if (color instanceof HColorGradient) return toColor(((HColorGradient) color).getColor1()); - } - if (color instanceof HColorMiddle) { + + if (color instanceof HColorMiddle) return ((HColorMiddle) color).getMappedColor(this); - } - if (color instanceof HColorScheme) { + + if (color instanceof HColorScheme) throw new IllegalStateException(); - } - if (color instanceof HColorAutomagic) { + + if (color instanceof HColorAutomagic) throw new IllegalStateException(); - } + return ((HColorSimple) color).getColor999(); } } diff --git a/src/net/sourceforge/plantuml/ugraphic/color/ColorMapperLightnessInverse.java b/src/net/sourceforge/plantuml/ugraphic/color/ColorMapperLightnessInverse.java index 3ddf57afa..fea9dd9b2 100644 --- a/src/net/sourceforge/plantuml/ugraphic/color/ColorMapperLightnessInverse.java +++ b/src/net/sourceforge/plantuml/ugraphic/color/ColorMapperLightnessInverse.java @@ -40,18 +40,18 @@ import java.awt.Color; public class ColorMapperLightnessInverse extends AbstractColorMapper implements ColorMapper { public Color toColor(HColor color) { - if (color == null) { + if (color == null) return null; - } - if (color instanceof HColorBackground) { - throw new UnsupportedOperationException(); - } - if (color instanceof HColorGradient) { + + if (color instanceof HColorGradient) return toColor(((HColorGradient) color).getColor1()); - } - if (color instanceof HColorMiddle) { + + if (color instanceof HColorMiddle) return ((HColorMiddle) color).getMappedColor(this); - } + + if (color instanceof HColorNone) + return ColorUtils.getReversed((new Color(0, 0, 0, 0))); + // return ColorUtils.reverseHsluv(((HColorSimple) color).getColor999()); return ColorUtils.getReversed(((HColorSimple) color).getColor999()); diff --git a/src/net/sourceforge/plantuml/ugraphic/color/ColorMapperReverse.java b/src/net/sourceforge/plantuml/ugraphic/color/ColorMapperReverse.java index d77036cc8..5635f6cad 100644 --- a/src/net/sourceforge/plantuml/ugraphic/color/ColorMapperReverse.java +++ b/src/net/sourceforge/plantuml/ugraphic/color/ColorMapperReverse.java @@ -46,12 +46,15 @@ public class ColorMapperReverse extends AbstractColorMapper implements ColorMapp } public Color toColor(HColor color) { - if (color == null) { + if (color == null) return null; - } - if (color instanceof HColorMiddle) { + + if (color instanceof HColorMiddle) return ((HColorMiddle) color).getMappedColor(this); - } + + if (color instanceof HColorNone) + return getReverse(new Color(0, 0, 0, 0)); + return getReverse(((HColorSimple) color).getColor999()); } diff --git a/src/net/sourceforge/plantuml/ugraphic/color/ColorMapperTransparentWrapper.java b/src/net/sourceforge/plantuml/ugraphic/color/ColorMapperTransparentWrapper.java index 75b217797..446f46bb7 100644 --- a/src/net/sourceforge/plantuml/ugraphic/color/ColorMapperTransparentWrapper.java +++ b/src/net/sourceforge/plantuml/ugraphic/color/ColorMapperTransparentWrapper.java @@ -47,13 +47,12 @@ public class ColorMapperTransparentWrapper extends AbstractColorMapper implement } public Color toColor(HColor color) { - if (color == null) { + if (color == null) return null; - } - if (color instanceof HColorBackground) { - final HColor back = ((HColorBackground) color).getBack(); - return mapper.toColor(back); - } + + if (color instanceof HColorNone) + return null; + return mapper.toColor(color); } diff --git a/src/net/sourceforge/plantuml/ugraphic/color/ColorUtils.java b/src/net/sourceforge/plantuml/ugraphic/color/ColorUtils.java index 3f4404bf8..aef16f39e 100644 --- a/src/net/sourceforge/plantuml/ugraphic/color/ColorUtils.java +++ b/src/net/sourceforge/plantuml/ugraphic/color/ColorUtils.java @@ -45,8 +45,19 @@ public class ColorUtils { public static int getGrayScale(int red, int green, int blue) { // YIQ equation from http://24ways.org/2010/calculating-color-contrast - final int grayScale = (red * 299 + green * 587 + blue * 114) / 1000; - return grayScale; + return getGrayScaleInternal(red, green, blue) / 1000; + } + + public static int distance(Color c1, Color c2) { + final int diffRed = Math.abs(c1.getRed() - c2.getRed()); + final int diffGreen = Math.abs(c1.getGreen() - c2.getGreen()); + final int diffBlue = Math.abs(c1.getBlue() - c2.getBlue()); + return getGrayScaleInternal(diffRed, diffGreen, diffBlue); + } + + private static int getGrayScaleInternal(int red, int green, int blue) { + // YIQ equation from http://24ways.org/2010/calculating-color-contrast + return red * 299 + green * 587 + blue * 114; } public static int getGrayScale(int rgb) { @@ -151,12 +162,12 @@ public class ColorUtils { private static int to255(final double value) { final int result = (int) (255 * value); - if (result < 0) { + if (result < 0) return 0; - } - if (result > 255) { + + if (result > 255) return 255; - } + return result; } diff --git a/src/net/sourceforge/plantuml/ugraphic/color/HColor.java b/src/net/sourceforge/plantuml/ugraphic/color/HColor.java index 5a2ba3f3a..b21270177 100644 --- a/src/net/sourceforge/plantuml/ugraphic/color/HColor.java +++ b/src/net/sourceforge/plantuml/ugraphic/color/HColor.java @@ -42,6 +42,8 @@ public interface HColor extends UChange { public UBackground bg(); + public HColor withDark(HColor dark); + public HColor darken(int ratio); public HColor lighten(int ratio); @@ -56,4 +58,6 @@ public interface HColor extends UChange { public HColor darkSchemeTheme(); + public HColor opposite(); + } diff --git a/src/net/sourceforge/plantuml/ugraphic/color/HColorAbstract.java b/src/net/sourceforge/plantuml/ugraphic/color/HColorAbstract.java index cf5d924bb..62f4df238 100644 --- a/src/net/sourceforge/plantuml/ugraphic/color/HColorAbstract.java +++ b/src/net/sourceforge/plantuml/ugraphic/color/HColorAbstract.java @@ -75,10 +75,20 @@ abstract class HColorAbstract implements HColor { public String asString() { return "?" + getClass().getSimpleName(); } - + @Override public HColor darkSchemeTheme() { return this; } + @Override + public HColor withDark(HColor dark) { + throw new UnsupportedOperationException(); + } + + @Override + public HColor opposite() { + throw new UnsupportedOperationException(); + } + } diff --git a/src/net/sourceforge/plantuml/ugraphic/color/HColorBackground.java b/src/net/sourceforge/plantuml/ugraphic/color/HColorBackground.java deleted file mode 100644 index abe2469d1..000000000 --- a/src/net/sourceforge/plantuml/ugraphic/color/HColorBackground.java +++ /dev/null @@ -1,60 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2023, Arnaud Roques - * - * Project Info: http://plantuml.com - * - * If you like this project or if you find it useful, you can support us at: - * - * http://plantuml.com/patreon (only 1$ per month!) - * http://plantuml.com/paypal - * - * This file is part of PlantUML. - * - * PlantUML is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PlantUML distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - * License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - * - * - * Original Author: Arnaud Roques - * - */ -package net.sourceforge.plantuml.ugraphic.color; - -import java.util.Objects; - -public class HColorBackground extends HColorAbstract implements HColor { - - private final HColor back; - - public HColorBackground(HColor back) { - this.back = Objects.requireNonNull(back); - } - - @Override - public String toString() { - return "BACK " + back; - } - - public HColor getNull() { - return null; - } - - final HColor getBack() { - return back; - } - -} diff --git a/src/net/sourceforge/plantuml/ugraphic/color/HColorSet.java b/src/net/sourceforge/plantuml/ugraphic/color/HColorSet.java index a66bc2702..b8c660aff 100644 --- a/src/net/sourceforge/plantuml/ugraphic/color/HColorSet.java +++ b/src/net/sourceforge/plantuml/ugraphic/color/HColorSet.java @@ -244,8 +244,8 @@ public class HColorSet { return isColorValid(s1) && isColorValid(s2); } - HColorGradient buildInternal(HColor background) { - return HColors.gradient(build(s1, background), build(s2, background), sep); + HColorGradient buildInternal() { + return HColors.gradient(build(s1), build(s2), sep); } } @@ -265,12 +265,11 @@ public class HColorSet { return true; } - HColorScheme buildInternal(HColor background) { + HColorScheme buildInternal() { if (colors.length == 2) - return new HColorScheme(build(colors[0], background), build(colors[1], background), null); + return new HColorScheme(build(colors[0]), build(colors[1]), null); - return new HColorScheme(build(colors[0], background), build(colors[1], background), - build(colors[2], background)); + return new HColorScheme(build(colors[0]), build(colors[1]), build(colors[2])); } } @@ -302,49 +301,41 @@ public class HColorSet { } public HColor getColorOrWhite(String s) { - return getColorOrWhite(null, s, null); + return getColorOrWhite(null, s); } public HColor getColorOrWhite(ThemeStyle UNUSED, String s) { - return getColorOrWhite(null, s, null); - } - - public HColor getColorOrWhite(ThemeStyle UNUSED, String s, HColor background) { if (isColorValid(Objects.requireNonNull(s)) == false) return HColors.WHITE; try { - return getColor(null, s, background); + return getColor(null, s); } catch (NoSuchColorException e) { assert false; return HColors.WHITE; } } - public HColor getColor(ThemeStyle UNUSED, String s) throws NoSuchColorException { - return getColor(null, s, null); - } - public HColor getColorLEGACY(String s) throws NoSuchColorException { - return getColor(null, s, null); + return getColor(null, s); } - public HColor getColor(ThemeStyle UNUSED, String s, HColor background) throws NoSuchColorException { + public HColor getColor(ThemeStyle UNUSED, String s) throws NoSuchColorException { if (isColorValid(Objects.requireNonNull(s)) == false) throw new NoSuchColorException(); final Automatic automatic = automaticFromString(s); if (automatic != null) - return automatic.buildInternal(background); + return automatic.buildInternal(); final Gradient gradient = gradientFromString(s); if (gradient != null) - return gradient.buildInternal(background); + return gradient.buildInternal(); - if (background == null && (s.equalsIgnoreCase("#transparent") || s.equalsIgnoreCase("transparent"))) + if (s.equalsIgnoreCase("#transparent") || s.equalsIgnoreCase("transparent")) s = "#00000000"; - return build(s, background); + return build(s); } private boolean isColorValid(String s) { @@ -367,11 +358,11 @@ public class HColorSet { } - private HColor build(String s, HColor background) { + private HColor build(String s) { s = removeFirstDieseAndgoLowerCase(s); final Color color; if (s.equalsIgnoreCase("transparent") || s.equalsIgnoreCase("background")) { - return new HColorBackground(background); + return HColors.generalBackground(); } else if (s.equalsIgnoreCase("automatic")) { return new HColorAutomagic(); } else if (s.matches("[0-9A-Fa-f]")) { @@ -388,7 +379,7 @@ public class HColorSet { final String value = Objects.requireNonNull(htmlNames.get(s)); color = new Color(Integer.parseInt(value.substring(1), 16)); } - return new HColorSimple(color, false); + return HColors.simple(color); } private Color fromRGBa(String s) { diff --git a/src/net/sourceforge/plantuml/ugraphic/color/HColorSimple.java b/src/net/sourceforge/plantuml/ugraphic/color/HColorSimple.java index 27925dcf5..fcad7c17c 100644 --- a/src/net/sourceforge/plantuml/ugraphic/color/HColorSimple.java +++ b/src/net/sourceforge/plantuml/ugraphic/color/HColorSimple.java @@ -42,8 +42,7 @@ import net.sourceforge.plantuml.StringUtils; public class HColorSimple extends HColorAbstract implements HColor { private final Color color; - private final boolean monochrome; - private HColor dark; + private final HColor dark; @Override public int hashCode() { @@ -52,8 +51,6 @@ public class HColorSimple extends HColorAbstract implements HColor { @Override public String toString() { - if (isTransparent()) - return "transparent"; final boolean withDark = this != dark; @@ -63,8 +60,8 @@ public class HColorSimple extends HColorAbstract implements HColor { sb.append(color.toString()); sb.append(" \u03B1="); sb.append(color.getAlpha()); - if (monochrome) - sb.append("MONOCHROME"); + if (isTransparent()) + sb.append(" transparent"); return sb.toString(); } @@ -83,24 +80,24 @@ public class HColorSimple extends HColorAbstract implements HColor { public HColor lighten(int ratio) { final float[] hsl = new HSLColor(color).getHSL(); hsl[2] += hsl[2] * (ratio / 100.0); - return new HColorSimple(new HSLColor(hsl).getRGB(), false); + return new HColorSimple(new HSLColor(hsl).getRGB()); } @Override public HColor darken(int ratio) { final float[] hsl = new HSLColor(color).getHSL(); hsl[2] -= hsl[2] * (ratio / 100.0); - return new HColorSimple(new HSLColor(hsl).getRGB(), false); + return new HColorSimple(new HSLColor(hsl).getRGB()); } @Override public HColor reverseHsluv() { - return new HColorSimple(ColorUtils.reverseHsluv(color), false); + return new HColorSimple(ColorUtils.reverseHsluv(color)); } @Override public HColor reverse() { - return new HColorSimple(ColorOrder.RGB.getReverse(color), false); + return new HColorSimple(ColorOrder.RGB.getReverse(color)); } @Override @@ -120,15 +117,13 @@ public class HColorSimple extends HColorAbstract implements HColor { return this.color.equals(((HColorSimple) other).color); } - public HColorSimple(Color c, boolean monochrome) { + HColorSimple(Color c) { this.color = c; - this.monochrome = monochrome; this.dark = this; } - private HColorSimple(Color c, boolean monochrome, HColor dark) { + private HColorSimple(Color c, HColor dark) { this.color = c; - this.monochrome = monochrome; this.dark = dark; } @@ -136,8 +131,8 @@ public class HColorSimple extends HColorAbstract implements HColor { return color; } - public HColorSimple asMonochrome() { - return new HColorSimple(new ColorChangerMonochrome().getChangedColor(color), monochrome); + public HColor asMonochrome() { + return new HColorSimple(new ColorChangerMonochrome().getChangedColor(color)); } public HColor asMonochrome(HColorSimple colorForMonochrome, double minGray, double maxGray) { @@ -148,32 +143,22 @@ public class HColorSimple extends HColorAbstract implements HColor { final double coef = (gray - minGray) / 256.0; final Color result = ColorUtils.grayToColor(coef, colorForMonochrome.color); - return new HColorSimple(result, monochrome); + return new HColorSimple(result); } - public HColorSimple opposite() { + @Override + public HColor opposite() { final Color mono = new ColorChangerMonochrome().getChangedColor(color); final int grayScale = 255 - mono.getGreen() > 127 ? 255 : 0; - return new HColorSimple(new Color(grayScale, grayScale, grayScale), true); + return new HColorSimple(new Color(grayScale, grayScale, grayScale)); } - public double distance(HColorSimple other) { - final int diffRed = Math.abs(this.color.getRed() - other.color.getRed()); - final int diffGreen = Math.abs(this.color.getGreen() - other.color.getGreen()); - final int diffBlue = Math.abs(this.color.getBlue() - other.color.getBlue()); - return diffRed * .3 + diffGreen * .59 + diffBlue * .11; - } - - public final boolean isMonochrome() { - return monochrome; + public int distanceTo(HColorSimple other) { + return ColorUtils.distance(this.color, other.color); } public boolean isGray() { - if (monochrome) - return true; - if (color.getRed() == color.getGreen() && color.getGreen() == color.getBlue()) - return true; - return false; + return color.getRed() == color.getGreen() && color.getGreen() == color.getBlue(); } public static HColorSimple unlinear(HColorSimple color1, HColorSimple color2, int completionInt) { @@ -192,7 +177,7 @@ public class HColorSimple extends HColorAbstract implements HColor { final HSLColor col = new HSLColor(hsl); - return new HColorSimple(col.getRGB(), color1.monochrome); + return new HColorSimple(col.getRGB()); } private static float[] linear(float factor, float[] hsl1, float[] hsl2) { @@ -203,11 +188,12 @@ public class HColorSimple extends HColorAbstract implements HColor { } private static float linear(float factor, float x, float y) { - return (x + (y - x) * factor); + return x + (y - x) * factor; } + @Override public HColor withDark(HColor dark) { - return new HColorSimple(color, monochrome, dark); + return new HColorSimple(color, dark); } @Override diff --git a/src/net/sourceforge/plantuml/ugraphic/color/HColors.java b/src/net/sourceforge/plantuml/ugraphic/color/HColors.java index b867cc91e..84fa97c4f 100644 --- a/src/net/sourceforge/plantuml/ugraphic/color/HColors.java +++ b/src/net/sourceforge/plantuml/ugraphic/color/HColors.java @@ -42,8 +42,8 @@ import net.sourceforge.plantuml.ugraphic.UGraphic; public class HColors { - public static final HColorSimple BLACK; - public static final HColorSimple WHITE; + public static final HColor BLACK; + public static final HColor WHITE; public static final HColor RED_LIGHT; public static final HColor RED_DARK; public static final HColor RED; @@ -133,17 +133,23 @@ public class HColors { return color.bg(); } - final private static HColorSimple TRANSPARENT = new HColorSimple(new Color(0, 0, 0, 0), false); - public static HColor transparent() { - return TRANSPARENT; + return new HColorNone(); + } + + public static HColor none() { + return new HColorNone(); + } + + public static HColor generalBackground() { + return new HColorNone(); } public static boolean isTransparent(HColor back) { - if (back == TRANSPARENT) + if (back == null) return true; - if (back instanceof HColorBackground && ((HColorBackground) back).getBack() == TRANSPARENT) + if (back instanceof HColorNone) return true; if (back instanceof HColorSimple && ((HColorSimple) back).isTransparent()) @@ -165,10 +171,6 @@ public class HColors { return color1; } - public static HColor none() { - return new HColorNone(); - } - public static HColor middle(HColor c1, HColor c2) { return new HColorMiddle(c1, c2); } @@ -177,4 +179,8 @@ public class HColors { return new HColorGradient(color1, color2, policy); } + public static HColor simple(Color c) { + return new HColorSimple(c); + } + } diff --git a/src/net/sourceforge/plantuml/ugraphic/debug/UGraphicDebug.java b/src/net/sourceforge/plantuml/ugraphic/debug/UGraphicDebug.java index bdc636832..2faebae69 100644 --- a/src/net/sourceforge/plantuml/ugraphic/debug/UGraphicDebug.java +++ b/src/net/sourceforge/plantuml/ugraphic/debug/UGraphicDebug.java @@ -261,8 +261,6 @@ public class UGraphicDebug extends AbstractCommonUGraphic implements ClipContain if (color instanceof HColorSimple) { final HColorSimple simple = (HColorSimple) color; final Color internal = simple.getColor999(); - if (simple.isMonochrome()) - return "monochrome " + Integer.toHexString(internal.getRGB()); return Integer.toHexString(internal.getRGB()); } diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index b3d0c352e..8143a74bc 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -45,7 +45,7 @@ public class Version { private static final int MAJOR_SEPARATOR = 1000000; public static int version() { - return 1202206; + return 1202207; } public static int versionPatched() { @@ -81,7 +81,7 @@ public class Version { } public static int beta() { - final int beta = 12; + final int beta = 0; return beta; } @@ -94,7 +94,7 @@ public class Version { } public static long compileTime() { - return 1655832889469L; + return 1661187690019L; } public static String compileTimeString() { diff --git a/test/nonreg/simple/A0002_TestResult.java b/test/nonreg/simple/A0002_TestResult.java index 7af685856..dc91b8c3f 100644 --- a/test/nonreg/simple/A0002_TestResult.java +++ b/test/nonreg/simple/A0002_TestResult.java @@ -765,7 +765,7 @@ ELLIPSE: stroke: 0.0-0.0-1.0 shadow: 0 color: ff222222 - backcolor: 0 + backcolor: NULL_COLOR ELLIPSE: pt1: [ 484.2327 ; 862.5000 ] diff --git a/test/nonreg/simple/A0005_TestResult.java b/test/nonreg/simple/A0005_TestResult.java index b656197a3..b59329391 100644 --- a/test/nonreg/simple/A0005_TestResult.java +++ b/test/nonreg/simple/A0005_TestResult.java @@ -23,7 +23,7 @@ RECTANGLE: yCorner: 0 stroke: 0.0-0.0-1.0 shadow: 0 - color: 0 + color: NULL_COLOR backcolor: ffff0000 TEXT: @@ -45,7 +45,7 @@ RECTANGLE: yCorner: 0 stroke: 0.0-0.0-1.0 shadow: 0 - color: 0 + color: NULL_COLOR backcolor: ffffff00 TEXT: @@ -251,7 +251,7 @@ RECTANGLE: yCorner: 0 stroke: 0.0-0.0-1.0 shadow: 0 - color: 0 + color: NULL_COLOR backcolor: ff800080 TEXT: @@ -273,7 +273,7 @@ RECTANGLE: yCorner: 0 stroke: 0.0-0.0-1.0 shadow: 0 - color: 0 + color: NULL_COLOR backcolor: ff0000ff TEXT: diff --git a/test/nonreg/simple/A0006_TestResult.java b/test/nonreg/simple/A0006_TestResult.java index de16472e4..36cfff6c9 100644 --- a/test/nonreg/simple/A0006_TestResult.java +++ b/test/nonreg/simple/A0006_TestResult.java @@ -23,7 +23,7 @@ RECTANGLE: yCorner: 0 stroke: 0.0-0.0-1.0 shadow: 0 - color: 0 + color: NULL_COLOR backcolor: ffffff00 TEXT: @@ -45,7 +45,7 @@ RECTANGLE: yCorner: 0 stroke: 0.0-0.0-1.0 shadow: 0 - color: 0 + color: NULL_COLOR backcolor: ff800080 TEXT: @@ -171,7 +171,7 @@ RECTANGLE: yCorner: 0 stroke: 0.0-0.0-1.0 shadow: 0 - color: 0 + color: NULL_COLOR backcolor: ffff0000 TEXT: @@ -193,7 +193,7 @@ RECTANGLE: yCorner: 0 stroke: 0.0-0.0-1.0 shadow: 0 - color: 0 + color: NULL_COLOR backcolor: ff0000ff TEXT: