1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-12-22 02:49:06 +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.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) {

View File

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

View File

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