From 35f5c0249b47d9ee0c74ed78b4d7e7986fb5af15 Mon Sep 17 00:00:00 2001 From: Alexander Schulz-Rosengarten Date: Mon, 14 Mar 2022 13:51:41 +0100 Subject: [PATCH] diagrams: Fixed bundle dependencies option for reactions This was lost in the conversion from xtend to java --- .../synthesis/LinguaFrancaSynthesis.java | 57 +++++++++++-------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/org.lflang.diagram/src/org/lflang/diagram/synthesis/LinguaFrancaSynthesis.java b/org.lflang.diagram/src/org/lflang/diagram/synthesis/LinguaFrancaSynthesis.java index 32f9a5bcbd..bee0a3c512 100644 --- a/org.lflang.diagram/src/org/lflang/diagram/synthesis/LinguaFrancaSynthesis.java +++ b/org.lflang.diagram/src/org/lflang/diagram/synthesis/LinguaFrancaSynthesis.java @@ -722,14 +722,18 @@ private Collection transformReactorNetwork( // connect input KPort port = null; for (TriggerInstance trigger : reaction.triggers) { - port = addInvisiblePort(node); - setLayoutOption(port, CoreOptions.PORT_SIDE, PortSide.WEST); - int triggersSize = reaction.triggers != null ? reaction.triggers.size() : 0; - int sourcesSize = reaction.sources != null ? reaction.sources.size() : 0; - if (getBooleanValue(REACTIONS_USE_HYPEREDGES) || triggersSize + sourcesSize == 1) { - // manual adjustment disabling automatic one - setLayoutOption(port, CoreOptions.PORT_BORDER_OFFSET, - (double) -LinguaFrancaShapeExtensions.REACTION_POINTINESS); + // Create new port if there is no previous one or each dependency should have its own one + if (port == null || !getBooleanValue(REACTIONS_USE_HYPEREDGES)) { + port = addInvisiblePort(node); + setLayoutOption(port, CoreOptions.PORT_SIDE, PortSide.WEST); + + int triggersSize = reaction.triggers != null ? reaction.triggers.size() : 0; + int sourcesSize = reaction.sources != null ? reaction.sources.size() : 0; + if (getBooleanValue(REACTIONS_USE_HYPEREDGES) || triggersSize + sourcesSize == 1) { + // manual adjustment disabling automatic one + setLayoutOption(port, CoreOptions.PORT_BORDER_OFFSET, + (double) -LinguaFrancaShapeExtensions.REACTION_POINTINESS); + } } if (trigger.isStartup()) { @@ -764,20 +768,22 @@ private Collection transformReactorNetwork( } // connect dependencies - //port = null // create new ports for (TriggerInstance dep : reaction.sources) { - if (reaction.triggers.contains(dep)) continue; - if (!(getBooleanValue(REACTIONS_USE_HYPEREDGES) && port != null)) { - port = addInvisiblePort(node); - setLayoutOption(port, CoreOptions.PORT_SIDE, PortSide.WEST); - int triggersSize = reaction.triggers != null ? reaction.triggers.size() : 0; - int sourcesSize = reaction.sources != null ? reaction.sources.size() : 0; - if (getBooleanValue(REACTIONS_USE_HYPEREDGES) || triggersSize + sourcesSize == 1) { - // manual adjustment disabling automatic one - setLayoutOption(port, CoreOptions.PORT_BORDER_OFFSET, - (double) -LinguaFrancaShapeExtensions.REACTION_POINTINESS); - } - } + if (reaction.triggers.contains(dep)) continue; // skip + + // Create new port if there is no previous one or each dependency should have its own one + if (port == null || !getBooleanValue(REACTIONS_USE_HYPEREDGES)) { + port = addInvisiblePort(node); + setLayoutOption(port, CoreOptions.PORT_SIDE, PortSide.WEST); + + int triggersSize = reaction.triggers != null ? reaction.triggers.size() : 0; + int sourcesSize = reaction.sources != null ? reaction.sources.size() : 0; + if (getBooleanValue(REACTIONS_USE_HYPEREDGES) || triggersSize + sourcesSize == 1) { + // manual adjustment disabling automatic one + setLayoutOption(port, CoreOptions.PORT_BORDER_OFFSET, + (double) -LinguaFrancaShapeExtensions.REACTION_POINTINESS); + } + } if (dep instanceof PortInstance) { KPort src = null; @@ -794,11 +800,14 @@ private Collection transformReactorNetwork( } // connect outputs - port = null; // create new ports + port = null; // enforce new ports for outputs Set> iterSet = reaction.effects != null ? reaction.effects : new HashSet<>(); for (TriggerInstance effect : iterSet) { - port = addInvisiblePort(node); - setLayoutOption(port, CoreOptions.PORT_SIDE, PortSide.EAST); + // Create new port if there is no previous one or each dependency should have its own one + if (port == null || !getBooleanValue(REACTIONS_USE_HYPEREDGES)) { + port = addInvisiblePort(node); + setLayoutOption(port, CoreOptions.PORT_SIDE, PortSide.EAST); + } if (effect instanceof ActionInstance) { actionSources.put((ActionInstance) effect, port);