PlantUML Language Reference Guide
PlantUML Language Reference Guide
PlantUML is an Open Source project that allows to quickly write: Sequence diagram, Usecase diagram, Class diagram, Activity diagram, Component diagram, State diagram, Object diagram. Diagrams are dened using a simple and intuitive language.
1 SEQUENCE DIAGRAM
1 Sequence Diagram
1.1 Basic examples
Every UML description must start by @startuml and must nish by @enduml. 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. Example:
@startuml Alice -> Bob: Authentication Request Bob --> Alice: Authentication Response Alice -> Bob: Another authentication Request Alice <-- Bob: another authentication Response @enduml
1 of 96
1 SEQUENCE DIAGRAM
2 of 96
1 SEQUENCE DIAGRAM
3 of 96
1 SEQUENCE DIAGRAM
You can specify a startnumber with autonumber 'start' , 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 Bob -> Alice : Yet another authentication Request Bob <- Alice : Yet another authentication Response @enduml
4 of 96
1 SEQUENCE DIAGRAM
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 also use some html tags 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 autonumber 40 10 "<font color=red ><b>Message 0 " Bob -> Alice : Yet another authentication Request Bob <- Alice : Yet another authentication Response @enduml
5 of 96
1.6 Title
1 SEQUENCE DIAGRAM
1.6 Title
The title keywords is used to put a title.
@startuml title Simple communication example Alice -> Bob: Authentication Request Bob --> Alice: Authentication Response @enduml
6 of 96
1 SEQUENCE DIAGRAM
7 of 96
1 SEQUENCE DIAGRAM
8 of 96
1 SEQUENCE DIAGRAM
9 of 96
1 SEQUENCE DIAGRAM
10 of 96
1 SEQUENCE DIAGRAM
11 of 96
1.12 Divider
1 SEQUENCE DIAGRAM
1.12 Divider
If you want, you can split a diagram using == separator to divide your diagram into logical steps.
@startuml == Initialisation == Alice -> Bob: Authentication Request Bob --> Alice: Authentication Response == Repetition == Alice -> Bob: Another authentication Request Alice <-- Bob: another authentication Response @enduml
12 of 96
1 SEQUENCE DIAGRAM
13 of 96
1 SEQUENCE DIAGRAM
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 deactivate A @enduml
14 of 96
1 SEQUENCE DIAGRAM
15 of 96
1 SEQUENCE DIAGRAM
16 of 96
1 SEQUENCE DIAGRAM
@startuml participant Bob << (C,# ADD1B2) >> participant Alice << (C,# ADD1B2) >> Bob ->Alice: First message @enduml
17 of 96
1 SEQUENCE DIAGRAM
18 of 96
1 SEQUENCE DIAGRAM
You can also dene 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 src=sourceforge.jpg > end title Alice -> Bob: Authentication Request Bob --> Alice: Authentication Response @enduml
19 of 96
1 SEQUENCE DIAGRAM
You can add an optional title or a optional background color, after the box keyword.
@startuml box "Internal Service" #LightBlue participant Bob participant Alice end box participant Other Bob -> Alice : hello Alice -> Other : hello @enduml
20 of 96
1 SEQUENCE DIAGRAM
21 of 96
1.20 Skinparam
1 SEQUENCE DIAGRAM
1.20 Skinparam
You can use the skinparam command to change colors and fonts for the drawing. You can use this command : In the diagram denition, like any other commands, In an included le, In a conguration le, provided in the command line or the ANT task.
@startuml skinparam backgroundColor #EEEBDC skinparam skinparam skinparam skinparam skinparam skinparam skinparam skinparam skinparam skinparam skinparam skinparam sequenceArrowColor DeepSkyBlue sequenceParticipantBorderColor DeepSkyBlue sequenceActorBorderColor DeepSkyBlue sequenceLifeLineBorderColor blue sequenceParticipantBackgroundColor DodgerBlue sequenceParticipantFontName Impact sequenceParticipantFontSize 17 sequenceParticipantFontColor #A9DCDF sequenceActorBackgroundColor aqua sequenceActorFontColor DeepSkyBlue sequenceActorFontSize 17 sequenceActorFontName Aapex
skinparam sequenceLifeLineBackgroundColor #A9DCDF 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
22 of 96
1.21 Skin
1 SEQUENCE DIAGRAM
1.21 Skin
Use the keyword skin to change the look of the generated diagram. There are only two skins available today (Rose, which is the default, and BlueModern), but it is possible to write your own skin.
@startuml skin BlueModern actor User participant "First Class" as A participant "Second Class" as B participant "Last Class" as C User -> A: DoWork activate A A -> B: << createRequest >> activate B B -> C: DoWork activate C C --> B: WorkDone destroy C B --> A: Request <u>Created </u> deactivate B A --> User: Done deactivate A @enduml
23 of 96
24 of 96
2.2 Actors
2.2 Actors
Actor are enclosed using between two points. You can also use the actor keyword to dene an actor. And you can dene an alias, using the as keyword. This alias will be used latter, when dening relations. We will see than actor denitions is optional.
@startuml :First Actor: :Another\nactor: as Men2 actor Men3 actor :Last actor: as Men4 @enduml
25 of 96
26 of 96
2.4 Extension
2.4 Extension
If one actor/use case extends another one, you can use the symbol <|-- (which stands for As for smiley, when you turn your head, you will see the symbol
@startuml :Main Admin: as Admin (Use the application) as (Use) User <|-- Admin (Start) <|-- (Use) @enduml
).
27 of 96
28 of 96
2.6 Stereotypes
2.6 Stereotypes
You can add stereotypes while dening actors and use cases using << and >>.
@startuml User << Human >> :Main Database: as MySql << Application >> (Start) << One Shot >> (Use the application) as (Use) << Main >> User -> (Start) User --> (Use) MySql --> (Use) @enduml
29 of 96
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
30 of 96
You can shorten the arrow by using only the rst character of the direction (for example, -d- instead of -down-) or the two rst characters (-do-). Please note that you should not abuse this functionnality : GraphViz gives usually good results without tweaking.
31 of 96
You may change to left to right using the left to right direction command. The result is often better with this direction.
@startuml left to right direction user1 --> (Usecase 1) user2 --> (Usecase 2) @enduml
32 of 96
2.10 Skinparam
2.10 Skinparam
You can use the skinparam command to change colors and fonts for the drawing. You can use this command : In the diagram denition, like any other commands, In an included le, In a conguration le, provided in the command line or the ANT task.
@startuml skinparam skinparam skinparam skinparam skinparam usecaseBackgroundColor DarkSeaGreen usecaseArrowColor Olive actorBorderColor black usecaseBorderColor DarkSlateGray usecaseActorFontName Courier
User << Human >> :Main Database: as MySql << Application >> (Start) << One Shot >> (Use the application) as (Use) << Main >> User -> (Start) User --> (Use) MySql --> (Use) @enduml
33 of 96
3 CLASS DIAGRAM
3 Class Diagram
3.1 Relations between classes
Relations between classes are dened using the following symbols : Extension Composition Agregation <|-*-o--
It is possible to replace -- by .. to have a dotted line. Knowing thoses rules, it is possible to draw the following drawings:
@startuml Class01 <|-- Class02 Class03 *-- Class04 Class05 o-- Class06 Class07 .. Class08 Class09 -- Class10 Class11 <|.. Class12 Class13 --> Class14 Class15 ..> Class16 Class17 ..|> Class18 Class19 <--* Class20 @enduml
34 of 96
3 CLASS DIAGRAM
35 of 96
3 CLASS DIAGRAM
36 of 96
3 CLASS DIAGRAM
You can turn o this feature using the skinparam classAttributeIconSize 0 command :
@startuml skinparam classAttributeIconSize 0 class Dummy { -field1 #field2 method1 () +method2 () } @enduml
37 of 96
3 CLASS DIAGRAM
38 of 96
3 CLASS DIAGRAM
39 of 96
3 CLASS DIAGRAM
40 of 96
3 CLASS DIAGRAM
41 of 96
3 CLASS DIAGRAM
42 of 96
3 CLASS DIAGRAM
43 of 96
3.11 Packages
3 CLASS DIAGRAM
3.11 Packages
You can dene a package using the package keyword, and optionally declare a background color for your package (Using a html color code or name). When you declare classes, they are automatically put in the last used package, and you can close the package denition using the end package keyword. You can also use brackets { }. Note that package denitions can be nested.
@startuml package "Classic Collections" #DDDDDD { Object <|-- ArrayList } package net.sourceforge.plantuml #Snow Object <|-- Demo1 Demo1 *- Demo2 end package @enduml
You can also dene links between packages, like in the following example:
@startuml package foo1.foo2 end package package foo1.foo2.foo3 { class Object } foo1.foo2 +-- foo1.foo2.foo3 @enduml
44 of 96
3.12 Namespaces
3 CLASS DIAGRAM
3.12 Namespaces
In packages, the name of a class is the unique identier of this class. It means that you cannot have two classes with the very same name in dierent 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 qualied with a starting dot. Note that you dont have to explicitly create namespace : a fully qualied class is automatically put in the right namespace.
@startuml class BaseClass namespace net.dummy #DDDDDD .BaseClass <|-- Person Meeting o-- Person .BaseClass <|- Meeting end namespace namespace net.foo { net.dummy.Person <|- Person .BaseClass <|-- Person net.dummy.Meeting o-- Person } BaseClass <|-- net.unused.Person @enduml
45 of 96
3 CLASS DIAGRAM
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
46 of 96
3 CLASS DIAGRAM
You can shorten the arrow by using only the rst character of the direction (for example, -d- instead of -down-) or the two rst characters (-do-) Please note that you should not abuse this functionnality : GraphViz gives usually good results without tweaking.
47 of 96
3 CLASS DIAGRAM
48 of 96
3.17 Skinparam
3 CLASS DIAGRAM
3.17 Skinparam
You can use the skinparam command to change colors and fonts for the drawing. You can use this command : In the diagram denition, like any other commands, In an included le, In a conguration le, provided in the command line or the ANT task.
@startuml skinparam skinparam skinparam skinparam classBackgroundColor PaleGreen classArrowColor SeaGreen classBorderColor SpringGreen stereotypeCBackgroundColor YellowGreen
Class01 "1" *-- "many" Class02 : contains Class03 o-- Class04 : agregation @enduml
49 of 96
3 CLASS DIAGRAM
50 of 96
4 ACTIVITY DIAGRAM
4 Activity Diagram
4.1 Simple Activity
You can use (*) for the starting point and ending point of the activity diagram. Use --> for arrows. Example:
@startuml (*) --> "First Activity" "First Activity" --> (*) @enduml
51 of 96
4 ACTIVITY DIAGRAM
You can shorten the arrow by using only the rst character of the direction (for example, -d- instead of -down-) or the two rst characters (-do-). Please note that you should not abuse this functionnality : GraphViz gives usually good results without tweaking.
52 of 96
4.4 Branches
4 ACTIVITY DIAGRAM
4.4 Branches
You can use if/then/else keywords to dene branches.
@startuml (*) --> "Initialisation" if "Some Test" then -->[true] "Some Activity" --> "Another activity" -right -> (*) else ->[false] "Something else" -->[Ending process] (*) endif @enduml
53 of 96
4 ACTIVITY DIAGRAM
54 of 96
4.6 Synchronization
4 ACTIVITY DIAGRAM
4.6 Synchronization
You can use === code === to display synchronization bars.
@startuml (*) --> ===B1=== --> "Parallel Activity 1" --> ===B2=== ===B1=== --> "Parallel Activity 2" --> ===B2=== --> (*) @enduml
55 of 96
4 ACTIVITY DIAGRAM
56 of 96
4.8 Notes
4 ACTIVITY DIAGRAM
4.8 Notes
You can add notes on a activity using the commands: note left, note right, note top, note bottom, just after the description of the activity you want to note. If you want to put a note on the starting point, dene the note at the very beginning of the diagram description. You can also have a note on several lines, using the end note keywords.
@startuml (*) --> "Some Activity" note right: This activity has to be defined "Some Activity" --> (*) note left This note is on several lines end note @enduml
57 of 96
4.9 Partition
4 ACTIVITY DIAGRAM
4.9 Partition
You can dene 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 denition using the end partition keyword.
@startuml partition Conductor (*) --> "Climbs on Platform" --> === S1 === --> Bows end partition partition Audience #LightSkyBlue === S1 === --> Applauds partition Conductor Bows --> === S2 === --> WavesArmes Applauds --> === S2 === end partition partition Orchestra #CCCCEE WavesArmes --> Introduction --> "Play music" end partition @enduml
58 of 96
4 ACTIVITY DIAGRAM
59 of 96
4.11 Skinparam
4 ACTIVITY DIAGRAM
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 denition, like any other commands, In an included le, In a conguration le, provided in the command line or the ANT task.
@startuml skinparam skinparam skinparam skinparam skinparam skinparam skinparam (*) --> --> --> --> --> backgroundColor #AAFFFF activityStartColor red activityBarColor SaddleBrown activityEndColor Silver activityBackgroundColor Peru activityBorderColor Peru activityFontName Impact
--> "Climbs on Platform" === S1 === Bows === S2 === WavesArmes (*)
@enduml
60 of 96
4 ACTIVITY DIAGRAM
61 of 96
4 ACTIVITY DIAGRAM
62 of 96
5 COMPONENT DIAGRAM
5 Component Diagram
5.1 Components
Components must be bracketed. You can also use the component keyword to denes a component. And you can dene an alias, using the as keyword. This alias will be used latter, when dening relations.
@startuml [First component] [Another component] as Comp2 component Comp3 component [Last\ncomponent] as Comp4 @enduml
63 of 96
5.2 Interfaces
5 COMPONENT DIAGRAM
5.2 Interfaces
Interface can be dened using the () symbol (because this looks like a circle). You can also use the interface keyword to denes a usecase. And you can dene an alias, using the as keyword. This alias will be used latter, when dening relations. We will see latter that interface declaration is optional.
@startuml () "First Interface" () "Another interface" as Interf2 interface Interf3 interface "Last\ninterface" as Interf4 @enduml
64 of 96
5 COMPONENT DIAGRAM
65 of 96
5 COMPONENT DIAGRAM
66 of 96
5 COMPONENT DIAGRAM
67 of 96
5 COMPONENT DIAGRAM
It is also possible to change arrow direction by adding left, right, up or down keywords inside the arrow:
@startuml [Component] [Component] [Component] [Component] @enduml -left -> left -right -> right -up -> up -down -> down
68 of 96
5 COMPONENT DIAGRAM
You can shorten the arrow by using only the rst character of the direction (for example, -d- instead of -down-) or the two rst characters (-do-). Please note that you should not abuse this functionnality : GraphViz gives usually good results without tweaking.
69 of 96
5.8 Skinparam
5 COMPONENT DIAGRAM
5.8 Skinparam
You can use the skinparam command to change colors and fonts for the drawing. You can use this command : In the diagram denition, like any other commands, In an included le, In a conguration le, provided in the command line or the ANT task.
@startuml skinparam skinparam skinparam skinparam skinparam skinparam skinparam skinparam skinparam componentFontSize 13 interfaceBackgroundColor RosyBrown interfaceBorderColor black componentBackgroundColor gold componentBorderColor orange componentArrowColor #FF6655 componentArrowFontColor #777777 componentFontName Courier componentArrowFontName Impact
() "Data Access" as DA DA - [First Component] [First Component] ..> () HTTP : use @enduml
70 of 96
6 STATE DIAGRAM
6 State Diagram
6.1 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
71 of 96
6 STATE DIAGRAM
72 of 96
6 STATE DIAGRAM
73 of 96
6 STATE DIAGRAM
74 of 96
6 STATE DIAGRAM
You can shorten the arrow by using only the rst character of the direction (for example, -d- instead of -down-) or the two rst characters (-do-). Please note that you should not abuse this functionnality : GraphViz gives usually good results without tweaking.
75 of 96
6.6 Note
6 STATE DIAGRAM
6.6 Note
You can alse dene notes using: note left of, note right of, note top of, note bottom of keywords. You can also dene 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
76 of 96
6 STATE DIAGRAM
77 of 96
OBJECTS DIAGRAM
7 Objects Diagram
7.1 Denition of objects
You dene instance of objects using the object keywords.
@startuml object firstObject object "My Second Object" as o2 @enduml
It is possible to replace -- by .. to have a dotted line. Knowing thoses rules, it is possible to draw the following drawings:
@startuml object Object01 object Object02 object Object03 object Object04 object Object05 object Object06 object Object07 object Object08 Object01 Object03 Object05 Object07 @enduml <|-- Object02 *-- Object04 o-- "4" Object06 .. Object08 : some labels
78 of 96
OBJECTS DIAGRAM
@enduml
79 of 96
8 COMMON COMMANDS
8 Common commands
8.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 keywork. As for title, it is possible to dene 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 > This is a demonstration diagram. Do not use in production. endheader center footer Generated for demonstration @enduml
80 of 96
8.2 Zoom
8 COMMON COMMANDS
8.2 Zoom
You can use the scale command to zoom the generated image. You can use either a number or a fraction to dene 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 t inside the specied dimension. scale 1.5, scale 2/3, scale 200 width, scale 200 height, scale 200*100
@startuml scale 180*90 Bob ->Alice : hello @enduml
81 of 96
8.3 Rotation
8 COMMON COMMANDS
8.3 Rotation
Sometimes, and especially for printing, you may want to rotate the generated image, so that it ts better in the page. You can use the rotate command for this.
@startuml rotate title Simple Usecase\nwith one actor "Use the application" as (Use) User -> (Use) @enduml
82 of 96
You can use this command : In the diagram denition, like any other commands, In an included le (see Preprocessing), In a conguration le, provided in the command line or the ANT task.
83 of 96
9.2 Color
9.2 Color
You can use either standard color name or RGB code.
Parameter name backgroundColor activityArrowColor activityBackgroundColor activityBorderColor activityStartColor activityEndColor activityBarColor usecaseArrowColor actorBackgroundColor actorBorderColor usecaseBackgroundColor usecaseBorderColor classArrowColor classBackgroundColor classBorderColor packageBackgroundColor packageBorderColor stereotypeCBackgroundColor stereotypeABackgroundColor stereotypeIBackgroundColor stereotypeEBackgroundColor componentArrowColor componentBackgroundColor componentBorderColor interfaceBackgroundColor interfaceBorderColor noteBackgroundColor noteBorderColor stateBackgroundColor stateBorderColor stateArrowColor sequenceArrowColor sequenceActorBackgroundColor sequenceActorBorderColor sequenceGroupBackgroundColor sequenceLifeLineBackgroundColor sequenceLifeLineBorderColor sequenceParticipantBackgroundColor sequenceParticipantBorderColor
Default Value
white #A80036 #FEFECE #A80036 black black black #A80036 #FEFECE #A80036 #FEFECE #A80036 #A80036 #FEFECE #A80036 #FEFECE #A80036 #ADD1B2 #A9DCDF #B4A7E5 #EB937F #A80036 #FEFECE #A80036 #FEFECE #A80036 #FBFB77 #A80036 #FEFECE #A80036 #A80036 #A80036 #FEFECE #A80036 #EEEEEE white #A80036 #FEFECE #A80036
Color
Comment
Background of the page Color of arrows in activity diagrams Background of activities Color of activity borders Starting circle in activity diagrams Ending circle in activity diagrams Synchronization bar in activity diagrams Color of arrows in usecase diagrams Heads color of actor in usecase diagrams Color of actor borders in usecase diagrams Background of usecases Color of usecase borders in usecase diagrams Color of arrows in class diagrams Background of classes/interface/enum in class diagrams Borders of classes/interface/enum in class diagrams Background of packages in class diagrams Borders of packages in class diagrams Background of class spots in class diagrams Background of abstract class spots in class diagrams Background of interface spots in class diagrams Background of enum spots in class diagrams Color of arrows in component diagrams Background of components Borders of components Background of interface in component diagrams Border of interface in component diagrams Background of notes Border of notes Background of states in state diagrams Border of states in state diagrams Colors of arrows in state diagrams Color of arrows in sequence diagrams Heads color of actor in sequence diagrams Border of actor in sequence diagrams Header color of alt/opt/loop in sequence diagrams Background of life line in sequence diagrams Border of life line in sequence diagrams Background of participant in sequence diagrams Border of participant in sequence diagrams
84 of 96
You can also change the default font for all fonts using skinparam defaultFontName. Example:
skinparam defaultFontName Aapex
Please note the fontname is highly system dependant, so do not over use it, if you look for portability. Parameter Name activityFontColor activityFontSize activityFontStyle activityFontName activityArrowFontColor activityArrowFontSize activityArrowFontStyle activityArrowFontName circledCharacterFontColor circledCharacterFontSize circledCharacterFontStyle circledCharacterFontName circledCharacterRadius classArrowFontColor classArrowFontSize classArrowFontStyle classArrowFontName classAttributeFontColor classAttributeFontSize classAttributeIconSize classAttributeFontStyle classAttributeFontName classFontColor classFontSize classFontStyle classFontName classStereotypeFontColor classStereotypeFontSize classStereotypeFontStyle classStereotypeFontName componentFontColor componentFontSize componentFontStyle componentFontName componentStereotypeFontColor componentStereotypeFontSize componentStereotypeFontStyle componentStereotypeFontName componentArrowFontColor componentArrowFontSize componentArrowFontStyle componentArrowFontName Default Value black 14 plain black 13 plain black 17 bold Courier 11 black 10 plain black 10 10 plain black 12 plain black 12 italic black 14 plain black 14 italic black 13 plain Comment
85 of 96
noteFontColor noteFontSize noteFontStyle noteFontName packageFontColor packageFontSize packageFontStyle packageFontName sequenceActorFontColor sequenceActorFontSize sequenceActorFontStyle sequenceActorFontName sequenceDividerFontColor sequenceDividerFontSize sequenceDividerFontStyle sequenceDividerFontName sequenceArrowFontColor sequenceArrowFontSize sequenceArrowFontStyle sequenceArrowFontName sequenceGroupingFontColor sequenceGroupingFontSize sequenceGroupingFontStyle sequenceGroupingFontName sequenceGroupingHeaderFontColor sequenceGroupingHeaderFontSize sequenceGroupingHeaderFontStyle sequenceGroupingHeaderFontName sequenceParticipantFontColor sequenceParticipantFontSize sequenceParticipantFontStyle sequenceParticipantFontName sequenceTitleFontColor sequenceTitleFontSize sequenceTitleFontStyle sequenceTitleFontName titleFontColor titleFontSize titleFontStyle titleFontName stateFontColor stateFontSize stateFontStyle stateFontName stateArrowFontColor stateArrowFontSize stateArrowFontStyle stateArrowFontName stateAttributeFontColor stateAttributeFontSize stateAttributeFontStyle stateAttributeFontName usecaseFontColor usecaseFontSize usecaseFontStyle usecaseFontName
black 13 plain black 14 plain black 13 plain black 13 bold black 13 plain black 11 plain black 13 plain black 13 plain black 13 plain black 18 plain black 14 plain black 13 plain black 12 plain black 14 plain
86 of 96
usecaseStereotypeFontColor usecaseStereotypeFontSize usecaseStereotypeFontStyle usecaseStereotypeFontName usecaseActorFontColor usecaseActorFontSize usecaseActorFontStyle usecaseActorFontName usecaseActorStereotypeFontColor usecaseActorStereotypeFontSize usecaseActorStereotypeFontStyle usecaseActorStereotypeFontName usecaseArrowFontColor usecaseArrowFontSize usecaseArrowFontStyle usecaseArrowFontName footerFontColor footerFontSize footerFontStyle footerFontName headerFontColor headerFontSize headerFontStyle headerFontName
black 14 italic black 14 plain black 14 italic black 13 plain black 10 plain black 10 plain
87 of 96
88 of 96
10 PREPROCESSING
10 Preprocessing
Some minor preprocessing capabilities are included in PlantUML, and available for all diagrams. Thoses 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 le List.iuml can be included in many diagrams, and any modication in this le will change all diagrams that include it.
89 of 96
10 PREPROCESSING
class USER << TABLE >> class ACCOUNT << TABLE >> class UID << SEQUENCE >> USER "1" -- "*" ACCOUNT USER -> UID @enduml
Of course, you can use the !include directive to dene all your constants in a single le that you include in your diagram. Constant can be undened with the !undef XXX directive.
90 of 96
10.3 Conditions
10 PREPROCESSING
10.3 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 dened before. You can also provide a !else part which will be included if the constant has not been dened.
@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 dened.
91 of 96
11 INTERNATIONALIZATION
11 Internationalization
The PlantUML language use letters to dene 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
11.1 Charset
The default charset used when reading the text les containing the UML text description is system dependant. Normally, it should just be ne, 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
92 of 96
11 INTERNATIONALIZATION
<plantuml dir ="./ src" charset ="UTF -8" /> </target >
Depending of your Java installation, the following charset should be available: ISO-8859-1, UTF-8, UTF-16BE, UTF-16LE, UTF-16.
93 of 96
12 COLOR NAMES
12 Color Names
Here is the list of colors recognized by PlantUML. Note that color names are case insensitive.
AliceBlue AntiqueWhite Aquamarine Aqua Azure Beige Bisque Black BlanchedAlmond BlueViolet Blue Brown BurlyWood CadetBlue Chartreuse Chocolate Coral CornowerBlue Cornsilk Crimson Cyan DarkBlue DarkCyan DarkGoldenRod DarkGray DarkGreen DarkKhaki DarkMagenta DarkOliveGreen DarkOrchid DarkRed DarkSalmon DarkSeaGreen DarkSlateBlue DarkSlateGray DarkTurquoise DarkViolet Darkorange DeepPink DeepSkyBlue DimGray DodgerBlue FireBrick FloralWhite ForestGreen Fuchsia Gainsboro
GhostWhite GoldenRod Gold Gray GreenYellow Green HoneyDew HotPink IndianRed Indigo Ivory Khaki LavenderBlush Lavender LawnGreen LemonChion LightBlue LightCoral LightCyan LightGoldenRodYellow LightGreen LightGrey LightPink LightSalmon LightSeaGreen LightSkyBlue LightSlateGray LightSteelBlue LightYellow LimeGreen Lime Linen Magenta Maroon MediumAquaMarine MediumBlue MediumOrchid MediumPurple MediumSeaGreen MediumSlateBlue MediumSpringGreen MediumTurquoise MediumVioletRed MidnightBlue MintCream MistyRose Moccasin
NavajoWhite Navy OldLace OliveDrab Olive OrangeRed Orange Orchid PaleGoldenRod PaleGreen PaleTurquoise PaleVioletRed PapayaWhip PeachPu Peru Pink Plum PowderBlue Purple Red RosyBrown RoyalBlue SaddleBrown Salmon SandyBrown SeaGreen SeaShell Sienna Silver SkyBlue SlateBlue SlateGray Snow SpringGreen SteelBlue Tan Teal Thistle Tomato Turquoise Violet Wheat WhiteSmoke White YellowGreen Yellow
94 of 96
CONTENTS
CONTENTS
Contents
1 Sequence Diagram 1.1 Basic examples . . . . . . . . . . . 1.2 Declaring participant . . . . . . . . 1.3 Use non-letters in participants . . . 1.4 Message to Self . . . . . . . . . . . 1.5 Message sequence numbering . . . 1.6 Title . . . . . . . . . . . . . . . . . 1.7 Splitting diagrams . . . . . . . . . 1.8 Grouping message . . . . . . . . . 1.9 Notes on messages . . . . . . . . . 1.10 Some other notes . . . . . . . . . . 1.11 Formatting using HTML . . . . . . 1.12 Divider . . . . . . . . . . . . . . . 1.13 Lifeline Activation and Destruction 1.14 Participant creation . . . . . . . . 1.15 Incoming and outgoing messages . 1.16 Stereotypes and Spots . . . . . . . 1.17 More information on titles . . . . . 1.18 Participants englober . . . . . . . . 1.19 Removing Footer . . . . . . . . . . 1.20 Skinparam . . . . . . . . . . . . . . 1.21 Skin . . . . . . . . . . . . . . . . . 2 Use 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 2.10 Case Diagram Usecases . . . . . . . . . . Actors . . . . . . . . . . . Basic example . . . . . . . Extension . . . . . . . . . Using notes . . . . . . . . Stereotypes . . . . . . . . Changing arrows direction Title the diagram . . . . . Left to right direction . . Skinparam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 2 3 3 4 6 7 8 9 10 11 12 13 15 16 17 18 20 21 22 23 24 24 25 26 27 28 29 30 31 32 33 34 34 35 36 37 38 39 40 41 42 43 44 45 46 47 47 48 49 50
3 Class Diagram 3.1 Relations between classes . 3.2 Label on relations . . . . . 3.3 Adding methods . . . . . . 3.4 Dening visibility . . . . . . 3.5 Notes and stereotypes . . . 3.6 More on notes . . . . . . . . 3.7 Abstract class and interface 3.8 Using non-letters . . . . . . 3.9 Hide attributes, methods... 3.10 Specic Spot . . . . . . . . 3.11 Packages . . . . . . . . . . . 3.12 Namespaces . . . . . . . . . 3.13 Changing arrows direction . 3.14 Lollipop interface . . . . . . 3.15 Title the diagram . . . . . . 3.16 Association classes . . . . . 3.17 Skinparam . . . . . . . . . . 3.18 Splitting large les . . . . .
95 of 96
CONTENTS
CONTENTS
4 Activity Diagram 4.1 Simple Activity . . . . . . 4.2 Label on arrows . . . . . . 4.3 Changing arrow direction 4.4 Branches . . . . . . . . . . 4.5 More on Branches . . . . 4.6 Synchronization . . . . . . 4.7 Long activity description . 4.8 Notes . . . . . . . . . . . 4.9 Partition . . . . . . . . . . 4.10 Title the diagram . . . . . 4.11 Skinparam . . . . . . . . . 4.12 Complete example . . . . 5 Component Diagram 5.1 Components . . . . . . . . 5.2 Interfaces . . . . . . . . . 5.3 Basic example . . . . . . . 5.4 Using notes . . . . . . . . 5.5 Grouping Components . . 5.6 Changing arrows direction 5.7 Title the diagram . . . . . 5.8 Skinparam . . . . . . . . . 6 State Diagram 6.1 Simple State . . 6.2 Composite state 6.3 Long name . . . 6.4 Concurrent state 6.5 Arrow direction . 6.6 Note . . . . . . . 6.7 More in notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
51 51 51 52 53 54 55 56 57 58 59 60 61 63 63 64 65 66 67 68 69 70 71 71 72 73 74 75 76 77 78 78 78 79 80 80 81 82 83 83 84 85 88 89 89 90 91 92 92 93 94
7 Objects Diagram 7.1 Denition of objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.2 Relations between objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3 Adding elds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Common commands 8.1 Footer and header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.2 Zoom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.3 Rotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Changing fonts and colors 9.1 Usage . . . . . . . . . . . 9.2 Color . . . . . . . . . . . . 9.3 Font color, name and size 9.4 Black and White . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10 Preprocessing 10.1 Including les . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.2 Constant denition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.3 Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Internationalization 11.1 Charset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Font Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Color Names
96 of 96