DevTools.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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=' + this.view.formatUnitText(parseFloat(geo.x)) + ',' + this.view.formatUnitText(parseFloat(geo.y)) + '<br>' +
  45. // 'size=' + this.view.formatUnitText(parseFloat(geo.width)) + 'x' + this.view.formatUnitText(parseFloat(geo.height));
  46. tip += 'x/y=' + parseFloat(geo.x) + ',' + parseFloat(geo.y) + '<br>' +
  47. 'w/h=' + parseFloat(geo.width) + 'x' + parseFloat(geo.height);
  48. if (state != null)
  49. {
  50. tip += '<br>pos=' + parseFloat(state.x) + ',' + parseFloat(state.y) + '<br>' +
  51. 'size=' + parseFloat(state.width) + 'x' + parseFloat(state.height);
  52. }
  53. }
  54. if (cell.style != null)
  55. {
  56. tip += '<br>style=<div style="display:inline-block;vertical-align:bottom;white-space:nowrap;width:480px;' +
  57. 'overflow:hidden;text-overflow:ellipsis;">' + mxUtils.htmlEntities(cell.style) + '</span>';
  58. }
  59. }
  60. return tip;
  61. };
  62. })();
  63. }