From 8ab89d5aa91082643305ab709f4f245e07a39eaf Mon Sep 17 00:00:00 2001 From: Niklas Rentz Date: Fri, 5 Apr 2024 11:07:56 +0200 Subject: [PATCH] lsp: fix an issue when recursing through non-expanded nodes in the micro layout calculation. --- .../klighd/lsp/utils/RenderingPreparer.xtend | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/utils/RenderingPreparer.xtend b/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/utils/RenderingPreparer.xtend index b52bd17f5..f9f40135d 100644 --- a/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/utils/RenderingPreparer.xtend +++ b/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/utils/RenderingPreparer.xtend @@ -3,7 +3,7 @@ * * http://rtsys.informatik.uni-kiel.de/kieler * - * Copyright 2018-2023 by + * Copyright 2018-2024 by * + Kiel University * + Department of Computer Science * + Real-Time and Embedded Systems Group @@ -46,6 +46,7 @@ import de.cau.cs.kieler.klighd.microlayout.DecoratorPlacementUtil.Decoration import de.cau.cs.kieler.klighd.microlayout.GridPlacementUtil import de.cau.cs.kieler.klighd.microlayout.PlacementUtil import de.cau.cs.kieler.klighd.util.KlighdProperties +import de.cau.cs.kieler.klighd.util.RenderingContextData import java.awt.geom.Point2D import java.util.ArrayList import java.util.HashMap @@ -124,8 +125,21 @@ final class RenderingPreparer { } } if (element instanceof KNode) { - for (node : element.children) { - prepareRendering(node, kGraphToSGraph) + // Do not recurse generating IDs if the element is not expanded, as there won't be any SGraph generated for + // it. + var boolean isExpanded + val renderingContextData = RenderingContextData.get(element) + if (renderingContextData.hasProperty(SprottyProperties.EXPANDED)) { + isExpanded = renderingContextData.getProperty(SprottyProperties.EXPANDED) + } else { + // If the expanded property does not exist yet, use the initial expansion. + isExpanded = element.getProperty(KlighdProperties.EXPAND) + } + + if (isExpanded) { + for (node : element.children) { + prepareRendering(node, kGraphToSGraph) + } } for (edge : element.outgoingEdges) { prepareRendering(edge, kGraphToSGraph)