1

There is a note connected to the actor me and I would like to have the node connected to the lifeline after the find keys action. Is that possible?

(I tried using name but was always getting errors.)

\documentclass{article}
\usepackage{tikz-uml}
\begin{document}

  \begin{tikzpicture}[auto]
    \begin{umlseqdiag}

      \umlactor[x=0, class=Person]{me}
      \umlboundary[x=6, class=Door]{door}
      \umlcontrol[x=12, class=Bed]{bed}

      \begin{umlcallself}[op={find keys}]{me}
      \end{umlcallself}
      \begin{umlcall}[op={open door}, return={door opened}]{me}{door}
      \end{umlcall}

      \umlnote[x=5,y=-5]{me}{This note should be connected to my lifeline instead of the actor, e.g. after find keys.}

    \end{umlseqdiag}
  \end{tikzpicture}

\end{document

Adding a note to the lifeline.

1 Answer 1

3

Documentation about tikz-uml does not talk about it, but it is possible. In fact, when you define a umlcall (or umlcallself), you draw two activity rectangles. On top and bottom of these rectangles, nodes are defined with special names.

Here is the code for your example:

\begin{tikzpicture}
\begin{umlseqdiag}
\umlactor[x=0, class=Person]{me}
\umlboundary[x=6, class=Door]{door}
\umlcontrol[x=12, class=Bed]{bed}
\begin{umlcallself}[op={find keys}, name=callfk]{me}
\end{umlcallself}
\begin{umlcall}[op={open door}, return={door opened}]{me}{door}
\end{umlcall}
\umlnote[x=5,y=-5]{sb-callfk}{This note should be connected to my lifeline instead of the actor, e.g. after find keys.}
\end{umlseqdiag}
\end{tikzpicture}

By giving a name to the self call "find keys", you can guess the name of these nodes.

For sender, you have on top of its activity rectangle a node called (st-callfk), st standing for "start-top", and at the bottom, a node called (sb-callfk), sb standing for "start-bottom". For receiver, you have on top of its activity rectangle a node called (et-callfk), et standing for "end-top", and at the bottom, a node called (eb-callfk), eb standing for "end-bottom".

I did not expected someone may need to define a note on a lifeline, so current node names are probably improvable. Perhaps using sender/receiver instead of start/end will be better. As I will make a new release of tikz-uml soon, I will update these node names.

1
  • The node names became useful once again, this time to add indexes to the calls so that I can refer to them in the text describing the figure more easily. For example, to add a number 4 to the left of callfk I'm using something similar to \node [anchor=east] at (st-callfk.west) {(4)};. (This is after \end{umlseqdiag}.)
    – Daniel
    Jun 27, 2016 at 12:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .