[Tex/LaTex] Jackson structured programming diagram (format a tree diagram)

tikz-stylestikz-trees

I'm trying to create a Jackson structured programming diagram. This is basically a simple tree diagram with the exception that boxes can either have a circle (O) or a star (*) in the upper right corner of each box. I am using the TikZ libary for the diagram but I don't know how to extend the styles to achieve this. Here is the unfinished diagram:

\documentclass{minimal}
\usepackage[a4paper,margin=1cm,landscape]{geometry}
\usepackage{tikz}
\usetikzlibrary{positioning,shadows,arrows}

\begin{document}
\begin{center}
\begin{tikzpicture}[
    box/.style={rectangle, draw=red!50!black!50, rounded corners=1mm, fill=blue, drop shadow, minimum width=5em, minimum height=3em, level distance=10cm,
        text centered, anchor=north, text=white},
    circle/.style={rectangle, draw=red!50!black!50, rounded corners=1mm, fill=blue, drop shadow, minimum width=5em, minimum height=3em, level distance=10cm,
        text centered, anchor=north, text=white},
    %SHOULD CONTAIN THE CIRCLES
    star/.style={rectangle, draw=red!50!black!50, rounded corners=1mm, fill=blue, drop shadow, minimum width=5em, minimum height=3em, level distance=10cm,
        text centered, anchor=north, text=white},
     %SHOULD CONTAIN THE STARS       
]
\node (State00) [box] {Jackson Diagramm}
 [sibling distance=3cm]
    child {node (a) [box] {int a = 1}}
    child {node (a) [box] {boolean n = true}}
    child {node (a) [box] {boolean z = true}}
    child {[sibling distance=4cm] node (d) [circle] {if (n)}
        child{  [sibling distance=3cm] node (e) [star] {while (z)}
        child {node (f) [box] {n = !z}}
        child {node (g) [box] {a++}}
        child { [sibling distance=4cm] node (h) [circle] {a <= 10}
                child {node (i) [box] {z = true}}
                child {node (j) [box] {System.out.println( "z\(>\)10")}}
            }
        }
        child {node (k) [box] {System.out.println(a)}} 
        child {node (l) [box] {System.out.println(z)}}      
    } 
;
\end{tikzpicture}
\end{center}
\end{document}

Current output:

enter image description here

Best Answer

You can use label={[xshift=-1.25em, yshift=-2.25ex]north east:$\ast$} to place additional graphics within the node:

enter image description here

Notes:

  • I changed the colors to make it easier to see where the special nodes are.

Code:

\documentclass{minimal}
\usepackage[a4paper,margin=1cm,landscape]{geometry}
\usepackage{tikz}
\usetikzlibrary{positioning,shadows,arrows}

\begin{document}
\begin{center}
\begin{tikzpicture}[
    box/.style={rectangle, draw=red!50!black!50, rounded corners=1mm, fill=blue!25, drop shadow, minimum width=5em, minimum height=3em, level distance=10cm,
        text centered, anchor=north, text=white},
    circle/.style={rectangle, draw=red!50!black!50, rounded corners=1mm, fill=green!25, drop shadow, minimum width=5em, minimum height=3em, level distance=10cm,
        text centered, anchor=north, text=black, label={[xshift=-1.25em, yshift=-2.25ex]north east:$\circ$}},
    %SHOULD CONTAIN THE CIRCLES
    star/.style={rectangle, draw=red!50!black!50, rounded corners=1mm, fill=red!25, drop shadow, minimum width=5em, minimum height=3em, level distance=10cm,
        text centered, anchor=north, text=black, label={[xshift=-1.25em, yshift=-2.25ex]north east:$\ast$}},
     %SHOULD CONTAIN THE STARS       
]
\node (State00) [box] {Jackson Diagramm}
 [sibling distance=3cm]
    child {node (a) [box] {int a = 1}}
    child {node (a) [box] {boolean n = true}}
    child {node (a) [box] {boolean z = true}}
    child {[sibling distance=4cm] node (d) [circle] {if (n)}
        child{  [sibling distance=3cm] node (e) [star] {while (z)}
        child {node (f) [box] {n = !z}}
        child {node (g) [box] {a++}}
        child { [sibling distance=4cm] node (h) [circle] {a <= 10}
                child {node (i) [box] {z = true}}
                child {node (j) [box] {System.out.println( "z\(>\)10")}}
            }
        }
        child {node (k) [box] {System.out.println(a)}} 
        child {node (l) [box] {System.out.println(z)}}      
    } 
;
\end{tikzpicture}
\end{center}
\end{document}
Related Question