我正在使用TikZ-UML 手册第 3 章“用例图”的最后一个例子(第 34-35 页)。
请考虑这个MWE:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\usepackage{amsmath}
\usepackage{silence}
\WarningFilter{pgf}{Your graphic driver} % FOR DELETE WARNING OF 'Package pgf Warning: Your graphic driver...'. From https://tex.stackexchange.com/q/63522/152550
\usepackage{tikz-uml}
\tikzumlset{fill usecase=white}
\usepackage{pdflscape}
\begin{document}
\begin{landscape}
\begin{tikzpicture}
\begin{umlsystem}[x=6] {Name of the system}
\umlusecase[name=a,width=2.5cm] {Use case a}
\umlusecase[name=b,x=6,width=2.5cm] {Use case b}
\umlusecase[name=c,x=6,y=-3,width=2.5cm] {Use case c}
\umlusecase[name=d,y=-3,width=2.5cm] {Use case d}
\end{umlsystem}
\umlactor[y=-1] {Actor 1}
\umlactor[y=-3] {Actor 2}
\umlactor[x=18] {Actor 3}
\umlassoc{Actor 1}{a}
\umlassoc{Actor 2}{a}
\umlextend{a}{b}
\umlinclude{c}{d}
\end{tikzpicture}
\end{landscape}
\end{document}
如果可能的话,我想实现三个改变:
- 将
Name of the system
标签放在矩形外面(其上方)。 - 将
≪extend≫
和≪include≫
标签置于其线条上方。 Actor 3
向下(或向上)弯曲和之间的关联Use case 1
(而不是\umlassoc{Actor 3}{a}
因为它与重叠\umlextend{a}{b}
)。
我要这个:
据我所见,手册上没有提到这一点。
(@N。基尔巴谢维奇请阅读这个问题!)
谢谢!!
答案1
正如 John Kormylo 所建议的,您可以通过混合常规 TikZ 绘图命令来实现这一点。
对于系统的名称,设置标题为
umlsystem
空,并在其后立即\end{umlsystem}
添加\node [above] at (current bounding box.north) {Name of the system};
虽然可以重新定义
\umlrelation
宏以将“立体声”放置在线条旁边,但使用以下方法手动绘制它们可能同样容易\draw [tikzuml dependency style] (a) -- node[above] {$\ll \text{extend} \gg$} (b); \draw [tikzuml dependency style] (d) -- node[above] {$\ll \text{include} \gg$} (c);
坐标对应于您为四个 s 赋予的名称
\umlusecase
(带有name=a
等)。演员被放置在具有您为演员命名的节点中,因此
a
和之间的弯曲关联Actor 3
可以用\draw [tikzuml association style] (a) to[bend right=10] (Actor 3);
\documentclass[border=5mm]{standalone}
\usepackage{amsmath}
\usepackage{tikz-uml}
\tikzumlset{fill usecase=white}
\begin{document}
\begin{tikzpicture}
\begin{umlsystem}[x=6] {} % empty title
\umlusecase[name=a,width=2.5cm] {Use case a}
\umlusecase[name=b,x=6,width=2.5cm] {Use case b}
\umlusecase[name=c,x=6,y=-3,width=2.5cm] {Use case c}
\umlusecase[name=d,y=-3,width=2.5cm] {Use case d}
\end{umlsystem}
\node [above] at (current bounding box.north) {Name of the system};
\umlactor[y=-1] {Actor 1}
\umlactor[y=-3] {Actor 2}
\umlactor[x=18] {Actor 3}
\umlassoc{Actor 1}{a}
\umlassoc{Actor 2}{a}
% \umlextend{a}{b}
% \umlinclude{c}{d}
% manual versions of the above
\draw [tikzuml dependency style] (a) -- node[above] {$\ll \text{extend} \gg$} (b);
\draw [tikzuml dependency style] (d) -- node[above] {$\ll \text{include} \gg$} (c);
% bent association
\draw [tikzuml association style] (a) to[bend right=10] (Actor 3);
\end{tikzpicture}
\end{document}