1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-12-22 10:59:01 +00:00

Import version 1.2022.7

This commit is contained in:
Arnaud Roques 2022-08-23 18:39:27 +02:00
parent b5a6684cd1
commit b4d191a365
56 changed files with 486 additions and 434 deletions

View File

@ -306,7 +306,7 @@ static private HColorSet colors = HColorSet.instance();
private Color decodeInternal(String value) { private Color decodeInternal(String value) {
if (value!=null) { if (value!=null) {
try { 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) { } catch (NoSuchColorException e) {
return Color.WHITE; return Color.WHITE;
} }

View File

@ -50,7 +50,7 @@ import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.ugraphic.UAntiAliasing; import net.sourceforge.plantuml.ugraphic.UAntiAliasing;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity; import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor; 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; import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d;
public class EmptyImageBuilder { public class EmptyImageBuilder {
@ -169,7 +169,7 @@ public class EmptyImageBuilder {
} }
public UGraphicG2d getUGraphicG2d() { 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); final UGraphicG2d result = new UGraphicG2d(back, new ColorMapperIdentity(), stringBounder, g2d, 1.0);
result.setBufferedImage(im); result.setBufferedImage(im);
return result; return result;

View File

@ -311,20 +311,19 @@ public class SkinParam implements ISkinParam {
} }
} }
final String value = getValue(getParamName(param, clickable)); final String value = getValue(getParamName(param, clickable));
if (value == null) { if (value == null)
return null; return null;
}
if ((param == ColorParam.background || param == ColorParam.arrowHead) if ((param == ColorParam.background || param == ColorParam.arrowHead)
&& (value.equalsIgnoreCase("transparent") || value.equalsIgnoreCase("none"))) { && (value.equalsIgnoreCase("transparent") || value.equalsIgnoreCase("none")))
return HColors.transparent(); return HColors.transparent();
}
if (param == ColorParam.background) { if (param == ColorParam.background)
return getIHtmlColorSet().getColorOrWhite(themeStyle, value); return getIHtmlColorSet().getColorOrWhite(themeStyle, value);
}
assert param != ColorParam.background; assert param != ColorParam.background;
// final boolean acceptTransparent = param == ColorParam.background
// || param == ColorParam.sequenceGroupBodyBackground || param == ColorParam.sequenceBoxBackground; return getIHtmlColorSet().getColorOrWhite(themeStyle, value);
return getIHtmlColorSet().getColorOrWhite(themeStyle, value, getBackgroundColor());
} }
public char getCircledCharacter(Stereotype stereotype) { public char getCircledCharacter(Stereotype stereotype) {
@ -1040,7 +1039,7 @@ public class SkinParam implements ISkinParam {
if (value == null) if (value == null)
return null; return null;
return getIHtmlColorSet().getColorOrWhite(themeStyle, value, null); return getIHtmlColorSet().getColorOrWhite(themeStyle, value);
} }
public double getPadding() { public double getPadding() {

View File

@ -68,16 +68,16 @@ public class SplitParam {
} }
public Color getBorderColor() { public Color getBorderColor() {
if (borderColor == null) { if (borderColor == null)
return null; return null;
}
return ((HColorSimple) borderColor).getColor999(); return ((HColorSimple) borderColor).getColor999();
} }
public Color getExternalColor() { public Color getExternalColor() {
if (externalColor == null) { if (externalColor == null)
return null; return null;
}
return ((HColorSimple) externalColor).getColor999(); return ((HColorSimple) externalColor).getColor999();
} }

View File

@ -123,9 +123,9 @@ public class CommandIf extends SingleLineCommand2<ActivityDiagram> {
final IEntity branch = diagram.getCurrentContext().getBranch(); final IEntity branch = diagram.getCurrentContext().getBranch();
Link link = new Link(entity1, branch, new LinkType(LinkDecor.ARROW, LinkDecor.NONE), Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), entity1, branch,
Display.getWithNewlines(arg.get("BRACKET", 0)), lenght, null, ifLabel, diagram.getLabeldistance(), new LinkType(LinkDecor.ARROW, LinkDecor.NONE), Display.getWithNewlines(arg.get("BRACKET", 0)), lenght, null, ifLabel,
diagram.getLabelangle(), diagram.getSkinParam().getCurrentStyleBuilder()); diagram.getLabeldistance(), diagram.getLabelangle());
if (arg.get("ARROW", 0) != null) { if (arg.get("ARROW", 0) != null) {
final Direction direction = StringUtils.getArrowDirection(arg.get("ARROW", 0)); final Direction direction = StringUtils.getArrowDirection(arg.get("ARROW", 0));
if (direction == Direction.LEFT || direction == Direction.UP) { if (direction == Direction.LEFT || direction == Direction.UP) {

View File

@ -167,8 +167,8 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
type = type.goDotted(); type = type.goDotted();
} }
Link link = new Link(entity1, entity2, type, linkLabel, lenght, Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), entity1, entity2, type, linkLabel,
diagram.getSkinParam().getCurrentStyleBuilder()); lenght);
if (arrowDirection.contains("*")) { if (arrowDirection.contains("*")) {
link.setConstraint(false); link.setConstraint(false);
} }

View File

@ -218,8 +218,8 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
if (arrow.contains(".")) { if (arrow.contains(".")) {
type = type.goDotted(); type = type.goDotted();
} }
Link link = new Link(entity1, entity2, type, linkLabel, lenght, Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), entity1, entity2, type, linkLabel,
diagram.getSkinParam().getCurrentStyleBuilder()); lenght);
final Direction direction = StringUtils.getArrowDirection(arrowBody1 + arrowDirection + arrowBody2 + ">"); final Direction direction = StringUtils.getArrowDirection(arrowBody1 + arrowDirection + arrowBody2 + ">");
if (direction == Direction.LEFT || direction == Direction.UP) { if (direction == Direction.LEFT || direction == Direction.UP) {
link = link.getInv(); link = link.getInv();

View File

@ -214,9 +214,9 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
if (type2 == LeafType.INTERFACE && entity.getLeafType() != LeafType.INTERFACE) if (type2 == LeafType.INTERFACE && entity.getLeafType() != LeafType.INTERFACE)
typeLink = typeLink.goDashed(); typeLink = typeLink.goDashed();
final Link link = new Link(cl2, entity, typeLink, Display.NULL, 2, null, null, final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl2, entity, typeLink, Display.NULL, 2, null,
diagram.getLabeldistance(), diagram.getLabelangle(), null, diagram.getLabeldistance(),
diagram.getSkinParam().getCurrentStyleBuilder()); diagram.getLabelangle());
diagram.addLink(link); diagram.addLink(link);
} }
} }

View File

@ -84,7 +84,16 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
)), new RegexOr( // )), new RegexOr( //
new RegexLeaf("ENT1", getClassIdentifier()), // new RegexLeaf("ENT1", getClassIdentifier()), //
new RegexLeaf("COUPLE1", COUPLE)), // new RegexLeaf("COUPLE1", COUPLE)), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexOptional(new RegexConcat( //
RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("[\\[]"), //
new RegexLeaf("QUALIFIER1", "([^\\[\\]]+)"), //
new RegexLeaf("[\\]]"), //
RegexLeaf.spaceOneOrMore() //
)), //
new RegexOptional(new RegexLeaf("FIRST_LABEL", "[%g]([^%g]+)[%g]")), // new RegexOptional(new RegexLeaf("FIRST_LABEL", "[%g]([^%g]+)[%g]")), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
@ -101,8 +110,20 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
new RegexLeaf("ARROW_BODY2", "([-=.]*)"), // new RegexLeaf("ARROW_BODY2", "([-=.]*)"), //
new RegexLeaf("ARROW_HEAD2", new RegexLeaf("ARROW_HEAD2",
"([ox][%s]+|:\\>\\>?|_\\>|[(#\\]>*+^\\{]|[\\|\\:]\\|\\>|\\|[>\\]]|o\\{|\\|\\{|o\\||\\|\\|)?")), // "([ox][%s]+|:\\>\\>?|_\\>|[(#\\]>*+^\\{]|[\\|\\:]\\|\\>|\\|[>\\]]|o\\{|\\|\\{|o\\||\\|\\|)?")), //
RegexLeaf.spaceZeroOrMore(), new RegexOptional(new RegexLeaf("SECOND_LABEL", "[%g]([^%g]+)[%g]")), //
RegexLeaf.spaceZeroOrMore(), // 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 RegexOr( //
new RegexLeaf("ENT2", getClassIdentifier()), // new RegexLeaf("ENT2", getClassIdentifier()), //
new RegexLeaf("COUPLE2", COUPLE)), // new RegexLeaf("COUPLE2", COUPLE)), //
@ -210,9 +231,9 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
final Labels labels = new Labels(arg); final Labels labels = new Labels(arg);
Link link = new Link(cl1, cl2, linkType, labels.getDisplay(), queue, labels.getFirstLabel(), Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, labels.getDisplay(), queue,
labels.getSecondLabel(), diagram.getLabeldistance(), diagram.getLabelangle(), labels.getFirstLabel(), labels.getSecondLabel(), diagram.getLabeldistance(),
diagram.getSkinParam().getCurrentStyleBuilder()); diagram.getLabelangle());
if (arg.get("URL", 0) != null) { if (arg.get("URL", 0) != null) {
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), UrlMode.STRICT); final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), UrlMode.STRICT);
final Url url = urlBuilder.getUrl(arg.get("URL", 0)); final Url url = urlBuilder.getUrl(arg.get("URL", 0));
@ -350,8 +371,8 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
final Display labelLink = Display.getWithNewlines(arg.get("LABEL_LINK", 0)); final Display labelLink = Display.getWithNewlines(arg.get("LABEL_LINK", 0));
final String firstLabel = arg.get("FIRST_LABEL", 0); final String firstLabel = arg.get("FIRST_LABEL", 0);
final String secondLabel = arg.get("SECOND_LABEL", 0); final String secondLabel = arg.get("SECOND_LABEL", 0);
final Link link = new Link(cl1, cl2, linkType, labelLink, queue, firstLabel, secondLabel, final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, labelLink, queue, firstLabel,
diagram.getLabeldistance(), diagram.getLabelangle(), diagram.getSkinParam().getCurrentStyleBuilder()); secondLabel, diagram.getLabeldistance(), diagram.getLabelangle());
link.setColors(color().getColor(diagram.getSkinParam().getThemeStyle(), arg, link.setColors(color().getColor(diagram.getSkinParam().getThemeStyle(), arg,
diagram.getSkinParam().getIHtmlColorSet())); diagram.getSkinParam().getIHtmlColorSet()));

View File

