embed sub diagrams in diagram like a note

+2 votes
asked Jan 8 in Wanted features by glenflet

I want to be able to write something like this

@startuml

abstract ATest {
  {static} +String id
  {abstract} -void doit()
}

class Test {
  -int count
  -int max
  -int increment
  -void doit()
}

ATest <|-- Test

subdiagram right of  Test::doit
    start

    while (count < max?)
      :count = count + increment;
    endwhile
    
    stop
end subdiagram
@enduml

such that it would draw something like

image

but with the activity diagram

image

in the note rather than the code to define the activity diagram.

I would like this to work for any set of diagrams (in the start/end(uml) block) with unlimited levels of nesting, but am currently only looking to embed activity diagrams in class diagrams.

1 Answer

0 votes
answered Jan 26 by Anthony-Gaudino (7,540 points)

You can do this:

@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()
{{
    start

    while (count < max?)
      :count = count + increment;
    endwhile

    stop
}}
end note
@enduml

you may also embed a diagram as an image.

...