Le symbole -> est utilisé pour dessiner un message entre deux participants. Les participants n'ont pas besoin d'être explicitement déclarés. Pour avoir une flèche en pointillée, il faut utiliser -->. Il est aussi possible d'utiliser <- et <--. Cela ne change pas le dessin, mais cela peut améliorer la lisibilité du texte source. Ceci est uniquement vrai pour les diagrammes de séquences, les règles sont différentes pour les autres diagrammes.
@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
Alice -> Bob: Another authentication Request
Alice <-- Bob: another authentication Response
@enduml
Déclaration de participants
Il est possible de changer l'ordre des participants à l'aide du mot clé participant. Il est aussi possible d'utiliser d'autres mot-clés pour déclarer un participant :
actor
boundary
control
entity
database
collections
@startuml
actor Foo1
boundary Foo2
control Foo3
entity Foo4
database Foo5
collections Foo6
Foo1 -> Foo2 : To boundary
Foo1 -> Foo3 : To control
Foo1 -> Foo4 : To entity
Foo1 -> Foo5 : To database
Foo1 -> Foo6 : To collections
@enduml
On peut aussi utiliser un nom court à l'aide grâce au mot-clé as. La couleur d'un acteur ou d'un participant peut être définie avec son code ou son nom HTML.
@startuml
actor Bob #red
' The only difference between actor
'and participant is the drawing
participant Alice
participant "I have a really\nlong name" as L #99FF99
/' You can also declare:
participant L as "I have a really\nlong name" #99FF99
'/
Alice->Bob: Authentication Request
Bob->Alice: Authentication Response
Bob->L: Log transaction
@enduml
Vous pouvez utiliser le mot-clé order pour modifier l'ordre des participants
@startuml
participant Last order 30
participant Middle order 20
participant First order 10
@enduml
WARNING
This translation need to be updated.
WARNING
Caractères non alphanumérique dans les participants
Si vous voulez mettre des charactères non alphanumériques, il est possible d'utiliser des guillemets. Et on peut utiliser le mot clé as pour définir un alias pour ces participants.
@startuml
Alice -> "Bob()" : Hello
"Bob()" -> "This is very\nlong" as Long
' You can also declare:
' "Bob()" -> Long as "This is very\nlong"
Long --> "Bob()" : ok
@enduml
Message à soi-même
Un participant peut très bien s'envoyer un message. Il est possible de mettre un message sur plusieurs lignes grâce à \n.
@startuml
Alice->Alice: This is a signal to self.\nIt also demonstrates\nmultiline \ntext
@enduml
Text alignment
Text of response message below the arrow
You can put the text of the response message below the arrow, with the skinparam responseMessageBelowArrow true command.
@startuml
skinparam responseMessageBelowArrow true
Bob -> Alice : hello
Alice -> Bob : ok
@enduml
Vous pouvez changer les flèches de plusieurs façons :
Pour indiquer un message perdu, terminer la flèche avec x
Utiliser \ ou / à la place de < ou > pour avoir seulement la partie supérieure ou inférieure de la flèche.
Doubler un des caractères (par exemple, >> ou //)pour avoir une flèche plus fine.
Utiliser -- à la place de - pour avoir des pointillés.
Utiliser "o" après la flèche
Utiliser une flèche bi-directionnelle <->
@startuml
Bob ->x Alice
Bob -> Alice
Bob ->> Alice
Bob -\ Alice
Bob \\- Alice
Bob //-- Alice
Bob ->o Alice
Bob o\\-- Alice
Bob <-> Alice
Bob <->o Alice
@enduml
Changer la couleur des flèches
Changer la couleur d'une flèche ainsi:
@startuml
Bob -[#red]> Alice : hello
Alice -[#0000FF]->Bob : ok
@enduml
Numérotation automatique des messages
Le mot clé autonumber est utilisé pour ajouter automatiquement des numéros aux messages.
@startuml
autonumber
Bob -> Alice : Authentication Request
Bob <- Alice : Authentication Response
@enduml
Spécifier le numéro de départ avec autonumber //start// , et l'incrément avec autonumber //start// //increment//.
@startuml
autonumber
Bob -> Alice : Authentication Request
Bob <- Alice : Authentication Response
autonumber 15
Bob -> Alice : Another authentication Request
Bob <- Alice : Another authentication Response
autonumber 40 10
Bob -> Alice : Yet another authentication Request
Bob <- Alice : Yet another authentication Response
@enduml
Spécifier le format d'un nombre entre guillemets anglais. Le formatage est fait par la classe DecimalFormat (0 signifie un chiffre, # signifie un chiffre ou zéro si absent). Des balises HTML sont permises dans le format.
@startuml
autonumber "<b>[000]"
Bob -> Alice : Authentication Request
Bob <- Alice : Authentication Response
autonumber 15 "<b>(<u>##</u>)"
Bob -> Alice : Another authentication Request
Bob <- Alice : Another authentication Response
autonumber 40 10 "<font color=red><b>Message 0 "
Bob -> Alice : Yet another authentication Request
Bob <- Alice : Yet another authentication Response
@enduml
Vous pouvez utiliser autonumber //stop// et autonumber resume //increment// //format// pour respectivement arrêter et reprendre la numérotation automatique.
@startuml
autonumber 10 10 "<b>[000]"
Bob -> Alice : Authentication Request
Bob <- Alice : Authentication Response
autonumber stop
Bob -> Alice : dummy
autonumber resume "<font color=red><b>Message 0 "
Bob -> Alice : Yet another authentication Request
Bob <- Alice : Yet another authentication Response
autonumber stop
Bob -> Alice : dummy
autonumber resume 1 "<font color=blue><b>Message 0 "
Bob -> Alice : Yet another authentication Request
Bob <- Alice : Yet another authentication Response
@enduml
Page Title, Header and Footer
The title keyword is used to add a title to the page. Pages can display headers and footers using header and footer.
@startuml
header Page Header
footer Page %page% of %lastpage%
title Example Title
Alice -> Bob : message 1
Alice -> Bob : message 2
@enduml
Découper un diagramme
Le mot clé newpage est utilisé pour découper un digramme en plusieurs images. Vous pouvez mettre un titre pour la nouvelle page juste après le mot clé newpage. Ceci est très pratique pour mettre de très longs digrammes sur plusieurs pages.
@startuml
Alice -> Bob : message 1
Alice -> Bob : message 2
newpage
Alice -> Bob : message 3
Alice -> Bob : message 4
newpage A title for the\nlast page
Alice -> Bob : message 5
Alice -> Bob : message 6
@enduml
Regrouper les messages (cadres UML)
Il est possible de regrouper les messages dans un cadre UML à l'aide d'un des mot clés suivants:
alt/else
opt
loop
par
break
critical
group, suivi par le texte à afficher
Il est aussi possible de mettre un texte à afficher dans l'entête. Le mot-clé end est utiliser pour fermer le groupe. Il est aussi possible d'imbriquer les groupes. Terminer le cadre avec le mot-clé end. Il est possible d'imbriquer les cadres.
@startuml
Alice -> Bob: Authentication Request
alt successful case
Bob -> Alice: Authentication Accepted
else some kind of failure
Bob -> Alice: Authentication Failure
group My own label
Alice -> Log : Log attack start
loop 1000 times
Alice -> Bob: DNS Attack
end
Alice -> Log : Log attack end
end
else Another type of failure
Bob -> Alice: Please repeat
end
@enduml
WARNING
This translation need to be updated.
WARNING
Secondary group label
For group, it is possible to add, between[ and ], a secondary text or label that will be displayed into the header.
@startuml
Alice -> Bob: Authentication Request
Bob -> Alice: Authentication Failure
group My own label [My own label 2]
Alice -> Log : Log attack start
loop 1000 times
Alice -> Bob: DNS Attack
end
Alice -> Log : Log attack end
end
@enduml
Pour attacher une note à un message, utiliser les mots-clés note left (pour une note à gauche) ou note right (pour une note à droite) juste après le message. Il est possible d'avoir une note sur plusieurs lignes avec le mot clé end note.
@startuml
Alice->Bob : hello
note left: this is a first note
Bob->Alice : ok
note right: this is another note
Bob->Bob : I am thinking
note left
a note
can also be defined
on several lines
end note
@enduml
Encore plus de notes
Il est aussi possible de mettre des notes placées par rapport aux participants. Il est aussi possible de faire ressortir une note en changeant sa couleur de fond. On peut aussi avoir des notes sur plusieurs lignes à l'aide du mot clé end note.
@startuml
participant Alice
participant Bob
note left of Alice #aqua
This is displayed
left of Alice.
end note
note right of Alice: This is displayed right of Alice.
note over Alice: This is displayed over Alice.
note over Alice, Bob #FFAAAA: This is displayed\n over Bob and Alice.
note over Bob, Alice
This is yet another
example of
a long note.
end note
@enduml
Changer l'aspect des notes
Vous pouvez préciser la forme géométrique des notes. \n (rnote : rectangulaire, ou hnote : hexagonale)
@startuml
caller -> server : conReq
hnote over caller : idle
caller <- server : conConf
rnote over server
"r" as rectangle
"h" as hexagon
endrnote
@enduml
You can directly make a note over all participants, with the syntax:
note across: note_description
@startuml
Alice->Bob:m1
Bob->Charlie:m2
note over Alice, Charlie: Old method for note over all part. with:\n ""note over //FirstPart, LastPart//"".
note across: New method with:\n""note across""
Bob->Alice
hnote across:Note across all part.
@enduml
@startuml
participant Alice
participant "The **Famous** Bob" as Bob
Alice -> Bob : hello --there--
... Some ~~long delay~~ ...
Bob -> Alice : ok
note left
This is **bold**
This is //italics//
This is ""monospaced""
This is --stroked--
This is __underlined__
This is ~~waved~~
end note
Alice -> Bob : A //well formatted// message
note right of Alice
This is <back:cadetblue><size:18>displayed</size></back>
__left of__ Alice.
end note
note left of Bob
<u:red>This</u> is <color #118888>displayed</color>
**<color purple>left of</color> <s:red>Alice</strike> Bob**.
end note
note over Alice, Bob
<w:#FF33FF>This is hosted</w> by <img sourceforge.jpg>
end note
@enduml
Séparation
Si vous voulez, vous pouvez séparer le diagramme avec l'aide de "==" en étapes logiques.
@startuml
== Initialization ==
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
== Repetition ==
Alice -> Bob: Another authentication Request
Alice <-- Bob: another authentication Response
@enduml
WARNING
This translation need to be updated.
WARNING
Référence
Vous pouvez ajouter des références dans un diagramme, en utilisant le mot-clé ref over.
@startuml
participant Alice
actor Bob
ref over Alice, Bob : init
Alice -> Bob : hello
ref over Bob
This can be on
several lines
end ref
@enduml
Retard
Utiliser ... pour indiquer le passage de temps arbitraire dans le diagramme. Un message peut être associé à un retard.
@startuml
Alice -> Bob: Authentication Request
...
Bob --> Alice: Authentication Response
...5 minutes later...
Bob --> Alice: Bye !
@enduml
Text wrapping
To break long messages, you can manually add \n in your text. Another option is to use maxMessageSize setting:
@startuml
skinparam maxMessageSize 50
participant a
participant b
a -> b :this\nis\nmanually\ndone
a -> b :this is a very long message on several words
@enduml
Séparation verticale
Utiliser ||| pour créer un espace vertical dans le diagramme. Il est également possible de spécifier un nombre de pixels pour la séparation verticale.
@startuml
Alice -> Bob: message 1
Bob --> Alice: ok
|||
Alice -> Bob: message 2
Bob --> Alice: ok
||45||
Alice -> Bob: message 3
Bob --> Alice: ok
@enduml
Lignes de vie
Vous pouvez utiliser activate et deactivate pour marquer l'activation des participants. Une fois qu'un participant est activé, sa ligne de vie apparaît. Les ordres activate et deactivate s'applique sur le message situé juste avant. Le mot clé destroy sert à montrer la fin de vie d'un participant.
@startuml
participant User
User -> A: DoWork
activate A
A -> B: << createRequest >>
activate B
B -> C: DoWork
activate C
C --> B: WorkDone
destroy C
B --> A: RequestCreated
deactivate B
A -> User: Done
deactivate A
@enduml
Les lignes de vie peuvent être imbriquées, et il est possible de les colorer.
@startuml
participant User
User -> A: DoWork
activate A #FFBBBB
A -> A: Internal call
activate A #DarkSalmon
A -> B: << createRequest >>
activate B
B --> A: RequestCreated
deactivate B
deactivate A
A -> User: Done
deactivate A
@enduml
Return
A new command return for generating a return message with optional text label. The point returned to is the point that cause the most recently activated life-line. The syntax is simply return label where label, if provided, can be any string acceptable on conventional messages.
@startuml
Bob -> Alice : hello
activate Alice
Alice -> Alice : some action
return bye
@enduml
Création de participants.
Vous pouvez utiliser le mot clé create juste avant la première réception d'un message pour montrer que le message en question est une création d'un nouvelle objet.
@startuml
Bob -> Alice : hello
create Other
Alice -> Other : new
create control String
Alice -> String
note right : You can also put notes!
Alice --> Bob : ok
@enduml
Shortcut syntax for activation, deactivation, creation
Immediately after specifying the target participant, the following syntax can be used:
++ Activate the target (optionally a #color may follow this)
-- Deactivate the source
** Create an instance of the target
!! Destroy an instance of the target
@startuml
alice -> bob ++ : hello
bob -> bob ++ : self call
bob -> bib ++ #005500 : hello
bob -> george ** : create
return done
return rc
bob -> george !! : delete
return success
@enduml
Messages entrant et sortant
Vous pouvez utiliser des flèches qui viennent de la droite ou de la gauche pour dessiner un sous-diagramme. Il faut utiliser des crochets pour indiquer la gauche "[" ou la droite "]" du diagramme.
@startuml
[-> A: DoWork
activate A
A -> A: Internal call
activate A
A ->] : << createRequest >>
A<--] : RequestCreated
deactivate A
[<- A: Done
deactivate A
@enduml
Vous pouvez aussi utiliser la syntaxe suivante:
@startuml
[-> Bob
[o-> Bob
[o->o Bob
[x-> Bob
[<- Bob
[x<- Bob
Bob ->]
Bob ->o]
Bob o->o]
Bob ->x]
Bob <-]
Bob x<-]
@enduml
WARNING
This translation need to be updated.
WARNING
Short arrows for incoming and outgoing messages
You can have short arrows with using ?.
@startuml
?-> Alice : ""?->""\n**short** to actor1
[-> Alice : ""[->""\n**from start** to actor1
[-> Bob : ""[->""\n**from start** to actor2
?-> Bob : ""?->""\n**short** to actor2
Alice ->] : ""->]""\nfrom actor1 **to end**
Alice ->? : ""->?""\n**short** from actor1
Alice -> Bob : ""->"" \nfrom actor1 to actor2
@enduml
With teoz usage it is possible to add anchors to the diagram and use the anchors to specify duration time.
@startuml
!pragma teoz true
{start} Alice -> Bob : start doing things during duration
Bob -> Max : something
Max -> Bob : something else
{end} Bob -> Alice : finish
{start} <-> {end} : some time
@enduml
Stéréotypes et décoration
Il est possible de rajouter un stéréotype aux participants en utilisant "<<" et ">>". Dans le stéréotype, vous pouvez ajouter un caractère entouré d'un cercle coloré en utilisant la syntaxe (X,couleur).
@startuml
participant "Famous Bob" as Bob << Generated >>
participant Alice << (C,#ADD1B2) Testable >>
Bob->Alice: First message
@enduml
Par défaut, le caractère guillemet est utilisé pour afficher les stéréotypes. Vous pouvez changer ce comportement en utilisant la propriété skinparam guillemet:
@startuml
skinparam guillemet false
participant "Famous Bob" as Bob << Generated >>
participant Alice << (C,#ADD1B2) Testable >>
Bob->Alice: First message
@enduml
@startuml
participant Bob << (C,#ADD1B2) >>
participant Alice << (C,#ADD1B2) >>
Bob->Alice: First message
@enduml
@startuml
title __Simple__ **communication** example
Alice -> Bob: Authentication Request
Bob -> Alice: Authentication Response
@enduml
Vous pouvez mettre des retours à la ligne en utilisant \n dans la description.
@startuml
title __Simple__ communication example\non several lines
Alice -> Bob: Authentication Request
Bob -> Alice: Authentication Response
@enduml
Vous pouvez aussi mettre un titre sur plusieurs lignes à l'aide des mots-clé title et end title.
@startuml
title
<u>Simple</u> communication example
on <i>several</i> lines and using <font color=red>html</font>
This is hosted by <img:sourceforge.jpg>
end title
Alice -> Bob: Authentication Request
Bob -> Alice: Authentication Response
@enduml
Cadre pour les participants
Il est possible de dessiner un cadre autour de certains participants, en utilisant les commandes box et end box. Vous pouvez ajouter un titre ou bien une couleur de fond après le mot-clé box.
@startuml
box "Internal Service" #LightBlue
participant Bob
participant Alice
end box
participant Other
Bob -> Alice : hello
Alice -> Other : hello
@enduml
Supprimer les participants en pied de page
Vous pouvez utiliser le mot-clé hide footbox pour supprimer la partie basse du diagramme.
@startuml
hide footbox
title Footer removed
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
@enduml
Personnalisation
Utilisez la commande skinparam pour changer la couleur et la mise en forme du texte du schéma. Vous pouvez utiliser cette commande :
Dans la définition du diagramme, comme pour les autres commandes,
Vous pouvez aussi modifier d'autres paramètres pour le rendu, comme le montrent les exemples suivants:
@startuml
skinparam sequenceArrowThickness 2
skinparam roundcorner 20
skinparam maxmessagesize 60
skinparam sequenceParticipant underline
actor User
participant "First Class" as A
participant "Second Class" as B
participant "Last Class" as C
User -> A: DoWork
activate A
A -> B: Create Request
activate B
B -> C: DoWork
activate C
C --> B: WorkDone
destroy C
B --> A: Request Created
deactivate B
A --> User: Done
deactivate A
@enduml
@startuml
skinparam backgroundColor #EEEBDC
skinparam handwritten true
skinparam sequence {
ArrowColor DeepSkyBlue
ActorBorderColor DeepSkyBlue
LifeLineBorderColor blue
LifeLineBackgroundColor #A9DCDF
ParticipantBorderColor DeepSkyBlue
ParticipantBackgroundColor DodgerBlue
ParticipantFontName Impact
ParticipantFontSize 17
ParticipantFontColor #A9DCDF
ActorBackgroundColor aqua
ActorFontColor DeepSkyBlue
ActorFontSize 17
ActorFontName Aapex
}
actor User
participant "First Class" as A
participant "Second Class" as B
participant "Last Class" as C
User -> A: DoWork
activate A
A -> B: Create Request
activate B
B -> C: DoWork
activate C
C --> B: WorkDone
destroy C
B --> A: Request Created
deactivate B
A --> User: Done
deactivate A
@enduml
Changer le padding
Il est possible de changer certains paramètres du padding.
@startuml
skinparam ParticipantPadding 20
skinparam BoxPadding 10
box "Foo1"
participant Alice1
participant Alice2
end box
box "Foo2"
participant Bob1
participant Bob2
end box
Alice1 -> Bob1 : hello
Alice1 -> Out : out
@enduml
Appendix: Examples of all arrow type
Normal arrow
@startuml
participant Alice as a
participant Bob as b
a -> b : ""-> ""
a ->> b : ""->> ""
a -\ b : ""-\ ""
a -\\ b : ""-\\\\""
a -/ b : ""-/ ""
a -// b : ""-// ""
a ->x b : ""->x ""
a x-> b : ""x-> ""
a o-> b : ""o-> ""
a ->o b : ""->o ""
a o->o b : ""o->o ""
a <-> b : ""<-> ""
a o<->o b : ""o<->o""
a x<->x b : ""x<->x""
a ->>o b : ""->>o ""
a -\o b : ""-\o ""
a -\\o b : ""-\\\\o""
a -/o b : ""-/o ""
a -//o b : ""-//o ""
a x->o b : ""x->o ""
@enduml
Incoming and outgoing messages (with '[', ']')
Incoming messages (with '[')
@startuml
participant Alice as a
participant Bob as b
[-> b : ""[-> ""
[->> b : ""[->> ""
[-\ b : ""[-\ ""
[-\\ b : ""[-\\\\""
[-/ b : ""[-/ ""
[-// b : ""[-// ""
[->x b : ""[->x ""
[x-> b : ""[x-> ""
[o-> b : ""[o-> ""
[->o b : ""[->o ""
[o->o b : ""[o->o ""
[<-> b : ""[<-> ""
[o<->o b : ""[o<->o""
[x<->x b : ""[x<->x""
[->>o b : ""[->>o ""
[-\o b : ""[-\o ""
[-\\o b : ""[-\\\\o""
[-/o b : ""[-/o ""
[-//o b : ""[-//o ""
[x->o b : ""[x->o ""
@enduml
Outgoing messages (with ']')
@startuml
participant Alice as a
participant Bob as b
a ->] : ""->] ""
a ->>] : ""->>] ""
a -\] : ""-\] ""
a -\\] : ""-\\\\]""
a -/] : ""-/] ""
a -//] : ""-//] ""
a ->x] : ""->x] ""
a x->] : ""x->] ""
a o->] : ""o->] ""
a ->o] : ""->o] ""
a o->o] : ""o->o] ""
a <->] : ""<->] ""
a o<->o] : ""o<->o]""
a x<->x] : ""x<->x]""
a ->>o] : ""->>o] ""
a -\o] : ""-\o] ""
a -\\o] : ""-\\\\o]""
a -/o] : ""-/o] ""
a -//o] : ""-//o] ""
a x->o] : ""x->o] ""
@enduml
Short incoming and outgoing messages (with '?')
Short incoming (with '?')
@startuml
participant Alice as a
participant Bob as b
a -> b : //Long long label//
?-> b : ""?-> ""
?->> b : ""?->> ""
?-\ b : ""?-\ ""
?-\\ b : ""?-\\\\""
?-/ b : ""?-/ ""
?-// b : ""?-// ""
?->x b : ""?->x ""
?x-> b : ""?x-> ""
?o-> b : ""?o-> ""
?->o b : ""?->o ""
?o->o b : ""?o->o ""
?<-> b : ""?<-> ""
?o<->o b : ""?o<->o""
?x<->x b : ""?x<->x""
?->>o b : ""?->>o ""
?-\o b : ""?-\o ""
?-\\o b : ""?-\\\\o ""
?-/o b : ""?-/o ""
?-//o b : ""?-//o ""
?x->o b : ""?x->o ""
@enduml
Short outgoing (with '?')
@startuml
participant Alice as a
participant Bob as b
a -> b : //Long long label//
a ->? : ""->? ""
a ->>? : ""->>? ""
a -\? : ""-\? ""
a -\\? : ""-\\\\?""
a -/? : ""-/? ""
a -//? : ""-//? ""
a ->x? : ""->x? ""
a x->? : ""x->? ""
a o->? : ""o->? ""
a ->o? : ""->o? ""
a o->o? : ""o->o? ""
a <->? : ""<->? ""
a o<->o? : ""o<->o?""
a x<->x? : ""x<->x?""
a ->>o? : ""->>o? ""
a -\o? : ""-\o? ""
a -\\o? : ""-\\\\o?""
a -/o? : ""-/o? ""
a -//o? : ""-//o? ""
a x->o? : ""x->o? ""
@enduml
Specific SkinParameter
By default
@startuml
Bob -> Alice : hello
Alice -> Bob : ok
@enduml
LifelineStrategy
nosolid (by default)
@startuml
skinparam lifelineStrategy nosolid
Bob -> Alice : hello
Alice -> Bob : ok
@enduml