1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-12-22 02:49:06 +00:00

Fix calculating shield (margin) size for nodes that are targets of qualified associations (#1467)

This commit is contained in:
Dietrich Travkin 2023-07-24 15:05:33 +02:00
parent d7efa7e9a2
commit 38cb4811f7
2 changed files with 24 additions and 5 deletions

View File

@ -59,6 +59,7 @@ import net.sourceforge.plantuml.style.ISkinSimple;
import net.sourceforge.plantuml.style.StyleBuilder;
import net.sourceforge.plantuml.svek.Bibliotekon;
import net.sourceforge.plantuml.url.Url;
import net.sourceforge.plantuml.utils.Direction;
import net.sourceforge.plantuml.utils.LineLocation;
public class Link extends WithLinkType implements Hideable, Removeable {
@ -541,4 +542,11 @@ public class Link extends WithLinkType implements Hideable, Removeable {
return opale;
}
public final boolean hasKal1() {
return this.linkArg.getKal1() != null && !this.linkArg.getKal1().isEmpty();
}
public final boolean hasKal2() {
return this.linkArg.getKal2() != null && !this.linkArg.getKal2().isEmpty();
}
}

View File

@ -381,7 +381,18 @@ public class SvekNode implements Positionable, Hideable {
}
public boolean isShielded() {
return shield().isZero() == false;
if (this.shield != null) {
return this.shield.isZero() == false;
}
// Avoid calculating "shield" size through this.shield() before finishing creation of all SvekLines (#1467)
// Instead, only check if we will have a shield (size is irrelevant here)
// This node will have a shield if it is target of a qualified association (will have a qualifier label
// placed besides this type's bounding box.)
return this.leaf.getDiagram().getLinks().stream()
.filter(link -> link.getEntity1() == this.leaf || link.getEntity2() == this.leaf)
.anyMatch(link -> (this.leaf == link.getEntity1() && link.hasKal1())
|| (this.leaf == link.getEntity2() && link.hasKal2()));
}
public void resetMoveSvek() {