1

enter image description here

code here-

\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}

When I use a -(private) as visibility the uniqueInstance variable goes to left. How can I align the visibility and variables?

1 Answer 1

2

Presumably you want to use $-$, so that it becomes a minus sign instead of a hyphen, which in turn means that the widths are similar.

For consistency, set the plus signs in math mode as well.

output of code

\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}
3
  • Thank you. I guessed that you will answer. But should I need $+$ for + instead of only +?
    – alhelal
    Nov 1, 2017 at 14:03
  • @alhelal Didn't seem to make a difference in this case, I did it just for consistency. But it will depend on font setup, if you're using a math font with smaller plus/minus signs you could see a small difference. Nov 1, 2017 at 14:08
  • Yes. Consistency is important. I recommend you to mention this in answer why you write extra $. Thank you.
    – alhelal
    Nov 1, 2017 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.