Diagrama de secuencia

Crear diagramas de secuencia con PlantUML es notablemente sencillo. Esta facilidad de uso se atribuye en gran medida a la naturaleza amigable de su sintaxis, diseñada para ser intuitiva y fácil de recordar.

  • Sintaxis intuitiva:
En primer lugar, los usuarios aprecian la sintaxis sencilla e intuitiva de PlantUML. Este diseño bien pensado significa que incluso aquellos que son nuevos en la creación de diagramas encuentran fácil comprender los conceptos básicos de forma rápida y sin complicaciones.

  • Correlación texto-gráfico:
Otra característica distintiva es la estrecha semejanza entre la representación textual y el resultado gráfico. Esta correlación armoniosa garantiza que los borradores textuales se traduzcan con bastante precisión en diagramas gráficos, proporcionando una experiencia de diseño cohesiva y predecible sin sorpresas desagradables en el resultado final.

  • Proceso de elaboración eficiente:
La fuerte correlación entre el texto y el resultado gráfico no sólo simplifica el proceso de creación, sino que también lo acelera significativamente. Los usuarios se benefician de un proceso más ágil con menos necesidades de revisiones y ajustes que requieren mucho tiempo.

  • Visualización durante la redacción:
La posibilidad de visualizar el resultado gráfico final mientras se redacta el texto es una función que muchos consideran inestimable. Fomenta de forma natural una transición fluida del borrador inicial a la presentación final, mejorando la productividad y reduciendo la probabilidad de errores.

  • Facilidad de edición y revisión:
Es importante destacar que la edición de los diagramas existentes es un proceso sin complicaciones. Dado que los diagramas se generan a partir de texto, los usuarios descubren que realizar ajustes es considerablemente más fácil y preciso que alterar una imagen utilizando herramientas gráficas. Se reduce simplemente a modificar el texto, un proceso mucho más sencillo y menos propenso a errores que realizar cambios a través de una interfaz gráfica con un ratón.

PlantUML facilita un enfoque sencillo y fácil de usar para crear y editar diagramas de secuencia, satisfaciendo las necesidades tanto de principiantes como de diseñadores experimentados. Aprovecha hábilmente la simplicidad de las entradas textuales para elaborar diagramas visualmente descriptivos y precisos, estableciéndose así como una herramienta imprescindible en el conjunto de herramientas de creación de diagramas.

Puede obtener más información sobre algunos de los comandos comunes en Plant UML para mejorar su experiencia de creación de diagramas.

Ejemplo básico

La secuencia -> es usada para dibujar un mensaje entre dos participantes. Los participantes tienen que ser declarados explícitamente.

Para definir una flecha punteada, se debe usar -->

También se puede usar <- y <--. No provoca cambios en el dibujo, pero puede mejorar la legibilidad. Tenga en cuenta que esto sólo es posible en diagramas de secuencia, las reglas son diferentes para otros diagramas.

🎉 Copied!

@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response

Alice -> Bob: Another authentication Request
Alice <-- Bob: another authentication Response
@enduml

WARNING
 This translation need to be updated. 
WARNING

Declarando participantes

Es posible cambiar el orden de los participantes usando la palabra reservada participant.

También es posible el uso de otras palabras reservadas para declarar un participante:
  • actor
  • boundary
  • control
  • entity
  • database
  • collections

🎉 Copied!

@startuml
actor Foo1
boundary Foo2
control Foo3
entity Foo4
database Foo5
collections Foo6
Foo1 -> Foo2 : To boundary
Foo1 -> Foo3 : To control
Foo1 -> Foo4 : To entity
Foo1 -> Foo5 : To database
Foo1 -> Foo6 : To collections

@enduml

Se puede renombrar un participante usando la palabra reservada as.

También es posible cambiar el color de fondo de los actores o participantes.

🎉 Copied!

@startuml
actor Bob #red
' The only difference between actor
'and participant is the drawing
participant Alice
participant "I have a really\nlong name" as L #99FF99
/' You can also declare:
   participant L as "I have a really\nlong name"  #99FF99
  '/

Alice->Bob: Authentication Request
Bob->Alice: Authentication Response
Bob->L: Log transaction
@enduml

You can use the orderkeyword to custom the print order of participant.

🎉 Copied!

@startuml
participant Last order 30
participant Middle order 20
participant First order 10
@enduml

WARNING
 This translation need to be updated. 
WARNING

Declaring participant on multiline

Puedes declarar el participante en múltiples líneas.

🎉 Copied!

@startuml
participant Participant [
    =Title
    ----
    ""SubTitle""
]

participant Bob

Participant -> Bob
@enduml

[Ref. QA-15232]

Sin usar letras en participantes

Puedes usar comillas para definir participantes. Y puedes usar la palabra reservada as para asignar un alias a esos participantes.

🎉 Copied!

@startuml
Alice -> "Bob()" : Hello
"Bob()" -> "This is very\nlong" as Long
' You can also declare:
' "Bob()" -> Long as "This is very\nlong"
Long --> "Bob()" : ok
@enduml

Mensaje a sí mismo

Un participante puede enviarse un mensaje a sí mismo.

También es posible tener varias líneas utilizando \n.

🎉 Copied!

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

🎉 Copied!

@startuml
Alice <- Alice: This is a signal to self.\nIt also demonstrates\nmultiline \ntext
@enduml

[Ref. QA-1361]

Text alignment

Text alignment on arrows can be set to left, right or center using skinparam sequenceMessageAlign.

You can also use direction or reverseDirection to align text depending on arrow direction. Further details and examples of this are available on the skinparam page.

🎉 Copied!

@startuml
skinparam sequenceMessageAlign right
Bob -> Alice : Request
Alice -> Bob : Response
@enduml

Text of response message below the arrow

You can put the text of the response message below the arrow, with the skinparam responseMessageBelowArrow true command.

🎉 Copied!

@startuml
skinparam responseMessageBelowArrow true
Bob -> Alice : hello
Alice -> Bob : ok
@enduml

Cambiar estilo de la flecha

