From 56a0006330b227cae5bf2dd379a66ebfa95ccc80 Mon Sep 17 00:00:00 2001 From: Skgland Date: Fri, 28 Jan 2022 12:30:16 +0100 Subject: [PATCH 1/5] fix spelling and make option text clearer --- .../cs/kieler/sccharts/ui/synthesis/TransitionSynthesis.xtend | 2 +- .../kieler/sccharts/ui/synthesis/hooks/HideAnnotationHook.xtend | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/TransitionSynthesis.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/TransitionSynthesis.xtend index 2f3985866e..f0e89e9cfe 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/TransitionSynthesis.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/TransitionSynthesis.xtend @@ -51,7 +51,7 @@ import static extension de.cau.cs.kieler.klighd.syntheses.DiagramSyntheses.* class TransitionSynthesis extends SubSynthesis { /** - * Immediate transition will be more likely drwn from left to right as long as there are no more than this threshold + * Immediate transition will be more likely drawn from left to right as long as there are no more than this threshold * number of other edges to flip to break a cycle. */ public static val IMMEDIATE_TRANSITION_DIRECTION_THRESHOLD = 6 diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/HideAnnotationHook.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/HideAnnotationHook.xtend index 27b83fccb5..9d7581a423 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/HideAnnotationHook.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/HideAnnotationHook.xtend @@ -48,7 +48,7 @@ class HideAnnotationHook extends SynthesisHook { public static final String HIDE_ANNOTATION_KEYWORD = "hide"; /** The related synthesis option */ - public static final SynthesisOption SHOW_HIDDEN_ELEMENTS = SynthesisOption.createCheckOption(HideAnnotationHook, "Hidden Elements (@Hide)", + public static final SynthesisOption SHOW_HIDDEN_ELEMENTS = SynthesisOption.createCheckOption(HideAnnotationHook, "Show Hidden Elements (@Hide)", false).setCategory(GeneralSynthesisOptions::APPEARANCE); override getDisplayedSynthesisOptions() { From f26a7352b2005176c9d4a033fb9bfc5c858d0e94 Mon Sep 17 00:00:00 2001 From: Skgland Date: Fri, 28 Jan 2022 12:30:29 +0100 Subject: [PATCH 2/5] add EdgeMergeHook --- ....sccharts.ui.synthesis.hooks.SynthesisHook | 1 + .../ui/synthesis/hooks/EdgeMergeHook.xtend | 100 ++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/EdgeMergeHook.xtend diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/META-INF/services/de.cau.cs.kieler.sccharts.ui.synthesis.hooks.SynthesisHook b/plugins/de.cau.cs.kieler.sccharts.ui/META-INF/services/de.cau.cs.kieler.sccharts.ui.synthesis.hooks.SynthesisHook index 6b3b1e3c7c..7409f7eb26 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/META-INF/services/de.cau.cs.kieler.sccharts.ui.synthesis.hooks.SynthesisHook +++ b/plugins/de.cau.cs.kieler.sccharts.ui/META-INF/services/de.cau.cs.kieler.sccharts.ui.synthesis.hooks.SynthesisHook @@ -1,4 +1,5 @@ de.cau.cs.kieler.sccharts.ui.synthesis.hooks.DeclarationsHook +de.cau.cs.kieler.sccharts.ui.synthesis.hooks.EdgeMergeHook de.cau.cs.kieler.sccharts.ui.synthesis.hooks.LocalDeclarationsHook de.cau.cs.kieler.sccharts.ui.synthesis.hooks.StateActionsHook de.cau.cs.kieler.sccharts.ui.synthesis.hooks.BlackWhiteModeHook diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/EdgeMergeHook.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/EdgeMergeHook.xtend new file mode 100644 index 0000000000..033f760e5b --- /dev/null +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/EdgeMergeHook.xtend @@ -0,0 +1,100 @@ +/* + * KIELER - Kiel Integrated Environment for Layout Eclipse RichClient + * + * http://www.informatik.uni-kiel.de/rtsys/kieler/ + * + * Copyright 2021,2022 by + * + Kiel University + * + Department of Computer Science + * + Real-Time and Embedded Systems Group + * + * This code is provided under the terms of the Eclipse Public License (EPL). + * See the file epl-v10.html for the license text. + */ +package de.cau.cs.kieler.sccharts.ui.synthesis.hooks + +import de.cau.cs.kieler.klighd.krendering.ViewSynthesisShared +import de.cau.cs.kieler.sccharts.ui.synthesis.hooks.SynthesisHook +import de.cau.cs.kieler.klighd.kgraph.KNode +import de.cau.cs.kieler.sccharts.State +import de.cau.cs.kieler.klighd.kgraph.KEdge +import de.cau.cs.kieler.sccharts.Transition +import de.cau.cs.kieler.sccharts.Scope +import org.eclipse.xtend.lib.annotations.Data +import de.cau.cs.kieler.sccharts.PreemptionType +import de.cau.cs.kieler.sccharts.HistoryType +import de.cau.cs.kieler.sccharts.DeferredType +import java.util.HashMap +import de.cau.cs.kieler.sccharts.ui.synthesis.GeneralSynthesisOptions +import de.cau.cs.kieler.klighd.SynthesisOption +import de.cau.cs.kieler.sccharts.DelayType + +@ViewSynthesisShared +class EdgeMergeHook extends SynthesisHook { + + + /** The related synthesis option */ + public static final SynthesisOption MERGE_SIMILAR_EDGES = SynthesisOption.createCheckOption(EdgeMergeHook, "Merge Similar Edges", + false).setCategory(GeneralSynthesisOptions::APPEARANCE); + + override getDisplayedSynthesisOptions() { + return newLinkedList(de.cau.cs.kieler.sccharts.ui.synthesis.hooks.EdgeMergeHook.MERGE_SIMILAR_EDGES) + } + + HashMap map = new HashMap(); + + @Data + static class EdgeGroupKey { + State source; + State target; + PreemptionType preemption; + HistoryType history; + DeferredType deferred; + DelayType delay; + boolean deterministic; + } + + /** + * Invoked before the translation of the model starts. + * @param scopethe input model + * @param nodethe empty diagram root node + */ + override void start(Scope scope, KNode node) { + map.clear() + } + + /** + * Invoked after a {@link Transition} is translated. + * @param transitionthe transition + * @param edgethe translated edge + */ + override void processTransition(Transition transition, KEdge edge) { + + if (MERGE_SIMILAR_EDGES.booleanValue) { + + var key = new EdgeGroupKey( + transition.sourceState, + transition.targetState, + transition.preemption, + transition.history, + transition.deferred, + transition.delay, + transition.isNondeterministic + ); + + + val rep = map.computeIfAbsent(key, [EdgeGroupKey _key | edge]); + + if (edge != rep) { + rep.labels.addAll(edge.labels) + for (label : edge.labels) { + label.parent = rep + } + edge.source.outgoingEdges.remove(edge) + edge.target.outgoingEdges.remove(edge) + } + + } + } + +} From e830dd85bccf49bb3c69f4d1c5bd5f9b78cef99f Mon Sep 17 00:00:00 2001 From: Skgland Date: Thu, 17 Feb 2022 18:03:21 +0100 Subject: [PATCH 3/5] add comments for the edge merge hook --- .../ui/synthesis/hooks/EdgeMergeHook.xtend | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/EdgeMergeHook.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/EdgeMergeHook.xtend index 033f760e5b..d2ef41e212 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/EdgeMergeHook.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/EdgeMergeHook.xtend @@ -41,8 +41,14 @@ class EdgeMergeHook extends SynthesisHook { return newLinkedList(de.cau.cs.kieler.sccharts.ui.synthesis.hooks.EdgeMergeHook.MERGE_SIMILAR_EDGES) } + /** + * a mapping of an edge group key to the representative edge for that group + */ HashMap map = new HashMap(); + /** + * A Key used to determine if two transitions are semantically similar to be represented by one edge + */ @Data static class EdgeGroupKey { State source; @@ -60,6 +66,7 @@ class EdgeMergeHook extends SynthesisHook { * @param nodethe empty diagram root node */ override void start(Scope scope, KNode node) { + // reset the map of representative edges as we start a new synthesis map.clear() } @@ -72,6 +79,8 @@ class EdgeMergeHook extends SynthesisHook { if (MERGE_SIMILAR_EDGES.booleanValue) { + // build the transitions key to find the representing edge + // or insert the current edge if no edge was already chosen var key = new EdgeGroupKey( transition.sourceState, transition.targetState, @@ -82,14 +91,17 @@ class EdgeMergeHook extends SynthesisHook { transition.isNondeterministic ); - + // if we do not already have a representative use the current edge as the representative val rep = map.computeIfAbsent(key, [EdgeGroupKey _key | edge]); if (edge != rep) { + // if this was not just chosen as the representative transfer all edge labels to the representative rep.labels.addAll(edge.labels) for (label : edge.labels) { + // adjust the transfered labels parent label.parent = rep } + // remove the current edge from the graph, as it will be represented by the representative edge edge.source.outgoingEdges.remove(edge) edge.target.outgoingEdges.remove(edge) } From a4ce7ed27637cf1bb5722aa8151fb0c0a5ba23fa Mon Sep 17 00:00:00 2001 From: Skgland Date: Thu, 17 Feb 2022 18:08:25 +0100 Subject: [PATCH 4/5] undo display name change of hide annotation synthesis hook --- .../kieler/sccharts/ui/synthesis/hooks/HideAnnotationHook.xtend | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/HideAnnotationHook.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/HideAnnotationHook.xtend index 9d7581a423..27b83fccb5 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/HideAnnotationHook.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/HideAnnotationHook.xtend @@ -48,7 +48,7 @@ class HideAnnotationHook extends SynthesisHook { public static final String HIDE_ANNOTATION_KEYWORD = "hide"; /** The related synthesis option */ - public static final SynthesisOption SHOW_HIDDEN_ELEMENTS = SynthesisOption.createCheckOption(HideAnnotationHook, "Show Hidden Elements (@Hide)", + public static final SynthesisOption SHOW_HIDDEN_ELEMENTS = SynthesisOption.createCheckOption(HideAnnotationHook, "Hidden Elements (@Hide)", false).setCategory(GeneralSynthesisOptions::APPEARANCE); override getDisplayedSynthesisOptions() { From 23071bf3b5c2a711d5747261f3fa9c7e7e9fa111 Mon Sep 17 00:00:00 2001 From: Skgland Date: Sun, 20 Mar 2022 19:44:49 +0100 Subject: [PATCH 5/5] add a doc comment to the class --- .../cs/kieler/sccharts/ui/synthesis/hooks/EdgeMergeHook.xtend | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/EdgeMergeHook.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/EdgeMergeHook.xtend index d2ef41e212..5c836ca869 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/EdgeMergeHook.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/EdgeMergeHook.xtend @@ -29,6 +29,9 @@ import de.cau.cs.kieler.sccharts.ui.synthesis.GeneralSynthesisOptions import de.cau.cs.kieler.klighd.SynthesisOption import de.cau.cs.kieler.sccharts.DelayType +/** + * Merge transitions that are considered semantically similar to be visualized using one edge. + */ @ViewSynthesisShared class EdgeMergeHook extends SynthesisHook {