cpee 2.1.141 → 2.1.144
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/cockpit/compliance-view.html +8 -11
- data/cockpit/compliance.html +8 -11
- data/cockpit/conformance.html +299 -0
- data/cockpit/css/compliance.css +3 -64
- data/cockpit/css/llmmodel.css +17 -22
- data/cockpit/css/ui.css +9 -14
- data/cockpit/edit.html +7 -10
- data/cockpit/graph.html +3 -6
- data/cockpit/index.html +7 -10
- data/cockpit/js/compliance.js +85 -396
- data/cockpit/js/extended_columns.js +8 -7
- data/cockpit/js/instance.js +3 -4
- data/cockpit/js/llmmodel.js +32 -0
- data/cockpit/js/mp-conformance.js +84 -0
- data/cockpit/js/parameters.js +3 -1
- data/cockpit/js/ui.js +2 -2
- data/cockpit/llm.html +58 -48
- data/cockpit/llmmodel.html +41 -36
- data/cockpit/model.html +6 -9
- data/cockpit/only_llm.html +5 -8
- data/cockpit/rngs/aggregations.rng +15 -0
- data/cockpit/rngs/intervals.rng +12 -0
- data/cockpit/rngs/nlrequirements.rng +8 -0
- data/cockpit/rngs/requirements.rng +2 -2
- data/cockpit/rngs/rules.rng +30 -0
- data/cockpit/templates/Coopis 2010 Replay.xml +7 -7
- data/cockpit/templates/Coopis 2010.xml +7 -7
- data/cockpit/templates/Frames.xml +1 -1
- data/cockpit/templates/Frames1.xml +527 -0
- data/cockpit/templates/ML-pipe-multi.xml +9 -9
- data/cockpit/templates/Readonly Local.xml +4 -4
- data/cockpit/templates/Track Test Local.xml +6 -6
- data/cockpit/templates/Track Test.xml +5 -5
- data/cockpit/templates/UR-VUE 2020 Solution Baseline.xml +6 -6
- data/cockpit/templates/UR-VUE 2020 Solution NN.xml +5 -5
- data/cockpit/templates/UR-VUE 2020 Solution View.xml +1 -1
- data/cockpit/templates/UR-VUE 2020.xml +1 -1
- data/cockpit/templates/Wait.xml +1 -1
- data/cockpit/templates/Worklist Vote.xml +2 -2
- data/cockpit/templates/Worklist.xml +1 -1
- data/cockpit/templates/instantiate/Take_Sub.xml +1 -1
- data/cockpit/templates/instantiate.local/Take_Sub.xml +1 -1
- data/cockpit/themes/base.js +18 -10
- data/cockpit/themes/presetlr/theme.js +1 -0
- data/cockpit/track.html +3 -6
- data/cpee.gemspec +2 -2
- data/lib/cpee/implementation.rb +2 -1
- data/lib/cpee/implementation_callbacks.rb +4 -2
- data/lib/cpee/implementation_notifications.rb +2 -2
- data/lib/cpee/persistence.rb +1 -0
- data/lib/engine/instances.rng +5 -0
- data/lib/properties/description.rng +0 -1
- data/lib/properties/dslx.rng +0 -1
- data/lib/properties/properties.rng +1 -0
- data/lib/properties/set-properties.rng +1 -0
- data/lib/properties/set-some-properties.rng +1 -0
- data/lib/properties/set-testset.rng +1 -0
- data/lib/properties/state.rng +0 -2
- data/lib/properties.xml +0 -1
- data/server/executionhandlers/eval/connection.rb +3 -6
- data/server/executionhandlers/ruby/connection.rb +3 -6
- data/server/executionhandlers/ruby/controller.rb +22 -16
- data/server/resources/states.dot +0 -4
- data/server/resources/states.xml +2 -8
- data/server/resources/topics.xml +0 -3
- data/tools/cpee +115 -2
- metadata +11 -5
- data/cockpit/css/wfadaptor.css +0 -401
- data/cockpit/js/wfadaptor.js +0 -1680
data/cockpit/js/wfadaptor.js
DELETED
|
@@ -1,1680 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
This file is part of cpee-layout.
|
|
3
|
-
|
|
4
|
-
cpee-layout is free software: you can redistribute it and/or modify it under
|
|
5
|
-
the terms of the GNU Lesser General Public License as published by the Free
|
|
6
|
-
Software Foundation, either version 3 of the License, or (at your option) any
|
|
7
|
-
later version.
|
|
8
|
-
|
|
9
|
-
cpee-layout is distributed in the hope that it will be useful, but WITHOUT
|
|
10
|
-
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
11
|
-
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
|
12
|
-
details.
|
|
13
|
-
|
|
14
|
-
You should have received a copy of the GNU Lesser General Public License
|
|
15
|
-
along with cpee-layout (file LICENSE in the main directory). If not, see
|
|
16
|
-
<http://www.gnu.org/licenses/>.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
// TODO: changes in svg-script:
|
|
20
|
-
// 1) drawing functions
|
|
21
|
-
// 2) creation of svg-container (Bug: arrows on lines)
|
|
22
|
-
// 3) after-function to insert using namespace of description
|
|
23
|
-
|
|
24
|
-
// WfAdaptor:
|
|
25
|
-
// Handles interaction between Illustartor and Description
|
|
26
|
-
// e.g. Event fires to Adaptor to insert Element and Illustrator and Description do it
|
|
27
|
-
function WfAdaptor(theme_base,doit) { // Controller {{{
|
|
28
|
-
|
|
29
|
-
// public variables {{{
|
|
30
|
-
this.illustrator;
|
|
31
|
-
this.description;
|
|
32
|
-
this.elements = {};
|
|
33
|
-
this.theme_base = theme_base;
|
|
34
|
-
this.theme_dir = theme_base.replace(/theme.js/,'');
|
|
35
|
-
this.properties = {};
|
|
36
|
-
// }}}
|
|
37
|
-
|
|
38
|
-
// private variables {{{
|
|
39
|
-
var illustrator;
|
|
40
|
-
var description;
|
|
41
|
-
var self = this;
|
|
42
|
-
// }}}
|
|
43
|
-
|
|
44
|
-
// helper funtions
|
|
45
|
-
this.set_description = function(desc,auto_update) { // public {{{
|
|
46
|
-
this.description.set_description(desc,auto_update);
|
|
47
|
-
} // }}}
|
|
48
|
-
|
|
49
|
-
this.get_description = function() { // public {{{
|
|
50
|
-
return description.get_description();
|
|
51
|
-
} // }}}
|
|
52
|
-
this.notify = function() { // public {{{
|
|
53
|
-
} // }}}
|
|
54
|
-
this.draw_labels = function(max,labels,dimensions,striped){ // public {{{
|
|
55
|
-
} // }}}
|
|
56
|
-
this.set_svg_container = function (container) { // {{{
|
|
57
|
-
illustrator.set_svg_container(container); // TODO: shadowing the container element
|
|
58
|
-
} // }}}
|
|
59
|
-
this.set_label_container = function(container) { // {{{
|
|
60
|
-
illustrator.set_label_container(container);
|
|
61
|
-
} // }}}
|
|
62
|
-
this.get_svg = function() { // {{{
|
|
63
|
-
return illustrator.get_svg();
|
|
64
|
-
} // }}}
|
|
65
|
-
this.get_svg_metrics = function() { // {{{
|
|
66
|
-
return illustrator.get_svg_metrics();
|
|
67
|
-
} // }}}
|
|
68
|
-
|
|
69
|
-
function loadTheme(doit) { //{{{
|
|
70
|
-
manifestation = new WFAdaptorManifestation(self);
|
|
71
|
-
illustrator.compact = manifestation.compact == true ? true : false;
|
|
72
|
-
illustrator.rotated_labels = manifestation.rotated_labels == true ? true : false;
|
|
73
|
-
illustrator.striped = manifestation.striped == true ? true : false;
|
|
74
|
-
illustrator.lr = manifestation.lr == true ? true : false;
|
|
75
|
-
illustrator.wellformed_pre_test = manifestation.wellformed_pre_test == true ? true : false;
|
|
76
|
-
description.source = manifestation.source;
|
|
77
|
-
var deferreds = [];
|
|
78
|
-
// copy parent stuff
|
|
79
|
-
for(element in manifestation.elements) {
|
|
80
|
-
if (manifestation.elements[element].parent) {
|
|
81
|
-
if (!manifestation.elements[element].description) {
|
|
82
|
-
manifestation.elements[element].description = manifestation.elements[manifestation.elements[element].parent].description;
|
|
83
|
-
}
|
|
84
|
-
if (!manifestation.elements[element].adaptor) {
|
|
85
|
-
manifestation.elements[element].adaptor = manifestation.elements[manifestation.elements[element].parent].adaptor;
|
|
86
|
-
}
|
|
87
|
-
var ill = manifestation.elements[manifestation.elements[element].parent].illustrator;
|
|
88
|
-
for (var key in ill) {
|
|
89
|
-
if (manifestation.elements[element].illustrator[key] == undefined) {
|
|
90
|
-
manifestation.elements[element].illustrator[key] = ill[key];
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
if (manifestation.elements[element].type == undefined) {
|
|
94
|
-
manifestation.elements[element].type = manifestation.elements[manifestation.elements[element].parent].type;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
// doit
|
|
99
|
-
for(element in manifestation.resources) {
|
|
100
|
-
deferreds.push(
|
|
101
|
-
$.ajax({
|
|
102
|
-
type: "GET",
|
|
103
|
-
dataType: "xml",
|
|
104
|
-
url: manifestation.resources[element],
|
|
105
|
-
context: element,
|
|
106
|
-
success: function(res){
|
|
107
|
-
manifestation.resources[this] = $(res.documentElement);
|
|
108
|
-
}
|
|
109
|
-
})
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
for(element in manifestation.elements) {
|
|
113
|
-
if (manifestation.elements[element].illustrator) {
|
|
114
|
-
if (manifestation.elements[element].illustrator.svg && (typeof manifestation.elements[element].illustrator.svg === 'string' || manifestation.elements[element].illustrator.svg instanceof String)) {
|
|
115
|
-
deferreds.push(
|
|
116
|
-
$.ajax({
|
|
117
|
-
type: "GET",
|
|
118
|
-
dataType: "xml",
|
|
119
|
-
url: manifestation.elements[element].illustrator.svg,
|
|
120
|
-
context: element,
|
|
121
|
-
success: function(res){
|
|
122
|
-
manifestation.elements[this].illustrator.svg = $(res.documentElement);
|
|
123
|
-
}
|
|
124
|
-
})
|
|
125
|
-
);
|
|
126
|
-
} else if (manifestation.elements[element].illustrator.svg && (typeof manifestation.elements[element].illustrator.svg === 'object' || manifestation.elements[element].illustrator.svg instanceof Object)) {
|
|
127
|
-
if (manifestation.elements[element].illustrator.svg.start) {
|
|
128
|
-
deferreds.push(
|
|
129
|
-
$.ajax({
|
|
130
|
-
type: "GET",
|
|
131
|
-
dataType: "xml",
|
|
132
|
-
url: manifestation.elements[element].illustrator.svg.start,
|
|
133
|
-
context: element,
|
|
134
|
-
success: function(res){
|
|
135
|
-
manifestation.elements[this].illustrator.svg.start = $(res.documentElement);
|
|
136
|
-
}
|
|
137
|
-
})
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
if (manifestation.elements[element].illustrator.svg.middle) {
|
|
141
|
-
deferreds.push(
|
|
142
|
-
$.ajax({
|
|
143
|
-
type: "GET",
|
|
144
|
-
dataType: "xml",
|
|
145
|
-
url: manifestation.elements[element].illustrator.svg.middle,
|
|
146
|
-
context: element,
|
|
147
|
-
success: function(res){
|
|
148
|
-
manifestation.elements[this].illustrator.svg.middle = $(res.documentElement);
|
|
149
|
-
}
|
|
150
|
-
})
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
if (manifestation.elements[element].illustrator.svg.end) {
|
|
154
|
-
deferreds.push(
|
|
155
|
-
$.ajax({
|
|
156
|
-
type: "GET",
|
|
157
|
-
dataType: "xml",
|
|
158
|
-
url: manifestation.elements[element].illustrator.svg.end,
|
|
159
|
-
context: element,
|
|
160
|
-
success: function(res){
|
|
161
|
-
manifestation.elements[this].illustrator.svg.end = $(res.documentElement);
|
|
162
|
-
}
|
|
163
|
-
})
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
illustrator.elements[element] = manifestation.elements[element].illustrator;
|
|
168
|
-
illustrator.elements[element].type = manifestation.elements[element].type || 'abstract';
|
|
169
|
-
}
|
|
170
|
-
if (manifestation.elements[element].description) {
|
|
171
|
-
if ( typeof manifestation.elements[element].description === 'string' ) {
|
|
172
|
-
manifestation.elements[element].description = [ manifestation.elements[element].description ];
|
|
173
|
-
}
|
|
174
|
-
if ($.isArray(manifestation.elements[element].description)) {
|
|
175
|
-
manifestation.elements[element].description.forEach(function(val,ind){
|
|
176
|
-
deferreds.push(
|
|
177
|
-
$.ajax({
|
|
178
|
-
type: "GET",
|
|
179
|
-
dataType: "xml",
|
|
180
|
-
url: val,
|
|
181
|
-
context: element,
|
|
182
|
-
success: function(res){
|
|
183
|
-
manifestation.elements[this].description = $(res.documentElement);
|
|
184
|
-
description.elements[this] = manifestation.elements[this].description;
|
|
185
|
-
}
|
|
186
|
-
})
|
|
187
|
-
);
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
if (manifestation.elements[element].adaptor) {
|
|
192
|
-
self.elements[element] = manifestation.elements[element].adaptor;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
$.when.apply($, deferreds).then(function(x) {
|
|
196
|
-
doit(self);
|
|
197
|
-
})
|
|
198
|
-
} //}}}
|
|
199
|
-
|
|
200
|
-
// initialize
|
|
201
|
-
this.illustrator = illustrator = new WfIllustrator(this);
|
|
202
|
-
this.description = description = new WfDescription(this, this.illustrator);
|
|
203
|
-
|
|
204
|
-
this.draw_element = function(type,id,label) {
|
|
205
|
-
let pos = {'row': 1,'col': 0};
|
|
206
|
-
let block = { 'max': {'row': pos.row, 'col': pos.col}, 'endnodes': [], 'svg': $X('<g class="group" xmlns="http://www.w3.org/2000/svg"/>') };
|
|
207
|
-
illustrator.draw.draw_symbol(type, id, label, pos.row, pos.row, pos.row, pos.col, block.svg, false, {}, {})
|
|
208
|
-
self.illustrator.set_svg(block);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
this.redraw = function(doit){
|
|
212
|
-
description.redraw(doit);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
$.getScript(self.theme_base).done(function() {
|
|
216
|
-
loadTheme(doit);
|
|
217
|
-
}).fail(function(){
|
|
218
|
-
// default theme
|
|
219
|
-
self.theme_base = 'themes/preset/theme.js';
|
|
220
|
-
self.theme_dir = self.theme_base.replace(/theme.js/,'');
|
|
221
|
-
$.getScript(self.theme_base,function() {
|
|
222
|
-
loadTheme(doit);
|
|
223
|
-
});
|
|
224
|
-
});
|
|
225
|
-
} // }}}
|
|
226
|
-
|
|
227
|
-
// WfIllustrator:
|
|
228
|
-
// Is in charge of displaying the Graph. It is further able insert and remove elements with given ID's from the illustration.
|
|
229
|
-
function WfIllustrator(wf_adaptor) { // View {{{
|
|
230
|
-
// Variable {{{
|
|
231
|
-
// public
|
|
232
|
-
this.endclipshift = 17;
|
|
233
|
-
this.height = 40;
|
|
234
|
-
this.width = 40;
|
|
235
|
-
this.default_width = 40;
|
|
236
|
-
this.default_height = 40;
|
|
237
|
-
this.height_shift = this.height * 0.26;
|
|
238
|
-
this.width_shift = this.width * 0.39;
|
|
239
|
-
this.width_shift_label = 7;
|
|
240
|
-
this.group_extend = 1;
|
|
241
|
-
this.structural_tighten = 3; // 'structural' borders are smaller in y
|
|
242
|
-
this.conn_center = 15; // connectors attach to the center of the symbols, i.e. half a symbol before the end of the cell
|
|
243
|
-
this.elements = {}; // the svgs
|
|
244
|
-
this.svg = {};
|
|
245
|
-
this.draw = {};
|
|
246
|
-
this.dim = {};
|
|
247
|
-
this.dim.symbols = [];
|
|
248
|
-
this.dim.connections = [];
|
|
249
|
-
this.dim.implied = []; // symbols that an icon draws in a neighbouring cell (theme: implied), for the metrics only
|
|
250
|
-
this.dim.labels = {}; // the shown label of each cell ('row,col'), for the metrics only
|
|
251
|
-
this.dim.rows = []; // lr only: start and size of each symbol along the rows
|
|
252
|
-
this.compact = true;
|
|
253
|
-
this.rotated_labels = true;
|
|
254
|
-
this.striped = true;
|
|
255
|
-
this.lr = false;
|
|
256
|
-
this.wellformed_pre_test = false; // experimental: pre_test loops are drawn reversed
|
|
257
|
-
this.inverted = false; // true while drawing inside such a loop, nested pre_test loops toggle it
|
|
258
|
-
this.global_style = {};
|
|
259
|
-
// private
|
|
260
|
-
var self = this;
|
|
261
|
-
var adaptor = null;
|
|
262
|
-
// }}}
|
|
263
|
-
// Internal Functions
|
|
264
|
-
this.set_label_container = function(con) { // {{{
|
|
265
|
-
self.svg.label_container = con;
|
|
266
|
-
} // }}}
|
|
267
|
-
this.set_svg_container = function(con) { // {{{
|
|
268
|
-
self.svg.container = con;
|
|
269
|
-
self.svg.container.append($X('<defs xmlns="http://www.w3.org/2000/svg">' +
|
|
270
|
-
' <marker id="arrow" viewBox="0 0 10 10" refX="28.5" refY="5" orient="auto" markerUnits="strokeWidth" markerWidth="14" markerHeight="3.5">' +
|
|
271
|
-
' <path d="m 2 2 l 6 3 l -6 3 z"/>' +
|
|
272
|
-
' </marker>' +
|
|
273
|
-
' <marker id="endarrow" viewBox="0 0 10 10" refX="7" refY="5" orient="auto" markerUnits="strokeWidth" markerWidth="14" markerHeight="5.2">' +
|
|
274
|
-
' <path d="M 2,2 L 6.21,4.11 Q 8,5 6.21,5.89 L 2,8 Z"/>' +
|
|
275
|
-
' </marker>' +
|
|
276
|
-
' <marker id="arrowrev" viewBox="0 0 10 10" refX="28.5" refY="5" orient="auto-start-reverse" markerUnits="strokeWidth" markerWidth="14" markerHeight="3.5">' +
|
|
277
|
-
' <path d="m 2 2 l 6 3 l -6 3 z"/>' +
|
|
278
|
-
' </marker>' +
|
|
279
|
-
' <marker id="endarrowrev" viewBox="0 0 10 10" refX="7" refY="5" orient="auto-start-reverse" markerUnits="strokeWidth" markerWidth="14" markerHeight="5.2">' +
|
|
280
|
-
' <path d="M 2,2 L 6.21,4.11 Q 8,5 6.21,5.89 L 2,8 Z"/>' +
|
|
281
|
-
' </marker>' +
|
|
282
|
-
' <marker id="arrowdiag" viewBox="0 0 10 10" refX="24.5" refY="5" orient="auto" markerUnits="strokeWidth" markerWidth="14" markerHeight="3.5">' +
|
|
283
|
-
' <path d="m 2 2 l 6 3 l -6 3 z"/>' +
|
|
284
|
-
' </marker>' +
|
|
285
|
-
' <marker id="arrowdiagrev" viewBox="0 0 10 10" refX="24.5" refY="5" orient="auto-start-reverse" markerUnits="strokeWidth" markerWidth="14" markerHeight="3.5">' +
|
|
286
|
-
' <path d="m 2 2 l 6 3 l -6 3 z"/>' +
|
|
287
|
-
' </marker>' +
|
|
288
|
-
' <clipPath id="startclip">' +
|
|
289
|
-
' <rect x="-4" y="-4" width="35" height="38"/>' +
|
|
290
|
-
' </clipPath>' +
|
|
291
|
-
' <clipPath id="endclip">' +
|
|
292
|
-
' <rect x="20" y="-1" width="' + self.endclipshift + '" height="35"/>' +
|
|
293
|
-
' </clipPath>' +
|
|
294
|
-
' <linearGradient id="custom-gradient" x2="0.35" y2="1">' +
|
|
295
|
-
' <stop offset="0%" stop-color="var(--wfadaptor-background)"/>' +
|
|
296
|
-
' <stop offset="50%" stop-color="var(--custom-color)"/>' +
|
|
297
|
-
' <stop offset="100%" stop-color="var(--custom-color)"/>' +
|
|
298
|
-
' </linearGradient>' +
|
|
299
|
-
'</defs>'));
|
|
300
|
-
self.svg.defs = {};
|
|
301
|
-
self.svg.defs['unknown'] = $X('<g xmlns="http://www.w3.org/2000/svg" class="unknown">' +
|
|
302
|
-
'<circle cx="15" cy="15" r="14" class="unkown"/>' +
|
|
303
|
-
'<text transform="translate(15,20)" class="normal">?</text>' +
|
|
304
|
-
'</g>');
|
|
305
|
-
for(element in self.elements)
|
|
306
|
-
if(self.elements[element].svg) {
|
|
307
|
-
var sym = $X('<g xmlns="http://www.w3.org/2000/svg"/>').append(self.elements[element].svg.clone().children()); // append all children to symbol
|
|
308
|
-
$.each(self.elements[element].svg.attr('class').split(/\s+/), function(index, item) { sym.addClass(item); }); // copy all classes from the root node
|
|
309
|
-
self.svg.defs[element] = sym;
|
|
310
|
-
}
|
|
311
|
-
} // }}}
|
|
312
|
-
this.set_svg = function(graph) { // {{{
|
|
313
|
-
self.svg.container.append(graph.svg);
|
|
314
|
-
let bb = graph.svg[0].getBBox();
|
|
315
|
-
|
|
316
|
-
let w = self.dim.get_x_max(0,graph.max.row,graph.max.col,'start');
|
|
317
|
-
if (w == 0) { w = bb.x + bb.width + self.width_shift; }
|
|
318
|
-
// the alternative is bb.x + bb.width + self.width_shift, but this is bad when clipped elements
|
|
319
|
-
if (self.lr) { w = Math.max(w, bb.x + bb.width + self.width_shift); } // lr: labels can reach across the flow, e.g. rotated below a gateway; clipped labels only reach along it
|
|
320
|
-
|
|
321
|
-
if (self.lr) { // mirror at the diagonal: rows go to the right, columns go down
|
|
322
|
-
graph.svg.attr('transform',lr_matrix());
|
|
323
|
-
self.svg.container.attr('height', w - lr_shift() + self.height_shift);
|
|
324
|
-
self.svg.container.attr('width', bb.y + bb.height + self.height_shift + lr_shift());
|
|
325
|
-
} else {
|
|
326
|
-
self.svg.container.attr('height', bb.y + bb.height + self.height_shift); // small border on the bottom
|
|
327
|
-
self.svg.container.attr('width', w); // small border on the right
|
|
328
|
-
}
|
|
329
|
-
} // }}}
|
|
330
|
-
this.get_svg = function() { // {{{
|
|
331
|
-
// standalone copy for export: the rules of all stylesheets marked with
|
|
332
|
-
// data-include-export are inlined into the style attributes (var()
|
|
333
|
-
// resolved, in cascade order), further columns from the label container are
|
|
334
|
-
// merged in, and interaction state and the render time are removed
|
|
335
|
-
var svgs = [self.svg.container.get(0)];
|
|
336
|
-
if (self.svg.label_container) {
|
|
337
|
-
self.svg.label_container.children('svg').not(self.svg.container).each(function(_,ele) { svgs.push(ele); });
|
|
338
|
-
}
|
|
339
|
-
var clones = svgs.map(function(s) { return s.cloneNode(true); });
|
|
340
|
-
|
|
341
|
-
var root = getComputedStyle(document.documentElement);
|
|
342
|
-
var rules = [];
|
|
343
|
-
var family = '';
|
|
344
|
-
$.each(document.styleSheets, function(_,sheet) {
|
|
345
|
-
if (!sheet.ownerNode || !sheet.ownerNode.hasAttribute('data-include-export')) { return; }
|
|
346
|
-
$.each(sheet.cssRules, function(_,rule) {
|
|
347
|
-
if (!rule.selectorText || rule.selectorText == ':root') { return; }
|
|
348
|
-
if (rule.selectorText == 'svg') {
|
|
349
|
-
if (rule.style.getPropertyValue('font-family') != '') {
|
|
350
|
-
family = getComputedStyle(svgs[0]).getPropertyValue('font-family').replace(/["']/g,'').trim();
|
|
351
|
-
}
|
|
352
|
-
return;
|
|
353
|
-
}
|
|
354
|
-
var css = rule.style.cssText.replace(/var\((--[\w-]+)\)/g, function(m,v) { return root.getPropertyValue(v).trim() || m; });
|
|
355
|
-
rule.selectorText.split(',').forEach(function(sel) {
|
|
356
|
-
rules.push({ sel: sel.trim(), spec: specificity(sel), order: rules.length, css: css });
|
|
357
|
-
});
|
|
358
|
-
});
|
|
359
|
-
});
|
|
360
|
-
rules.sort(function(a,b) { return a.spec - b.spec || a.order - b.order; });
|
|
361
|
-
family = family.replace(/-/,' ').split(' ').map(function(w) { return w[0].toUpperCase() + w.substr(1); }).join(' '); // adwaita-sans -> Adwaita Sans, the installed name
|
|
362
|
-
|
|
363
|
-
clones.forEach(function(clone) {
|
|
364
|
-
$(clone).find('.duration').remove();
|
|
365
|
-
$(clone).find('.selected').removeClass('selected');
|
|
366
|
-
$(clone).find('.hover').removeClass('hover');
|
|
367
|
-
$(clone).find('*').each(function(_,el) {
|
|
368
|
-
var decl = [];
|
|
369
|
-
rules.forEach(function(r) {
|
|
370
|
-
try { if (el.matches(r.sel)) { decl.push(r.css); } } catch (e) { } // e.g. unsupported pseudo classes
|
|
371
|
-
});
|
|
372
|
-
var own = el.getAttribute('style');
|
|
373
|
-
if (own && own.trim() != '') { decl.push(own.trim().replace(/;?$/,';')); }
|
|
374
|
-
if ($(el).is('text.super, g.hoverstyle, g.markstyle')) { decl.push('display: none;'); }
|
|
375
|
-
if (el.nodeName == 'text' && family != '') { decl.push('font-family: \'' + family + '\';'); }
|
|
376
|
-
if (decl.length > 0) { el.setAttribute('style', decl.join(' ')); }
|
|
377
|
-
});
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
var svg = clones.shift();
|
|
381
|
-
var width = parseInt(svg.getAttribute('width'));
|
|
382
|
-
clones.forEach(function(clone) {
|
|
383
|
-
var gr = $X('<g transform="translate(' + width + ')" xmlns="http://www.w3.org/2000/svg"></g>');
|
|
384
|
-
gr.append($(clone).children());
|
|
385
|
-
width += parseInt(clone.getAttribute('width'));
|
|
386
|
-
$(svg).append(gr);
|
|
387
|
-
});
|
|
388
|
-
svg.setAttribute('width', width + 1);
|
|
389
|
-
return svg;
|
|
390
|
-
} // }}}
|
|
391
|
-
this.get_svg_metrics = function() { // {{{
|
|
392
|
-
// the layout of the last drawing as it is shown (a copy, empty cells are
|
|
393
|
-
// null): pos_matrix holds the symbols per row and column, x and width are
|
|
394
|
-
// horizontal; con_list the connections between them. Rows and columns are
|
|
395
|
-
// 0-indexed here, the layout counts from 1. lr is laid out top to bottom
|
|
396
|
-
// and mirrored at the diagonal, so rows and columns are swapped back, and x
|
|
397
|
-
// and width come from the rows (as in get_x, x is the symbol position plus
|
|
398
|
-
// width_shift). geometry: a symbol is drawn shift left of its x, and the
|
|
399
|
-
// symbols of row r start at top + r * row. label_box is where the label is
|
|
400
|
-
// shown, in the coordinates of the svg
|
|
401
|
-
var center_x = (self.width - self.default_width) / 2;
|
|
402
|
-
var center_y = (self.height - self.default_height) / 2;
|
|
403
|
-
var geometry = self.lr ? // lr: x runs along the internal rows, the rows are the internal columns, lr_matrix moves both by lr_shift
|
|
404
|
-
{ shift: self.width_shift - center_y, top: 2 * self.height_shift + center_x, row: self.width } :
|
|
405
|
-
{ shift: self.width_shift - center_x, top: self.height_shift + center_y, row: self.height };
|
|
406
|
-
var pos =function(r,c) { return self.lr ? { row: c - 1, col: r - 1 } : { row: r - 1, col: c - 1 }; };
|
|
407
|
-
var row_start = function(r,c) { // like get_row, but symbols without an own entry (e.g. alternative) also find one to the right
|
|
408
|
-
var rs = self.dim.rows[r] || [];
|
|
409
|
-
for (var j = c; j >= 0; j--) { if (rs[j]) { return rs[j].start; } }
|
|
410
|
-
for (var j = c + 1; j < rs.length; j++) { if (rs[j]) { return rs[j].start; } }
|
|
411
|
-
return 0;
|
|
412
|
-
};
|
|
413
|
-
var pos_matrix = [];
|
|
414
|
-
self.dim.symbols.forEach(function(row,r) {
|
|
415
|
-
if (!row) { return; }
|
|
416
|
-
row.forEach(function(sym,c) {
|
|
417
|
-
if (!sym || !sym.type || r == 0 || c == 0) { return; } // without type the cell is only reserved (set_x), nothing is drawn there
|
|
418
|
-
var p = pos(r,c);
|
|
419
|
-
var s = $.extend({}, sym);
|
|
420
|
-
if (self.lr) {
|
|
421
|
-
s.x = row_start(r,c) + self.width;
|
|
422
|
-
s.width = (self.dim.rows[r] && self.dim.rows[r][c] && self.dim.rows[r][c].size) || self.height;
|
|
423
|
-
}
|
|
424
|
-
var lab = self.dim.labels[r + ',' + c];
|
|
425
|
-
if (lab) {
|
|
426
|
-
var b = get_box(lab);
|
|
427
|
-
s.label_box = { x: b.x, y: b.y, width: b.width, height: b.height };
|
|
428
|
-
}
|
|
429
|
-
if (!pos_matrix[p.row]) { pos_matrix[p.row] = []; }
|
|
430
|
-
pos_matrix[p.row][p.col] = s;
|
|
431
|
-
});
|
|
432
|
-
});
|
|
433
|
-
self.dim.implied.forEach(function(i) { // x/y are cells in the icon; lr mirrors the icon, so its x runs along the rows there
|
|
434
|
-
var dr = self.lr ? (i.x || 0) : (i.y || 0), dc = self.lr ? (i.y || 0) : (i.x || 0);
|
|
435
|
-
var r = i.row + dr, c = i.col + dc;
|
|
436
|
-
var p = pos(r,c);
|
|
437
|
-
var src = self.dim.symbols[i.row][i.col];
|
|
438
|
-
if (!pos_matrix[p.row]) { pos_matrix[p.row] = []; }
|
|
439
|
-
if (pos_matrix[p.row][p.col]) { return; } // a real symbol wins
|
|
440
|
-
pos_matrix[p.row][p.col] = self.lr ?
|
|
441
|
-
{ x: row_start(i.row,i.col) + self.width + dr * self.height, width: self.height, type: i.type, eid: src.eid } :
|
|
442
|
-
{ x: src.x + dc * self.width, width: self.width, type: i.type, eid: src.eid };
|
|
443
|
-
});
|
|
444
|
-
var con_list = self.dim.connections.map(function(c) {
|
|
445
|
-
return { from: pos(c.from.row,c.from.col), to: pos(c.to.row,c.to.col) };
|
|
446
|
-
});
|
|
447
|
-
return JSON.parse(JSON.stringify({ lr: self.lr == true, geometry: geometry, pos_matrix: pos_matrix, con_list: con_list })); // holes become null
|
|
448
|
-
} // }}}
|
|
449
|
-
var specificity = function(sel) { // {{{ ids, classes/attributes/pseudo classes, types
|
|
450
|
-
var s = sel.replace(/::[\w-]+/g,'');
|
|
451
|
-
var a = (s.match(/#[\w-]+/g) || []).length;
|
|
452
|
-
var b = (s.match(/\.[\w-]+|\[[^\]]*\]|:[\w-]+/g) || []).length;
|
|
453
|
-
var c = (s.replace(/\[[^\]]*\]/g,'').match(/(^|[\s>+~(])[a-zA-Z][\w-]*/g) || []).length;
|
|
454
|
-
return a * 10000 + b * 100 + c;
|
|
455
|
-
} // }}}
|
|
456
|
-
this.set_duration = function(start) { //{{{
|
|
457
|
-
self.svg.container.append(
|
|
458
|
-
$X('<text class="duration" transform="translate(3,' + self.height_shift + ') rotate(90)" xmlns="http://www.w3.org/2000/svg">' +
|
|
459
|
-
Math.trunc(performance.now()-start) + ' ms' +
|
|
460
|
-
'</text>')
|
|
461
|
-
);
|
|
462
|
-
} //}}}
|
|
463
|
-
|
|
464
|
-
this.get_node_by_svg_id = function(svg_id) { // {{{
|
|
465
|
-
return $('[element-id = \'' + svg_id + '\'] g.activities', self.svg.container);
|
|
466
|
-
} // }}}
|
|
467
|
-
this.get_label_by_svg_id = function(svg_id) { // {{{
|
|
468
|
-
return $('[element-id = \'' + svg_id + '\']', self.svg.label_container);
|
|
469
|
-
} // }}}
|
|
470
|
-
this.get_elements = function() { // {{{
|
|
471
|
-
return $('g.element', self.svg.container);
|
|
472
|
-
} // }}}
|
|
473
|
-
this.get_labels = function() { // {{{
|
|
474
|
-
return $('[element-id]', self.svg.label_container);
|
|
475
|
-
} // }}}
|
|
476
|
-
|
|
477
|
-
// External Functions
|
|
478
|
-
var clear = this.clear = function() { // {{{
|
|
479
|
-
$('> :not(defs)', self.svg.container).each(function() {$(this).remove()});
|
|
480
|
-
$('> defs > [belongs-to=element]', self.svg.container).each(function() {$(this).remove()});
|
|
481
|
-
self.dim.symbols = [];
|
|
482
|
-
self.dim.connections = [];
|
|
483
|
-
self.dim.implied = [];
|
|
484
|
-
self.dim.labels = {};
|
|
485
|
-
self.dim.rows = [];
|
|
486
|
-
} // }}}
|
|
487
|
-
var get_symbol = this.get_symbol = function() { // {{{
|
|
488
|
-
} // }}}
|
|
489
|
-
var get_properties = this.get_properties = function() { // {{{
|
|
490
|
-
} // }}}
|
|
491
|
-
|
|
492
|
-
// Helper Functions {{{
|
|
493
|
-
var debug_dim = this.dim.debug = function() { //{{{
|
|
494
|
-
line = '\n';
|
|
495
|
-
for (let i=1; i < self.dim.symbols.length; i++) {
|
|
496
|
-
line += $.sprintf('%02d',i) + ': ';
|
|
497
|
-
if (self.dim.symbols[i]) {
|
|
498
|
-
for (let j=1; j < self.dim.symbols[i].length; j++) {
|
|
499
|
-
line += ' [ ';
|
|
500
|
-
if (self.dim.symbols[i] && self.dim.symbols[i][j] && self.dim.symbols[i][j].x) { line += $.sprintf('%3d',self.dim.symbols[i][j].x); } else { line += ' '; }
|
|
501
|
-
line += ', ';
|
|
502
|
-
if (self.dim.symbols[i] && self.dim.symbols[i][j] && self.dim.symbols[i][j].width) { line += $.sprintf('%3d',self.dim.symbols[i][j].width); } else { line += ' '; }
|
|
503
|
-
line += ' ] ';
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
line += "\n";
|
|
507
|
-
}
|
|
508
|
-
return line;
|
|
509
|
-
} //}}}
|
|
510
|
-
|
|
511
|
-
var set_x = this.dim.set_x = function(row,col,twidth) { //{{{
|
|
512
|
-
// reserves the space of a cell; what is drawn there (type, label, ...) is set by set_x_cond
|
|
513
|
-
if (!self.dim.symbols[row]) { self.dim.symbols[row] = []; }
|
|
514
|
-
if (!self.dim.symbols[row][col]) { self.dim.symbols[row][col] = {}; }
|
|
515
|
-
|
|
516
|
-
if (self.dim.symbols[row-1] && self.dim.symbols[row-1][col] && self.dim.symbols[row-1][col].x) { // row before
|
|
517
|
-
self.dim.symbols[row][col].x = self.dim.symbols[row-1][col].x;
|
|
518
|
-
} else if (self.dim.symbols[row] && self.dim.symbols[row][col-1] && self.dim.symbols[row][col-1].x) { // column before
|
|
519
|
-
let mx = 0;
|
|
520
|
-
for (let i=row; i<self.dim.symbols.length; i++) {
|
|
521
|
-
if (self.dim.symbols[i][col-1] && mx < self.dim.symbols[i][col-1].x + self.dim.symbols[i][col-1].width) {
|
|
522
|
-
mx = self.dim.symbols[i][col-1].x + self.dim.symbols[i][col-1].width;
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
self.dim.symbols[row][col].x = mx;
|
|
526
|
-
} else if (self.dim.symbols[row-1] && self.dim.symbols[row-1][col-1] && self.dim.symbols[row-1][col-1].x) { // diagonal left above
|
|
527
|
-
self.dim.symbols[row][col].x = self.dim.symbols[row-1][col-1].x + self.dim.symbols[row-1][col-1].width;
|
|
528
|
-
} else if (self.dim.symbols.length > row + 1) { // same column below
|
|
529
|
-
let mx = 0;
|
|
530
|
-
for (let i=row; i<self.dim.symbols.length; i++) {
|
|
531
|
-
if (self.dim.symbols[i] && self.dim.symbols[i][col] && mx < self.dim.symbols[i][col].x) {
|
|
532
|
-
mx = self.dim.symbols[i][col].x;
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
self.dim.symbols[row][col].x = mx;
|
|
536
|
-
} else { // same column above
|
|
537
|
-
let mx = 0;
|
|
538
|
-
for (let i=row; i>0; i--) {
|
|
539
|
-
if (self.dim.symbols[i] && self.dim.symbols[i][col] && mx < self.dim.symbols[i][col].x) {
|
|
540
|
-
mx = self.dim.symbols[i][col].x;
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
self.dim.symbols[row][col].x = mx;
|
|
544
|
-
}
|
|
545
|
-
if (self.dim.symbols[row][col].width) {
|
|
546
|
-
if (twidth > self.dim.symbols[row][col].width) {
|
|
547
|
-
self.dim.symbols[row][col].width = twidth;
|
|
548
|
-
}
|
|
549
|
-
} else {
|
|
550
|
-
self.dim.symbols[row][col].width = twidth;
|
|
551
|
-
}
|
|
552
|
-
// console.log('set_x ',row,col,debug_dim());
|
|
553
|
-
} //}}}
|
|
554
|
-
var set_x_cond = this.dim.set_x_cond = function(row,col,tx,twidth,sname,label,subtype,sty,eid) { //{{{
|
|
555
|
-
if (self.lr) { // labels widen the row, not the column
|
|
556
|
-
set_row(row,col,[]);
|
|
557
|
-
self.dim.rows[row][col].size = Math.max(self.dim.rows[row][col].size || 0, twidth);
|
|
558
|
-
twidth = self.width;
|
|
559
|
-
}
|
|
560
|
-
if (!self.dim.symbols[row]) { self.dim.symbols[row] = []; }
|
|
561
|
-
if (!self.dim.symbols[row][col] || self.dim.symbols[row][col].width < twidth) {
|
|
562
|
-
self.dim.symbols[row][col] = {};
|
|
563
|
-
self.dim.symbols[row][col].x = tx;
|
|
564
|
-
self.dim.symbols[row][col].width = twidth;
|
|
565
|
-
}
|
|
566
|
-
self.dim.symbols[row][col].type = sname;
|
|
567
|
-
self.dim.symbols[row][col].label = label;
|
|
568
|
-
self.dim.symbols[row][col].subtype = subtype;
|
|
569
|
-
self.dim.symbols[row][col].eid = eid;
|
|
570
|
-
for (const s in sty) {
|
|
571
|
-
self.dim.symbols[row][col][s] = sty[s];
|
|
572
|
-
}
|
|
573
|
-
// console.log('set_x_cond',row,col,debug_dim());
|
|
574
|
-
} //}}}
|
|
575
|
-
|
|
576
|
-
var get_x = this.dim.get_x = function(row,col,deb='') { //{{{
|
|
577
|
-
if (row<0) { row = 0 };
|
|
578
|
-
|
|
579
|
-
let mlen = 0;
|
|
580
|
-
if (self.dim.symbols[row] && self.dim.symbols[row][col] && self.dim.symbols[row][col].x) { // this column
|
|
581
|
-
mlen = self.dim.symbols[row][col].x;
|
|
582
|
-
} else if (self.dim.symbols[row] && !self.dim.symbols[row][col] && self.dim.symbols.length > row && self.dim.symbols[row+1] && self.dim.symbols[row+1][col] && self.dim.symbols[row+1][col].x ) { // row after
|
|
583
|
-
mlen = self.dim.symbols[row+1][col].x;
|
|
584
|
-
} else if (self.dim.symbols[row-1] && self.dim.symbols[row-1][col] && self.dim.symbols[row-1][col].x) { // row before
|
|
585
|
-
mlen = self.dim.symbols[row-1][col].x;
|
|
586
|
-
} else if (self.dim.symbols[row] && self.dim.symbols[row][col-1] && self.dim.symbols[row][col-1].x) { // column before
|
|
587
|
-
for (let i=row; i<self.dim.symbols.length; i++) {
|
|
588
|
-
if (self.dim.symbols[i][col-1] && mlen < self.dim.symbols[i][col-1].x + self.dim.symbols[i][col-1].width) {
|
|
589
|
-
mlen = self.dim.symbols[i][col-1].x + self.dim.symbols[i][col-1].width;
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
} else if (self.dim.symbols[row+1] && self.dim.symbols[row+1][col] && self.dim.symbols[row+1][col].x) { // directly below
|
|
593
|
-
mlen = self.dim.symbols[row+1][col].x;
|
|
594
|
-
} else if (self.dim.symbols[row-1] && self.dim.symbols[row-1][col-1] && self.dim.symbols[row-1][col-1].x) { // diagonal left above
|
|
595
|
-
mlen = self.dim.symbols[row-1][col-1].x + self.dim.symbols[row-1][col-1].width;
|
|
596
|
-
} else { // same column below
|
|
597
|
-
for (let i=row; i<self.dim.symbols.length; i++) {
|
|
598
|
-
if (self.dim.symbols[i] && self.dim.symbols[i][col] && mlen < self.dim.symbols[i][col].x + self.dim.symbols[i][col].width) {
|
|
599
|
-
mlen = self.dim.symbols[i][col].x;
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
// found nothing in the rows below
|
|
603
|
-
if (mlen == 0) { // mostly for column 0
|
|
604
|
-
mlen = self.width;
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
// console.log(deb,row,col,'--> ' + mlen,debug_dim());
|
|
608
|
-
return mlen;
|
|
609
|
-
} //}}}
|
|
610
|
-
var get_x_plus = this.dim.get_x_plus = function(rowf,rowt,col,deb='') { //{{{
|
|
611
|
-
if (rowf<0) { rowf = 0 };
|
|
612
|
-
|
|
613
|
-
mlen = 0;
|
|
614
|
-
for (let i=rowf; i<=rowt; i++) {
|
|
615
|
-
if (self.dim.symbols[i] && self.dim.symbols[i][col] && mlen < self.dim.symbols[i][col].x + self.dim.symbols[i][col].width) {
|
|
616
|
-
mlen = self.dim.symbols[i][col].x + self.dim.symbols[i][col].width;
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
// console.log(deb,rowf,rowt,col,'--> ' + mlen,debug_dim());
|
|
620
|
-
return mlen;
|
|
621
|
-
} //}}}
|
|
622
|
-
var get_x_max = this.dim.get_x_max = function(rowf,rowt,colt,deb='') { //{{{
|
|
623
|
-
if (rowf<0) { rowf = 0 };
|
|
624
|
-
|
|
625
|
-
mlen = 0;
|
|
626
|
-
for (let i=rowf; i<=rowt; i++) {
|
|
627
|
-
for (let j=0; j<=colt; j++) {
|
|
628
|
-
if (self.dim.symbols[i] && self.dim.symbols[i][j] && mlen < self.dim.symbols[i][j].x + self.dim.symbols[i][j].width) {
|
|
629
|
-
mlen = self.dim.symbols[i][j].x + self.dim.symbols[i][j].width;
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
// console.log(deb,rowf,rowt,colt,'--> ' + mlen,debug_dim());
|
|
634
|
-
return mlen;
|
|
635
|
-
} //}}}
|
|
636
|
-
var get_x_width = this.dim.get_x_width = function(maxcol) { //{{{
|
|
637
|
-
let cwidth = 0;
|
|
638
|
-
for (let i=0; i < self.dim.symbols.length; i++) {
|
|
639
|
-
let lwidth = 0;
|
|
640
|
-
for (let j=0; j <= maxcol; j++) {
|
|
641
|
-
if (typeof self.dim.symbols[i] !== 'undefined' && typeof self.dim.symbols[i][j] !== 'undefined') {
|
|
642
|
-
lwidth += self.dim.symbols[i][j].width;
|
|
643
|
-
} else {
|
|
644
|
-
// go up the column and find the next valid value
|
|
645
|
-
let x = i;
|
|
646
|
-
let found = false;
|
|
647
|
-
while (x > 0 && !found) {
|
|
648
|
-
x -= 1;
|
|
649
|
-
if (typeof self.dim.symbols[x] !== 'undefined' && typeof self.dim.symbols[x][j] !== 'undefined') {
|
|
650
|
-
lwidth += self.dim.symbols[x][j].width;
|
|
651
|
-
found = true;
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
if (!found) {
|
|
655
|
-
lwidth[i] += self.width;
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
if (cwidth < lwidth) { cwidth = lwidth; }
|
|
660
|
-
}
|
|
661
|
-
return cwidth;
|
|
662
|
-
} //}}}
|
|
663
|
-
|
|
664
|
-
var get_y = this.draw.get_y = function(row) { // {{{
|
|
665
|
-
return { y: row * self.height - self.height, height_shift: self.height_shift};
|
|
666
|
-
} // }}}
|
|
667
|
-
var lr_shift = function() { // {{{
|
|
668
|
-
// mirroring swaps the left (width - width_shift) and top (height_shift) margins, so shift them back
|
|
669
|
-
return self.width - self.width_shift - self.height_shift;
|
|
670
|
-
} // }}}
|
|
671
|
-
var lr_matrix = function() { // {{{
|
|
672
|
-
return 'matrix(0,1,1,0,' + lr_shift() + ',' + (self.height_shift - lr_shift()) + ')'; // top margin is twice the height_shift
|
|
673
|
-
} // }}}
|
|
674
|
-
var set_row = this.dim.set_row = function(row,col,prev) { // {{{
|
|
675
|
-
// lr: a symbol starts where its predecessors end, so only things in the same block are aligned
|
|
676
|
-
if (!self.lr) { return; }
|
|
677
|
-
if (!self.dim.rows[row]) { self.dim.rows[row] = []; }
|
|
678
|
-
if (self.dim.rows[row][col]) { return; }
|
|
679
|
-
let mx = 0;
|
|
680
|
-
prev.forEach((p) => {
|
|
681
|
-
if (!p) { return; }
|
|
682
|
-
if (p.row == 0 || p.col == 0) { p = { row: 1, col: 1 }; } // first element connects to description
|
|
683
|
-
mx = Math.max(mx, get_row_end(p.row,p.col));
|
|
684
|
-
});
|
|
685
|
-
for (let i=1; i<row; i++) { // and after everything before in this and the following columns, e.g. blocks in vertical parallels share columns
|
|
686
|
-
for (let j=col; self.dim.rows[i] && j<self.dim.rows[i].length; j++) {
|
|
687
|
-
if (self.dim.rows[i][j]) { mx = Math.max(mx, get_row_end(i,j)); }
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
self.dim.rows[row][col] = { start: mx };
|
|
691
|
-
} // }}}
|
|
692
|
-
var get_row = this.dim.get_row = function(row,col) { // {{{
|
|
693
|
-
if (!self.lr) { return (row - 1) * self.height; }
|
|
694
|
-
for (let j=col; j>=0; j--) { // e.g. wide connections point to empty columns
|
|
695
|
-
if (self.dim.rows[row] && self.dim.rows[row][j]) { return self.dim.rows[row][j].start; }
|
|
696
|
-
}
|
|
697
|
-
return 0;
|
|
698
|
-
} // }}}
|
|
699
|
-
var get_row_end = this.dim.get_row_end = function(row,col) { // {{{
|
|
700
|
-
if (!self.lr) { return row * self.height; }
|
|
701
|
-
let size = self.dim.rows[row] && self.dim.rows[row][col] && self.dim.rows[row][col].size;
|
|
702
|
-
return get_row(row,col) + (size || self.height);
|
|
703
|
-
} // }}}
|
|
704
|
-
var get_row_max = this.dim.get_row_max = function(rowf,rowt,colf,colt) { // {{{
|
|
705
|
-
if (!self.lr) { return rowt * self.height; }
|
|
706
|
-
let mx = 0;
|
|
707
|
-
let last = false;
|
|
708
|
-
for (let i=rowf; i<=rowt; i++) {
|
|
709
|
-
for (let j=colf; j<=colt; j++) {
|
|
710
|
-
if (self.dim.rows[i] && self.dim.rows[i][j]) {
|
|
711
|
-
mx = Math.max(mx, get_row_end(i,j));
|
|
712
|
-
if (i == rowt) { last = true; }
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
return last ? mx : mx + self.height; // closing symbols are drawn after the border
|
|
717
|
-
} // }}}
|
|
718
|
-
|
|
719
|
-
var get_width = this.draw.get_width = function(g) { //{{{
|
|
720
|
-
let t = g.clone();
|
|
721
|
-
self.svg.container.append(t);
|
|
722
|
-
let bb = t[0].getBBox();
|
|
723
|
-
let w = bb.width - bb.x;
|
|
724
|
-
t.remove();
|
|
725
|
-
return w;
|
|
726
|
-
} //}}}
|
|
727
|
-
var get_label_end = this.draw.get_label_end = function(lab,frame) { //{{{
|
|
728
|
-
// where a label ends, in the coordinates of frame (one of its ancestors),
|
|
729
|
-
// including all transforms in between, so it does not matter if the label
|
|
730
|
-
// is beside the icon, below it, rotated or right aligned
|
|
731
|
-
let inner = lab.clone();
|
|
732
|
-
lab.parentsUntil(frame).each(function(_,p) {
|
|
733
|
-
let w = $X('<g xmlns="http://www.w3.org/2000/svg"></g>');
|
|
734
|
-
if ($(p).attr('transform')) { w.attr('transform',$(p).attr('transform')); }
|
|
735
|
-
inner = w.append(inner);
|
|
736
|
-
});
|
|
737
|
-
let g = $X('<g xmlns="http://www.w3.org/2000/svg"></g>').append(inner);
|
|
738
|
-
self.svg.container.append(g);
|
|
739
|
-
let bb = g[0].getBBox();
|
|
740
|
-
g.remove();
|
|
741
|
-
return Math.max(0, bb.x + bb.width);
|
|
742
|
-
} //}}}
|
|
743
|
-
var get_height = this.draw.get_height = function(g) { //{{{
|
|
744
|
-
let t = g.clone();
|
|
745
|
-
self.svg.container.append(t);
|
|
746
|
-
let bb = t[0].getBBox();
|
|
747
|
-
let h = bb.height - bb.y;
|
|
748
|
-
t.remove();
|
|
749
|
-
return h;
|
|
750
|
-
} //}}}
|
|
751
|
-
var get_dim = this.draw.get_dim = function(g) { //{{{
|
|
752
|
-
let element = g.clone();
|
|
753
|
-
self.svg.container.append(element);
|
|
754
|
-
let dim = get_box(element[0]);
|
|
755
|
-
element.remove();
|
|
756
|
-
return dim;
|
|
757
|
-
} //}}}
|
|
758
|
-
var get_box = this.draw.get_box = function(el) { //{{{
|
|
759
|
-
// the enclosing box of a drawn element, in the coordinates of its svg,
|
|
760
|
-
// including all transforms (e.g. its blocks and the lr mirroring)
|
|
761
|
-
let svg = el.ownerSVGElement;
|
|
762
|
-
|
|
763
|
-
var r = el.getBBox();
|
|
764
|
-
|
|
765
|
-
if (!svg) {
|
|
766
|
-
return { x: 0, y: 0, cx: 0, cy: 0, width: 0, height: 0 };
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
var p = svg.createSVGPoint();
|
|
770
|
-
|
|
771
|
-
var matrix = svg.getScreenCTM().inverse().multiply(el.getScreenCTM());
|
|
772
|
-
|
|
773
|
-
p.x = r.x;
|
|
774
|
-
p.y = r.y;
|
|
775
|
-
var a = p.matrixTransform(matrix);
|
|
776
|
-
|
|
777
|
-
p.x = r.x + r.width;
|
|
778
|
-
p.y = r.y;
|
|
779
|
-
var b = p.matrixTransform(matrix);
|
|
780
|
-
|
|
781
|
-
p.x = r.x + r.width;
|
|
782
|
-
p.y = r.y + r.height;
|
|
783
|
-
var c = p.matrixTransform(matrix);
|
|
784
|
-
|
|
785
|
-
p.x = r.x;
|
|
786
|
-
p.y = r.y + r.height;
|
|
787
|
-
var d = p.matrixTransform(matrix);
|
|
788
|
-
|
|
789
|
-
var minX = Math.min(a.x, b.x, c.x, d.x);
|
|
790
|
-
var maxX = Math.max(a.x, b.x, c.x, d.x);
|
|
791
|
-
var minY = Math.min(a.y, b.y, c.y, d.y);
|
|
792
|
-
var maxY = Math.max(a.y, b.y, c.y, d.y);
|
|
793
|
-
|
|
794
|
-
var width = maxX - minX;
|
|
795
|
-
var height = maxY - minY;
|
|
796
|
-
|
|
797
|
-
return {
|
|
798
|
-
x: minX,
|
|
799
|
-
y: minY,
|
|
800
|
-
width: width,
|
|
801
|
-
height: height,
|
|
802
|
-
cx: minX + width / 2,
|
|
803
|
-
cy: minY + height / 2
|
|
804
|
-
};
|
|
805
|
-
} //}}}
|
|
806
|
-
|
|
807
|
-
var bind_event = this.draw.bind_event = function(sym,tname,context) { //{{{
|
|
808
|
-
for(event_name in adaptor.elements[tname]) {
|
|
809
|
-
sym.bind(event_name, {'function_call':adaptor.elements[tname][event_name]}, function(e) { e.data.function_call($(this).attr('element-id'),e)});
|
|
810
|
-
if(event_name == 'mousedown') sym.bind('contextmenu', false);
|
|
811
|
-
}
|
|
812
|
-
} //}}}
|
|
813
|
-
|
|
814
|
-
var draw_stripe = this.draw.draw_stripe = function (row, maxcol) { // {{{
|
|
815
|
-
if (maxcol < 1) maxcol = 1;
|
|
816
|
-
|
|
817
|
-
let cwidth = get_x_width(maxcol);
|
|
818
|
-
cwidth = cwidth + 2 * self.width - self.width_shift;
|
|
819
|
-
|
|
820
|
-
var g = $X('<rect element-row="' + row + '" class="stripe ' + (row % 2 == 0 ? 'even' : 'odd') + '" x="0" y="' + String(row*self.height+self.height_shift/2) + '" width="' + cwidth + '" height="' + (self.height) + '" xmlns="http://www.w3.org/2000/svg"></rect>');
|
|
821
|
-
self.svg.container.prepend(g);
|
|
822
|
-
return g;
|
|
823
|
-
} // }}}
|
|
824
|
-
var draw_symbol = this.draw.draw_symbol = function(sname, id, title, parent_row, max_row, row, col, group, addition, info, style) { // {{{
|
|
825
|
-
if(self.elements[sname] == undefined || self.elements[sname].svg == undefined) sname = 'unknown';
|
|
826
|
-
let center_x = (self.width - self.default_width) / 2;
|
|
827
|
-
let center_y = (self.height - self.default_height) / 2;
|
|
828
|
-
|
|
829
|
-
let dstart = get_x(parent_row,col,'symbol ' + sname);
|
|
830
|
-
|
|
831
|
-
let sstart = dstart + center_x - self.width_shift;
|
|
832
|
-
let stop = get_row(row,col) + center_y + self.height_shift;
|
|
833
|
-
|
|
834
|
-
var g = $X('<g class="element" element-row="' + (row-1) + '" element-type="' + sname + '" element-id="' + id + '" xmlns="http://www.w3.org/2000/svg">' +
|
|
835
|
-
'<g transform="translate(' + String(sstart) + ',' + String(stop) + ')' + (self.lr ? ' matrix(0,1,1,0,0,0)' : '') + '"></g>' + // lr: mirror back, so that the symbol is upright
|
|
836
|
-
'</g>');
|
|
837
|
-
|
|
838
|
-
// add the element-endpoint and other stuff to each symbol (from theme info function)
|
|
839
|
-
for (const key in info) {
|
|
840
|
-
g.attr(key, info[key]);
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
var sym = self.svg.defs[sname].clone();
|
|
844
|
-
var subtype = undefined;
|
|
845
|
-
|
|
846
|
-
if (g.attr('element-endpoint')) {
|
|
847
|
-
let tsym = self.get_symbol(g.attr('element-endpoint'));
|
|
848
|
-
if (tsym) {
|
|
849
|
-
let found = false;
|
|
850
|
-
$('.part-end',sym).remove();
|
|
851
|
-
if ($('.part-end',tsym).length > 0) {
|
|
852
|
-
sym.prepend($('.part-end',tsym).clone());
|
|
853
|
-
found = true;
|
|
854
|
-
}
|
|
855
|
-
if ($('.part-middle',tsym).length > 0) {
|
|
856
|
-
$('.part-middle',sym).remove();
|
|
857
|
-
sym.prepend($('.part-middle',tsym).clone());
|
|
858
|
-
found = true;
|
|
859
|
-
}
|
|
860
|
-
if ($('.part-start',tsym).length > 0) {
|
|
861
|
-
$('.part-start',sym).remove();
|
|
862
|
-
sym.prepend($('.part-start',tsym).clone());
|
|
863
|
-
found = true;
|
|
864
|
-
}
|
|
865
|
-
if ($('.part-normal',tsym).length > 0) {
|
|
866
|
-
$('.part-normal',sym).remove();
|
|
867
|
-
sym.prepend($('.part-normal',tsym).clone());
|
|
868
|
-
found = true;
|
|
869
|
-
}
|
|
870
|
-
if (!found) {
|
|
871
|
-
$('.part-normal',sym).remove();
|
|
872
|
-
let ts = $X('<g class="part-normal" xmlns="http://www.w3.org/2000/svg"></g>');
|
|
873
|
-
ts.append($(tsym.documentElement.children).clone());
|
|
874
|
-
sym.prepend(ts);
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
let tprop = self.get_properties(g.attr('element-endpoint'));
|
|
878
|
-
if (tprop) {
|
|
879
|
-
subtype = tprop.subtype;
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
sym.attr('class','activities');
|
|
884
|
-
let sty = { ...self.global_style, ...style };
|
|
885
|
-
for (const s in sty) {
|
|
886
|
-
$('.colorstyle', sym).each((_,ele) => {
|
|
887
|
-
$(ele).css(s,sty[s]);
|
|
888
|
-
});
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
var tit = $X('<title xmlns="http://www.w3.org/2000/svg"></title>');
|
|
892
|
-
tit.text(title);
|
|
893
|
-
sym.prepend(tit);
|
|
894
|
-
let lab = $('.label',sym);
|
|
895
|
-
if (lab.length > 0 && self.compact) {
|
|
896
|
-
let l_maxlen = 40; // max label size
|
|
897
|
-
let l_split = 18; // desired split position
|
|
898
|
-
let l_dev = 10; // if one split line is bigger than l_split + l_dev, split was not successfull and we have to display a more truncated string
|
|
899
|
-
let l_trunc = 18; // trucation size
|
|
900
|
-
|
|
901
|
-
let sta = $('.part-start',sym);
|
|
902
|
-
let mid = $('.part-middle',sym);
|
|
903
|
-
let end = $('.part-end',sym);
|
|
904
|
-
let xtr = $('.part-extra',sym);
|
|
905
|
-
let nor = $('.part-normal',sym);
|
|
906
|
-
if (title && title != '') {
|
|
907
|
-
if (title.length < l_split) {
|
|
908
|
-
lab.text(title);
|
|
909
|
-
} else {
|
|
910
|
-
if (title.length > l_maxlen) { title = title.substr(0,l_maxlen) + '\u2026'; }
|
|
911
|
-
if (title.includes(' ')) {
|
|
912
|
-
let len = title.length;
|
|
913
|
-
let pos = -2;
|
|
914
|
-
let seps = []
|
|
915
|
-
while (pos != -1) {
|
|
916
|
-
pos = title.indexOf(' ',pos+1);
|
|
917
|
-
if (pos > -1) seps.push(pos);
|
|
918
|
-
}
|
|
919
|
-
let closest = title.length;
|
|
920
|
-
let it = 0;
|
|
921
|
-
seps.forEach((ele) => {
|
|
922
|
-
let min = Math.abs(title.length/2 - ele);
|
|
923
|
-
if (min < closest) { closest = min; it = ele; }
|
|
924
|
-
});
|
|
925
|
-
let l1 = title.substr(0,it);
|
|
926
|
-
let l2 = title.substr(it+1);
|
|
927
|
-
if (l1.length > l_split+l_dev) {
|
|
928
|
-
title = title.substr(0,l_trunc) + '\u2026';
|
|
929
|
-
lab.text(title);
|
|
930
|
-
} else {
|
|
931
|
-
if (l2.length > l_split) { l2 = l2.substr(0,l_trunc) + '\u2026'; }
|
|
932
|
-
let a1 = $X('<tspan x="0" dy="-8" xmlns="http://www.w3.org/2000/svg"></tspan>');
|
|
933
|
-
a1.text(l1);
|
|
934
|
-
let a2 = $X('<tspan x="0" dy="12" xmlns="http://www.w3.org/2000/svg"></tspan>');
|
|
935
|
-
a2.text(l2);
|
|
936
|
-
lab.append(a1);
|
|
937
|
-
lab.append(a2);
|
|
938
|
-
}
|
|
939
|
-
} else {
|
|
940
|
-
if (title.length > l_split) { title = title.substr(0,l_trunc) + '\u2026'; }
|
|
941
|
-
lab.text(title);
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
|
-
if (self.elements[sname].hidelabel) { lab.addClass('invisible'); } // still takes its space
|
|
945
|
-
if (mid.length > 0) {
|
|
946
|
-
if (end.length > 0) {
|
|
947
|
-
let width = this.get_label_end(lab,mid); // the clip path is inside part-middle
|
|
948
|
-
let pos = get_dim(mid);
|
|
949
|
-
mid.attr('clip-path','url(#ele-' + id + ')');
|
|
950
|
-
let clip = $X('<clipPath belongs-to="element" id="ele-' + id + '" xmlns="http://www.w3.org/2000/svg">' +
|
|
951
|
-
'<rect x="0" y="-1" width="' + width + '" height="' + (pos.y + pos.height + 4) + '"></rect>' +
|
|
952
|
-
'</clipPath>');
|
|
953
|
-
$('defs',self.svg.container).append(clip);
|
|
954
|
-
|
|
955
|
-
end.attr('transform','translate(' + (pos.x + width - self.endclipshift - 4) + ',0)');
|
|
956
|
-
if (xtr.length > 0) {
|
|
957
|
-
xtr.attr('transform','translate(' + (pos.x + width - self.endclipshift - 4) + ',0)');
|
|
958
|
-
}
|
|
959
|
-
set_x_cond(row,col,dstart,pos.x + width - self.endclipshift - 4 + this.get_width(end) + 2 * self.width_shift_label,sname,title,subtype,sty,id);
|
|
960
|
-
} else {
|
|
961
|
-
let tdim = 0;
|
|
962
|
-
if (self.rotated_labels && self.elements[sname].rotatelabels != false) {
|
|
963
|
-
lab.addClass('rotate');
|
|
964
|
-
tdim = self.width;
|
|
965
|
-
} else {
|
|
966
|
-
tdim = Math.max(self.width, this.get_label_end(lab,sym) + self.width_shift_label);
|
|
967
|
-
}
|
|
968
|
-
set_x_cond(row,col,dstart,tdim,sname,title,subtype,sty,id);
|
|
969
|
-
}
|
|
970
|
-
} else {
|
|
971
|
-
set_x_cond(row,col,dstart,self.width,sname,title,subtype,sty,id);
|
|
972
|
-
}
|
|
973
|
-
if (nor.length > 0) { nor.remove(); }
|
|
974
|
-
} else {
|
|
975
|
-
set_x_cond(row,col,dstart,self.width,sname,title,subtype,sty,id);
|
|
976
|
-
if (sta.length > 0) { sta.remove(); }
|
|
977
|
-
if (mid.length > 0) { mid.remove(); }
|
|
978
|
-
if (end.length > 0) { end.remove(); }
|
|
979
|
-
}
|
|
980
|
-
} else {
|
|
981
|
-
$('.part-start',sym).remove();
|
|
982
|
-
$('.part-middle',sym).remove();
|
|
983
|
-
$('.part-end',sym).remove();
|
|
984
|
-
set_x_cond(row,col,dstart,self.width,sname,title,subtype,sty,id);
|
|
985
|
-
}
|
|
986
|
-
if (self.elements[sname].implied) { self.dim.implied.push($.extend({row: row, col: col}, self.elements[sname].implied)); }
|
|
987
|
-
if (self.elements[sname].hidelabel) { // only takes its space, it is not shown
|
|
988
|
-
self.dim.symbols[row][col].label = undefined;
|
|
989
|
-
} else if (lab.length > 0 && lab.text() != '' && $.contains(sym[0],lab[0])) {
|
|
990
|
-
self.dim.labels[row + ',' + col] = lab[0];
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
$(g[0].childNodes[0]).append(sym);
|
|
995
|
-
if (!addition) {
|
|
996
|
-
// TODO change to better respresent exec
|
|
997
|
-
$(g[0].childNodes[0]).append(
|
|
998
|
-
$X('<text class="super" transform="translate(20,-2)" xmlns="http://www.w3.org/2000/svg">' +
|
|
999
|
-
'<tspan class="exec">▶</tspan>' +
|
|
1000
|
-
'<tspan class="active">0</tspan>' +
|
|
1001
|
-
'<tspan class="colon">,</tspan>' +
|
|
1002
|
-
'<tspan class="vote">0</tspan>' +
|
|
1003
|
-
'</text>')
|
|
1004
|
-
);
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
// hover, top left of the symbol, or top right if the theme says so (e.g. because of a label on the left)
|
|
1008
|
-
$(g[0].childNodes[0]).append(
|
|
1009
|
-
$X(
|
|
1010
|
-
'<g class="hoverstyle markstyle"' + (self.elements[sname].mark_position == 'right' ? ' transform="translate(27,0)"' : '') + ' xmlns="http://www.w3.org/2000/svg">' +
|
|
1011
|
-
'<circle cx="2" cy="0" r="7"/>' +
|
|
1012
|
-
'<path d="m -1 0 l 2 2 l 4 -4" class="standline"/>' +
|
|
1013
|
-
'</g>'
|
|
1014
|
-
)
|
|
1015
|
-
);
|
|
1016
|
-
|
|
1017
|
-
// Binding events for symbol
|
|
1018
|
-
bind_event(g,sname,true);
|
|
1019
|
-
|
|
1020
|
-
if (group) {group.append(g);}
|
|
1021
|
-
else {self.svg.container.children('g:first').append(g);}
|
|
1022
|
-
|
|
1023
|
-
return g;
|
|
1024
|
-
} // }}}
|
|
1025
|
-
var draw_border = this.draw.draw_border = function(id, p1, p2, group, yshrink) { // {{{
|
|
1026
|
-
yshrink = yshrink || 0;
|
|
1027
|
-
let bstart = get_x(p1.row,p1.col,'border from');
|
|
1028
|
-
let bend = get_x_plus(p1.row,p2.row,p2.col,'border to');
|
|
1029
|
-
group.prepend($X('<rect element-id="' + id + '" x="' + (bstart - 1.1 * self.width_shift - self.group_extend) + '" ' +
|
|
1030
|
-
'y="' + (get_row(p1.row,p1.col)+self.height_shift/2-self.group_extend+yshrink) + '" ' +
|
|
1031
|
-
'width="' + (bend-bstart+2*self.group_extend) + '" ' +
|
|
1032
|
-
'height="' + (get_row_max(p1.row,p2.row,p1.col,p2.col)-get_row(p1.row,p1.col)+2*self.group_extend-2*yshrink) + '" ' +
|
|
1033
|
-
'class="block" rx="12" ry="12" xmlns="http://www.w3.org/2000/svg"/>'));
|
|
1034
|
-
} // }}}
|
|
1035
|
-
var draw_tile = this.draw.draw_tile = function(id, p1, p2, group, yshrink=0) { // {{{
|
|
1036
|
-
let bstart = get_x(p1.row,p1.col,'tile from');
|
|
1037
|
-
let bend = get_x_plus(p1.row,p2.row,p2.col,'tile to');
|
|
1038
|
-
group.prepend($X('<rect element-id="' + id + '" x="' + (bstart - 1.1 * self.width_shift - self.group_extend) + '" ' +
|
|
1039
|
-
'y="' + (get_row(p1.row,p1.col)+self.height_shift/2-self.group_extend+yshrink) + '" ' +
|
|
1040
|
-
'width="' + (bend-bstart+2*self.group_extend) + '" ' +
|
|
1041
|
-
'height="' + (get_row_max(p1.row,p2.row,p1.col,p2.col)-get_row(p1.row,p1.col)+2*self.group_extend-2*yshrink) + '" ' +
|
|
1042
|
-
'class="tile" rx="12" ry="12" xmlns="http://www.w3.org/2000/svg"/>'));
|
|
1043
|
-
} // }}}
|
|
1044
|
-
var draw_connection = this.draw.draw_connection = function(group, start, end, context_row, arrow, around=false) { // {{{
|
|
1045
|
-
let sr = Math.min(start.row,end.row);
|
|
1046
|
-
let cstart = get_x(sr,start.col,'conn from');
|
|
1047
|
-
let cend = get_x(sr,end.col,'conn to');
|
|
1048
|
-
let from = {row: start.row, col: start.col}, to = {row: end.row, col: end.col};
|
|
1049
|
-
self.dim.connections.push(self.inverted ? {from: to, to: from} : {from: from, to: to}); // inverted: the arrow points to the start
|
|
1050
|
-
|
|
1051
|
-
if(((end['row']-start['row']) == 0) && ((end['col']-start['col']) == 0)) return;
|
|
1052
|
-
var line = $X('<path xmlns="http://www.w3.org/2000/svg" class="edge"/>');
|
|
1053
|
-
let diag = false; // the arrow sits on a diagonal segment (into a gateway), so it has to be closer to the center
|
|
1054
|
-
let sy = get_row(start['row'],start['col']) + self.height - self.conn_center + start.yoffset; // center of the symbols
|
|
1055
|
-
let ssym = self.dim.symbols[start['row']] && self.dim.symbols[start['row']][start['col']];
|
|
1056
|
-
if (self.lr && self.inverted && ssym && self.elements[ssym.type] && self.elements[ssym.type].svg && $('.part-end',self.elements[ssym.type].svg).length > 0) { // inverted: the arrow points into the start from its end, not under the task template (tasks are the symbols with a part-end)
|
|
1057
|
-
sy = get_row_end(start['row'],start['col']) - self.conn_center + start.yoffset; // as far in from the end as other arrows are from the start
|
|
1058
|
-
}
|
|
1059
|
-
let ey = get_row(end['row'],end['col']) + self.height - self.conn_center + end.yoffset;
|
|
1060
|
-
if (around) { // e.g. back in an empty loop: leave at 45 degrees to the right, go straight, enter at 45 degrees
|
|
1061
|
-
diag = true;
|
|
1062
|
-
let off = 7.5 + 7; // from the center to the corner of the gateway, then 7 further
|
|
1063
|
-
line.attr("d", "M " + String(cstart) + "," + String(sy) +" "+
|
|
1064
|
-
String(cstart+off) + "," + String(sy-off) +" "+
|
|
1065
|
-
String(cend+off) + "," + String(ey+off) +" "+
|
|
1066
|
-
String(cend) + "," + String(ey)
|
|
1067
|
-
);
|
|
1068
|
-
} else if (end['row']-start['row'] == 0 || end['col']-start['col'] == 0) { // straight line
|
|
1069
|
-
line.attr("d", "M " + String(cstart) + "," + String(sy) +" "+
|
|
1070
|
-
String(cend) + "," + String(ey)
|
|
1071
|
-
);
|
|
1072
|
-
} else if (end['row']-start['row'] > 0) { // downwards
|
|
1073
|
-
if (end['col']-start['col'] > 0) {// left - right
|
|
1074
|
-
if (self.compact) {
|
|
1075
|
-
diag = self.inverted;
|
|
1076
|
-
line.attr("d", "M " + String(cstart) + "," + String(sy) +" "+
|
|
1077
|
-
String(cstart+14) + "," + String(get_row_end(start['row'],start['col'])) +" "+ // first turn of horizontal-line going away from node
|
|
1078
|
-
String(cend) + "," + String(get_row_end(start['row'],start['col'])) +" "+
|
|
1079
|
-
String(cend) + "," + String(ey)
|
|
1080
|
-
);
|
|
1081
|
-
} else {
|
|
1082
|
-
line.attr("d", "M " + String(cstart) + "," + String(sy) +" "+
|
|
1083
|
-
String(cend) + "," + String(sy) +" "+
|
|
1084
|
-
String(cend) + "," + String(ey)
|
|
1085
|
-
);
|
|
1086
|
-
}
|
|
1087
|
-
} else { // right - left
|
|
1088
|
-
diag = !self.inverted;
|
|
1089
|
-
line.attr("d", "M " + String(cstart) + "," + String(sy) +" "+
|
|
1090
|
-
String(cstart) + "," + String(get_row(end['row'],end['col'])+self.height-32) +" "+
|
|
1091
|
-
String(cend+14) + "," + String(get_row(end['row'],end['col'])+self.height-32) +" "+ // last turn of horizontal-line going into the node
|
|
1092
|
-
String(cend) + "," + String(ey)
|
|
1093
|
-
);
|
|
1094
|
-
}
|
|
1095
|
-
} else if(end['row']-start['row'] < 0) { // upwards
|
|
1096
|
-
diag = !self.inverted;
|
|
1097
|
-
let by = (self.lr ? get_row_end(start['row'],start['col']) : (self.dim.symbols.length-1)*self.height) + 4;
|
|
1098
|
-
line.attr("d", "M " + String(cstart) + "," + String(sy) +" "+
|
|
1099
|
-
String(cstart) + "," + String(by) +" "+
|
|
1100
|
-
String(cend+15) + "," + String(by) +" "+
|
|
1101
|
-
String(cend+15) + "," + String(get_row(end['row'],end['col'])+self.height+15)+" "+
|
|
1102
|
-
String(cend) + "," + String(ey)
|
|
1103
|
-
);
|
|
1104
|
-
}
|
|
1105
|
-
if (arrow) { line.attr(self.inverted ? 'marker-start' : 'marker-end', 'url(#' + (end.structural ? 'endarrow' : (diag ? 'arrowdiag' : 'arrow')) + (self.inverted ? 'rev' : '') + ')'); } // inverted: arrow points to the start
|
|
1106
|
-
if (self.lr) { line.attr('transform',lr_matrix()); } // connections are not part of the graph group
|
|
1107
|
-
self.svg.container.append(line);
|
|
1108
|
-
} // }}}
|
|
1109
|
-
// }}}
|
|
1110
|
-
|
|
1111
|
-
// Initialize {{{
|
|
1112
|
-
adaptor = wf_adaptor;
|
|
1113
|
-
// }}}
|
|
1114
|
-
|
|
1115
|
-
} // }}}
|
|
1116
|
-
|
|
1117
|
-
// WfDescription:
|
|
1118
|
-
// Manages the description. Is is further able to add/remove elements from the controlflow description.
|
|
1119
|
-
function WfDescription(wf_adaptor, wf_illustrator) { // Model {{{
|
|
1120
|
-
// public variables
|
|
1121
|
-
this.elements = {}; // the rngs
|
|
1122
|
-
this.source = null;
|
|
1123
|
-
// private variables
|
|
1124
|
-
var self = this;
|
|
1125
|
-
var adaptor;
|
|
1126
|
-
var illustrator;
|
|
1127
|
-
var used_id_list = [];
|
|
1128
|
-
var description;
|
|
1129
|
-
var orig_description;
|
|
1130
|
-
var id_counter = {};
|
|
1131
|
-
var update_illustrator = true;
|
|
1132
|
-
var labels = [];
|
|
1133
|
-
|
|
1134
|
-
// Set Labels //{{{
|
|
1135
|
-
this.set_labels = function(graph) {
|
|
1136
|
-
if (illustrator.striped == true && illustrator.compact == false) {
|
|
1137
|
-
for (var i=0; i < graph.max.row; i++) {
|
|
1138
|
-
illustrator.draw.draw_stripe(i,graph.max.col);
|
|
1139
|
-
}
|
|
1140
|
-
}
|
|
1141
|
-
adaptor.draw_labels(graph.max,labels,{ 'height': illustrator.height, 'stripe_height': illustrator.default_height, 'height_shift': illustrator.height_shift },illustrator.striped == true ? true : false);
|
|
1142
|
-
} //}}}
|
|
1143
|
-
|
|
1144
|
-
// Generic Functions {{{
|
|
1145
|
-
this.set_description = function(desc, auto_update) { // public {{{
|
|
1146
|
-
if(auto_update != undefined) update_illustrator = auto_update;
|
|
1147
|
-
if(typeof desc == "string") {
|
|
1148
|
-
description = $($.parseXML(desc));
|
|
1149
|
-
} else if(desc instanceof jQuery) {
|
|
1150
|
-
description = desc;
|
|
1151
|
-
} else {
|
|
1152
|
-
alert("WfDescription: unknown description type:\nConstructor-Name: " + desc.constructor + " / TypeOf: " + (typeof desc));
|
|
1153
|
-
description = null;
|
|
1154
|
-
}
|
|
1155
|
-
orig_description = $($X(description.serializeXML()).get(0).ownerDocument);
|
|
1156
|
-
id_counter = {};
|
|
1157
|
-
labels = [];
|
|
1158
|
-
let start = performance.now();
|
|
1159
|
-
illustrator.clear();
|
|
1160
|
-
var graph = parse(description.children('description').get(0), {'row':0,'col':0,final:false,wide:false,yoffset:0});
|
|
1161
|
-
illustrator.set_svg(graph);
|
|
1162
|
-
self.set_labels(graph);
|
|
1163
|
-
illustrator.set_duration(start);
|
|
1164
|
-
} // }}}
|
|
1165
|
-
var gd = this.get_description = function() { // public {{{
|
|
1166
|
-
var serxml = $(description.get(0).documentElement).clone(true);
|
|
1167
|
-
serxml.attr('dir', illustrator.lr ? 'lr' : 'td'); // layout direction of the theme, e.g. for the bpmn export
|
|
1168
|
-
serxml.removeAttr('svg-id');
|
|
1169
|
-
serxml.removeAttr('svg-type');
|
|
1170
|
-
serxml.removeAttr('svg-subtype');
|
|
1171
|
-
serxml.removeAttr('svg-label');
|
|
1172
|
-
$('*[svg-id]',serxml).each(function(){
|
|
1173
|
-
$(this).removeAttr('svg-id');
|
|
1174
|
-
});
|
|
1175
|
-
$('*[svg-type]',serxml).each(function(){
|
|
1176
|
-
$(this).removeAttr('svg-type');
|
|
1177
|
-
});
|
|
1178
|
-
$('*[svg-subtype]',serxml).each(function(){
|
|
1179
|
-
$(this).removeAttr('svg-subtype');
|
|
1180
|
-
});
|
|
1181
|
-
$('*[svg-label]',serxml).each(function(){
|
|
1182
|
-
$(this).removeAttr('svg-label');
|
|
1183
|
-
});
|
|
1184
|
-
return serxml.serializeXML();
|
|
1185
|
-
} // }}}
|
|
1186
|
-
this.get_node_by_svg_id = function(svg_id) { // {{{
|
|
1187
|
-
return $('[svg-id = \'' + svg_id + '\']', description);
|
|
1188
|
-
} // }}}
|
|
1189
|
-
var context_eval = this.context_eval = function(what) { // {{{
|
|
1190
|
-
return eval(what);
|
|
1191
|
-
} // }}}
|
|
1192
|
-
|
|
1193
|
-
var reset_used_id_list = this.reset_used_id_list = function() { // {{{
|
|
1194
|
-
used_id_list = [];
|
|
1195
|
-
} // }}}
|
|
1196
|
-
var get_free_id = this.get_free_id = function(prefix,aname,other) { // {{{
|
|
1197
|
-
var existing = new Array();
|
|
1198
|
-
if (other) {
|
|
1199
|
-
if ($(other).attr(aname)) {
|
|
1200
|
-
existing.push($(other).attr(aname));
|
|
1201
|
-
}
|
|
1202
|
-
$(other).find("[" + aname + "]").each(function(k,v){
|
|
1203
|
-
existing.push($(v).attr(aname));
|
|
1204
|
-
});
|
|
1205
|
-
}
|
|
1206
|
-
$('*[' + aname + ']', description).each(function(){existing.push($(this).attr(aname))});
|
|
1207
|
-
var id = 1;
|
|
1208
|
-
while ($.inArray(prefix + id,existing) != -1) {
|
|
1209
|
-
id += 1;
|
|
1210
|
-
}
|
|
1211
|
-
while ($.inArray(prefix + id,used_id_list) != -1) {
|
|
1212
|
-
id += 1;
|
|
1213
|
-
}
|
|
1214
|
-
used_id_list.push(prefix + id);
|
|
1215
|
-
return prefix + id;
|
|
1216
|
-
} // }}}
|
|
1217
|
-
var redraw = this.redraw = function(doit) {
|
|
1218
|
-
id_counter = {};
|
|
1219
|
-
let start = performance.now();
|
|
1220
|
-
labels = [];
|
|
1221
|
-
illustrator.clear();
|
|
1222
|
-
clean_description();
|
|
1223
|
-
var graph = parse(description.children('description').get(0), {'row':0,'col':0,final:false,wide:false,yoffset:0});
|
|
1224
|
-
illustrator.set_svg(graph);
|
|
1225
|
-
self.set_labels(graph);
|
|
1226
|
-
illustrator.set_duration(start);
|
|
1227
|
-
if (doit) doit(self);
|
|
1228
|
-
}
|
|
1229
|
-
var update = this.update = function(svgid) { // {{{
|
|
1230
|
-
id_counter = {};
|
|
1231
|
-
var notify_target = () => {
|
|
1232
|
-
var newn = $('*[new=true]',description);
|
|
1233
|
-
newn.removeAttr('new');
|
|
1234
|
-
|
|
1235
|
-
if (newn.attr('svg-id') != undefined)
|
|
1236
|
-
adaptor.notify(newn.attr('svg-id'));
|
|
1237
|
-
else if (svgid != undefined)
|
|
1238
|
-
adaptor.notify(svgid);
|
|
1239
|
-
else if (newn.parents('[svg-id]').length > 0)
|
|
1240
|
-
adaptor.notify(newn.parent('[svg-id]').attr('svg-id'));
|
|
1241
|
-
else
|
|
1242
|
-
console.info('Something went horribly wrong');
|
|
1243
|
-
};
|
|
1244
|
-
if (update_illustrator) {
|
|
1245
|
-
self.redraw(notify_target);
|
|
1246
|
-
} else {
|
|
1247
|
-
notify_target();
|
|
1248
|
-
}
|
|
1249
|
-
} // }}}
|
|
1250
|
-
// }}}
|
|
1251
|
-
// Adaption functions {{{
|
|
1252
|
-
this.insert_after = function(new_node, target, source_opts) { // {{{
|
|
1253
|
-
reset_used_id_list();
|
|
1254
|
-
if ($.isArray(new_node)) {
|
|
1255
|
-
$.each(new_node,function(k,v){
|
|
1256
|
-
var nn = self.source(v,source_opts);
|
|
1257
|
-
target.after(nn);
|
|
1258
|
-
nn.attr('new','true');
|
|
1259
|
-
});
|
|
1260
|
-
} else {
|
|
1261
|
-
var nn = self.source(new_node,source_opts);
|
|
1262
|
-
target.after(nn);
|
|
1263
|
-
nn.attr('new','true');
|
|
1264
|
-
}
|
|
1265
|
-
update();
|
|
1266
|
-
} // }}}
|
|
1267
|
-
this.insert_first_into = function(new_node, target, source_opts) { // {{{
|
|
1268
|
-
reset_used_id_list();
|
|
1269
|
-
if ($.isArray(new_node)) {
|
|
1270
|
-
$.each(new_node,function(k,v){
|
|
1271
|
-
var nn = self.source(v,source_opts);
|
|
1272
|
-
target.prepend(nn);
|
|
1273
|
-
nn.attr('new','true');
|
|
1274
|
-
});
|
|
1275
|
-
} else {
|
|
1276
|
-
var nn = self.source(new_node,source_opts);
|
|
1277
|
-
target.prepend(nn);
|
|
1278
|
-
nn.attr('new','true');
|
|
1279
|
-
}
|
|
1280
|
-
update();
|
|
1281
|
-
} // }}}
|
|
1282
|
-
this.insert_last_into = function(new_node, target) { // {{{
|
|
1283
|
-
reset_used_id_list();
|
|
1284
|
-
if ($.isArray(new_node)) {
|
|
1285
|
-
$.each(new_node,function(k,v){
|
|
1286
|
-
var nn = self.source(v);
|
|
1287
|
-
target.append(nn);
|
|
1288
|
-
nn.attr('new','true');
|
|
1289
|
-
});
|
|
1290
|
-
} else {
|
|
1291
|
-
var nn = self.source(new_node);
|
|
1292
|
-
target.append(nn);
|
|
1293
|
-
nn.attr('new','true');
|
|
1294
|
-
}
|
|
1295
|
-
update();
|
|
1296
|
-
} // }}}
|
|
1297
|
-
this.remove = function(selector, target) {//{{{
|
|
1298
|
-
var svgid;
|
|
1299
|
-
if(selector == undefined) {
|
|
1300
|
-
svgid = target.attr('svg-id');
|
|
1301
|
-
target.remove()
|
|
1302
|
-
} else {
|
|
1303
|
-
svgid = $(selector, target).attr('svg-id');
|
|
1304
|
-
if (!svgid) {
|
|
1305
|
-
svgid = target.attr('svg-id');
|
|
1306
|
-
}
|
|
1307
|
-
$(selector, target).remove();
|
|
1308
|
-
}
|
|
1309
|
-
update(svgid);
|
|
1310
|
-
}
|
|
1311
|
-
// }}}
|
|
1312
|
-
// }}}
|
|
1313
|
-
// Helper Functions {{{
|
|
1314
|
-
var clean_description = function() { // private {{{
|
|
1315
|
-
$('*[svg-id]',description).each(function(){
|
|
1316
|
-
$(this).removeAttr('svg-id');
|
|
1317
|
-
});
|
|
1318
|
-
$('*[svg-type]',description).each(function(){
|
|
1319
|
-
$(this).removeAttr('svg-type');
|
|
1320
|
-
});
|
|
1321
|
-
$('*[svg-subtype]',description).each(function(){
|
|
1322
|
-
$(this).removeAttr('svg-subtype');
|
|
1323
|
-
});
|
|
1324
|
-
$('*[svg-label]',description).each(function(){
|
|
1325
|
-
$(this).removeAttr('svg-label');
|
|
1326
|
-
});
|
|
1327
|
-
} //}}}
|
|
1328
|
-
var reversed_loop = function(node) { // private {{{
|
|
1329
|
-
return illustrator.wellformed_pre_test && node.tagName == 'loop' && $(node).attr('mode') == 'pre_test';
|
|
1330
|
-
} // }}}
|
|
1331
|
-
var parse = function(root, parent_pos, first_prev) { // private {{{
|
|
1332
|
-
var pos = JSON.parse(JSON.stringify(parent_pos));
|
|
1333
|
-
var max = {'row': 0,'col': 0};
|
|
1334
|
-
var prev = [first_prev || parent_pos]; // connects parent with child(s), depending on the expansion
|
|
1335
|
-
var endnodes = [];
|
|
1336
|
-
var markers = []; // wellformed_pre_test: branch markers, drawn in one row below all branches
|
|
1337
|
-
var sname = sym_name(root.tagName,root);
|
|
1338
|
-
var root_expansion = illustrator.elements[root.tagName].expansion(root);
|
|
1339
|
-
var block = { 'max': {'row': pos.row, 'col': pos.col}, 'endnodes': [], 'svg': $X('<g class="group" xmlns="http://www.w3.org/2000/svg"/>') };
|
|
1340
|
-
|
|
1341
|
-
if(root_expansion == 'horizontal') pos.row++;
|
|
1342
|
-
if(illustrator.elements[root.tagName].col_shift(root) == true && root_expansion != 'horizontal') pos.col++;
|
|
1343
|
-
|
|
1344
|
-
if(root.tagName == 'description') { // First parsing {{{
|
|
1345
|
-
pos.row++;
|
|
1346
|
-
$(root).attr('svg-id','description');
|
|
1347
|
-
$(root).attr('svg-type','description');
|
|
1348
|
-
$(root).attr('svg-subtype','description');
|
|
1349
|
-
block.svg.attr('element-id','group-description');
|
|
1350
|
-
if (illustrator.elements[sname].label) {
|
|
1351
|
-
// javascript object spread syntax is my new weird crush - the JS designers must be serious people
|
|
1352
|
-
labels.push({...{row: pos.row, element_id: 'start', tname: 'start', label: illustrator.elements[sname].label(root)},...illustrator.draw.get_y(pos.row)});
|
|
1353
|
-
}
|
|
1354
|
-
illustrator.global_style = (illustrator.elements[sname].style && root) ? illustrator.elements[sname].style(root) : {};
|
|
1355
|
-
illustrator.draw.draw_symbol(sname, 'description', '', pos.row, pos.row, pos.row, pos.col, block.svg, false, {}, {})
|
|
1356
|
-
} // }}}
|
|
1357
|
-
|
|
1358
|
-
var children = $(root).children().filter(function(){ return this.localName[0] != '_'; });
|
|
1359
|
-
if (illustrator.inverted && root_expansion != 'horizontal') { children = $(children.get().reverse()); } // wellformed_pre_test: everything inside is drawn in reverse order, but not the branches
|
|
1360
|
-
children.each(function() {
|
|
1361
|
-
var context = this;
|
|
1362
|
-
var tname = context.tagName;
|
|
1363
|
-
var sname = sym_name(tname,context);
|
|
1364
|
-
pos.final = illustrator.elements[sname].final ? true : false;
|
|
1365
|
-
pos.wide = illustrator.elements[sname].wide ? true : false;
|
|
1366
|
-
pos.noindent = illustrator.elements[sname].noindent ? true : false;
|
|
1367
|
-
|
|
1368
|
-
// Calculate next position {{{
|
|
1369
|
-
if(root_expansion == 'vertical') { pos.row++; }
|
|
1370
|
-
if(root_expansion == 'horizontal') {
|
|
1371
|
-
// for noindent themes do not indent the first column
|
|
1372
|
-
if (!pos.noindent || (pos.noindent && endnodes.length > 1)) {
|
|
1373
|
-
illustrator.dim.set_x(pos.row,pos.col,illustrator.width);
|
|
1374
|
-
pos.col++;
|
|
1375
|
-
}
|
|
1376
|
-
if (!illustrator.compact) {
|
|
1377
|
-
if (block.max.row) {
|
|
1378
|
-
illustrator.dim.set_x(pos.row,pos.col,illustrator.width);
|
|
1379
|
-
pos.row = block.max.row + 1;
|
|
1380
|
-
}
|
|
1381
|
-
}
|
|
1382
|
-
}
|
|
1383
|
-
|
|
1384
|
-
var bottom = false;
|
|
1385
|
-
if(illustrator.elements[tname] != undefined && illustrator.elements[tname].type == 'complex') {
|
|
1386
|
-
bottom = illustrator.inverted && root_expansion == 'horizontal'; // wellformed_pre_test: branch markers are drawn below their content
|
|
1387
|
-
if(illustrator.elements[tname] != undefined && !illustrator.elements[tname].svg) pos.row--;
|
|
1388
|
-
// TODO: Remaining problem is the order inside the svg. Thats why the connection is above the icon
|
|
1389
|
-
|
|
1390
|
-
illustrator.dim.set_x(pos.row,pos.col,illustrator.width);
|
|
1391
|
-
illustrator.dim.set_row(pos.row,pos.col,prev);
|
|
1392
|
-
if ((bottom ? !illustrator.lr : (illustrator.lr && illustrator.elements[tname].expansion(context) == 'vertical' && !illustrator.elements[tname].col_shift(context))) && illustrator.elements[sname].svg) { // lr: the content follows the label in the same column, bottom: the marker is drawn after the next branches, so measure the symbol before it is drawn
|
|
1393
|
-
let lab = (illustrator.elements[sname].label ? illustrator.elements[sname].label(context) : []) || [];
|
|
1394
|
-
let tit = lab.find((l) => l && l.column == 'Label' && l.value);
|
|
1395
|
-
illustrator.draw.draw_symbol(sname, 'measure', tit ? tit.value : undefined, pos.row, pos.row, pos.row, pos.col, $X('<g xmlns="http://www.w3.org/2000/svg"/>'), true, {}, {});
|
|
1396
|
-
}
|
|
1397
|
-
// but fuuuuu, we calculate the gateways only later, so we couldnt even have them bigger for now
|
|
1398
|
-
|
|
1399
|
-
// console.log('----> down', tname, parent_pos.row, pos.row, parent_pos.col, pos.col, illustrator.dim.debug());
|
|
1400
|
-
|
|
1401
|
-
if (reversed_loop(context)) { illustrator.inverted = !illustrator.inverted; }
|
|
1402
|
-
let tblock;
|
|
1403
|
-
if (bottom) { // content starts in the row of the marker and connects to the gateway
|
|
1404
|
-
let up = JSON.parse(JSON.stringify(pos));
|
|
1405
|
-
up.row--;
|
|
1406
|
-
tblock = parse(context, up, prev[0]);
|
|
1407
|
-
} else {
|
|
1408
|
-
tblock = parse(context, JSON.parse(JSON.stringify(pos)));
|
|
1409
|
-
}
|
|
1410
|
-
if (reversed_loop(context)) { illustrator.inverted = !illustrator.inverted; }
|
|
1411
|
-
|
|
1412
|
-
// merge block and tblock, enforce the max, as the second branch could have fewer nodes than the first
|
|
1413
|
-
block.max.row = Math.max(block.max.row,tblock.max.row);
|
|
1414
|
-
block.max.col = Math.max(block.max.col,tblock.max.col);
|
|
1415
|
-
block.endnodes = tblock.endnodes;
|
|
1416
|
-
if (bottom) { // markers are drawn after all branches, see below
|
|
1417
|
-
markers.push({ tname: tname, sname: sname, context: context, prev: tblock.endnodes, col: pos.col, top: pos.row, maxcol: tblock.max.col });
|
|
1418
|
-
}
|
|
1419
|
-
|
|
1420
|
-
// console.log('<---- up', tname, parent_pos.row, block.max.row, parent_pos.col, block.max.col, illustrator.dim.debug());
|
|
1421
|
-
|
|
1422
|
-
block.svg.append(tblock.svg);
|
|
1423
|
-
block.svg.attr('id', 'group-' + $(context).attr('svg-id'));
|
|
1424
|
-
if(illustrator.elements[sname].endnodes == 'aggregate') endnodes = []; // resets endpoints e.g. potential preceding primitive
|
|
1425
|
-
} else {
|
|
1426
|
-
if(illustrator.elements[tname] != undefined && illustrator.elements[tname].type == 'primitive' && illustrator.elements[tname].svg) { // This enables "invisble" elements, by returning undefined in the SVG function (e.g. constraints)
|
|
1427
|
-
block.max.row = pos.row;
|
|
1428
|
-
block.max.col = pos.col;
|
|
1429
|
-
block.endnodes = [pos];
|
|
1430
|
-
}
|
|
1431
|
-
}
|
|
1432
|
-
// }}}
|
|
1433
|
-
|
|
1434
|
-
var g;
|
|
1435
|
-
if (!bottom) {
|
|
1436
|
-
set_details(tname,sname,pos,context);
|
|
1437
|
-
var origpos = JSON.parse(JSON.stringify(pos));
|
|
1438
|
-
[g, endnodes] = draw_position(tname,parent_pos,origpos,prev,block,endnodes,context);
|
|
1439
|
-
}
|
|
1440
|
-
|
|
1441
|
-
// Prepare next iteration {{{
|
|
1442
|
-
if(root_expansion == 'vertical') { prev = JSON.parse(JSON.stringify(endnodes)); pos.row = block.max.row;} // covers e.g. input's for alternative, parallel_branch, ... everything with horizontal expansion
|
|
1443
|
-
if(root_expansion == 'horizontal') pos.col = block.max.col;
|
|
1444
|
-
if(max.row < block.max.row) max.row = block.max.row;
|
|
1445
|
-
if(max.col < block.max.col) max.col = block.max.col;
|
|
1446
|
-
// }}}
|
|
1447
|
-
|
|
1448
|
-
if (illustrator.elements[sname].closing_symbol) {
|
|
1449
|
-
var ctname = illustrator.elements[sname].closing_symbol;
|
|
1450
|
-
var csname = sym_name(ctname,context);
|
|
1451
|
-
pos.row++;
|
|
1452
|
-
max.row++;
|
|
1453
|
-
block.max.row = pos.row;
|
|
1454
|
-
// the arrows to the closing symbol belong to the loop. empty loops: the
|
|
1455
|
-
// straight arrow comes from the opening symbol, not from the content, and
|
|
1456
|
-
// the way back goes around the side, so both point the other way
|
|
1457
|
-
let flip = reversed_loop(context) != (illustrator.elements[csname].closeblock == true && pos.row == origpos.row + 1);
|
|
1458
|
-
if (flip) { illustrator.inverted = !illustrator.inverted; }
|
|
1459
|
-
if (illustrator.elements[sname].endnodes == 'this') {
|
|
1460
|
-
pos.col++;
|
|
1461
|
-
if (pos.col > max.col) {
|
|
1462
|
-
max.col++;
|
|
1463
|
-
block.max.col = pos.col;
|
|
1464
|
-
}
|
|
1465
|
-
draw_position(ctname,parent_pos,pos,block.endnodes,block,[],context,{svg: g, pos: origpos});
|
|
1466
|
-
pos.col--;
|
|
1467
|
-
set_details(ctname,csname,pos,context,true);
|
|
1468
|
-
} else {
|
|
1469
|
-
set_details(ctname,csname,pos,context,true);
|
|
1470
|
-
[undefined, endnodes] = draw_position(ctname,parent_pos,pos,prev,block,[],context,{svg: g, pos: origpos});
|
|
1471
|
-
}
|
|
1472
|
-
if (flip) { illustrator.inverted = !illustrator.inverted; }
|
|
1473
|
-
if (illustrator.elements[sname].border == 'structural') {
|
|
1474
|
-
// structural border: outgoing arrow starts at the group border instead of from the icon
|
|
1475
|
-
// small y offset.
|
|
1476
|
-
endnodes = endnodes.map(function(p) {
|
|
1477
|
-
var np = JSON.parse(JSON.stringify(p));
|
|
1478
|
-
np.yoffset = illustrator.height_shift/2 + illustrator.group_extend + illustrator.conn_center - illustrator.structural_tighten;
|
|
1479
|
-
return np;
|
|
1480
|
-
});
|
|
1481
|
-
}
|
|
1482
|
-
prev = JSON.parse(JSON.stringify(endnodes));
|
|
1483
|
-
}
|
|
1484
|
-
});
|
|
1485
|
-
|
|
1486
|
-
if (markers.length > 0) {
|
|
1487
|
-
max.row++;
|
|
1488
|
-
block.max.row = max.row;
|
|
1489
|
-
let maxcol = block.max.col;
|
|
1490
|
-
if (illustrator.lr) { // all markers start at the same position, after the longest branch
|
|
1491
|
-
markers.forEach((m) => { illustrator.dim.set_row(max.row,m.col,m.prev); });
|
|
1492
|
-
let start = Math.max(...markers.map((m) => illustrator.dim.get_row(max.row,m.col)));
|
|
1493
|
-
markers.forEach((m) => { illustrator.dim.rows[max.row][m.col].start = start; });
|
|
1494
|
-
}
|
|
1495
|
-
markers.forEach((m) => {
|
|
1496
|
-
let mpos = { row: max.row, col: m.col, final: false, wide: false, yoffset: 0, top: m.top, marker: true }; // the tile starts at the top of the branch
|
|
1497
|
-
block.endnodes = [mpos]; // the marker is the end of its branch
|
|
1498
|
-
block.max.col = m.maxcol; // the tile only covers its own branch
|
|
1499
|
-
set_details(m.tname,m.sname,mpos,m.context);
|
|
1500
|
-
draw_position(m.tname,parent_pos,mpos,m.prev,block,endnodes,m.context);
|
|
1501
|
-
});
|
|
1502
|
-
block.max.col = maxcol;
|
|
1503
|
-
}
|
|
1504
|
-
|
|
1505
|
-
if($(root).children().filter(function(){ return this.attributes['svg-id'] != undefined; }).length == 0) { // empty complex found
|
|
1506
|
-
endnodes = [prev[0]]; // parent_pos, or for markers below their content the gateway
|
|
1507
|
-
max.row = parent_pos.row;
|
|
1508
|
-
max.col = parent_pos.col;
|
|
1509
|
-
}
|
|
1510
|
-
|
|
1511
|
-
if(root.tagName == 'description' && illustrator.elements[root.tagName].closing_symbol) {
|
|
1512
|
-
pos.row++;
|
|
1513
|
-
max.row = pos.row;
|
|
1514
|
-
draw_position(illustrator.elements['start'].closing_symbol,parent_pos,pos,prev,block,[],root,{svg: block.svg, pos: pos});
|
|
1515
|
-
}
|
|
1516
|
-
|
|
1517
|
-
return {'endnodes': endnodes, 'max':max, 'svg': block.svg};
|
|
1518
|
-
} // }}}
|
|
1519
|
-
var sym_name = function(tname,context) { //{{{
|
|
1520
|
-
var sname;
|
|
1521
|
-
if(!illustrator.elements[tname]) {sname = 'unknown';}
|
|
1522
|
-
else if(typeof illustrator.elements[tname].resolve_symbol == 'function') {sname = illustrator.elements[tname].resolve_symbol(context,illustrator.elements[tname].col_shift ? illustrator.elements[tname].col_shift(context) : undefined);}
|
|
1523
|
-
else if(typeof illustrator.elements[tname].resolve_symbol == 'string') {sname = illustrator.elements[tname].resolve_symbol;}
|
|
1524
|
-
else {sname = tname;}
|
|
1525
|
-
if (sname == null) {sname = tname;}
|
|
1526
|
-
return sname;
|
|
1527
|
-
} //}}}
|
|
1528
|
-
var set_details = function(tname,sname,pos,context,simple) { //{{{
|
|
1529
|
-
if (simple == undefined || simple == false) {
|
|
1530
|
-
if($(context).attr('id') == undefined) {
|
|
1531
|
-
if(id_counter[tname] == undefined) id_counter[tname] = -1;
|
|
1532
|
-
$(context).attr('svg-id', tname + '_' + (++id_counter[tname]));
|
|
1533
|
-
} else {
|
|
1534
|
-
$(context).attr('svg-id', $(context).attr('id'));
|
|
1535
|
-
}
|
|
1536
|
-
}
|
|
1537
|
-
if (illustrator.elements[sname].label) {
|
|
1538
|
-
var lab = illustrator.elements[sname].label(context);
|
|
1539
|
-
if (lab) {
|
|
1540
|
-
for (let i=0; i<lab.length; i++) {
|
|
1541
|
-
if (lab[i] && lab[i].value && lab[i].column == 'Label' && lab[i].value != '') {
|
|
1542
|
-
$(context).attr('svg-label', lab[0].value);
|
|
1543
|
-
if (illustrator.compact) {
|
|
1544
|
-
lab.splice(i,1);
|
|
1545
|
-
}
|
|
1546
|
-
}
|
|
1547
|
-
}
|
|
1548
|
-
labels.push({...{row: pos.row, element_id: $(context).attr('svg-id'), tname: tname, label: lab},...illustrator.draw.get_y(pos.row)});
|
|
1549
|
-
}
|
|
1550
|
-
}
|
|
1551
|
-
} //}}}
|
|
1552
|
-
var draw_position = function(tname,parent_pos,pos,prev,block,endnodes,context,second) { // private {{{
|
|
1553
|
-
var sname = sym_name(tname,context);
|
|
1554
|
-
// console.log('----- pos ' + sname, parent_pos.row, block.max.row, parent_pos.col, block.max.col, block, illustrator.dim.debug());
|
|
1555
|
-
|
|
1556
|
-
// Draw Symbol {{{
|
|
1557
|
-
illustrator.dim.set_row(pos.row,pos.col,prev);
|
|
1558
|
-
let style = {};
|
|
1559
|
-
if (illustrator.elements[sname].style && context) {
|
|
1560
|
-
style = illustrator.elements[sname].style(context);
|
|
1561
|
-
}
|
|
1562
|
-
if (second) {
|
|
1563
|
-
// wide is only for the special case of variable parallel, only event_end has it, all others should reference the first row
|
|
1564
|
-
illustrator.draw.draw_symbol(sname, $(context).attr('svg-id'), $(context).attr('svg-label'), illustrator.elements[sname].wide == true ? parent_pos.row+1 : parent_pos.row, block.max.row, pos.row, pos.col, second.svg, true, {}, style).addClass(illustrator.elements[sname] ? illustrator.elements[sname].type : 'primitive unknown');
|
|
1565
|
-
} else {
|
|
1566
|
-
$(context).attr('svg-type',tname);
|
|
1567
|
-
$(context).attr('svg-subtype',sname);
|
|
1568
|
-
if((illustrator.elements[sname] && illustrator.elements[sname].svg) || sname == 'unknown') {
|
|
1569
|
-
let info = {};
|
|
1570
|
-
if (illustrator.elements[sname].info && context) {
|
|
1571
|
-
info = illustrator.elements[sname].info(context);
|
|
1572
|
-
}
|
|
1573
|
-
var g = illustrator.draw.draw_symbol(sname, $(context).attr('svg-id'), $(context).attr('svg-label'), parent_pos.row, block.max.row, pos.row, pos.col, block.svg, false, info, style).addClass(illustrator.elements[sname] ? illustrator.elements[sname].type : 'primitive unknown');
|
|
1574
|
-
} else { console.log("no icon "+ sname);}
|
|
1575
|
-
if (illustrator.elements[sname] && illustrator.elements[sname].border) {
|
|
1576
|
-
let wide = (illustrator.elements[sname].wide == true && block.max.col == pos.col) ? pos.col + 1 : block.max.col;
|
|
1577
|
-
let yshrink = illustrator.elements[sname].border == 'structural' ? illustrator.structural_tighten : 0;
|
|
1578
|
-
if (illustrator.elements[sname].closing_symbol) {
|
|
1579
|
-
illustrator.draw.draw_border($(context).attr('svg-id'), pos, { col: wide, row: block.max.row + 1 }, block.svg, yshrink);
|
|
1580
|
-
} else {
|
|
1581
|
-
illustrator.draw.draw_border($(context).attr('svg-id'), pos, { col: wide, row: block.max.row }, block.svg, yshrink);
|
|
1582
|
-
}
|
|
1583
|
-
}
|
|
1584
|
-
if (illustrator.elements[sname] && illustrator.elements[sname].type == 'complex') {
|
|
1585
|
-
let wide = (illustrator.elements[sname].wide == true && block.max.col == pos.col) ? pos.col + 1 : block.max.col;
|
|
1586
|
-
let yshrink = illustrator.elements[sname].border == 'structural' ? illustrator.structural_tighten : 0;
|
|
1587
|
-
if (illustrator.elements[sname].closing_symbol) {
|
|
1588
|
-
illustrator.draw.draw_tile($(context).attr('svg-id'), pos, { col: wide, row: block.max.row + 1 }, block.svg, yshrink);
|
|
1589
|
-
} else {
|
|
1590
|
-
illustrator.draw.draw_tile($(context).attr('svg-id'), pos.top ? { row: pos.top, col: pos.col } : pos, { col: wide, row: block.max.row }, block.svg, yshrink); // top: marker below its content
|
|
1591
|
-
}
|
|
1592
|
-
}
|
|
1593
|
-
}
|
|
1594
|
-
// }}}
|
|
1595
|
-
|
|
1596
|
-
// Calculate Connection {{{
|
|
1597
|
-
let connection_case = 0;
|
|
1598
|
-
var conn_target = pos;
|
|
1599
|
-
if (illustrator.elements[sname].border == 'structural' && !second) {
|
|
1600
|
-
// structural border: incoming arrow stops at the group border instead of reaching into the icon
|
|
1601
|
-
// (only a pixel-level yoffset, row/col stay integers so get_x() column lookups stay correct)
|
|
1602
|
-
conn_target = JSON.parse(JSON.stringify(pos));
|
|
1603
|
-
conn_target.yoffset = -illustrator.height + illustrator.height_shift/2 - illustrator.group_extend + illustrator.conn_center + illustrator.structural_tighten;
|
|
1604
|
-
conn_target.structural = true;
|
|
1605
|
-
}
|
|
1606
|
-
if(illustrator.elements[sname] != undefined && illustrator.elements[sname].closeblock == true) { // Close Block if element e.g. loop
|
|
1607
|
-
if (second) {
|
|
1608
|
-
if (second.pos.row+1 < pos.row) { // when no content, dont paint the up arrow
|
|
1609
|
-
connection_case = 1;
|
|
1610
|
-
// console.log('++ case 1',prev[node].row,pos.row,illustrator.dim.debug());
|
|
1611
|
-
illustrator.draw.draw_connection(block.svg, pos, second.pos, 0, true);
|
|
1612
|
-
} else { // no content: the way back goes around the side
|
|
1613
|
-
connection_case = 7;
|
|
1614
|
-
illustrator.draw.draw_connection(block.svg, pos, second.pos, 0, true, true);
|
|
1615
|
-
}
|
|
1616
|
-
} else {
|
|
1617
|
-
for (let node=0; node < block.endnodes.length; node++) {
|
|
1618
|
-
if (block.endnodes[node] && !block.endnodes[node].final) {
|
|
1619
|
-
connection_case = 2;
|
|
1620
|
-
// console.log('++ case 2',prev[node].row,pos.row,illustrator.dim.debug());
|
|
1621
|
-
illustrator.draw.draw_connection(block.svg, block.endnodes[node], pos, 0, true);
|
|
1622
|
-
}
|
|
1623
|
-
}
|
|
1624
|
-
}
|
|
1625
|
-
}
|
|
1626
|
-
if(illustrator.elements[sname] != undefined && illustrator.elements[sname].endnodes != 'this') {
|
|
1627
|
-
for(i in block.endnodes) { endnodes.push(block.endnodes[i]); } // collects all endpoints from different childs e.g. alternatives from choose
|
|
1628
|
-
} else { endnodes = [JSON.parse(JSON.stringify(pos))]; } // sets this element as only endpoint (aggregate)
|
|
1629
|
-
if(prev[0].row == 0 || prev[0].col == 0) { // this enforces the connection from description to the first element
|
|
1630
|
-
connection_case = 3;
|
|
1631
|
-
illustrator.draw.draw_connection(block.svg, { row: 1, col: 1, yoffset: 0 }, conn_target, 0, true);
|
|
1632
|
-
} else {
|
|
1633
|
-
if (illustrator.elements[sname].noarrow == undefined || illustrator.elements[sname].noarrow == false || illustrator.inverted) { // inverted: the arrow points from the marker to the content
|
|
1634
|
-
for (let node=0; node < prev.length; node++) {
|
|
1635
|
-
if (prev[node] && !(illustrator.inverted ? pos.final : prev[node].final)) { // inverted: nothing goes out of a final element, which is drawn as the target
|
|
1636
|
-
if (prev[node].wide) {
|
|
1637
|
-
var pn = JSON.parse(JSON.stringify(prev[node]));
|
|
1638
|
-
if (pos.col > prev[node].col) {
|
|
1639
|
-
pn.col = pos.col;
|
|
1640
|
-
}
|
|
1641
|
-
connection_case = 4;
|
|
1642
|
-
// console.log('++ case 4',prev[node].row,pos.row,illustrator.dim.debug());
|
|
1643
|
-
illustrator.draw.draw_connection(block.svg, pn, conn_target, 0, true);
|
|
1644
|
-
} else {
|
|
1645
|
-
connection_case = 5;
|
|
1646
|
-
if (prev.length == 1) {
|
|
1647
|
-
// console.log('++ case 5a',parent_pos.row, '---', prev[node].row,pos.row,illustrator.dim.debug());
|
|
1648
|
-
illustrator.draw.draw_connection(block.svg, prev[node], conn_target, 0, !prev[node].marker);
|
|
1649
|
-
} else {
|
|
1650
|
-
// console.log('++ case 5b',prev[node].row,pos.row,illustrator.dim.debug());
|
|
1651
|
-
illustrator.draw.draw_connection(block.svg, prev[node], conn_target, 0, !prev[node].marker); // no arrow into markers drawn below their content
|
|
1652
|
-
}
|
|
1653
|
-
}
|
|
1654
|
-
}
|
|
1655
|
-
}
|
|
1656
|
-
} else {
|
|
1657
|
-
for (let node=0; node < prev.length; node++) {
|
|
1658
|
-
if (prev[node] && !prev[node].final) {
|
|
1659
|
-
connection_case = 6;
|
|
1660
|
-
// console.log('++ case 6',prev[node].row,pos.row,illustrator.dim.debug());
|
|
1661
|
-
illustrator.draw.draw_connection(block.svg, prev[node], conn_target, prev[node].row, false);
|
|
1662
|
-
}
|
|
1663
|
-
}
|
|
1664
|
-
}
|
|
1665
|
-
}
|
|
1666
|
-
// }}}
|
|
1667
|
-
|
|
1668
|
-
///////// show graph step by step
|
|
1669
|
-
// illustrator.set_svg(block);
|
|
1670
|
-
// debugger;
|
|
1671
|
-
|
|
1672
|
-
return [g, endnodes];
|
|
1673
|
-
} // }}}
|
|
1674
|
-
// }}}
|
|
1675
|
-
|
|
1676
|
-
// Initialze {{{
|
|
1677
|
-
adaptor = wf_adaptor;
|
|
1678
|
-
illustrator = wf_illustrator;
|
|
1679
|
-
// }}}
|
|
1680
|
-
} // }}}
|