Debian Codegraph @

texmf-dist/metapost/metauml/metauml_activity.mp

raw
1 % Copyright 2005 2015 Ovidiu Gheorghies
2 % Licensed under the Apache License, Version 2.0.
3
4 if known _metauml_activity_mp:
5 expandafter endinput
6 fi;
7 _metauml_activity_mp:=1;
8
9 % Sadly, this copy of the macro is needed to prevent multiple file loads being shown by MetaPost.
10 % The guard values (such as _metauml_mp) do ensure that the file isn't loaded multiple times,
11 % but this macro makes sure that MetaPost won't try to load the file and display a message for that.
12 def inputonce text libraryFile=
13 if not known scantokens ("_" & str libraryFile & "_mp"):
14 %includeonce% show "Loading " & str libraryFile;
15 scantokens ("input " & str libraryFile);
16 else:
17 %includeonce% show str libraryFile & " already loaded.";
18 fi;
19 enddef;
20
21 inputonce metauml_defaults;
22 inputonce util_log;
23
24 vardef ActivityInfo@#=
25 attributes(@#);
26 var(color) foreColor, borderColor;
27
28 FontInfo.@#iFont(metauml_defaultFont, defaultscale);
29 @#iFont.ignoreNegativeBase := 1;
30
31 PictureInfo.@#iText (2, 2, 2, 2)(@#iFont);
32 PictureStackInfo.@#iStack (2, 2, 2, 2)(9)(@#iText);
33
34 @#iStack.iPict.ignoreNegativeBase := 1;
35
36 Margins.@#(2,2,2,2);
37
38 @#fat := 5;
39
40 ShadeInfo.@#iShade;
41 @#foreColor := .9white;
42 @#borderColor := black;
43 enddef;
44
45 vardef ActivityInfoCopy@#(text src)=
46 log "ActivityInfoCopy: Copying activity info";
47
48 attributes(@#);
49 var(color) foreColor, borderColor;
50
51 PictureStackInfoCopy.@#iStack (src.iStack);
52 MarginsCopy.@#(src);
53 @#fat := src.fat;
54
55 ShadeInfoCopy.@#iShade(src.iShade);
56
57 @#foreColor := src.foreColor;
58 @#borderColor := src.borderColor;
59 enddef;
60
61 ActivityInfo.iActivity;
62
63 vardef Activity@#(text contents)=
64 EActivity.@#(iActivity)(contents);
65 enddef;
66
67 vardef EActivity@#(text _info)(text contents)=
68 ObjectEquations(@#);
69 @#className := "Activity";
70
71 ActivityInfoCopy.@#info(_info);
72
73 numeric @#nLines; @#nLines := 0;
74 string @#lines[];
75 for l=contents:
76 @#lines[@#nLines] := l;
77 @#nLines := @#nLines + 1;
78 endfor;
79
80 EPictureStack.@#stack(@#info.iStack)(scantokens listArray(@#lines)(@#nLines))("vcenterbase");
81 enddef;
82
83 vardef Activity_layout@#=
84 if @#laidout = 1:
85 log "Activity " & (str @#) & " has already been layed out";
86 else:
87 @#laidout := 1;
88
89 PictureStack_layout.@#stack;
90
91 @#width = @#stack.width + @#info.left + @#info.right + 2 * @#info.fat;
92 @#height = @#stack.height + @#info.top + @#info.bottom;
93
94 @#c = @#stack.c;
95
96 pair @#urt, @#lrt, @#ulft, @#llft;
97
98 @#urt := @#ne - (@#info.fat, 0);
99 @#lrt := @#se - (@#info.fat, 0);
100 @#ulft := @#nw + (@#info.fat, 0);
101 @#llft := @#sw + (@#info.fat, 0);
102 fi;
103 enddef;
104
105 vardef Activity_draw@#=
106 Activity_layout@#;
107 objectEnsurePositioning.@#;
108
109 attributes(@#);
110 var(path) border;
111 @#border := @#ulft -- @#urt .. @#e .. @#lrt -- @#llft .. @#w .. cycle;
112
113 drawObjectShade(@#);
114 fill @#border withcolor @#info.foreColor;
115 draw @#border withcolor @#info.borderColor;
116
117 drawObject(@#stack);
118 enddef;
119
120 vardef Activity_border@#=
121 @#border
122 enddef;
123
124
125 vardef BranchInfo@#=
126 @#width := 10;
127 @#height := 10;
128
129 numeric @#shade;
130 color @#shadeColor, @#foreColor;
131 @#shade := .3;
132 @#shadeColor := .6white;
133 @#foreColor := white;
134 enddef;
135
136 BranchInfo.iBranch;
137
138 vardef Branch@#=
139 ObjectEquations(@#);
140 @#className := "Branch";
141
142 @#width = iBranch.width;
143 @#height = iBranch.height;
144 enddef;
145
146 vardef Branch_layout@#=
147 % nothing to do
148 enddef;
149
150 vardef Branch_draw@#=
151 objectEnsurePositioning.@#;
152
153 path @#border;
154 @#border := @#n -- @#e -- @#s -- @#w -- cycle;
155
156 fill @#border shifted (iBranch.shade, -iBranch.shade) withcolor iBranch.shadeColor;
157 fill @#border withcolor iBranch.foreColor;
158 draw @#border;
159 enddef;
160
161 vardef Branch_border@#=
162 @#border
163 enddef;
164
165 vardef ForkInfo@#=
166 @#thickness := 3;
167
168 numeric @#shade;
169 color @#shadeColor, @#foreColor;
170 @#shade := .3;
171 @#shadeColor := .6white;
172 @#foreColor := black;
173 enddef;
174
175 ForkInfo.iFork;
176
177 vardef Fork@#(expr orientation, length)=
178 ObjectEquations(@#);
179 @#className := "Fork";
180
181 if (orientation="h") or (orientation="horiz") or (orientation="horizontal"):
182 @#width = length;
183 @#height = iFork.thickness;
184 else:
185 @#height = length;
186 @#width = iFork.thickness;
187 fi;
188 enddef;
189
190 vardef Fork_layout@#=
191 % nothing to do
192 enddef;
193
194 vardef Fork_draw@#=
195 objectEnsurePositioning.@#;
196
197 path @#border;
198 @#border := @#nw -- @#ne -- @#se -- @#sw -- cycle;
199
200 fill @#border shifted (iFork.shade, -iFork.shade) withcolor iFork.shadeColor;
201 fill @#border withcolor iFork.foreColor;
202 enddef;
203
204 vardef Fork_border@#=
205 @#border
206 enddef;
207
208 defaultTransitionHeadWidth := 15;
209 defaultTransitionHeadHeight := 5;
210
211 vardef TransitionInfo@# =
212 LinkInfo@#;
213
214 @#widthA = 0;
215 @#heightA = 0;
216 @#drawMethodA = "drawNothing";
217
218 @#widthB = defaultTransitionHeadWidth;
219 @#heightB = defaultTransitionHeadHeight;
220 @#drawMethodB = "drawArrow";
221
222 @#drawMethod = "drawLine";
223 enddef;
224
225 TransitionInfo.transition;
226
227 FontInfo.guardFont(metauml_defaultFont, .7);
228 PictureInfo.iGuard(2, 2, 2, 2)(guardFont);
229 iGuard.ignoreNegativeBase := 1;