mxSAP.js 2.2 KB

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