I would like to be able to reuse components in a state diagram using TikZ-UML. I created a savebox
called \giraffe
with two components inside and I would like to place these above the initial node and below the final node. The code doesn't seem to produce the required result. Any idea why?
\documentclass{report}
\usepackage{tikz}
\usepackage{tikz-uml}
\usetikzlibrary{arrows,positioning,shapes}
\begin{document}
\begin{tikzpicture}[auto]
\newsavebox{\giraffe}
\savebox{\giraffe}{
\umlbasicstate[x=0, y=0, fill=pink, width=15ex]{test1}
\umlbasicstate[x=3, y=0, fill=yellow, width=15ex]{test2}
}
\umlstateinitial[x=0, y=11, name=initial]
\umlbasicstate[x=0, y=9, name=a, fill=white, width=15ex]{a}
\umlbasicstate[x=0, y=6, name=b, fill=white, width=15ex]{b}
\umlbasicstate[x=0, y=3, name=c, fill=white, width=15ex]{c}
\umlstatefinal[x=0, y=1, name=final]
\node [below of=final] {\usebox{\giraffe}}; % below final
\node [above of=initial] {\usebox{\giraffe}}; % above initial
\umltrans{initial}{a}
\umltrans{a}{b}
\umltrans{b}{c}
\umltrans{c}{final}
\end{tikzpicture}
\end{document}
Note: the code above is compiling but tikz-uml
is a non-standard package; it can be downloaded from here.
\def
instead of a box approach wouldn't save computer cycles, but would save typing. Which savings is your goal?\def
still allow me to choose the location of the inner nodes? [ Note: I was able to successfully do this using simple rectangles, but for some reason similar code does not work with\umlbasicstate
. ]tikz-uml
does not come by default. I downloaded the.sty
from perso.ensta-paristech.fr/~kielbasi/tikzuml.