97
Drawing UML with PlantUML Language Reference Guide (Version 5737) 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 defined using a simple and intuitive language.

PlantUML Language Reference Guide.pdf

  • Upload
    devaert

  • View
    299

  • Download
    13

Embed Size (px)

Citation preview

Page 1: PlantUML Language Reference Guide.pdf

Drawing UML with PlantUML

Language Reference Guide(Version 5737)

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 defined using a simple and intuitive language.

Page 2: PlantUML Language Reference Guide.pdf

1 SEQUENCE DIAGRAM

1 Sequence Diagram1.1 Basic examplesEvery UML description must start by @startuml and must finish 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:@startumlAlice -> Bob: Authentication RequestBob --> Alice: Authentication ResponseAlice -> Bob: Another authentication RequestAlice <-- Bob: another authentication Response@enduml

To use asynchronous message, you can use ”->>” or ”<<-”.

@startumlAlice -> Bob: synchronous callAlice ->> Bob: asynchronous call@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 1 of 96

Page 3: PlantUML Language Reference Guide.pdf

1.2 Declaring participant 1 SEQUENCE DIAGRAM

1.2 Declaring participantIt is possible to change participant order using the participant keyword.

It is also possible to use the actor keyword to use a stickman instead of a box for the participant.

You can rename a participant using the as keyword.

You can also change the background color of actor or participant, using html code or color name.

Everything that starts with simple quote ' is a comment.

@startumlactor Bob #red' The only difference between actor and participant is the drawingparticipant Aliceparticipant "I have a really\nlong name" as L #99FF99

Alice->Bob: Authentication RequestBob->Alice: Authentication ResponseBob->L: Log transaction@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 2 of 96

Page 4: PlantUML Language Reference Guide.pdf

1.3 Use non-letters in participants 1 SEQUENCE DIAGRAM

1.3 Use non-letters in participantsYou can use quotes to define participants. And you can use the as keyword to give an alias to thosesparticipants.@startumlAlice -> "Bob()" : Hello"Bob()" -> "This is very\nlong" as Long' You can also declare:' "Bob()" -> Long as "This is very\nlong"Long --> "Bob()" : ok@enduml

1.4 Message to SelfA participant can send a message to itself.

It is also possible to have multilines using \n.

@startuml

Alice->Alice: This is a signal to self.\nIt also demonstrates\nmultiline \ntext

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 3 of 96

Page 5: PlantUML Language Reference Guide.pdf

1.5 Message sequence numbering 1 SEQUENCE DIAGRAM

1.5 Message sequence numberingThe keyword autonumber is used to automatically add number to messages.@startumlautonumberBob -> Alice : Authentication RequestBob <- Alice : Authentication Response@enduml

You can specify

• a startnumber with ”autonumber 'start'” ,

• an increment with ”autonumber 'start' 'increment'”

@startuml

autonumberBob -> Alice : Authentication RequestBob <- Alice : Authentication Response

autonumber 15Bob -> Alice : Another authentication RequestBob <- Alice : Another authentication Response

autonumber 40 10Bob -> Alice : Yet another authentication RequestBob <- Alice : Yet another authentication Response

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 4 of 96

Page 6: PlantUML Language Reference Guide.pdf

1.5 Message sequence numbering 1 SEQUENCE DIAGRAM

You can specify a format for your number by using between double-quote. The formatting is donewith 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 RequestBob <- Alice : Authentication Response

autonumber 15 "<b>(<u>##</u>)"Bob -> Alice : Another authentication RequestBob <- Alice : Another authentication Response

autonumber 40 10 "<font color=red><b>Message 0 "Bob -> Alice : Yet another authentication RequestBob <- Alice : Yet another authentication Response

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 5 of 96

Page 7: PlantUML Language Reference Guide.pdf

1.6 Title 1 SEQUENCE DIAGRAM

1.6 TitleThe title keywords is used to put a title.@startuml

title Simple communication example

Alice -> Bob: Authentication RequestBob --> Alice: Authentication Response

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 6 of 96

Page 8: PlantUML Language Reference Guide.pdf

1.7 Splitting diagrams 1 SEQUENCE DIAGRAM

1.7 Splitting diagramsThe newpage keyword is used to split a diagram into several images. You can put a title for the new pagejust after the newpage keyword. This is very handy to print long diagram on several pages.@startumlAlice -> Bob : message 1Alice -> Bob : message 2

newpage

Alice -> Bob : message 3Alice -> Bob : message 4

newpage A title for the\nlast page

Alice -> Bob : message 5Alice -> Bob : message 6@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 7 of 96

Page 9: PlantUML Language Reference Guide.pdf

1.8 Grouping message 1 SEQUENCE DIAGRAM

1.8 Grouping messageIt is possible to group messages together using the following keywords:

• alt/else

• opt

• loop

• par

• break

• critical

• group, followed by a text to be displayedIt is possible a add a text that will be displayed into the header. The end keyword is used to close

the group. Note that it is possible to nest groups.@startumlAlice -> Bob: Authentication Requestalt successful case

Bob -> Alice: Authentication Acceptedelse some kind of failure

Bob -> Alice: Authentication Failuregroup My own label

Alice -> Log : Log attack startloop 1000 times

Alice -> Bob: DNS AttackendAlice -> Log : Log attack end

endelse Another type of failure

Bob -> Alice: Please repeatend@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 8 of 96

Page 10: PlantUML Language Reference Guide.pdf

1.9 Notes on messages 1 SEQUENCE DIAGRAM

1.9 Notes on messagesIt is possible to put notes on message using :

• note left or

• note right keywords just after the message.

You can have multilines note using the end note keyword.@startumlAlice->Bob : hellonote left: this is a first note

Bob->Alice : oknote right: this is another note

Bob->Bob : I am thinkingnote left

a notecan also be definedon several lines

end note@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 9 of 96

Page 11: PlantUML Language Reference Guide.pdf

1.10 Some other notes 1 SEQUENCE DIAGRAM

1.10 Some other notesIt is also possible to place notes relative to participant with:

• note left of,

• note right of or

• note over keywords.

It is possible to highlight a note by changing its background color. You can also have multilines noteusing the end note keywords.@startumlparticipant Aliceparticipant Bobnote left of Alice #aqua

This is displayedleft of Alice.

end note

note right of Alice: This is displayed right of Alice.

note over Alice: This is displayed over Alice.

note over Alice, Bob #FFAAAA: This is displayed\n over Bob and Alice.

note over Bob, AliceThis is yet anotherexample ofa long note.

end note@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 10 of 96

Page 12: PlantUML Language Reference Guide.pdf

1.11 Formatting using HTML 1 SEQUENCE DIAGRAM

1.11 Formatting using HTMLIt is also possible to use few html tags like :

• <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

@startumlparticipant Aliceparticipant "The <b>Famous</b> Bob" as Bob

Alice -> Bob : A <i>well formated</i> messagenote right of Alice

This is <size:18>displayed</size><u>left of</u> Alice.

end notenote left of Bob

This is <color:#118888>displayed</color><b><color:purple>left of</color> <strike>Alice</strike> Bob</b>.

end notenote over Alice, Bob

This is hosted by <img:sourceforge.jpg>end note

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 11 of 96

Page 13: PlantUML Language Reference Guide.pdf

1.12 Divider 1 SEQUENCE DIAGRAM

1.12 DividerIf you want, you can split a diagram using ”==” separator to divide your diagram into logical steps.@startuml

== Initialisation ==

Alice -> Bob: Authentication RequestBob --> Alice: Authentication Response

== Repetition ==

Alice -> Bob: Another authentication RequestAlice <-- Bob: another authentication Response

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 12 of 96

Page 14: PlantUML Language Reference Guide.pdf

