spring-statemachine icon indicating copy to clipboard operation
spring-statemachine copied to clipboard

Output state diagram

Open naude-r opened this issue 10 years ago • 18 comments

I would be great to be able to generate a state diagram (dot format?) of the configured state machine. This would be useful for documentation purposes as well as seeing a graphical view of the state machine.

naude-r avatar May 29 '15 12:05 naude-r

Yes, I've been thinking about this also. Dot is prop a best bet to start experimenting with any kind of visualization.

jvalkeal avatar May 29 '15 14:05 jvalkeal

@jvalkeal how do you generate the current ascii diagram?

naude-r avatar Jun 01 '15 10:06 naude-r

@naude-r I'm using http://ditaa.sourceforge.net/. Had to compile it from trunk because current releases seem to be broken with some features.

jvalkeal avatar Jun 01 '15 11:06 jvalkeal

@jvalkeal Thank you. the samples can print an ascii diagram using the "print" command. it seems to work with:

@Qualifier("stateChartModel")

how is that processed?

can take a stab at provided Dot output.

naude-r avatar Jun 01 '15 11:06 naude-r

There's no magic on that stateChartModel. Content of those files are created as bean at https://github.com/spring-projects/spring-statemachine/blob/master/spring-statemachine-samples/src/main/java/demo/CommonConfiguration.java#L46.

Every sample has a statechartmodel.txt file on its classpath. You can then print content of that file and then I manually use ditaa to provide image png to be used in docs.

jvalkeal avatar Jun 01 '15 11:06 jvalkeal

:+1: for this feature request. However, state machine [web]designer (which I assume is on road-map) should cover this as well. Great competitor to .NET Workflow :)

jvmlet avatar Aug 20 '15 06:08 jvmlet

I know this is not exactly it is what asked here, but I created a blog entry, instead having an Output State Diagram as a result artifact, using an UML Diagram to create a Spring State Machine configuration and making it a primary artifact for the project.

May be it can be useful for you, you can reach the blog from the link below.

https://mehmetsalgar.wordpress.com/2015/12/14/ajax-spring-web-flow-and-spring-state-machine/

mehmetsalgar avatar Dec 14 '15 11:12 mehmetsalgar

@mehmetsalgar wow, that is funky. Think I need to take a closer look over the holidays what those components can do. Thx for pointing out your blog :)

jvalkeal avatar Dec 16 '15 19:12 jvalkeal

I have started to program a little tool (https://github.com/WorkingDevelopers/spring-state-machine-chart-dumper) that dumps a state machine configuration to an Eclipse MDT UML2 model file (XML; same as used by UmlStateMachineModelFactory). The model file can when be imported into UML Designer or Papyrus. It is in an early stage, but maybe a starting point...

WorkingDevel avatar Sep 12 '16 20:09 WorkingDevel

@WorkingDevel didn't see your message here until now.

That is interesting work indeed. I've been thinking that as any config(javaconfig,uml,repository config) is first translated to pojo model(StateMachineModel) we could add feature to dump machine into these pojo's. Then you would not need to use reflection(which is always prone to errors if internals are changed).

One question, how pretty graph models these will produce? As a human it's always easy to draw these models so that graph doesn't look messy, but reversing that so that program does it automatically is, I assume, less ideal when graph is complex. Visualisation from a raw data is always hard!

jvalkeal avatar Oct 01 '16 09:10 jvalkeal

I started using Graphviz with guru.nidi - graphviz-java: But it works only with very simple state machines, no region support: https://gist.github.com/wolframite/78afb9b6891fe2815252d300020731dd

wolframite avatar Jul 07 '18 13:07 wolframite

I started using Graphviz with guru.nidi - graphviz-java: But it works only with very simple state machines, no region support: https://gist.github.com/wolframite/78afb9b6891fe2815252d300020731dd

@wolframite It seems a good alternative while this enhancement is being developed. Unfortunately the gist is not functional, there are some parts missing. Could you complete it please? Thanks a lot

jonybuzz avatar Nov 29 '18 14:11 jonybuzz

@jonybuzz You're right, I fixed it. Problem was that the visualization part looks different in my project, because I outsourced the whole state machine configuration into a JSON file with some customizations. Please try it again. It "works on my laptop"

wolframite avatar Nov 29 '18 22:11 wolframite

It has been a while since the last activity in this issue. Is there a solution to this? I wasn't (yet) able to find anything.

Any advice would be greatly appreciated.

michael-buerkle avatar Jul 14 '21 08:07 michael-buerkle

@jvalkeal i am not getting how the ascii diagram ie statechartmodel.txt is generated and from which part of the code. can ypu please attached the piece of code alog with logic for the same

agupta1009 avatar Aug 01 '23 07:08 agupta1009