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
|
% Copyright 2005 2015 Ovidiu Gheorghies
% Licensed under the Apache License, Version 2.0.
if known _metauml_paths_mp:
expandafter endinput
fi;
_metauml_paths_mp:=1;
def pathDirect(expr pA,pB) =
pA--pB
enddef;
vardef pathManhattanX(text twoParams) =
pair pointA__, pointB__;
string paramA_str__, paramB_str__;
boolean paramA_isObject__, paramB_isObject__;
paramA_isObject__ := true;
paramB_isObject__ := true;
boolean isFirstParam__;
isFirstParam__ := true;
%string twoParams;
%twoParams := "";
%twoParams := str paramA & ", " & str paramB;
%%includeonce% show "the two params are: " & twoParams;
forsuffixes param__ = twoParams:
if isFirstParam__:
isFirstParam__ := false;
paramA_str__ := str param__;
%includeonce% show "paramA_str__ <-- " & paramA_str__;
if not known (scantokens (paramA_str__ & ".className")):
%includeonce% show "paramA is not an object";
paramA_isObject__ := false;
fi;
else:
paramB_str__ := str param__;
%includeonce% show "paramB_str__ <-- " & paramB_str__;
if not known (scantokens (paramB_str__ & ".className")):
%includeonce% show "paramB is not an object";
paramB_isObject__ := false;
fi;
fi;
endfor;
%includeonce% show paramA_str__;
%includeonce% show paramA_isObject__;
%includeonce% show paramB_str__;
%includeonce% show paramB_isObject__;
string stringPath__;
stringPath__ := "(0,0)--(50,50)";
if (not paramA_isObject__) and (not paramB_isObject__):
%includeonce% show "Both are points!";
stringPath__ := paramA_str__ & "--(xpart " & paramB_str__ & ", ypart " & paramA_str__ & ") -- " & paramB_str__;
%includeonce% show stringPath__;
else:
pair refPointA__, refPointB__;
if paramA_isObject__:
refPointA__ := scantokens (paramA_str__ & ".c");
else:
refPointA__ := scantokens paramA_str__;
fi;
if paramB_isObject__:
refPointB__ := scantokens (paramB_str__ & ".c");
else:
refPointB__ := scantokens paramB_str__;
fi;
%includeonce% show "Reference point A: ";
%includeonce% show refPointA__;
%includeonce% show "Reference point B: ";
%includeonce% show refPointB__;
numeric dx__, dy__;
dx__ := xpart refPointB__ - xpart refPointA__;
dy__ := ypart refPointB__ - ypart refPointA__;
string addornmentA__;
addornmentA__ := "";
string addornmentB__;
addornmentB__ := "";
if (paramA_isObject__):
if (dx__ > 0):
addornmentA__ := ".e";
else:
addornmentA__ := ".w";
fi;
fi;
if (paramB_isObject__):
if (dy__ > 0):
addornmentB__ := ".s";
else:
addornmentB__ := ".n";
fi;
fi;
stringPath__ := "pathManhattanX(" & paramA_str__ & addornmentA__ & ", " & paramB_str__ & addornmentB__ & ")";
%includeonce% show stringPath;
%includeonce% show "-------------------> recursive call";
fi;
scantokens stringPath__
enddef;
vardef rpathManhattanX(text twoParams) =
reverse pathManhattanX(twoParams)
enddef;
vardef pathManhattanY(expr pA,pB) =
pA--(xpart(pA), ypart(pB))--pB
enddef;
vardef rpathManhattanY(expr pA,pB) =
pB--(xpart(pA), ypart(pB))--pA
enddef;
vardef pathStepX(expr pA,pB, deltax) =
pA--(pA+(deltax, 0))--(((xpart pA)+deltax), ypart(pB))--pB
enddef;
vardef rpathStepX(expr pA,pB, deltax) =
pB--(((xpart pA)+deltax), ypart(pB))--(pA+(deltax, 0))--pA
enddef;
vardef pathStepY(expr pA,pB, deltay) =
pA--(pA+(0, deltay))--(xpart(pB), ((ypart pA)+deltay))--pB
enddef;
vardef rpathStepY(expr pA,pB, deltay) =
pB--(xpart(pB), ((ypart pA)+deltay))--(pA+(0, deltay))--pA
enddef;
vardef pathHorizontal(expr pA, untilX) =
pA--(untilX,ypart(pA))
enddef;
vardef rpathHorizontal(expr pA, untilX) =
(untilX,ypart(pA))--pA
enddef;
vardef pathVertical(expr pA, untilY) =
pA--(xpart(pA), untilY)
enddef;
vardef rpathVertical(expr pA, untilY) =
(xpart(pA), untilY)--pA
enddef;
% Cuts path thePath so that it won't intersect the objects
% objectA and objectB. The border of the objects is obtained
% by invoking the method "_border".
%
vardef pathCut(suffix objectA, objectB)(expr thePath)=
save timeA, timeB;
timeA = xpart (thePath intersectiontimes objectBorder(objectA));
timeB = xpart (thePath intersectiontimes objectBorder(objectB));
subpath (timeA, timeB) of thePath
enddef;
|