choice for dot exporter as rectangles

This commit is contained in:
2025-07-15 16:46:44 +02:00
parent d6449a8de1
commit 1ee173a880

View File

@@ -15,7 +15,7 @@ public class Dot implements StateMachineExporter {
Set<String> startStates,
Set<String> endStates,
boolean useLambdaGuards) {
boolean includeChoiceStates = true;
StringBuilder sb = new StringBuilder();
sb.append("digraph stateMachine {\n");
sb.append(" rankdir=LR;\n");
@@ -54,7 +54,7 @@ public class Dot implements StateMachineExporter {
// Declare normal states
for (String state : allStates) {
if (!statesWithChoice.contains(state + "_choice")) {
if (!statesWithChoice.contains(includeChoiceStates ? state + "_choice" : state)) {
String shape = endStates.contains(state) ? "doublecircle" : "circle";
sb.append(" ").append(state)
.append(" [shape=").append(shape).append(", fillcolor=lightgray];\n");
@@ -63,7 +63,8 @@ public class Dot implements StateMachineExporter {
// Declare choice pseudostates
for (String state : statesWithChoice) {
sb.append(" ").append(state).append("_choice")
String choiceState = includeChoiceStates ? state + "_choice" : state;
sb.append(" ").append(choiceState)
.append(" [shape=diamond, label=\"\", fillcolor=lightyellow];\n");
}
@@ -76,12 +77,14 @@ public class Dot implements StateMachineExporter {
sb.append("\n");
// Connect normal states to their choice pseudostates
for (String state : statesWithChoice) {
sb.append(" ").append(state).append(" -> ").append(state).append("_choice;\n");
if (includeChoiceStates) {
// Connect normal states to their choice pseudostates
for (String state : statesWithChoice) {
sb.append(" ").append(state).append(" -> ").append(state).append("_choice;\n");
}
sb.append("\n");
}
sb.append("\n");
// Transitions
for (Transition t : transitions) {
@@ -106,7 +109,7 @@ public class Dot implements StateMachineExporter {
String edgeSource = source;
if ("withChoice".equals(t.getType()) && statesWithChoice.contains(source)) {
edgeSource = source + "_choice";
edgeSource = includeChoiceStates ? source + "_choice" : source;
}
// Label: event [guard] / actions