1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-06-15 14:42:24 +00:00
Arnaud Roques 2023-01-17 19:23:30 +01:00
parent c1bbdd6ade
commit 74bcf039a2
3 changed files with 30 additions and 14 deletions

View File

@ -47,6 +47,8 @@ import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock; 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.AbstractEntityImage;
import net.sourceforge.plantuml.svek.Bibliotekon; import net.sourceforge.plantuml.svek.Bibliotekon;
import net.sourceforge.plantuml.svek.Cluster; import net.sourceforge.plantuml.svek.Cluster;
@ -58,7 +60,13 @@ public abstract class AbstractEntityImageBorder extends AbstractEntityImage {
protected final Bibliotekon bibliotekon; protected final Bibliotekon bibliotekon;
protected final Rankdir rankdir; 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, AbstractEntityImageBorder(ILeaf leaf, ISkinParam skinParam, Cluster parent, Bibliotekon bibliotekon,
FontParam fontParam) { FontParam fontParam) {
@ -69,13 +77,14 @@ public abstract class AbstractEntityImageBorder extends AbstractEntityImage {
this.entityPosition = leaf.getEntityPosition(); this.entityPosition = leaf.getEntityPosition();
this.rankdir = skinParam.getRankdir(); this.rankdir = skinParam.getRankdir();
if (entityPosition == EntityPosition.NORMAL) { if (entityPosition == EntityPosition.NORMAL)
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
final Stereotype stereotype = leaf.getStereotype(); protected final TextBlock getDesc() {
final FontConfiguration fc = FontConfiguration.create(skinParam, fontParam, stereotype); final ILeaf leaf = (ILeaf) getEntity();
this.desc = leaf.getDisplay().create(fc, HorizontalAlignment.CENTER, skinParam); final FontConfiguration fc = FontConfiguration.create(getSkinParam(), getStyle());
return leaf.getDisplay().create(fc, HorizontalAlignment.CENTER, getSkinParam());
} }
public XDimension2D calculateDimension(StringBounder stringBounder) { public XDimension2D calculateDimension(StringBounder stringBounder) {

View File

@ -43,11 +43,11 @@ import net.sourceforge.plantuml.awt.geom.XPoint2D;
import net.sourceforge.plantuml.baraye.ILeaf; import net.sourceforge.plantuml.baraye.ILeaf;
import net.sourceforge.plantuml.cucadiagram.EntityPosition; import net.sourceforge.plantuml.cucadiagram.EntityPosition;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.ColorType;
import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.PName;
import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleSignature;
import net.sourceforge.plantuml.style.StyleSignatureBasic; import net.sourceforge.plantuml.style.StyleSignatureBasic;
import net.sourceforge.plantuml.svek.Bibliotekon; import net.sourceforge.plantuml.svek.Bibliotekon;
import net.sourceforge.plantuml.svek.Cluster; import net.sourceforge.plantuml.svek.Cluster;
@ -69,8 +69,9 @@ public class EntityImagePort extends AbstractEntityImageBorder {
this.sname = sname; this.sname = sname;
} }
private StyleSignature getSignature() { @Override
return StyleSignatureBasic.of(SName.root, SName.element, sname, SName.port).withTOBECHANGED(getStereo()); protected StyleSignatureBasic getSignature() {
return StyleSignatureBasic.of(SName.root, SName.element, sname, SName.port);
} }
private boolean upPosition() { private boolean upPosition() {
@ -85,6 +86,7 @@ public class EntityImagePort extends AbstractEntityImageBorder {
} }
public double getMaxWidthFromLabelForEntryExit(StringBounder stringBounder) { public double getMaxWidthFromLabelForEntryExit(StringBounder stringBounder) {
final TextBlock desc = getDesc();
final XDimension2D dimDesc = desc.calculateDimension(stringBounder); final XDimension2D dimDesc = desc.calculateDimension(stringBounder);
return dimDesc.getWidth(); return dimDesc.getWidth();
} }
@ -95,6 +97,7 @@ public class EntityImagePort extends AbstractEntityImageBorder {
} }
final public void drawU(UGraphic ug) { final public void drawU(UGraphic ug) {
final TextBlock desc = getDesc();
double y = 0; double y = 0;
final XDimension2D dimDesc = desc.calculateDimension(ug.getStringBounder()); final XDimension2D dimDesc = desc.calculateDimension(ug.getStringBounder());
final double x = 0 - (dimDesc.getWidth() - 2 * EntityPosition.RADIUS) / 2; 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))); 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 backcolor = getEntity().getColors().getColor(ColorType.BACK);
HColor borderColor = getEntity().getColors().getColor(ColorType.LINE); HColor borderColor = getEntity().getColors().getColor(ColorType.LINE);

View File

@ -42,6 +42,7 @@ import net.sourceforge.plantuml.awt.geom.XPoint2D;
import net.sourceforge.plantuml.baraye.ILeaf; import net.sourceforge.plantuml.baraye.ILeaf;
import net.sourceforge.plantuml.cucadiagram.EntityPosition; import net.sourceforge.plantuml.cucadiagram.EntityPosition;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.ColorType;
import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.PName;
import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.SName;
@ -65,7 +66,8 @@ public class EntityImageStateBorder extends AbstractEntityImageBorder {
this.sname = sname; this.sname = sname;
} }
private StyleSignatureBasic getSignature() { @Override
protected StyleSignatureBasic getSignature() {
return StyleSignatureBasic.of(SName.root, SName.element, sname); return StyleSignatureBasic.of(SName.root, SName.element, sname);
} }
@ -79,6 +81,7 @@ public class EntityImageStateBorder extends AbstractEntityImageBorder {
} }
final public void drawU(UGraphic ug) { final public void drawU(UGraphic ug) {
final TextBlock desc = getDesc();
double y = 0; double y = 0;
final XDimension2D dimDesc = desc.calculateDimension(ug.getStringBounder()); final XDimension2D dimDesc = desc.calculateDimension(ug.getStringBounder());
final double x = 0 - (dimDesc.getWidth() - 2 * EntityPosition.RADIUS) / 2; 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))); 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()); final HColor borderColor = style.value(PName.LineColor).asColor(getSkinParam().getIHtmlColorSet());
HColor backcolor = getEntity().getColors().getColor(ColorType.BACK); HColor backcolor = getEntity().getColors().getColor(ColorType.BACK);
if (backcolor == null) if (backcolor == null)
@ -104,11 +108,11 @@ public class EntityImageStateBorder extends AbstractEntityImageBorder {
private UStroke getUStroke() { private UStroke getUStroke() {
return new UStroke(1.5); return new UStroke(1.5);
} }
public double getMaxWidthFromLabelForEntryExit(StringBounder stringBounder) { public double getMaxWidthFromLabelForEntryExit(StringBounder stringBounder) {
final TextBlock desc = getDesc();
final XDimension2D dimDesc = desc.calculateDimension(stringBounder); final XDimension2D dimDesc = desc.calculateDimension(stringBounder);
return dimDesc.getWidth(); return dimDesc.getWidth();
} }
} }