-
Notifications
You must be signed in to change notification settings - Fork 0
/
transactiondiagram.sty
83 lines (76 loc) · 2.95 KB
/
transactiondiagram.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
% Copyright 2015 Konrad Siek <konrad.siek@gmail.com>
\tikzset{
% dot
dot/.style={draw, circle, fill=white, inner sep=2pt, outer sep=0pt},
% poké ball
cir/.style={draw, circle, fill opacity=0, inner sep=1pt, outer sep=0pt},
% diamond
dia/.style={draw, diamond, fill opacity=0, inner sep=2pt, outer sep=0pt},
% half dot, open (invoke)
inv/.style={dot, semicircle, shape border rotate=90, scale=.75},
% half dot, close (response)
res/.style={dot, semicircle, shape border rotate=270, scale=.75},
% above operation
aop/.style={above=5pt, anchor=base west, scale=.75},
% below operation
bop/.style={below, anchor=north west, scale=.75},
% annotation (below)
not/.style={below, anchor=north west, scale=.7, gray},
% transaction ID
tid/.style={left=14pt, below},
% happens before arrow
hb/.style={-latex, very thin, gray}, %, dash pattern=on 3pt off 1pt},
wait/.style={very thin, dash pattern=on 3pt off 1pt},
dotdotdot/.style={dotted},
% retry arrow
retry/.style={-latex, draw, very thin, decorate, decoration={snake, amplitude=.4mm, segment length=2mm, post length=1mm}, gray}
%, dash pattern=on 3pt off 1pt}
}
% line definition for happens before arrow
\def\squiggle {.. controls +(270:.85) and +(90:0.85) ..}
\def\squiggleup {.. controls +(90:.85) and +(270:0.85) ..}
% arrow-only axis
% arguments: start x, end x, y
\def\simpleaxis#1#2#3{%
\draw[->] (#1cm,#3cm) -- (#2cm+0.6cm,#3cm);%
}
% axis with notches
% arguments: start x, end x, y
\def\axis#1#2#3{%
\simpleaxis{#1}{#2}{#3}%
\foreach \i in {#1,...,#2}%
\draw (\i, #3cm-1pt) -- (\i, #3cm+1pt)%
node[below=3pt, anchor=north, scale=.65] {{\i}};%
}
% draw a rectangle marking a distance between two nodes
% arguments: first node, second node, height,
% text node position (above/below),
% color config,
% text over first node, text over second node
% named in hommage to GrimithR of Youtube fame
\def\getrect#1#2#3#4#5#6#7{
\node (#4-#1) at ([yshift=#3]#1){};
\node (#4-#2) at ([yshift=#3]#2){};
\fill [#5] (#1.center) rectangle (#4-#2);
\draw[dashed] (#1.center) -- (#4-#1.center);
\draw[dashed] (#2.center) -- (#4-#2.center);
\node[#4] at (#4-#1) {#6};
\node[#4] at (#4-#2) {#7};
}
% draw a slim rectanagle over one node
% arguments: node, height,
% text node position (above/below),
% color config,
% text over node
\def\getslimrect#1#2#3#4#5{
\node [dot, opacity=0] (#3-#1) at ([yshift=#2]#1){};
\fill [#4] (#1.east) rectangle (#3-#1.west);
\draw[dashed] (#1.east) -- (#3-#1.east);
\draw[dashed] (#1.west) -- (#3-#1.west);
\node[#3] at (#3-#1) {#5};
}
% split the text of a node within multiple lines
% arguments: text, with // delimiting lines
\def\multinot#1{
\begin{tabular}{l}#1\end{tabular}
}