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
215
216
217
|
% MetaUML, a MetaPost library for typesetting exquisite UML diagrams.
% Copyright (C) 2005 Ovidiu Gheorghies
%
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation; either version 2
% of the License, or (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
if known _metauml_usecase_mp:
expandafter endinput
fi;
_metauml_usecase_mp:=1;
input metauml_defaults;
input util_log;
vardef ActorInfo@#=
FontInfo.@#iFont(metauml_defaultFont, defaultscale);
@#iFont.ignoreNegativeBase := 1;
PictureInfo.@#iName (2, 2, 2, 2)(@#iFont);
PictureStackInfo.@#iNameStack (1pt, 1pt, 1pt, 1pt)(9)(@#iName);
@#iNameStack.iPict.ignoreNegativeBase := 1;
HumanInfo.@#iHuman(25, 35, .3, .35, .5, 1, 1);
enddef;
vardef ActorInfoCopy@#(text src)=
log "ActorInfoCopy: Copying actor info";
PictureStackInfoCopy.@#iNameStack (src.iNameStack);
HumanInfoCopy.@#iHuman(src.iHuman);
enddef;
ActorInfo.iActor;
vardef Actor@#(text contents)=
EActor.@#(iActor)(contents);
enddef;
vardef EActor@#(text _info)(text contents)=
ObjectEquations(@#);
@#className := "Actor";
ActorInfoCopy.@#info(_info);
numeric @#nLines; @#nLines := 0;
string @#lines[];
for l=contents:
@#lines[@#nLines] := l;
@#nLines := @#nLines + 1;
endfor;
EHuman.@#human(@#info.iHuman);
EPictureStack.@#nameStack(@#info.iNameStack)(scantokens listArray(@#lines)(@#nLines))("vcenterbase");
enddef;
vardef Actor_setDebugMode@#=
@#.nameStack.info.boxed := 1;
enddef;
vardef Actor_layout@#=
if @#layedout = 1:
log "Actor " & (str @#) & " has already been layed out";
else:
@#layedout := 1;
log "Actor layout: " & (str @#);
Human_layout.@#human;
PictureStack_layout.@#nameStack;
@#width = max(@#nameStack.width)(@#human.width);
@#height = @#nameStack.height + @#human.height;
@#n = @#human.n;
@#nameStack.n=@#human.s;
@#s = @#nameStack.s;
fi;
enddef;
vardef Actor_draw@#=
Actor_layout.@#;
objectEnsurePositioning.@#;
drawObjects(@#nameStack, @#human);
enddef;
vardef Actor_border@#=
objectBox(@#);
enddef;
vardef UsecaseInfo@#=
attributes(@#);
var(color) foreColor, borderColor;
FontInfo.@#iFont(metauml_defaultFont, defaultscale);
@#iFont.ignoreNegativeBase := 1;
PictureInfo.@#iName (2, 2, 2, 2)(@#iFont);
PictureStackInfo.@#iNameStack (0, 0, 0, 0)(9)(@#iName);
@#iNameStack.iPict.ignoreNegativeBase := 1;
Margins.@#(2,2,2,2);
@#hFatRatio := .1;
@#vFatRatio := .15;
ShadeInfo.@#iShade;
@#foreColor := .9white;
@#borderColor := black;
enddef;
vardef UsecaseInfoCopy@#(text src)=
log "UsecaseInfoCopy: Copying usecase info";
attributes(@#);
var(color) foreColor, borderColor;
PictureStackInfoCopy.@#iNameStack (src.iNameStack);
MarginsCopy.@#(src);
@#hFatRatio := src.hFatRatio;
@#vFatRatio := src.vFatRatio;
ShadeInfoCopy.@#iShade(src.iShade);
@#foreColor := src.foreColor;
@#borderColor := src.borderColor;
enddef;
UsecaseInfo.iUsecase;
vardef Usecase@#(text contents)=
EUsecase.@#(iUsecase)(contents);
enddef;
vardef EUsecase@#(text _info)(text contents)=
ObjectEquations(@#);
@#className := "Usecase";
UsecaseInfoCopy.@#info(_info);
attributes(@#);
var(numeric) nLines;
@#nLines := 0;
string @#lines[];
for l=contents:
@#lines[@#nLines] := l;
@#nLines := @#nLines + 1;
endfor;
enddef;
vardef Usecase_layout@#=
if @#layedout = 1:
log "Usecase " & (str @#) & " has already been layed out";
else:
@#layedout := 1;
EPictureStack.@#nameStack(@#info.iNameStack)(scantokens listArray(@#lines)(@#nLines))("vcenterbase");
PictureStack_layout.@#nameStack;
numeric @#vFat, @#hFat;
@#hFat = 0;
@#vFat = 10;
@#width = @#nameStack.width + @#info.left + @#info.right + 2 * @#hFat;
@#height = @#nameStack.height + @#info.top + @#info.bottom + 2 * @#vFat;
log "UC w,h";
log @#hFat;
log @#vFat;
log @#nameStack.width;
log @#nameStack.height;
log @#width;
log @#height;
@#c = @#nameStack.c;
fi;
enddef;
vardef Usecase_draw@#=
Usecase_layout@#;
pair @#urt, @#lrt, @#ulft, @#llft;
@#urt = @#nameStack.ne;
@#lrt = @#nameStack.se;
@#ulft = @#nameStack.nw;
@#llft = @#nameStack.sw;
objectEnsurePositioning.@#;
path @#border;
%@#border := @#w .. @#ulft .. @#n .. @#urt .. @#e .. @#lrt .. @#s .. @#llft .. cycle;
@#border := @#w .. @#n .. @#e .. @#s .. cycle;
drawObjectShade(@#);
fill Usecase_border.@# withcolor @#info.foreColor;
draw Usecase_border.@# withcolor @#info.borderColor;
drawObject(@#nameStack);
enddef;
vardef Usecase_border@#=
@#border
enddef;
|