我一直在尝试使用包中的所有选项tikz-uml
来为两个未对齐的类获取一条直线
\usepackage{float}
\usepackage{tikz}
\usepackage{tikz-uml}
\usepackage{adjustbox}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows.meta}
\begin{document}\errorcontextlines=9
\begin{figure}[H]
\centering
\begin{tikzpicture}
\umlclass[]{ApplicationController}
{
}
{
}
\umlclass[below right=2cm and -1cm of ApplicationController]{RelayHandler}{}
{
}
\umluniassoc[]{ApplicationController}{RelayHandler}
\end{tikzpicture}
\end{figure}
\end{document}
我需要的是
答案1
使用 calc 库,我在“应用程序控制器”框边缘(aux)
的中心和“RelayHandler”节点的边缘放置一个辅助点。然后使用语法,我放置箭头。south east
north west
|-
\documentclass[tikz,border=1mm]{standalone}
\usepackage{float}
\usepackage{tikz}
\usepackage{tikz-uml}
\usepackage{adjustbox}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows.meta,calc}
\tikzset{> = {Straight Barb[length=4pt,width=3.4pt]}}
\begin{document}\errorcontextlines=9
%\begin{figure}[H]
% \centering
\begin{tikzpicture}
\umlclass[]{ApplicationController}
{
}
{
}
\umlclass[below right=2cm and -1cm of ApplicationController]{RelayHandler}{}
{
}
% \umluniassoc[]{ApplicationController}{RelayHandler}
\coordinate (aux) at ($(ApplicationController.south east)!.5!(RelayHandler.north west)$);
\draw[->](ApplicationController.south-|aux)--(aux|-RelayHandler.north);
\end{tikzpicture}
%\end{figure}
\end{document}