mxFlowchart.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /**
  2. * $Id: mxFlowchart.js,v 1.5 2016/04/1 12:32:06 mate Exp $
  3. * Copyright (c) 2006-2018, JGraph Ltd
  4. */
  5. //**********************************************************************************************************************************************************
  6. // Document 2
  7. //**********************************************************************************************************************************************************
  8. /**
  9. * Extends mxShape.
  10. */
  11. function mxShapeFlowchartDocument2(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. this.size = 0.5;
  19. };
  20. /**
  21. * Extends mxShape.
  22. */
  23. mxUtils.extend(mxShapeFlowchartDocument2, mxActor);
  24. mxShapeFlowchartDocument2.prototype.cst = {DOCUMENT2 : 'mxgraph.flowchart.document2'};
  25. mxShapeFlowchartDocument2.prototype.customProperties = [
  26. {name: 'size', dispName: 'Wave Size', type: 'float', min:0, max:1, defVal:0.25},
  27. ];
  28. /**
  29. * Function: paintVertexShape
  30. *
  31. * Paints the vertex shape.
  32. */
  33. mxShapeFlowchartDocument2.prototype.paintVertexShape = function(c, x, y, w, h)
  34. {
  35. c.translate(x, y);
  36. var dy = h * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  37. var fy = 1.4;
  38. var r = 5;
  39. c.begin();
  40. c.moveTo(w - r, 0);
  41. c.arcTo(r, r, 0, 0, 1, w, r);
  42. c.lineTo(w, h - dy / 2);
  43. c.quadTo(w * 3 / 4, h - dy * fy, w / 2, h - dy / 2);
  44. c.quadTo(w / 4, h - dy * (1 - fy), 0, h - dy / 2);
  45. c.lineTo(0, dy / 2);
  46. c.lineTo(0, r);
  47. c.arcTo(r, r, 0, 0, 1, r, 0);
  48. c.close();
  49. c.fillAndStroke();
  50. };
  51. mxCellRenderer.registerShape(mxShapeFlowchartDocument2.prototype.cst.DOCUMENT2, mxShapeFlowchartDocument2);
  52. mxShapeFlowchartDocument2.prototype.constraints =
  53. [new mxConnectionConstraint(new mxPoint(0.25, 0), false),
  54. new mxConnectionConstraint(new mxPoint(0.5, 0), false),
  55. new mxConnectionConstraint(new mxPoint(0.75, 0), false),
  56. new mxConnectionConstraint(new mxPoint(0, 0.25), false),
  57. new mxConnectionConstraint(new mxPoint(0, 0.5), false),
  58. new mxConnectionConstraint(new mxPoint(0, 0.75), false),
  59. new mxConnectionConstraint(new mxPoint(1, 0.25), false),
  60. new mxConnectionConstraint(new mxPoint(1, 0.5), false),
  61. new mxConnectionConstraint(new mxPoint(1, 0.75), false)];
  62. Graph.handleFactory[mxShapeFlowchartDocument2.prototype.cst.DOCUMENT2] = function(state)
  63. {
  64. var handles = [Graph.createHandle(state, ['size'], function(bounds)
  65. {
  66. var size = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'size', this.size))));
  67. return new mxPoint(bounds.x + 3 * bounds.width / 4, bounds.y + (1 - size) * bounds.height);
  68. }, function(bounds, pt)
  69. {
  70. this.state.style['size'] = Math.max(0, Math.min(1, (bounds.y + bounds.height - pt.y) / bounds.height));
  71. })];
  72. return handles;
  73. };