2

I tried using msc package but it suffers from many issues. This is why I decided to draw it like the following.

My code:

    %!TEX TS-program = pdflatex
\documentclass[border=1mm,tikz]{standalone}

\usetikzlibrary{positioning,calc}%to use righ=of

\begin{document}
    \def\nodeTextWidth{4.5cm}
    \def\levelOne{2cm}
    \begin{tikzpicture}[
    node distance=7mm and 5mm,
    every node/.append style={very thick},
    entity/.style={draw, rectangle, minimum width=\nodeTextWidth},
    hiddenentity/.style={,rectangle, minimum width=\nodeTextWidth},
    operation/.style={draw=black,thick,fill=white,rounded corners=0mm,text width=\nodeTextWidth,font=\scriptsize, inner sep=2pt, text centered},
    myarrow/.style={line width=2pt,black,-latex},
    textAboveArrow/.style={inner sep=2pt,outer sep=4pt, fill=white,font=\footnotesize}
    ]

    \node[entity] (bank) {Eve};
    \node[entity, right=of bank] (smartMeter)  {Alice};
    \node[entity, right=of smartMeter] (utilityProvider)  {Bob};

    \node[operation, below=of bank] (accountDescription) { $xxxxxxx$};

    %VERTICAL LINES
    \draw [very thick] (bank)  --  (accountDescription)--(0,-11);
    \node[mark size=3pt,color=black] at (0,-11) {\pgfuseplotmark{*}};
    \draw [very thick] (smartMeter)--++(0,-11);
    \node[mark size=3pt,color=black] at (\nodeTextWidth+5.5mm,-11) {\pgfuseplotmark{*}};
    \draw [very thick] (utilityProvider)--++(0,-11);
    \node[mark size=3pt,color=black] at (\nodeTextWidth*2+11mm,-11) {\pgfuseplotmark{*}};

    %=============================== AUTHENTICATION PHASE =======================
    %LEVEL ONE COMMUNICATION 
    \node[hiddenentity,below=of accountDescription](bankL2){};
    \node[hiddenentity,right=of bankL2](SML2){};
    %
    \draw [myarrow] (bankL2.center)--(SML2.center) node[textAboveArrow,above,midway] {$xxxxxxx$};

    \node[hiddenentity,below=of SML2](SML3){};
    \node[hiddenentity,right=of SML3](UPL3){};
    \draw [myarrow] (SML3.center)--(UPL3.center) node[textAboveArrow,above,midway] {$xxxxxxx$};

    \node[hiddenentity,below=of SML3](SML4){};
    \node[hiddenentity,right=of SML4](UPL4){};
    \draw [myarrow] (UPL4.center)--(SML4.center) node[textAboveArrow,above,midway] {$xxxxxxx$};

    \node[operation, below=of SML4] (findSigma) {Find the value of $xxxxxxx$};
    \node[hiddenentity,right=of findSigma](UPL5){};

    \draw[thick] ($(accountDescription.north west)+(-0.1,0.15)$) rectangle ($(UPL5.south east)+(0.1,-0.25)$) node[below=2.5mm of smartMeter,fill=white, draw, rectangle]{\textit{First Phase}} ;

    %======================== REPORTING PHASE ===============================
    \node[hiddenentity,below=of findSigma](SML6){};
    \node[hiddenentity,left=of findSigma](BL6){};
    \node[hiddenentity,below=of BL6](BL7){};
    \node[hiddenentity,right=of SML6](UPL6){};
    \draw [myarrow] (SML6.center)--(UPL6.center) node[textAboveArrow,above,midway] {xxxxxxx};

    \node[operation, below=of UPL6] (recordPayment) {xxxxxxx};
    \draw[thick] ($(BL7.north west)+(-0.1,0.25)$) rectangle ($(recordPayment.south east)+(0.1,-0.1)$) node[below=2.5mm of BL6,fill=white, draw, rectangle, rounded corners=0mm]{\textit{Second Phase}} ;
    %==================== REWARDING PHASE ========================
    \node[hiddenentity,below=of recordPayment](UPL8){};
    \node[hiddenentity,left=of UPL8](SML8){};
    \node[hiddenentity,left=of SML8](BL8){};
    \draw [myarrow] (SML8.center)--(UPL8.center) node[textAboveArrow,above,midway] {xxxxxxx};

    \node[hiddenentity,below=of UPL8](UPL9){};
    \node[hiddenentity,left=of UPL9](SML9){};
    \node[hiddenentity,left=of SML9](BL9){};
    \draw [myarrow] (UPL9.center)--(BL9.center) node[textAboveArrow,above,midway] {xxxxxxx};

    \draw[thick] ($(BL8.north west)+(-0.15,0.5)$) rectangle ($(UPL9.south east)+(0.15,-0.1)$) node[below=16mm of BL7,fill=white, draw, rectangle]{\textit{Third Phase}} ;       
    \end{tikzpicture}

