mxUML25.js 6.9 KB

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