From 74bcf039a28380fe662c5530b8bf798f0e40e469 Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Tue, 17 Jan 2023 19:23:30 +0100 Subject: [PATCH] Fix https://github.com/plantuml/plantuml/issues/1265 --- .../svek/image/AbstractEntityImageBorder.java | 21 +++++++++++++------ .../plantuml/svek/image/EntityImagePort.java | 11 ++++++---- .../svek/image/EntityImageStateBorder.java | 12 +++++++---- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/net/sourceforge/plantuml/svek/image/AbstractEntityImageBorder.java b/src/net/sourceforge/plantuml/svek/image/AbstractEntityImageBorder.java index 0a4415634..79a68bf3e 100644 --- a/src/net/sourceforge/plantuml/svek/image/AbstractEntityImageBorder.java +++ b/src/net/sourceforge/plantuml/svek/image/AbstractEntityImageBorder.java @@ -47,6 +47,8 @@ import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleSignatureBasic; import net.sourceforge.plantuml.svek.AbstractEntityImage; import net.sourceforge.plantuml.svek.Bibliotekon; import net.sourceforge.plantuml.svek.Cluster; @@ -58,7 +60,13 @@ public abstract class AbstractEntityImageBorder extends AbstractEntityImage { protected final Bibliotekon bibliotekon; protected final Rankdir rankdir; - protected final TextBlock desc; + protected abstract StyleSignatureBasic getSignature(); + + final protected Style getStyle() { + final ILeaf leaf = (ILeaf) getEntity(); + final Stereotype stereotype = leaf.getStereotype(); + return getSignature().withTOBECHANGED(stereotype).getMergedStyle(getSkinParam().getCurrentStyleBuilder()); + } AbstractEntityImageBorder(ILeaf leaf, ISkinParam skinParam, Cluster parent, Bibliotekon bibliotekon, FontParam fontParam) { @@ -69,13 +77,14 @@ public abstract class AbstractEntityImageBorder extends AbstractEntityImage { this.entityPosition = leaf.getEntityPosition(); this.rankdir = skinParam.getRankdir(); - if (entityPosition == EntityPosition.NORMAL) { + if (entityPosition == EntityPosition.NORMAL) throw new IllegalArgumentException(); - } + } - final Stereotype stereotype = leaf.getStereotype(); - final FontConfiguration fc = FontConfiguration.create(skinParam, fontParam, stereotype); - this.desc = leaf.getDisplay().create(fc, HorizontalAlignment.CENTER, skinParam); + protected final TextBlock getDesc() { + final ILeaf leaf = (ILeaf) getEntity(); + final FontConfiguration fc = FontConfiguration.create(getSkinParam(), getStyle()); + return leaf.getDisplay().create(fc, HorizontalAlignment.CENTER, getSkinParam()); } public XDimension2D calculateDimension(StringBounder stringBounder) { diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImagePort.java b/src/net/sourceforge/plantuml/svek/image/EntityImagePort.java index 4fef3fb49..f56c419c6 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImagePort.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImagePort.java @@ -43,11 +43,11 @@ import net.sourceforge.plantuml.awt.geom.XPoint2D; import net.sourceforge.plantuml.baraye.ILeaf; import net.sourceforge.plantuml.cucadiagram.EntityPosition; import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.Style; -import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.style.StyleSignatureBasic; import net.sourceforge.plantuml.svek.Bibliotekon; import net.sourceforge.plantuml.svek.Cluster; @@ -69,8 +69,9 @@ public class EntityImagePort extends AbstractEntityImageBorder { this.sname = sname; } - private StyleSignature getSignature() { - return StyleSignatureBasic.of(SName.root, SName.element, sname, SName.port).withTOBECHANGED(getStereo()); + @Override + protected StyleSignatureBasic getSignature() { + return StyleSignatureBasic.of(SName.root, SName.element, sname, SName.port); } private boolean upPosition() { @@ -85,6 +86,7 @@ public class EntityImagePort extends AbstractEntityImageBorder { } public double getMaxWidthFromLabelForEntryExit(StringBounder stringBounder) { + final TextBlock desc = getDesc(); final XDimension2D dimDesc = desc.calculateDimension(stringBounder); return dimDesc.getWidth(); } @@ -95,6 +97,7 @@ public class EntityImagePort extends AbstractEntityImageBorder { } final public void drawU(UGraphic ug) { + final TextBlock desc = getDesc(); double y = 0; final XDimension2D dimDesc = desc.calculateDimension(ug.getStringBounder()); final double x = 0 - (dimDesc.getWidth() - 2 * EntityPosition.RADIUS) / 2; @@ -106,7 +109,7 @@ public class EntityImagePort extends AbstractEntityImageBorder { desc.drawU(ug.apply(new UTranslate(x, y))); - final Style style = getSignature().getMergedStyle(getSkinParam().getCurrentStyleBuilder()); + final Style style = getStyle(); HColor backcolor = getEntity().getColors().getColor(ColorType.BACK); HColor borderColor = getEntity().getColors().getColor(ColorType.LINE); diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageStateBorder.java b/src/net/sourceforge/plantuml/svek/image/EntityImageStateBorder.java index 4b6aad551..4de935e18 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageStateBorder.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageStateBorder.java @@ -42,6 +42,7 @@ import net.sourceforge.plantuml.awt.geom.XPoint2D; import net.sourceforge.plantuml.baraye.ILeaf; import net.sourceforge.plantuml.cucadiagram.EntityPosition; import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.SName; @@ -65,7 +66,8 @@ public class EntityImageStateBorder extends AbstractEntityImageBorder { this.sname = sname; } - private StyleSignatureBasic getSignature() { + @Override + protected StyleSignatureBasic getSignature() { return StyleSignatureBasic.of(SName.root, SName.element, sname); } @@ -79,6 +81,7 @@ public class EntityImageStateBorder extends AbstractEntityImageBorder { } final public void drawU(UGraphic ug) { + final TextBlock desc = getDesc(); double y = 0; final XDimension2D dimDesc = desc.calculateDimension(ug.getStringBounder()); final double x = 0 - (dimDesc.getWidth() - 2 * EntityPosition.RADIUS) / 2; @@ -89,7 +92,8 @@ public class EntityImageStateBorder extends AbstractEntityImageBorder { desc.drawU(ug.apply(new UTranslate(x, y))); - final Style style = getSignature().getMergedStyle(getSkinParam().getCurrentStyleBuilder()); + final Style style = getStyle(); + final HColor borderColor = style.value(PName.LineColor).asColor(getSkinParam().getIHtmlColorSet()); HColor backcolor = getEntity().getColors().getColor(ColorType.BACK); if (backcolor == null) @@ -104,11 +108,11 @@ public class EntityImageStateBorder extends AbstractEntityImageBorder { private UStroke getUStroke() { return new UStroke(1.5); } - + public double getMaxWidthFromLabelForEntryExit(StringBounder stringBounder) { + final TextBlock desc = getDesc(); final XDimension2D dimDesc = desc.calculateDimension(stringBounder); return dimDesc.getWidth(); } - }