1. How to organize a loop to draw the lines automatically? Cause the pattern of node ids is repeated. C syntax:
Code: Select all
for(i = 1, i < 3; i++)
{
\draw[line] (i.''_1''.west) --++ (-5mm, 0) |-
}
//the last node is nasty - I can't use |- with it
(3_1.west);
The code for the diagram:
Code: Select all
\documentclass{article}
\usepackage[a3paper]{geometry}
\usepackage[cm]{fullpage}
\usepackage[utf8]{inputenc}
\usepackage{listings}
\usepackage[english]{babel}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,backgrounds,calc}
\begin{document}
\begin{tikzpicture}
%{{{ tikz styles
\tikzset{
header/.style={ellipse, draw=black, top color=white, bottom color=yellow!50,thick, inner sep=3mm, minimum size=3em, text centered, double, anchor=west},
pointer/.style = {signal, signal to=east, anchor=west},
mnemonic-block/.style={rectangle, anchor=west, inner sep=3mm},
line/.style = {draw},
comment/.style = {rectangle, rounded corners, draw, inner sep=3mm, anchor=west},
}
%}}}
\matrix[nodes={draw}, row sep=5mm,
column sep=2mm,minimum width=.875cm, minimum height=1cm]
{
\node[header] (1_1) {Moose Attributes};\\
%{{{read-write / read only
\node[pointer] (2_1) {read-write / read only}; &
\node[mnemonic-block] (2_2) {
\begin{lstlisting}[language=Perl]
has 'attr' => {is => 'rw'}
has 'attr' => {is => 'ro'}
\end{lstlisting}
}; \\
%}}}
%{{{accessor methods
\node[pointer] (3_1) {accessor methods}; &
\node[mnemonic-block] (3_2) {
\begin{lstlisting}[language=Perl]
has 'attr' => {reader => 'get_attr',}
has 'attr' => {writer => 'set_attr',}
\end{lstlisting}
}; \\
};
\draw[line] (1_1.west) --++ (-5mm, 0) |- (2_1.west) --++ (-5mm, 0) |- (3_1.west);
\draw[line] (2_1.east) -- (2_2.west);
\draw[line] (3_1.east) -- (3_2.west);
% \draw[line] (1.east) -- (18.west);
\end{tikzpicture}
\end{document}