6

With PlantUML I've created a little state chart for my documentation:

@startuml

state Powered {
    [*]      -d->    Starting
    Powered  -r->    Starting : Some error
    Starting -d->    Operational
}
[*]     -d->   Powered  : Power On
Powered -u->   [*]      : Power Off
Powered -d->   Powered  : Reset

@enduml

(btw: PlantUML is a very nice tool to create graphical output from a textual description embedded embedded markup documents like asciidoc or reStructuredText)

This is what the given state diagram is rendered to: enter image description here

As you can see the chart is drawn a bit sloppy

  • the "Power Off" transition arrow is not straight
  • the Initial/End state are swapped
  • the arrow from "Powered" to "Starting" looks like it's somehow connected to the "Power Off" transition
  • The "Starting" and "Operational" state are not aligned

As the documentation describes you have some influence on the arrow direction by writing -left-> or -l-> for short rather than just -->.

Is there a way to to influence the way how and where arrows are drawn? I'd really like to have only horizontal or vertical straight lines being drawn.

frans
  • 8,868
  • 11
  • 58
  • 132

2 Answers2

21

To answer the original question for future readers:

In order to have only horizontal or vertical straight lines drawn, you can use skinparam linetype ortho.

In order to make all lines straight (but not necessarily horizontal or vertical) you can use skinparam linetype polyline.

(source)

gebi
  • 585
  • 4
  • 11
5

PlantUML has not been designed to provide nice straight arrows when many directions are imposed. Using default layout provides cleanest and most readable result to me.

Here is an example with the same meaning, but without layout issues:

@startuml

state Powered {
  [*] --> Starting
  Starting --> Operational
}
[*] --> Powered : Power On
Powered --> [*] : Power Off
Powered --> Powered : Reset
Powered --> Powered : Fatal Error

@enduml

enter image description here

EDIT: I also changed your Powered --> Starting : Fatal Error transition to : Powered --> Powered : Fatal Error, which better expresses that from any state within Powered, a Fatal Error event will restart at the Starting substate.

Alternatively the two statements:

Powered --> Powered : Reset
Powered --> Powered : Fatal Error

can be merged in:

Powered --> Powered : Reset, Fatal Error

see OMG UML 2.5 format specification section 14.2.4.9 page 329

[<trigger> [‘,’ <trigger>]* [‘[‘ <guard>’]’] [‘/’ <behavior-expression>]]
PaulH
  • 2,918
  • 2
  • 15
  • 31
  • Maybe I just did not see the point yet but to me it looks like you just simplify the model to avoid the described problem. In my case I need the `Powered --> Starting` transition because it tells me that from *any* state contained in "Powered" I can enter "Starting" again (e.g. by an error). So +1 for the working example but I doubt this approach works for more complex models. – frans Jun 22 '16 at 12:56
  • @frans I adapted my answer to include the Fatal Error treatment. – PaulH Jun 22 '16 at 14:44
  • 1
    You may consider using Umple. See this example: http://cruise.eecs.uottawa.ca/umpleonline/?example=manualexamples/NestedStateMachines2&diagramtype=state – PaulH Jun 22 '16 at 17:00