使用标准 tikZ 命令修改 UML-tikz 元素的样式

使用标准 tikZ 命令修改 UML-tikz 元素的样式

我使用 UML-tikZ 包来创建 UML 状态机。有时我想更改给定元素的外观。例如,我想放大元素 \umltrans(第 13 行)的箭头。愚蠢的是,一个完全不同的箭头放大了,这与此转换完全无关。您能告诉我是否以及如何使用 tikZ 库中的命令更改 UML 元素的样式吗?

\documentclass[tikz]{standalone}
\usetikzlibrary{positioning, calc, shadings, shadows, shapes.arrows, arrows.meta, matrix, mindmap}
\usepackage{tikz-uml}
\begin{document}
\begin{tikzpicture}
\begin{umlstate}[name=Statemaschine,fill=yellow!20]{Lightcontrol}
    \umlstateinitial[name=start, x=0,y=3]{start}
    \umlbasicstate [name=manuel, fill=red!20, width=5cm] {manuel}
    \umlbasicstate [name=waiting,below left=4of manuel,fill=red!20, width=5cm,] {witing}
    \umlbasicstate [name=auto,below right=4of manuel,fill=red!20, width=5cm] {auto}
    \umlbasicstate [name=time,below=8of manuel,fill=red!20, width=5cm] {time}
    \umltrans[geometry =-|]{start}{waiting}
    \umltrans[->,/tikz/arrows={-Straight Barb[angle=60:9pt 3]}]{waiting}{auto}
\end{umlstate}
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案1

对于状态转换宏,这是默认样式:

\tikzstyle{tikzuml transition style}=[color=\tikzumlDefaultDrawColor, rounded corners, -angle 45]

您可以在序言中定义自己的样式来改变特定的转换。

A

\documentclass[tikz]{standalone}

\usetikzlibrary{positioning,calc,shadings,shadows,shapes.arrows,arrows.meta,matrix,mindmap}
\usepackage{tikz-uml}

\tikzstyle{tikzuml transition style2}=[color=blue, rounded corners, arrows={-Straight Barb[angle=60:9pt 3]}]% added <<<<

\tikzstyle{tikzuml transition style3}=[color=red, rounded corners, arrows={-Latex[angle=40:5.5mm]}]% added <<<<

\begin{document}
    \begin{tikzpicture}
        \begin{umlstate}[name=Statemaschine,fill=yellow!20]{Lightcontrol}
            
            \umlstateinitial[name=start,x=0,y=3,]{start}
            \umlbasicstate[name=manuel,fill=red!20,width=5cm]{manuel}
            \umlbasicstate[name=waiting,below left=1 of manuel,fill=red!20,width=5cm,]{waiting}
            \umlbasicstate[name=auto,below right=1 of manuel,fill=red!20,width=5cm]{auto}
            \umlbasicstate[name=time,below=8 of manuel,fill=red!20,width=5cm]{time}
            \umlHVtrans[tikzuml transition style2]{start}{waiting} % changed <<<<<<<<<<<<
            \umltrans[tikzuml transition style3]{waiting}{auto}% changed <<<<<<<<<<<<
            
        \end{umlstate}
    \end{tikzpicture}
\end{document}

类似地,状态的默认样式

\tikzstyle{tikzuml state style}=[rectangle split, rectangle split parts=2, rounded corners, inner xsep=1.5ex]%

可以被重新定义。

相关内容