@ -192,9 +192,9 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
* secondLabel); } * secondLabel); }
*/ */
final Link link = new Link(cl1, cl2, linkType, Display.getWithNewlines(labelLink), length, firstLabel, final Link link = new Link(diagram.getSkinParam()
secondLabel, diagram.getLabeldistance(), diagram.getLabelangle(), diagram.getSkinParam() .getCurrentStyleBuilder(), cl1, cl2, linkType, Display.getWithNewlines(labelLink), length,
.getCurrentStyleBuilder()); firstLabel, secondLabel, diagram.getLabeldistance(), diagram.getLabelangle());
diagram.resetPragmaLabel(); diagram.resetPragmaLabel();
addLink(diagram, link, arg.get("HEADER", 0)); addLink(diagram, link, arg.get("HEADER", 0));

View File

@ -167,13 +167,13 @@ public final class CommandFactoryNoteActivity implements SingleMultiFactoryComma
final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).goDashed(); final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).goDashed();
if (position == Position.RIGHT) { if (position == Position.RIGHT) {
link = new Link(activity, note, type, Display.NULL, 1, diagram.getSkinParam().getCurrentStyleBuilder()); link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), activity, note, type, Display.NULL, 1);
} else if (position == Position.LEFT) { } else if (position == Position.LEFT) {
link = new Link(note, activity, type, Display.NULL, 1, diagram.getSkinParam().getCurrentStyleBuilder()); link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), note, activity, type, Display.NULL, 1);
} else if (position == Position.BOTTOM) { } else if (position == Position.BOTTOM) {
link = new Link(activity, note, type, Display.NULL, 2, diagram.getSkinParam().getCurrentStyleBuilder()); link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), activity, note, type, Display.NULL, 2);
} else if (position == Position.TOP) { } else if (position == Position.TOP) {
link = new Link(note, activity, type, Display.NULL, 2, diagram.getSkinParam().getCurrentStyleBuilder()); link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), note, activity, type, Display.NULL, 2);
} else { } else {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }

View File

@ -259,15 +259,15 @@ public final class CommandFactoryNoteOnEntity implements SingleMultiFactoryComma
final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).goDashed(); final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).goDashed();
if (position == Position.RIGHT) { if (position == Position.RIGHT) {
link = new Link(cl1, note, type, Display.NULL, 1, diagram.getSkinParam().getCurrentStyleBuilder()); link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, note, type, Display.NULL, 1);
link.setHorizontalSolitary(true); link.setHorizontalSolitary(true);
} else if (position == Position.LEFT) { } else if (position == Position.LEFT) {
link = new Link(note, cl1, type, Display.NULL, 1, diagram.getSkinParam().getCurrentStyleBuilder()); link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), note, cl1, type, Display.NULL, 1);
link.setHorizontalSolitary(true); link.setHorizontalSolitary(true);
} else if (position == Position.BOTTOM) { } else if (position == Position.BOTTOM) {
link = new Link(cl1, note, type, Display.NULL, 2, diagram.getSkinParam().getCurrentStyleBuilder()); link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, note, type, Display.NULL, 2);
} else if (position == Position.TOP) { } else if (position == Position.TOP) {
link = new Link(note, cl1, type, Display.NULL, 2, diagram.getSkinParam().getCurrentStyleBuilder()); link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), note, cl1, type, Display.NULL, 2);
} else { } else {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }

View File

@ -164,11 +164,11 @@ public final class CommandFactoryTipOnEntity implements SingleMultiFactoryComman
final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).getInvisible(); final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).getInvisible();
final Link link; final Link link;
if (position == Position.RIGHT) { if (position == Position.RIGHT) {
link = new Link(cl1, (IEntity) tips, type, Display.NULL, 1, diagram.getSkinParam() link = new Link(diagram.getSkinParam()
.getCurrentStyleBuilder()); .getCurrentStyleBuilder(), cl1, (IEntity) tips, type, Display.NULL, 1);
} else { } else {
link = new Link((IEntity) tips, cl1, type, Display.NULL, 1, diagram.getSkinParam() link = new Link(diagram.getSkinParam()
.getCurrentStyleBuilder()); .getCurrentStyleBuilder(), (IEntity) tips, cl1, type, Display.NULL, 1);
} }
diagram.addLink(link); diagram.addLink(link);
} }

View File

@ -94,8 +94,8 @@ public class CommandLinkBlock extends SingleLineCommand2<CompositeDiagram> {
final String queue = arg.get("QUEUE", 0); final String queue = arg.get("QUEUE", 0);
final Link link = new Link(cl1, cl2, linkType, Display.getWithNewlines(arg.get("DISPLAY", 0)), queue.length(), final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, Display.getWithNewlines(arg.get("DISPLAY", 0)),
diagram.getSkinParam().getCurrentStyleBuilder()); queue.length());
diagram.addLink(link); diagram.addLink(link);
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();
} }

View File

@ -101,9 +101,9 @@ public class AtomMath extends AbstractAtom implements Atom {
} }
private Color getColor(HColor color, Color defaultValue) { private Color getColor(HColor color, Color defaultValue) {
if (color instanceof HColorSimple) { if (color instanceof HColorSimple)
return colorMapper.toColor(color); return colorMapper.toColor(color);
}
return defaultValue; return defaultValue;
} }

View File

