2

Is it possible to add some notes on tikz-uml diagram? e.g. I wish to add "MSG_PERSIST_VOLUME" under handleMessage (below the arrow line).

\documentclass[border=2pt]{standalone} 
\usepackage[english]{babel} 
\usepackage{tikz} 
\usepackage{tikz-uml} 
\usetikzlibrary{matrix, shapes, positioning} 

\begin{document} 
\small\begin{tikzpicture} 
  \begin{umlseqdiag} 
    \umlactor{user} 
    \umlobject{AudioService} 
    \umlobject[]{Settings} 
    \begin{umlcall}[op=handleMessage(),return=1]{user}{AudioService}
        \begin{umlcall}[op=persistVolume(),return=1]{AudioService}{AudioService}
             \begin{umlcall}[op=putIntForUser(),return=1]{AudioService}{Settings}
                \begin{umlcall}[op=putStringForUser(),return=1]{Settings}{Settings}
                \end{umlcall} 
             \end{umlcall} 
        \end{umlcall} 
    \end{umlcall}
  \end{umlseqdiag} 
\end{tikzpicture} 

 \end{document}

Output: enter image description here

beetlej
  • 947
  • 5
  • 15
  • Do you want to add only text? You can insert a text as node manually. –  Mar 29 '16 at 20:13
  • @ferahfeza Yes,but I wish to get some location info looks like " message1.south west", it's not good idea to use absolute coordinate since it maybe changed after insert more elements. – beetlej Mar 29 '16 at 22:59

1 Answers1

2

If you provide the option name=a to the umlcall environment, the op node will be called a-op (and similarly, the return node is called a-return), so you can use that to position a node.

If you don't provide a name, those nodes are like call-N-op, where N is a counter for umlcalls starting at 1. In other words, if you leave out name=a in the code below, use call-1-op.south instead of a.south.

output of code

\documentclass[border=20pt]{standalone} 
\usepackage[english]{babel} 
\usepackage{tikz-uml} 

\begin{document} 
\small\begin{tikzpicture} 
  \begin{umlseqdiag} 
    \umlactor{user} 
    \umlobject{AudioService} 
    \umlobject[]{Settings} 
    \begin{umlcall}[op=handleMessage(),return=1,name=a]{user}{AudioService}
        \begin{umlcall}[op=persistVolume(),return=1]{AudioService}{AudioService}
             \begin{umlcall}[op=putIntForUser(),return=1]{AudioService}{Settings}
                \begin{umlcall}[op=putStringForUser(),return=1]{Settings}{Settings}
                \end{umlcall} 
             \end{umlcall} 
        \end{umlcall} 
    \end{umlcall}
  \end{umlseqdiag} 

\node [below,font=\scriptsize] at (a-op.south) {MSG\_PERSIST\_VOLUME};
\end{tikzpicture} 
\end{document}
Torbjørn T.
  • 206,688