mxC4.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. /**
  2. * Copyright (c) 2006-2018, JGraph Holdings Ltd
  3. */
  4. //**********************************************************************************************************************************************************
  5. // Person
  6. //**********************************************************************************************************************************************************
  7. /**
  8. * Extends mxShape.
  9. */
  10. function mxShapeC4Person(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(mxShapeC4Person, mxShape);
  22. mxShapeC4Person.prototype.cst = {PERSONSHAPE : 'mxgraph.c4.person'};
  23. /**
  24. * Function: paintVertexShape
  25. *
  26. * Paints the vertex shape.
  27. */
  28. mxShapeC4Person.prototype.paintVertexShape = function(c, x, y, w, h)
  29. {
  30. c.translate(x, y);
  31. var headSize = Math.min(w / 2, h / 3);
  32. var r = headSize / 2;
  33. c.ellipse(w * 0.5 - headSize * 0.5, 0, headSize, headSize);
  34. c.fillAndStroke();
  35. c.begin();
  36. c.moveTo(0, headSize * 0.8 + r);
  37. c.arcTo(r, r, 0, 0, 1, r, headSize * 0.8);
  38. c.lineTo(w - r, headSize * 0.8);
  39. c.arcTo(r, r, 0, 0, 1, w, headSize * 0.8 + r);
  40. c.lineTo(w, h - r);
  41. c.arcTo(r, r, 0, 0, 1, w - r, h);
  42. c.lineTo(r, h);
  43. c.arcTo(r, r, 0, 0, 1, 0, h -r);
  44. c.close();
  45. c.fillAndStroke();
  46. c.setShadow(false);
  47. c.ellipse(w * 0.5 - headSize * 0.5, 0, headSize, headSize);
  48. c.fillAndStroke();
  49. };
  50. mxShapeC4Person.prototype.getLabelMargins = function(rect)
  51. {
  52. var headSize = Math.min(rect.width / 2, rect.height / 3);
  53. return new mxRectangle(0, headSize * 0.8, 0, 0);
  54. };
  55. mxCellRenderer.registerShape(mxShapeC4Person.prototype.cst.PERSONSHAPE, mxShapeC4Person);
  56. //**********************************************************************************************************************************************************
  57. // Person
  58. //**********************************************************************************************************************************************************
  59. /**
  60. * Extends mxShape.
  61. */
  62. function mxShapeC4Person2(bounds, fill, stroke, strokewidth)
  63. {
  64. mxShape.call(this);
  65. this.bounds = bounds;
  66. this.fill = fill;
  67. this.stroke = stroke;
  68. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  69. };
  70. /**
  71. * Extends mxShape.
  72. */
  73. mxUtils.extend(mxShapeC4Person2, mxShape);
  74. mxShapeC4Person2.prototype.cst = {PERSONSHAPE : 'mxgraph.c4.person2'};
  75. /**
  76. * Function: paintVertexShape
  77. *
  78. * Paints the vertex shape.
  79. */
  80. mxShapeC4Person2.prototype.paintVertexShape = function(c, x, y, w, h)
  81. {
  82. c.translate(x, y);
  83. var headSize = Math.min(w * 0.45, h * 0.45);
  84. var r = headSize / 2;
  85. c.ellipse(w * 0.5 - headSize * 0.5, 0, headSize, headSize);
  86. c.fillAndStroke();
  87. c.begin();
  88. c.moveTo(0, headSize * 0.8 + r);
  89. c.arcTo(r, r, 0, 0, 1, r, headSize * 0.8);
  90. c.lineTo(w - r, headSize * 0.8);
  91. c.arcTo(r, r, 0, 0, 1, w, headSize * 0.8 + r);
  92. c.lineTo(w, h - r);
  93. c.arcTo(r, r, 0, 0, 1, w - r, h);
  94. c.lineTo(r, h);
  95. c.arcTo(r, r, 0, 0, 1, 0, h -r);
  96. c.close();
  97. c.fillAndStroke();
  98. c.setShadow(false);
  99. c.ellipse(w * 0.5 - headSize * 0.5, 0, headSize, headSize);
  100. c.fillAndStroke();
  101. };
  102. mxShapeC4Person2.prototype.getLabelMargins = function(rect)
  103. {
  104. var headSize = Math.min(rect.width * 0.45, rect.height * 0.45);
  105. return new mxRectangle(0, headSize * 0.8, 0, 0);
  106. };
  107. mxCellRenderer.registerShape(mxShapeC4Person2.prototype.cst.PERSONSHAPE , mxShapeC4Person2);
  108. //**********************************************************************************************************************************************************
  109. // Web Browser Container
  110. //**********************************************************************************************************************************************************
  111. /**
  112. * Extends mxShape.
  113. */
  114. function mxShapeC4WebBrowserContainer(bounds, fill, stroke, strokewidth)
  115. {
  116. mxShape.call(this);
  117. this.bounds = bounds;
  118. this.fill = fill;
  119. this.stroke = stroke;
  120. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  121. };
  122. /**
  123. * Extends mxShape.
  124. */
  125. mxUtils.extend(mxShapeC4WebBrowserContainer, mxShape);
  126. mxShapeC4WebBrowserContainer.prototype.cst = {WEB_BROWSER_CONTAINER_SHAPE : 'mxgraph.c4.webBrowserContainer'};
  127. /**
  128. * Function: paintVertexShape
  129. *
  130. * Paints the vertex shape.
  131. */
  132. mxShapeC4WebBrowserContainer.prototype.paintVertexShape = function(c, x, y, w, h)
  133. {
  134. c.translate(x, y);
  135. var r = 8;
  136. c.begin();
  137. c.moveTo(0, r);
  138. c.arcTo(r, r, 0, 0, 1, r, 0);
  139. c.lineTo(w - r, 0);
  140. c.arcTo(r, r, 0, 0, 1, w, r);
  141. c.lineTo(w, h - r);
  142. c.arcTo(r, r, 0, 0, 1, w - r, h);
  143. c.lineTo(r, h);
  144. c.arcTo(r, r, 0, 0, 1, 0, h - r);
  145. c.close();
  146. c.fillAndStroke();
  147. c.setShadow(false);
  148. var ins = 5;
  149. var r2 = 3;
  150. var h2 = 12;
  151. if (w > (ins * 5 + h2 * 3) && h > (2 * h2 + 3 * ins))
  152. {
  153. c.setFillColor('#23A2D9');
  154. c.begin();
  155. c.moveTo(ins, ins + r2);
  156. c.arcTo(r2, r2, 0, 0, 1, ins + r2, ins);
  157. c.lineTo(w - 3 * h2 - 4 * ins - r2, ins);
  158. c.arcTo(r2, r2, 0, 0, 1, w - 3 * h2 - 4 * ins, ins + r2);
  159. c.lineTo(w - 3 * h2 - 4 * ins, ins + h2 - r2);
  160. c.arcTo(r2, r2, 0, 0, 1, w - 3 * h2 - 4 * ins - r2, ins + h2);
  161. c.lineTo(ins + r2, ins + h2);
  162. c.arcTo(r2, r2, 0, 0, 1, ins, ins + h2 - r2);
  163. c.close();
  164. c.moveTo(w - 3 * h2 - 3 * ins, ins + r2);
  165. c.arcTo(r2, r2, 0, 0, 1, w - 3 * h2 - 3 * ins + r2, ins);
  166. c.lineTo(w - 2 * h2 - 3 * ins - r2, ins);
  167. c.arcTo(r2, r2, 0, 0, 1, w - 2 * h2 - 3 * ins, ins + r2);
  168. c.lineTo(w - 2 * h2 - 3 * ins, ins + h2 - r2);
  169. c.arcTo(r2, r2, 0, 0, 1, w - 2 * h2 - 3 * ins - r2, ins + h2);
  170. c.lineTo(w - 3 * h2 - 3 * ins + r2, ins + h2);
  171. c.arcTo(r2, r2, 0, 0, 1, w - 3 * h2 - 3 * ins, ins + h2 - r2);
  172. c.close();
  173. c.moveTo(w - 2 * h2 - 2 * ins, ins + r2);
  174. c.arcTo(r2, r2, 0, 0, 1, w - 2 * h2 - 2 * ins + r2, ins);
  175. c.lineTo(w - h2 - 2 * ins - r2, ins);
  176. c.arcTo(r2, r2, 0, 0, 1, w - h2 - 2 * ins, ins + r2);
  177. c.lineTo(w - h2 - 2 * ins, ins + h2 - r2);
  178. c.arcTo(r2, r2, 0, 0, 1, w - h2 - 2 * ins - r2, ins + h2);
  179. c.lineTo(w - 2 * h2 - 2 * ins + r2, ins + h2);
  180. c.arcTo(r2, r2, 0, 0, 1, w - 2 * h2 - 2 * ins, ins + h2 - r2);
  181. c.close();
  182. c.moveTo(w - h2 - ins, ins + r2);
  183. c.arcTo(r2, r2, 0, 0, 1, w - h2 - ins + r2, ins);
  184. c.lineTo(w - ins - r2, ins);
  185. c.arcTo(r2, r2, 0, 0, 1, w - ins, ins + r2);
  186. c.lineTo(w - ins, ins + h2 - r2);
  187. c.arcTo(r2, r2, 0, 0, 1, w - ins - r2, ins + h2);
  188. c.lineTo(w - h2 - ins + r2, ins + h2);
  189. c.arcTo(r2, r2, 0, 0, 1, w - h2 - ins, ins + h2 - r2);
  190. c.close();
  191. c.moveTo(ins, h2 + 2 * ins + r);
  192. c.arcTo(r, r, 0, 0, 1, ins + r, h2 + 2 * ins);
  193. c.lineTo(w - r - ins, h2 + 2 * ins);
  194. c.arcTo(r, r, 0, 0, 1, w - ins, h2 + 2 * ins + r);
  195. c.lineTo(w - ins, h - r - ins);
  196. c.arcTo(r, r, 0, 0, 1, w - r - ins, h - ins);
  197. c.lineTo(ins + r, h - ins);
  198. c.arcTo(r, r, 0, 0, 1, ins, h - r - ins);
  199. c.close();
  200. c.fill();
  201. c.fill();
  202. }
  203. };
  204. mxCellRenderer.registerShape(mxShapeC4WebBrowserContainer.prototype.cst.WEB_BROWSER_CONTAINER_SHAPE, mxShapeC4WebBrowserContainer);
  205. //**********************************************************************************************************************************************************
  206. // Web Browser Container v2
  207. //**********************************************************************************************************************************************************
  208. /**
  209. * Extends mxShape.
  210. */
  211. function mxShapeC4WebBrowserContainer2(bounds, fill, stroke, strokewidth)
  212. {
  213. mxShape.call(this);
  214. this.bounds = bounds;
  215. this.fill = fill;
  216. this.stroke = stroke;
  217. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  218. };
  219. /**
  220. * Extends mxShape.
  221. */
  222. mxUtils.extend(mxShapeC4WebBrowserContainer2, mxShape);
  223. mxShapeC4WebBrowserContainer2.prototype.cst = {WEB_BROWSER_CONTAINER2_SHAPE : 'mxgraph.c4.webBrowserContainer2'};
  224. mxShapeC4WebBrowserContainer2.prototype.customProperties = [
  225. {name: 'strokeColor2', dispName: 'Outline color', type: 'color', defVal: '#0E7DAD'}
  226. ];
  227. /**
  228. * Function: paintVertexShape
  229. *
  230. * Paints the vertex shape.
  231. */
  232. mxShapeC4WebBrowserContainer2.prototype.paintVertexShape = function(c, x, y, w, h)
  233. {
  234. c.translate(x, y);
  235. var r = 8;
  236. var fillColor = mxUtils.getValue(this.state.style, 'fillColor', '#ffffff');
  237. var strokeColor = mxUtils.getValue(this.state.style, 'strokeColor', '#000000');
  238. var strokeColor2 = mxUtils.getValue(this.state.style, 'strokeColor2', '#0E7DAD');
  239. c.setStrokeColor(strokeColor2);
  240. c.setFillColor(strokeColor);
  241. c.begin();
  242. c.moveTo(0, r);
  243. c.arcTo(r, r, 0, 0, 1, r, 0);
  244. c.lineTo(w - r, 0);
  245. c.arcTo(r, r, 0, 0, 1, w, r);
  246. c.lineTo(w, h - r);
  247. c.arcTo(r, r, 0, 0, 1, w - r, h);
  248. c.lineTo(r, h);
  249. c.arcTo(r, r, 0, 0, 1, 0, h - r);
  250. c.close();
  251. c.fillAndStroke();
  252. c.setShadow(false);
  253. var ins = 5;
  254. var r2 = 3;
  255. var h2 = 12;
  256. if (w > (ins * 5 + h2 * 3) && h > (2 * h2 + 3 * ins))
  257. {
  258. //set fill color to fill color
  259. c.setFillColor(fillColor);
  260. c.begin();
  261. c.moveTo(ins, ins + r2);
  262. c.arcTo(r2, r2, 0, 0, 1, ins + r2, ins);
  263. c.lineTo(w - 3 * h2 - 4 * ins - r2, ins);
  264. c.arcTo(r2, r2, 0, 0, 1, w - 3 * h2 - 4 * ins, ins + r2);
  265. c.lineTo(w - 3 * h2 - 4 * ins, ins + h2 - r2);
  266. c.arcTo(r2, r2, 0, 0, 1, w - 3 * h2 - 4 * ins - r2, ins + h2);
  267. c.lineTo(ins + r2, ins + h2);
  268. c.arcTo(r2, r2, 0, 0, 1, ins, ins + h2 - r2);
  269. c.close();
  270. c.moveTo(w - 3 * h2 - 3 * ins, ins + r2);
  271. c.arcTo(r2, r2, 0, 0, 1, w - 3 * h2 - 3 * ins + r2, ins);
  272. c.lineTo(w - 2 * h2 - 3 * ins - r2, ins);
  273. c.arcTo(r2, r2, 0, 0, 1, w - 2 * h2 - 3 * ins, ins + r2);
  274. c.lineTo(w - 2 * h2 - 3 * ins, ins + h2 - r2);
  275. c.arcTo(r2, r2, 0, 0, 1, w - 2 * h2 - 3 * ins - r2, ins + h2);
  276. c.lineTo(w - 3 * h2 - 3 * ins + r2, ins + h2);
  277. c.arcTo(r2, r2, 0, 0, 1, w - 3 * h2 - 3 * ins, ins + h2 - r2);
  278. c.close();
  279. c.moveTo(w - 2 * h2 - 2 * ins, ins + r2);
  280. c.arcTo(r2, r2, 0, 0, 1, w - 2 * h2 - 2 * ins + r2, ins);
  281. c.lineTo(w - h2 - 2 * ins - r2, ins);
  282. c.arcTo(r2, r2, 0, 0, 1, w - h2 - 2 * ins, ins + r2);
  283. c.lineTo(w - h2 - 2 * ins, ins + h2 - r2);
  284. c.arcTo(r2, r2, 0, 0, 1, w - h2 - 2 * ins - r2, ins + h2);
  285. c.lineTo(w - 2 * h2 - 2 * ins + r2, ins + h2);
  286. c.arcTo(r2, r2, 0, 0, 1, w - 2 * h2 - 2 * ins, ins + h2 - r2);
  287. c.close();
  288. c.moveTo(w - h2 - ins, ins + r2);
  289. c.arcTo(r2, r2, 0, 0, 1, w - h2 - ins + r2, ins);
  290. c.lineTo(w - ins - r2, ins);
  291. c.arcTo(r2, r2, 0, 0, 1, w - ins, ins + r2);
  292. c.lineTo(w - ins, ins + h2 - r2);
  293. c.arcTo(r2, r2, 0, 0, 1, w - ins - r2, ins + h2);
  294. c.lineTo(w - h2 - ins + r2, ins + h2);
  295. c.arcTo(r2, r2, 0, 0, 1, w - h2 - ins, ins + h2 - r2);
  296. c.close();
  297. c.moveTo(ins, h2 + 2 * ins + r);
  298. c.arcTo(r, r, 0, 0, 1, ins + r, h2 + 2 * ins);
  299. c.lineTo(w - r - ins, h2 + 2 * ins);
  300. c.arcTo(r, r, 0, 0, 1, w - ins, h2 + 2 * ins + r);
  301. c.lineTo(w - ins, h - r - ins);
  302. c.arcTo(r, r, 0, 0, 1, w - r - ins, h - ins);
  303. c.lineTo(ins + r, h - ins);
  304. c.arcTo(r, r, 0, 0, 1, ins, h - r - ins);
  305. c.close();
  306. c.fill();
  307. c.fill();
  308. }
  309. };
  310. mxCellRenderer.registerShape(mxShapeC4WebBrowserContainer2.prototype.cst.WEB_BROWSER_CONTAINER2_SHAPE, mxShapeC4WebBrowserContainer2);