0

I am making a diagram on TikZ. It requires to have a custom drawing in the middle of the connecting lines, that also must be annotated late. In the middle of the line I need to have a circle from one side and a semicircle embracing the circle from another side (from UML Component diagram). Sorry for no MWE, I just have no idea where to start.

  • any news? you receive two answers. are no one fulfill your expectations that you can accept it? – Zarko Jun 3 '18 at 22:40
5

as starting point:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta, calc, positioning}

\tikzset{
SC/.style = {% Square - Circle
    {Square[open, fill=white, length=3mm]}-{Circle[open,length=2.4mm]},
     shorten > = -1.2mm, shorten < = -1.5mm
            },
AC/.style = {% Arc -- Square
    {Arc Barb[reversed,arc=180,length=2mm]}-{Square[open,fill=white,length=3mm]},
     shorten > = -1.5mm, 
            },
block/.style = {rectangle, draw, minimum size=12mm, outer sep=0pt}
        }

\begin{document}
\begin{tikzpicture}[node distance=22mm and 11mm]
  \node (a) [block] {A};
  \node (b) [block,above=of a] {B};
  \draw[SC] (a) -- ($(a.north)!0.5!(b.south)$);
  \draw[AC] ($(a.north)!0.5!(b.south)$) node[right=2mm] {some text} -- (b);
\end{tikzpicture}
\end{document}

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta, calc, positioning}

\tikzset{
SC/.style = {% Square - Circle
    {Square[open, fill=white, length=3mm]}-{Circle[open,length=2.4mm]},
     shorten > = -1.2mm, shorten < = -1.5mm
            },
AC/.style = {% Arc -- Square
    {Arc Barb[reversed,arc=180,length=2mm]}-{Square[open,fill=white,length=3mm]},
     shorten > = -1.5mm, 
            },
block/.style = {rectangle, draw, minimum size=12mm, outer sep=0pt}
        }

\begin{document}
\begin{tikzpicture}[node distance=22mm and 11mm]
  \node (a) [block] {A};
  \node (b) [block,above=of a] {B};
  \draw[SC] (a) -- ($(a.north)!0.5!(b.south)$);
  \draw[AC] ($(a.north)!0.5!(b.south)$) node[right=2mm] {some text} -- (b);
\end{tikzpicture}
\end{document}

enter image description here

connections between two nodes is composed from two lines:

  • the first line, SC (as Square - Circle) is intended for the first part of connection between nodes. it begin with white square of size 3 and with black circle on the end. line lenght i accordingly prolonged that can be simply determined start and end coordinate.
  • the second line, AC (as Arc -- Square) is intended for draw next part of connection. it begin with arc (on top of circle) and end with square
  • in mwe are used separately that is evident how is connection consist. on this way it cab be easy adapted to horizontal connection.
  • in real use for shorter image code is possible to define shortcut(s) with \newcommand(s), for example as marmot did in his answer.

addendum: from question is not very clear if you also interested for design of nodes in your diagram. till now i understood that not, hence simple node used in above mwe. however, answer of marmot hinted me, that might i been wrong. he also suggest one of possible solution, but for completeness of this answer let me add my similar solution of nodes design and possible connection between two nodes:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta,
                backgrounds,
                calc,
                positioning,
                shapes.multipart}
\pgfdeclarelayer{foreground}  % <--- needed for draw missing line in 
                              % rectangle split node by use of
                              % "append after command={\pgfextra{...}}" 
\pgfsetlayers{main,foreground}

\tikzset{
SC/.style = {% Square - Circle
    {Square[open, fill=white, length=3mm]}-{Circle[open,length=2.4mm]},
     shorten > = -1.2mm, shorten < = -1.5mm
            },
AC/.style = {% Arc -- Square
    {Arc Barb[reversed,arc=180,length=2mm]}-{Square[open,fill=white,length=3mm]},
     shorten > = -1.5mm,
            },
picnode/.style={draw,inner sep=0pt, minimum height=1.5pt}, % <--- emblem style
emblem/.pic = {% <--- emblem on top right corner of node
    \node (aux) [picnode,minimum size=3mm] {};
    \node[picnode,minimum width=4pt,above=0.5pt] at (aux.west) {};
    \node[picnode,minimum width=4pt,below=0.5pt] at (aux.west) {};
              },
block/.style = {%
    rectangle split,
    rectangle split parts=5,
    rectangle split draw splits=false,
    rectangle split empty part height=7mm,
    draw,
    fill=#1,  % <--- for selection node fill
    text width=44mm,
    align=flush center,
    label={[below left]north east: \tikz{\pic {emblem};} },
        append after command={\pgfextra{%
        \begin{pgfonlayer}{foreground}
        \draw(\tikzlastnode.three split west) -- (\tikzlastnode.three split  east);
        \end{pgfonlayer}}}
            },
block/.default = white
        }
