1

I try to use tikz-uml package to draw state diagrams. I am in big trouble with positioning of the states. If there is text inside the states (eg. in state0), it seems that the anchors of this state become damaged. Without text it works as expected. Another problem is the size of the parrent state. It does not fit to the sizes of the substates, if there is text in the substates. I hope somebody can help me please.

    \documentclass[a4paper,11pt, svgnames]{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{Z:/Latex_lib/TikzUml/tikzuml-v1.0-2016-03-29/tikz-uml}


\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\begin{document}

\resizebox{\textwidth}{!}{
\begin{tikzpicture}
\begin{umlstate}[ x=0, y=0, name=swing]{swing}

%   \umlbasicstate[x=0, anchor= west, name=state0,  fill=white, 
%   %entry={vorgabe Getriebestellung},
%   ]{0}

    \begin{umlstate}[x=0, anchor= west, name=state0,  fill=white, 
    entry={vorgabe Getriebestellung},   
    ]{0}
    %\umlstatetext{test\\ lkjasdfklasd}
    \end{umlstate}

    \umlbasicstate[right=1.5cm of state0-body.east, anchor=west,
    name=state1,  fill=white]{1}
    \umlbasicstate[right=2.8cm of state1-body.east, anchor=west, name=state2,  fill=white,
    %entry = {servo\\ deaktivieren},
    %exit = {servo\\ aktivieren}
    ]{2}    


    \umlstatedecision [below right=2cm and 2cm of state1-body.south east, anchor = west, name=decision]

    \umltrans [anchor1=east, anchor2=west ]{state0}{state1}
    \umlVHtrans [anchor1 = south]{state1}{decision}
    \umlVHtrans[anchor2=east, arg={einstellung nicht erreicht}, text width = 1.2cm, pos=1.6]{decision}{state1}  
    \umlHVtrans [anchor2=-50, arg={einstellung erreicht}, text width = 1cm, pos=0.3]{decision}{state2}


\end{umlstate}

\umltrans[recursive=-150|-60|1cm, recursive direction=bottom to bottom]{swing}{swing}

\umlbasicstate[left=1cm of swing-body.south west, anchor=south east, name=lifterDown]{lifter down}
\umlbasicstate[right=1cm of swing-body.south east, anchor=south west, name=lifterUp]{lifter up}
\umlHVtrans [anchor1=east, anchor2=north, arg={Arm heben}, text width = 1cm,pos=0.6 ]{state2}{lifterUp}
\umlVHtrans [anchor1=north, anchor2=west, arg={unterer Endpunkt erreicht}, text width = 1cm,pos=1.4  ]{lifterDown}{state0}

\node [coordinate, left=0.5cm of lifterDown.west](in1){};
\node [coordinate, below=0.5cm of lifterDown.south](out1){};
\umltrans [anchor2=west ]{in1}{lifterDown}
\umltrans [anchor1=south]{lifterDown}{out1}

\node [coordinate, right=0.5cm of lifterUp.east](in2){};
\node [coordinate, below=0.5cm of lifterUp.south](out2){};
\umltrans [anchor2=east ]{in2}{lifterUp}
\umltrans [anchor1=south]{lifterUp}{out2}

\end{tikzpicture}
}
\end{document}
1
  • You should use e.g. right=1.5cm of state0.east, not right=1.5cm of state0-body.east. The size is still wrong though. Apr 4, 2018 at 22:12

0

You must log in to answer this question.

Browse other questions tagged .