\end{document}

I have two primary issues:

First Issue: When this is compiled with pdflatex it shows correct output as follow (Third Phase positioning is incorrect): enter image description here

However, when I compile it with xelatex (required for my paper) the circles at the end of vertical line disappear. as follows. enter image description here

Second issue:

Is there a better way to draw rectangles around a group of nodes and create a label as in (First Phase, Second Phase, and Third Phase) to be centered using relative positioning. Third Phase should be similar to Second Phase positioning.

  • As for your second issue: yes, there is the fit library, which allows you to draw a frame around a given set of nodes. Unfortunately, I hardly ever use xelatex, so I can't answer your question. (Sometimes it is better to ask two separate questions for that reason.) – marmot Nov 20 '18 at 16:34
2

Following code has been compiled with xelatex. I don't know what was the problem with plotmarks, but I've replaced them with -{Circle[]} arrows (arrows.meta library) and they are shown again.

I've also made some other changes on your code. Mainly I've only used hiddenentity nodes when needed. I've replaced them with coordinate nodes.

Phase rectangles have been replaced by fit nodes. In order to keep simetry some hiddenentity nodes have been used.

\documentclass[border=1mm,tikz]{standalone}

\usetikzlibrary{positioning,calc, arrows.meta, fit}%to use righ=of

\begin{document}
    \def\nodeTextWidth{4.5cm}
    \def\levelOne{2cm}
    \begin{tikzpicture}[
    node distance=7mm and 5mm,
    every node/.append style={very thick},
    entity/.style={draw, rectangle, minimum width=\nodeTextWidth},
    hiddenentity/.style={,rectangle, minimum width=\nodeTextWidth},
    operation/.style={draw=black,thick,fill=white,rounded corners=0mm,text width=\nodeTextWidth,font=\scriptsize, inner sep=2pt, text centered},
    myarrow/.style={line width=2pt,black,-latex},
    textAboveArrow/.style={inner sep=2pt,outer sep=4pt, fill=white,font=\footnotesize}
    ]

    \node[entity] (bank) {Eve};
    \node[entity, right=of bank] (smartMeter)  {Alice};
    \node[entity, right=of smartMeter] (utilityProvider)  {Bob};

    \node[operation, below=of bank] (accountDescription) { $xxxxxxx$};

    %VERTICAL LINES
    \draw [very thick, -{Circle[]}] (bank)  --  (accountDescription)--(0,-11);
%    \node[mark size=3pt,color=black] at (0,-11) {\pgfuseplotmark{*}};
    \draw [very thick, -{Circle[]}] (smartMeter)--++(0,-11);
%    \node[mark size=3pt,color=black] at (\nodeTextWidth+5.5mm,-11) {\pgfuseplotmark{*}};
    \draw [very thick, -{Circle[]}] (utilityProvider)--++(0,-11);
%    \node[mark size=3pt,color=black] at (\nodeTextWidth*2+11mm,-11) {\pgfuseplotmark{*}};

    %=============================== AUTHENTICATION PHASE =======================
    %LEVEL ONE COMMUNICATION 
