混合的水平和垂直对齐用例节点

时间:2015-01-01 17:55:56

标签: plantuml

我想在用例图中显示比Graphviz默认更紧凑的节点。比如说以下情况包装在一个矩形中:

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

默认情况下,案例是垂直对齐的。我更倾向于(案例a)并排(案例b)并且(混合案例)居中并且低于先前案例。我也尝试过使用 - [隐藏] - 链接

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

然后(混合大小写)左对齐,案例a和b分开太宽。这就是它看起来如何美丽:

@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

图片在这里: UC format example

1 个答案:

答案 0 :(得分:2)

我通常接受格式化(在使用-left-&gt;,-right-&gt;等进行一些调整之后) 您可以考虑使用skinparam在一列中使用用例(默认,非常紧凑)并按颜色区分它们。这与你要求的不同,但我确实希望它

@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

这导致以下结果: color coded example