我正在使用 Tikz-Uml 包,当多个类实现相同的接口时,我不断收到重叠的虚线:
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usepackage{tikz-uml}
\begin{document}
\begin{tikzpicture}
\umlclass[x=-4, y=0]{First}{}{
\umlvirt{+execute(): bool}
}
\umlclass[x=-4, y=-4, type=abstract]{Second}{}{
\umlvirt{+execute(): bool}
}
\umlclass[x=2, y=-4]{Third}{}{
+execute(): bool \\
}
\umlclass[x=2, y=-6]{Fourth}{}{
+execute(): bool \\
}
\umlclass[x=2, y=-8]{Fifth}{}{
+execute(): bool \\
}
\umlimpl{Third}{Second}
\umlHVHimpl[anchors=west and east]{Fourth}{Second}
\umlHVHimpl[anchors=west and east]{Fifth}{Second}
\end{tikzpicture}
\end{document}
结果:
如何避免第四类和第五类的关联中虚线重叠?
答案1
我认为可以通过调整 UML 元素的位置来手动解决。也许这种方法不太好,但很有用。
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usepackage{tikz-uml}
\begin{document}
\begin{tikzpicture}
\umlclass[x=-4, y=0]{First}{}{
\umlvirt{+execute(): bool}
}
\umlclass[x=-4, y=-4, type=abstract]{Second}{}{
\umlvirt{+execute(): bool}
}
\umlclass[x=2, y=-4]{Third}{}{
+execute(): bool \\
}
\umlclass[x=2, y=-6.1]{Fourth}{}{%previous y - 0.1
+execute(): bool \\
}
\umlclass[x=2, y=-8.2]{Fifth}{}{%previous y - 0.2
+execute(): bool \\
}
\umlimpl{Third}{Second}
\umlHVHimpl[anchors=west and east]{Fourth}{Second}
\umlHVHimpl[anchors=west and east]{Fifth}{Second}
\end{tikzpicture}
\end{document}
结果