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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
% Copyright 2005 2015 Ovidiu Gheorghies
% Licensed under the Apache License, Version 2.0.
if known _metauml_behavioral_common_mp:
expandafter endinput
fi;
_metauml_behavioral_common_mp:=1;
% Sadly, this copy of the macro is needed to prevent multiple file loads being shown by MetaPost.
% The guard values (such as _metauml_mp) do ensure that the file isn't loaded multiple times,
% but this macro makes sure that MetaPost won't try to load the file and display a message for that.
def inputonce text libraryFile=
if not known scantokens ("_" & str libraryFile & "_mp"):
%includeonce% show "Loading " & str libraryFile;
scantokens ("input " & str libraryFile);
else:
%includeonce% show str libraryFile & " already loaded.";
fi;
enddef;
inputonce util_log;
vardef SpecialStateInfo@#=
numeric @#diameter;
color @#discColor;
numeric @#shade;
color @#shadeColor, @#foreColor;
@#diameter := 0.4cm;
@#discColor := black;
@#foreColor := black;
ShadeInfo.@#iShade;
enddef;
vardef SpecialStateInfoCopy@#(text src)=
SpecialStateInfo.@#;
ShadeInfo_copy.@#iShade(src.iShade);
@#diameter := src.diameter;
@#discColor := src.discColor;
@#foreColor := src.foreColor;
enddef;
%%%%%%%%%%%%%%%%%%
% BEGIN %
%%%%%%%%%%%%%%%%%%
SpecialStateInfo.iBegin;
vardef Begin@#=
ObjectEquations(@#);
@#className := "Begin";
SpecialStateInfoCopy.@#info(iBegin);
enddef;
vardef Begin_layout@#=
if @#laidout = 1:
log "Begin " & (str @#) & " has already been layed out";
else:
@#laidout := 1;
@#width = @#info.diameter;
@#height = @#info.diameter;
fi;
enddef;
vardef Begin_draw@#=
Begin_layout@#;
objectEnsurePositioning.@#;
path @#border;
@#border := @#n..@#e..@#s..@#w..cycle;
drawObjectShade(@#);
fill @#border withcolor @#info.discColor;
draw @#border withcolor @#info.foreColor;
enddef;
vardef Begin_border@#=
@#border
enddef;
%%%%%%%%%%%%%%%%%%
% END %
%%%%%%%%%%%%%%%%%%
SpecialStateInfo.iEnd;
iEnd.innerSpacing := 2;
iEnd.discColor := white;
vardef End@#=
ObjectEquations(@#);
@#className := "End";
SpecialStateInfoCopy.@#info(iEnd);
@#info.innerSpacing := iEnd.innerSpacing;
enddef;
vardef End_layout@#=
Begin_layout@#;
enddef;
vardef End_draw@#=
Begin_draw.@#;
path @#innerDisc;
@#innerDisc := @#n - (0, @#info.innerSpacing) ..
@#e - (@#info.innerSpacing, 0) ..
@#s + (0, @#info.innerSpacing) ..
@#w + (@#info.innerSpacing, 0) ..cycle;
fill @#innerDisc withcolor @#info.foreColor;
enddef;
vardef End_border@#=
@#border
enddef;
%%%%%%%%%%%%%%%%%%
% ENTRY POINT %
%%%%%%%%%%%%%%%%%%
SpecialStateInfo.iEntryPoint;
iEntryPoint.discColor := white;
iEntryPoint.innerSpacing := 2;
vardef EntryPoint@#=
ObjectEquations(@#);
@#className := "EntryPoint";
SpecialStateInfoCopy.@#info(iEntryPoint);
@#info.innerSpacing := iEntryPoint.innerSpacing;
enddef;
vardef EntryPoint_layout@#=
Begin_layout@#;
enddef;
vardef EntryPoint_draw@#=
Begin_draw.@#;
enddef;
vardef EntryPoint_border@#=
@#border
enddef;
%%%%%%%%%%%%%%%%%%
% EXIT POINT %
%%%%%%%%%%%%%%%%%%
SpecialStateInfo.iExitPoint;
iExitPoint.discColor := white;
iExitPoint.innerSpacing := 2;
vardef ExitPoint@#=
ObjectEquations(@#);
@#className := "ExitPoint";
SpecialStateInfoCopy.@#info(iExitPoint);
@#info.innerSpacing := iExitPoint.innerSpacing;
@#info.iShade.shift := 0;
enddef;
vardef ExitPoint_layout@#=
Begin_layout@#;
enddef;
vardef ExitPoint_draw@#=
Begin_draw.@#;
_n_ := str @#;
generic_declare(pair) _n.urt, _n.lrt, _n.llft, _n.ulft;
@#urt := @#c + @#info.diameter/2 * (sind(45), cosd(45));
@#lrt := @#c + @#info.diameter/2 * (sind(135), cosd(135));
@#llft := @#c + @#info.diameter/2 * (sind(225), cosd(225));
@#ulft := @#c + @#info.diameter/2 * (sind(315), cosd(315));
draw @#urt -- @#llft;
draw @#ulft -- @#lrt;
enddef;
vardef ExitPoint_border@#=
@#border
enddef;
%%%%%%%%%%%%%%%%%%
% FlowFinal %
%%%%%%%%%%%%%%%%%%
SpecialStateInfo.iFlowFinal;
iFlowFinal.discColor := white;
iFlowFinal.innerSpacing := 2;
vardef FlowFinal@#=
ObjectEquations(@#);
@#className := "FlowFinal";
SpecialStateInfoCopy.@#info(iFlowFinal);
@#info.innerSpacing := iFlowFinal.innerSpacing;
%@#info.iShade.shift := 0;
enddef;
vardef FlowFinal_layout@#=
Begin_layout@#;
enddef;
vardef FlowFinal_draw@#=
ExitPoint_draw@#
enddef;
vardef FlowFinal_border@#=
@#border
enddef;
|