[*]
pour le début et la fin du diagramme d'état. Utilisez -->
pour les flèches.
@startuml
[*] --> State1
State1 --> [*]
State1 : this is a string
State1 : this is another string
State1 -> State2
State2 --> [*]
@enduml
You can use hide empty description
to render state as simple box.
@startuml
hide empty description
[*] --> State1
State1 --> [*]
State1 : this is a string
State1 : this is another string
State1 -> State2
State2 --> [*]
@enduml
Un état peut également être composite. Vous devez alors le définir avec le mot-clé state
et des accolades.
@startuml
scale 350 width
[*] --> NotShooting
state NotShooting {
[*] --> Idle
Idle --> Configuring : EvConfig
Configuring --> Idle : EvConfig
}
state Configuring {
[*] --> NewValueSelection
NewValueSelection --> NewValuePreview : EvNewValue
NewValuePreview --> NewValueSelection : EvNewValueRejected
NewValuePreview --> NewValueSelection : EvNewValueSaved
state NewValuePreview {
State1 -> State2
}
}
@enduml
Vous pouvez aussi utiliser le mot-clé state
pour donner un nom avec des espaces à un état.
@startuml
scale 600 width
[*] -> State1
State1 --> State2 : Succeeded
State1 --> [*] : Aborted
State2 --> State3 : Succeeded
State2 --> [*] : Aborted
state State3 {
state "Accumulate Enough Data\nLong State Name" as long1
long1 : Just a test
[*] --> long1
long1 --> long1 : New Data
long1 --> ProcessData : Enough Data
}
State3 --> State3 : Failed
State3 --> [*] : Succeeded / Save Result
State3 --> [*] : Aborted
@enduml
Vous pouvez définir un état concurrent dans un état composé en utilisant le symbole --
ou ||
comme séparateur.
@startuml
[*] --> Active
state Active {
[*] -> NumLockOff
NumLockOff --> NumLockOn : EvNumLockPressed
NumLockOn --> NumLockOff : EvNumLockPressed
--
[*] -> CapsLockOff
CapsLockOff --> CapsLockOn : EvCapsLockPressed
CapsLockOn --> CapsLockOff : EvCapsLockPressed
--
[*] -> ScrollLockOff
ScrollLockOff --> ScrollLockOn : EvCapsLockPressed
ScrollLockOn --> ScrollLockOff : EvCapsLockPressed
}
@enduml
Vous pouvez utiliser ->
pour les flèches horizontales. Il est aussi possible de forcer la direction de la flèche avec la syntaxe suivante:
-down->
(default arrow)-right->
or ->
-left->
-up->
@startuml
[*] -up-> First
First -right-> Second
Second --> Third
Third -left-> Last
@enduml
-d-
à la place de -down-
) ou bien les deux premiers caractères (-do-
). Veuillez noter qu'il ne faut pas abuser de cette fonction : Graphviz donne généralement de bons résultats sans peaufinage.
Vous pouvez définir des notes avec les mots clés suivant: note left of
, note right of
, note top of
, note bottom of
Vous pouvez aussi définir des notes sur plusieurs lignes.
@startuml
[*] --> Active
Active --> Inactive
note left of Active : this is a short\nnote
note right of Inactive
A note can also
be defined on
several lines
end note
@enduml
Vous pouvez aussi avoir des notes flottantes.
@startuml
state foo
note "This is a floating note" as N1
@enduml
Vous pouvez mettre des notes sur les états de composite
@startuml
[*] --> NotShooting
state "Not Shooting State" as NotShooting {
state "Idle mode" as Idle
state "Configuring mode" as Configuring
[*] --> Idle
Idle --> Configuring : EvConfig
Configuring --> Idle : EvConfig
}
note right of NotShooting : This is a note on a composite state
@enduml
Utilisez la commande skinparam
pour changer la couleur et la mise en forme du texte du schéma.
Vous pouvez utiliser cette commande :
Vous pouvez définir une couleur spécifique et une police d'écriture pour les états stéréotypés.
@startuml
skinparam backgroundColor LightYellow
skinparam state {
StartColor MediumBlue
EndColor Red
BackgroundColor Peru
BackgroundColor<<Warning>> Olive
BorderColor Gray
FontName Impact
}
[*] --> NotShooting
state "Not Shooting State" as NotShooting {
state "Idle mode" as Idle <<Warning>>
state "Configuring mode" as Configuring
[*] --> Idle
Idle --> Configuring : EvConfig
Configuring --> Idle : EvConfig
}
NotShooting --> [*]
@enduml