| 1 |
% Copyright 2005 2015 Ovidiu Gheorghies |
| 2 |
% Licensed under the Apache License, Version 2.0. |
| 3 |
|
| 4 |
if known _metauml_behavioral_common_mp: |
| 5 |
expandafter endinput |
| 6 |
fi; |
| 7 |
_metauml_behavioral_common_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 util_log; |
| 22 |
|
| 23 |
vardef SpecialStateInfo@#= |
| 24 |
numeric @#diameter; |
| 25 |
color @#discColor; |
| 26 |
|
| 27 |
numeric @#shade; |
| 28 |
color @#shadeColor, @#foreColor; |
| 29 |
|
| 30 |
@#diameter := 0.4cm; |
| 31 |
@#discColor := black; |
| 32 |
@#foreColor := black; |
| 33 |
|
| 34 |
ShadeInfo.@#iShade; |
| 35 |
enddef; |
| 36 |
|
| 37 |
vardef SpecialStateInfoCopy@#(text src)= |
| 38 |
SpecialStateInfo.@#; |
| 39 |
ShadeInfo_copy.@#iShade(src.iShade); |
| 40 |
|
| 41 |
@#diameter := src.diameter; |
| 42 |
@#discColor := src.discColor; |
| 43 |
@#foreColor := src.foreColor; |
| 44 |
enddef; |
| 45 |
|
| 46 |
%%%%%%%%%%%%%%%%%% |
| 47 |
% BEGIN % |
| 48 |
%%%%%%%%%%%%%%%%%% |
| 49 |
|
| 50 |
SpecialStateInfo.iBegin; |
| 51 |
|
| 52 |
vardef Begin@#= |
| 53 |
ObjectEquations(@#); |
| 54 |
@#className := "Begin"; |
| 55 |
|
| 56 |
SpecialStateInfoCopy.@#info(iBegin); |
| 57 |
enddef; |
| 58 |
|
| 59 |
vardef Begin_layout@#= |
| 60 |
if @#laidout = 1: |
| 61 |
log "Begin " & (str @#) & " has already been layed out"; |
| 62 |
else: |
| 63 |
@#laidout := 1; |
| 64 |
|
| 65 |
@#width = @#info.diameter; |
| 66 |
@#height = @#info.diameter; |
| 67 |
fi; |
| 68 |
enddef; |
| 69 |
|
| 70 |
vardef Begin_draw@#= |
| 71 |
Begin_layout@#; |
| 72 |
objectEnsurePositioning.@#; |
| 73 |
|
| 74 |
path @#border; |
| 75 |
@#border := @#n..@#e..@#s..@#w..cycle; |
| 76 |
|
| 77 |
drawObjectShade(@#); |
| 78 |
|
| 79 |
fill @#border withcolor @#info.discColor; |
| 80 |
draw @#border withcolor @#info.foreColor; |
| 81 |
enddef; |
| 82 |
|
| 83 |
vardef Begin_border@#= |
| 84 |
@#border |
| 85 |
enddef; |
| 86 |
|
| 87 |
%%%%%%%%%%%%%%%%%% |
| 88 |
% END % |
| 89 |
%%%%%%%%%%%%%%%%%% |
| 90 |
|
| 91 |
SpecialStateInfo.iEnd; |
| 92 |
iEnd.innerSpacing := 2; |
| 93 |
iEnd.discColor := white; |
| 94 |
|
| 95 |
vardef End@#= |
| 96 |
ObjectEquations(@#); |
| 97 |
@#className := "End"; |
| 98 |
SpecialStateInfoCopy.@#info(iEnd); |
| 99 |
@#info.innerSpacing := iEnd.innerSpacing; |
| 100 |
enddef; |
| 101 |
|
| 102 |
vardef End_layout@#= |
| 103 |
Begin_layout@#; |
| 104 |
enddef; |
| 105 |
|
| 106 |
vardef End_draw@#= |
| 107 |
Begin_draw.@#; |
| 108 |
|
| 109 |
path @#innerDisc; |
| 110 |
@#innerDisc := @#n - (0, @#info.innerSpacing) .. |
| 111 |
@#e - (@#info.innerSpacing, 0) .. |
| 112 |
@#s + (0, @#info.innerSpacing) .. |
| 113 |
@#w + (@#info.innerSpacing, 0) ..cycle; |
| 114 |
|
| 115 |
fill @#innerDisc withcolor @#info.foreColor; |
| 116 |
enddef; |
| 117 |
|
| 118 |
vardef End_border@#= |
| 119 |
@#border |
| 120 |
enddef; |
| 121 |
|
| 122 |
%%%%%%%%%%%%%%%%%% |
| 123 |
% ENTRY POINT % |
| 124 |
%%%%%%%%%%%%%%%%%% |
| 125 |
|
| 126 |
SpecialStateInfo.iEntryPoint; |
| 127 |
iEntryPoint.discColor := white; |
| 128 |
iEntryPoint.innerSpacing := 2; |
| 129 |
|
| 130 |
vardef EntryPoint@#= |
| 131 |
ObjectEquations(@#); |
| 132 |
@#className := "EntryPoint"; |
| 133 |
SpecialStateInfoCopy.@#info(iEntryPoint); |
| 134 |
@#info.innerSpacing := iEntryPoint.innerSpacing; |
| 135 |
enddef; |
| 136 |
|
| 137 |
vardef EntryPoint_layout@#= |
| 138 |
Begin_layout@#; |
| 139 |
enddef; |
| 140 |
|
| 141 |
vardef EntryPoint_draw@#= |
| 142 |
Begin_draw.@#; |
| 143 |
enddef; |
| 144 |
|
| 145 |
vardef EntryPoint_border@#= |
| 146 |
@#border |
| 147 |
enddef; |
| 148 |
|
| 149 |
%%%%%%%%%%%%%%%%%% |
| 150 |
% EXIT POINT % |
| 151 |
%%%%%%%%%%%%%%%%%% |
| 152 |
|
| 153 |
SpecialStateInfo.iExitPoint; |
| 154 |
iExitPoint.discColor := white; |
| 155 |
iExitPoint.innerSpacing := 2; |
| 156 |
|
| 157 |
vardef ExitPoint@#= |
| 158 |
ObjectEquations(@#); |
| 159 |
@#className := "ExitPoint"; |
| 160 |
SpecialStateInfoCopy.@#info(iExitPoint); |
| 161 |
@#info.innerSpacing := iExitPoint.innerSpacing; |
| 162 |
@#info.iShade.shift := 0; |
| 163 |
enddef; |
| 164 |
|
| 165 |
vardef ExitPoint_layout@#= |
| 166 |
Begin_layout@#; |
| 167 |
enddef; |
| 168 |
|
| 169 |
vardef ExitPoint_draw@#= |
| 170 |
Begin_draw.@#; |
| 171 |
|
| 172 |
_n_ := str @#; |
| 173 |
generic_declare(pair) _n.urt, _n.lrt, _n.llft, _n.ulft; |
| 174 |
|
| 175 |
@#urt := @#c + @#info.diameter/2 * (sind(45), cosd(45)); |
| 176 |
@#lrt := @#c + @#info.diameter/2 * (sind(135), cosd(135)); |
| 177 |
@#llft := @#c + @#info.diameter/2 * (sind(225), cosd(225)); |
| 178 |
@#ulft := @#c + @#info.diameter/2 * (sind(315), cosd(315)); |
| 179 |
|
| 180 |
draw @#urt -- @#llft; |
| 181 |
draw @#ulft -- @#lrt; |
| 182 |
enddef; |
| 183 |
|
| 184 |
vardef ExitPoint_border@#= |
| 185 |
@#border |
| 186 |
enddef; |
| 187 |
|
| 188 |
%%%%%%%%%%%%%%%%%% |
| 189 |
% FlowFinal % |
| 190 |
%%%%%%%%%%%%%%%%%% |
| 191 |
|
| 192 |
SpecialStateInfo.iFlowFinal; |
| 193 |
iFlowFinal.discColor := white; |
| 194 |
iFlowFinal.innerSpacing := 2; |
| 195 |
|
| 196 |
vardef FlowFinal@#= |
| 197 |
ObjectEquations(@#); |
| 198 |
@#className := "FlowFinal"; |
| 199 |
SpecialStateInfoCopy.@#info(iFlowFinal); |
| 200 |
@#info.innerSpacing := iFlowFinal.innerSpacing; |
| 201 |
%@#info.iShade.shift := 0; |
| 202 |
enddef; |
| 203 |
|
| 204 |
vardef FlowFinal_layout@#= |
| 205 |
Begin_layout@#; |
| 206 |
enddef; |
| 207 |
|
| 208 |
vardef FlowFinal_draw@#= |
| 209 |
ExitPoint_draw@# |
| 210 |
enddef; |
| 211 |
|
| 212 |
vardef FlowFinal_border@#= |
| 213 |
@#border |
| 214 |
enddef; |