%    \node[hiddenentity,below=of accountDescription](bankL2){};
    \coordinate[below=of accountDescription] (bankL2);
    \draw[myarrow] (bankL2)--(bankL2-|smartMeter) coordinate (SML2) node[textAboveArrow,above,midway] {$xxxxxxx$};
%    \node[hiddenentity,right=of bankL2](SML2){};
%    %
%    \draw [myarrow] (bankL2.center)--(SML2.center) node[textAboveArrow,above,midway] {$xxxxxxx$};

    \coordinate[below=of SML2](SML3);
%    \node[hiddenentity,right=of SML3](UPL3){};
    \draw [myarrow] (SML3)--(SML3-|utilityProvider) coordinate(UPL3) node[textAboveArrow,above,midway] {$xxxxxxx$};

    \coordinate[below=of UPL3](UPL4){};
%    \node[hiddenentity,right=of SML4](UPL4){};
    \draw [myarrow] (UPL4)--(UPL4-|SML3) coordinate (SML4) node[textAboveArrow,above,midway] {$xxxxxxx$};

    \node[operation, below=of SML4] (findSigma) {Find the value of $xxxxxxx$};
    \node[hiddenentity,right=of findSigma](UPL5){};

    \node[fit=(accountDescription) (UPL5), draw, thick, label={[font=\itshape, fill=white, draw, anchor=center]90:First Phase}] {};

%    \draw[thick] ($(accountDescription.north west)+(-0.1,0.15)$) rectangle ($(UPL5.south east)+(0.1,-0.25)$) node[below=2.5mm of smartMeter,fill=white, draw, rectangle]{\textit{First Phase}} ;

    %======================== REPORTING PHASE ===============================
    \coordinate[below=12mm of findSigma](SML6);
    \draw [myarrow] (SML6)--(SML6-|UPL4) coordinate (UPL6) node[textAboveArrow,above,midway] (text6) {xxxxxxx};

    \node[hiddenentity] at (SML6-|bankL2) (BL6) {};

%    \node[hiddenentity,below=of BL6] (BL7){};
%    \node[hiddenentity,right=of SML6](UPL6){};

    \node[operation, below=of UPL6] (recordPayment) {xxxxxxx};

    \node[fit=(BL6) (recordPayment) (text6), draw, thick, label={[font=\itshape, fill=white, draw, anchor=center]90:Second Phase}] {};

%    \draw[thick] ($(BL7.north west)+(-0.1,0.25)$) rectangle ($(recordPayment.south east)+(0.1,-0.1)$) node[below=2.5mm of BL6,fill=white, draw, rectangle, rounded corners=0mm]{\textit{Second Phase}} ;
    %==================== REWARDING PHASE ========================
    \coordinate[below=12mm of recordPayment](UPL8);
    \draw [myarrow] (UPL8-|SML6)--(UPL8)  node[textAboveArrow,above,midway] (text8) {xxxxxxx};

%    \node[hiddenentity,left=of UPL8](SML8){};
%    \node[hiddenentity,left=of SML8](BL8){};
%    \draw [myarrow] (SML8.center)--(UPL8.center) node[textAboveArrow,above,midway] {xxxxxxx};

     \coordinate[below=of UPL8] (UPL9);
    \draw [myarrow] (UPL9)--(UPL9-|bankL2) node[textAboveArrow,above,midway] {xxxxxxx};

    \node[hiddenentity] at (bankL2|-UPL8) (BL8) {};
    \node[hiddenentity] at (UPL9) (UPL9aux) {};
%    \node[hiddenentity,left=of SML9](BL9){};
%    \draw [myarrow] (UPL9.center)--(BL9.center) node[textAboveArrow,above,midway] {xxxxxxx};

    \node[fit=(BL8) (UPL9aux) (text8), draw, thick, label={[font=\itshape, fill=white, draw, anchor=center]90:Third Phase}] {};

%    \draw[thick] ($(BL8.north west)+(-0.15,0.5)$) rectangle ($(UPL9.south east)+(0.15,-0.1)$) node[below=16mm of BL7,fill=white, draw, rectangle]{\textit{Third Phase}} ;       
    \end{tikzpicture}

\end{document}

enter image description here

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.