我目前正在尝试使用 tikz-uml 包创建 uml 活动图。但是,我希望我的 uml 活动有一个简单的主体,而不是现在的“矩形分割”式主体。
梅威瑟:
\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-uml}
\begin{document}
\begin{tikzpicture}
\umlbasicstate [y=-10, rectangle] {I am a state}
\end{tikzpicture}
\end{document}
我尝试将 tikz-uml.sty 的第 2988 行从
\tikzstyle{tikzuml 状态样式}=[矩形分割,矩形分割部分=2,圆角,内部 xsep=1.5ex]
到
\tikzstyle{tikzuml 状态样式}=[矩形,圆角,内部 xsep=1.5ex]
但似乎并没有改变什么。
答案1
您可以将tikz-uml
节点与常规、可自定义的tikz
节点混合使用。在下面的示例中,为简单状态定义了一种样式,以连接到 uml 节点。
代码:
\documentclass{article}
\usepackage{tikz-uml}
\tikzset{singlestate/.style={draw,fill=yellow!20, rounded corners}}
\begin{document}
\begin{tikzpicture}
\umlstateinitial[name=initial]
\node[singlestate] at (5,0) (create){Create ticket};
\umlstatedecision[y=-3,x=5,name=decision]
\node[singlestate] at (1,-3)(reproduce){Reproduce issue};
\node[singlestate] at (10,-3)(update){Update ticket};
\umltrans{initial}{create}
\umltrans{create}{decision}
\umltrans{update}{decision}
\umltrans{decision}{reproduce}
\end{tikzpicture}
\end{document}
结果:
答案2
没有活动图包!
您正在尝试使用TikZ的UML画一个活动图,但引用他们的文件:
该包包含完整的类图、用例图、序列图、状态图和组件图的定义
所以,这个包并非设计用于支持活动图它的“竞争对手”,pgf-umlcd和pgf-umlsd,仅支持类图和序列图(分别)。
所有这些都是 UML 图的示例,但它们与活动图不同。
据我所知,没有活动图的类,但您可以在线找到多个示例,或者轻松构建自己的示例。
我的例子
\documentclass[border=20pt]{standalone}
\renewcommand\familydefault{\sfdefault} % Default family: serif
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{arrows.meta,arrows}
\usetikzlibrary{positioning}
\tikzset{
initial/.style={circle, fill},
decision/.style={diamond, black, draw},
action/.style={rectangle, draw, rounded corners},
arrow/.style={draw, -{Latex[length=3mm]}, thick}
}
\begin{document}
\begin{tikzpicture}[node distance=1.5cm]
% Frame
\draw [rounded corners] (-4,-1.5) rectangle (7, -8.5);
\node (title) at (5.2, -2) {\textbf{Teaching a class}};
% Nodes
\node[initial] (initial) at (0,-1) {};
\node[action, below of = initial] (ask) {Ask for questions};
\node[decision, below of= ask] (decision1) {};
\node[action, below left = 1cm and 1cm of decision1] (answer) {Answer question};
\node[action, right = 2.3cm of decision1] (intro) {Introduce class};
\node[decision, below of=intro] (decision2) {};
\node[action, below left = 1cm and 1cm of decision2] (quiz) {Distribute quiz};
\node[action, below right = 1cm and 1cm of decision2] (class) {Start class};
% Arrow
\draw [arrow] (initial) -- (ask);
\draw [arrow] (ask) -- (decision1);
\draw [arrow] (decision1) -- node[above, pos=1pt]{[Question]} ++(-2cm, 0) -| (answer);
\draw [arrow] (answer) -- ++(2cm, 0) -| (decision1);
\draw [arrow] (decision1) -- node[above, pos=.4pt]{[No question]} (intro);
\draw [arrow] (intro) -- (decision2);
\draw [arrow] (decision2) -- node[above, pos=1pt]{[Quiz]} ++(-2cm, 0) -| (quiz);
\draw [arrow] (decision2) -- node[above, pos=.7pt]{[No quiz]} ++(2cm, 0) -| (class);
% Etc.
\draw[thick] (quiz) -- ++(0, -1);
\draw[dotted, thick] ($ (quiz)+(0,-1)$) -- ++(0, -.33);
\draw[thick] (class) -- ++(0, -1);
\draw[dotted, thick] ($ (class)+(0,-1)$) -- ++(0, -.33);
\end{tikzpicture}
\end{document}
会给你: