DevTools.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. if (urlParams['dev'] == '1')
  2. {
  3. (function()
  4. {
  5. var graphGetTooltipForCell = Graph.prototype.getTooltipForCell;
  6. /**
  7. * Overrides tooltips to show custom tooltip or metadata.
  8. */
  9. Graph.prototype.getTooltipForCell = function(cell)
  10. {
  11. var tip = graphGetTooltipForCell.apply(this, arguments);
  12. var geo = this.getCellGeometry(cell);
  13. tip += ((tip.length > 0) ? '<br>' : '') + 'id=' + cell.id + '<br>';
  14. if (geo != null)
  15. {
  16. if (geo.sourcePoint != null)
  17. {
  18. tip += 'source=' + parseFloat(geo.sourcePoint.x) + ',' + parseFloat(geo.sourcePoint.y) + '<br>';
  19. }
  20. if (geo.targetPoint != null)
  21. {
  22. tip += 'target=' + parseFloat(geo.targetPoint.x) + ',' + parseFloat(geo.targetPoint.y) + '<br>';
  23. }
  24. var state = this.view.getState(cell);
  25. if (state != null && state.absolutePoints != null)
  26. {
  27. tip += 'abspoints(' + state.absolutePoints.length + ')=';
  28. for (var i = 0; i < state.absolutePoints.length; i++)
  29. {
  30. tip += parseFloat(state.absolutePoints[i].x) + ',' + parseFloat(state.absolutePoints[i].y) + ';';
  31. }
  32. tip += '<br>';
  33. if (geo.points != null)
  34. {
  35. tip += 'points=(' + geo.points.length + ')=';
  36. for (var i = 0; i < geo.points.length; i++)
  37. {
  38. tip += parseFloat(geo.points[i].x) + ',' + parseFloat(geo.points[i].y) + ';';
  39. }
  40. }
  41. }
  42. else
  43. {
  44. tip += 'pos=' + parseFloat(geo.x) + ',' + parseFloat(geo.y) + '<br>' +
  45. 'size=' + parseFloat(geo.width) + 'x' + parseFloat(geo.height);
  46. }
  47. }
  48. return tip;
  49. };
  50. })();
  51. }