Reference Markdown Guide
Reference Markdown Guide
• Sequence diagram,
• Usecase diagram,
• Class diagram,
• Activity diagram,
• Component diagram,
• State diagram,
• Object diagram.
1 Sequence Diagram
1.1 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.
@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
1.2 Comments
Everything that starts with simple quote ' is a comment.
You can also put comments on several lines using /' to start and '/ to end.
• actor
• boundary
• control
• entity
• database
@startuml
actor Foo1
boundary Foo2
control Foo3
entity Foo4
database Foo5
Foo1 -> Foo2 : To boundary
Foo1 -> Foo3 : To control
Foo1 -> Foo4 : To entity
Foo1 -> Foo5 : To database
@enduml
• repeat the arrow head (for example, >> or //) head to have a thin drawing
• use -- instead of - to have a dotted arrow
@startuml
Bob ->x Alice
Bob -> Alice
Bob ->> Alice
Bob -\ Alice
Bob \\- Alice
Bob //-- Alice
You can specify a startnumber with autonumber 'start' , and also an increment with 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
@enduml
You can specify a format for your number by using between double-quote.
The formatting is done with the Java class DecimalFormat (’0’ means digit, ’#’ means digit and zero
if absent).
You can use some html tag in the 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
@enduml
1.9 Title
The title keywords is used to put a title.
@startuml
@enduml
@enduml
newpage
end
@enduml
Bob ->Alice : ok
note right: this is another note
note over Alice , Bob #FFAAAA: This is displayed\n over Bob and Alice.
1.17 Divider
If you want, you can split a diagram using == separator to divide your diagram into logical steps.
@startuml
== Initialization ==
== Repetition ==
@enduml
1.18 Reference
You can use reference in a diagram, using the keyword ref over.
@startuml
participant Alice
actor Bob
1.19 Delay
You can use ... to indicate a delay in the diagram. And it is also possible to put a message with this
delay.
@startuml
@enduml
1.20 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
@enduml
B -> C: DoWork
activate C
C --> B: WorkDone
destroy C
B --> A: RequestCreated
deactivate B
@enduml
Nested lifeline can be used, and it is possible to add a color on the lifeline.
@startuml
participant User
B --> A: RequestCreated
deactivate B
deactivate A
A -> User: Done
deactivate A
@enduml
create Other
Alice -> Other : new
@enduml
activate A
A<--] : RequestCreated
deactivate A
[<- A: Done
deactivate A
@enduml
[<- Bob
[x<- Bob
Bob ->]
Bob ->o]
Bob o->o]
Bob ->x]
Bob <-]
Bob x<-]
@enduml
@enduml
By default, the guillemet character is used to display the stereotype. You can change this behavious
using the skinparam guillemet:
@startuml
@enduml
@startuml
@enduml
@enduml
@enduml
You can also define title on several lines using 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
@enduml
@enduml
hide footbox
title Footer removed
@enduml
1.28 Skinparam
You can use the skinparam command to change colors and fonts for the drawing.
You can use this command:
@startuml
skinparam backgroundColor #EEEBDC
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
B -> C: DoWork
activate C
C --> B: WorkDone
destroy C
@enduml
(First usecase)
(Another usecase) as (UC2)
usecase UC3
usecase (Last\nusecase) as UC4
@enduml
2.2 Actors
Actor are enclosed using between two points.
You can also use the actor keyword to define an actor. And you can define an alias, using the as
keyword. This alias will be used latter, when defining relations.
We will see later that the actor definitions are optional.
@startuml
:First Actor:
:Another\nactor: as Men2
actor Men3
actor :Last actor: as Men4
@enduml
@startuml
@enduml
@enduml
2.5 Extension
If one actor/use case extends another one, you can use the symbol <|-- (which stands for ).
@startuml
:Main Admin: as Admin
(Use the application) as (Use)
@enduml
2.7 Stereotypes
You can add stereotypes while defining actors and use cases using ” << ” and ” >> ”.
@startuml
User << Human >>
:Main Database: as MySql << Application >>
(Start) << One Shot >>
(Use the application) as (Use) << Main >>
@enduml
It is also possible to change arrow direction by adding left, right, up or down keywords inside the
arrow:
@startuml
:user: -left -> (dummyLeft)
:user: -right -> (dummyRight)
:user: -up -> (dummyUp)
:user: -down -> (dummyDown)
@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.
@enduml
@enduml
You may change to left to right using the left to right direction command. The result is often
better with this direction.
@startuml
@enduml
2.12 Skinparam
You can use the skinparam command to change colors and fonts for the drawing.
You can use this command :
• In the diagram definition, like any other commands,
• In an included file,
• In a configuration file, provided in the command line or the ANT task.
You can define specific color and fonts for stereotyped actors and usecases.
@startuml
skinparam handwritten true
skinparam usecase {
BackgroundColor DarkSeaGreen
BorderColor DarkSlateGray
ArrowColor Olive
ActorBorderColor black
ActorFontName Courier
@enduml
3 Class Diagram
3.1 Relations between classes
Relations between classes are defined using the following symbols :
Extension <|--
Composition *--
Aggregation o--
It is possible to replace -- by .. to have a dotted line.
Knowing those rules, it is possible to draw the following drawings:
@startuml
scale 800 width
Class01 <|-- Class02
Class03 *-- Class04
Class05 o-- Class06
Class07 .. Class08
Class09 -- Class10
Class11 <|.. Class12
Class13 --> Class14
Class15 ..> Class16
Class17 ..|> Class18
Class19 <--* Class20
@enduml
For cardinality, you can use double-quotes "" on each side of the relation.
@startuml
@enduml
You can add an extra arrow pointing at one object showing which object acts on the other object,
using < or > at the begin or at the end of the label.
@startuml
class Car
@enduml
The system checks for parenthesis to choose between methods and fields.
@startuml
Object <|-- ArrayList
Object : equals ()
ArrayList : Object [] elementData
ArrayList : size ()
@enduml
@startuml
class Dummy {
String data
void methods ()
}
class Flight {
flightNumber : Integer
departureTime : Date
}
@enduml
@startuml
class Dummy {
-field1
#field2
~method1 ()
+method2 ()
}
@enduml
You can turn off this feature using the skinparam classAttributeIconSize 0 command :
@startuml
skinparam classAttributeIconSize 0
class Dummy {
-field1
#field2
~method1 ()
+method2 ()
}
@enduml
These modifiers can be used at the start or at the end of the line. You can also use classifier instead
of static.
@startuml
class Dummy {
{static} String id
{abstract} void methods ()
}
@enduml
@startuml
class Foo1 {
You can use
several lines
..
as you want
and group
==
things together.
__
You can have as many groups
as you want
--
End of class
}
class User {
.. Simple Getter ..
+ getName ()
+ getAddress ()
.. Some setter ..
+ setName ()
__ private data __
int age
-- encrypted --
String password
}
@enduml
You can also define notes using note left of , note right of , note top of , note bottom of
keywords.
You can also define a note on the last defined class using note left, note right, note top, note
bottom.
A note can be also define alone with the note keywords, then linked to other objects using the ..
symbol.
@startuml
class Object << general >>
Object <|--- ArrayList
class Foo
note left: On last defined class
@enduml
• <b>
• <u>
• <i>
• <s>, <del>, <strike>
• <font color="AAAAAA"> or <font color="colorName">
• <color:AAAAAA> or <color:colorName>
• <size:nn> to change font size
• <img src="file"> or <img:file> : the file must be accessible by the filesystem
You can also have a note on several lines You can also define a note on the last defined class using
note left, note right, note top, note bottom.
@startuml
class Foo
note left: On last defined class
note as N1
This note is <u>also </u>
<b><color:royalBlue >on several </color >
<s>words </s> lines
And this is hosted by <img:sourceforge.jpg >
end note
@enduml
class Dummy
Dummy --> Foo : A link
note on link #red: note that is red
@enduml
class ArrayList {
Object [] elementData
size ()
}
enum TimeUnit {
DAYS
HOURS
MINUTES
}
annotation SuppressWarnings
@enduml
You can also provide, just after the hide or show keyword:
• class for all classes,
• interface for all interfaces,
• enum for all enums,
• <<foo1>> for classes which are stereotyped with foo1,
• an existing class name.
You can use several show/hide commands to define rules and exceptions.
@startuml
class Dummy1 {
+myMethods ()
}
class Dummy2 {
+hiddenMethod ()
}
hide members
hide <<Serializable >> circle
show Dummy1 methods
show <<Serializable >> fields
@enduml
class Foo1
class Foo2
hide Foo2
@enduml
@enduml
3.16 Packages
You can define a package using the package keyword, and optionally declare a background color
for your package (Using a html color code or name).
Note that package definitions can be nested.
@startuml
package net.sourceforge.plantuml {
Object <|-- Demo1
Demo1 *- Demo2
}
@enduml
@enduml
You can also define links between packages, like in the following example:
@startuml
package foo1.foo2 {
}
package foo1.foo2.foo3 {
class Object
}
@enduml
3.18 Namespaces
In packages, the name of a class is the unique identifier of this class. It means that you cannot have
two classes with the very same name in different packages.
In that case, you should use namespaces instead of packages.
You can refer to classes from other namespaces by fully qualify them. Classes from the default
namespace are qualified with a starting dot.
Note that you don’t have to explicitly create namespace : a fully qualified class is automatically
put in the right namespace.
@startuml
class BaseClass
namespace net.foo {
net.dummy.Person <|- Person
@enduml
set namespaceSeparator ::
class X1::X2::foo {
some info
}
@enduml
You can disable automatic package creation using the command set namespaceSeparator none.
@startuml
@enduml
It is also possible to change arrow direction by adding left, right, up or down keywords inside the
arrow:
@startuml
foo -left -> dummyLeft
foo -right -> dummyRight
foo -up -> dummyUp
foo -down -> dummyDown
@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.
@enduml
@startuml
legend right
<b>Object </b> and <b>ArrayList </b>
are simple class
endlegend
@enduml
class Enrollment {
drop ()
cancel ()
}
@enduml
class Enrollment {
drop ()
cancel ()
}
@enduml
3.25 Skinparam
You can use the skinparam command to change colors and fonts for the drawing.
You can use this command :
• In the diagram definition, like any other commands,
• In an included file,
• In a configuration file, provided in the command line or the ANT task.
@startuml
skinparam class {
BackgroundColor PaleGreen
ArrowColor SeaGreen
BorderColor SpringGreen
}
skinparam stereotypeCBackgroundColor YellowGreen
@enduml
skinparam class {
BackgroundColor PaleGreen
ArrowColor SeaGreen
BorderColor SpringGreen
BackgroundColor <<Foo >> Wheat
BorderColor <<Foo >> Tomato
}
skinparam stereotypeCBackgroundColor YellowGreen
skinparam stereotypeCBackgroundColor << Foo >> DimGray
@enduml
• |,
• /,
• \,
• or -
depending the direction of the gradient.
For example, you could have:
@startuml
@enduml
class BaseClass
namespace net.foo {
net.dummy.Person <|- Person
.BaseClass <|-- Person
4 Activity Diagram
4.1 Simple Activity
You can use (*) for the starting point and ending point of the activity diagram.
In some occasion, you may want to use (*top) to force the starting point to be at the top of the
diagram.
Use --> for arrows.
@startuml
@enduml
@enduml
@enduml
4.4 Branches
You can use if/then/else keywords to define branches.
@startuml
(*) --> "Initialization"
@enduml
Unfortunately, you will have to sometimes repeat the same activity in the diagram text:
@startuml
(*) --> "check input"
If "input is verbose" then
--> [Yes] "turn on verbosity"
--> "run command"
else
--> "run command"
Endif
-->(*)
@enduml
if "" then
-> "activity 3" as a3
else
if "Other test" then
-left -> "activity 5"
else
--> "activity 6"
endif
endif
else
endif
endif
@enduml
4.6 Synchronization
You can use === code === to display synchronization bars.
@startuml
--> (*)
@enduml
4.8 Notes
You can add notes on a activity using the commands note left, note right, note top or note
bottom, just after the description of the activity you want to note.
If you want to put a note on the starting point, define the note at the very beginning of the diagram
description.
You can also have a note on several lines, using the endnote keywords.
@startuml
@enduml
4.9 Partition
You can define a partition using the partition keyword, and optionally declare a background color
for your partition (Using a html color code or name)
When you declare activities, they are automatically put in the last used partition.
You can close the partition definition using a closing bracket }.
@startuml
partition Conductor {
(*) --> "Climbs on Platform"
--> === S1 ===
--> Bows
}
partition Conductor {
Bows --> === S2 ===
--> WavesArmes
Applauds --> === S2 ===
}
@enduml
4.11 Skinparam
You can use the skinparam command to change colors and fonts for the drawing.
You can use this command :
• In the diagram definition, like any other commands,
• In an included file,
• In a configuration file, provided in the command line or the ANT task.
You can define specific color and fonts for stereotyped activities.
@startuml
@enduml
4.12 Octagon
You can change the shape of activities to octagon using the skinparam activityShape octagon
command.
@startuml
'Default is skinparam activityShape roundBox
skinparam activityShape octagon
@enduml
if "Page.onSecurityCheck" then
->[true] "Page.onInit ()"
else
-->[yes] === RENDERING ===
endif
else
-->[false] === REDIRECT_CHECK ===
endif
@enduml
5.2 Start/Stop
You can use start and stop keywords to denote the beginning and the end of a diagram.
@startuml
start
:Hello world;
:This is on defined on
several ** lines **;
stop
@enduml
5.3 Conditional
You can use if, then and else keywords to put tests if your diagram. Labels can be provided
using parentheses.
@startuml
start
stop
@enduml
start
repeat
:read data;
:generate diagrams;
repeat while (more data ?)
stop
@enduml
start
stop
@enduml
It is possible to provide a label after the endwhile keyword, or using the is keyword.
@startuml
while (check filesize ?) is (not empty)
:read file;
endwhile (empty)
:close file;
@enduml
start
@enduml
5.7 Notes
Text formatting can be done using creole wiki syntax.
@startuml
start
:foo1;
@enduml
legend
this is the legend
endlegend
@enduml
5.9 Colors
You can use specify a color for some activities.
@startuml
start
:starting progress;
#HotPink:reading configuration files
These files should edited at this point !;
#AAAAAA:ending of the process;
@enduml
5.10 Arrows
Using the -> notation, you can add texts to arrow, and change their color.
@startuml
:foo1;
-> You can put text on arrows;
if (test) then
-[#blue]->
:foo2;
-[#green]-> The text can
also be on several lines
and ** very ** long ...;
:foo3;
else
-[#black]->
:foo4;
endif
-[#gray]->
:foo5;
@enduml
5.11 Grouping
You can group activity together by defining partition:
@startuml
start
partition Initialization {
:read config file;
:init internal variable;
}
partition Running {
:wait for user interaction;
:print information;
}
stop
@enduml
5.12 Swimlanes
Using pipe |, you can define swimlanes.
It’s also possible to change swimlanes color.
@startuml
|Swimlane1|
start
:foo1;
|# AntiqueWhite|Swimlane2|
:foo2;
:foo3;
|Swimlane1|
:foo4;
|Swimlane2|
:foo5;
stop
@enduml
5.13 Detach
It’s possible to remove an arrow using the detach keyword.
@startuml
:start;
fork
:foo1;
:foo2;
fork again
:foo3;
detach
endfork
if (foo4) then
:foo5;
detach
endif
:foo6;
detach
:foo7;
stop
@enduml
5.14 SDL
By changing the final ; separator, you can set different rendering for the activity:
• |
• <
• >
• /
• ]
• }
@startuml
:Ready;
:next(o)|
:Receiving;
split
:nak(i)<
:ack(o)>
split again
:ack(i)<
:next(o)
on several line|
:i := i + 1]
:ack(o)>
split again
:err(i)<
:nak(o)>
split again
:foo/
split again
:i > 5}
stop
end split
:finish;
@enduml
start
:ClickServlet.handleRequest ();
:new page;
if (Page.onSecurityCheck) then (true)
:Page.onInit ();
if (isForward ?) then (no)
:Process controls;
if (continue processing ?) then (no)
stop
endif
stop
@enduml
6 Component Diagram
6.1 Components
Components must be bracketed.
You can also use the component keyword to defines a component. And you can define an alias,
using the as keyword. This alias will be used latter, when defining relations.
@startuml
[First component]
[Another component] as Comp2
component Comp3
component [Last\ncomponent] as Comp4
@enduml
6.2 Interfaces
Interface can be defined using the () symbol (because this looks like a circle).
You can also use the interface keyword to defines an interface. And you can define an alias, using
the as keyword. This alias will be used latter, when defining relations.
We will see latter that interface definition is optional.
@startuml
() "First Interface"
() "Another interface" as Interf2
interface Interf3
interface "Last\ninterface" as Interf4
@enduml
@startuml
@enduml
DA - [First Component]
[First Component] ..> HTTP : use
@enduml
@startuml
cloud {
[Example 1]
}
database "MySql" {
folder "This is my folder" {
[Folder 3]
}
frame "Foo" {
[Frame 4]
}
}
@enduml
It is also possible to change arrow direction by adding left, right, up or down keywords inside the
arrow:
@startuml
[Component] -left -> left
[Component] -right -> right
[Component] -up -> up
[Component] -down -> down
@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.
DA - [First Component]
[First Component] ..> HTTP : use
@enduml
DA - [First Component]
[First Component] ..> HTTP : use
@enduml
6.10 Skinparam
You can use the skinparam command to change colors and fonts for the drawing.
You can use this command :
• In the diagram definition, like any other commands,
• In an included file,
• In a configuration file, provided in the command line or the ANT task.
You can define specific color and fonts for stereotyped components and interfaces.
@startuml
skinparam component {
FontSize 13
InterfaceBackgroundColor RosyBrown
InterfaceBorderColor orange
BackgroundColor <<Apache >> Red
BorderColor <<Apache >> #FF6655
FontName Courier
BorderColor black
BackgroundColor gold
ArrowFontName Impact
ArrowColor #FF6655
ArrowFontColor #777777
}
() "Data Access" as DA
DA - [First Component]
[First Component] ..> () HTTP : use
HTTP - [Web Server] << Apache >>
@enduml
@startuml
[AA] <<static lib >>
[BB] <<shared lib >>
[CC] <<static lib >>
node node1
node node2 <<shared node >>
database Production
skinparam component {
backgroundColor <<static lib >> DarkKhaki
backgroundColor <<shared lib >> Green
}
skinparam node {
borderColor Green
backgroundColor Yellow
backgroundColor <<shared node >> Magenta
}
skinparam databaseBackgroundColor Aqua
@enduml
7 State Diagram
7.1 Simple State
You can use [*] for the starting point and ending point of the state diagram.
Use --> for arrows.
@startuml
@enduml
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
@enduml
state Active {
[*] -> NumLockOff
NumLockOff --> NumLockOn : EvNumLockPressed
NumLockOn --> NumLockOff : EvNumLockPressed
--
[*] -> CapsLockOff
CapsLockOff --> CapsLockOn : EvCapsLockPressed
CapsLockOn --> CapsLockOff : EvCapsLockPressed
--
[*] -> ScrollLockOff
ScrollLockOff --> ScrollLockOn : EvCapsLockPressed
ScrollLockOn --> ScrollLockOff : EvCapsLockPressed
}
@enduml
@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.
7.6 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
@enduml
state foo
note "This is a floating note" as N1
@enduml
@enduml
7.8 Skinparam
You can use the skinparam command to change colors and fonts for the drawing.
You can use this command :
• In the diagram definition, like any other commands,
• In an included file,
• In a configuration file, provided in the command line or the ANT task.
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
}
8 Object Diagram
8.1 Definition of objects
You define instance of objects using the object keywords.
@startuml
object firstObject
object "My Second Object" as o2
@enduml
object user
@enduml
object user {
name = "Dummy"
id = 123
}
@enduml
9 Common commands
9.1 Footer and header
You can use the commands header or footer to add a footer or a header on any generated diagram.
You can optionally specify if you want a center, left or right footer/header, by adding a keyword.
As for title, it is possible to define a header or a footer on several lines.
It is also possible to put some HTML into the header or footer.
@startuml
Alice -> Bob: Authentication Request
header
<font color=red >Warning :</font >
Do not use in production.
endheader
@enduml
9.2 Zoom
You can use the scale command to zoom the generated image.
You can use either a number or a fraction to define the scale factor. You can also specify either
width or height (in pixel). And you can also give both width and height : the image is scaled to fit
inside the specified dimension.
• scale 1.5
• scale 2/3
• scale 200 width
• scale 200 height
• scale 200*100
@startuml
scale 180*90
Bob ->Alice : hello
@enduml
10 Salt
Salt is a subproject included in PlantUML that may help you to design graphical interface.
You can use either @startsalt keyword, or @startuml followed by a line with salt keyword.
The goal of this tool is to discuss about simple and sample windows.
Just after the opening bracket, you can use a character to define if you want to draw lines or columns
of the grid :
# To display all vertical and horizontal lines
! To display all vertical lines
- To display all horizontal lines
+ To display external lines
@startsalt
{+
Login | "MyName "
Password | "**** "
[Cancel] | [ OK ]
}
@endsalt
++++ Berlin
++ Africa
}
}
@endsalt
@startsalt
{+
{/ <b>General
Fullscreen
Behavior
Saving } |
{
{ Open image in: | ^Smart Mode^ }
[X] Smooth images when zoomed
[X] Confirm image deletion
[ ] Show hidden images
[Close]
}
}
@endsalt
11 Creole
A light Creole engine have been integrated into PlantUML to have a standardized way of defining
text style.
All diagrams are now supporting this syntax.
(Note that ascending compatibility with HTML syntax is preserved)
11.2 List
@startuml
object demo {
* Bullet list
* Second item
** Sub item
}
legend
# Numbered list
# Second item
## Sub item
## Another sub item
# Third item
end legend
@enduml
@enduml
11.5 Headings
@startuml
usecase UC1 as "
= Extra -large heading
Some text
== Large heading
Other text
=== Medium heading
Information
....
==== Small heading"
@enduml
@enduml
11.7 Table
@startuml
skinparam titleFontSize 14
title
Example of simple table
|= |= table |= header |
| a | table | row |
| b | table | row |
end title
[*] --> State1
@enduml
11.8 OpenIconic
OpenIconic is an very nice open source icon set. Those icons have been integrated into the creole
parser, so you can use them out-of-the-box. You can use the following syntax: <&ICON_NAME>.
@startuml
title: <size :20><&heart >Use of OpenIconic <&heart ></size >
class Wifi
note left
Click on <&wifi >
end note
@enduml
The complete list is available on OpenIconic Website, or you can use the following special diagram:
@startuml
listopeniconic
@enduml
where foo.png if the image file you want to use (it will be converted to gray automatically).
After -encodesprite, you have to specify a format: 4, 8, 16, 4z, 8z or 16z.
The number indicates the gray level and the optionnal z is used to enable compression in sprite
definition.
After copying an image into you clipboard, several possible definitions of the corresponding sprite
will be displayed : you will just have to pickup the one you want.
11.12 Examples
@startuml
sprite $printer [15 x15/8z] NOtH3W0W208HxFz_kMAhj7lHWpa1XC716sz0Pq4MVPEWfBHIuxP3L6kbTcizR8tAhzaqFvXwvFfPEq
start
:click on <$printer > to print the page;
@enduml
@startuml
sprite $bug [15 x15 /16z] PKzR2i0m2BFMi15p__FEjQEqB1z27aeqCqixa8S4OT7C53cKpsHpaYPDJY_12MHM - BLRyywPhrrlw3qum
sprite $printer [15 x15/8z] NOtH3W0W208HxFz_kMAhj7lHWpa1XC716sz0Pq4MVPEWfBHIuxP3L6kbTcizR8tAhzaqFvXwvFfPEq
sprite $disk {
444445566677881
436000000009991
43600000000 ACA1
53700000001 A7A1
53700000012 B8A1
53800000123 B8A1
63800001233 C9A1
634999 AABBC99B1
744566778899 AB1
7456 AAAAA99AAB1
8566 AFC228AABB1
8567 AC8118BBBB1
867 BD4433BBBBB1
39 AAAAABBBBBBC1
}
class Example {
Can have some bug : <$bug >
Click on <$disk > to save
}
@enduml
12.2 Nested
To avoid repetition, it is possible to nest definition. So the following definition :
skinparam xxxxParam1 value1
skinparam xxxxParam2 value2
skinparam xxxxParam3 value3
skinparam xxxxParam4 value4
12.3 Color
You can use either standard color name or RGB code.
You can also change the default font for all fonts using skinparam defaultFontName.
Example:
skinparam defaultFontName Aapex
Please note the fontname is highly system dependent, so do not over use it, if you look for portability.
componentArrowFontColor black
componentArrowFontSize 13
Used for text on arrows in component diagrams
componentArrowFontStyle plain
componentArrowFontName
noteFontColor black
noteFontSize 13
Used for notes in all diagrams but sequence diagrams
noteFontStyle plain
noteFontName
packageFontColor black
packageFontSize 14
Used for package and partition names
packageFontStyle plain
packageFontName
sequenceActorFontColor black
sequenceActorFontSize 13
Used for actor in sequence diagrams
sequenceActorFontStyle plain
sequenceActorFontName
sequenceDividerFontColor black
sequenceDividerFontSize 13
Used for text on dividers in sequence diagrams
sequenceDividerFontStyle bold
sequenceDividerFontName
sequenceArrowFontColor black
sequenceArrowFontSize 13
Used for text on arrows in sequence diagrams
sequenceArrowFontStyle plain
sequenceArrowFontName
sequenceGroupingFontColor black
sequenceGroupingFontSize 11
Used for text for ”else” in sequence diagrams
sequenceGroupingFontStyle plain
sequenceGroupingFontName
sequenceGroupingHeaderFontColor black
sequenceGroupingHeaderFontSize 13
Used for text for ”alt/opt/loop” headers in sequence diagrams
sequenceGroupingHeaderFontStyle plain
sequenceGroupingHeaderFontName
sequenceParticipantFontColor black
sequenceParticipantFontSize 13
Used for text on participant in sequence diagrams
sequenceParticipantFontStyle plain
sequenceParticipantFontName
sequenceTitleFontColor black
sequenceTitleFontSize 13
Used for titles in sequence diagrams
sequenceTitleFontStyle plain
sequenceTitleFontName
titleFontColor black
titleFontSize 18
Used for titles in all diagrams but sequence diagrams
titleFontStyle plain
titleFontName
stateFontColor black
stateFontSize 14
Used for states in state diagrams
stateFontStyle plain
stateFontName
stateArrowFontColor black
stateArrowFontSize 13
Used for text on arrows in state diagrams
stateArrowFontStyle plain
stateArrowFontName
stateAttributeFontColor black
stateAttributeFontSize 12
Used for states description in state diagrams
stateAttributeFontStyle plain
stateAttributeFontName
usecaseFontColor black
usecaseFontSize 14
Used for usecase labels in usecase diagrams
usecaseFontStyle plain
usecaseFontName
usecaseStereotypeFontColor black
usecaseStereotypeFontSize 14
Used for stereotype in usecase
usecaseStereotypeFontStyle italic
usecaseStereotypeFontName
usecaseActorFontColor black
usecaseActorFontSize 14
Used for actor labels in usecase diagrams
usecaseActorFontStyle plain
usecaseActorFontName
usecaseActorStereotypeFontColor black
usecaseActorStereotypeFontSize 14
Used for stereotype for actor
usecaseActorStereotypeFontStyle italic
usecaseActorStereotypeFontName
usecaseArrowFontColor black
usecaseArrowFontSize 13
Used for text on arrows in usecase diagrams
usecaseArrowFontStyle plain
usecaseArrowFontName
footerFontColor black
footerFontSize 10
Used for footer
footerFontStyle plain
footerFontName
headerFontColor black
headerFontSize 10
Used for header
headerFontStyle plain
headerFontName
actor User
participant "First Class" as A
participant "Second Class" as B
participant "Last Class" as C
B -> C: DoWork
activate C
C --> B: WorkDone
destroy C
@enduml
13 Preprocessing
Some minor preprocessing capabilities are included in PlantUML, and available for all diagrams.
Those functionnalities are very similar to the C language preprocessor, except that the special
character (#) has been changed to the exclamation mark (!).
File List.iuml: interface List List : int size() List : void clear()
The file List.iuml can be included in many diagrams, and any modification in this file will change
all diagrams that include it.
You can also put several @startuml/@enduml text block in an included file and then specify which
block you want to include adding !0 where 0 is the block number.
For example, if you use !include foo.txt!1, the second @startuml/@enduml block within foo.txt
will be included.
Of course, you can use the !include directive to define all your constants in a single file that you
include in your diagram.
Constant can be undefined with the !undef XXX directive.
You can also specify constants within the command line, with the -D flags.
Note that the -D flag must be put after the ”-jar plantuml.jar” section.
@startuml
!define DOUBLE(x) x x
!definelong AUTHEN(x,y)
x -> y : DOUBLE(hello)
y -> x : ok
!enddefinelong
AUTHEN(Bob ,Alice)
@enduml
13.6 Conditions
You can use !ifdef XXX and !endif directives to have conditionnal drawings.
The lines between those two directives will be included only if the constant after the !ifdef directive
has been defined before.
You can also provide a !else part which will be included if the constant has not been defined.
@startuml
!include ArrayList.iuml
@enduml
File ArrayList.iuml:
class ArrayList
!ifdef SHOW_METHODS
ArrayList : int size ()
ArrayList : void clear ()
!endif
You can then use the !define directive to activate the conditionnal part of the diagram.
@startuml
!define SHOW_METHODS
!include ArrayList.iuml
@enduml
You can also use the !ifndef directive that includes lines if the provided constant has NOT been
defined.
Note the this -D option has to put before the -jar option. -D options after the -jar option will be
used to define constants within plantuml preprocessor.
You can use system environment variable or constant definition when using include:
14 Internationalization
The PlantUML language use letters to define actor, usecase and so on. But letters are not only A-Z
latin characters, it could be any kind of letter from any language.
@startuml
skinparam backgroundColor #EEEBDC
actor 使 用 者
participant " 頭 等 艙 " as A
participant " 第 二 類 " as B
participant " 最 後 一 堂 課 " as 別 的 東 西
使 用 者 -> A: 完 成 這 項 工 作
activate A
A -> B: 創 建 請 求
activate B
B -> 別 的 東 西 : 創 建 請 求
activate 別 的 東 西
別 的 東 西 --> B: 這 項 工 作 完 成
destroy 別 的 東 西
B --> A: 請 求 創 建
deactivate B
A --> 使 用 者 : 做 完
deactivate A
@enduml
14.1 Charset
The default charset used when reading the text files containing the UML text description is system
dependent. Normally, it should just be fine, but in some case, you may want to the use another
charset. For example, with the command line:
java -jar plantuml.jar -charset UTF -8 files.txt
Depending of your Java installation, the following charset should be available: ISO-8859-1, UTF-8,
UTF-16BE, UTF-16LE, UTF-16.
15 Color Names
Here is the list of colors recognized by PlantUML. Note that color names are case insensitive.
Contents
1 Sequence Diagram 1
1.1 Basic examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 Declaring participant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.4 Use non-letters in participants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.5 Message to Self . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.6 Change arrow style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.7 Change arrow color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.8 Message sequence numbering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.9 Title . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.10 Legend the diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.11 Splitting diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.12 Grouping message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.13 Notes on messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.14 Some other notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.15 Changing notes shape . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.16 Creole and HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.17 Divider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.18 Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.19 Delay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.20 Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.21 Lifeline Activation and Destruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.22 Participant creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.23 Incoming and outgoing messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
1.24 Stereotypes and Spots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1.25 More information on titles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
1.26 Participants encompass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
1.27 Removing Footer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
1.28 Skinparam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3 Class Diagram 29
3.1 Relations between classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.2 Label on relations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.3 Adding methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.4 Defining visibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.5 Abstract and Static . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.6 Advanced class body . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.7 Notes and stereotypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
3.8 More on notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.9 Note on links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.10 Abstract class and interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.11 Using non-letters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.12 Hide attributes, methods... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
3.13 Hide classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.14 Use generics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.15 Specific Spot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.16 Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
3.17 Packages style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
3.18 Namespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.19 Automatic namespace creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.20 Lollipop interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.21 Changing arrows direction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.22 Title the diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3.23 Legend the diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3.24 Association classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.25 Skinparam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
3.26 Skinned Stereotypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
3.27 Color gradient . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.28 Splitting large files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
4 Activity Diagram 52
4.1 Simple Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
4.2 Label on arrows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
4.3 Changing arrow direction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
4.4 Branches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
4.5 More on Branches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
4.6 Synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
4.7 Long activity description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
4.8 Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
4.9 Partition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
4.10 Title the diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
4.11 Skinparam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
4.12 Octagon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
4.13 Complete example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
6 Component Diagram 74
6.1 Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
6.2 Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
6.3 Basic example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
6.4 Using notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
6.5 Grouping Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
6.6 Changing arrows direction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
6.7 Title the diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
6.8 Use UML2 notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
6.9 Individual colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
6.10 Skinparam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
7 State Diagram 81
7.1 Simple State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
7.2 Composite state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
7.3 Long name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
7.4 Concurrent state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
7.5 Arrow direction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
7.6 Note . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
7.7 More in notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
7.8 Skinparam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
8 Object Diagram 88
8.1 Definition of objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
8.2 Relations between objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
8.3 Adding fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
8.4 Common features with class diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . 89
9 Common commands 90
9.1 Footer and header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
9.2 Zoom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
10 Salt 91
10.1 Basic widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
10.2 Using grid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
10.3 Using separator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
10.4 Tree widget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
10.5 Enclosing brackets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
10.6 Adding tabs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
10.7 Using menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
10.8 Advanced table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
11 Creole 96
11.1 Emphasized text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
11.2 List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
11.3 Escape character . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
11.4 Horizontal lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
11.5 Headings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
11.6 Legacy HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
11.7 Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
11.8 OpenIconic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
11.9 Defining and using sprites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
11.10Encoding Sprite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
11.11Importing Sprite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
11.12Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
13 Preprocessing 109
13.1 Including files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
13.2 Including URL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
13.3 Constant definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
13.4 Macro definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
13.5 Macro on several lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
13.6 Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
13.7 Search path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
13.8 Advanced features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
14 Internationalization 114
14.1 Charset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114