mxSAP.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /**
  2. * Copyright (c) 2006-2016, JGraph Holdings Ltd
  3. */
  4. //**********************************************************************************************************************************************************
  5. //Icon
  6. //**********************************************************************************************************************************************************
  7. /**
  8. * Extends mxShape.
  9. */
  10. function mxSAPIconShape(bounds, fill, stroke, strokewidth)
  11. {
  12. mxShape.call(this);
  13. this.bounds = bounds;
  14. this.fill = fill;
  15. this.stroke = stroke;
  16. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  17. };
  18. /**
  19. * Extends mxShape.
  20. */
  21. mxUtils.extend(mxSAPIconShape, mxShape);
  22. mxSAPIconShape.prototype.cst = {
  23. ICON : 'mxgraph.sap.icon'
  24. };
  25. /**
  26. * Function: paintVertexShape
  27. *
  28. * Paints the vertex shape.
  29. */
  30. mxSAPIconShape.prototype.paintVertexShape = function(c, x, y, w, h)
  31. {
  32. c.translate(x, y);
  33. this.background(c, 0, 0, w, h);
  34. c.setShadow(false);
  35. this.foreground(c, 0, 0, w, h);
  36. };
  37. mxSAPIconShape.prototype.background = function(c, x, y, w, h)
  38. {
  39. c.ellipse(0, 0, w, h);
  40. c.fillAndStroke();
  41. };
  42. mxSAPIconShape.prototype.foreground = function(c, x, y, w, h)
  43. {
  44. var sapIcon = mxUtils.getValue(this.style, 'SAPIcon', '');
  45. c.image(w * 0.2, h * 0.2, w * 0.6, h * 0.6, GRAPH_IMAGE_PATH + '/lib/sap/' + sapIcon + '.svg');
  46. };
  47. mxCellRenderer.registerShape(mxSAPIconShape.prototype.cst.ICON, mxSAPIconShape);
  48. mxSAPIconShape.prototype.getConstraints = function(style, w, h)
  49. {
  50. var constr = [];
  51. constr.push(new mxConnectionConstraint(new mxPoint(0.625, 0), false));
  52. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  53. constr.push(new mxConnectionConstraint(new mxPoint(0.625, 1), false));
  54. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.325), false));
  55. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.675), false));
  56. constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false));
  57. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
  58. constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false));
  59. constr.push(new mxConnectionConstraint(new mxPoint(0.25, 1), false));
  60. return (constr);
  61. };