draw.js~ 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. function changelines(fcolor,tcolor) {
  2. var conn = $('#graphcolumn .draw .lines .conn-' + fcolor);
  3. conn.removeClass('conn-' + fcolor);
  4. conn.addClass('conn-' + tcolor);
  5. }
  6. function drawline(from,to,between,color) {
  7. var nfrom = $('#graphcolumn .draw g.node[data-id=' + from + ']');
  8. var nto = $('#graphcolumn .draw g.node[data-id=' + to + ']');
  9. var conn = $('#graphcolumn .draw defs .conn-' + color).clone();
  10. var points = [];
  11. var devx = 3.9;
  12. var devy = 1.5;
  13. points.push((parseInt(nfrom.data('x')) + devx) + ',' + (parseInt(nfrom.data('y')) + devy));
  14. $(between).each(function(k,val){
  15. if (val[0] == 'f') { val[0] = parseInt(nfrom.data('x')) + devx; }
  16. if (val[1] == 'f') { val[1] = parseInt(nfrom.data('y')) + devy; }
  17. if (val[0] == 't') { val[0] = parseInt(nto.data('x')) + devx; }
  18. if (val[1] == 't') { val[1] = parseInt(nto.data('y')) + devy; }
  19. points.push(val.join(','));
  20. });
  21. points.push((parseInt(nto.data('x')) + devx) + ',' + (parseInt(nto.data('y')) + devy));
  22. conn.attr('points',points.join(' '));
  23. $('#graphcolumn .draw .lines').append(conn);
  24. }
  25. function drawnode(id,x,y,text) {
  26. var clonode = $('#graphcolumn .draw defs .node').clone();
  27. clonode.attr('transform','translate(' + x + ' ' + y +')');
  28. clonode.attr('data-id',id);
  29. clonode.attr('data-x',x);
  30. clonode.attr('data-y',y);
  31. $(text.split('\n')).each(function(k1,val1){
  32. var tspan = $('#graphcolumn .draw defs .text').clone();
  33. tspan.text(val1);
  34. $(clonode).find('text').append(tspan);
  35. });
  36. $('#graphcolumn .draw .texts').append(clonode);
  37. }