1.13 Lifeline Activation and Destruction 1 SEQUENCE DIAGRAM

1.13 Lifeline Activation and DestructionThe activate and deactivate are used to denote participant activation.

Once a participant is activated, its lifeline appears.

The activate and deactivate apply on the previous message.

The destroy denote the end of the lifeline of a participant.

@startumlparticipant User

User -> A: DoWorkactivate A

A -> B: << createRequest >>activate B

B -> C: DoWorkactivate CC --> B: WorkDonedestroy C

B --> A: RequestCreateddeactivate B

A -> User: Donedeactivate A

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 13 of 96

Page 15: PlantUML Language Reference Guide.pdf

1.13 Lifeline Activation and Destruction 1 SEQUENCE DIAGRAM

Nested lifeline can be used, and it is possible to add a color on the lifeline.@startumlparticipant User

User -> A: DoWorkactivate A #FFBBBB

A -> A: Internal callactivate A #DarkSalmon

A -> B: << createRequest >>activate B

B --> A: RequestCreateddeactivate Bdeactivate AA -> User: Donedeactivate A

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 14 of 96

Page 16: PlantUML Language Reference Guide.pdf

1.14 Participant creation 1 SEQUENCE DIAGRAM

1.14 Participant creationYou can use the create keyword just before the first reception of a message to emphasize the fact thatthis message is actually creating this new object.@startumlBob -> Alice : hello

create OtherAlice -> Other : new

create StringAlice -> Stringnote right : You can also put notes!

Alice --> Bob : ok

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 15 of 96

Page 17: PlantUML Language Reference Guide.pdf

1.15 Incoming and outgoing messages 1 SEQUENCE DIAGRAM

1.15 Incoming and outgoing messagesYou can use incoming or outgoing arrows if you want to focus on a part of the diagram.

Use square brackets to denotate the left ”[” or the right ”]” side of the diagram.

@startuml[-> A: DoWork

activate A

A -> A: Internal callactivate A

A ->] : << createRequest >>

