mxAWS4.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. /**
  2. * Copyright (c) 2006-2018, JGraph Holdings Ltd
  3. */
  4. //**********************************************************************************************************************************************************
  5. //Product Icon
  6. //**********************************************************************************************************************************************************
  7. /**
  8. * Extends mxShape.
  9. */
  10. function mxShapeAws4ProductIcon(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(mxShapeAws4ProductIcon, mxShape);
  22. mxShapeAws4ProductIcon.prototype.cst = {
  23. PRODUCT_ICON : 'mxgraph.aws4.productIcon'
  24. };
  25. /**
  26. * Function: paintVertexShape
  27. *
  28. * Paints the vertex shape.
  29. */
  30. mxShapeAws4ProductIcon.prototype.paintVertexShape = function(c, x, y, w, h)
  31. {
  32. c.translate(x, y);
  33. var opacity = parseFloat(mxUtils.getValue(this.style, 'opacity', '100'));
  34. var op1 = opacity;
  35. var op2 = opacity;
  36. if (fillColor == 'none')
  37. {
  38. op1 = 0;
  39. }
  40. if (gradientColor == 'none')
  41. {
  42. op2 = 0;
  43. }
  44. var ind = 1;
  45. var strokeColor = mxUtils.getValue(this.state.style, 'strokeColor', 'none');
  46. c.setFillColor(strokeColor);
  47. c.begin();
  48. c.moveTo(0, 0);
  49. c.lineTo(w, 0);
  50. c.lineTo(w, h);
  51. c.lineTo(0, h);
  52. c.close();
  53. c.fill();
  54. c.setShadow(false);
  55. var fillColor = mxUtils.getValue(this.state.style, 'fillColor', '#ffffff');
  56. var gradientColor = mxUtils.getValue(this.state.style, 'gradientColor', fillColor);
  57. var gradientDir = mxUtils.getValue(this.state.style, 'gradientDirection', 'south');
  58. c.setFillColor(fillColor);
  59. c.setGradient(fillColor, gradientColor, 0, 0, w, h, gradientDir, op1, op2);
  60. c.begin();
  61. c.moveTo(ind, ind);
  62. c.lineTo(w - ind, ind);
  63. c.lineTo(w - ind, w - ind);
  64. c.lineTo(ind, w - ind);
  65. c.close();
  66. c.fill();
  67. var prIcon = mxUtils.getValue(this.state.style, 'prIcon', '');
  68. var stencil = mxStencilRegistry.getStencil(prIcon);
  69. if (stencil != null)
  70. {
  71. c.setFillColor(strokeColor);
  72. c.setStrokeColor('none');
  73. // stencil.drawShape(c, this, w * 0.1, h * 0.1, w * 0.8, h * 0.8);
  74. stencil.drawShape(c, this, ind + w * 0.15, ind + w * 0.15, w * 0.7 - 2 * ind, w * 0.7 - 2 * ind);
  75. }
  76. };
  77. mxCellRenderer.registerShape(mxShapeAws4ProductIcon.prototype.cst.PRODUCT_ICON, mxShapeAws4ProductIcon);
  78. //**********************************************************************************************************************************************************
  79. //Resource Icon
  80. //**********************************************************************************************************************************************************
  81. /**
  82. * Extends mxShape.
  83. */
  84. function mxShapeAws4ResourceIcon(bounds, fill, stroke, strokewidth)
  85. {
  86. mxShape.call(this);
  87. this.bounds = bounds;
  88. this.fill = fill;
  89. this.stroke = stroke;
  90. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  91. };
  92. /**
  93. * Extends mxShape.
  94. */
  95. mxUtils.extend(mxShapeAws4ResourceIcon, mxShape);
  96. mxShapeAws4ResourceIcon.prototype.cst = {
  97. RESOURCE_ICON : 'mxgraph.aws4.resourceIcon'
  98. };
  99. /**
  100. * Function: paintVertexShape
  101. *
  102. * Paints the vertex shape.
  103. */
  104. mxShapeAws4ResourceIcon.prototype.paintVertexShape = function(c, x, y, w, h)
  105. {
  106. c.translate(x, y);
  107. c.begin();
  108. c.moveTo(0, 0);
  109. c.lineTo(w, 0);
  110. c.lineTo(w, h);
  111. c.lineTo(0, h);
  112. c.close();
  113. c.fill();
  114. c.setShadow(false);
  115. var prIcon = mxUtils.getValue(this.state.style, 'resIcon', '');
  116. var stencil = mxStencilRegistry.getStencil(prIcon);
  117. if (stencil != null)
  118. {
  119. var strokeColor = mxUtils.getValue(this.state.style, 'strokeColor', '#000000');
  120. c.setFillColor(strokeColor);
  121. c.setStrokeColor('none');
  122. stencil.drawShape(c, this, w * 0.1, h * 0.1, w * 0.8, h * 0.8);
  123. }
  124. };
  125. mxCellRenderer.registerShape(mxShapeAws4ResourceIcon.prototype.cst.RESOURCE_ICON, mxShapeAws4ResourceIcon);
  126. //**********************************************************************************************************************************************************
  127. //Group
  128. //**********************************************************************************************************************************************************
  129. /**
  130. * Extends mxShape.
  131. */
  132. function mxShapeAws4Group(bounds, fill, stroke, strokewidth)
  133. {
  134. mxShape.call(this);
  135. this.bounds = bounds;
  136. this.fill = fill;
  137. this.stroke = stroke;
  138. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  139. };
  140. /**
  141. * Extends mxShape.
  142. */
  143. mxUtils.extend(mxShapeAws4Group, mxShape);
  144. mxShapeAws4Group.prototype.cst = {
  145. GROUP : 'mxgraph.aws4.group'
  146. };
  147. /**
  148. * Function: paintVertexShape
  149. *
  150. * Paints the vertex shape.
  151. */
  152. mxShapeAws4Group.prototype.paintVertexShape = function(c, x, y, w, h)
  153. {
  154. c.translate(x, y);
  155. var grStroke = mxUtils.getValue(this.state.style, 'grStroke', '1');
  156. var size = 25;
  157. if (this.style != null && mxUtils.getValue(this.style, mxConstants.STYLE_POINTER_EVENTS, '1') == '0')
  158. {
  159. c.pointerEvents = false;
  160. }
  161. c.begin();
  162. c.moveTo(0, 0);
  163. c.lineTo(w, 0);
  164. c.lineTo(w, h);
  165. c.lineTo(0, h);
  166. c.close();
  167. if (grStroke == '1' || this.outline)
  168. {
  169. c.fillAndStroke();
  170. }
  171. else
  172. {
  173. c.fill();
  174. }
  175. c.pointerEvents = true;
  176. c.setShadow(false);
  177. var grIcon = mxUtils.getValue(this.state.style, 'grIcon', '');
  178. var stencil = mxStencilRegistry.getStencil(grIcon);
  179. if (stencil != null)
  180. {
  181. var strokeColor = mxUtils.getValue(this.state.style, 'strokeColor', '#000000');
  182. size = mxUtils.getValue(this.state.style, 'grIconSize', size);
  183. c.setFillAlpha(this.strokeOpacity / 100);
  184. c.setFillColor(strokeColor);
  185. c.setStrokeColor('none');
  186. stencil.drawShape(c, this, 0, 0, size, size);
  187. }
  188. };
  189. mxCellRenderer.registerShape(mxShapeAws4Group.prototype.cst.GROUP, mxShapeAws4Group);
  190. //**********************************************************************************************************************************************************
  191. //Group Center
  192. //**********************************************************************************************************************************************************
  193. /**
  194. * Extends mxShape.
  195. */
  196. function mxShapeAws4GroupCenter(bounds, fill, stroke, strokewidth)
  197. {
  198. mxShape.call(this);
  199. this.bounds = bounds;
  200. this.fill = fill;
  201. this.stroke = stroke;
  202. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  203. };
  204. /**
  205. * Extends mxShape.
  206. */
  207. mxUtils.extend(mxShapeAws4GroupCenter, mxShape);
  208. mxShapeAws4GroupCenter.prototype.cst = {
  209. GROUP_CENTER : 'mxgraph.aws4.groupCenter'
  210. };
  211. /**
  212. * Function: paintVertexShape
  213. *
  214. * Paints the vertex shape.
  215. */
  216. mxShapeAws4GroupCenter.prototype.paintVertexShape = function(c, x, y, w, h)
  217. {
  218. c.translate(x, y);
  219. var grStroke = mxUtils.getValue(this.state.style, 'grStroke', '1');
  220. var size = 25;
  221. c.begin();
  222. c.moveTo(0, 0);
  223. c.lineTo(w, 0);
  224. c.lineTo(w, h);
  225. c.lineTo(0, h);
  226. c.close();
  227. if (grStroke == '1' || this.outline)
  228. {
  229. c.fillAndStroke();
  230. }
  231. else
  232. {
  233. c.fill();
  234. }
  235. c.setShadow(false);
  236. var grIcon = mxUtils.getValue(this.state.style, 'grIcon', '');
  237. var stencil = mxStencilRegistry.getStencil(grIcon);
  238. if (stencil != null)
  239. {
  240. var strokeColor = mxUtils.getValue(this.state.style, 'strokeColor', '#000000');
  241. size = mxUtils.getValue(this.state.style, 'grIconSize', size);
  242. c.setFillAlpha(this.strokeOpacity / 100);
  243. c.setFillColor(strokeColor);
  244. c.setStrokeColor('none');
  245. stencil.drawShape(c, this, (w - size) * 0.5, 0, size, size);
  246. }
  247. };
  248. mxCellRenderer.registerShape(mxShapeAws4GroupCenter.prototype.cst.GROUP_CENTER, mxShapeAws4GroupCenter);
  249. ////**********************************************************************************************************************************************************
  250. ////Resource Icon
  251. ////**********************************************************************************************************************************************************
  252. ///**
  253. //* Extends mxShape.
  254. //*/
  255. //function mxShapeAws4ResourceIcon(bounds, fill, stroke, strokewidth)
  256. //{
  257. // mxShape.call(this);
  258. // this.bounds = bounds;
  259. // this.fill = fill;
  260. // this.stroke = stroke;
  261. // this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  262. //};
  263. //
  264. ///**
  265. //* Extends mxShape.
  266. //*/
  267. //mxUtils.extend(mxShapeAws4ResourceIcon, mxShape);
  268. //
  269. //mxShapeAws4ResourceIcon.prototype.cst = {
  270. // RESOURCE_ICON : 'mxgraph.aws4.resourceIcon'
  271. //};
  272. //
  273. ///**
  274. //* Function: paintVertexShape
  275. //*
  276. //* Paints the vertex shape.
  277. //*/
  278. //mxShapeAws4ResourceIcon.prototype.paintVertexShape = function(c, x, y, w, h)
  279. //{
  280. // c.translate(x, y);
  281. //
  282. // c.begin();
  283. // c.moveTo(0, 0);
  284. // c.lineTo(w, 0);
  285. // c.lineTo(w, h);
  286. // c.lineTo(0, h);
  287. // c.close();
  288. // c.fillAndStroke();
  289. //
  290. // var prIcon = mxUtils.getValue(this.state.style, 'resIcon', '');
  291. // var stencil = mxStencilRegistry.getStencil(prIcon);
  292. //
  293. // if (stencil != null)
  294. // {
  295. // var strokeColor = mxUtils.getValue(this.state.style, 'strokeColor', '#000000');
  296. // c.setFillColor(strokeColor);
  297. // c.setStrokeColor('none');
  298. // stencil.drawShape(c, this, w * 0.1, h * 0.1, w * 0.8, h * 0.8);
  299. // }
  300. //
  301. //};
  302. //**********************************************************************************************************************************************************
  303. //Group2
  304. //**********************************************************************************************************************************************************
  305. /**
  306. * Extends mxShape.
  307. */
  308. function mxShapeAws4Group2(bounds, fill, stroke, strokewidth)
  309. {
  310. mxShape.call(this);
  311. this.bounds = bounds;
  312. this.fill = fill;
  313. this.stroke = stroke;
  314. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  315. };
  316. /**
  317. * Extends mxShape.
  318. */
  319. mxUtils.extend(mxShapeAws4Group2, mxShape);
  320. mxShapeAws4Group2.prototype.cst = {
  321. GROUP2 : 'mxgraph.aws4.group2'
  322. };
  323. /**
  324. * Function: paintVertexShape
  325. *
  326. * Paints the vertex shape.
  327. */
  328. mxShapeAws4Group2.prototype.paintVertexShape = function(c, x, y, w, h)
  329. {
  330. c.translate(x, y);
  331. var size = 25;
  332. c.begin();
  333. c.moveTo(0, 0);
  334. c.lineTo(w, 0);
  335. c.lineTo(w, h);
  336. c.lineTo(0, h);
  337. c.close();
  338. c.fillAndStroke();
  339. c.setShadow(false);
  340. var strokeColor = mxUtils.getValue(this.state.style, 'strokeColor', '#000000');
  341. c.setFillColor(strokeColor);
  342. c.begin();
  343. c.moveTo(0, 0);
  344. c.lineTo(size, 0);
  345. c.lineTo(size, size);
  346. c.lineTo(0, size);
  347. c.close();
  348. c.fill();
  349. var grIcon = mxUtils.getValue(this.state.style, 'grIcon', '');
  350. var stencil = mxStencilRegistry.getStencil(grIcon);
  351. if (stencil != null)
  352. {
  353. size = mxUtils.getValue(this.state.style, 'grIconSize', size);
  354. c.setFillAlpha(this.strokeOpacity / 100);
  355. c.setFillColor('#ffffff');
  356. c.setStrokeColor('none');
  357. stencil.drawShape(c, this, size * 0.1, size * 0.1, size * 0.8, size * 0.8);
  358. }
  359. };
  360. mxCellRenderer.registerShape(mxShapeAws4Group2.prototype.cst.GROUP2, mxShapeAws4Group2);