mxAWS4.js 11 KB

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