cpee 1.4.30 → 1.4.31

Sign up to get free protection for your applications and to get access to all the features.
@@ -47,8 +47,7 @@ function do_main_save() { //{{{
47
47
  nnew.attr('trans-xmlns','http://cpee.org/ns/description/1.0');
48
48
 
49
49
  if ($('*[svg-id]',node).length > 0) {
50
- // TODO maybe not all children. Maybe only thingies that have svg-id but nothing with svg-id between it and node.
51
- nnew.append(node.children());
50
+ nnew.append(node.children().filter(function(){ return this.attributes['svg-id'] != undefined; }));
52
51
  }
53
52
 
54
53
  var ntxt = nnew.serializeXML();
@@ -58,7 +57,7 @@ function do_main_save() { //{{{
58
57
  desc.refresh(function(graphrealization){
59
58
  var vtarget = manifestation.adaptor.illustrator.get_node_by_svg_id(svgid);
60
59
  if (vtarget.length > 0) {
61
- vtarget.parents('g.element[element-id]').addClass('clicked');
60
+ vtarget.parents('g.element[element-id]').addClass('selected');
62
61
  }
63
62
  var newnode = vtarget.parents('g.element[element-id]');
64
63
  var newtype = newnode.attr('element-type') + '_' + newnode.attr('element-endpoint');
@@ -13,6 +13,7 @@ var save = {};
13
13
  save['graph_adaptor'] = undefined;
14
14
  save['endpoints'] = undefined;
15
15
  save['endpoints_cache'] = {};
16
+ save['endpoints_list'] = {};
16
17
  save['dataelements'] = undefined;
17
18
  save['attributes'] = undefined;
18
19
  save['details'] = undefined;
@@ -353,8 +354,10 @@ function monitor_instance_values(val) {// {{{
353
354
  success: function(res){
354
355
  save[val].content(res);
355
356
  if (val == "endpoints") {
357
+ save['endpoints_list'] = {};
356
358
  var tmp = {};
357
359
  $(res).find(" > value > *").each(function(k,v) {
360
+ save['endpoints_list'][v.localName] = v.lastChild.nodeValue;
358
361
  $.ajax({
359
362
  url: rep + encodeURIComponent($(v).text()),
360
363
  success: function() {
@@ -409,7 +412,34 @@ function adaptor_init(url,theme,dslx) { //{{{
409
412
  if (save['graph_theme'] != theme) {
410
413
  save['graph_theme'] = theme;
411
414
  save['graph_adaptor'] = new WfAdaptor($('body').data('theme-base') + '/' + theme + '/theme.js',function(graphrealization){
415
+ manifestation.endpoints = save.endpoints_list;
416
+ graphrealization.draw_labels = function(max,labels,shift) {
417
+ $('#graphcanvas').css('grid-row', '1/span ' +( max.row + 1));
418
+ $('#graphgrid .graphlabel').remove();
419
+ $('#graphgrid').css('grid-template-rows', shift + 'px repeat(' + max.row + ', 1fr)');
420
+ var tlabels = {};
421
+ var tcolumns = [];
422
+ _.each(labels,function(val){
423
+ if (val.label != "") {
424
+ tlabels[val.row] = [];
425
+ _.each(val.label,function(col) {
426
+ if (!tcolumns.includes(col.column)) {
427
+ tcolumns.push(col.column);
428
+ }
429
+ tlabels[val.row][tcolumns.indexOf(col.column)] = col.value;
430
+ });
431
+ }
432
+ });
433
+ for (var i = 0; i < max.row; i++) {
434
+ _.each(tlabels[i+1],function(col,j) {
435
+ if (col != undefined) {
436
+ $('#graphgrid').append($('<div class="graphlabel" style="grid-column: ' + (j+2) + '; grid-row: ' + (i+2) + '; padding-bottom: ' + shift + 'px"><span>' + col + '</span></div>'));
437
+ }
438
+ });
439
+ }
440
+ };
412
441
  graphrealization.set_svg_container($('#graphcanvas'));
442
+ graphrealization.set_css_container($('#graphgrid'));
413
443
  graphrealization.set_description($(dslx), true);
414
444
  graphrealization.notify = function(svgid) {
415
445
  var g = graphrealization.get_description();
@@ -430,7 +460,7 @@ function adaptor_init(url,theme,dslx) { //{{{
430
460
  });
431
461
  } else {
432
462
  save['graph_adaptor'].update(function(graphrealization){
433
- var svgid = manifestation.clicked();
463
+ var svgid = manifestation.selected();
434
464
  graphrealization.set_description($(dslx));
435
465
  adaptor_update();
436
466
  manifestation.events.click(svgid);
@@ -556,11 +586,13 @@ function monitor_instance_state_change(notification) { //{{{
556
586
 
557
587
  var but = "";
558
588
  if (notification == "ready" || notification == "stopped") {
589
+ $('#state_extended').show();
559
590
  $("button[name=state_start]").show();
560
591
  $("button[name=state_stop]").hide();
561
592
  $("button[name=state_sim]").show();
562
593
  $("button[name=state_abandon]").show();
563
594
  } else if (notification == "running") {
595
+ $('#state_extended').hide();
564
596
  $("button[name=state_start]").hide();
565
597
  $("button[name=state_stop]").show();
566
598
  $("button[name=state_sim]").hide();
@@ -574,8 +606,9 @@ function monitor_instance_state_change(notification) { //{{{
574
606
  save['graph_adaptor'].illustrator.get_elements().removeClass('marked');
575
607
  }
576
608
 
577
- if (notification == "finished") {
609
+ if (notification == "finished" || notification == "abandoned") {
578
610
  $('.tabbehind button').hide();
611
+ $('#state_any').hide();
579
612
  } else {
580
613
  $('#parameters .tabbehind button').show();
581
614
  }
@@ -1146,8 +1179,8 @@ function format_visual_clear() {//{{{
1146
1179
  $('.super .vote').each(function(a,b){b.setAttribute('class','vote');});
1147
1180
  $('.super .colon').each(function(a,b){b.setAttribute('class','colon');});
1148
1181
  $('.activities').each(function(a,b){
1149
- if (b.hasAttribute('clicked')) {
1150
- b.setAttribute('class','activities clicked');
1182
+ if (b.hasAttribute('selected')) {
1183
+ b.setAttribute('class','activities selected');
1151
1184
  } else {
1152
1185
  b.setAttribute('class','activities');
1153
1186
  }
@@ -42,13 +42,19 @@ function WfAdaptor(theme_base,doit) { // Controller {{{
42
42
  this.set_description = function(desc,auto_update) { // public {{{
43
43
  this.description.set_description(desc,auto_update);
44
44
  } // }}}
45
+
45
46
  this.get_description = function() { // public {{{
46
47
  return description.get_description();
47
48
  } // }}}
48
49
  this.notify = function() { // public {{{
49
50
  } // }}}
51
+ this.draw_labels = function(max,labels){ // public {{{
52
+ } // }}}
50
53
  this.set_svg_container = function (container) { // {{{
51
- illustrator.set_container(container); // TODO: shadowing the container element
54
+ illustrator.set_svg_container(container); // TODO: shadowing the container element
55
+ } // }}}
56
+ this.set_css_container = function(container) { // {{{
57
+ illustrator.set_css_container(container);
52
58
  } // }}}
53
59
 
54
60
  // initialize
@@ -59,21 +65,27 @@ function WfAdaptor(theme_base,doit) { // Controller {{{
59
65
 
60
66
  $.getScript(theme_base, function() {
61
67
  manifestation = new WFAdaptorManifestation(self);
62
- illustrator.noarrow = manifestation.noarrow;
63
68
  illustrator.compact = manifestation.compact == true ? true : false;
64
69
  description.source = manifestation.source;
65
70
  var deferreds = [];
66
71
  // copy parent stuff
67
72
  for(element in manifestation.elements) {
68
- if (!manifestation.elements[element].description) {
69
- if (manifestation.elements[element].parent) { // take from parent if empty
73
+ if (manifestation.elements[element].parent) {
74
+ if (!manifestation.elements[element].description) {
70
75
  manifestation.elements[element].description = manifestation.elements[manifestation.elements[element].parent].description;
71
76
  }
72
- }
73
- if (!manifestation.elements[element].adaptor) {
74
- if (manifestation.elements[element].parent) { // take from parent if empty
77
+ if (!manifestation.elements[element].adaptor) {
75
78
  manifestation.elements[element].adaptor = manifestation.elements[manifestation.elements[element].parent].adaptor;
76
79
  }
80
+ var ill = manifestation.elements[manifestation.elements[element].parent].illustrator;
81
+ for (var key in ill) {
82
+ if (manifestation.elements[element].illustrator[key] == undefined) {
83
+ manifestation.elements[element].illustrator[key] = ill[key];
84
+ }
85
+ }
86
+ if (manifestation.elements[element].type == undefined) {
87
+ manifestation.elements[element].type = manifestation.elements[manifestation.elements[element].parent].type;
88
+ }
77
89
  }
78
90
  }
79
91
  // doit
@@ -146,7 +158,7 @@ function WfIllustrator(wf_adaptor) { // View {{{
146
158
  // public
147
159
  this.height = 40;
148
160
  this.width = 40;
149
- this.noarrow = [];
161
+ this.shift = this.height * 0.26;
150
162
  this.elements = {}; // the svgs
151
163
  this.svg = {};
152
164
  this.draw = {};
@@ -156,7 +168,10 @@ function WfIllustrator(wf_adaptor) { // View {{{
156
168
  var adaptor = null;
157
169
  // }}}
158
170
  // Generic Functions {{{
159
- this.set_container = function(con) { // {{{
171
+ this.set_css_container = function(con) { // {{{
172
+ self.svg.css = con;
173
+ } // }}}
174
+ this.set_svg_container = function(con) { // {{{
160
175
  self.svg.container = con;
161
176
  self.svg.container.append($X('<defs xmlns="http://www.w3.org/2000/svg">' +
162
177
  ' <marker id="arrow" viewBox="0 0 10 10" refX="33" refY="5" orient="auto" markerUnits="strokeWidth" markerWidth="4.5" makerHeight="4.5">' +
@@ -174,14 +189,15 @@ function WfIllustrator(wf_adaptor) { // View {{{
174
189
  $.each(self.elements[element].svg.attr('class').split(/\s+/), function(index, item) { sym.addClass(item); }); // copy all classes from the root node
175
190
  self.svg.defs[element] = sym;
176
191
  }
177
- } // }}}
192
+ } // }}}
178
193
  var clear = this.clear = function() { // {{{
179
194
  $('> :not(defs)', self.svg.container).each(function() {$(this).remove()});
180
195
  } // }}}
181
196
  this.set_svg = function(graph) { // {{{
182
197
  if(graph.max.row < 1) graph.max.row = 1;
183
198
  if(graph.max.col < 1) graph.max.col = 1;
184
- self.svg.container.attr({'height': (graph.max.row+0.3)*self.height, 'style': "min-width: " + (graph.max.col+0.55)*self.width + "px"});
199
+ self.svg.container.attr('height', (graph.max.row) * self.height + self.shift);
200
+ self.svg.container.attr('width', (graph.max.col+0.55) * self.width );
185
201
  self.svg.container.append(graph.svg);
186
202
  } // }}}
187
203
  this.get_node_by_svg_id = function(svg_id) { // {{{
@@ -211,18 +227,24 @@ function WfIllustrator(wf_adaptor) { // View {{{
211
227
  else {self.svg.container.children('g:first').append(g);}
212
228
  return g;
213
229
  } // }}}
214
- var draw_symbol = this.draw.draw_symbol = function (tname, sym_name, id, title, row, col, group) { // {{{
215
- if(self.elements[sym_name] == undefined || self.elements[sym_name].svg == undefined) sym_name = 'unknown';
216
- var g = $X('<g class="element" element-type="' + sym_name + '" element-id="' + id + '" xmlns="http://www.w3.org/2000/svg">' +
217
- '<g transform="translate(' + String((col*self.width)-((self.width*0.39))) + ',' + String(row*self.height-((self.height*0.74))) + ')">' +
218
- '<text class="super" transform="translate(30,8.4)">' +
219
- '<tspan class="active">0</tspan>' +
220
- '<tspan class="colon">,</tspan>' +
221
- '<tspan class="vote">0</tspan>' +
222
- '</text>' +
223
- '</g>' +
224
- '</g>');
225
- var sym = self.svg.defs[sym_name].clone();
230
+ var draw_symbol = this.draw.draw_symbol = function (sname, id, title, row, col, group, addition) { // {{{
231
+ if(self.elements[sname] == undefined || self.elements[sname].svg == undefined) sname = 'unknown';
232
+ if (addition) {
233
+ var g = $X('<g class="element" element-type="' + sname + '" element-id="' + id + '" xmlns="http://www.w3.org/2000/svg">' +
234
+ '<g transform="translate(' + String((col*self.width)-((self.width*0.39))) + ',' + String(row*self.height-((self.height*0.74))) + ')"></g>' +
235
+ '</g>');
236
+ } else {
237
+ var g = $X('<g class="element" element-type="' + sname + '" element-id="' + id + '" xmlns="http://www.w3.org/2000/svg">' +
238
+ '<g transform="translate(' + String((col*self.width)-((self.width*0.39))) + ',' + String(row*self.height-((self.height*0.74))) + ')">' +
239
+ '<text class="super" transform="translate(30,8.4)">' +
240
+ '<tspan class="active">0</tspan>' +
241
+ '<tspan class="colon">,</tspan>' +
242
+ '<tspan class="vote">0</tspan>' +
243
+ '</text>' +
244
+ '</g>' +
245
+ '</g>');
246
+ }
247
+ var sym = self.svg.defs[sname].clone();
226
248
  var tit = $X('<title xmlns="http://www.w3.org/2000/svg"></title>');
227
249
  tit.text(title);
228
250
  sym.prepend(tit);
@@ -230,7 +252,7 @@ function WfIllustrator(wf_adaptor) { // View {{{
230
252
  $(g[0].childNodes[0]).append(sym);
231
253
 
232
254
  // Binding events for symbol
233
- bind_event(sym,tname);
255
+ bind_event(sym,sname);
234
256
 
235
257
  if(group) {group.append(g);}
236
258
  else {self.svg.container.children('g:first').append(g);}
@@ -298,16 +320,13 @@ function WfIllustrator(wf_adaptor) { // View {{{
298
320
  );
299
321
  } else {
300
322
  line.attr("d", "M " + String(start['col']*self.width) + "," + String(start['row']*self.height-15) +" "+
301
- String(end['col']*self.width+20) + "," + String(start['row']*self.height-15) +" "+
302
- String(end['col']*self.width+20) + "," + String(end['row']*self.height+25)+" "+
323
+ String(end['col']*self.width+15) + "," + String(start['row']*self.height-15) +" "+
324
+ String(end['col']*self.width+15) + "," + String(end['row']*self.height+15)+" "+
303
325
  String(end['col']*self.width) + "," + String(end['row']*self.height-15)
304
326
  );
305
327
  }
306
328
  }
307
- // Seems to solve injection groups-line problem, but I guess it will cause problem when collapsing elements
308
- //if(group) {group.prepend(line);}
309
- //else
310
- {self.svg.container.append(line);}
329
+ self.svg.container.append(line);
311
330
  } // }}}
312
331
  // }}}
313
332
  // Initialize {{{
@@ -333,12 +352,16 @@ function WfDescription(wf_adaptor, wf_illustrator) { // Model {{{
333
352
  // Set Labels //{{{
334
353
  this.set_labels = function(graph) {
335
354
  if (illustrator.compact == false) {
336
- if (labels.length > 0) {
337
- _.each(labels,function(a,key) {
338
- illustrator.draw.draw_label(a.tname, a.element_id, a.label, a.row, graph.max.col + 1, graph.svg);
339
- });
340
- }
355
+ adaptor.draw_labels(graph.max,labels,illustrator.shift);
341
356
  }
357
+ // if (illustrator.compact == false) {
358
+ // if (labels.length > 0) {
359
+ // var csscol = 0;
360
+ // _.each(labels,function(a,key) {
361
+ // // illustrator.draw.draw_label(a.tname, a.element_id, a.label, a.row, graph.max.col + 1, graph.svg);
362
+ // });
363
+ // }
364
+ // }
342
365
  } //}}}
343
366
 
344
367
  // Generic Functions {{{
@@ -355,7 +378,7 @@ function WfDescription(wf_adaptor, wf_illustrator) { // Model {{{
355
378
  id_counter = {};
356
379
  labels = [];
357
380
  illustrator.clear();
358
- var graph = parse(description.children('description').get(0), {'row':0,'col':0,final:false});
381
+ var graph = parse(description.children('description').get(0), {'row':0,'col':0,final:false,wide:false});
359
382
  self.set_labels(graph);
360
383
  // set labels
361
384
  illustrator.set_svg(graph);
@@ -501,30 +524,30 @@ function WfDescription(wf_adaptor, wf_illustrator) { // Model {{{
501
524
  var max = {'row': 0,'col': 0};
502
525
  var prev = [parent_pos]; // connects parent with child(s), depending on the expansion
503
526
  var endnodes = [];
527
+ var sname = sym_name(root.tagName,root);
504
528
  var root_expansion = illustrator.elements[root.tagName].expansion(root);
505
529
  var block = {'max':{}}; // e.g. {'max':{'row':0,'col':0}, 'endpoints':[]};
506
- var collapsed = false;
507
530
 
508
531
  var group = $X('<g class="group" xmlns="http://www.w3.org/2000/svg"/>');
509
532
 
510
533
  if(root_expansion == 'horizontal') pos.row++;
511
534
  if(illustrator.elements[root.tagName].col_shift(root) == true && root_expansion != 'horizontal') pos.col++;
512
535
 
513
- if(root .tagName == 'description') { // First parsing {{{
536
+ if(root.tagName == 'description') { // First parsing {{{
514
537
  pos.row++;
515
- max.row++;
516
538
  $(root).attr('svg-id','description');
517
539
  group.attr('element-id','group-description');
518
- illustrator.draw.draw_symbol('start', 'start', 'description', 'START', pos.row, pos.col, group);
540
+ illustrator.draw.draw_symbol('start', 'description', 'START', pos.row, pos.col, group);
519
541
  } // }}}
520
542
 
521
- $(root).children().each(function() {
522
- var tname = this.tagName;
523
- pos.final = illustrator.elements[tname].final ? true : false;
543
+ $(root).children().filter(function(){ return this.localName[0] != '_'; }).each(function() {
544
+ var context = this;
545
+ var tname = context.tagName;
546
+ var sname = sym_name(tname,context);
547
+ pos.final = illustrator.elements[sname].final ? true : false;
548
+ pos.wide = illustrator.elements[sname].wide ? true : false;
524
549
 
525
550
  // Calculate next position {{{
526
- if($(this).attr('collapsed') == undefined || $(this).attr('collapsed') == 'false') { collapsed = false; }
527
- else { collapsed = true; }
528
551
  if(root_expansion == 'vertical') pos.row++;
529
552
  if(root_expansion == 'horizontal') {
530
553
  pos.col++;
@@ -534,100 +557,165 @@ function WfDescription(wf_adaptor, wf_illustrator) { // Model {{{
534
557
  }
535
558
  }
536
559
  }
537
- if(illustrator.elements[tname] != undefined && illustrator.elements[tname].type == 'complex' && !collapsed) {
560
+
561
+ if(illustrator.elements[tname] != undefined && illustrator.elements[tname].type == 'complex') {
538
562
  if(illustrator.elements[tname] != undefined && !illustrator.elements[tname].svg) pos.row--;
539
563
  // TODO: Remaining problem is the order inside the svg. Thats why the connection is above the icon
540
- block = parse(this, jQuery.extend(true, {}, pos));
564
+ block = parse(context, jQuery.extend(true, {}, pos));
541
565
  group.append(block.svg);
542
- block.svg.attr('id', 'group-' + $(this).attr('svg-id'));
543
- if(illustrator.elements[tname].endnodes == 'aggregate') endnodes = []; // resets endpoints e.g. potential preceding primitive
566
+ block.svg.attr('id', 'group-' + $(context).attr('svg-id'));
567
+ if(illustrator.elements[sname].endnodes == 'aggregate') endnodes = []; // resets endpoints e.g. potential preceding primitive
544
568
  } else {
545
569
  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)
546
570
  block.max.row = pos.row;
547
571
  block.max.col = pos.col;
548
- block.endnodes = (!collapsed ? [pos] : [jQuery.extend(true, {}, pos)]);
572
+ block.endnodes = [pos];
549
573
  block.svg = group;
550
574
  }
551
575
  }
552
576
  // }}}
553
577
  // Set SVG-ID and labels {{{
554
- if($(this).attr('id') == undefined) {
578
+ if($(context).attr('id') == undefined) {
555
579
  if(id_counter[tname] == undefined) id_counter[tname] = -1;
556
- $(this).attr('svg-id', tname + '_' + (++id_counter[tname]));
580
+ $(context).attr('svg-id', tname + '_' + (++id_counter[tname]));
557
581
  } else {
558
- $(this).attr('svg-id', $(this).attr('id'));
582
+ $(context).attr('svg-id', $(context).attr('id'));
559
583
  }
560
- if (illustrator.elements[tname].label) {
561
- var lab = illustrator.elements[tname].label(this);
562
- $(this).attr('svg-label', lab);
563
- labels.push({row: pos.row, element_id: $(this).attr('svg-id'), tname: tname, label: lab});
584
+ if (illustrator.elements[sname].label) {
585
+ var lab = illustrator.elements[sname].label(context);
586
+ $(context).attr('svg-label', lab);
587
+ labels.push({row: pos.row, element_id: $(context).attr('svg-id'), tname: tname, label: lab});
564
588
  } else {
565
- $(this).attr('svg-label', '');
589
+ $(context).attr('svg-label', '');
566
590
  } // }}}
567
- // Draw symbol {{{
568
- var sym_name = '';
569
- if(!illustrator.elements[tname]) {sym_name = 'unknown';}
570
- else if(typeof illustrator.elements[tname].resolve_symbol == 'function') {sym_name = illustrator.elements[tname].resolve_symbol(this);}
571
- else if(typeof illustrator.elements[tname].resolve_symbol == 'string') {sym_name = illustrator.elements[tname].resolve_symbol;}
572
- else {sym_name = tname;}
573
- $(this).attr('svg-type',tname);
574
- $(this).attr('svg-subtype',sym_name);
575
- if((illustrator.elements[tname] && illustrator.elements[tname].svg) || sym_name == 'unknown') {
576
- var g = illustrator.draw.draw_symbol(tname, sym_name, $(this).attr('svg-id'), $(this).attr('svg-label'), pos.row, pos.col, block.svg).addClass(illustrator.elements[tname] ? illustrator.elements[tname].type : 'primitive unknown');
577
- if (illustrator.elements[sym_name].info) {
578
- var info = illustrator.elements[sym_name].info(this);
579
- _.each(info,function(val,key) {
580
- g.attr(key, val);
581
- });
582
- }
583
- } else { console.log("no icon "+ tname);}
584
- if(illustrator.elements[tname] && illustrator.elements[tname].border) illustrator.draw.draw_border($(this).attr('svg-id'), pos, block.max, block.svg);
585
- if(illustrator.elements[tname] && illustrator.elements[tname].type == 'complex') illustrator.draw.draw_tile($(this).attr('svg-id'), pos, block.max, block.svg);
586
- // }}}
587
- // Calculate Connection {{{
588
- if(illustrator.elements[tname] != undefined && illustrator.elements[tname].closeblock) { // Close Block if element e.g. loop
589
- for(node in block.endnodes) {
590
- if (!block.endnodes[node].final) {
591
- illustrator.draw.draw_connection(group, block.endnodes[node], pos, block.max.row+1, block.endnodes.length, true);
592
- }
593
- }
594
- }
595
- if(illustrator.elements[tname] != undefined && illustrator.elements[tname].endnodes != 'this') {
596
- for(i in block.endnodes) endnodes.push(block.endnodes[i]); // collects all endpoints from different childs e.g. alternatives from choose
597
- } else { endnodes = [jQuery.extend(true, {}, pos)]; } // sets this element as only endpoint (aggregate)
598
- if(prev[0].row == 0 || prev[0].col == 0) { // this enforces the connection from description to the first element
599
- illustrator.draw.draw_connection(group, { row: 1, col: 1 }, pos, null, null, true);
600
- } else {
601
- if ($.inArray(tname,illustrator.noarrow) == -1) {
602
- for (node in prev) {
603
- if (!prev[node].final)
604
- illustrator.draw.draw_connection(group, prev[node], pos, null, null, true);
605
- }
606
- } else {
607
- for(node in prev) {
608
- if (!prev[node].final)
609
- illustrator.draw.draw_connection(group, prev[node], pos, null, null, false);
610
- }
611
- }
612
- }
613
- // }}}
591
+
592
+ var g;
593
+ [g, endnodes] = draw_position(tname,pos,prev,block,group,endnodes,context);
594
+
614
595
  // Prepare next iteration {{{
615
596
  if(root_expansion == 'vertical') { prev = jQuery.extend(true, {}, endnodes); pos.row = block.max.row;} // covers e.g. input's for alternative, parallel_branch, ... everything with horizontal expansion
616
597
  if(root_expansion == 'horizontal') pos.col = block.max.col;
617
598
  if(max.row < block.max.row) max.row = block.max.row;
618
599
  if(max.col < block.max.col) max.col = block.max.col;
619
600
  // }}}
601
+
602
+ if (illustrator.elements[sname].closing_symbol) {
603
+ pos.row++;
604
+ max.row++;
605
+ block.max.row = pos.row;
606
+ if (illustrator.elements[sname].endnodes == 'this') {
607
+ pos.col++;
608
+ if (pos.col > max.col) {
609
+ max.col++;
610
+ block.max.col = pos.col;
611
+ }
612
+ draw_position(illustrator.elements[sname].closing_symbol,pos,block.endnodes,block,group,[],context,g);
613
+ pos.col--;
614
+ } else {
615
+ [undefined, endnodes] = draw_position(illustrator.elements[sname].closing_symbol,pos,prev,block,group,[],context,g);
616
+ }
617
+ prev = jQuery.extend(true, {}, endnodes);
618
+ }
620
619
  });
621
620
 
622
- if($(root).children().length == 0) { // empty complex found
621
+ if($(root).children().filter(function(){ return this.attributes['svg-id'] != undefined; }).length == 0) { // empty complex found
623
622
  endnodes = [parent_pos];
624
623
  max.row = parent_pos.row;
625
624
  max.col = parent_pos.col;
626
625
  }
627
- if(illustrator.elements[root.tagName].endnodes == 'this' && illustrator.elements[root.tagName].closeblock == false) {endnodes = [prev];} // closeblock == false, allows loop to close himselfe
626
+
627
+ if((illustrator.elements[root.tagName].endnodes == 'this' || illustrator.elements[sname].endnodes == 'this') && illustrator.elements[root.tagName].closeblock == false) {endnodes = prev;} // closeblock == false, allows loop to close himself
628
+
629
+ if(root.tagName == 'description' && illustrator.elements[root.tagName].closing_symbol) {
630
+ pos.row++;
631
+ max.row = pos.row;
632
+ draw_position(illustrator.elements['start'].closing_symbol,pos,prev,block,group,[],this,group);
633
+ }
634
+
628
635
  return {'endnodes': endnodes, 'max':max, 'svg':group};
629
636
  } // }}}
630
- // }}}
637
+ var sym_name = function(tname,context) { //{{{
638
+ var sname;
639
+ if(!illustrator.elements[tname]) {sname = 'unknown';}
640
+ 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);}
641
+ else if(typeof illustrator.elements[tname].resolve_symbol == 'string') {sname = illustrator.elements[tname].resolve_symbol;}
642
+ else {sname = tname;}
643
+ return sname;
644
+ } //}}}
645
+ var draw_position = function(tname,pos,prev,block,group,endnodes,context,second) { // private {{{
646
+ var sname = sym_name(tname,context);
647
+ // Draw Symbol {{{
648
+ if (second) {
649
+ illustrator.draw.draw_symbol(sname, $(context).attr('svg-id'), $(context).attr('svg-label'), pos.row, pos.col, second, true).addClass(illustrator.elements[sname] ? illustrator.elements[sname].type : 'primitive unknown');
650
+ } else {
651
+ $(context).attr('svg-type',tname);
652
+ $(context).attr('svg-subtype',sname);
653
+ if((illustrator.elements[sname] && illustrator.elements[sname].svg) || sname == 'unknown') {
654
+ var g = illustrator.draw.draw_symbol(sname, $(context).attr('svg-id'), $(context).attr('svg-label'), pos.row, pos.col, block.svg).addClass(illustrator.elements[sname] ? illustrator.elements[sname].type : 'primitive unknown');
655
+ if (illustrator.elements[sname].info) {
656
+ var info = illustrator.elements[sname].info(context);
657
+ _.each(info,function(val,key) {
658
+ g.attr(key, val);
659
+ });
660
+ }
661
+ } else { console.log("no icon "+ sname);}
662
+ if(illustrator.elements[sname] && illustrator.elements[sname].border) {
663
+ var wide = (illustrator.elements[sname].wide == true && block.max.col == pos.col) ? pos.col + 1 : block.max.col;
664
+ if (illustrator.elements[sname].closing_symbol) {
665
+ illustrator.draw.draw_border($(context).attr('svg-id'), pos, { col: wide, row: (illustrator.elements[sname].closing_symbol ? block.max.row+1 : block.max.row) }, block.svg);
666
+ } else {
667
+ illustrator.draw.draw_border($(context).attr('svg-id'), pos, { col: wide, row: (illustrator.elements[sname].closing_symbol ? block.max.row+1 : block.max.row) }, block.svg);
668
+ }
669
+ }
670
+ if(illustrator.elements[sname] && illustrator.elements[sname].type == 'complex') {
671
+ var wide = (illustrator.elements[sname].wide == true && block.max.col == pos.col) ? pos.col + 1 : block.max.col;
672
+ if (illustrator.elements[sname].closing_symbol) {
673
+ illustrator.draw.draw_tile($(context).attr('svg-id'), pos, { col: wide, row: block.max.row + 1 }, block.svg);
674
+ } else {
675
+ illustrator.draw.draw_tile($(context).attr('svg-id'), pos, { col: wide, row: block.max.row }, block.svg);
676
+ }
677
+ }
678
+ }
679
+ // }}}
680
+ // Calculate Connection {{{
681
+ if(illustrator.elements[sname] != undefined && illustrator.elements[sname].closeblock) { // Close Block if element e.g. loop
682
+ for(node in block.endnodes) {
683
+ if (!block.endnodes[node].final) {
684
+ illustrator.draw.draw_connection(group, block.endnodes[node], pos, block.max.row+1, block.endnodes.length, true);
685
+ }
686
+ }
687
+ }
688
+ if(illustrator.elements[sname] != undefined && illustrator.elements[sname].endnodes != 'this') {
689
+ for(i in block.endnodes) { endnodes.push(block.endnodes[i]); } // collects all endpoints from different childs e.g. alternatives from choose
690
+ } else { endnodes = [jQuery.extend(true, {}, pos)]; } // sets this element as only endpoint (aggregate)
691
+ if(prev[0].row == 0 || prev[0].col == 0) { // this enforces the connection from description to the first element
692
+ illustrator.draw.draw_connection(group, { row: 1, col: 1 }, pos, null, null, true);
693
+ } else {
694
+ if (illustrator.elements[sname].noarrow == undefined || illustrator.elements[sname].noarrow == false) {
695
+ for (node in prev) {
696
+ if (!prev[node].final) {
697
+ if (prev[node].wide) {
698
+ var pn = jQuery.extend(true, {}, prev[node]);
699
+ if (pos.col > prev[node].col) {
700
+ pn.col = pos.col;
701
+ }
702
+ illustrator.draw.draw_connection(group, pn, pos, null, null, true);
703
+ } else {
704
+ illustrator.draw.draw_connection(group, prev[node], pos, null, null, true);
705
+ }
706
+ }
707
+ }
708
+ } else {
709
+ for(node in prev) {
710
+ if (!prev[node].final)
711
+ illustrator.draw.draw_connection(group, prev[node], pos, null, null, false);
712
+ }
713
+ }
714
+ }
715
+ // }}}
716
+ return [g, endnodes];
717
+ } // }}}
718
+ // }}}
631
719
 
632
720
  // Initialze {{{
633
721
  adaptor = wf_adaptor;