Puede cambiar el estilo de la flecha de diferentes formas:
  • añade una x al final para indicar un mensaje perdido
  • utilice \ o / en lugar de < o > para tener solo la parte inferior o superior de la flecha
  • repite la cabeza de la flecha (por ejemplo, >> o //) para tener un trazo más fino
  • Utilice -- en lugar de - para obtener una flecha punteada.
  • añade una "o" al final de la cabeza de una flecha
  • utilice flechas bidireccionales <->

🎉 Copied!

@startuml
Bob ->x Alice
Bob -> Alice
Bob ->> Alice
Bob -\ Alice
Bob \\- Alice
Bob //-- Alice

Bob ->o Alice
Bob o\\-- Alice

Bob <-> Alice
Bob <->o Alice
@enduml

Cambiar el color de la flecha

Puede cambiar el color de flechas individuales usando la siguiente notación:

🎉 Copied!

@startuml
Bob -[#red]> Alice : hello
Alice -[#0000FF]->Bob : ok
@enduml

Numeración de la secuencia de mensajes

La palabra clave autonumber es usada para añadir automáticamente números a los mensajes.

🎉 Copied!

@startuml
autonumber
Bob -> Alice : Authentication Request
Bob <- Alice : Authentication Response
@enduml

Puedes especificar un número de comienzo con autonumber //número inicial// , y también un incremento con autonumber //número inicial// //incremento//.

🎉 Copied!

@startuml
autonumber
Bob -> Alice : Authentication Request
Bob <- Alice : Authentication Response

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

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

@enduml

Puedes especificar un formato para su número usándolo entre comillas dobles.

El formateo se hace mediante la calse Java DecimalFormat (0 denota un dígito, # denota un digito y cero si está ausente).

Puedes usar alguna etiqueta HTML en el formato.

🎉 Copied!

@startuml
autonumber "<b>[000]"
Bob -> Alice : Authentication Request
Bob <- Alice : Authentication Response

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

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

@enduml

También puedes usar autonumber stop y autonumber resume //increment// //format// para pausar y continuar la numeración automática, respectivamente.

🎉 Copied!

@startuml
autonumber 10 10 "<b>[000]"
Bob -> Alice : Authentication Request
Bob <- Alice : Authentication Response

autonumber stop
Bob -> Alice : dummy

autonumber resume "<font color=red><b>Message 0  "
Bob -> Alice : Yet another authentication Request
Bob <- Alice : Yet another authentication Response

autonumber stop
Bob -> Alice : dummy

autonumber resume 1 "<font color=blue><b>Message 0  "
Bob -> Alice : Yet another authentication Request
Bob <- Alice : Yet another authentication Response
@enduml

*[Ref. [QA-7119](https://forum.plantuml.net/7119/create-links-after-creating-a-diagram?show=7137#a7137)]*
WARNING
 This translation need to be updated. 
WARNING

Page Title, Header and Footer

The title keyword is used to add a title to the page.

Pages can display headers and footers using header and footer.

🎉 Copied!

@startuml

header Page Header
footer Page %page% of %lastpage%

title Example Title

Alice -> Bob : message 1
Alice -> Bob : message 2

@enduml

Dividiendo diagramas

La palabra reservada newpage es empleada para dividir un diagrama en varias imágenes.

Puedes colocar un título para la página nueva justo después de la palabra reservada newpage .

Esto es bastante práctico con Word para devolver diagramas grandes en varias páginas.

🎉 Copied!

@startuml

Alice -> Bob : message 1
Alice -> Bob : message 2

newpage

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

newpage A title for the\nlast page

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

Agrupando mensajes

Es posible agrupar mensajes usando las siguientes palabras reservadas:
  • alt/else
  • opt
  • loop
  • par
  • break
  • critical
  • group, seguida de un texto para mostrar

Es posible añadir un texto que será mostrado en el encabezado (excepto para group).

La palabra reservada end es usada para cerrar el grupo.

Tenga en cuenta que es posible anidar grupos.

🎉 Copied!

@startuml
Alice -> Bob: Authentication Request

alt successful case

    Bob -> Alice: Authentication Accepted

else some kind of failure

    Bob -> Alice: Authentication Failure
    group My own label
    Alice -> Log : Log attack start
        loop 1000 times
            Alice -> Bob: DNS Attack
        end
    Alice -> Log : Log attack end
    end

else Another type of failure

   Bob -> Alice: Please repeat

end
@enduml

WARNING
 This translation need to be updated. 
WARNING

Secondary group label

For group, it is possible to add, between[ and ], a secondary text or label that will be displayed into the header.

🎉 Copied!

@startuml
Alice -> Bob: Authentication Request
Bob -> Alice: Authentication Failure
group My own label [My own label 2]
    Alice -> Log : Log attack start
    loop 1000 times
        Alice -> Bob: DNS Attack
    end
    Alice -> Log : Log attack end
end
@enduml

[Ref. QA-2503]

Notas en mensajes

Es posible colocar notas en mensajes usando las palabras reservadas note left o note rightinmediatamente después del mensaje.

Puedes tener una nota multi-líneas usando la palabra reservada end note .

🎉 Copied!

@startuml
Alice->Bob : hello
note left: this is a first note

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

Bob->Bob : I am thinking
note left
a note
can also be defined
on several lines
end note
@enduml

Algunas otras notas

También es posible colocar notas relativas al participante con las palabras reservadas <code>note left of</code> , note right of o note over .

Es posible resaltar una nota cambiando su color de fondo.

También puedes tener una nota multi-líneas usando la palabra reservada end note .

🎉 Copied!

@startuml
participant Alice
participant Bob
note left of Alice #aqua
This is displayed
left 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, Alice
This is yet another
example of
a long note.
end note
@enduml

WARNING
 This translation need to be updated. 
WARNING

Cambiando el aspecto de las notas

Puedes usar las palabras reservadas hnote y rnote para cambiar el aspecto de las notas.

🎉 Copied!

@startuml
caller -> server : conReq
hnote over caller : idle
caller <- server : conConf
rnote over server
 "r" as rectangle
 "h" as hexagon
endrnote
@enduml

*[Ref. [QA-1765](https://forum.plantuml.net/1765/is-it-possible-to-have-different-shapes-for-notes?show=1806#c1806)]*
WARNING
 This translation need to be updated. 
WARNING

Note over all participants [across]

You can directly make a note over all participants, with the syntax:
  • note across: note_description

🎉 Copied!

@startuml
Alice->Bob:m1
Bob->Charlie:m2
note over Alice, Charlie: Old method for note over all part. with:\n ""note over //FirstPart, LastPart//"".
note across: New method with:\n""note across""
Bob->Alice
hnote across:Note across all part.
@enduml

[Ref. QA-9738]

Several notes aligned at the same level [/]

You can make several notes aligned at the same level, with the syntax /:
  • without /(by default, the notes are not aligned)

🎉 Copied!

@startuml
note over Alice : initial state of Alice
note over Bob : initial state of Bob
Bob -> Alice : hello
@enduml

  • with /(the notes are aligned)

🎉 Copied!

@startuml
note over Alice : initial state of Alice
/ note over Bob : initial state of Bob
Bob -> Alice : hello
@enduml

[Ref. QA-354]

Creole y HTML

También es posible usar sintexis de WikiCreole:

🎉 Copied!

@startuml
participant Alice
participant "The **Famous** Bob" as Bob

Alice -> Bob : hello --there--
... Some ~~long delay~~ ...
Bob -> Alice : ok
note left
  This is **bold**
  This is //italics//
  This is ""monospaced""
  This is --stroked--
  This is __underlined__
  This is ~~waved~~
end note

Alice -> Bob : A //well formatted// message
note right of Alice
 This is <back:cadetblue><size:18>displayed</size></back>
 __left of__ Alice.
end note
note left of Bob
 <u:red>This</u> is <color #118888>displayed</color>
 **<color purple>left of</color> <s:red>Alice</strike> Bob**.
end note
note over Alice, Bob
 <w:#FF33FF>This is hosted</w> by <img sourceforge.jpg>
end note
@enduml

Divisor

Si quieres, puedes dividir un diagrama usando el separador == para separar su diagrama en pasos lógicos.

🎉 Copied!

@startuml

== Initialization ==

Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response

== Repetition ==

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

@enduml

WARNING
 This translation need to be updated. 
WARNING

Referencia

Puedes referenciar en un diagrama utilizando la palabra clave ref over.

🎉 Copied!

@startuml
participant Alice
actor Bob

ref over Alice, Bob : init

Alice -> Bob : hello

ref over Bob
  This can be on
  several lines
end ref
@enduml

Retardo

Puedes usar ... para indicar un retardo en el diagrama. Y también es posible colocar un mensaje con ese retardo.

🎉 Copied!

@startuml

Alice -> Bob: Authentication Request
...
Bob --> Alice: Authentication Response
...5 minutes latter...
Bob --> Alice: Bye !

@enduml

Text wrapping

To break long messages, you can manually add \n in your text.

Another option is to use maxMessageSize setting:

🎉 Copied!

@startuml
skinparam maxMessageSize 50
participant a
participant b
a -> b :this\nis\nmanually\ndone
a -> b :this is a very long message on several words
@enduml

Espaciado

Puedes usar ||| para indicar espaciado en el diagrama.

También es posible especificar un número de píxel para ser usado.

🎉 Copied!

@startuml

Alice -> Bob: message 1
Bob --> Alice: ok
|||
Alice -> Bob: message 2
Bob --> Alice: ok
||45||
Alice -> Bob: message 3
Bob --> Alice: ok

@enduml

Activación y Destrucción de la Línea de vida

activate y deactivate son usados para denotar la activación de un participante.

Una vez que un participante es activado, su línea de vida aparece.

activate y deactivate aplica en el mensaje anterior.

destroy denota el final de la línea de vida de un participante.

🎉 Copied!

@startuml
participant User

User -> A: DoWork
activate A

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

B -> C: DoWork
activate C
C --> B: WorkDone
destroy C

B --> A: RequestCreated
deactivate B

A -> User: Done
deactivate A

@enduml

Puede usarse anidamiento de líneas de vida, y es posible agregar un color a dicha línea de vida.

🎉 Copied!

@startuml
participant User

User -> A: DoWork
activate A #FFBBBB

A -> A: Internal call
activate A #DarkSalmon

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

B --> A: RequestCreated
deactivate B
deactivate A
A -> User: Done
deactivate A

@enduml

WARNING
 This translation need to be updated. 
WARNING

Return

A new command return for generating a return message with optional text label. The point returned to is the point that cause the most recently activated life-line. The syntax is simply return label where label, if provided, can be any string acceptable on conventional messages.

🎉 Copied!

@startuml
Bob -> Alice : hello
activate Alice
Alice -> Alice : some action
return bye
@enduml

Creación de participante

Puedes usar la palabra reservada create justo antes de la primera recepción de un mensaje para recalcar el hecho de que ese mensaje se encuentra creando ese nuevo objeto.

🎉 Copied!

@startuml
Bob -> Alice : hello

create Other
Alice -> Other : new

create control String
Alice -> String
note right : You can also put notes!

Alice --> Bob : ok

@enduml

Shortcut syntax for activation, deactivation, creation

Immediately after specifying the target participant, the following syntax can be used:

  • ++ Activate the target (optionally a color may follow this)
  • -- Deactivate the source
  • ** Create an instance of the target
  • !! Destroy an instance of the target

🎉 Copied!

@startuml
alice -> bob ++ : hello
bob -> bob ++ : self call
bob -> bib ++  #005500 : hello
bob -> george ** : create
return done
return rc
bob -> george !! : delete
return success
@enduml

Then you can mix activation and deactivation, on same line:

🎉 Copied!

@startuml
alice   ->  bob     ++   : hello1
bob     ->  charlie --++ : hello2
charlie --> alice   --   : ok
@enduml

🎉 Copied!

@startuml
@startuml
alice -> bob   --++ #gold: hello
bob   -> alice --++ #gold: you too
alice -> bob   --: step1
alice -> bob   : step2
@enduml
@enduml

[Ref. QA-4834, QA-9573 and QA-13234]

Mensajes entrantes y salientes

Puedes usar flechas entrantes y salientes si quieres centrarte en una parte del diagrama.

Utilice corchetes para denotar el lado izquierdo "[" o el lado derecho "]" del diagrama.

🎉 Copied!

@startuml
[-> A: DoWork

activate A

A -> A: Internal call
activate A

A ->] : << createRequest >>

A<--] : RequestCreated
deactivate A
[<- A: Done
deactivate A
@enduml

También puedes tener la siguiente sintaxis:

🎉 Copied!

@startuml
[-> Bob
[o-> Bob
[o->o Bob
[x-> Bob

[<- Bob
[x<- Bob

Bob ->]
Bob ->o]
Bob o->o]
Bob ->x]

Bob <-]
Bob x<-]
@enduml

WARNING
 This translation need to be updated. 
WARNING

Short arrows for incoming and outgoing messages

You can have short arrows with using ?.

🎉 Copied!

@startuml
?-> Alice    : ""?->""\n**short** to actor1
[-> Alice    : ""[->""\n**from start** to actor1
[-> Bob      : ""[->""\n**from start** to actor2
?-> Bob      : ""?->""\n**short** to actor2
Alice ->]    : ""->]""\nfrom actor1 **to end**
Alice ->?    : ""->?""\n**short** from actor1
Alice -> Bob : ""->"" \nfrom actor1 to actor2
@enduml

[Ref. QA-310]

Anchors and Duration

With teoz it is possible to add anchors to the diagram and use the anchors to specify duration time.

🎉 Copied!

@startuml
!pragma teoz true

{start} Alice -> Bob : start doing things during duration
Bob -> Max : something
Max -> Bob : something else
{end} Bob -> Alice : finish

{start} <-> {end} : some time

@enduml

You can use the -Pcommand-line option to specify the pragma:

java -jar plantuml.jar -Pteoz=true

[Ref. issue-582]

Estereotipos y marcas

Es posible añadir estereotipos a participantes usando << y >>.

En el estereotipo, puedes añadir un carácter marcado en un círculo coloreado usando la sintaxis (X,color).

🎉 Copied!

@startuml

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

Bob->Alice: First message

@enduml

Por defecto, guillemet (comillas) son usadas para mostrar el estereotipo. Puedes cambiar este comportamiento usando skinparam guillemet:

🎉 Copied!

@startuml

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

Bob->Alice: First message

@enduml

🎉 Copied!

@startuml

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

Bob->Alice: First message

@enduml

Mayor información en los títulos

Puedes usar sintaxis de Creole en el título.

🎉 Copied!

@startuml

title __Simple__ **communication** example

Alice -> Bob: Authentication Request
Bob -> Alice: Authentication Response

@enduml

Puedes añadir una nueva línea usando \n en la descripción del título.

🎉 Copied!

@startuml

title __Simple__ communication example\non several lines

Alice -> Bob: Authentication Request
Bob -> Alice: Authentication Response

@enduml

Además puedes definir un título en varias líneas usando las palabras reservadas title y end title .

🎉 Copied!

@startuml

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

Alice -> Bob: Authentication Request
Bob -> Alice: Authentication Response

@enduml

Entorno de participante

Es posible dibujar una caja alrededor de algunos participantes, usando los comandos box y end box .

Puedes añadir un título opcional o un color de fondo opcional, después de la palabra reservada box .

🎉 Copied!

@startuml

box "Internal Service" #LightBlue
participant Bob
participant Alice
end box
participant Other

Bob -> Alice : hello
Alice -> Other : hello

@enduml

WARNING
 This translation need to be updated. 
WARNING

Removiendo pie de página

Puedes usar las palabras reservadas hide footbox para remover el pie de página del diagrama.

🎉 Copied!

@startuml

hide footbox
title Footer removed

Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response

@enduml

Personalización (Skinparam)

Puedes usar el comando skinparam para cambiar los colores y las fuentes de los dibujos

Puedes usar este comando:

También puedes cambiar otros parámetros de renderización, como se ve en los siguientes ejemplos

🎉 Copied!

@startuml
skinparam sequenceArrowThickness 2
skinparam roundcorner 20
skinparam maxmessagesize 60
skinparam sequenceParticipant underline

actor User
participant "First Class" as A
participant "Second Class" as B
participant "Last Class" as C

User -> A: DoWork
activate A

A -> B: Create Request
activate B

B -> C: DoWork
activate C
C --> B: WorkDone
destroy C

B --> A: Request Created
deactivate B

A --> User: Done
deactivate A

@enduml

🎉 Copied!

@startuml
skinparam backgroundColor #EEEBDC
skinparam handwritten true

skinparam sequence {
ArrowColor DeepSkyBlue
ActorBorderColor DeepSkyBlue
LifeLineBorderColor blue
LifeLineBackgroundColor #A9DCDF

ParticipantBorderColor DeepSkyBlue
ParticipantBackgroundColor DodgerBlue
ParticipantFontName Impact
ParticipantFontSize 17
ParticipantFontColor #A9DCDF

ActorBackgroundColor aqua
ActorFontColor DeepSkyBlue
ActorFontSize 17
ActorFontName Aapex
}

actor User
participant "First Class" as A
participant "Second Class" as B
participant "Last Class" as C

User -> A: DoWork
activate A

A -> B: Create Request
activate B

B -> C: DoWork
activate C
C --> B: WorkDone
destroy C

B --> A: Request Created
deactivate B

A --> User: Done
deactivate A

@enduml

Cambiando el relleno

Es posible ajustar algunos parámetros de relleno

🎉 Copied!

@startuml
skinparam ParticipantPadding 20
skinparam BoxPadding 10

box "Foo1"
participant Alice1
participant Alice2
end box
box "Foo2"
participant Bob1
participant Bob2
end box
Alice1 -> Bob1 : hello
Alice1 -> Out : out
@enduml

Appendix: Examples of all arrow type

Normal arrow

🎉 Copied!

@startuml
participant Alice as a
participant Bob   as b
a ->     b : ""->   ""
a ->>    b : ""->>  ""
a -\     b : ""-\   ""
a -\\    b : ""-\\\\""
a -/     b : ""-/   ""
a -//    b : ""-//  ""
a ->x    b : ""->x  ""
a x->    b : ""x->  ""
a o->    b : ""o->  ""
a ->o    b : ""->o  ""
a o->o   b : ""o->o ""
a <->    b : ""<->  ""
a o<->o  b : ""o<->o""
a x<->x  b : ""x<->x""
a ->>o   b : ""->>o ""
a -\o    b : ""-\o  ""
a -\\o   b : ""-\\\\o""
a -/o    b : ""-/o  ""
a -//o   b : ""-//o ""
a x->o   b : ""x->o ""
@enduml

Itself arrow

🎉 Copied!

@startuml
participant Alice as a
participant Bob   as b
a ->     a : ""->   ""
a ->>    a : ""->>  ""
a -\     a : ""-\   ""
a -\\    a : ""-\\\\""
a -/     a : ""-/   ""
a -//    a : ""-//  ""
a ->x    a : ""->x  ""
a x->    a : ""x->  ""
a o->    a : ""o->  ""
a ->o    a : ""->o  ""
a o->o   a : ""o->o ""
a <->    a : ""<->  ""
a o<->o  a : ""o<->o""
a x<->x  a : ""x<->x""
a ->>o   a : ""->>o ""
a -\o    a : ""-\o  ""
a -\\o   a : ""-\\\\o""
a -/o    a : ""-/o  ""
a -//o   a : ""-//o ""
a x->o   a : ""x->o ""
@enduml

Incoming and outgoing messages (with '[', ']')

Incoming messages (with '[')

🎉 Copied!

@startuml
participant Alice as a
participant Bob   as b
[->      b : ""[->   ""
[->>     b : ""[->>  ""
[-\      b : ""[-\   ""
[-\\     b : ""[-\\\\""
[-/      b : ""[-/   ""
[-//     b : ""[-//  ""
[->x     b : ""[->x  ""
[x->     b : ""[x->  ""
[o->     b : ""[o->  ""
[->o     b : ""[->o  ""
[o->o    b : ""[o->o ""
[<->     b : ""[<->  ""
[o<->o   b : ""[o<->o""
[x<->x   b : ""[x<->x""
[->>o    b : ""[->>o ""
[-\o     b : ""[-\o  ""
[-\\o    b : ""[-\\\\o""
[-/o     b : ""[-/o  ""
[-//o    b : ""[-//o ""
[x->o    b : ""[x->o ""
@enduml

Outgoing messages (with ']')

🎉 Copied!

@startuml
participant Alice as a
participant Bob   as b
a ->]      : ""->]   ""
a ->>]     : ""->>]  ""
a -\]      : ""-\]   ""
a -\\]     : ""-\\\\]""
a -/]      : ""-/]   ""
a -//]     : ""-//]  ""
a ->x]     : ""->x]  ""
a x->]     : ""x->]  ""
a o->]     : ""o->]  ""
a ->o]     : ""->o]  ""
a o->o]    : ""o->o] ""
a <->]     : ""<->]  ""
a o<->o]   : ""o<->o]""
a x<->x]   : ""x<->x]""
a ->>o]    : ""->>o] ""
a -\o]     : ""-\o]  ""
a -\\o]    : ""-\\\\o]""
a -/o]     : ""-/o]  ""
a -//o]    : ""-//o] ""
a x->o]    : ""x->o] ""
@enduml

Short incoming and outgoing messages (with '?')

Short incoming (with '?')

🎉 Copied!

@startuml
participant Alice as a
participant Bob   as b
a ->     b : //Long long label//
?->      b : ""?->   ""
?->>     b : ""?->>  ""
?-\      b : ""?-\   ""
?-\\     b : ""?-\\\\""
?-/      b : ""?-/   ""
?-//     b : ""?-//  ""
?->x     b : ""?->x  ""
?x->     b : ""?x->  ""
?o->     b : ""?o->  ""
?->o     b : ""?->o  ""
?o->o    b : ""?o->o ""
?<->     b : ""?<->  ""
?o<->o   b : ""?o<->o""
?x<->x   b : ""?x<->x""
?->>o    b : ""?->>o ""
?-\o     b : ""?-\o  ""
?-\\o    b : ""?-\\\\o ""
?-/o     b : ""?-/o  ""
?-//o    b : ""?-//o ""
?x->o    b : ""?x->o ""
@enduml

Short outgoing (with '?')

🎉 Copied!

@startuml
participant Alice as a
participant Bob   as b
a ->     b : //Long long label//
a ->?      : ""->?   ""
a ->>?     : ""->>?  ""
a -\?      : ""-\?   ""
a -\\?     : ""-\\\\?""
a -/?      : ""-/?   ""
a -//?     : ""-//?  ""
a ->x?     : ""->x?  ""
a x->?     : ""x->?  ""
a o->?     : ""o->?  ""
a ->o?     : ""->o?  ""
a o->o?    : ""o->o? ""
a <->?     : ""<->?  ""
a o<->o?   : ""o<->o?""
a x<->x?   : ""x<->x?""
a ->>o?    : ""->>o? ""
a -\o?     : ""-\o?  ""
a -\\o?    : ""-\\\\o?""
a -/o?     : ""-/o?  ""
a -//o?    : ""-//o? ""
a x->o?    : ""x->o? ""
@enduml

Specific SkinParameter

By default

🎉 Copied!

@startuml
Bob -> Alice : hello
Alice -> Bob : ok
@enduml

LifelineStrategy

  • nosolid (by default)

🎉 Copied!

@startuml
skinparam lifelineStrategy nosolid
Bob -> Alice : hello
Alice -> Bob : ok
@enduml

[Ref. QA-9016]

  • solid
In order to have solid life line in sequence diagrams, you can use: skinparam lifelineStrategy solid

🎉 Copied!

@startuml
skinparam lifelineStrategy solid
Bob -> Alice : hello
Alice -> Bob : ok
@enduml

[Ref. QA-2794]

style strictuml

To be conform to strict UML (for arrow style: emits triangle rather than sharp arrowheads), you can use:
  • skinparam style strictuml

🎉 Copied!

@startuml
skinparam style strictuml
Bob -> Alice : hello
Alice -> Bob : ok
@enduml

[Ref. QA-1047]

Hide unlinked participant

By default, all participants are displayed.

🎉 Copied!

@startuml
participant Alice
participant Bob
participant Carol

Alice -> Bob : hello
@enduml

But you can hide unlinked participant.

🎉 Copied!

@startuml
hide unlinked
participant Alice
participant Bob
participant Carol

Alice -> Bob : hello
@enduml

[Ref. QA-4247]

Color a group message

It is possible to color a group messages:

🎉 Copied!

@startuml
Alice -> Bob: Authentication Request
alt#Gold #LightBlue Successful case
    Bob -> Alice: Authentication Accepted
else #Pink Failure
    Bob -> Alice: Authentication Rejected
end
@enduml

[Ref. QA-4750 and QA-6410]

Mainframe

🎉 Copied!

@startuml
mainframe This is a **mainframe**
Alice->Bob : Hello
@enduml

[Ref. QA-4019 and Issue#148]

Slanted or odd arrows

You can use the (nn) option (before or after arrow) to make the arrows slanted, where nn is the number of shift pixels.

[Available only after v1.2022.6beta+]

🎉 Copied!

@startuml
A ->(10) B: text 10
B ->(10) A: text 10

A ->(10) B: text 10
A (10)<- B: text 10
@enduml

🎉 Copied!

@startuml
A ->(40) B++: Rq
B -->(20) A--: Rs
@enduml

[Ref. QA-14145]

🎉 Copied!

@startuml
!pragma teoz true
A ->(50) C: Starts\nwhen 'B' sends
& B ->(25) C: \nBut B's message\n arrives before A's
@enduml

[Ref. QA-6684]

🎉 Copied!

@startuml
!pragma teoz true

S1 ->(30) S2: msg 1\n
& S2 ->(30) S1: msg 2

note left S1: msg\nS2 to S1
& note right S2: msg\nS1 to S2
@enduml

[Ref. QA-1072]


Privacy Policy      Advertise