[Tex/LaTex] How to create this type of diagram in LaTeX

diagramstikz-pgftikz-uml

I would like to recreate the following diagram in LaTeX:

enter image description here

Something that uses TikZ is likely to be good and I have seen TikZ-UML which is somewhat similar to what I want, but I would really value some guidance. I'm not sure how to go about creating a diagram like this in TikZ. Thank you for any ideas you may have.

Best Answer

This can give you a starting point:

\documentclass{article}
\usepackage[margin=1cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{positioning,fit,backgrounds,calc}

\pgfdeclarelayer{backgroundi}
\pgfdeclarelayer{backgroundii}
\pgfdeclarelayer{backgroundiii}
\pgfsetlayers{backgroundiii,backgroundii,backgroundi,main}

\begin{document}

\begin{tikzpicture}[node distance=0.3cm,
mynode/.style={
  draw,
  fill=white,
  text width=3cm,
  align=center,
  minimum height=20pt
},
>=latex
]

% The upper "Job" box
\node[mynode] (func) {function}; 
\node[mynode,below=of func] (argu) {arguments}; 
\node[mynode,below=of argu] (time) {timeout}; 
\node[mynode,below=of time] (resu) {result}; 
\node[mynode,below=of resu] (other) {other information};

% Auxiliary coordinates for the background frame for "Job"
\coordinate (ul) at ([xshift=-15pt,yshift=7pt]func.north west);
\coordinate (lr) at ([xshift=15pt,yshift=-7pt]other.south east);

% The background frame for "Job"
\begin{pgfonlayer}{backgroundi}
\node[draw,fill=gray!30,fit=(ul) (lr)] (frame) {}; 
\end{pgfonlayer}
\node[anchor=south west,draw,fill=gray!30] 
  at ([yshift=-.5\pgflinewidth]frame.north west) {Job};

% The lower "Job" box
\node[mynode,below=2cm of frame.south] (funcb) {function}; 
\node[mynode,below=of funcb] (argub) {arguments}; 
\node[mynode,below=of argub] (timeb) {timeout}; 
\node[mynode,below=of timeb] (resub) {result}; 
\node[mynode,below=of resub] (otherb) {other information};

% Auxiliary coordinates for the background frame for "Job"
\coordinate (ulb) at ([xshift=-15pt,yshift=7pt]funcb.north west);
\coordinate (lrb) at ([xshift=15pt,yshift=-7pt]otherb.south east);

% The background frame for "Job"
\begin{pgfonlayer}{backgroundi}
\node[draw,fill=gray!30,fit=(ulb) (lrb)] (frameb) {}; 
\end{pgfonlayer}
\node[anchor=south west,draw,fill=gray!30] 
  at ([yshift=-.5\pgflinewidth]frameb.north west) {Job};

% Auxiliary coordinates for the background frame for both "Job" boxes
\coordinate (ulc) at ([xshift=-15pt,yshift=18pt]frame.north west);
\coordinate (lrc) at ([xshift=15pt,yshift=-7pt]frameb.south east);

% The background frame for both "Job" boxes
\begin{pgfonlayer}{backgroundii}
\node[draw,fill=gray!50,fit=(ulc) (lrc)] (framec) {}; 
\end{pgfonlayer}
\node[anchor=south west,draw,fill=gray!50] 
  at ([yshift=-.5\pgflinewidth]framec.north west) {Job group};

% The midlle "init" box
\node[mynode,right=3.5cm of func] (init) {init}; 
\node[mynode,below=of init] (subm) {submit}; 
\node[mynode,below=of subm] (getR) {getResults}; 

% The "pool" box
\node[mynode,right=2cm of init] (processi) {process}; 
\node[mynode,below=of processi] (processii) {process}; 
\node[mynode,below=of processii] (processiii) {process}; 
\node[mynode,below=of processiii] (processiv) {process}; 

% Auxiliary coordinates for the background frame for "pool" box
\coordinate (uld) at ([xshift=-15pt,yshift=7pt]processi.north west);
\coordinate (lrd) at ([xshift=15pt,yshift=-7pt]processiv.south east);

% The background frame for "pool"
\begin{pgfonlayer}{backgroundi}
\node[draw,fill=gray!30,fit=(uld) (lrd)] (framed) {}; 
\end{pgfonlayer}
\node[anchor=south west,draw,fill=gray!30] 
  at ([yshift=-.5\pgflinewidth]framed.north west) {pool};

% Auxiliary coordinates for the background frame for both "init" and "pool" boxes
\coordinate (ule) at ([yshift=17pt,xshift=-15pt]init.north west|-framed.north);
\coordinate (lre) at ([xshift=15pt,yshift=-7pt]framed.south east);

% The background frame for "init" and "pool"
\begin{pgfonlayer}{backgroundii}
\node[draw,fill=gray!50,fit=(ule) (lre)] (framee) {}; 
\end{pgfonlayer}
\node[anchor=south west,draw,fill=gray!50] 
  at ([yshift=-.5\pgflinewidth]framee.north west) {ParallelJobProcessor};

% Auxiliary coordinates for the general background frame
\coordinate (ulf) at ([yshift=17pt,xshift=-15pt]framec.north west);
\coordinate (lrf) at ([xshift=15pt,yshift=-7pt]framee.south east|-framec.south);

% The general background frame
\begin{pgfonlayer}{backgroundiii}
\node[draw,fill=black!60,fit=(ulf) (lrf)] (framef) {}; 
\end{pgfonlayer}

% Some arrows
\begin{scope}[line width=6pt]
\draw[->] 
  (frame.east|-argu) -- (subm);
\draw[->] 
  (getR.west) -- +(-1.5cm,0) -| ([xshift=2cm]resub.east) -- (resub.east);
\draw[->]
  (init.east) -- (framed.west|-processi.west);
\draw[->]
  (subm.east) -- (framed.west|-processii.west);
\draw[->]
  (framed.west|-processiii.west) -- (getR.east);
\end{scope}
\end{tikzpicture}%

\end{document}

enter image description here

Related Question