mxUML25.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. /**
  2. * Copyright (c) 2020-2025, JGraph Holdings Ltd
  3. * Copyright (c) 2020-2025, draw.io AG
  4. */
  5. //**********************************************************************************************************************************************************
  6. //Input Pin
  7. //**********************************************************************************************************************************************************
  8. function mxShapeUMLInputPin(bounds, fill, stroke, strokewidth)
  9. {
  10. mxShape.call(this);
  11. this.bounds = bounds;
  12. this.fill = fill;
  13. this.stroke = stroke;
  14. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  15. this.dx = 0.5;
  16. };
  17. /**
  18. * Extends mxShape.
  19. */
  20. mxUtils.extend(mxShapeUMLInputPin, mxActor);
  21. mxShapeUMLInputPin.prototype.cst = {INPUT_PIN : 'mxgraph.uml25.inputPin'};
  22. mxShapeUMLInputPin.prototype.paintVertexShape = function(c, x, y, w, h)
  23. {
  24. c.translate(x, y);
  25. c.begin();
  26. c.moveTo(0, 0);
  27. c.lineTo(w, 0);
  28. c.lineTo(w, h);
  29. c.lineTo(0, h);
  30. c.close();
  31. c.fillAndStroke();
  32. c.setShadow(false);
  33. c.begin();
  34. c.moveTo(w * 0.75, h * 0.5);
  35. c.lineTo(w * 0.25, h * 0.5);
  36. c.moveTo(w * 0.4, h * 0.4);
  37. c.lineTo(w * 0.25, h * 0.5);
  38. c.lineTo(w * 0.4, h * 0.6);
  39. c.stroke();
  40. };
  41. mxCellRenderer.registerShape(mxShapeUMLInputPin.prototype.cst.INPUT_PIN, mxShapeUMLInputPin);
  42. mxShapeUMLInputPin.prototype.constraints = null;
  43. //**********************************************************************************************************************************************************
  44. //Behavior Action
  45. //**********************************************************************************************************************************************************
  46. function mxShapeUMLBehaviorAction(bounds, fill, stroke, strokewidth)
  47. {
  48. mxShape.call(this);
  49. this.bounds = bounds;
  50. this.fill = fill;
  51. this.stroke = stroke;
  52. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  53. this.dx = 0.5;
  54. };
  55. mxUtils.extend(mxShapeUMLBehaviorAction, mxActor);
  56. mxShapeUMLBehaviorAction.prototype.cst = {BEHAVIOR_ACTION : 'mxgraph.uml25.behaviorAction'};
  57. /**
  58. * Function: paintVertexShape
  59. *
  60. * Paints the vertex shape.
  61. */
  62. mxShapeUMLBehaviorAction.prototype.paintVertexShape = function(c, x, y, w, h)
  63. {
  64. c.translate(x, y);
  65. var rounded = mxUtils.getValue(this.style, 'rounded', false);
  66. var absArcSize = mxUtils.getValue(this.style, 'absoluteArcSize', false);
  67. var arcSize = parseFloat(mxUtils.getValue(this.style, 'arcSize', this.arcSize));
  68. if (!absArcSize)
  69. {
  70. arcSize = Math.min(w, h) * arcSize;
  71. }
  72. arcSize = Math.min(arcSize, w * 0.5, h * 0.5);
  73. if (!rounded)
  74. {
  75. arcSize = 0;
  76. }
  77. c.begin();
  78. if (rounded)
  79. {
  80. c.moveTo(0, arcSize);
  81. c.arcTo(arcSize, arcSize, 0, 0, 1, arcSize, 0);
  82. c.lineTo(w - arcSize, 0);
  83. c.arcTo(arcSize, arcSize, 0, 0, 1, w, arcSize);
  84. c.lineTo(w, h - arcSize);
  85. c.arcTo(arcSize, arcSize, 0, 0, 1, w - arcSize, h);
  86. c.lineTo(arcSize, h);
  87. c.arcTo(arcSize, arcSize, 0, 0, 1, 0, h - arcSize);
  88. }
  89. else
  90. {
  91. c.moveTo(0, 0);
  92. c.lineTo(w, 0);
  93. c.lineTo(w, h);
  94. c.lineTo(0, h);
  95. }
  96. c.close();
  97. c.fillAndStroke();
  98. c.setShadow(false);
  99. if (w >= 60 && h >= 40)
  100. {
  101. c.begin();
  102. c.moveTo(w - 60, h * 0.5 + 20);
  103. c.lineTo(w - 60, h * 0.5);
  104. c.lineTo(w - 20, h * 0.5);
  105. c.lineTo(w - 20, h * 0.5 + 20);
  106. c.moveTo(w - 40, h * 0.5 - 20);
  107. c.lineTo(w - 40, h * 0.5 + 20);
  108. c.stroke();
  109. }
  110. };
  111. mxCellRenderer.registerShape(mxShapeUMLBehaviorAction.prototype.cst.BEHAVIOR_ACTION, mxShapeUMLBehaviorAction);
  112. mxShapeUMLBehaviorAction.prototype.constraints = null;
  113. //**********************************************************************************************************************************************************
  114. //Action
  115. //**********************************************************************************************************************************************************
  116. /**
  117. * Extends mxShape.
  118. */
  119. function mxShapeUMLAction(bounds, fill, stroke, strokewidth)
  120. {
  121. mxShape.call(this);
  122. this.bounds = bounds;
  123. this.fill = fill;
  124. this.stroke = stroke;
  125. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  126. this.dx = 0.5;
  127. };
  128. /**
  129. * Extends mxShape.
  130. */
  131. mxUtils.extend(mxShapeUMLAction, mxActor);
  132. mxShapeUMLAction.prototype.cst = {ACTION : 'mxgraph.uml25.action'};
  133. /**
  134. * Function: paintVertexShape
  135. *
  136. * Paints the vertex shape.
  137. */
  138. mxShapeUMLAction.prototype.paintVertexShape = function(c, x, y, w, h)
  139. {
  140. c.translate(x, y);
  141. var absArcSize = mxUtils.getValue(this.style, 'absoluteArcSize', false);
  142. var arcSize = parseFloat(mxUtils.getValue(this.style, 'arcSize', this.arcSize));
  143. if (!absArcSize)
  144. {
  145. arcSize = Math.min(w, h) * arcSize;
  146. }
  147. arcSize = Math.min(arcSize, w * 0.5, h * 0.5);
  148. c.begin();
  149. c.moveTo(0, arcSize);
  150. c.arcTo(arcSize, arcSize, 0, 0, 1, arcSize, 0);
  151. c.lineTo(w - arcSize - 10, 0);
  152. c.arcTo(arcSize, arcSize, 0, 0, 1, w - 10, arcSize);
  153. c.lineTo(w - 10, h - arcSize);
  154. c.arcTo(arcSize, arcSize, 0, 0, 1, w - arcSize - 10, h);
  155. c.lineTo(arcSize, h);
  156. c.arcTo(arcSize, arcSize, 0, 0, 1, 0, h - arcSize);
  157. c.close();
  158. c.fillAndStroke();
  159. c.rect(w - 10, h * 0.5 - 10, 10, 20);
  160. c.fillAndStroke();
  161. };
  162. mxCellRenderer.registerShape(mxShapeUMLAction.prototype.cst.ACTION, mxShapeUMLAction);
  163. mxShapeUMLAction.prototype.constraints = null;
  164. //**********************************************************************************************************************************************************
  165. //Action with parameters
  166. //**********************************************************************************************************************************************************
  167. /**
  168. * Extends mxShape.
  169. */
  170. function mxShapeUMLActionParams(bounds, fill, stroke, strokewidth)
  171. {
  172. mxShape.call(this);
  173. this.bounds = bounds;
  174. this.fill = fill;
  175. this.stroke = stroke;
  176. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  177. this.dx = 0.5;
  178. };
  179. /**
  180. * Extends mxShape.
  181. */
  182. mxUtils.extend(mxShapeUMLActionParams, mxActor);
  183. mxShapeUMLActionParams.prototype.cst = {ACTION_PARAMS : 'mxgraph.uml25.actionParams'};
  184. /**
  185. * Function: paintVertexShape
  186. *
  187. * Paints the vertex shape.
  188. */
  189. mxShapeUMLActionParams.prototype.paintVertexShape = function(c, x, y, w, h)
  190. {
  191. c.translate(x, y);
  192. var absArcSize = mxUtils.getValue(this.style, 'absoluteArcSize', false);
  193. var arcSize = parseFloat(mxUtils.getValue(this.style, 'arcSize', this.arcSize));
  194. if (!absArcSize)
  195. {
  196. arcSize = Math.min(w, h) * arcSize;
  197. }
  198. arcSize = Math.min(arcSize, w * 0.5, h * 0.5);
  199. c.begin();
  200. c.moveTo(20, arcSize);
  201. c.arcTo(arcSize, arcSize, 0, 0, 1, 20 + arcSize, 0);
  202. c.lineTo(w - arcSize, 0);
  203. c.arcTo(arcSize, arcSize, 0, 0, 1, w, arcSize);
  204. c.lineTo(w, h - arcSize);
  205. c.arcTo(arcSize, arcSize, 0, 0, 1, w - arcSize, h);
  206. c.lineTo(20 + arcSize, h);
  207. c.arcTo(arcSize, arcSize, 0, 0, 1, 20, h - arcSize);
  208. c.close();
  209. c.fillAndStroke();
  210. c.rect(5, h * 0.5 - 17, 20, 34);
  211. c.fillAndStroke();
  212. c.rect(0, h * 0.5 - 13, 10, 10);
  213. c.fillAndStroke();
  214. c.rect(0, h * 0.5 + 3, 10, 10);
  215. c.fillAndStroke();
  216. };
  217. mxCellRenderer.registerShape(mxShapeUMLActionParams.prototype.cst.ACTION_PARAMS, mxShapeUMLActionParams);
  218. mxShapeUMLActionParams.prototype.constraints = null;