Professional Documents
Culture Documents
http://plantuml.com/sequence.html#Basic_examples
Sequence
Basic examples
Comments
Declaring participant
Use non-letters in participants
Message to Self
Change arrow style
Change arrow color
Message sequence numbering
Title
Legend the diagram
Splitting diagrams
Grouping message
Notes on messages
Some other notes
Changing notes shape
Creole and HTML
Divider
Reference
Delay
Space
Lifeline Activation and Destruction
Participant creation
Incoming and outgoing messages
Stereotypes and Spots
More information on titles
Participants encompass
Removing Footer
Skinparam
Use Case
Usecases
Actors
Usecases description
Basic example
Extension
Using notes
Stereotypes
Changing arrows direction
Title the diagram
Splitting diagrams
Left to right direction
Skinparam
Complete example
Class
Relations between classes
Label on relations
1 of 33
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
Adding methods
Dening visibility
Abstract and Static
Advanced class body
Notes and stereotypes
More on notes
Note on links
Abstract class and interface
Using non-letters
Hide attributes, methods...
Hide classes
Use generics
Specic Spot
Packages
Packages style
Namespaces
Automatic namespace creation
Lollipop interface
Changing arrows direction
Title the diagram
Legend the diagram
Association classes
Skinparam
Skinned Stereotypes
Color gradient
Help on layout
Splitting large les
Activity
Simple Activity
Label on arrows
Changing arrow direction
Branches
More on Branches
Synchronization
Long activity description
Notes
Partition
Title the diagram
Skinparam
Octagon
Complete example
Activity
Simple Activity
Start/Stop
Conditional
Repeat loop
While loop
2 of 33
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
Parallel processing
Notes
Title & Legend
Colors
Arrows
Grouping
Swimlanes
Detach
SDL
Complete example
Component
Components
Interfaces
Basic example
Using notes
Grouping Components
Arrows direction
Title the diagram
Use UML2 notation
Individual colors
Sprite in Stereotype
Skinparam
State
Simple State
Composite state
Long name
Concurrent state
Arrow direction
Note
More in notes
Skinparam
Object
Denition of objects
Relations between objects
Adding elds
Visibility
Denes notes
Use packages
Title the diagram
Skin the output
Split the image
Donate
3 of 33
87
Patreon
25
49
Tweet
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
Home
Screenshots
What's New ?
Getting Started
Running
F.A.Q.
Download
Question & Answer
Preprocessing
Site Map
External Links
Sequence Diagram
Basic examples
The sequence -> is used to draw a message between two participants.
Participants do not have to be explicitly declared.
To have a dotted arrow, you use
-->
It is also possible to use <- and <--. That does not change the drawing, but may
improve readability. Note that this is only true for sequence diagrams, rules are
dierent for the other diagrams.
@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
Alice -> Bob: Another authentication Request
Alice <-- Bob: another authentication Response
@enduml
4 of 33
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
Comments
Everything that starts with
is a comment.
/'
to start and
'/
to end.
Declaring participant
It is possible to change participant order using the
participant
keyword.
To
To
To
To
boundary
control
entity
database
@enduml
5 of 33
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
as
keyword.
6 of 33
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
as
keyword to
@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 to Self
A participant can send a message to itself.
It is also possible to have multi-line using
7 of 33
\n.
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
@startuml
Alice->Alice: This is a signal to self.\nIt also demonstrates\nmultiline \ntext
@enduml
8 of 33
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
autonumber
@startuml
autonumber
Bob -> Alice : Authentication Request
Bob <- Alice : Authentication Response
@enduml
9 of 33
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
autonumber 'start'
@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
You can specify a format for your number by using between double-quote.
The formatting is done with the Java class
digit and zero if absent).
DecimalFormat
10 of 33
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
You can also use autonumber stop and autonumber resume 'increment'
respectively pause and resume automatic numbering.
'format'
to
@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
11 of 33
"
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
Title
The
title
@startuml
title Simple communication example
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
@enduml
There is also a
caption
@startuml
caption figure 1
12 of 33
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
legend
and
end legend
left, right
or
center
@startuml
Alice -> Bob : Hello
legend right
Short
legend
endlegend
@enduml
Splitting diagrams
The
newpage
You can put a title for the new page just after the
13 of 33
newpage
keyword.
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
This is very handy with Word to print long diagram on several 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
Grouping message
It is possible to group messages together using the following keywords:
alt/else
opt
loop
par
break
critical
group,
It is possible a add a text that will be displayed into the header (except for
group).
The
end
14 of 33
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
Notes on messages
15 of 33
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
note left
keywords.
end note
or
note right
keywords
@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
note left of
note
end note
keywords.
@startuml
participant Alice
participant Bob
note left of Alice #aqua
This is displayed
left of Alice.
end note
16 of 33
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
hnote
and
rnote
@startuml
caller -> server : conReq
hnote over caller : idle
caller <- server : conConf
rnote over server
"r" as rectangle
"h" as hexagon
endrnote
@enduml
17 of 33
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
18 of 33
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
Divider
If you want, you can split a diagram using
into logical steps.
==
@startuml
== Initialization ==
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
== Repetition ==
Alice -> Bob: Another authentication Request
Alice <-- Bob: another authentication Response
@enduml
19 of 33
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
Reference
You can use reference in a diagram, using the keyword
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
20 of 33
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
Delay
You can use ... to indicate a delay in the diagram. And it is also possible to put a
message with this delay.
@startuml
Alice -> Bob: Authentication Request
...
Bob --> Alice: Authentication Response
...5 minutes latter...
Bob --> Alice: Bye !
@enduml
21 of 33
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
Space
You can use ||| to indicate some spacing in the diagram.
It is also possible to specify a number of pixel to be used.
@startuml
Alice -> Bob: message 1
Bob --> Alice: ok
|||
Alice -> Bob: message 2
Bob --> Alice: ok
||45||
Alice -> Bob: message 3
Bob --> Alice: ok
@enduml
activate
and
deactivate
activate
The
destroy
and
deactivate
@startuml
22 of 33
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
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
Nested lifeline can be used, and it is possible to add a color on the lifeline.
@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
23 of 33
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
deactivate A
@enduml
Participant creation
You can use the create keyword just before the rst reception of a message to
emphasize the fact that this message is actually creating this new object.
@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
24 of 33
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
25 of 33
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
->]
->o]
o->o]
->x]
Bob <-]
Bob x<-]
@enduml
26 of 33
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
<<
and
>>.
In the stereotype, you can add a spotted character in a colored circle using the
syntax (X,color).
@startuml
participant "Famous Bob" as Bob << Generated >>
participant Alice << (C,#ADD1B2) Testable >>
Bob->Alice: First message
@enduml
By default, the guillemet character is used to display the stereotype. You can
change this behavious using the 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) >>
27 of 33
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
\n
@startuml
title __Simple__ communication example\non several lines
Alice -> Bob: Authentication Request
Bob -> Alice: Authentication Response
@enduml
28 of 33
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
title
and
end title
keywords.
@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
Participants encompass
It is possible to draw a box around some participants, using
commands.
box
and
end box
You can add an optional title or a optional background color, after the
keyword.
box
@startuml
29 of 33
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
Removing Footer
You can use the
hide footbox
@startuml
hide footbox
title Footer removed
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
@enduml
Skinparam
You can use the
30 of 33
skinparam
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
sequenceArrowThickness 2
roundcorner 20
maxmessagesize 60
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
31 of 33
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
@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
32 of 33
09/06/2016 01:06 AM
http://plantuml.com/sequence.html#Basic_examples
Donate
33 of 33
87
Patreon
25
49
Tweet
09/06/2016 01:06 AM