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