代码在这里-
\documentclass{standalone}
\usepackage{pgf-umlcd}
\begin{document}
\begin{tikzpicture}
\begin{class}[text width = 8cm]{JavaLanguageBehavior}{0,0}
\attribute{$\sim$ com.alhelal.textpad}
\attribute{- uniqueInstance : JavaLanguageBehavior}
\operation{+ getUniqueInstance : JavaLanguageBehavior}
\operation{+ runCode(file : File) : BufferedReader}
\operation{+ buildCode(file : File) : BufferedReader}
\operation{+ setHighlightableText()}
\operation{+ setAutoCompletableText()}
\end{class}
\node [above=3mm] at (current bounding box.north) {Singleton Pattern};
\end{tikzpicture}
\end{document}
当我使用-
(private) 作为可见性时,uniqueInstance
变量移到左侧。如何对齐可见性和变量?
答案1
假设您想要使用$-$
,以便它变成减号而不是连字符,这反过来意味着宽度相似。
为了保持一致性,在数学模式中也设置加号。
\documentclass{standalone}
\usepackage{pgf-umlcd}
\begin{document}
\begin{tikzpicture}
\begin{class}[text width = 8cm]{JavaLanguageBehavior}{0,0}
\attribute{$\sim$ com.alhelal.textpad}
\attribute{$-$ uniqueInstance : JavaLanguageBehavior}
\operation{$+$ getUniqueInstance : JavaLanguageBehavior}
\operation{$+$ runCode(file : File) : BufferedReader}
\operation{$+$ buildCode(file : File) : BufferedReader}
\operation{$+$ setHighlightableText()}
\operation{$+$ setAutoCompletableText()}
\end{class}
\node [above=3mm] at (current bounding box.north) {Singleton Pattern};
\end{tikzpicture}
\end{document}