@ -35,7 +35,6 @@
*/ */
package net.sourceforge.plantuml.creole.legacy; package net.sourceforge.plantuml.creole.legacy;
import net.sourceforge.plantuml.awt.geom.Dimension2D;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
@ -49,6 +48,7 @@ import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.Log; import net.sourceforge.plantuml.Log;
import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url; 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.AbstractAtom;
import net.sourceforge.plantuml.creole.atom.Atom; import net.sourceforge.plantuml.creole.atom.Atom;
import net.sourceforge.plantuml.graphic.FontConfiguration; 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.UText;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor; 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.HColorAutomagic;
import net.sourceforge.plantuml.ugraphic.color.HColorSimple; import net.sourceforge.plantuml.ugraphic.color.HColorScheme;
import net.sourceforge.plantuml.utils.CharHidder; import net.sourceforge.plantuml.utils.CharHidder;
public final class AtomText extends AbstractAtom implements Atom { public final class AtomText extends AbstractAtom implements Atom {
@ -144,7 +143,7 @@ public final class AtomText extends AbstractAtom implements Atom {
HColor textColor = fontConfiguration.getColor(); HColor textColor = fontConfiguration.getColor();
FontConfiguration useFontConfiguration = fontConfiguration; FontConfiguration useFontConfiguration = fontConfiguration;
if (textColor instanceof HColorAutomagic && ug.getParam().getBackcolor() != null) { if (textColor instanceof HColorAutomagic && ug.getParam().getBackcolor() != null) {
textColor = ((HColorSimple) ug.getParam().getBackcolor()).opposite(); textColor = ug.getParam().getBackcolor().opposite();
useFontConfiguration = fontConfiguration.changeColor(textColor); useFontConfiguration = fontConfiguration.changeColor(textColor);
} }
if (textColor instanceof HColorScheme) { if (textColor instanceof HColorScheme) {

View File

@ -121,18 +121,17 @@ public class Link extends WithLinkType implements Hideable, Removeable {
return new UComment("link " + getEntity1().getCodeGetName() + " to " + getEntity2().getCodeGetName()); return new UComment("link " + getEntity1().getCodeGetName() + " to " + getEntity2().getCodeGetName());
} }
public Link(IEntity cl1, IEntity cl2, LinkType type, Display label, int length, StyleBuilder styleBuilder) { public Link(StyleBuilder styleBuilder, IEntity cl1, IEntity cl2, LinkType type, Display label, int length) {
this(cl1, cl2, type, label, length, null, null, null, null, null, styleBuilder); 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, public Link(StyleBuilder styleBuilder, IEntity cl1, IEntity cl2, LinkType type, Display label, int length,
String qualifier2, String labeldistance, String labelangle, StyleBuilder styleBuilder) { String qualifier1, String qualifier2, String labeldistance, String labelangle) {
this(cl1, cl2, type, label, length, qualifier1, qualifier2, labeldistance, labelangle, null, styleBuilder); 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, public Link(StyleBuilder styleBuilder, IEntity cl1, IEntity cl2, LinkType type, Display label, int length,
String qualifier2, String labeldistance, String labelangle, HColor specificColor, String qualifier1, String qualifier2, String labeldistance, String labelangle, HColor specificColor) {
StyleBuilder styleBuilder) {
if (length < 1) if (length < 1)
throw new IllegalArgumentException(); throw new IllegalArgumentException();
@ -144,9 +143,8 @@ public class Link extends WithLinkType implements Hideable, Removeable {
this.label = Display.NULL; this.label = Display.NULL;
} else { } else {
this.label = label.manageGuillemet(); this.label = label.manageGuillemet();
if (VisibilityModifier.isVisibilityCharacter(label.get(0))) { if (VisibilityModifier.isVisibilityCharacter(label.get(0)))
visibilityModifier = VisibilityModifier.getVisibilityModifier(label.get(0), false); visibilityModifier = VisibilityModifier.getVisibilityModifier(label.get(0), false);
}
} }
this.length = length; this.length = length;
@ -164,8 +162,8 @@ public class Link extends WithLinkType implements Hideable, Removeable {
} }
public Link getInv() { public Link getInv() {
final Link result = new Link(cl2, cl1, getType().getInversed(), label, length, qualifier2, qualifier1, final Link result = new Link(styleBuilder, cl2, cl1, getType().getInversed(), label, length, qualifier2,
labeldistance, labelangle, getSpecificColor(), styleBuilder); qualifier1, labeldistance, labelangle, getSpecificColor());
result.inverted = !this.inverted; result.inverted = !this.inverted;
result.port1 = this.port2; result.port1 = this.port2;
result.port2 = this.port1; result.port2 = this.port1;

View File

@ -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;
}
}

View File

@ -51,13 +51,13 @@ class Magma {
public void putInSquare() { public void putInSquare() {
final SquareLinker<ILeaf> linker = new SquareLinker<ILeaf>() { final SquareLinker<ILeaf> linker = new SquareLinker<ILeaf>() {
public void topDown(ILeaf top, ILeaf down) { public void topDown(ILeaf top, ILeaf down) {
diagram.addLink(new Link(top, down, linkType, Display.NULL, 2, diagram.getSkinParam() diagram.addLink(new Link(diagram.getSkinParam()
.getCurrentStyleBuilder())); .getCurrentStyleBuilder(), top, down, linkType, Display.NULL, 2));
} }
public void leftRight(ILeaf left, ILeaf right) { public void leftRight(ILeaf left, ILeaf right) {
diagram.addLink(new Link(left, right, linkType, Display.NULL, 1, diagram.getSkinParam() diagram.addLink(new Link(diagram.getSkinParam()
.getCurrentStyleBuilder())); .getCurrentStyleBuilder(), left, right, linkType, Display.NULL, 1));
} }
}; };
new SquareMaker<ILeaf>().putInSquare(standalones, linker); new SquareMaker<ILeaf>().putInSquare(standalones, linker);
@ -103,14 +103,14 @@ class Magma {
} }
public void linkToDown(Magma down) { public void linkToDown(Magma down) {
diagram.addLink(new Link(this.getBottomLeft(), down.getTopLeft(), linkType, Display.NULL, 2, diagram diagram.addLink(new Link(diagram
.getSkinParam().getCurrentStyleBuilder())); .getSkinParam().getCurrentStyleBuilder(), this.getBottomLeft(), down.getTopLeft(), linkType, Display.NULL, 2));
} }
public void linkToRight(Magma right) { public void linkToRight(Magma right) {
diagram.addLink(new Link(this.getTopRight(), right.getTopLeft(), linkType, Display.NULL, 1, diagram diagram.addLink(new Link(diagram
.getSkinParam().getCurrentStyleBuilder())); .getSkinParam().getCurrentStyleBuilder(), this.getTopRight(), right.getTopLeft(), linkType, Display.NULL, 1));
} }
} }

View File

@ -258,9 +258,9 @@ public class CommandLinkElement extends SingleLineCommand2<DescriptionDiagram> {
cl1 = getFoo1(diagram, code1, ident1, ident1pure); cl1 = getFoo1(diagram, code1, ident1, ident1pure);
cl2 = getFoo1(diagram, code2, ident2, ident2pure); cl2 = getFoo1(diagram, code2, ident2, ident2pure);
} }
Link link = new Link(cl1, cl2, linkType, Display.getWithNewlines(labels.getLabelLink()), queue.length(), Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, Display.getWithNewlines(labels.getLabelLink()),
labels.getFirstLabel(), labels.getSecondLabel(), diagram.getLabeldistance(), diagram.getLabelangle(), queue.length(), labels.getFirstLabel(), labels.getSecondLabel(), diagram.getLabeldistance(),
diagram.getSkinParam().getCurrentStyleBuilder()); diagram.getLabelangle());
link.setLinkArrow(labels.getLinkArrow()); link.setLinkArrow(labels.getLinkArrow());
if (dir == Direction.LEFT || dir == Direction.UP) if (dir == Direction.LEFT || dir == Direction.UP)
link = link.getInv(); link = link.getInv();

View File

@ -77,11 +77,11 @@ public class PSystemColors extends PlainDiagram implements UDrawable {
public PSystemColors(UmlSource source, String option) { public PSystemColors(UmlSource source, String option) {
super(source); super(source);
if (option == null) { if (option == null)
this.paletteCentralColor = null; this.paletteCentralColor = null;
} else { else
this.paletteCentralColor = option.replaceAll("\\#", ""); this.paletteCentralColor = option.replaceAll("\\#", "");
}
} }
@Override @Override
@ -94,12 +94,11 @@ public class PSystemColors extends PlainDiagram implements UDrawable {
} }
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
if (paletteCentralColor != null && colors.getColorOrWhite(paletteCentralColor) instanceof HColorSimple) { if (paletteCentralColor != null && colors.getColorOrWhite(paletteCentralColor) instanceof HColorSimple)
drawPalette(ug); drawPalette(ug);
} else { else
drawFull(ug); drawFull(ug);
} }
}
private void drawPalette(UGraphic ug) { private void drawPalette(UGraphic ug) {
double x = (centerHexa(2, 0).getX() + centerHexa(3, 0).getX()) / 2; double x = (centerHexa(2, 0).getX() + centerHexa(3, 0).getX()) / 2;
@ -145,7 +144,7 @@ public class PSystemColors extends PlainDiagram implements UDrawable {
} }
private void drawOneHexa(UGraphic ug, String colorName, int i, int j, UPolygon hexa) { 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 = applyColor(ug, color);
ug = ug.apply(new UTranslate(centerHexa(i, j))); ug = ug.apply(new UTranslate(centerHexa(i, j)));
ug.draw(hexa); ug.draw(hexa);
@ -165,9 +164,9 @@ public class PSystemColors extends PlainDiagram implements UDrawable {
String result = null; String result = null;
double min = Double.MAX_VALUE; double min = Double.MAX_VALUE;
for (int i = 1; i < colorName.length() - 1; i++) { for (int i = 1; i < colorName.length() - 1; i++) {
if (Character.isLowerCase(colorName.charAt(i))) { if (Character.isLowerCase(colorName.charAt(i)))
continue; continue;
}
final String candidat = colorName.substring(0, i) + BackSlash.BS_BS_N + colorName.substring(i); final String candidat = colorName.substring(0, i) + BackSlash.BS_BS_N + colorName.substring(i);
final TextBlock tt = getTextName(font, candidat, (HColorSimple) HColors.BLACK); final TextBlock tt = getTextName(font, candidat, (HColorSimple) HColors.BLACK);
final double width = tt.calculateDimension(stringBounder).getWidth(); final double width = tt.calculateDimension(stringBounder).getWidth();
@ -191,9 +190,9 @@ public class PSystemColors extends PlainDiagram implements UDrawable {
private UPolygon getHexa() { private UPolygon getHexa() {
final UPolygon result = new UPolygon(); final UPolygon result = new UPolygon();
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++)
result.addPoint(corner(i)); result.addPoint(corner(i));
}
return result; return result;
} }
@ -202,26 +201,25 @@ public class PSystemColors extends PlainDiagram implements UDrawable {
for (Iterator<String> it = result.iterator(); it.hasNext();) { for (Iterator<String> it = result.iterator(); it.hasNext();) {
final String candidat = it.next(); final String candidat = it.next();
final String similar = candidat.replaceAll("Gray", "Grey"); final String similar = candidat.replaceAll("Gray", "Grey");
if (candidat.equals(similar)) { if (candidat.equals(similar))
continue; continue;
}
if (result.contains(similar)) { if (result.contains(similar))
it.remove(); it.remove();
} }
} if (containsCaseInsensitive(result, other) == false)
if (containsCaseInsensitive(result, other) == false) {
result.add(other); result.add(other);
}
Collections.sort(result, closeComparator(paletteCentralColor)); Collections.sort(result, closeComparator(paletteCentralColor));
return result; return result;
} }
private boolean containsCaseInsensitive(Collection<String> source, String target) { private boolean containsCaseInsensitive(Collection<String> source, String target) {
for (String s : source) { for (String s : source)
if (s.equalsIgnoreCase(target)) { if (s.equalsIgnoreCase(target))
return true; return true;
}
}
return false; return false;
} }
@ -229,8 +227,8 @@ public class PSystemColors extends PlainDiagram implements UDrawable {
final HColorSimple centerColor = (HColorSimple) colors.getColorOrWhite(center); final HColorSimple centerColor = (HColorSimple) colors.getColorOrWhite(center);
return new Comparator<String>() { return new Comparator<String>() {
public int compare(String col1, String col2) { public int compare(String col1, String col2) {
final double dist1 = centerColor.distance((HColorSimple) colors.getColorOrWhite(col1)); final int dist1 = centerColor.distanceTo((HColorSimple) colors.getColorOrWhite(col1));
final double dist2 = centerColor.distance((HColorSimple) colors.getColorOrWhite(col2)); final int dist2 = centerColor.distanceTo((HColorSimple) colors.getColorOrWhite(col2));
return (int) Math.signum(dist1 - dist2); return (int) Math.signum(dist1 - dist2);
} }
}; };
@ -244,7 +242,7 @@ public class PSystemColors extends PlainDiagram implements UDrawable {
int j = 0; int j = 0;
for (String name : colors.names()) { for (String name : colors.names()) {
UGraphic tmp = getPositioned(ug, i, j); 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)); applyColor(tmp, color).draw(new URectangle(rectangleWidth, rectangleHeight));
final TextBlock tt = getTextName(font, name, color); final TextBlock tt = getTextName(font, name, color);
final Dimension2D dimText = tt.calculateDimension(ug.getStringBounder()); 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) { private TextBlock getTextName(final UFont font, String name, final HColor color) {
final HColorSimple opposite = color.opposite(); final HColor opposite = color.opposite();
final FontConfiguration fc = FontConfiguration.create(font, opposite, HColors.BLUE, true); final FontConfiguration fc = FontConfiguration.create(font, opposite, HColors.BLUE, true);
final TextBlock tt = Display.getWithNewlines(name).create(fc, HorizontalAlignment.CENTER, final TextBlock tt = Display.getWithNewlines(name).create(fc, HorizontalAlignment.CENTER,
new SpriteContainerEmpty()); new SpriteContainerEmpty());

View File

@ -35,7 +35,6 @@
package net.sourceforge.plantuml.error; package net.sourceforge.plantuml.error;
import java.awt.Color; import java.awt.Color;
import net.sourceforge.plantuml.awt.geom.Dimension2D;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.IOException;
@ -58,6 +57,7 @@ import net.sourceforge.plantuml.SpriteContainerEmpty;
import net.sourceforge.plantuml.StringLocated; import net.sourceforge.plantuml.StringLocated;
import net.sourceforge.plantuml.api.ImageDataSimple; import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.asciiart.UmlCharArea; import net.sourceforge.plantuml.asciiart.UmlCharArea;
import net.sourceforge.plantuml.awt.geom.Dimension2D;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.core.UmlSource;
@ -368,7 +368,7 @@ public abstract class PSystemError extends PlainDiagram {
} }
private TextBlockBackcolored getMessageAdopt() { private TextBlockBackcolored getMessageAdopt() {
final HColorSimple backColor = (HColorSimple) HColorSet.instance().getColorOrWhite("#eff4d2"); final HColor backColor = HColorSet.instance().getColorOrWhite("#eff4d2");
final Display disp = Display.create("<b>Adopt-a-Word and put your message here!", " ", final Display disp = Display.create("<b>Adopt-a-Word and put your message here!", " ",
"Details on <i>[[http://plantuml.com/adopt]]", " "); "Details on <i>[[http://plantuml.com/adopt]]", " ");
@ -387,7 +387,7 @@ public abstract class PSystemError extends PlainDiagram {
final UImage message = new UImage( final UImage message = new UImage(
new PixelImage(PSystemVersion.getTime01(), AffineTransformType.TYPE_BILINEAR)); new PixelImage(PSystemVersion.getTime01(), AffineTransformType.TYPE_BILINEAR));
final Color back = new Color(message.getImage(1).getRGB(0, 0)); 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 FlashCodeUtils utils = FlashCodeFactory.getFlashCodeUtils();
final BufferedImage qrcode = smaller( final BufferedImage qrcode = smaller(
@ -434,7 +434,7 @@ public abstract class PSystemError extends PlainDiagram {
final UImage message = new UImage( final UImage message = new UImage(
new PixelImage(PSystemVersion.getTime15(), AffineTransformType.TYPE_BILINEAR)); new PixelImage(PSystemVersion.getTime15(), AffineTransformType.TYPE_BILINEAR));
final Color back = new Color(message.getImage(1).getRGB(0, 0)); 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 FlashCodeUtils utils = FlashCodeFactory.getFlashCodeUtils();
final BufferedImage qrcode = smaller(utils.exportFlashcode("http://plantuml.com/lp", Color.BLACK, Color.WHITE)); final BufferedImage qrcode = smaller(utils.exportFlashcode("http://plantuml.com/lp", Color.BLACK, Color.WHITE));

View File

@ -38,7 +38,6 @@ package net.sourceforge.plantuml.graphic;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorBackground;
import net.sourceforge.plantuml.ugraphic.color.HColors; import net.sourceforge.plantuml.ugraphic.color.HColors;
public class SymbolContext { public class SymbolContext {
@ -88,14 +87,6 @@ public class SymbolContext {
return ug.apply(stroke); 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) { public SymbolContext(HColor backColor, HColor foreColor) {
this(backColor, foreColor, new UStroke(), 0, 0, 0); this(backColor, foreColor, new UStroke(), 0, 0, 0);
} }

View File

@ -78,11 +78,11 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
if (link == null) { if (link == null) {
return false; return false;
} }
final Link l1 = new Link(entity1, node, link.getType(), link.getLabel(), link.getLength(), link.getQualifier1(), final Link l1 = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, node, link.getType(), link.getLabel(), link.getLength(),
null, link.getLabeldistance(), link.getLabelangle(), getSkinParam().getCurrentStyleBuilder()); link.getQualifier1(), null, link.getLabeldistance(), link.getLabelangle());
final Link l2 = new Link(node, entity2, link.getType(), link.getLabel(), link.getLength(), null, final Link l2 = new Link(getSkinParam().getCurrentStyleBuilder(), node, entity2, link.getType(), link.getLabel(), link.getLength(),
link.getQualifier2(), link.getLabeldistance(), link.getLabelangle(), null, link.getQualifier2(), link.getLabeldistance(),
getSkinParam().getCurrentStyleBuilder()); link.getLabelangle());
addLink(l1); addLink(l1);
addLink(l2); addLink(l2);
removeLink(link); removeLink(link);
@ -147,8 +147,8 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
insertPointBetween(entity2A, entity2B, point2); insertPointBetween(entity2A, entity2B, point2);
final int length = 1; final int length = 1;
final Link point1ToPoint2 = new Link(point1, point2, linkType, label, length, final Link point1ToPoint2 = new Link(getSkinParam().getCurrentStyleBuilder(), point1, point2, linkType, label,
getSkinParam().getCurrentStyleBuilder()); length);
addLink(point1ToPoint2); addLink(point1ToPoint2);
return CommandExecutionResult.ok(); 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) { private void insertPointBetween(final IEntity entity1A, final IEntity entity1B, final IEntity point1) {
Link existingLink1 = foundLink(entity1A, entity1B); Link existingLink1 = foundLink(entity1A, entity1B);
if (existingLink1 == null) { if (existingLink1 == null) {
existingLink1 = new Link(entity1A, entity1B, new LinkType(LinkDecor.NONE, LinkDecor.NONE), Display.NULL, 2, existingLink1 = new Link(getSkinParam().getCurrentStyleBuilder(), entity1A, entity1B, new LinkType(LinkDecor.NONE, LinkDecor.NONE), Display.NULL,
getSkinParam().getCurrentStyleBuilder()); 2);
} else { } else {
removeLink(existingLink1); removeLink(existingLink1);
} }
@ -170,14 +170,14 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
final IEntity entity2real = existingLink1.isInverted() ? existingLink1.getEntity1() final IEntity entity2real = existingLink1.isInverted() ? existingLink1.getEntity1()
: existingLink1.getEntity2(); : existingLink1.getEntity2();
final Link entity1ToPoint = new Link(entity1real, point1, existingLink1.getType().getPart2(), final Link entity1ToPoint = new Link(getSkinParam().getCurrentStyleBuilder(), entity1real, point1,
existingLink1.getLabel(), existingLink1.getLength(), existingLink1.getQualifier1(), null, existingLink1.getType().getPart2(), existingLink1.getLabel(), existingLink1.getLength(), existingLink1.getQualifier1(),
existingLink1.getLabeldistance(), existingLink1.getLabelangle(), null, existingLink1.getLabeldistance(),
getSkinParam().getCurrentStyleBuilder()); existingLink1.getLabelangle());
entity1ToPoint.setLinkArrow(existingLink1.getLinkArrow()); entity1ToPoint.setLinkArrow(existingLink1.getLinkArrow());
final Link pointToEntity2 = new Link(point1, entity2real, existingLink1.getType().getPart1(), Display.NULL, final Link pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point1, entity2real, existingLink1.getType().getPart1(),
existingLink1.getLength(), null, existingLink1.getQualifier2(), existingLink1.getLabeldistance(), Display.NULL, existingLink1.getLength(), null, existingLink1.getQualifier2(),
existingLink1.getLabelangle(), getSkinParam().getCurrentStyleBuilder()); existingLink1.getLabeldistance(), existingLink1.getLabelangle());
// int length = 1; // int length = 1;
// if (existingLink.getLength() == 1 && entity1A != entity1B) { // if (existingLink.getLength() == 1 && entity1A != entity1B) {
@ -268,8 +268,8 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
void createNew(int mode, LinkType linkType, Display label) { void createNew(int mode, LinkType linkType, Display label) {
existingLink = foundLink(entity1, entity2); existingLink = foundLink(entity1, entity2);
if (existingLink == null) { if (existingLink == null) {
existingLink = new Link(entity1, entity2, new LinkType(LinkDecor.NONE, LinkDecor.NONE), Display.NULL, 2, existingLink = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, entity2, new LinkType(LinkDecor.NONE, LinkDecor.NONE), Display.NULL,
getSkinParam().getCurrentStyleBuilder()); 2);
} else { } else {
removeLink(existingLink); removeLink(existingLink);
} }
@ -279,13 +279,13 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
final IEntity entity2real = existingLink.isInverted() ? existingLink.getEntity1() final IEntity entity2real = existingLink.isInverted() ? existingLink.getEntity1()
: existingLink.getEntity2(); : existingLink.getEntity2();
entity1ToPoint = new Link(entity1real, point, existingLink.getType().getPart2(), existingLink.getLabel(), entity1ToPoint = new Link(getSkinParam().getCurrentStyleBuilder(), entity1real, point, existingLink.getType().getPart2(),
existingLink.getLength(), existingLink.getQualifier1(), null, existingLink.getLabeldistance(), existingLink.getLabel(), existingLink.getLength(), existingLink.getQualifier1(), null,
existingLink.getLabelangle(), getSkinParam().getCurrentStyleBuilder()); existingLink.getLabeldistance(), existingLink.getLabelangle());
entity1ToPoint.setLinkArrow(existingLink.getLinkArrow()); entity1ToPoint.setLinkArrow(existingLink.getLinkArrow());
pointToEntity2 = new Link(point, entity2real, existingLink.getType().getPart1(), Display.NULL, pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point, entity2real, existingLink.getType().getPart1(),
existingLink.getLength(), null, existingLink.getQualifier2(), existingLink.getLabeldistance(), Display.NULL, existingLink.getLength(), null, existingLink.getQualifier2(),
existingLink.getLabelangle(), getSkinParam().getCurrentStyleBuilder()); existingLink.getLabeldistance(), existingLink.getLabelangle());
int length = 1; int length = 1;
if (existingLink.getLength() == 1 && entity1 != entity2) { if (existingLink.getLength() == 1 && entity1 != entity2) {
@ -304,11 +304,11 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
addLink(pointToEntity2); addLink(pointToEntity2);
if (mode == 1) { if (mode == 1) {
pointToAssocied = new Link(point, associed, linkType, label, length, pointToAssocied = new Link(getSkinParam().getCurrentStyleBuilder(), point, associed, linkType, label,
getSkinParam().getCurrentStyleBuilder()); length);
} else { } else {
pointToAssocied = new Link(associed, point, linkType, label, length, pointToAssocied = new Link(getSkinParam().getCurrentStyleBuilder(), associed, point, linkType, label,
getSkinParam().getCurrentStyleBuilder()); length);
} }
addLink(pointToAssocied); addLink(pointToAssocied);
} }
@ -316,18 +316,18 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
void createInSecond(LinkType linkType, Display label) { void createInSecond(LinkType linkType, Display label) {
existingLink = foundLink(entity1, entity2); existingLink = foundLink(entity1, entity2);
if (existingLink == null) { if (existingLink == null) {
existingLink = new Link(entity1, entity2, new LinkType(LinkDecor.NONE, LinkDecor.NONE), Display.NULL, 2, existingLink = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, entity2, new LinkType(LinkDecor.NONE, LinkDecor.NONE), Display.NULL,
getSkinParam().getCurrentStyleBuilder()); 2);
} else { } else {
removeLink(existingLink); removeLink(existingLink);
} }
entity1ToPoint = new Link(entity1, point, existingLink.getType().getPart2(), existingLink.getLabel(), 2, entity1ToPoint = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, point, existingLink.getType().getPart2(), existingLink.getLabel(),
existingLink.getQualifier1(), null, existingLink.getLabeldistance(), existingLink.getLabelangle(), 2, existingLink.getQualifier1(), null, existingLink.getLabeldistance(),
getSkinParam().getCurrentStyleBuilder()); existingLink.getLabelangle());
pointToEntity2 = new Link(point, entity2, existingLink.getType().getPart1(), Display.NULL, 2, null, pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point, entity2, existingLink.getType().getPart1(), Display.NULL, 2,
existingLink.getQualifier2(), existingLink.getLabeldistance(), existingLink.getLabelangle(), null, existingLink.getQualifier2(), existingLink.getLabeldistance(),
getSkinParam().getCurrentStyleBuilder()); existingLink.getLabelangle());
// entity1ToPoint = new Link(entity1, point, existingLink.getType(), // entity1ToPoint = new Link(entity1, point, existingLink.getType(),
// null, 2); // null, 2);
// pointToEntity2 = new Link(point, entity2, existingLink.getType(), // pointToEntity2 = new Link(point, entity2, existingLink.getType(),
@ -339,11 +339,11 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
other.pointToAssocied = other.pointToAssocied.getInv(); other.pointToAssocied = other.pointToAssocied.getInv();
addLink(other.pointToAssocied); 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); addLink(pointToAssocied);
final Link lnode = new Link(other.point, this.point, new LinkType(LinkDecor.NONE, LinkDecor.NONE), final Link lnode = new Link(getSkinParam().getCurrentStyleBuilder(), other.point, this.point,
Display.NULL, 1, getSkinParam().getCurrentStyleBuilder()); new LinkType(LinkDecor.NONE, LinkDecor.NONE), Display.NULL, 1);
lnode.setInvis(true); lnode.setInvis(true);
addLink(lnode); addLink(lnode);

View File

@ -128,8 +128,8 @@ public class CommandCreateMap extends CommandMultilines2<AbstractEntityDiagram>
final LinkType linkType = new LinkType(LinkDecor.ARROW, LinkDecor.NONE); final LinkType linkType = new LinkType(LinkDecor.ARROW, LinkDecor.NONE);
final int length = linkStr.length() - 2; final int length = linkStr.length() - 2;
final Link link = new Link(entity1, entity2, linkType, Display.NULL, length, final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), entity1, entity2, linkType, Display.NULL,
diagram.getSkinParam().getCurrentStyleBuilder()); length);
link.setPortMembers(key, null); link.setPortMembers(key, null);
diagram.addLink(link); diagram.addLink(link);
} }

View File

@ -54,7 +54,6 @@ import net.sourceforge.plantuml.security.SFile;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorAutomagic; import net.sourceforge.plantuml.ugraphic.color.HColorAutomagic;
import net.sourceforge.plantuml.ugraphic.color.HColorSimple;
public class OpenIcon { public class OpenIcon {
@ -103,7 +102,7 @@ public class OpenIcon {
} }
void saveCopy(SFile fnew) throws IOException { void saveCopy(SFile fnew) throws IOException {
try(PrintWriter pw = fnew.createPrintWriter()) { try (PrintWriter pw = fnew.createPrintWriter()) {
pw.println(rawData.get(0)); pw.println(rawData.get(0));
pw.println(svgPath.toSvg()); pw.println(svgPath.toSvg());
pw.println(rawData.get(rawData.size() - 1)); pw.println(rawData.get(rawData.size() - 1));
@ -136,9 +135,9 @@ public class OpenIcon {
return new AbstractTextBlock() { return new AbstractTextBlock() {
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
HColor textColor = color; HColor textColor = color;
if (textColor instanceof HColorAutomagic && ug.getParam().getBackcolor() != null) { if (textColor instanceof HColorAutomagic && ug.getParam().getBackcolor() != null)
textColor = ((HColorSimple) ug.getParam().getBackcolor()).opposite(); textColor = ug.getParam().getBackcolor().opposite();
}
svgPath.drawMe(ug.apply(textColor), factor); svgPath.drawMe(ug.apply(textColor), factor);
} }

View File

@ -39,7 +39,6 @@ import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorSet; import net.sourceforge.plantuml.ugraphic.color.HColorSet;
import net.sourceforge.plantuml.ugraphic.color.HColorSimple;
import net.sourceforge.plantuml.ugraphic.color.HColors; import net.sourceforge.plantuml.ugraphic.color.HColors;
public abstract class AbstractElement implements Element { public abstract class AbstractElement implements Element {
@ -73,7 +72,7 @@ public abstract class AbstractElement implements Element {
} }
private HColor buildColor(String color1, String color2) { 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); final HColor tmp2 = HColorSet.instance().getColorOrWhite(null, color2);
return tmp1.withDark(tmp2); return tmp1.withDark(tmp2);
} }

View File

@ -79,13 +79,12 @@ public class CommandGrouping extends SingleLineCommand2<SequenceDiagram> {
final HColorSet colorSet = diagram.getSkinParam().getIHtmlColorSet(); final HColorSet colorSet = diagram.getSkinParam().getIHtmlColorSet();
HColor backColorElement = null; HColor backColorElement = null;
if (s != 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); final String s2 = arg.get("COLORS", 1);
HColor backColorGeneral = null; HColor backColorGeneral = null;
if (s2 != null) { if (s2 != null) {
backColorGeneral = colorSet.getColor(diagram.getSkinParam().getThemeStyle(), s2, backColorGeneral = colorSet.getColor(diagram.getSkinParam().getThemeStyle(), s2);
diagram.getSkinParam().getBackgroundColor());
} }
String comment = arg.get("COMMENT", 0); String comment = arg.get("COMMENT", 0);
final GroupingType groupingType = GroupingType.getType(type); final GroupingType groupingType = GroupingType.getType(type);

View File

@ -63,7 +63,7 @@ public class ComponentRoseEnglober extends AbstractTextualComponent {
@Override @Override
protected void drawBackgroundInternalU(UGraphic ug, Area area) { protected void drawBackgroundInternalU(UGraphic ug, Area area) {
final Dimension2D dimensionToUse = area.getDimensionToUse(); final Dimension2D dimensionToUse = area.getDimensionToUse();
ug = symbolContext.transparentBackColorToNull().apply(ug); ug = symbolContext.apply(ug);
ug.draw(new URectangle(dimensionToUse.getWidth(), dimensionToUse.getHeight()).rounded(roundCorner)); ug.draw(new URectangle(dimensionToUse.getWidth(), dimensionToUse.getHeight()).rounded(roundCorner));
final double xpos = (dimensionToUse.getWidth() - getPureTextWidth(ug.getStringBounder())) / 2; final double xpos = (dimensionToUse.getWidth() - getPureTextWidth(ug.getStringBounder())) / 2;
getTextBlock().drawU(ug.apply(UTranslate.dx(xpos))); getTextBlock().drawU(ug.apply(UTranslate.dx(xpos)));

View File

@ -52,7 +52,6 @@ import net.sourceforge.plantuml.ugraphic.UShape;
import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorBackground;
import net.sourceforge.plantuml.ugraphic.color.HColors; import net.sourceforge.plantuml.ugraphic.color.HColors;
public class ComponentRoseGroupingElse extends AbstractTextualComponent { public class ComponentRoseGroupingElse extends AbstractTextualComponent {
@ -72,9 +71,6 @@ public class ComponentRoseGroupingElse extends AbstractTextualComponent {
@Override @Override
protected void drawBackgroundInternalU(UGraphic ug, Area area) { protected void drawBackgroundInternalU(UGraphic ug, Area area) {
if (backgroundColor instanceof HColorBackground)
return;
if (HColors.isTransparent(backgroundColor)) if (HColors.isTransparent(backgroundColor))
return; return;

View File

@ -56,7 +56,6 @@ import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorBackground;
public class ComponentRoseGroupingHeader extends AbstractTextualComponent { public class ComponentRoseGroupingHeader extends AbstractTextualComponent {
@ -123,9 +122,6 @@ public class ComponentRoseGroupingHeader extends AbstractTextualComponent {
@Override @Override
protected void drawBackgroundInternalU(UGraphic ug, Area area) { protected void drawBackgroundInternalU(UGraphic ug, Area area) {
if (background instanceof HColorBackground)
return;
final Dimension2D dimensionToUse = area.getDimensionToUse(); final Dimension2D dimensionToUse = area.getDimensionToUse();
ug = symbolContext.applyStroke(ug).apply(symbolContext.getForeColor()); ug = symbolContext.applyStroke(ug).apply(symbolContext.getForeColor());
final URectangle rect = new URectangle(dimensionToUse.getWidth(), dimensionToUse.getHeight()) final URectangle rect = new URectangle(dimensionToUse.getWidth(), dimensionToUse.getHeight())

View File

@ -40,21 +40,22 @@ import java.util.Objects;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorSimple; import net.sourceforge.plantuml.ugraphic.color.HColorSimple;
import net.sourceforge.plantuml.ugraphic.color.HColors;
public class ColorPalette { public class ColorPalette {
private static final String colorValue = "!#$%&*+-:;<=>?@^_~GHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; private static final String colorValue = "!#$%&*+-:;<=>?@^_~GHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
public char getCharFor(Color dest) { public char getCharFor(Color dest) {
return getCharFor(new HColorSimple(dest, false)); return getCharFor(HColors.simple(dest));
} }
public char getCharFor(HColor dest) { public char getCharFor(HColor dest) {
char result = 0; char result = 0;
double resultDist = Double.MAX_VALUE; int resultDist = Integer.MAX_VALUE;
for (int i = 0; i < colorValue.length(); i++) { for (int i = 0; i < colorValue.length(); i++) {
final char c = colorValue.charAt(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) { if (dist < resultDist) {
result = c; result = c;
resultDist = dist; resultDist = dist;
@ -64,9 +65,9 @@ public class ColorPalette {
return result; return result;
} }
private HColorSimple getHtmlColorSimpleFor(char c) { private HColor getHtmlColorSimpleFor(char c) {
final Color color = Objects.requireNonNull(getColorFor(c)); final Color color = Objects.requireNonNull(getColorFor(c));
return new HColorSimple(color, false); return HColors.simple(color);
} }
public Color getColorFor(char c) { public Color getColorFor(char c) {

View File

@ -40,20 +40,21 @@ import java.util.Objects;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorSimple; import net.sourceforge.plantuml.ugraphic.color.HColorSimple;
import net.sourceforge.plantuml.ugraphic.color.HColors;
public class ColorPalette4096 { public class ColorPalette4096 {
private static final String colorValue = "!#$%&*+-:;<=>?@^_~GHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; private static final String colorValue = "!#$%&*+-:;<=>?@^_~GHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
public String getStringFor(Color dest) { public String getStringFor(Color dest) {
return getStringFor(new HColorSimple(dest, false)); return getStringFor(HColors.simple(dest));
} }
public String getStringFor(HColor dest) { public String getStringFor(HColor dest) {
int result = 0; int result = 0;
double resultDist = Double.MAX_VALUE; int resultDist = Integer.MAX_VALUE;
for (int i = 0; i < 4096; i++) { 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) { if (dist < resultDist) {
result = i; result = i;
resultDist = dist; resultDist = dist;
@ -69,23 +70,23 @@ public class ColorPalette4096 {
return "" + colorValue.charAt(v1) + colorValue.charAt(v2); return "" + colorValue.charAt(v1) + colorValue.charAt(v2);
} }
private HColorSimple getHtmlColorSimpleFor(int s) { private HColor getHtmlColorSimpleFor(int s) {
final Color color = Objects.requireNonNull(getColorFor(s)); final Color color = Objects.requireNonNull(getColorFor(s));
return new HColorSimple(color, false); return HColors.simple(color);
} }
public Color getColorFor(String s) { public Color getColorFor(String s) {
if (s.length() != 2) { if (s.length() != 2)
throw new IllegalArgumentException(); throw new IllegalArgumentException();
}
final int v1 = colorValue.indexOf(s.charAt(0)); final int v1 = colorValue.indexOf(s.charAt(0));
if (v1 == -1) { if (v1 == -1)
return null; return null;
}
final int v2 = colorValue.indexOf(s.charAt(1)); final int v2 = colorValue.indexOf(s.charAt(1));
if (v2 == -1) { if (v2 == -1)
return null; return null;
}
final int code = v1 * 64 + v2; final int code = v1 * 64 + v2;
return getColorFor(code); return getColorFor(code);
} }

View File

@ -52,7 +52,6 @@ import net.sourceforge.plantuml.ugraphic.UImage;
import net.sourceforge.plantuml.ugraphic.color.ColorMapper; import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorGradient; import net.sourceforge.plantuml.ugraphic.color.HColorGradient;
import net.sourceforge.plantuml.ugraphic.color.HColorSimple;
import net.sourceforge.plantuml.ugraphic.color.HColors; import net.sourceforge.plantuml.ugraphic.color.HColors;
public class SpriteMonochrome implements Sprite { 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); final BufferedImage im = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
for (int col = 0; col < width; col++) { for (int col = 0; col < width; col++) {
for (int line = 0; line < height; line++) { for (int line = 0; line < height; line++) {
final HColor backColorLocal = new HColorSimple(backcolor.getColor(colorMapper, 1.0 * line / height), final HColor backColorLocal = HColors
false); .simple(backcolor.getColor(colorMapper, 1.0 * line / height));
final HColorGradient gradient = HColors.gradient(backColorLocal, color, '\0'); final HColorGradient gradient = HColors.gradient(backColorLocal, color, '\0');
final double coef = 1.0 * gray[line][col] / (grayLevel - 1); final double coef = 1.0 * gray[line][col] / (grayLevel - 1);
final Color c = gradient.getColor(colorMapper, coef); final Color c = gradient.getColor(colorMapper, coef);

View File

@ -118,7 +118,7 @@ abstract class CommandLinkStateCommon extends SingleLineCommand2<StateDiagram> {
crossStart ? LinkDecor.CIRCLE_CROSS : LinkDecor.NONE); crossStart ? LinkDecor.CIRCLE_CROSS : LinkDecor.NONE);
final Display label = Display.getWithNewlines(arg.get("LABEL", 0)); 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) { if (dir == Direction.LEFT || dir == Direction.UP) {
link = link.getInv(); link = link.getInv();
} }

View File

@ -42,7 +42,6 @@ import net.sourceforge.plantuml.api.ThemeStyle;
import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorSet; import net.sourceforge.plantuml.ugraphic.color.HColorSet;
import net.sourceforge.plantuml.ugraphic.color.HColorSimple;
import net.sourceforge.plantuml.ugraphic.color.HColors; import net.sourceforge.plantuml.ugraphic.color.HColors;
public class ValueImpl implements Value { public class ValueImpl implements Value {
@ -105,7 +104,7 @@ public class ValueImpl implements Value {
final HColor result = set.getColorOrWhite(themeStyle, value1); final HColor result = set.getColorOrWhite(themeStyle, value1);
if (value.getValue2() != null) { if (value.getValue2() != null) {
final HColor dark = set.getColorOrWhite(themeStyle, value.getValue2()); final HColor dark = set.getColorOrWhite(themeStyle, value.getValue2());
return ((HColorSimple) result).withDark(dark); return result.withDark(dark);
} }
return result; return result;
} }

View File

@ -46,7 +46,7 @@ import net.sourceforge.plantuml.tim.TContext;
import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TFunctionSignature;
import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.TMemory;
import net.sourceforge.plantuml.tim.expression.TValue; 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; import net.sourceforge.plantuml.ugraphic.color.HSLColor;
public class HslColor extends SimpleReturnFunction { public class HslColor extends SimpleReturnFunction {
@ -67,12 +67,12 @@ public class HslColor extends SimpleReturnFunction {
if (values.size() == 3) { if (values.size() == 3) {
final HSLColor color = new HSLColor(h, s, l); final HSLColor color = new HSLColor(h, s, l);
final Color rgb = color.getRGB(); 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 int a = values.get(3).toInt();
final HSLColor color = new HSLColor(h, s, l, (float) (a / 100.0)); final HSLColor color = new HSLColor(h, s, l, (float) (a / 100.0));
final Color rgb = color.getRGB(); final Color rgb = color.getRGB();
return TValue.fromString(new HColorSimple(rgb, false).asString()); return TValue.fromString(HColors.simple(rgb).asString());
} }
} }

View File

@ -93,7 +93,6 @@ import net.sourceforge.plantuml.svg.LengthAdjust;
import net.sourceforge.plantuml.ugraphic.color.ColorMapper; import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity; import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor; 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.HColorGradient;
import net.sourceforge.plantuml.ugraphic.color.HColorNone; import net.sourceforge.plantuml.ugraphic.color.HColorNone;
import net.sourceforge.plantuml.ugraphic.color.HColorSimple; import net.sourceforge.plantuml.ugraphic.color.HColorSimple;
@ -169,9 +168,9 @@ public class ImageBuilder {
public ImageBuilder drawable(UDrawable drawable) { public ImageBuilder drawable(UDrawable drawable) {
this.udrawable = drawable; this.udrawable = drawable;
if (backcolor == null && drawable instanceof TextBlockBackcolored) { if (backcolor == null && drawable instanceof TextBlockBackcolored)
backcolor = ((TextBlockBackcolored) drawable).getBackcolor(); backcolor = ((TextBlockBackcolored) drawable).getBackcolor();
}
return this; return this;
} }
@ -201,13 +200,13 @@ public class ImageBuilder {
} }
private String getSvgLinkTarget() { private String getSvgLinkTarget() {
if (fileFormatOption.getSvgLinkTarget() != null) { if (fileFormatOption.getSvgLinkTarget() != null)
return fileFormatOption.getSvgLinkTarget(); return fileFormatOption.getSvgLinkTarget();
} else if (skinParam != null) { else if (skinParam != null)
return skinParam.getSvgLinkTarget(); return skinParam.getSvgLinkTarget();
} else { else
return null; return null;
}
} }
public ImageBuilder warningOrError(String warningOrError) { public ImageBuilder warningOrError(String warningOrError) {
@ -272,12 +271,13 @@ public class ImageBuilder {
/ 96.0; / 96.0;
if (scaleFactor <= 0) if (scaleFactor <= 0)
throw new IllegalStateException("Bad scaleFactor"); throw new IllegalStateException("Bad scaleFactor");
UGraphic ug = createUGraphic(fileFormatOption, dim, animationArg, dx, dy, scaleFactor, UGraphic ug = createUGraphic(fileFormatOption, dim, animationArg, dx, dy, scaleFactor,
titledDiagram == null ? new Pragma() : titledDiagram.getPragma()); titledDiagram == null ? new Pragma() : titledDiagram.getPragma());
maybeDrawBorder(ug, dim); maybeDrawBorder(ug, dim);
if (randomPixel) { if (randomPixel)
drawRandomPoint(ug); drawRandomPoint(ug);
}
ug = handwritten(ug.apply(new UTranslate(margin.getLeft(), margin.getTop()))); ug = handwritten(ug.apply(new UTranslate(margin.getLeft(), margin.getTop())));
udrawable.drawU(ug); udrawable.drawU(ug);
ug.flushUg(); ug.flushUg();
@ -319,7 +319,7 @@ public class ImageBuilder {
final int green = rnd.nextInt(40); final int green = rnd.nextInt(40);
final int blue = rnd.nextInt(40); final int blue = rnd.nextInt(40);
final Color c = new Color(red, green, blue); 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)); ug2.apply(color).apply(color.bg()).draw(new URectangle(1, 1));
} }
@ -334,9 +334,9 @@ public class ImageBuilder {
} }
private UGraphic handwritten(UGraphic ug) { private UGraphic handwritten(UGraphic ug) {
if (skinParam != null && skinParam.handwritten()) { if (skinParam != null && skinParam.handwritten())
return new UGraphicHandwritten(ug); return new UGraphicHandwritten(ug);
}
// if (OptionFlags.OMEGA_CROSSING) { // if (OptionFlags.OMEGA_CROSSING) {
// return new UGraphicCrossing(ug); // return new UGraphicCrossing(ug);
// } else { // } else {
@ -450,16 +450,14 @@ public class ImageBuilder {
double dy, String watermark) { double dy, String watermark) {
Color backColor = getDefaultBackColor(); Color backColor = getDefaultBackColor();
if (this.backcolor instanceof HColorSimple) { if (this.backcolor instanceof HColorSimple)
backColor = colorMapper.toColor(this.backcolor); backColor = colorMapper.toColor(this.backcolor);
} else if (this.backcolor instanceof HColorBackground || this.backcolor instanceof HColorNone) { else if (this.backcolor instanceof HColorNone)
backColor = null; backColor = null;
}
if (OptionFlags.getInstance().isReplaceWhiteBackgroundByTransparent() && backColor != null if (OptionFlags.getInstance().isReplaceWhiteBackgroundByTransparent() && backColor != null
&& backColor.equals(Color.WHITE)) { && backColor.equals(Color.WHITE))
backColor = new Color(0, 0, 0, 0); backColor = new Color(0, 0, 0, 0);
}
final EmptyImageBuilder builder = new EmptyImageBuilder(watermark, (int) (dim.getWidth() * scaleFactor), final EmptyImageBuilder builder = new EmptyImageBuilder(watermark, (int) (dim.getWidth() * scaleFactor),
(int) (dim.getHeight() * scaleFactor), backColor, stringBounder); (int) (dim.getHeight() * scaleFactor), backColor, stringBounder);
@ -469,10 +467,9 @@ public class ImageBuilder {
affineTransforms == null ? null : affineTransforms.getFirst(), dx, dy); affineTransforms == null ? null : affineTransforms.getFirst(), dx, dy);
ug.setBufferedImage(builder.getBufferedImage()); ug.setBufferedImage(builder.getBufferedImage());
final BufferedImage im = ug.getBufferedImage(); final BufferedImage im = ug.getBufferedImage();
if (this.backcolor instanceof HColorGradient) { if (this.backcolor instanceof HColorGradient)
ug.apply(this.backcolor.bg()) ug.apply(this.backcolor.bg())
.draw(new URectangle(im.getWidth() / scaleFactor, im.getHeight() / scaleFactor)); .draw(new URectangle(im.getWidth() / scaleFactor, im.getHeight() / scaleFactor));
}
return ug; return ug;
} }
@ -490,9 +487,9 @@ public class ImageBuilder {
return fileFormatOption.getHoverColor(); return fileFormatOption.getHoverColor();
} else if (skinParam != null) { } else if (skinParam != null) {
final HColor color = skinParam.hoverPathColor(); final HColor color = skinParam.hoverPathColor();
if (color != null) { if (color != null)
return colorMapper.toRGB(color); return colorMapper.toRGB(color);
}
} }
return null; return null;
} }
@ -507,13 +504,13 @@ public class ImageBuilder {
} }
public String getPreserveAspectRatio() { public String getPreserveAspectRatio() {
if (fileFormatOption.getPreserveAspectRatio() != null) { if (fileFormatOption.getPreserveAspectRatio() != null)
return fileFormatOption.getPreserveAspectRatio(); return fileFormatOption.getPreserveAspectRatio();
} else if (skinParam != null) { else if (skinParam != null)
return skinParam.getPreserveAspectRatio(); return skinParam.getPreserveAspectRatio();
} else { else
return DEFAULT_PRESERVE_ASPECT_RATIO; return DEFAULT_PRESERVE_ASPECT_RATIO;
}
} }
private ImageDataSimple createImageData(Dimension2D dim) { private ImageDataSimple createImageData(Dimension2D dim) {

View File

@ -53,12 +53,6 @@ public abstract class AbstractColorMapper implements ColorMapper {
if (hcolor == null) if (hcolor == null)
return "none"; return "none";
if (hcolor instanceof HColorBackground) {
hcolor = ((HColorBackground) hcolor).getBack();
// Thread.dumpStack();
// System.exit(0);
// return toHtml(result);
}
if (HColors.isTransparent(hcolor)) if (HColors.isTransparent(hcolor))
return "#00000000"; return "#00000000";

View File

@ -40,24 +40,24 @@ import java.awt.Color;
public class ColorMapperForceDark extends AbstractColorMapper implements ColorMapper { public class ColorMapperForceDark extends AbstractColorMapper implements ColorMapper {
public Color toColor(HColor color) { public Color toColor(HColor color) {
if (color == null) { if (color == null)
return null; return null;
}
if (color instanceof HColorBackground) { if (color instanceof HColorNone)
throw new UnsupportedOperationException(); return new Color(0, 0, 0, 0);
}
if (color instanceof HColorGradient) { if (color instanceof HColorGradient)
return toColor(((HColorGradient) color).getColor1()); return toColor(((HColorGradient) color).getColor1());
}
if (color instanceof HColorMiddle) { if (color instanceof HColorMiddle)
return ((HColorMiddle) color).getMappedColor(this); return ((HColorMiddle) color).getMappedColor(this);
}
if (color instanceof HColorScheme) { if (color instanceof HColorScheme)
throw new IllegalStateException(); throw new IllegalStateException();
}
if (color instanceof HColorAutomagic) { if (color instanceof HColorAutomagic)
throw new IllegalStateException(); throw new IllegalStateException();
}
final HColor tmp = ((HColorSimple) color).darkSchemeTheme(); final HColor tmp = ((HColorSimple) color).darkSchemeTheme();
return ((HColorSimple) tmp).getColor999(); return ((HColorSimple) tmp).getColor999();
} }

View File

@ -40,24 +40,24 @@ import java.awt.Color;
public class ColorMapperIdentity extends AbstractColorMapper implements ColorMapper { public class ColorMapperIdentity extends AbstractColorMapper implements ColorMapper {
public Color toColor(HColor color) { public Color toColor(HColor color) {
if (color == null) { if (color == null)
return null; return null;
}
if (color instanceof HColorBackground) { if (color instanceof HColorNone)
throw new UnsupportedOperationException(); return new Color(0, 0, 0, 0);
}
if (color instanceof HColorGradient) { if (color instanceof HColorGradient)
return toColor(((HColorGradient) color).getColor1()); return toColor(((HColorGradient) color).getColor1());
}
if (color instanceof HColorMiddle) { if (color instanceof HColorMiddle)
return ((HColorMiddle) color).getMappedColor(this); return ((HColorMiddle) color).getMappedColor(this);
}
if (color instanceof HColorScheme) { if (color instanceof HColorScheme)
throw new IllegalStateException(); throw new IllegalStateException();
}
if (color instanceof HColorAutomagic) { if (color instanceof HColorAutomagic)
throw new IllegalStateException(); throw new IllegalStateException();
}
return ((HColorSimple) color).getColor999(); return ((HColorSimple) color).getColor999();
} }
} }

View File

@ -40,18 +40,18 @@ import java.awt.Color;
public class ColorMapperLightnessInverse extends AbstractColorMapper implements ColorMapper { public class ColorMapperLightnessInverse extends AbstractColorMapper implements ColorMapper {
public Color toColor(HColor color) { public Color toColor(HColor color) {
if (color == null) { if (color == null)
return null; return null;
}
if (color instanceof HColorBackground) { if (color instanceof HColorGradient)
throw new UnsupportedOperationException();
}
if (color instanceof HColorGradient) {
return toColor(((HColorGradient) color).getColor1()); return toColor(((HColorGradient) color).getColor1());
}
if (color instanceof HColorMiddle) { if (color instanceof HColorMiddle)
return ((HColorMiddle) color).getMappedColor(this); 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.reverseHsluv(((HColorSimple) color).getColor999());
return ColorUtils.getReversed(((HColorSimple) color).getColor999()); return ColorUtils.getReversed(((HColorSimple) color).getColor999());

View File

@ -46,12 +46,15 @@ public class ColorMapperReverse extends AbstractColorMapper implements ColorMapp
} }
public Color toColor(HColor color) { public Color toColor(HColor color) {
if (color == null) { if (color == null)
return null; return null;
}
if (color instanceof HColorMiddle) { if (color instanceof HColorMiddle)
return ((HColorMiddle) color).getMappedColor(this); return ((HColorMiddle) color).getMappedColor(this);
}
if (color instanceof HColorNone)
return getReverse(new Color(0, 0, 0, 0));
return getReverse(((HColorSimple) color).getColor999()); return getReverse(((HColorSimple) color).getColor999());
} }

View File

@ -47,13 +47,12 @@ public class ColorMapperTransparentWrapper extends AbstractColorMapper implement
} }
public Color toColor(HColor color) { public Color toColor(HColor color) {
if (color == null) { if (color == null)
return null; return null;
}
if (color instanceof HColorBackground) { if (color instanceof HColorNone)
final HColor back = ((HColorBackground) color).getBack(); return null;
return mapper.toColor(back);
}
return mapper.toColor(color); return mapper.toColor(color);
} }

View File

@ -45,8 +45,19 @@ public class ColorUtils {
public static int getGrayScale(int red, int green, int blue) { public static int getGrayScale(int red, int green, int blue) {
// YIQ equation from http://24ways.org/2010/calculating-color-contrast // YIQ equation from http://24ways.org/2010/calculating-color-contrast
final int grayScale = (red * 299 + green * 587 + blue * 114) / 1000; return getGrayScaleInternal(red, green, blue) / 1000;
return grayScale; }
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) { public static int getGrayScale(int rgb) {
@ -151,12 +162,12 @@ public class ColorUtils {
private static int to255(final double value) { private static int to255(final double value) {
final int result = (int) (255 * value); final int result = (int) (255 * value);
if (result < 0) { if (result < 0)
return 0; return 0;
}
if (result > 255) { if (result > 255)
return 255; return 255;
}
return result; return result;
} }

View File

@ -42,6 +42,8 @@ public interface HColor extends UChange {
public UBackground bg(); public UBackground bg();
public HColor withDark(HColor dark);
public HColor darken(int ratio); public HColor darken(int ratio);
public HColor lighten(int ratio); public HColor lighten(int ratio);
@ -56,4 +58,6 @@ public interface HColor extends UChange {
public HColor darkSchemeTheme(); public HColor darkSchemeTheme();
public HColor opposite();
} }

View File

@ -81,4 +81,14 @@ abstract class HColorAbstract implements HColor {
return this; return this;
} }
@Override
public HColor withDark(HColor dark) {
throw new UnsupportedOperationException();
}
@Override
public HColor opposite() {
throw new UnsupportedOperationException();
}
} }

View File

@ -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;
}
}

View File

@ -244,8 +244,8 @@ public class HColorSet {
return isColorValid(s1) && isColorValid(s2); return isColorValid(s1) && isColorValid(s2);
} }
HColorGradient buildInternal(HColor background) { HColorGradient buildInternal() {
return HColors.gradient(build(s1, background), build(s2, background), sep); return HColors.gradient(build(s1), build(s2), sep);
} }
} }
@ -265,12 +265,11 @@ public class HColorSet {
return true; return true;
} }
HColorScheme buildInternal(HColor background) { HColorScheme buildInternal() {
if (colors.length == 2) 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), return new HColorScheme(build(colors[0]), build(colors[1]), build(colors[2]));
build(colors[2], background));
} }
} }
@ -302,49 +301,41 @@ public class HColorSet {
} }
public HColor getColorOrWhite(String s) { public HColor getColorOrWhite(String s) {
return getColorOrWhite(null, s, null); return getColorOrWhite(null, s);
} }
public HColor getColorOrWhite(ThemeStyle UNUSED, String 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) if (isColorValid(Objects.requireNonNull(s)) == false)
return HColors.WHITE; return HColors.WHITE;
try { try {
return getColor(null, s, background); return getColor(null, s);
} catch (NoSuchColorException e) { } catch (NoSuchColorException e) {
assert false; assert false;
return HColors.WHITE; return HColors.WHITE;
} }
} }
public HColor getColor(ThemeStyle UNUSED, String s) throws NoSuchColorException {
return getColor(null, s, null);
}
public HColor getColorLEGACY(String s) throws NoSuchColorException { 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) if (isColorValid(Objects.requireNonNull(s)) == false)
throw new NoSuchColorException(); throw new NoSuchColorException();
final Automatic automatic = automaticFromString(s); final Automatic automatic = automaticFromString(s);
if (automatic != null) if (automatic != null)
return automatic.buildInternal(background); return automatic.buildInternal();
final Gradient gradient = gradientFromString(s); final Gradient gradient = gradientFromString(s);
if (gradient != null) 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"; s = "#00000000";
return build(s, background); return build(s);
} }
private boolean isColorValid(String 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); s = removeFirstDieseAndgoLowerCase(s);
final Color color; final Color color;
if (s.equalsIgnoreCase("transparent") || s.equalsIgnoreCase("background")) { if (s.equalsIgnoreCase("transparent") || s.equalsIgnoreCase("background")) {
return new HColorBackground(background); return HColors.generalBackground();
} else if (s.equalsIgnoreCase("automatic")) { } else if (s.equalsIgnoreCase("automatic")) {
return new HColorAutomagic(); return new HColorAutomagic();
} else if (s.matches("[0-9A-Fa-f]")) { } else if (s.matches("[0-9A-Fa-f]")) {
@ -388,7 +379,7 @@ public class HColorSet {
final String value = Objects.requireNonNull(htmlNames.get(s)); final String value = Objects.requireNonNull(htmlNames.get(s));
color = new Color(Integer.parseInt(value.substring(1), 16)); color = new Color(Integer.parseInt(value.substring(1), 16));
} }
return new HColorSimple(color, false); return HColors.simple(color);
} }
private Color fromRGBa(String s) { private Color fromRGBa(String s) {

View File

@ -42,8 +42,7 @@ import net.sourceforge.plantuml.StringUtils;
public class HColorSimple extends HColorAbstract implements HColor { public class HColorSimple extends HColorAbstract implements HColor {
private final Color color; private final Color color;
private final boolean monochrome; private final HColor dark;
private HColor dark;
@Override @Override
public int hashCode() { public int hashCode() {
@ -52,8 +51,6 @@ public class HColorSimple extends HColorAbstract implements HColor {
@Override @Override
public String toString() { public String toString() {
if (isTransparent())
return "transparent";
final boolean withDark = this != dark; final boolean withDark = this != dark;
@ -63,8 +60,8 @@ public class HColorSimple extends HColorAbstract implements HColor {
sb.append(color.toString()); sb.append(color.toString());
sb.append(" \u03B1="); sb.append(" \u03B1=");
sb.append(color.getAlpha()); sb.append(color.getAlpha());
if (monochrome) if (isTransparent())
sb.append("MONOCHROME"); sb.append(" transparent");
return sb.toString(); return sb.toString();
} }
@ -83,24 +80,24 @@ public class HColorSimple extends HColorAbstract implements HColor {
public HColor lighten(int ratio) { public HColor lighten(int ratio) {
final float[] hsl = new HSLColor(color).getHSL(); final float[] hsl = new HSLColor(color).getHSL();
hsl[2] += hsl[2] * (ratio / 100.0); hsl[2] += hsl[2] * (ratio / 100.0);
return new HColorSimple(new HSLColor(hsl).getRGB(), false); return new HColorSimple(new HSLColor(hsl).getRGB());
} }
@Override @Override
public HColor darken(int ratio) { public HColor darken(int ratio) {
final float[] hsl = new HSLColor(color).getHSL(); final float[] hsl = new HSLColor(color).getHSL();
hsl[2] -= hsl[2] * (ratio / 100.0); hsl[2] -= hsl[2] * (ratio / 100.0);
return new HColorSimple(new HSLColor(hsl).getRGB(), false); return new HColorSimple(new HSLColor(hsl).getRGB());
} }
@Override @Override
public HColor reverseHsluv() { public HColor reverseHsluv() {
return new HColorSimple(ColorUtils.reverseHsluv(color), false); return new HColorSimple(ColorUtils.reverseHsluv(color));
} }
@Override @Override
public HColor reverse() { public HColor reverse() {
return new HColorSimple(ColorOrder.RGB.getReverse(color), false); return new HColorSimple(ColorOrder.RGB.getReverse(color));
} }
@Override @Override
@ -120,15 +117,13 @@ public class HColorSimple extends HColorAbstract implements HColor {
return this.color.equals(((HColorSimple) other).color); return this.color.equals(((HColorSimple) other).color);
} }
public HColorSimple(Color c, boolean monochrome) { HColorSimple(Color c) {
this.color = c; this.color = c;
this.monochrome = monochrome;
this.dark = this; this.dark = this;
} }
private HColorSimple(Color c, boolean monochrome, HColor dark) { private HColorSimple(Color c, HColor dark) {
this.color = c; this.color = c;
this.monochrome = monochrome;
this.dark = dark; this.dark = dark;
} }
@ -136,8 +131,8 @@ public class HColorSimple extends HColorAbstract implements HColor {
return color; return color;
} }
public HColorSimple asMonochrome() { public HColor asMonochrome() {
return new HColorSimple(new ColorChangerMonochrome().getChangedColor(color), monochrome); return new HColorSimple(new ColorChangerMonochrome().getChangedColor(color));
} }
public HColor asMonochrome(HColorSimple colorForMonochrome, double minGray, double maxGray) { 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 double coef = (gray - minGray) / 256.0;
final Color result = ColorUtils.grayToColor(coef, colorForMonochrome.color); 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 Color mono = new ColorChangerMonochrome().getChangedColor(color);
final int grayScale = 255 - mono.getGreen() > 127 ? 255 : 0; 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) { public int distanceTo(HColorSimple other) {
final int diffRed = Math.abs(this.color.getRed() - other.color.getRed()); return ColorUtils.distance(this.color, other.color);
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 boolean isGray() { public boolean isGray() {
if (monochrome) return color.getRed() == color.getGreen() && color.getGreen() == color.getBlue();
return true;
if (color.getRed() == color.getGreen() && color.getGreen() == color.getBlue())
return true;
return false;
} }
public static HColorSimple unlinear(HColorSimple color1, HColorSimple color2, int completionInt) { 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); 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) { 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) { 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) { public HColor withDark(HColor dark) {
return new HColorSimple(color, monochrome, dark); return new HColorSimple(color, dark);
} }
@Override @Override

View File

@ -42,8 +42,8 @@ import net.sourceforge.plantuml.ugraphic.UGraphic;
public class HColors { public class HColors {
public static final HColorSimple BLACK; public static final HColor BLACK;
public static final HColorSimple WHITE; public static final HColor WHITE;
public static final HColor RED_LIGHT; public static final HColor RED_LIGHT;
public static final HColor RED_DARK; public static final HColor RED_DARK;
public static final HColor RED; public static final HColor RED;
@ -133,17 +133,23 @@ public class HColors {
return color.bg(); return color.bg();
} }
final private static HColorSimple TRANSPARENT = new HColorSimple(new Color(0, 0, 0, 0), false);
public static HColor transparent() { 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) { public static boolean isTransparent(HColor back) {
if (back == TRANSPARENT) if (back == null)
return true; return true;
if (back instanceof HColorBackground && ((HColorBackground) back).getBack() == TRANSPARENT) if (back instanceof HColorNone)
return true; return true;
if (back instanceof HColorSimple && ((HColorSimple) back).isTransparent()) if (back instanceof HColorSimple && ((HColorSimple) back).isTransparent())
@ -165,10 +171,6 @@ public class HColors {
return color1; return color1;
} }
public static HColor none() {
return new HColorNone();
}
public static HColor middle(HColor c1, HColor c2) { public static HColor middle(HColor c1, HColor c2) {
return new HColorMiddle(c1, c2); return new HColorMiddle(c1, c2);
} }
@ -177,4 +179,8 @@ public class HColors {
return new HColorGradient(color1, color2, policy); return new HColorGradient(color1, color2, policy);
} }
public static HColor simple(Color c) {
return new HColorSimple(c);
}
} }

View File

@ -261,8 +261,6 @@ public class UGraphicDebug extends AbstractCommonUGraphic implements ClipContain
if (color instanceof HColorSimple) { if (color instanceof HColorSimple) {
final HColorSimple simple = (HColorSimple) color; final HColorSimple simple = (HColorSimple) color;
final Color internal = simple.getColor999(); final Color internal = simple.getColor999();
if (simple.isMonochrome())
return "monochrome " + Integer.toHexString(internal.getRGB());
return Integer.toHexString(internal.getRGB()); return Integer.toHexString(internal.getRGB());
} }

View File

@ -45,7 +45,7 @@ public class Version {
private static final int MAJOR_SEPARATOR = 1000000; private static final int MAJOR_SEPARATOR = 1000000;
public static int version() { public static int version() {
return 1202206; return 1202207;
} }
public static int versionPatched() { public static int versionPatched() {
@ -81,7 +81,7 @@ public class Version {
} }
public static int beta() { public static int beta() {
final int beta = 12; final int beta = 0;
return beta; return beta;
} }
@ -94,7 +94,7 @@ public class Version {
} }
public static long compileTime() { public static long compileTime() {
return 1655832889469L; return 1661187690019L;
} }
public static String compileTimeString() { public static String compileTimeString() {

View File

@ -765,7 +765,7 @@ ELLIPSE:
stroke: 0.0-0.0-1.0 stroke: 0.0-0.0-1.0
shadow: 0 shadow: 0
color: ff222222 color: ff222222
backcolor: 0 backcolor: NULL_COLOR
ELLIPSE: ELLIPSE:
pt1: [ 484.2327 ; 862.5000 ] pt1: [ 484.2327 ; 862.5000 ]

View File

@ -23,7 +23,7 @@ RECTANGLE:
yCorner: 0 yCorner: 0
stroke: 0.0-0.0-1.0 stroke: 0.0-0.0-1.0
shadow: 0 shadow: 0
color: 0 color: NULL_COLOR
backcolor: ffff0000 backcolor: ffff0000
TEXT: TEXT:
@ -45,7 +45,7 @@ RECTANGLE:
yCorner: 0 yCorner: 0
stroke: 0.0-0.0-1.0 stroke: 0.0-0.0-1.0
shadow: 0 shadow: 0
color: 0 color: NULL_COLOR
backcolor: ffffff00 backcolor: ffffff00
TEXT: TEXT:
@ -251,7 +251,7 @@ RECTANGLE:
yCorner: 0 yCorner: 0
stroke: 0.0-0.0-1.0 stroke: 0.0-0.0-1.0
shadow: 0 shadow: 0
color: 0 color: NULL_COLOR
backcolor: ff800080 backcolor: ff800080
TEXT: TEXT:
@ -273,7 +273,7 @@ RECTANGLE:
yCorner: 0 yCorner: 0
stroke: 0.0-0.0-1.0 stroke: 0.0-0.0-1.0
shadow: 0 shadow: 0
color: 0 color: NULL_COLOR
backcolor: ff0000ff backcolor: ff0000ff
TEXT: TEXT:

View File

@ -23,7 +23,7 @@ RECTANGLE:
yCorner: 0 yCorner: 0
stroke: 0.0-0.0-1.0 stroke: 0.0-0.0-1.0
shadow: 0 shadow: 0
color: 0 color: NULL_COLOR
backcolor: ffffff00 backcolor: ffffff00
TEXT: TEXT:
@ -45,7 +45,7 @@ RECTANGLE:
yCorner: 0 yCorner: 0
stroke: 0.0-0.0-1.0 stroke: 0.0-0.0-1.0
shadow: 0 shadow: 0
color: 0 color: NULL_COLOR
backcolor: ff800080 backcolor: ff800080
TEXT: TEXT:
@ -171,7 +171,7 @@ RECTANGLE:
yCorner: 0 yCorner: 0
stroke: 0.0-0.0-1.0 stroke: 0.0-0.0-1.0
shadow: 0 shadow: 0
color: 0 color: NULL_COLOR
backcolor: ffff0000 backcolor: ffff0000
TEXT: TEXT:
@ -193,7 +193,7 @@ RECTANGLE:
yCorner: 0 yCorner: 0
stroke: 0.0-0.0-1.0 stroke: 0.0-0.0-1.0
shadow: 0 shadow: 0
color: 0 color: NULL_COLOR
backcolor: ff0000ff backcolor: ff0000ff
TEXT: TEXT: