Spring State Machine Chart Exporter
This package write a state chart file based on information probed. at runtime, from a Spring State Machine/
Current exports include
- PlantUML state charts
- SCXML states and transitions
- Lucid Chart CSV file via File / Import Data / Process File
This was created to find errors when setting up the state machine. It is very easy to make a mistake, forget or connect the incorrect states.
It may also be useful for those that code first and document later.
Maven Setup
<dependency>
<groupId>com.nofacepress</groupId>
<artifactId>spring-statemachine-chart-exporter</artifactId>
<version>0.3.1</version>
</dependency>
Getting started
Using it is easy.
// PlantUML
StateMachinePlantUMLExporter.export(machine, "MY State Machine", "statemachine.plantuml");
// SCXML
StateMachineSCXMLExporter.export(machine, "statemachine.scxml");
// Lucid Chart
StateMachineLucidChartExporter.export(machine, "State Machine", "statemachine-lucid.csv");
See the test state machine setup in src/test for a full working demo.
Official Source Repository
Release Notes
Arranging charts in PlantUML
PlantUML does not currently have an option to auto-arrange the charts. In fact, the specification requires the arrows specify the direction. This is a difficult problem to solve, especially for such a tiny project.
The strategy is to plot states downward and when a node has more than one connection rotate from down, to right, to left, ... The downward precedence goes to the state with the longest path. It is simple but it works pretty well. In any event, the result is a text file which a human can tweak if needed.