Date post: | 19-Oct-2015 |
Category: |
Documents |
Upload: | edgark-rodriguez-keane |
View: | 90 times |
Download: | 7 times |
of 101
Dibujo UML con PlantUML
Gua de Referencia del lenguaje(Version 6085)
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 Diagram1.1 Basic examplesEvery 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 Alice: Authentication ResponseAlice -> Bob: Another authentication RequestAlice
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, January 23, 2011 (Version 6085) 2 of 100
1.3 Use non-letters in participants 1 SEQUENCE DIAGRAM
1.3 Use non-letters in participantsYou can use quotes to dene 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 nn.
@startuml
Alice->Alice: This is a signal to self.\nIt also demonstrates\nmultiline \ntext
@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 3 of 100
1.5 Change arrow style 1 SEQUENCE DIAGRAM
1.5 Change arrow styleYou can change arrow style by several ways:
use n or / instead of < or > to have only the bottom or top part of the arrow. repeat the arrow head (for example, >> or //) head to have a thin drawing. Utilice -- en vez de - para obtener una echa punteada.
@startumlBob -> AliceBob ->> AliceBob -\ AliceBob \\- AliceBob //-- Alice@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 4 of 100
1.6 Message sequence numbering 1 SEQUENCE DIAGRAM
1.6 Message sequence numberingThe keyword autonumber is used to automatically add number to messages.@startumlautonumberBob -> Alice : Authentication RequestBob Alice : Authentication RequestBob Alice : Another authentication RequestBob Alice : Yet another authentication RequestBob
1.6 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 "[000]"Bob -> Alice : Authentication RequestBob Alice : Another authentication RequestBob Alice : Yet another authentication RequestBob
1.7 Title 1 SEQUENCE DIAGRAM
1.7 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, January 23, 2011 (Version 6085) 7 of 100
1.8 Splitting diagrams 1 SEQUENCE DIAGRAM
1.8 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, January 23, 2011 (Version 6085) 8 of 100
1.9 Grouping message 1 SEQUENCE DIAGRAM
1.9 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 displayed
It is possible a add a text that will be displayed into the header. The end keyword is used to closethe 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, January 23, 2011 (Version 6085) 9 of 100
1.9 Grouping message 1 SEQUENCE DIAGRAM
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 10 of 100
1.10 Notes on messages 1 SEQUENCE DIAGRAM
1.10 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.@startumlAlicia->Roberto : holanote left: esta es una primera nota
Roberto->Alicia : aprobadonote right: esta es otra nota
Roberto->Roberto : estoy pensandonote left
una notatambin puede ser definidaon several lines
end note@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 11 of 100
1.11 Some other notes 1 SEQUENCE DIAGRAM
1.11 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, January 23, 2011 (Version 6085) 12 of 100
1.12 Formatting using HTML 1 SEQUENCE DIAGRAM
1.12 Formatting using HTMLIt is also possible to use few html tags like :
for bold text or for underline for italic or for strike text or or for wave underline text or or for background color to change font size : the le must be accessible by the lesystem.
@startumlparticipant Aliceparticipant "The Famous Bob" as Bob
Alice -> Bob : A well formated messagenote right of Alice
This is displayedleft of Alice.
end notenote left of Bob
This is displayedleft of Alice Bob.
end notenote over Alice, Bob
This is hosted by end note
@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 13 of 100
1.13 Divider 1 SEQUENCE DIAGRAM
1.13 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
1.14 Lifeline Activation and Destruction 1 SEQUENCE DIAGRAM
1.14 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: >activate B
B -> C: DoWorkactivate CC --> B: WorkDonedestroy C
B --> A: RequestCreateddeactivate B
A -> User: Donedeactivate A
@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 15 of 100
1.14 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: >activate B
B --> A: RequestCreateddeactivate Bdeactivate AA -> User: Donedeactivate A
@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 16 of 100
1.15 Participant creation 1 SEQUENCE DIAGRAM
1.15 Participant creationYou can use the create keyword just before the rst 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, January 23, 2011 (Version 6085) 17 of 100
1.16 Incoming and outgoing messages 1 SEQUENCE DIAGRAM
1.16 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 ->] : >
A
1.17 Stereotypes and Spots 1 SEQUENCE DIAGRAM
1.17 Stereotypes and SpotsIt is possible to add stereotypes to participants using . In the stereotype, you can add aspotted character in a colored circle using the syntax (X,color).@startuml
participant "Famous Bob" as Bob >participant Alice > #EEEEEE
Bob->Alice: First message
@enduml
@startuml
participant Bob >participant Alice >
Bob->Alice: First message
@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 19 of 100
1.18 More information on titles 1 SEQUENCE DIAGRAM
1.18 More information on titlesYou can use some HTML tags in the title.@startuml
title Simple communication example
Alice -> Bob: Authentication RequestBob --> Alice: Authentication Response
@enduml
You can add newline using nn in the title description.@startuml
title Simple communication example\non several lines
Alice -> Bob: Authentication RequestBob --> Alice: Authentication Response
@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 20 of 100
1.18 More information on titles 1 SEQUENCE DIAGRAM
You can also dene title on several lines using title and end title keywords.@startuml
titleSimple communication exampleon several lines and using htmlThis is hosted by
end title
Alice -> Bob: Authentication RequestBob --> Alice: Authentication Response
@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 21 of 100
1.19 Participants englober 1 SEQUENCE DIAGRAM
1.19 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, January 23, 2011 (Version 6085) 22 of 100
1.20 Removing Footer 1 SEQUENCE DIAGRAM
1.20 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, January 23, 2011 (Version 6085) 23 of 100
1.21 Skinparam 1 SEQUENCE DIAGRAM
1.21 SkinparamYou can use the skinparam command to change colors and fonts for the drawing. You can use thiscommand :
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.
@startumlskinparam backgroundColor #EEEBDC
skinparam sequence {ArrowColor DeepSkyBlueActorBorderColor DeepSkyBlueLifeLineBorderColor blueLifeLineBackgroundColor #A9DCDF
ParticipantBorderColor DeepSkyBlueParticipantBackgroundColor DodgerBlueParticipantFontName ImpactParticipantFontSize 17ParticipantFontColor #A9DCDF
ActorBackgroundColor aquaActorFontColor DeepSkyBlueActorFontSize 17ActorFontName Aapex
}
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, January 23, 2011 (Version 6085) 24 of 100
1.21 Skinparam 1 SEQUENCE DIAGRAM
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 25 of 100
1.22 Skin 1 SEQUENCE DIAGRAM
1.22 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: >activate B
B -> C: DoWorkactivate CC --> B: WorkDonedestroy C
B --> A: Request Createddeactivate B
A --> User: Donedeactivate A
@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 26 of 100
2 DIAGRAMA DE CASOS DE USO
2 Diagrama de casos de uso2.1 Casos de usoLos casos de uso estan encerrados entre parntesis (los parntesis tienen un aspecto similar a un valo).Tambin puede usar la palabra usecase para crear un caso de uso.Ademas puede crear un alias, usando la palabra as. Este alias ser usado mas adelante, cuando dena
relaciones.
@startuml
(First usecase)(Another usecase) as (UC2)usecase UC3usecase (Last\nusecase) as UC4
@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 27 of 100
2.2 Actores 2 DIAGRAMA DE CASOS DE USO
2.2 ActoresLos actores se encierran entre dos puntos.Tambin puede usar la palabra actor para denir un actor.Ademas puede crear un alias, usando la palabra as. Este alias sera usado mas adelante cuando haga las
relaciones.We will see than actor denitions is optional.
@startuml
:Primer Actor::Otro actor: as Hombre2actor hombre3actor :ultimo actor: as hombre4
@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 28 of 100
2.3 Basic example 2 DIAGRAMA DE CASOS DE USO
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 denition.In this example, you see that User has not been dened before, and is implicitly dened 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, January 23, 2011 (Version 6085) 29 of 100
2.4 Extension 2 DIAGRAMA DE CASOS DE USO
2.4 ExtensionIf one actor/use case extends another one, you can use the symbol
2.5 Using notes 2 DIAGRAMA DE CASOS DE USO
2.5 Using notesYou can use the :
note left of, note right of, note top of, note bottom of
keywords to dene notes related to a single object. A note can be also dene 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, January 23, 2011 (Version 6085) 31 of 100
2.6 Stereotypes 2 DIAGRAMA DE CASOS DE USO
2.6 StereotypesYou can add stereotypes while dening actors and use cases using .@startumlUser >:Main Database: as MySql >(Start) >(Use the application) as (Use) >
User -> (Start)User --> (Use)
MySql --> (Use)
@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 32 of 100
2.7 Changing arrows direction 2 DIAGRAMA DE CASOS DE USO
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) (dummyRight):user: -up-> (dummyUp):user: -down-> (dummyDown)@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 33 of 100
2.8 Casos de uso 2 DIAGRAMA DE CASOS DE USO
You can shorten the arrow by using only the rst character of the direction (for example, -d- insteadof -down-) or the two rst characters (-do-).
Please note that you should not abuse this functionnality : GraphViz gives usually good resultswithout tweaking.
2.8 Casos de usoThe 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 Usecase\nwith one actor
usecase (Use the application) as (Use)User -> (Use)
@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 34 of 100
2.9 Left to right direction 2 DIAGRAMA DE CASOS DE USO
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, January 23, 2011 (Version 6085) 35 of 100
2.10 Skinparam 2 DIAGRAMA DE CASOS DE USO
2.10 SkinparamPuedes usar el comando skinparam para cambiar los colores y los fuentes de los dibujos Puedes usar estecomando:
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.
@startumlskinparam usecase {
BackgroundColor DarkSeaGreenBorderColor DarkSlateGray
BackgroundColor> YellowGreenBorderColor> YellowGreen
ArrowColor OliveActorBorderColor blackActorFontName Courier
ActorBackgroundColor > Gold}
User >:Main Database: as MySql >(Start) >(Use the application) as (Use) >
User -> (Start)User --> (Use)
MySql --> (Use)
@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 36 of 100
3 CLASS DIAGRAM
3 Class Diagram3.1 Relations between classesRelations between classes are dened using the following symbols :
Extension Class18Class19
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, January 23, 2011 (Version 6085) 38 of 100
3.3 Adding methods 3 CLASS DIAGRAM
3.3 Adding methodsTo declare elds and methods, you can use the symbol : followed by the elds or methods name.The system checks for parenthesis to choose between methods and elds.
@startumlObject
3.4 Dening visibility 3 CLASS DIAGRAM
3.4 Dening visibilityWhen you dene methods or elds, you can use characters to dene the visibility of the corresponding
item:- private# protected package private+ public
@startumlclass Dummy {
-field1#field2method1()+method2()
}@enduml
Puede deshabilitar esta caracterstica usando skinparam classAttributeIconSize 0 comando :
@startumlskinparam classAttributeIconSize 0class Dummy {
-field1#field2method1()+method2()
}@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 40 of 100
3.5 Notes and stereotypes 3 CLASS DIAGRAM
3.5 Notes and stereotypesStereotypes are dened with the class keyword, .You can alse dene notes using note left of, note right of, note top of, note bottom of keywords.A note can be also dene alone with the note keywords, then linked to other objects using the ..
symbol.
@startumlclass Object >Object
3.6 More on notes 3 CLASS DIAGRAM
3.6 More on notesIt is also possible to use few html tags like :
, , or or to change font size or : the le must be accessible by the lesystemTambin puede ubicar una nota en varias lneas.
@startuml
note top of ObjectEn java, cada classextendsthis one.
end note
note as N1This note is alsoon severalwords linesAnd this is hosted by
end note
@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 42 of 100
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
3.8 No utilizar letras 3 CLASS DIAGRAM
3.8 No utilizar letrasSi no desea utilizar letras en la vista de clase (o enum...), usted puede:
Utilice la palabra clave as en la denicin de la clase Poner el nombre de la clase entre comillas ""
@startumlclase "Esta es mi clase" como clase1class class2 as "It works this way too"
class2 *-- "foo/dummy" : use@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 44 of 100
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 atributos o mtodos, si estn
vacos.Instancia de empty members, se puede utilizar:
empty fields o empty attributes para los campos vacos, empty methods por mtodos vacos, fields o attributes que ocultar campos, incluso si se describen, methods cual se ocultar mtodos, incluso si se describen, members cual se ocultar campos y mtodos, incluso si se describen, circle para el personaje en crculos frente a nombre de la clase, 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, for classes which are stereotyped with foo1, an existing class name.
You can use several show/hide commands to dene rules and exceptions.@startumlclass Dummy1 {
+myMethods()}
class Dummy2 {+hiddenMethod()
}
class Dummy3 {String name
}
hide membershide circleshow Dummy1 methodshow fields@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 45 of 100
3.10 Specic Spot 3 CLASS DIAGRAM
3.10 Specic SpotUsually, a spotted character (C, I, E or A) is used for classes, interface, enum and abstract classes. Butyou can dene your own spot for a class when you dene the stereotype, adding a single character and acolor, like in this example:@startuml
class System >class Date >@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 46 of 100
3.11 Packages 3 CLASS DIAGRAM
3.11 PackagesYou can dene 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 denition using the end package keyword. You canalso use brackets { }.
Note that package denitions can be nested.@startuml
package "Classic Collections" #DDDDDD {Object
3.12 Namespaces 3 CLASS DIAGRAM
3.12 NamespacesIn packages, the name of a class is the unique identier of this class. It means that you cannot have twoclasses with the very same name in dierent 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 qualied with a starting dot.
Note that you dont have to explicitly create namespace : a fully qualied class is automatically putin the right namespace.@startuml
class BaseClass
namespace net.dummy #DDDDDD.BaseClass
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
You can shorten the arrow by using only the rst character of the direction (for example, -d- insteadof -down-) or the two rst characters (-do-)
Please note that you should not abuse this functionnality : GraphViz gives usually good resultswithout tweaking.
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 49 of 100
3.14 Lollipop interface 3 CLASS DIAGRAM
3.14 Lollipop interfaceYou can also dene 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 example\nof title
Object
3.16 Association classes 3 CLASS DIAGRAM
3.16 Association classesYou can dene association class after that a relation has been dened between two classes, like in thisexample:@startumlStudent : NameStudent "0..*" - "1..*" Course(Student, Course) .. Enrollment
Enrollment : drop()Enrollment : cancel()@enduml
You can dene it in another direction:@startumlStudent : NameStudent "0..*" -- "1..*" Course(Student, Course) . Enrollment
Enrollment : drop()Enrollment : cancel()@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 51 of 100
3.17 Skinparam 3 CLASS DIAGRAM
3.17 SkinparamUsted puede utilizar la skinparam comando para cambiar colores y fuentes para la dibujo. Usted puedeutilizar este comando :
Denicin del diagrama, al igual que cualquier otro comando, En un archivo incluido, In a conguration le, 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, January 23, 2011 (Version 6085) 52 of 100
3.18 Skinned Stereotypes 3 CLASS DIAGRAM
3.18 Skinned StereotypesYou can dene specic color and fonts for stereotyped classes.@startuml
skinparam class {BackgroundColor PaleGreenArrowColor SeaGreenBorderColor SpringGreenBackgroundColor WheatBorderColor Tomato
}skinparam stereotypeCBackgroundColor YellowGreenskinparam stereotypeCBackgroundColor DimGray
Class01 Class01 "1" *-- "many" Class02 : contains
Class03 o-- Class04 : agregation
@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 53 of 100
3.19 Splitting large les 3 CLASS DIAGRAM
3.19 Splitting large lesSometimes, you will get some very large image les. You can use the page (hpages)x(vpages)command to split the generated image into several les :
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
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 denition.
@startuml(*) --> "First Activity"-->[You can put also labels] "Second Activity"--> (*)@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 55 of 100
4.3 Changing arrow direction 4 ACTIVITY DIAGRAM
4.3 Changing arrow directionYou can use -> for horizontal arrows. It is possible to force arrows direction using the following syntax:
-down-> (default arrow) -right-> or -> -left-> -up->
@startuml(*) -up-> "First Activity"-right-> "Second Activity"--> "Third Activity"-left-> (*)@enduml
Puede acortar la echa utilizando slo el primer carcter de la direccin (por ejemplo,-d- en lugar de-down-) o los dos primeros personajes (-do-).
Tenga en cuenta que no se debe abusar de esta funcionalidad: GraphViz por lo general da buenosresultados sin ajustar.
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 56 of 100
4.4 Ramas 4 ACTIVITY DIAGRAM
4.4 RamasUsted puede usar if/then/else palabras clave para denir las ramas.
@startuml(*) --> "Initialisation"
if "Some Test" then-->[true] "Some Activity"--> "Another activity"-right-> (*)
else->[false] "Something else"-->[Ending process] (*)
endif@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 57 of 100
4.5 More on Branches 4 ACTIVITY DIAGRAM
4.5 More on BranchesBy default, a branch is connected to the last dened activity, but it is possible to override this and to
dene 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, January 23, 2011 (Version 6085) 58 of 100
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, January 23, 2011 (Version 6085) 59 of 100
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 nn inthe description. It is also possible to use few html tags like :
or to change font size or or 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 activity
is very longand defined on several linesthat contains many text" as A1
-up-> "Another activity\n on several lines"
A1 --> "Short activity "@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 60 of 100
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, 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 leftThis note is onseveral lines
end note@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 61 of 100
4.9 Partition 4 ACTIVITY DIAGRAM
4.9 PartitionYou 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 ===--> 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, January 23, 2011 (Version 6085) 62 of 100
4.10 Ttulo del diagrama 4 ACTIVITY DIAGRAM
4.10 Ttulo del diagramatitle es usado para poner ttulos. Se puede usar ttulo y fin del ttulo para ttulos largos, comoen los diagramas de secuencia.@startumltitle Simple example\nof title
(*) --> "Primera actividad"--> (*)@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 63 of 100
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 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 #AAFFFFskinparam activity {
StartColor redBarColor SaddleBrownEndColor SilverBackgroundColor PeruBorderColor PeruFontName Impact
}
(*) --> "Sube a la plataforma"--> === S1 ===--> Se inclina--> === S2 ===--> Agitan los brazos--> (*)
@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 64 of 100
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, January 23, 2011 (Version 6085) 65 of 100
4.12 Complete example 4 ACTIVITY DIAGRAM
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 66 of 100
5 COMPONENT DIAGRAM
5 Component Diagram5.1 ComponentsComponents 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 Comp2component Comp3component [Last\ncomponent] as Comp4
@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 67 of 100
5.2 Interfaces 5 COMPONENT DIAGRAM
5.2 InterfacesInterface can be dened using the () symbol (because this looks like a circle).You can also use the interface keyword to denes an interface.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 Interf2interface Interf3interface "Last\ninterface" as Interf4
@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 68 of 100
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, January 23, 2011 (Version 6085) 69 of 100
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 dene notes related to a single object.A note can also be dened 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, January 23, 2011 (Version 6085) 70 of 100
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, January 23, 2011 (Version 6085) 71 of 100
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 right[Component] -up-> up[Component] -down-> down@enduml
You can shorten the arrow by using only the rst character of the direction (for example, -d- insteadof -down-) or the two rst characters (-do-).
Please note that you should not abuse this functionnality : GraphViz gives usually good resultswithout tweaking.
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 72 of 100
5.7 Title the diagram 5 COMPONENT DIAGRAM
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, January 23, 2011 (Version 6085) 73 of 100
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 denition, like any other commands, In an included le, In a conguration le, provided in the command line or the ANT task.
@startumlskinparam component {
FontSize 13InterfaceBackgroundColor RosyBrownInterfaceBorderColor orangeBackgroundColor> RedBorderColor> #FF6655FontName CourierBorderColor blackBackgroundColor goldArrowFontName ImpactArrowColor #FF6655ArrowFontColor #777777
}
() "Data Access" as DA
DA - [First Component][First Component] ..> () HTTP : useHTTP - [Web Server] >@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 74 of 100
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, January 23, 2011 (Version 6085) 75 of 100
6.2 Composite state 6 STATE DIAGRAM
6.2 Composite stateA state can also be composite. You have to dene 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, January 23, 2011 (Version 6085) 76 of 100
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, January 23, 2011 (Version 6085) 77 of 100
6.4 Concurrent state 6 STATE DIAGRAM
6.4 Concurrent stateYou can dene concurrent state into a composite state using the -- symbol as separator.@startuml
[*] --> Activo
estado Activo{[*] -> NumLockOffNumLockOff --> NumLockOn : EvNumLockPressedNumLockOn --> NumLockOff : EvNumLockPressed--[*] -> CapsLockOffCapsLockOff --> CapsLockOn : EvCapsLockPressedCapsLockOn --> CapsLockOff : EvCapsLockPressed--[*] -> ScrollLockOffScrollLockOff --> ScrollLockOn : EvCapsLockPressedScrollLockOn --> ScrollLockOff : EvCapsLockPressed
}
@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 78 of 100
6.5 direccin de la echa 6 STATE DIAGRAM
6.5 direccin de la echaPuede usar -> para echas horizontales. Es posible forzar la direccin de las echas utilizando la siguientesintaxis:
-down-> (default arrow) -right-> or -> -left-> -up->
@startuml
[*] -up-> FirstFirst -right-> SecondSecond --> ThirdThird -left-> Last
@enduml
Puede hacer la echa mas corta usando slo el primer caracter de la direccion (por ejemplo, -d- envez de -down-) o los dos primeros carcteres (-do-).
Tenga en cuenta que no debe abusar de esta funcionalidad: GraphViz sta generalmente obtienebuenos resultados sin ajustarla.
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 79 of 100
6.6 Note 6 STATE DIAGRAM
6.6 NoteYou 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
[*] --> 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, January 23, 2011 (Version 6085) 80 of 100
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, January 23, 2011 (Version 6085) 81 of 100
7 OBJECTS DIAGRAM
7 Objects Diagram7.1 Denition of objectsYou dene instance of objects using the object keywords.@startumlobject firstObjectobject "My Second Object" as o2
@enduml
7.2 Relations between objectsRelations between objects are dened using the following symbols :
Extension
7.3 Adding elds 7 OBJECTS DIAGRAM
7.3 Adding eldsTo declare elds, you can use the symbol : followed by the elds name.@startuml
object user
user : name = "Dummy"user : id = 123
@enduml
It is also possible to ground between brackets fg all elds.@startumlobject user {
name = "Dummy"id = 123
}@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 83 of 100
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 dene 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
headerWarning: This is a demonstration diagram.Do not use in production.endheader
center footer Generated for demonstration@enduml
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 84 of 100
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 dene 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 t inside the specied 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, January 23, 2011 (Version 6085) 85 of 100
8.3 Rotation 8 COMMON COMMANDS
8.3 RotationSometimes, and especially for printing, you may want to rotate the generated image, so that it ts 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, January 23, 2011 (Version 6085) 86 of 100
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 denition, like any other commands, In an included le (see Preprocessing), In a conguration le, provided in the command line or the ANT task.
9.2 NestedTo avoid repetition, it is possible to nest denition. So the following denition :skinparam xxxxParam1 value1skinparam xxxxParam2 value2skinparam xxxxParam3 value3skinparam xxxxParam4 value4
is strictly equivalent to:skinparam xxxx {
Param1 value1Param2 value2Param3 value3Param4 value4
}
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 87 of 100
9.3 Color 9 CHANGING FONTS AND COLORS
9.3 ColorYou can use either standard color name or RGB code.
Parameter name Default Color CommentValue
backgroundColor white Background of the pageactivityArrowColor #A80036 Color de las echas en los diagramas de actividadactivityBackgroundColor #FEFECE Antecedentes de actividadesactivityBorderColor #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 diagramsusecaseActorBackgroundColor #FEFECE Heads color of actor in usecase diagramsusecaseActorBorderColor #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 componentscomponentInterfaceBackgroundColor #FEFECE Background of interface in component diagramscomponentInterfaceBorderColor #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 diagramsstateStartColor black Starting circle in state diagramsstateEndColor black Ending circle in state diagramssequenceArrowColor #A80036 Color of arrows in sequence diagramssequenceActorBackgroundColor #FEFECE Heads 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, January 23, 2011 (Version 6085) 88 of 100
9.4 Font color, name and size 9 CHANGING FONTS AND COLORS
9.4 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, January 23, 2011 (Version 6085) 89 of 100
9.4 Font color, name and size 9 CHANGING FONTS AND COLORS
noteFontColor blackUsed for notes in all diagrams but sequence diagramsnoteFontSize 13noteFontStyle plain
noteFontNamepackageFontColor 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, January 23, 2011 (Version 6085) 90 of 100
9.4 Font color, name and size 9 CHANGING FONTS AND COLORS
usecaseStereotypeFontColor blackUsed for stereotype in usecaseusecaseStereotypeFontSize 14usecaseStereotypeFontStyle italic
usecaseStereotypeFontNameusecaseActorFontColor black
Used for actor labels in usecase diagramsusecaseActorFontSize 14usecaseActorFontStyle plainusecaseActorFontNameusecaseActorStereotypeFontColor black
Used for stereotype for actorusecaseActorStereotypeFontSize 14usecaseActorStereotypeFontStyle italicusecaseActorStereotypeFontNameusecaseArrowFontColor black
Usado para texto en las echas de los diagramas de casos de usousecaseArrowFontSize 13usecaseArrowFontStyle plainusecaseArrowFontNamefooterFontColor black
Used for footerfooterFontSize 10footerFontStyle plainfooterFontNameheaderFontColor black
Used for headerheaderFontSize 10headerFontStyle plainheaderFontName
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 91 of 100
9.5 Black and White 9 CHANGING FONTS AND COLORS
9.5 Black and WhiteYou can force the use of a black white 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, January 23, 2011 (Version 6085) 92 of 100
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 lesUse the !include directive to include le in your diagram.
Imagine you have the very same class that appears in many diagrams. Instead of duplicating thedescription of this class, you can dene a le that contains the description.@startuml!include List.iumlList
10.2 Constant denition 10 PREPROCESSING
10.2 Constant denitionYou can dene 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 >class ACCOUNT >class UID >USER "1" -- "*" ACCOUNTUSER -> UID
@enduml
Of course, you can use the !include directive to dene all your constants in a single le that youinclude in your diagram.
Constant can be undened with the !undef XXX directive.
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 94 of 100
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 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_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 beendened.
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 95 of 100
11 INTERNATIONALIZATION
11 InternationalizationThe PlantUML language use letters to dene 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 system dependant.Normally, it should just be fine, but in some case, you may want to the use another charset. For example, with thecommand line:java -jar plantuml.jar -charset UTF-8 files.txt
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 96 of 100
11.1 Charset 11 INTERNATIONALIZATION
Or, with the ant task:
Depending of your Java installation, the following charset should be available: ISO-8859-1, UTF-8, UTF-16BE,UTF-16LE, UTF-16.
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 97 of 100
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, January 23, 2011 (Version 6085) 98 of 100
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 Change arrow style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.6 Message sequence numbering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.7 Title . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71.8 Splitting diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81.9 Grouping message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91.10 Notes on messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111.11 Some other notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121.12 Formatting using HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131.13 Divider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141.14 Lifeline Activation and Destruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151.15 Participant creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171.16 Incoming and outgoing messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181.17 Stereotypes and Spots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191.18 More information on titles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201.19 Participants englober . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221.20 Removing Footer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231.21 Skinparam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241.22 Skin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2 Diagrama de casos de uso 272.1 Casos de uso . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272.2 Actores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282.3 Basic example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292.4 Extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302.5 Using notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312.6 Stereotypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322.7 Changing arrows direction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332.8 Casos de uso . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342.9 Left to right direction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352.10 Skinparam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3 Class Diagram 373.1 Relations between classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373.2 Label on relations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383.3 Adding methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393.4 Defining visibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403.5 Notes and stereotypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413.6 More on notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423.7 Abstract class and interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433.8 No utilizar letras . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443.9 Hide attributes, methods... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453.10 Specific Spot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463.11 Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473.12 Namespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483.13 Changing arrows direction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493.14 Lollipop interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503.15 Title the diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503.16 Association classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513.17 Skinparam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523.18 Skinned Stereotypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533.19 Splitting large files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 99 of 100
CONTENTS CONTENTS
4 Activity Diagram 554.1 Simple Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554.2 Label on arrows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554.3 Changing arrow direction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564.4 Ramas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 574.5 More on Branches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584.6 Synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 594.7 Long activity description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 604.8 Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 614.9 Partition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 624.10 Ttulo del diagrama . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 634.11 Skinparam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 644.12 Complete example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
5 Component Diagram 675.1 Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675.2 Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 685.3 Basic example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 695.4 Using notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 705.5 Grouping Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715.6 Changing arrows direction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 725.7 Title the diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735.8 Skinparam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
6 State Diagram 756.1 Simple State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 756.2 Composite state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 766.3 Long name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 776.4 Concurrent state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 786.5 direccin de la flecha . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 796.6 Note . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 806.7 More in notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
7 Objects Diagram 827.1 Definition of objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 827.2 Relations between objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 827.3 Adding fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
8 Common commands 848.1 Footer and header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 848.2 Zoom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 858.3 Rotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
9 Changing fonts and colors 879.1 Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 879.2 Nested . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 879.3 Color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 889.4 Font color, name and size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 899.5 Black and White . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
10 Preprocessing 9310.1 Including files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9310.2 Constant definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9410.3 Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
11 Internationalization 9611.1 Charset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
12 Color Names 98
PlantUML : Language Reference Guide, January 23, 2011 (Version 6085) 100 of 100
Sequence DiagramBasic examplesDeclaring participantUse non-letters in participantsMessage to SelfChange arrow styleMessage sequence numberingTitleSplitting diagramsGrouping messageNotes on messagesSome other notesFormatting using HTMLDividerLifeline Activation and DestructionParticipant creationIncoming and outgoing messagesStereotypes and SpotsMore information on titlesParticipants engloberRemoving FooterSkinparamSkin
Diagrama de casos de usoCasos de usoActoresBasic exampleExtensionUsing notesStereotypesChanging arrows directionCasos de usoLeft to right directionSkinparam
Class DiagramRelations between classesLabel on relationsAdding methodsDefining visibilityNotes and stereotypesMore on notesAbstract class and interfaceNo utilizar letrasHide attributes, methods...Specific SpotPackagesNamespacesChanging arrows directionLollipop interfaceTitle the diagramAssociation classesSkinparamSkinned StereotypesSplitting large files
Activity DiagramSimple ActivityLabel on arrowsChanging arrow directionRamasMore on BranchesSynchronizationLong activity descriptionNotesPartitionTtulo del diagramaSkinparamComplete example
Component DiagramComponentsInterfacesBasic exampleUsing notesGrouping ComponentsChanging arrows directionTitle the diagramSkinparam
State DiagramSimple StateComposite stateLong nameConcurrent statedireccin de la flechaNoteMore in notes
Objects DiagramDefinition of objectsRelations between objectsAdding fields
Common commandsFooter and headerZoomRotation
Changing fonts and colorsUsageNestedColorFont color, name and sizeBlack and White
PreprocessingIncluding filesConstant definitionConditions
InternationalizationCharset
Color Names