From 38cb4811f779d4638fbde4bc2ec9b78ebc19f380 Mon Sep 17 00:00:00 2001 From: Dietrich Travkin Date: Mon, 24 Jul 2023 15:05:33 +0200 Subject: [PATCH] Fix calculating shield (margin) size for nodes that are targets of qualified associations (#1467) --- src/net/sourceforge/plantuml/abel/Link.java | 8 +++++++ .../sourceforge/plantuml/svek/SvekNode.java | 21 ++++++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/net/sourceforge/plantuml/abel/Link.java b/src/net/sourceforge/plantuml/abel/Link.java index bffd58234..468351a04 100644 --- a/src/net/sourceforge/plantuml/abel/Link.java +++ b/src/net/sourceforge/plantuml/abel/Link.java @@ -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(); + } } diff --git a/src/net/sourceforge/plantuml/svek/SvekNode.java b/src/net/sourceforge/plantuml/svek/SvekNode.java index 23ead13eb..722d7963c 100644 --- a/src/net/sourceforge/plantuml/svek/SvekNode.java +++ b/src/net/sourceforge/plantuml/svek/SvekNode.java @@ -5,12 +5,12 @@ * (C) Copyright 2009-2024, Arnaud Roques * * Project Info: https://plantuml.com - * + * * If you like this project or if you find it useful, you can support us at: - * + * * https://plantuml.com/patreon (only 1$ per month!) * https://plantuml.com/paypal - * + * * This file is part of PlantUML. * * PlantUML is free software; you can redistribute it and/or modify it @@ -31,7 +31,7 @@ * * Original Author: Arnaud Roques * - * + * */ package net.sourceforge.plantuml.svek; @@ -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() {