A<--] : RequestCreateddeactivate A[<- A: Donedeactivate A@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 16 of 96

Page 18: PlantUML Language Reference Guide.pdf

1.16 Stereotypes and Spots 1 SEQUENCE DIAGRAM

1.16 Stereotypes and SpotsIt is possible to add stereotypes to participants using ”<<” and ”>>”. In the stereotype, you can add aspotted character in a colored circle using the syntax ”(X,color)”.@startuml

participant "Famous Bob" as Bob << Generated >>participant Alice << (C,#ADD1B2) Testable >> #EEEEEE

Bob->Alice: First message

@enduml

@startuml

participant Bob << (C,#ADD1B2) >>participant Alice << (C,#ADD1B2) >>

Bob->Alice: First message

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 17 of 96

Page 19: PlantUML Language Reference Guide.pdf

1.17 More information on titles 1 SEQUENCE DIAGRAM

1.17 More information on titlesYou can use some HTML tags in the title.@startuml

title <u>Simple</u> communication example

Alice -> Bob: Authentication RequestBob --> Alice: Authentication Response

@enduml

You can add newline using \n in the title description.@startuml

title <u>Simple</u> communication example\non several lines

Alice -> Bob: Authentication RequestBob --> Alice: Authentication Response

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 18 of 96

Page 20: PlantUML Language Reference Guide.pdf

1.17 More information on titles 1 SEQUENCE DIAGRAM

You can also define title on several lines using title and end title keywords.@startuml

title<u>Simple</u> communication exampleon <i>several</i> lines and using <font color=red>html</font>This is hosted by <img src=sourceforge.jpg>

end title

Alice -> Bob: Authentication RequestBob --> Alice: Authentication Response

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 19 of 96

Page 21: PlantUML Language Reference Guide.pdf

1.18 Participants englober 1 SEQUENCE DIAGRAM

1.18 Participants engloberIt is possible to draw a box arround some participants, using box and end box commands.

You can add an optional title or a optional background color, after the box keyword.

@startumlbox "Internal Service" #LightBlue

participant Bobparticipant Alice

end boxparticipant Other

Bob -> Alice : helloAlice -> Other : hello@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 20 of 96

Page 22: PlantUML Language Reference Guide.pdf

1.19 Removing Footer 1 SEQUENCE DIAGRAM

1.19 Removing FooterYou can use the hide footbox keywords to remove the footer of the diagram.@startuml

hide footboxtitle Footer removed

Alice -> Bob: Authentication RequestBob --> Alice: Authentication Response

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 21 of 96

Page 23: PlantUML Language Reference Guide.pdf

1.20 Skinparam 1 SEQUENCE DIAGRAM

1.20 SkinparamYou can use the skinparam command to change colors and fonts for the drawing. You can use thiscommand :

• 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.

@startumlskinparam backgroundColor #EEEBDC

skinparam sequenceArrowColor DeepSkyBlueskinparam sequenceParticipantBorderColor DeepSkyBlueskinparam sequenceActorBorderColor DeepSkyBlueskinparam sequenceLifeLineBorderColor blue

skinparam sequenceParticipantBackgroundColor DodgerBlueskinparam sequenceParticipantFontName Impactskinparam sequenceParticipantFontSize 17skinparam sequenceParticipantFontColor #A9DCDF

skinparam sequenceActorBackgroundColor aquaskinparam sequenceActorFontColor DeepSkyBlueskinparam sequenceActorFontSize 17skinparam sequenceActorFontName Aapex

skinparam sequenceLifeLineBackgroundColor #A9DCDF

actor Userparticipant "First Class" as Aparticipant "Second Class" as Bparticipant "Last Class" as CUser -> A: DoWorkactivate AA -> B: Create Requestactivate BB -> C: DoWorkactivate CC --> B: WorkDonedestroy CB --> A: Request Createddeactivate BA --> User: Donedeactivate A@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 22 of 96

Page 24: PlantUML Language Reference Guide.pdf

1.21 Skin 1 SEQUENCE DIAGRAM

1.21 SkinUse the keyword skin to change the look of the generated diagram. There are only two skins availabletoday (Rose, which is the default, and BlueModern), but it is possible to write your own skin.@startumlskin BlueModern

actor Userparticipant "First Class" as Aparticipant "Second Class" as Bparticipant "Last Class" as C

User -> A: DoWorkactivate A

A -> B: << createRequest >>activate B

B -> C: DoWorkactivate CC --> B: WorkDonedestroy C

B --> A: Request <u>Created</u>deactivate B

A --> User: Donedeactivate A

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 23 of 96

Page 25: PlantUML Language Reference Guide.pdf

2 USE CASE DIAGRAM

2 Use Case Diagram2.1 UsecasesUse cases are enclosed using between parentheses (because two parentheses looks like an oval).

You can also use the usecase keyword to define a usecase.

And you can define an alias, using the as keyword. This alias will be used latter, when defining relations.

@startuml

(First usecase)(Another usecase) as (UC2)usecase UC3usecase (Last\nusecase) as UC4

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 24 of 96

Page 26: PlantUML Language Reference Guide.pdf

2.2 Actors 2 USE CASE DIAGRAM

2.2 ActorsActor 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 than actor definitions is optional.

@startuml

:First Actor::Another\nactor: as Men2actor Men3actor :Last actor: as Men4

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 25 of 96

Page 27: PlantUML Language Reference Guide.pdf

2.3 Basic example 2 USE CASE DIAGRAM

2.3 Basic exampleTo link actors and use cases, the arrow ”-->” is used.

The more dashes ”-” in the arrow, the longer the arrow.

You can add a label on the arrow, by adding a ”:” character in the arrow definition.

In this example, you see that User has not been defined before, and is implicitly defined as an actor.

@startuml

User -> (Start)User --> (Use the application) : A small label

:Main Admin: ---> (Use the application) : This is\nyet another\nlabel

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 26 of 96

Page 28: PlantUML Language Reference Guide.pdf

2.4 Extension 2 USE CASE DIAGRAM

2.4 ExtensionIf 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

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 27 of 96

Page 29: PlantUML Language Reference Guide.pdf

2.5 Using notes 2 USE CASE DIAGRAM

2.5 Using notesYou can use the :

• note left of,

• note right of,

• note top of,

• note bottom of

keywords to define notes related to a single object. A note can be also define alone with the note keywords,then linked to other objects using the .. symbol.@startuml:Main Admin: as Admin(Use the application) as (Use)

User -> (Start)User --> (Use)

Admin ---> (Use)

note right of Admin : This is an example.

note right of (Use)A note can alsobe on several lines

end note

note "This note is connected\nto several objects." as N2(Start) .. N2N2 .. (Use)@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 28 of 96

Page 30: PlantUML Language Reference Guide.pdf

2.6 Stereotypes 2 USE CASE DIAGRAM

2.6 StereotypesYou can add stereotypes while defining actors and use cases using ”<<” and ”>>”.@startumlUser << Human >>:Main Database: as MySql << Application >>(Start) << One Shot >>(Use the application) as (Use) << Main >>

User -> (Start)User --> (Use)

MySql --> (Use)

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 29 of 96

Page 31: PlantUML Language Reference Guide.pdf

2.7 Changing arrows direction 2 USE CASE DIAGRAM

2.7 Changing arrows directionBy default, links between classes have two dashes -- and are verticaly oriented. It is possible to usehorizontal link by putting a single dash (or dot) like this:@startuml:user: --> (Use case 1):user: -> (Use case 2)@enduml

You can also change directions by reversing the link:@startuml(Use case 1) <.. :user:(Use case 2) <- :user:@enduml

It is also possible to change arrow direction by adding left, right, up or down keywords inside thearrow:@startuml:user: -left-> (dummyLeft):user: -right-> (dummyRight):user: -up-> (dummyUp):user: -down-> (dummyDown)@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 30 of 96

Page 32: PlantUML Language Reference Guide.pdf

2.8 Title the diagram 2 USE CASE DIAGRAM

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

Please note that you should not abuse this functionnality : GraphViz gives usually good resultswithout tweaking.

2.8 Title the diagramThe title keywords is used to put a title.

You can use title and end title keywords for a longer title, as in sequence diagrams.

@startumltitle Simple <b>Usecase</b>\nwith one actor

usecase (Use the application) as (Use)User -> (Use)

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 31 of 96

Page 33: PlantUML Language Reference Guide.pdf

2.9 Left to right direction 2 USE CASE DIAGRAM

2.9 Left to right directionThe general default behaviour when building diagram is top to bottom.@startuml'defaulttop to bottom directionuser1 --> (Usecase 1)user2 --> (Usecase 2)

@enduml

You may change to left to right using the left to right direction command. The result is oftenbetter with this direction.@startuml

left to right directionuser1 --> (Usecase 1)user2 --> (Usecase 2)

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 32 of 96

Page 34: PlantUML Language Reference Guide.pdf

2.10 Skinparam 2 USE CASE DIAGRAM

2.10 SkinparamYou can use the skinparam command to change colors and fonts for the drawing. You can use thiscommand :

• 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 usecaseBackgroundColor DarkSeaGreenskinparam usecaseArrowColor Oliveskinparam actorBorderColor blackskinparam usecaseBorderColor DarkSlateGrayskinparam 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

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 33 of 96

Page 35: PlantUML Language Reference Guide.pdf

3 CLASS DIAGRAM

3 Class Diagram3.1 Relations between classesRelations between classes are defined 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:

@startumlClass01 <|-- Class02Class03 *-- Class04Class05 o-- Class06Class07 .. Class08Class09 -- Class10Class11 <|.. Class12Class13 --> Class14Class15 ..> Class16Class17 ..|> Class18Class19 <--* Class20@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 34 of 96

Page 36: PlantUML Language Reference Guide.pdf

3.2 Label on relations 3 CLASS DIAGRAM

3.2 Label on relationsIt is possible a add a label on the relation, using ”:”, followed by the text of the label.

For cardinality, you can use double-quotes "" on each side of the relation.

@startuml

Class01 "1" *-- "many" Class02 : contains

Class03 o-- Class04 : agregation

Class05 --> "1" Class06

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 35 of 96

Page 37: PlantUML Language Reference Guide.pdf

3.3 Adding methods 3 CLASS DIAGRAM

3.3 Adding methodsTo declare fields and methods, you can use the symbol ”:” followed by the field’s or method’s name.

The system checks for parenthesis to choose between methods and fields.

@startumlObject <|-- ArrayList

Object : equals()ArrayList : Object[] elementDataArrayList : size()

@enduml

It is also possible to group between brackets {} all fields and methods.

@startumlclass Dummy {

String datavoid methods()

}@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 36 of 96

Page 38: PlantUML Language Reference Guide.pdf

3.4 Defining visibility 3 CLASS DIAGRAM

3.4 Defining visibilityWhen you define methods or fields, you can use characters to define the visibility of the corresponding

item:

- private# protected˜ package private+ public

@startumlclass Dummy {

-field1#field2˜method1()+method2()

}@enduml

You can turn off this feature using the skinparam classAttributeIconSize 0 command :

@startumlskinparam classAttributeIconSize 0class Dummy {

-field1#field2˜method1()+method2()

}@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 37 of 96

Page 39: PlantUML Language Reference Guide.pdf

3.5 Notes and stereotypes 3 CLASS DIAGRAM

3.5 Notes and stereotypesStereotypes are defined with the class keyword, ”<<” and ”>>”.

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

A note can be also define alone with the note keywords, then linked to other objects using the ”..”symbol.

@startumlclass Object << general >>Object <|--- ArrayList

note top of Object : In java, every class\nextends this one.

note "This is a floating note" as N1note "This note is connected\nto several objects." as N2Object .. N2N2 .. ArrayList

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 38 of 96

Page 40: PlantUML Language Reference Guide.pdf

3.6 More on notes 3 CLASS DIAGRAM

3.6 More on notesIt is also possible to use few html tags like :

• <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.@startuml

note top of ObjectIn java, every <u>class</u><b>extends</b><i>this</i> one.

end note

note as N1This <size:10>note</size> is <u>also</u><b><color:royalBlue>on several</color><s>words</s> linesAnd this is hosted by <img:sourceforge.jpg>

end note

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 39 of 96

Page 41: PlantUML Language Reference Guide.pdf

3.7 Abstract class and interface 3 CLASS DIAGRAM

3.7 Abstract class and interfaceYou can declare a class as abstract using ”abstract” or ”abstract class” keywords. The class will beprinted in italic.

You can use the interface and enum keywords too.@startuml

abstract class AbstractListabstract AbstractCollectioninterface Listinterface Collection

List <|-- AbstractListCollection <|-- AbstractCollection

Collection <|- ListAbstractCollection <|- AbstractListAbstractList <|-- ArrayList

ArrayList : Object[] elementDataArrayList : size()

enum TimeUnitTimeUnit : DAYSTimeUnit : HOURSTimeUnit : MINUTES

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 40 of 96

Page 42: PlantUML Language Reference Guide.pdf

3.8 Using non-letters 3 CLASS DIAGRAM

3.8 Using non-lettersIf you want to use non-letters in the class (or enum...) display, you can either :

• Use the as keyword in the class definition

• Put quotes "" around the class name

@startumlclass "This is my class" as class1class class2 as "It works this way too"

class2 *-- "foo/dummy" : use@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 41 of 96

Page 43: PlantUML Language Reference Guide.pdf

3.9 Hide attributes, methods... 3 CLASS DIAGRAM

3.9 Hide attributes, methods...You can parameterize the display of classes using the hide/show command.

The basic command is: hide empty members. This command will hide attributes or methods if theyare empty.

Instead of empty members, you can use:

• empty fields or empty attributes for empty fields,

• empty methods for empty methods,

• fields or attributes which will hide fields, even if they are described,

• methods wich will hide methods, even if they are described,

• members wich will hide fields and methods, even if they are described,

• circle for the circled character in front of class name,

• stereotype for the stereotype.

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.@startumlclass Dummy1 {

+myMethods()}

class Dummy2 {+hiddenMethod()

}

class Dummy3 <<Serializable>> {String name

}

hide membershide <<Serializable>> circleshow Dummy1 methodshow <<Serializable>> fields@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 42 of 96

Page 44: PlantUML Language Reference Guide.pdf

3.10 Specific Spot 3 CLASS DIAGRAM

3.10 Specific SpotUsually, a spotted character (C, I, E or A) is used for classes, interface, enum and abstract classes. Butyou can define your own spot for a class when you define the stereotype, adding a single character and acolor, like in this example:@startuml

class System << (S,#FF7700) Singleton >>class Date << (D,orchid) >>@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 43 of 96

Page 45: PlantUML Language Reference Guide.pdf

3.11 Packages 3 CLASS DIAGRAM

3.11 PackagesYou can define a package using the package keyword, and optionally declare a background color for yourpackage (Using a html color code or name). When you declare classes, they are automatically put in thelast used package, and you can close the package definition using the end package keyword. You canalso use brackets { }.

Note that package definitions can be nested.@startuml

package "Classic Collections" #DDDDDD {Object <|-- ArrayList

}

package net.sourceforge.plantuml #SnowObject <|-- Demo1Demo1 *- Demo2

end package

@enduml

You can also define links between packages, like in the following example:@startuml

package foo1.foo2end package

package foo1.foo2.foo3 {class Object

}

foo1.foo2 +-- foo1.foo2.foo3

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 44 of 96

Page 46: PlantUML Language Reference Guide.pdf

3.12 Namespaces 3 CLASS DIAGRAM

3.12 NamespacesIn packages, the name of a class is the unique identifier of this class. It means that you cannot have twoclasses with the very same name in different packages. In that case, you should use namespaces insteadof packages.

You can refer to classes from other namespaces by fully qualify them. Classes from the defaultnamespace are qualified with a starting dot.

Note that you don’t have to explicitly create namespace : a fully qualified class is automatically putin the right namespace.@startuml

class BaseClass

namespace net.dummy #DDDDDD.BaseClass <|-- PersonMeeting 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

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 45 of 96

Page 47: PlantUML Language Reference Guide.pdf

3.13 Changing arrows direction 3 CLASS DIAGRAM

3.13 Changing arrows directionBy default, links between classes have two dashes -- and are verticaly oriented. It is possible to usehorizontal link by putting a single dash (or dot) like this:@startumlRoom o- StudientRoom *-- Chair@enduml

You can also change directions by reversing the link:@startumlStudient -o RoomChair --* Room@enduml

It is also possible to change arrow direction by adding left, right, up or down keywords inside thearrow:@startumlfoo -left-> dummyLeftfoo -right-> dummyRightfoo -up-> dummyUpfoo -down-> dummyDown@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 46 of 96

Page 48: PlantUML Language Reference Guide.pdf

3.14 Lollipop interface 3 CLASS DIAGRAM

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

Please note that you should not abuse this functionnality : GraphViz gives usually good resultswithout tweaking.

3.14 Lollipop interfaceYou can also define lollipops interface on classes, using the following syntax:

• bar ()- foo,

• bar ()-- foo,

• foo -() bar

@startumlclass foobar ()- foo@enduml

3.15 Title the diagramThe title keywords is used to put a title. You can use title and end title keywords for a longer title, asin sequence diagrams.@startumltitle Simple <b>example</b>\nof title

Object <|-- ArrayList

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 47 of 96

Page 49: PlantUML Language Reference Guide.pdf

3.16 Association classes 3 CLASS DIAGRAM

3.16 Association classesYou can define association class after that a relation has been defined between two classes, like in thisexample:@startumlStudent : NameStudent "0..*" - "1..*" Course(Student, Course) .. Enrollment

Enrollment : drop()Enrollment : cancel()@enduml

You can define it in another direction:@startumlStudent : NameStudent "0..*" -- "1..*" Course(Student, Course) . Enrollment

Enrollment : drop()Enrollment : cancel()@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 48 of 96

Page 50: PlantUML Language Reference Guide.pdf

3.17 Skinparam 3 CLASS DIAGRAM

3.17 SkinparamYou can use the skinparam command to change colors and fonts for the drawing. You can use thiscommand :

• 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 classBackgroundColor PaleGreenskinparam classArrowColor SeaGreenskinparam classBorderColor SpringGreenskinparam stereotypeCBackgroundColor YellowGreen

Class01 "1" *-- "many" Class02 : contains

Class03 o-- Class04 : agregation

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 49 of 96

Page 51: PlantUML Language Reference Guide.pdf

3.18 Splitting large files 3 CLASS DIAGRAM

3.18 Splitting large filesSometimes, you will get some very large image files. You can use the ”page (hpages)x(vpages)”command to split the generated image into several files :

• hpages is a number that indicated the number of horizontal pages,

• vpages is a number that indicated the number of vertical pages.

@startuml' Split into 4 pagespage 2x2

class BaseClass

namespace net.dummy #DDDDDD.BaseClass <|-- PersonMeeting 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

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 50 of 96

Page 52: PlantUML Language Reference Guide.pdf

4 ACTIVITY DIAGRAM

4 Activity Diagram4.1 Simple ActivityYou can use (*) for the starting point and ending point of the activity diagram.

Use --> for arrows.

Example:@startuml(*) --> "First Activity""First Activity" --> (*)@enduml

4.2 Label on arrowsBy default, an arrow starts at the last used activity.

You can put a label on a arrow using brackets [ and ] just after the arrow definition.

@startuml(*) --> "First Activity"-->[You can put also labels] "Second Activity"--> (*)@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 51 of 96

Page 53: PlantUML Language Reference Guide.pdf

4.3 Changing arrow direction 4 ACTIVITY DIAGRAM

4.3 Changing arrow directionYou can use -> for horizontal arrows. It is possible to force arrow’s direction using the following syntax:

• -down-> (default arrow)

• -right-> or ->

• -left->

• -up->

@startuml(*) -up-> "First Activity"-right-> "Second Activity"--> "Third Activity"-left-> (*)@enduml

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

Please note that you should not abuse this functionnality : GraphViz gives usually good resultswithout tweaking.

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 52 of 96

Page 54: PlantUML Language Reference Guide.pdf

4.4 Branches 4 ACTIVITY DIAGRAM

4.4 BranchesYou can use if/then/else keywords to define branches.

@startuml(*) --> "Initialisation"

if "Some Test" then-->[true] "Some Activity"--> "Another activity"-right-> (*)

else->[false] "Something else"-->[Ending process] (*)

endif@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 53 of 96

Page 55: PlantUML Language Reference Guide.pdf

4.5 More on Branches 4 ACTIVITY DIAGRAM

4.5 More on BranchesBy default, a branch is connected to the last defined activity, but it is possible to override this and to

define a link with the if keywords.

It is also possible to nest branches.

@startuml(*) --> if "Some Test" then

-->[true] "activity 1"

if "" then-> "activity 3" as a3

elseif "Other test" then

-left-> "activity 5"else

--> "activity 6"endif

endif

else

->[false] "activity 2"

endif

a3 --> if "last test" then--> "activity 7"

else-> "activity 8"

endif@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 54 of 96

Page 56: PlantUML Language Reference Guide.pdf

4.6 Synchronization 4 ACTIVITY DIAGRAM

4.6 SynchronizationYou can use ”=== code ===” to display synchronization bars.@startuml

(*) --> ===B1===--> "Parallel Activity 1"--> ===B2===

===B1=== --> "Parallel Activity 2"--> ===B2===

--> (*)

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 55 of 96

Page 57: PlantUML Language Reference Guide.pdf

4.7 Long activity description 4 ACTIVITY DIAGRAM

4.7 Long activity descriptionWhen you declare activities, you can span on several lines the description text. You can also add \n inthe description. It is also possible to use few html tags like :

• <b>

• <i>

• <font size="nn"> or <size:nn> to change font size

• <font color="#AAAAAA"> or <font color="colorName">

• <color:#AAAAAA> or <color:colorName>

• <img:file.png> to include an image

You can also give a short code to the activity with the as keyword. This code can be used latter inthe diagram description.@startuml(*) -left-> "this <size:20>activity</size>

is <b>very</b> <color:red>long</color>and defined on several linesthat contains many <i>text</i>" as A1

-up-> "Another activity\n on several lines"

A1 --> "Short activity <img:sourceforge.jpg>"@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 56 of 96

Page 58: PlantUML Language Reference Guide.pdf

4.8 Notes 4 ACTIVITY DIAGRAM

4.8 NotesYou 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 startingpoint, define 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 leftThis note is onseveral lines

end note@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 57 of 96

Page 59: PlantUML Language Reference Guide.pdf

4.9 Partition 4 ACTIVITY DIAGRAM

4.9 PartitionYou 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 the end partition keyword.@startuml

partition Conductor(*) --> "Climbs on Platform"--> === S1 ===--> Bowsend partition

partition Audience #LightSkyBlue=== S1 === --> Applauds

partition ConductorBows --> === S2 ===--> WavesArmesApplauds --> === S2 ===end partition

partition Orchestra #CCCCEEWavesArmes --> Introduction--> "Play music"end partition

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 58 of 96

Page 60: PlantUML Language Reference Guide.pdf

4.10 Title the diagram 4 ACTIVITY DIAGRAM

4.10 Title the diagramThe title keywords is used to put a title. You can use title and end title keywords for a longer title,as in sequence diagrams.@startumltitle Simple example\nof title

(*) --> "First activity"--> (*)@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 59 of 96

Page 61: PlantUML Language Reference Guide.pdf

4.11 Skinparam 4 ACTIVITY DIAGRAM

4.11 SkinparamYou can use the skinparam command to change colors and fonts for the drawing. You can use thiscommand :

• 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 backgroundColor #AAFFFFskinparam activityStartColor redskinparam activityBarColor SaddleBrownskinparam activityEndColor Silverskinparam activityBackgroundColor Peruskinparam activityBorderColor Peruskinparam activityFontName Impact

(*) --> "Climbs on Platform"--> === S1 ===--> Bows--> === S2 ===--> WavesArmes--> (*)

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 60 of 96

Page 62: PlantUML Language Reference Guide.pdf

4.12 Complete example 4 ACTIVITY DIAGRAM

4.12 Complete example

@startuml'http://click.sourceforge.net/images/activity-diagram-small.pngtitle Servlet Container

(*) --> "ClickServlet.handleRequest()"--> "new Page"

if "Page.onSecurityCheck" then->[true] "Page.onInit()"

if "isForward?" then->[no] "Process controls"

if "continue processing?" then-->[yes] ===RENDERING===

else-->[no] ===REDIRECT_CHECK===

endif

else-->[yes] ===RENDERING===

endif

if "is Post?" then-->[yes] "Page.onPost()"--> "Page.onRender()" as render--> ===REDIRECT_CHECK===

else-->[no] "Page.onGet()"--> render

endif

else-->[false] ===REDIRECT_CHECK===

endif

if "Do redirect?" then->[yes] "redirect request"--> ==BEFORE_DESTROY===

elseif "Do Forward?" then-left->[yes] "Forward request"--> ==BEFORE_DESTROY===

else-right->[no] "Render page template"--> ==BEFORE_DESTROY===

endifendif

--> "Page.onDestroy()"-->(*)

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 61 of 96

Page 63: PlantUML Language Reference Guide.pdf

4.12 Complete example 4 ACTIVITY DIAGRAM

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 62 of 96

Page 64: PlantUML Language Reference Guide.pdf

5 COMPONENT DIAGRAM

5 Component Diagram5.1 ComponentsComponents 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 Comp2component Comp3component [Last\ncomponent] as Comp4

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 63 of 96

Page 65: PlantUML Language Reference Guide.pdf

5.2 Interfaces 5 COMPONENT DIAGRAM

5.2 InterfacesInterface can be defined using the ”()” symbol (because this looks like a circle).

You can also use the interface keyword to defines a usecase.

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 declaration is optional.

@startuml

() "First Interface"() "Another interface" as Interf2interface Interf3interface "Last\ninterface" as Interf4

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 64 of 96

Page 66: PlantUML Language Reference Guide.pdf

5.3 Basic example 5 COMPONENT DIAGRAM

5.3 Basic exampleLinks between elements are made using combinaisons of dotted line ”..”, straight line ”--”, and arrows”-->” symbols.@startuml

DataAccess - [First Component][First Component] ..> HTTP : use

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 65 of 96

Page 67: PlantUML Language Reference Guide.pdf

5.4 Using notes 5 COMPONENT DIAGRAM

5.4 Using notesYou can use the

• note left of,

• note right of,

• note top of,

• note bottom of,

keywords to define notes related to a single object.A note can also be defined alone with the note keywords, then linked to other objects using the ”..”

symbol.@startuml

interface "Data Access" as DA

DA - [First Component][First Component] ..> HTTP : use

note left of HTTP : Web Service only

note right of [First Component]A note can alsobe on several lines

end note

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 66 of 96

Page 68: PlantUML Language Reference Guide.pdf

5.5 Grouping Components 5 COMPONENT DIAGRAM

5.5 Grouping ComponentsYou can use the package keyword to group components and interfaces together.@startuml

package "Some Group" {HTTP - [First Component][Another Component]

}

package "Other Groups" {FTP - [Second Component][First Component] --> FTP

}@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 67 of 96

Page 69: PlantUML Language Reference Guide.pdf

5.6 Changing arrows direction 5 COMPONENT DIAGRAM

5.6 Changing arrows directionBy default, links between classes have two dashes -- and are verticaly oriented. It is possible to usehorizontal link by putting a single dash (or dot) like this:@startuml[Component] --> Interface1[Component] -> Interface2@enduml

You can also change directions by reversing the link:@startumlInterface1 <-- [Component]Interface2 <- [Component]@enduml

It is also possible to change arrow direction by adding left, right, up or down keywords inside thearrow:@startuml[Component] -left-> left[Component] -right-> right[Component] -up-> up[Component] -down-> down@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 68 of 96

Page 70: PlantUML Language Reference Guide.pdf

5.7 Title the diagram 5 COMPONENT DIAGRAM

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

Please note that you should not abuse this functionnality : GraphViz gives usually good resultswithout tweaking.

5.7 Title the diagramThe title keywords is used to put a title. You can use title and end title keywords for a longer title,as in sequence diagrams.@startumltitle Very simple component\ndiagram

interface "Data Access" as DA

DA - [First Component][First Component] ..> HTTP : use

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 69 of 96

Page 71: PlantUML Language Reference Guide.pdf

5.8 Skinparam 5 COMPONENT DIAGRAM

5.8 SkinparamYou can use the skinparam command to change colors and fonts for the drawing. You can use thiscommand :

• 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 componentFontSize 13skinparam interfaceBackgroundColor RosyBrownskinparam interfaceBorderColor blackskinparam componentBackgroundColor goldskinparam componentBorderColor orangeskinparam componentArrowColor #FF6655skinparam componentArrowFontColor #777777skinparam componentFontName Courierskinparam componentArrowFontName Impact

() "Data Access" as DA

DA - [First Component][First Component] ..> () HTTP : use

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 70 of 96

Page 72: PlantUML Language Reference Guide.pdf

6 STATE DIAGRAM

6 State Diagram6.1 Simple StateYou can use [*] for the starting point and ending point of the state diagram.

Use --> for arrows.

@startuml[*] --> State1State1 --> [*]State1 : this is a stringState1 : this is another string

State1 -> State2State2 --> [*]@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 71 of 96

Page 73: PlantUML Language Reference Guide.pdf

6.2 Composite state 6 STATE DIAGRAM

6.2 Composite stateA state can also be composite. You have to define it using the state keywords and brackets.@startuml

[*] --> NotShooting

state NotShooting {[*] --> IdleIdle --> Configuring : EvConfigConfiguring --> Idle : EvConfig

}

state Configuring {[*] --> NewValueSelectionNewValueSelection --> NewValuePreview : EvNewValueNewValuePreview --> NewValueSelection : EvNewValueRejectedNewValuePreview --> NewValueSelection : EvNewValueSaved

state NewValuePreview {State1 -> State2

}

}@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 72 of 96

Page 74: PlantUML Language Reference Guide.pdf

6.3 Long name 6 STATE DIAGRAM

6.3 Long nameYou can also use the state keyword to use long description for states.@startuml

[*] -> State1State1 --> State2 : SucceededState1 --> [*] : AbortedState2 --> State3 : SucceededState2 --> [*] : Abortedstate State3 {

state "Accumulate Enough Data\nLong State Name" as long1long1 : Just a test[*] --> long1long1 --> long1 : New Datalong1 --> ProcessData : Enough Data

}State3 --> State3 : FailedState3 --> [*] : Succeeded / Save ResultState3 --> [*] : Aborted

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 73 of 96

Page 75: PlantUML Language Reference Guide.pdf

6.4 Concurrent state 6 STATE DIAGRAM

6.4 Concurrent stateYou can define concurrent state into a composite state using the ”--” symbol as separator.@startuml

[*] --> Active

state Active {[*] -> NumLockOffNumLockOff --> NumLockOn : EvNumLockPressedNumLockOn --> NumLockOff : EvNumLockPressed--[*] -> CapsLockOffCapsLockOff --> CapsLockOn : EvCapsLockPressedCapsLockOn --> CapsLockOff : EvCapsLockPressed--[*] -> ScrollLockOffScrollLockOff --> ScrollLockOn : EvCapsLockPressedScrollLockOn --> ScrollLockOff : EvCapsLockPressed

}

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 74 of 96

Page 76: PlantUML Language Reference Guide.pdf

6.5 Arrow direction 6 STATE DIAGRAM

6.5 Arrow directionYou can use -> for horizontal arrows. It is possible to force arrow’s direction using the following syntax:

• -down-> (default arrow)

• -right-> or ->

• -left->

• -up->

@startuml

[*] -up-> FirstFirst -right-> SecondSecond --> ThirdThird -left-> Last

@enduml

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

Please note that you should not abuse this functionnality : GraphViz gives usually good resultswithout tweaking.

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 75 of 96

Page 77: PlantUML Language Reference Guide.pdf

6.6 Note 6 STATE DIAGRAM

6.6 NoteYou can alse 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

[*] --> ActiveActive --> Inactive

note left of Active : this is a short\nnote

note right of InactiveA note can alsobe defined onseveral lines

end note

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 76 of 96

Page 78: PlantUML Language Reference Guide.pdf

6.7 More in notes 6 STATE DIAGRAM

6.7 More in notesYou can put notes on composite states.@startuml

[*] --> NotShooting

state "Not Shooting State" as NotShooting {state "Idle mode" as Idlestate "Configuring mode" as Configuring[*] --> IdleIdle --> Configuring : EvConfigConfiguring --> Idle : EvConfig

}

note right of NotShooting : This is a note on a composite state

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 77 of 96

Page 79: PlantUML Language Reference Guide.pdf

7 OBJECTS DIAGRAM

7 Objects Diagram7.1 Definition of objectsYou define instance of objects using the object keywords.@startumlobject firstObjectobject "My Second Object" as o2

@enduml

7.2 Relations between objectsRelations between objects are defined 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:

@startumlobject Object01object Object02object Object03object Object04object Object05object Object06object Object07object Object08

Object01 <|-- Object02Object03 *-- Object04Object05 o-- "4" Object06Object07 .. Object08 : some labels@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 78 of 96

Page 80: PlantUML Language Reference Guide.pdf

7.3 Adding fields 7 OBJECTS DIAGRAM

7.3 Adding fieldsTo declare fields, you can use the symbol ”:” followed by the field’s name.@startuml

object user

user : name = "Dummy"user : id = 123

@enduml

It is also possible to ground between brackets {} all fields.@startumlobject user {

name = "Dummy"id = 123

}@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 79 of 96

Page 81: PlantUML Language Reference Guide.pdf

8 COMMON COMMANDS

8 Common commands8.1 Footer and headerYou 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 define a header or a footer on several lines.

It is also possible to put some HTML into the header or footer

@startumlAlice -> 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

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 80 of 96

Page 82: PlantUML Language Reference Guide.pdf

8.2 Zoom 8 COMMON COMMANDS

8.2 ZoomYou can use the scale command to zoom the generated image. You can use either a number or a fractionto define the scale factor. You can also specify either width or height (in pixel). And you can also giveboth 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

@startumlscale 180*90Bob->Alice : hello@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 81 of 96

Page 83: PlantUML Language Reference Guide.pdf

8.3 Rotation 8 COMMON COMMANDS

8.3 RotationSometimes, and especially for printing, you may want to rotate the generated image, so that it fits betterin the page. You can use the rotate command for this.@startumlrotate

title Simple Usecase\nwith one actor"Use the application" as (Use)User -> (Use)

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 82 of 96

Page 84: PlantUML Language Reference Guide.pdf

9 CHANGING FONTS AND COLORS

9 Changing fonts and colors9.1 UsageYou can change colors and font of the drawing using the skinparam command. Example:skinparam backgroundColor yellow

You can use this command :

• In the diagram definition, like any other commands,

• In an included file (see Preprocessing),

• In a configuration file, provided in the command line or the ANT task.

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 83 of 96

Page 85: PlantUML Language Reference Guide.pdf

9.2 Color 9 CHANGING FONTS AND COLORS

9.2 ColorYou can use either standard color name or RGB code.

Parameter name Default Color CommentValue

backgroundColor white Background of the pageactivityArrowColor #A80036 Color of arrows in activity diagramsactivityBackgroundColor #FEFECE Background of activitiesactivityBorderColor #A80036 Color of activity bordersactivityStartColor black Starting circle in activity diagramsactivityEndColor black Ending circle in activity diagramsactivityBarColor black Synchronization bar in activity diagramsusecaseArrowColor #A80036 Color of arrows in usecase diagramsactorBackgroundColor #FEFECE Head’s color of actor in usecase diagramsactorBorderColor #A80036 Color of actor borders in usecase diagramsusecaseBackgroundColor #FEFECE Background of usecasesusecaseBorderColor #A80036 Color of usecase borders in usecase diagramsclassArrowColor #A80036 Color of arrows in class diagramsclassBackgroundColor #FEFECE Background of classes/interface/enum in class diagramsclassBorderColor #A80036 Borders of classes/interface/enum in class diagramspackageBackgroundColor #FEFECE Background of packages in class diagramspackageBorderColor #A80036 Borders of packages in class diagramsstereotypeCBackgroundColor #ADD1B2 Background of class spots in class diagramsstereotypeABackgroundColor #A9DCDF Background of abstract class spots in class diagramsstereotypeIBackgroundColor #B4A7E5 Background of interface spots in class diagramsstereotypeEBackgroundColor #EB937F Background of enum spots in class diagramscomponentArrowColor #A80036 Color of arrows in component diagramscomponentBackgroundColor #FEFECE Background of componentscomponentBorderColor #A80036 Borders of componentsinterfaceBackgroundColor #FEFECE Background of interface in component diagramsinterfaceBorderColor #A80036 Border of interface in component diagramsnoteBackgroundColor #FBFB77 Background of notesnoteBorderColor #A80036 Border of notesstateBackgroundColor #FEFECE Background of states in state diagramsstateBorderColor #A80036 Border of states in state diagramsstateArrowColor #A80036 Colors of arrows in state diagramssequenceArrowColor #A80036 Color of arrows in sequence diagramssequenceActorBackgroundColor #FEFECE Head’s color of actor in sequence diagramssequenceActorBorderColor #A80036 Border of actor in sequence diagramssequenceGroupBackgroundColor #EEEEEE Header color of alt/opt/loop in sequence diagramssequenceLifeLineBackgroundColor white Background of life line in sequence diagramssequenceLifeLineBorderColor #A80036 Border of life line in sequence diagramssequenceParticipantBackgroundColor #FEFECE Background of participant in sequence diagramssequenceParticipantBorderColor #A80036 Border of participant in sequence diagrams

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 84 of 96

Page 86: PlantUML Language Reference Guide.pdf

9.3 Font color, name and size 9 CHANGING FONTS AND COLORS

9.3 Font color, name and sizeYou can change the font for the drawing using xxxFontColor, xxxFontSize and xxxFontName parameters.

Example:skinparam classFontColor redskinparam classFontSize 10skinparam classFontName Aapex

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 Default CommentName ValueactivityFontColor black

Used for activity boxactivityFontSize 14activityFontStyle plainactivityFontNameactivityArrowFontColor black

Used for text on arrows in activity diagramsactivityArrowFontSize 13activityArrowFontStyle plainactivityArrowFontNamecircledCharacterFontColor black

Used for text in circle for class, enum and otherscircledCharacterFontSize 17circledCharacterFontStyle boldcircledCharacterFontName CouriercircledCharacterRadius 11classArrowFontColor black

Used for text on arrows in class diagramsclassArrowFontSize 10classArrowFontStyle plainclassArrowFontNameclassAttributeFontColor black

Class attributes and methodsclassAttributeFontSize 10classAttributeIconSize 10classAttributeFontStyle plainclassAttributeFontNameclassFontColor black

Used for classes nameclassFontSize 12classFontStyle plainclassFontNameclassStereotypeFontColor black

Used for stereotype in classesclassStereotypeFontSize 12classStereotypeFontStyle italicclassStereotypeFontNamecomponentFontColor black

Used for components namecomponentFontSize 14componentFontStyle plaincomponentFontNamecomponentStereotypeFontColor black

Used for stereotype in componentscomponentStereotypeFontSize 14componentStereotypeFontStyle italiccomponentStereotypeFontNamecomponentArrowFontColor black

Used for text on arrows in component diagramscomponentArrowFontSize 13componentArrowFontStyle plaincomponentArrowFontName

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 85 of 96

Page 87: PlantUML Language Reference Guide.pdf

9.3 Font color, name and size 9 CHANGING FONTS AND COLORS

noteFontColor black

Used for notes in all diagrams but sequence diagramsnoteFontSize 13noteFontStyle plainnoteFontNamepackageFontColor black

Used for package and partition namespackageFontSize 14packageFontStyle plainpackageFontNamesequenceActorFontColor black

Used for actor in sequence diagramssequenceActorFontSize 13sequenceActorFontStyle plainsequenceActorFontNamesequenceDividerFontColor black

Used for text on dividers in sequence diagramssequenceDividerFontSize 13sequenceDividerFontStyle boldsequenceDividerFontNamesequenceArrowFontColor black

Used for text on arrows in sequence diagramssequenceArrowFontSize 13sequenceArrowFontStyle plainsequenceArrowFontNamesequenceGroupingFontColor black

Used for text for ”else” in sequence diagramssequenceGroupingFontSize 11sequenceGroupingFontStyle plainsequenceGroupingFontNamesequenceGroupingHeaderFontColor black

Used for text for ”alt/opt/loop” headers in sequence diagramssequenceGroupingHeaderFontSize 13sequenceGroupingHeaderFontStyle plainsequenceGroupingHeaderFontNamesequenceParticipantFontColor black

Used for text on participant in sequence diagramssequenceParticipantFontSize 13sequenceParticipantFontStyle plainsequenceParticipantFontNamesequenceTitleFontColor black

Used for titles in sequence diagramssequenceTitleFontSize 13sequenceTitleFontStyle plainsequenceTitleFontNametitleFontColor black

Used for titles in all diagrams but sequence diagramstitleFontSize 18titleFontStyle plaintitleFontNamestateFontColor black

Used for states in state diagramsstateFontSize 14stateFontStyle plainstateFontNamestateArrowFontColor black

Used for text on arrows in state diagramsstateArrowFontSize 13stateArrowFontStyle plainstateArrowFontNamestateAttributeFontColor black

Used for states description in state diagramsstateAttributeFontSize 12stateAttributeFontStyle plainstateAttributeFontNameusecaseFontColor black

Used for usecase labels in usecase diagramsusecaseFontSize 14usecaseFontStyle plainusecaseFontName

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 86 of 96

Page 88: PlantUML Language Reference Guide.pdf

9.3 Font color, name and size 9 CHANGING FONTS AND COLORS

usecaseStereotypeFontColor black

Used for stereotype in usecaseusecaseStereotypeFontSize 14usecaseStereotypeFontStyle italicusecaseStereotypeFontNameusecaseActorFontColor black

Used for actor labels in usecase diagramsusecaseActorFontSize 14usecaseActorFontStyle plainusecaseActorFontNameusecaseActorStereotypeFontColor black

Used for stereotype for actorusecaseActorStereotypeFontSize 14usecaseActorStereotypeFontStyle italicusecaseActorStereotypeFontNameusecaseArrowFontColor black

Used for text on arrows in usecase diagramsusecaseArrowFontSize 13usecaseArrowFontStyle plainusecaseArrowFontNamefooterFontColor black

Used for footerfooterFontSize 10footerFontStyle plainfooterFontNameheaderFontColor black

Used for headerheaderFontSize 10headerFontStyle plainheaderFontName

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 87 of 96

Page 89: PlantUML Language Reference Guide.pdf

9.4 Black and White 9 CHANGING FONTS AND COLORS

9.4 Black and WhiteYou can force the use of a blackwhite output using the skinparam monochrome true command.@startumlskinparam monochrome true

actor Userparticipant "First Class" as Aparticipant "Second Class" as Bparticipant "Last Class" as C

User -> A: DoWorkactivate A

A -> B: Create Requestactivate B

B -> C: DoWorkactivate CC --> B: WorkDonedestroy C

B --> A: Request Createddeactivate B

A --> User: Donedeactivate A

@enduml

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 88 of 96

Page 90: PlantUML Language Reference Guide.pdf

10 PREPROCESSING

10 PreprocessingSome 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 char-acter ”#” has been changed to the exclamation mark ”!”.

10.1 Including filesUse the !include directive to include file in your diagram.

Imagine you have the very same class that appears in many diagrams. Instead of duplicating thedescription of this class, you can define a file that contains the description.@startuml!include List.iumlList <|.. ArrayList@enduml

File List.iuml:interface ListList : int size()List : void clear()

The file List.iuml can be included in many diagrams, and any modification in this file will changeall diagrams that include it.

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 89 of 96

Page 91: PlantUML Language Reference Guide.pdf

10.2 Constant definition 10 PREPROCESSING

10.2 Constant definitionYou can define constant using the !define directive. As in C language, a constant name can only usealphanumeric and underscore characters, and cannot start with a digit.@startuml

!define SEQUENCE (S,#AAAAAA) Database Sequence!define TABLE (T,#FFAAAA) Database Table

class USER << TABLE >>class ACCOUNT << TABLE >>class UID << SEQUENCE >>USER "1" -- "*" ACCOUNTUSER -> UID

@enduml

Of course, you can use the !include directive to define all your constants in a single file that youinclude in your diagram.

Constant can be undefined with the !undef XXX directive.

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 90 of 96

Page 92: PlantUML Language Reference Guide.pdf

10.3 Conditions 10 PREPROCESSING

10.3 ConditionsYou 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 directivehas 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_METHODSArrayList : 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 beendefined.

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 91 of 96

Page 93: PlantUML Language Reference Guide.pdf

11 INTERNATIONALIZATION

11 InternationalizationThe PlantUML language use letters to define actor, usecase and so on. But letters are not only A-Z latincharacters, it could be any kind of letter from any language.

@startumlskinparam backgroundColor #EEEBDCactor 使用者participant "頭等艙" as Aparticipant "第二類" as Bparticipant "最後一堂課" as 別的東西

使用者 -> A: 完成這項工作activate AA -> B: 創建請求activate BB -> 別的東西: 創建請求activate 別的東西別的東西 --> B: 這項工作完成destroy 別的東西B --> A: 請求創建deactivate BA --> 使用者: 做完deactivate A@enduml

11.1 CharsetThe default charset used when reading the text files containing the UML text description is systemdependant. 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

Or, with the ant task:<!-- Put images in c:/images directory --><target name="main">

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 92 of 96

Page 94: PlantUML Language Reference Guide.pdf

11.2 Font Issues 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.

11.2 Font IssuesWhen using East Asian Fonts, you may have some issues, because Graphviz default fonts may not containssome characters. So you may have to force the usage of a system font that contains those characters, byadding the following lines in your diagram descriptions:skinparam defaultFontName MS Mincho

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 93 of 96

Page 95: PlantUML Language Reference Guide.pdf

12 COLOR NAMES

12 Color Names

Here is the list of colors recognized by PlantUML. Note that color names are case insensitive.

AliceBlue GhostWhite NavajoWhiteAntiqueWhite GoldenRod NavyAquamarine Gold OldLaceAqua Gray OliveDrabAzure GreenYellow OliveBeige Green OrangeRedBisque HoneyDew OrangeBlack HotPink OrchidBlanchedAlmond IndianRed PaleGoldenRodBlueViolet Indigo PaleGreenBlue Ivory PaleTurquoiseBrown Khaki PaleVioletRedBurlyWood LavenderBlush PapayaWhipCadetBlue Lavender PeachPuffChartreuse LawnGreen PeruChocolate LemonChiffon PinkCoral LightBlue PlumCornflowerBlue LightCoral PowderBlueCornsilk LightCyan PurpleCrimson LightGoldenRodYellow RedCyan LightGreen RosyBrownDarkBlue LightGrey RoyalBlueDarkCyan LightPink SaddleBrownDarkGoldenRod LightSalmon SalmonDarkGray LightSeaGreen SandyBrownDarkGreen LightSkyBlue SeaGreenDarkKhaki LightSlateGray SeaShellDarkMagenta LightSteelBlue SiennaDarkOliveGreen LightYellow SilverDarkOrchid LimeGreen SkyBlueDarkRed Lime SlateBlueDarkSalmon Linen SlateGrayDarkSeaGreen Magenta SnowDarkSlateBlue Maroon SpringGreenDarkSlateGray MediumAquaMarine SteelBlueDarkTurquoise MediumBlue TanDarkViolet MediumOrchid TealDarkorange MediumPurple ThistleDeepPink MediumSeaGreen TomatoDeepSkyBlue MediumSlateBlue TurquoiseDimGray MediumSpringGreen VioletDodgerBlue MediumTurquoise WheatFireBrick MediumVioletRed WhiteSmokeFloralWhite MidnightBlue WhiteForestGreen MintCream YellowGreenFuchsia MistyRose YellowGainsboro Moccasin

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 94 of 96

Page 96: PlantUML Language Reference Guide.pdf

CONTENTS CONTENTS

Contents1 Sequence Diagram 1

1.1 Basic examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Declaring participant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3 Use non-letters in participants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.4 Message to Self . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.5 Message sequence numbering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.6 Title . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.7 Splitting diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71.8 Grouping message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81.9 Notes on messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91.10 Some other notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101.11 Formatting using HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111.12 Divider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121.13 Lifeline Activation and Destruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131.14 Participant creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151.15 Incoming and outgoing messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161.16 Stereotypes and Spots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171.17 More information on titles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181.18 Participants englober . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201.19 Removing Footer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211.20 Skinparam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221.21 Skin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

2 Use Case Diagram 242.1 Usecases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242.2 Actors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252.3 Basic example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262.4 Extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272.5 Using notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282.6 Stereotypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292.7 Changing arrows direction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302.8 Title the diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312.9 Left to right direction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322.10 Skinparam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

3 Class Diagram 343.1 Relations between classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343.2 Label on relations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353.3 Adding methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363.4 Defining visibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373.5 Notes and stereotypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383.6 More on notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393.7 Abstract class and interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403.8 Using non-letters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413.9 Hide attributes, methods... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423.10 Specific Spot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433.11 Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443.12 Namespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453.13 Changing arrows direction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463.14 Lollipop interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473.15 Title the diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473.16 Association classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483.17 Skinparam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493.18 Splitting large files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 95 of 96

Page 97: PlantUML Language Reference Guide.pdf

CONTENTS CONTENTS

4 Activity Diagram 514.1 Simple Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514.2 Label on arrows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514.3 Changing arrow direction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524.4 Branches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534.5 More on Branches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544.6 Synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554.7 Long activity description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564.8 Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 574.9 Partition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584.10 Title the diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 594.11 Skinparam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 604.12 Complete example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

5 Component Diagram 635.1 Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 635.2 Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 645.3 Basic example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 655.4 Using notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 665.5 Grouping Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675.6 Changing arrows direction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 685.7 Title the diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 695.8 Skinparam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70

6 State Diagram 716.1 Simple State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 716.2 Composite state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 726.3 Long name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 736.4 Concurrent state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 746.5 Arrow direction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 756.6 Note . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 766.7 More in notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

7 Objects Diagram 787.1 Definition of objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 787.2 Relations between objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 787.3 Adding fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79

8 Common commands 808.1 Footer and header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 808.2 Zoom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 818.3 Rotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82

9 Changing fonts and colors 839.1 Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 839.2 Color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 849.3 Font color, name and size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 859.4 Black and White . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88

10 Preprocessing 8910.1 Including files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8910.2 Constant definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9010.3 Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

11 Internationalization 9211.1 Charset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9211.2 Font Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

12 Color Names 94

PlantUML : Language Reference Guide, December 11, 2010 (Version 5737) 96 of 96