\usepackage[T1]{fontenc} % added for "\guillemotleft" and "\guillemotright"

\begin{document}
\begin{tikzpicture}[node distance=12mm and 6mm]
  \node (a) [block] {%
        \vspace{3mm} % <--- additional vertical space above \nodepart{one}
        \nodepart{two} \guillemotleft component\guillemotright
        \nodepart{three} \textbf{Lincense Servece Net}
        \nodepart{four} artifacts
        \nodepart[align=left]{five} licence\_service.dll
                    };
  \node (b) [block=yellow!30,below right=of a] {%
        \vspace{3mm} % <--- additional vertical space above \nodepart{one}
        \nodepart{two} \guillemotleft provided component\guillemotright
        \nodepart{three} \textbf{HASP Java Native Interface }
        \nodepart{four} artifacts
        \nodepart[align=left]{five} HASP Java.dll\\
                                    HASP Java\_x64.dll\\
                                    HASP Java\_ia64.dll
                                        };
  \coordinate[right=of a] (connect);
  \draw[SC] (a) -- (connect);
  \draw[AC] (connect) node[above=2mm,align=center] {some\\ text} -| (b);
\end{tikzpicture}
\end{document}

enter image description here

  • @marmot, thank you. i like to add some explanation, but my english already hibernate. it is time that i go to sleep too :-). i will edit answer during saturday. by – Zarko Mar 31 '18 at 1:03
1

Building on Zarko's nice arrows, here is a proposal to do the boxes.

\documentclass[tikz, border=5pt]{standalone}
\usepackage[T1]{fontenc}
\usetikzlibrary{arrows.meta, calc, positioning,shapes.multipart,backgrounds}
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}

\tikzset{
SC/.style = {% Square - Circle
    {Square[open, fill=white, length=3mm]}-{Circle[open,length=2.4mm]},
     shorten > = -1.2mm, shorten < = -1.5mm
            },
AC/.style = {% Arc -- Square
    {Arc Barb[reversed,arc=180,length=2mm]}-{Square[open,fill=white,length=3mm]},
     shorten > = -1.5mm, 
            },
block/.style={
        draw,
        text width=5cm,
        rectangle split,
        rectangle split parts=5,
         rectangle split draw splits=false,
        align=center,
        append after command={\pgfextra{\begin{pgfonlayer}{foreground}
        \draw ($(\tikzlastnode.north east)+(-1mm,-1mm)$) rectangle ++(-4mm,-4mm);
        \draw[fill=white] ($(\tikzlastnode.north east)+(-4.25mm,-1.3mm)$) rectangle ++
        (-1.5mm,-1.2mm);
        \draw[fill=white] ($(\tikzlastnode.north east)+(-4.25mm,-3.4mm)$) rectangle ++
        (-1.5mm,-1.2mm);
        \draw(\tikzlastnode.three split west) -- (\tikzlastnode.three split  east);
        \end{pgfonlayer}
        }
        }
        }
}
\newcommand{\Connect}[4][]{
  \draw[SC] (#3) -- ($(#2.north)!0.5!(#3.south)$);
  \draw[AC] ($(#3.north)!0.5!(#2.south)$) node[right=2mm] {#4} -- (#2);
}
\begin{document}
\begin{tikzpicture}[node distance=22mm and 11mm,font=\sffamily]
  \node (l3) [block,fill=yellow!20] {\nodepart{two}\guillemotleft 
  provided components\guillemotright
  \nodepart{three} \textbf{HASP .Net runtime}
  \nodepart{four} artifacts
  \nodepart[align=left]{five} hasp\_net\_windows.dll
  };
  \node (l2) [block,above=of l3] {\nodepart{two}\guillemotleft component\guillemotright
  \nodepart{three} \textbf{License Services Net}
  \nodepart{four} artifacts
  \nodepart[align=left]{five} license\_service.dll
  };
  \node (l1) [block,above=of l2] {\nodepart{two}\guillemotleft application\guillemotright
  \nodepart{three} \textbf{License Status}
  \nodepart{four} artifacts
  \nodepart[align=left]{five} license\_status.exe};
  \Connect{l1}{l2}{LicenseService}
  \Connect{l2}{l3}{\guillemotleft API\guillemotright HASPA .Net}
\end{tikzpicture}
\end{document}

enter image description here

  • :-) :-) ... reading op question i didn't recognize, that (s)he has problems with boxes too (otherwise i hadn't provide only simple boxes for illustration how my connections work, meanwhile i learn how to draw lines over multipart nodes with fill ;-) ). now is to late for me. anyway, i do not have much free time today :-). – Zarko Mar 31 '18 at 15:55
  • @Zarko I agree that it is not in the question, but didn't you tell me that it is not straightforward to add a single horizontal line line in rectangle splits nodes? And I also looked up how to have some parts left-aligned. – marmot Mar 31 '18 at 16:36

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.