# Symbols for EAI diagrams in TikZ/PGF?

I would like to produce some diagrams (preferably using TikZ/PGF) using the visual notation given in Enterprise Integration Patterns by Hohpe & Woolf. I'm aware of stencils from the above site, based on Visio, but I'd rather be able to compose them directly in my LaTeX documents. Is anyone aware of PGF library packages that I can use, or failing that how I can create reusable symbols for use in a TikZ/PGF figure?

-
Do you want to just have the figures in your document by themselves, or as part of flowcharts (similar to a circuit diagram)? – Jake Jul 11 '11 at 12:38
These symbols would be used multiple times in the same diagram. The diagrams will serve a similar purpose as UML diagrams. The symbols would, I assume, be nodes that I can then attach with edges. In some cases, I would like to be able to annotate these edges with symbols too. – Andrew Matthews Jul 11 '11 at 22:00

Taking an "order" symbol from this page, you can draw it with TikZ in the following way:

• define an origin for the symbol. I chose the upper left corner of the rectangle
• draw the elemnt with TikZ
• create a \newcommand, best giving it a telling name, with at least two parameters for X and Y coordinate
• now enter the #1 and #2 (X and Y) in all coordinates

The effect is that your component is drawn relatively to the coordinates specified. Here you have an example for the order element:

\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,patterns}

\newcommand{\EAIOrder}[2]{% X coordinate, Y coordiante
\filldraw[fill=yellow] (#1,#2) rectangle (#1+0.4,#2-0.4);
\filldraw[pattern=north east lines,pattern color=green!50!black] (#1,#2) rectangle (#1+0.4,#2-0.4);%
\draw (#1,#2-0.2) -- (#1-0.2,#2-0.2) -- (#1-0.2,#2+0.2);%
\filldraw[gray,draw=black] (#1-0.2,#2+0.4) circle (0.2);
}

\begin{document}

\begin{tikzpicture}[show background rectangle]
\EAIOrder{0}{0}
\EAIOrder{0}{1}
\EAIOrder{1}{0}
\EAIOrder{1}{1}
\EAIOrder{3}{0}
\EAIOrder{1}{2}
\end{tikzpicture}

\end{document}


In the same fashion you can define other components and use them together. You can also be fancy and give it more parameters (line color, filling, pattern color, scaling, ...), but be aware that without special efforts (e.g. with package keyval) nine parameters is the maximum.

BTW, the above code produces:

Edit 1: There is of cause a much easier way using a scope. The scope is passed the options for xshift and yshift, this avoids having to insert #1 and #2 into all coordinates. The following produces exactly the same as the code before:

\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,patterns,backgrounds}

\newcommand{\EAIOrder}[2]{% X coordinate, Y coordiante
\begin{scope}[xshift=#1, yshift=#2]
\filldraw[fill=yellow] (0,0) rectangle (0.4,-0.4);
\filldraw[pattern=north east lines,pattern color=green!50!black] (0,0) rectangle (0.4,-0.4);%
\draw (0,-0.2) -- (-0.2,-0.2) -- (-0.2,+0.2);%
\filldraw[gray,draw=black] (-0.2,0.4) circle (0.2);
\end{scope}
}

\begin{document}

\begin{tikzpicture}[show background rectangle]
\EAIOrder{0cm}{0cm}
\EAIOrder{0cm}{1cm}
\EAIOrder{1cm}{0cm}
\EAIOrder{1cm}{1cm}
\EAIOrder{3cm}{0cm}
\EAIOrder{1cm}{2cm}
\end{tikzpicture}

\end{document}


And as I newly learned, instead of keyval you can use pgfkeys already built in TikZfor fancy enhancements and customizability of your commands

-