2

I want to display nodes in a Use Case diagram more compact than Graphviz does by default. Say for example the following cases are wrapped in a rectangle:

actor A
actor B
A - (case a)
(case b) - B
A - (mixed case)
(mixed case) - B

By default the cases are aligned vertically. I'd prefer to have (case a) an (case b) side-by-side and (mixed case) centred and below the previous cases. I've also tried to use -[hidden]- links

(case a) -[hidden]- (case b)

but then (mixed case) gets left aligned and cases a and b are too wide apart. Here's how it looks in full beauty:

@startuml
left to right direction
Source  <<Operator>>
Sink    <<Operator>>
Source ..> Sink : notify service address
rectangle "Init phase" {
    Source -> (Prepare service)
    (Prepare service) -[hidden]-(Register with service)
    (Register with service) <- Sink
    Source -> (Secure channel) : <<initiate>>
    (Secure channel) <-- Sink : <<participate>>
    Source --> (Ensure readiness) : <<participate>>
    (Ensure readiness) <- Sink : <<initiate>>
}
@enduml

Image here: UC format example

Adriaan
  • 3,282
  • 1
  • 23
  • 31
lusitania
  • 45
  • 1
  • 8

1 Answers1

2

I usually accept the formatting (after a bit of tweaking with -left->, -right-> etc.) You might consider the use of skinparam to have use cases in one column (default, very compact) and distinguish them by color. This is different than what you have asked for, but I do hope that it

@startuml
left to right direction
Source  <<Operator>>
Sink    <<Operator>>

Source ..> Sink : notify service address
skinparam usecase {
    BackgroundColor<< Source >> DarkSeaGreen
    BorderColor<< Source >> DarkSlateGray

    BackgroundColor<< Both >> YellowGreen
    BorderColor<< Both >> YellowGreen

    BackgroundColor<< Sink >> Yellow
    BorderColor<< Sink >> Yellow

}


rectangle "Init phase" {
    Source -> (Prepare service)<<Source>>
    ' (Prepare service) -[hidden]-(Register with service)
    Source -> (Secure channel)<<Both>> : initiate
    (Secure channel) <-- Sink : <<participate>>
    Source --> (Ensure readiness) : <<participate>>
    (Ensure readiness)<<Both>> <- Sink : <<initiate>>
    (Register with service)<<Sink>> <- Sink
}
@enduml

This results in the following: color coded example

Adriaan
  • 3,282
  • 1
  • 23
  • 31