Deutsch      Español      Français      日本語      한국어      Русский      中文

Translation support

You can click here to access the wiki and update the translation.

You can go back to the translated webpage.

To help you in the translation process, here is a comparison with the English version :

État syntaxe de diagramme et caractéristiques

PlantUML syntaxe de diagramme d'état: Vous pouvez avoir l'état simple, état composite, état concurrent, relation, notes ... Changer les polices et les couleurs est également possible.

State Diagram syntax and features

PlantUML state diagram syntax: You can have simple state, composite state, concurrent state, relationship, notes... Changing fonts and colors is also possible.

 

 

Diagrammes d'état

 

 

State Diagram

State diagrams are used to give an abstract description of the behavior of a system. This behavior is represented as a series of events that can occur in one or more possible states.

 

 

Exemple simple

Vous devez utiliser [*] 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

 

 

Simple State

You can use [*] for the starting point and ending point of the state diagram.

Use --> for arrows.

@startuml

[*] --> State1
State1 --> [*]
State1 : this is a string
State1 : this is another string

State1 -> State2
State2 --> [*]

@enduml

 

 

Change state rendering

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

 

 

Change state rendering

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

 

 

Etat composite

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

 

 

Composite state

A state can also be composite. You have to define it using the state keywords and brackets.

@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

 

 

Nom long

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

 

 

Long name

You can also use the state keyword to use long description for states.

@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

 

 

Etat concurrent

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

 

 

Fork

You can also fork and join using the <<fork>> and <<join>> stereotypes.

@startuml

state fork_state <<fork>>
[*] --> fork_state
fork_state --> State2
fork_state --> State3

state join_state <<join>>
State2 --> join_state
State3 --> join_state
join_state --> State4
State4 --> [*]

@enduml

 

 

Direction des flèches

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
Vous pouvez aussi utiliser une notation abrégée, avec soit le premier caractère de la direction (par exemple -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.

 

 

Concurrent state

You can define concurrent state into a composite state using either -- or || symbol as separator.

@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

 

 

Note

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

 

 

Arrow direction

You can use -> for horizontal arrows. It is possible to force arrow's direction using the following syntax:

  • -down-> (default arrow)
  • -right-> or ->
  • -left->
  • -up->

@startuml

[*] -up-> First
First -right-> Second
Second --> Third
Third -left-> Last

@enduml
You can shorten the arrow by using only the first character of the direction (for example, -d- instead of -down-) or the two first characters (-do-).

Please note that you should not abuse this functionality : Graphviz gives usually good results without tweaking.

 

 

Plus de notes

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

 

 

Note

You can also define notes using note left of, note right of, note top of, note bottom of keywords.

You can also define notes on several lines.

@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

You can also have floating notes.

@startuml

state foo
note "This is a floating note" as N1

@enduml

 

 

Skinparam

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

 

 

More in notes

You can put notes on composite states.

@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

 

 

Skinparam

You can use the skinparam command to change colors and fonts for the drawing.

You can use this command :

You can define specific color and fonts for stereotyped states.

@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

This page is generated once per day from the wiki content.