On PlantUML, you can mix all diagram type and make sub-diagram.
To activate this feature, the sub-diagram must:
- begin with
{{
- end with
}}
.
Here is a basic example of sub-diagram, with adding an
Activty diagram on a note on a
Class diagram:
🎉 Copied!
|
@startuml
abstract ATest {
{static} +String id
{abstract} -void doit()
}
class Test {
-int count
-int max
-int increment
-void doit()
}
ATest <|-- Test
note right of Test::doit()
{{
skinparam backgroundcolor transparent
start
while (count < max?)
:count = count + increment;
endwhile
stop
}}
end note
@enduml
|
[Ref. QA-6947]
By default the background color of a sub-diagram is white.
This can be solved by adding
skinparam Backgroundcolor transparent
to the sub-diagram.
🎉 Copied!
|
@startuml
rectangle A [
{{
rectangle A
}}
]
rectangle B [
{{
skinparam Backgroundcolor transparent
rectangle B
}}
]
@enduml
|
Besides being used in other elements or notes, they can also be used in messages.
For this, the sub-diagram must be all on one line:
🎉 Copied!
|
@startuml
(A) --> (B): \tSub-diagram in a message\n{{\n(C)->(D)\n}}
@enduml
|
Sub-diagram can only herite of the
handwritten
skinparam from the hosted diagram, as:
🎉 Copied!
|
@startuml
skinparam handwritten true
component a {
}
note left of a
handwritten is OK
end note
note right of a
{{
a->b:test
note right
handwritten is inherited
end note
}}
end note
@enduml
|
[Ref. QA-9043]