在plantUML活动图中绕过一个活动

huangapple go评论63阅读模式
英文:

Bypassing an activity in plantUML activity diagram

问题

我一直在努力弄清楚如何让这张图看起来符合我的喜好。这是我目前为止最接近的一次:

[在plantUML活动图中绕过一个活动][1]

它是通过这段代码实现的:

```
@startuml
:A;
split;
-> A 到 B;
:B;
-> B 到 E;
:E;
-> E 到 G;
split again;
-> A 到 C;
:C;
-> C 到 D;
:D;
-> D 到 F;
:F;
-> F 到 G;
end split;
:G;
@enduml
```

但是缺少了一个从 C 到 F 的箭头,但是我无论如何也搞不明白如何在新的语法中制作它。

我曾经使用旧的语法做过类似的事情,就像这样:

```
@startuml
"A" -left->["A 到 B"] "B"
"A" -right->["A 到 C"] "C"
"B"-->[ "B 到 E"] "E"
"C"-->[ "C 到 D"] "D"
"D"-->[ "D 到 F"] "F"
"C"-->[ "C 到 F"] "F"
"F"-->[ "F 到 G"]"G"
"E"-->[ "E 到 G"] "G"
@enduml
```

这导致了这张图片:

[在plantUML活动图中绕过一个活动][2]

但是这种方法有它的缺点,它是旧的语法,而我个人认为新的语法产生的“矩形”外观比旧语法的曲线更容易阅读。

所以,如何在新的语法中从 C 到 F 添加箭头呢?有些问题,比如《如何在PlantUML UML活动图中引用先前的活动》 已经让我接近了答案,但它们似乎并不完全是我所寻找的。我还研究了graphViz,但是我无法弄清楚如何产生与新的PlantUML语法给我带来的干净方正外观相同的效果,所以这也是失败的。所以,能帮忙吗?

编辑:我注意到我的标签中有错误,我现在已经修复了它,并且在逻辑连接方面,现在两个图像应该是等价的。我还添加了红色箭头和标签,以更清晰地显示我想要实现的内容。感谢所有表达困惑的人,现在情况应该更清晰了。

英文:

I've been trying to figure for the life of me how to get this graph looking how I like it. Here's the closest I've gotten

在plantUML活动图中绕过一个活动

and it has been achieved with this code

@startuml
:A;
split;
  -> A to B;
  :B;
  -> B to E;
  :E;
  -> E to G;
split again;
  -> A to C;
  :C;
  ->C to D;
  :D;
  ->D to F;
  :F;
  ->F to G;
end split;
:G;
@enduml

But it's missing an arrow from C to F and I can't for the life of me figure out how to make it in the new syntax.

I did manage to do something like that with the old syntax like this

@startuml
"A" -left->["A to B"] "B"
"A" -right->["A to C"] "C"
"B"-->["B to E"] "E"
"C"-->["C to D"] "D"
"D"-->["D to F"] "F"
"C"-->["C to F"] "F"
"F"-->["F to G"]"G"
"E"-->["E to G"] "G"
@enduml

which results in this image

在plantUML活动图中绕过一个活动

But this one has the drawbacks of being old syntax and I personally find the "rectangular" look produced by the new syntax much more readable than the curved lines of the old.

So, how to get an arrow from C to F in the new syntax? Some of the questions, like How to reference earlier activity in PlantUML UML Activity Diagram have gotten me close, but they don't quite seem to be what I'm looking for. I also looked into graphViz, but I couldn't figure out how to produce the same kind of clean squared up look that the new plantUML syntax gave me, so that's a bust as well. So, help?

EDIT: I noticed there were mistakes in my labeling, I have hopefully now fixed it and in terms of logical connections, both images shhould now be equivalent. I also added the red arrow and the label on paint to more clearly display what I want to achieve. Thank you to everyone who voiced their confusion, situation should now be much more clear.

答案1

得分: 1

在活动图中,您可以使用`split`来表示绕过。但是,您不能这样做,因为在流程中没有额外的活动绕过该活动。所以,这看起来像是一种条件流。活动图有一种语法(使用菱形节点),所以它看起来像这样:

```plantuml
@startuml diagram name
:A;
split;
  -> A 到 B;
  :B;
  -> B 到 E;
  :E;
  -> E 到 G;
split again;
  -> A 到 C;
  :C;
    if (条件?) then
    :D;
    endif
  :F;
  ->F 到 G;
end split;
:G;
@enduml

在plantUML活动图中绕过一个活动

如果您只是想要一个图表,那么状态图可能更好(这是您的第二个例子,我承认我不理解绕过--它与第一个例子不同)。
无论如何,通常删除leftright的规格会使布局更好。我总是从那个开始。这是您的第二个例子(更好吗?)没有那些:

@startuml
"A"-->[ "A 到 B" ] "B"
"A"-->[ "A 到 C" ] "C"
"B"-->[ "B 到 E" ] "E"
"C"-->[ "C 到 D" ] "D"
"D"-->[ "D 到 F" ] "F"
"C"-->[ "C 到 F" ] "F"
"F"-->[ "F 到 G" ] "G"
"E"-->[ "E 到 G" ] "G"
@enduml

在plantUML活动图中绕过一个活动


<details>
<summary>英文:</summary>

In an activity diagram, you can show a bypass by using `split`. However, you can&#39;t because there&#39;s no extra activity on the flow that bypasses the activity. So, that seems like a conditional flow. Activity diagrams have a syntax (with diamond nodes) so this is how it looks:

```plantuml
@startuml diagram name
:A;
split;
  -&gt; A to B;
  :B;
  -&gt; B to E;
  :E;
  -&gt; E to G;
split again;
  -&gt; A to C;
  :C;
    if (condition?) then
    :D;
    endif
  :F;
  -&gt;F to G;
end split;
:G;
@enduml

在plantUML活动图中绕过一个活动

If you're just trying to get a graph, then maybe a state diagram is better (it's your second example, which I admit I don't understand the bypass -- it's not the same as the first example).
Anyway, removing the left and right specifications usually makes for a better layout. I always start with that. Here's your second example (is it better?) without those:

@startuml
&quot;A&quot;--&gt;[&quot;A to B&quot;] &quot;B&quot;
&quot;A&quot;--&gt;[&quot;A to C&quot;] &quot;C&quot;
&quot;B&quot;--&gt;[&quot;B to E&quot;] &quot;E&quot;
&quot;C&quot;--&gt;[&quot;C to D&quot;] &quot;D&quot;
&quot;D&quot;--&gt;[&quot;D to F&quot;] &quot;F&quot;
&quot;C&quot;--&gt;[&quot;C to F&quot;] &quot;F&quot;
&quot;F&quot;--&gt;[&quot;F to G&quot;] &quot;G&quot;
&quot;E&quot;--&gt;[&quot;E to G&quot;] &quot;G&quot;
@enduml

在plantUML活动图中绕过一个活动

huangapple
  • 本文由 发表于 2023年3月7日 17:59:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/75660454.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定