2

I want to draw something like this. I have three difficulties:

  1. How to draw bigger circular states and dashed circular state?
  2. How to draw multiple arrows between states? (Ex. In the state "App components state machines", there are multiple incoming and outgoing arrows.)
  3. How to get that surrounded box around transition labels?

enter image description here

This is my code:

\documentclass{article}
\usepackage{tikz}
\usepackage[margin=15mm]{geometry}
\usepackage{calc}
\usetikzlibrary{matrix,arrows}
\usetikzlibrary{positioning,arrows}
\usetikzlibrary{shapes,arrows,fit,calc,positioning,automata}





    \begin{document}


    \begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=9 cm]
    %  \tikzstyle{every state}=[fill=white,draw=none,text=black]

        \node[initial,state] (A)                                    {app initialized};
        \node[state]         (B) [right of=A]                       {Activity State Machine};
        \node[state]         (C) [below of=B]                       {Service State Machine};
        \node[state]         (D) [below of=A]                       {App components state machines};

      \path[->]
            (A) edge []     node [below,align=center]           {} (B)
            (C) edge []     node [pos=0.75,left,align=center]           {} (D)
            (C) edge []     node [pos=0.75,left,align=center]           {} (B);



    \end{tikzpicture}

    \end{document}

Output is something like this: (I want all states of uniform size and new line character within the states)

enter image description here

6

Here's a version of your document with most of the things you requested. The double lines could be better automated, I think.

\documentclass{article}
\usepackage{tikz}
\usepackage[margin=15mm]{geometry}
\usepackage{calc}
\usetikzlibrary{matrix,arrows}
\usetikzlibrary{positioning,arrows}
\usetikzlibrary{shapes,arrows,fit,calc,positioning,automata}

\begin{document}


    \begin{tikzpicture}[>=stealth',shorten >=2pt,auto,shorten <=2pt,node distance=5 cm,
    every state/.style={align=center,minimum size=3cm,text width=2cm},
    every edge/.style={draw,thick},
    loop label/.style={draw,align=center,text width=2cm,outer sep=4pt,minimum height=1cm}
    ]


        \node[initial,state] (A)                {app initialized};
        \node[state]         (B) [right= of A]  {Activity State Machine};
        \node[state]         (C) [below= of B]  {Service State Machine};
        \node[state,dashed]         (D) [below= of A]  {App components state machines};

      \path[->]
            (A) edge []     node [below,align=center]           {} (B)
            (C) edge []      node [pos=0.75,left,align=center]           {} (D)
                  (B) edge [loop above] node [loop label] {Events+UI events} ()
                  (C) edge [loop right] node [loop label,above=15pt] {Events} ()
                  (D) edge [loop left] node [loop label,above=15 pt] {Evens+UI events} ();

            \draw[->] ([xshift=1ex]B.south) -- ([xshift=1ex]C.north);
            \draw[<-] ([xshift=-1ex]B.south) -- ([xshift=-1ex]C.north);
            \draw[->,dashed,shorten >=8pt,shorten <=1pt] ([yshift=1.5ex]D.north east) -- ([yshift=1.5ex]B.south west);
            \draw[<-,,dashed,shorten >=1pt,shorten <=8pt] ([yshift=-1.5ex]D.north east) -- ([yshift=-1.5ex]B.south west);

    \end{tikzpicture}

\end{document}

output of code

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.