mxGCP2.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. /**
  2. * Copyright (c) 2006-2018, JGraph Holdings Ltd
  3. */
  4. //**********************************************************************************************************************************************************
  5. //double rect
  6. //**********************************************************************************************************************************************************
  7. /**
  8. * Extends mxShape.
  9. */
  10. function mxShapeGCP2DoubleRect(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(mxShapeGCP2DoubleRect, mxShape);
  22. mxShapeGCP2DoubleRect.prototype.cst = {
  23. SHAPE_DOUBLE_RECT : 'mxgraph.gcp2.doubleRect'
  24. };
  25. /**
  26. * Function: paintVertexShape
  27. *
  28. * Paints the vertex shape.
  29. */
  30. mxShapeGCP2DoubleRect.prototype.paintVertexShape = function(c, x, y, w, h)
  31. {
  32. var dx = 8;
  33. var dy = 8;
  34. w = w - dx;
  35. h = h - dy;
  36. c.translate(x, y);
  37. c.begin();
  38. c.roundrect(dx, dy, w , h, 1, 1);
  39. c.fillAndStroke();
  40. c.roundrect(0, 0, w, h, 1, 1);
  41. c.fillAndStroke();
  42. };
  43. mxCellRenderer.registerShape(mxShapeGCP2DoubleRect.prototype.cst.SHAPE_DOUBLE_RECT, mxShapeGCP2DoubleRect);
  44. mxShapeGCP2DoubleRect.prototype.constraints = mxRectangleShape.prototype.constraints;
  45. //**********************************************************************************************************************************************************
  46. //hexagonal icon
  47. //**********************************************************************************************************************************************************
  48. /**
  49. * Extends mxShape.
  50. */
  51. function mxShapeGCP2HexIcon(bounds, fill, stroke, strokewidth)
  52. {
  53. mxShape.call(this);
  54. this.bounds = bounds;
  55. this.fill = fill;
  56. this.stroke = stroke;
  57. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  58. };
  59. /**
  60. * Extends mxShape.
  61. */
  62. mxUtils.extend(mxShapeGCP2HexIcon, mxShape);
  63. mxShapeGCP2HexIcon.prototype.cst = {
  64. HEX_ICON : 'mxgraph.gcp2.hexIcon'
  65. };
  66. mxShapeGCP2HexIcon.prototype.customProperties = [
  67. {name: 'instNum', dispName: 'Number of instances', type: 'int', min: 0, defVal: 0},
  68. {name: 'prType', dispName: 'Instance Type', defVal: 'standard', type: 'enum',
  69. enumList: [{val: 'standard', dispName: 'Standard'},
  70. {val: 'dynamic', dispName: 'Dynamic'},
  71. {val: 'multiple', dispName: 'Multiple'},
  72. {val: 'shared', dispName: 'Shared'},
  73. {val: 'replica', dispName: 'Replica'},
  74. {val: 'dynamic2', dispName: 'Dynamic 2'},
  75. {val: 'dynamic3', dispName: 'Dynamic 3'},
  76. {val: 'highmem', dispName: 'High-Mem'},
  77. {val: 'highcomp', dispName: 'High-Comp'},
  78. {val: 'backend', dispName: 'Backend'},
  79. {val: 'input', dispName: 'Input'}]},
  80. {name: 'prIcon', dispName: 'Instance Icon', defVal: 'compute_engine', type: 'enum',
  81. enumList: [{val: 'compute_engine', dispName: 'Compute Engine'},
  82. {val: 'gpu', dispName: 'GPU'},
  83. {val: 'app_engine', dispName: 'App Engine'},
  84. {val: 'cloud_functions', dispName: 'Cloud Functions'},
  85. {val: 'container_engine', dispName: 'Kubernetes Engine'},
  86. {val: 'container_optimized_os', dispName: 'Container-Optimized OS'},
  87. {val: 'api_analytics', dispName: 'API Analytics'},
  88. {val: 'apigee_sense', dispName: 'Apigee Sense'},
  89. {val: 'api_monetization', dispName: 'API Monetization'},
  90. {val: 'cloud_endpoints', dispName: 'Cloud Endpoints'},
  91. {val: 'apigee_api_platform', dispName: 'Apigee API Platform'},
  92. {val: 'developer_portal', dispName: 'Developer Portal'},
  93. {val: 'cloud_iam', dispName: 'Cloud IAM'},
  94. {val: 'beyondcorp', dispName: 'BeyondCorp'},
  95. {val: 'cloud_iam', dispName: 'Cloud Resource Manager'},
  96. {val: 'data_loss_prevention_api', dispName: 'Data Loss Prevention API'},
  97. {val: 'cloud_security_scanner', dispName: 'Cloud Security Scanner'},
  98. {val: 'key_management_service', dispName: 'Key Management Service'},
  99. {val: 'identity_aware_proxy', dispName: 'Identity-Aware Proxy'},
  100. {val: 'security_key_enforcement', dispName: 'Security Key Enforcement'},
  101. {val: 'bigquery', dispName: 'BigQuery'},
  102. {val: 'cloud_datalab', dispName: 'Cloud Datalab'},
  103. {val: 'cloud_dataflow', dispName: 'Cloud Dataflow'},
  104. {val: 'cloud_pubsub', dispName: 'Cloud Pub/Sub'},
  105. {val: 'cloud_dataproc', dispName: 'Cloud Dataproc'},
  106. {val: 'genomics', dispName: 'Genomics'},
  107. {val: 'cloud_dataprep', dispName: 'Cloud Dataprep'},
  108. {val: 'data_studio', dispName: 'Data Studio'},
  109. {val: 'transfer_appliance', dispName: 'Transfer Appliance'},
  110. {val: 'cloud_machine_learning', dispName: 'Cloud Machine Learning'},
  111. {val: 'cloud_natural_language_api', dispName: 'Cloud Natural Language API'},
  112. {val: 'cloud_vision_api', dispName: 'Vision API'},
  113. {val: 'cloud_translation_api', dispName: 'Translation API'},
  114. {val: 'cloud_speech_api', dispName: 'Speech API'},
  115. {val: 'cloud_jobs_api', dispName: 'Jobs API'},
  116. {val: 'cloud_video_intelligence_api', dispName: 'Cloud Video Intelligence API'},
  117. {val: 'advanced_solutions_lab', dispName: 'Advanced Solutions Lab'},
  118. {val: 'cloud_iot_core', dispName: 'Cloud IoT Core'},
  119. {val: 'cloud_storage', dispName: 'Cloud Storage'},
  120. {val: 'cloud_sql', dispName: 'Cloud SQL'},
  121. {val: 'cloud_bigtable', dispName: 'Cloud Bigtable'},
  122. {val: 'cloud_spanner', dispName: 'Cloud Spanner'},
  123. {val: 'cloud_datastore', dispName: 'Cloud Datastore'},
  124. {val: 'persistent_disk', dispName: 'Persistent Disk'},
  125. {val: 'cloud_memorystore', dispName: 'Cloud Memorystore'},
  126. {val: 'cloud_filestore', dispName: 'Cloud Filestore'},
  127. {val: 'stackdriver', dispName: 'Stackdriver'},
  128. {val: 'cloud_deployment_manager', dispName: 'Monitoring'},
  129. {val: 'cloud_deployment_manager', dispName: 'Deployment Manager'},
  130. {val: 'logging', dispName: 'Logging'},
  131. {val: 'placeholder', dispName: 'Cloud Console'},
  132. {val: 'error_reporting', dispName: 'Error Reporting'},
  133. {val: 'placeholder', dispName: 'Cloud Shell'},
  134. {val: 'trace', dispName: 'Trace'},
  135. {val: 'placeholder', dispName: 'Cloud Mobile App'},
  136. {val: 'profiler', dispName: 'Profiler'},
  137. {val: 'placeholder', dispName: 'Billing API'},
  138. {val: 'cloud_apis', dispName: 'Cloud APIs'},
  139. {val: 'virtual_private_cloud', dispName: 'Virtual Private Cloud'},
  140. {val: 'dedicated_interconnect', dispName: 'Dedicated Interconnect'},
  141. {val: 'cloud_load_balancing', dispName: 'Cloud Load Balancing'},
  142. {val: 'cloud_dns', dispName: 'Cloud DNS'},
  143. {val: 'cloud_cdn', dispName: 'Cloud CDN'},
  144. {val: 'cloud_network', dispName: 'Cloud Network'},
  145. {val: 'cloud_external_ip_addresses', dispName: 'Cloud External IP Addresses'},
  146. {val: 'cloud_routes', dispName: 'Cloud Routes'},
  147. {val: 'cloud_firewall_rules', dispName: 'Cloud Firewall Rules'},
  148. {val: 'cloud_vpn', dispName: 'Cloud VPN'},
  149. {val: 'cloud_router', dispName: 'Cloud Router'},
  150. {val: 'cloud_armor', dispName: 'Cloud Armor'},
  151. {val: 'standard_network_tier', dispName: 'Standard Network Tier'},
  152. {val: 'premium_network_tier', dispName: 'Premium Network Tier'},
  153. {val: 'partner_interconnect', dispName: 'Partner Interconnect'},
  154. {val: 'placeholder', dispName: 'Cloud SDK'},
  155. {val: 'container_builder', dispName: 'Cloud Build'},
  156. {val: 'cloud_tools_for_powershell', dispName: 'Cloud Tools for Visual Studio'},
  157. {val: 'placeholder', dispName: 'Cloud Source Repositories'},
  158. {val: 'placeholder', dispName: 'Maven App Engine Plugin'},
  159. {val: 'placeholder', dispName: 'Cloud Tools for Eclipse'},
  160. {val: 'placeholder', dispName: 'Cloud Tools for IntelliJ'},
  161. {val: 'placeholder', dispName: 'Cloud Test Lab'},
  162. {val: 'cloud_tools_for_powershell', dispName: 'Cloud Tools for PowerShell'},
  163. {val: 'cloud_tools_for_powershell', dispName: 'IDE Plugins'},
  164. {val: 'container_registry', dispName: 'Container Registry'},
  165. {val: 'cloud_iot_edge', dispName: 'Cloud IoT Edge'},
  166. {val: 'cloud_firestore', dispName: 'Cloud Firestore'},
  167. {val: 'cloud_run', dispName: 'Cloud Run'},
  168. {val: 'gke_on_prem', dispName: 'GKE-on-Prem'},
  169. {val: 'cloud_data_catalog', dispName: 'Cloud Data Catalog'},
  170. {val: 'cloud_data_fusion', dispName: 'Cloud Data Fusion'},
  171. {val: 'ai_hub', dispName: 'AI Hub'},
  172. {val: 'automl_video_intelligence', dispName: 'AutoML Video Intelligence'},
  173. {val: 'automl_natural_language', dispName: 'AutoML Natural Language'},
  174. {val: 'automl_tables', dispName: 'AutoML Tables'},
  175. {val: 'automl_translation', dispName: 'AutoML Translation'},
  176. {val: 'automl_vision', dispName: 'AutoML Vision'},
  177. {val: 'recommendations_ai', dispName: 'Recommendations AI'},
  178. {val: 'cloud_inference_api', dispName: 'Cloud Inference API'},
  179. {val: 'cloud_service_mesh', dispName: 'Cloud Service Mesh'},
  180. {val: 'cloud_nat', dispName: 'Cloud NAT'},
  181. {val: 'traffic_director', dispName: 'Traffic Director'},
  182. {val: 'cloud_test_lab', dispName: 'Cloud Test Lab'},
  183. {val: 'cloud_code', dispName: 'Cloud Code'},
  184. {val: 'cloud_tasks', dispName: 'Cloud Tasks'},
  185. {val: 'placeholder', dispName: 'Gradle App Engine Plugin'}]}
  186. ];
  187. /**
  188. * Function: paintVertexShape
  189. *
  190. * Paints the vertex shape.
  191. */
  192. mxShapeGCP2HexIcon.prototype.paintVertexShape = function(c, x, y, w, h)
  193. {
  194. c.translate(x, y);
  195. var prIcon = mxUtils.getValue(this.state.style, 'prIcon', 'compute_engine');
  196. var prType = mxUtils.getValue(this.state.style, 'prType', '');
  197. var instNum = parseInt(mxUtils.getValue(this.state.style, 'instNum', 0));
  198. var fillColor = mxUtils.getValue(this.state.style, 'fillColor', '#ffffff');
  199. var opacity = mxUtils.getValue(this.state.style, 'opacity', '100');
  200. var strokeColor = mxUtils.getValue(this.state.style, 'strokeColor', 'none');
  201. var strokeWidth = mxUtils.getValue(this.state.style, 'strokeWidth', 1);
  202. var iconSize = Math.min(w, h);
  203. switch(prType)
  204. {
  205. case 'dynamic':
  206. var bgSt1 = mxStencilRegistry.getStencil('mxgraph.gcp2.outline_blank_2');
  207. c.setAlpha(opacity * 0.5 / 100);
  208. c.setStrokeColor('none');
  209. bgSt1.drawShape(c, this, w * 0.21, h * 0.12, w * 0.58, h * 0.76);
  210. break;
  211. case 'multiple':
  212. var bgSt1 = mxStencilRegistry.getStencil('mxgraph.gcp2.outline_blank_2');
  213. c.setAlpha(opacity * 0.5 / 100);
  214. c.setStrokeColor('none');
  215. bgSt1.drawShape(c, this, w * 0.21, h * 0.12, w * 0.58, h * 0.76);
  216. var bgSt2 = mxStencilRegistry.getStencil('mxgraph.gcp2.outline_blank_3');
  217. c.setAlpha(opacity * 0.7 / 100);
  218. c.setStrokeColor('none');
  219. bgSt2.drawShape(c, this, w * 0.17, h * 0.13, w * 0.66, h * 0.74);
  220. break;
  221. case 'shared':
  222. var bgSt1 = mxStencilRegistry.getStencil('mxgraph.gcp2.outline_blank_1');
  223. this.style[mxConstants.STYLE_STROKEWIDTH] = iconSize * 0.038;
  224. c.setAlpha(opacity * 0.4 / 100);
  225. c.setStrokeColor(fillColor);
  226. c.setFillColor('none');
  227. bgSt1.drawShape(c, this, w * 0.02, h * 0, w * 0.96, h);
  228. var bgSt2 = mxStencilRegistry.getStencil('mxgraph.gcp2.outline_blank_2');
  229. c.setAlpha(opacity * 0.7 / 100);
  230. bgSt2.drawShape(c, this, w * 0.14, h * 0.01, w * 0.72, h * 0.98);
  231. c.setAlpha(opacity / 100);
  232. c.setFillColor('#ffffff');
  233. bgSt1.drawShape(c, this, w * 0.13, h * 0.12, w * 0.74, h * 0.76);
  234. this.style[mxConstants.STYLE_STROKEWIDTH] = strokeWidth;
  235. break;
  236. case 'replica':
  237. var bgSt1 = mxStencilRegistry.getStencil('mxgraph.gcp2.outline_blank_1');
  238. this.style[mxConstants.STYLE_STROKEWIDTH] = iconSize * 0.038;
  239. c.setAlpha(opacity * 0.4 / 100);
  240. c.setStrokeColor(fillColor);
  241. c.setFillColor('none');
  242. bgSt1.drawShape(c, this, w * 0.02, h * 0, w * 0.96, h);
  243. c.setAlpha(opacity * 0.7 / 100);
  244. bgSt1.drawShape(c, this, w * 0.075, h * 0.06, w * 0.85, h * 0.88);
  245. c.setAlpha(opacity / 100);
  246. c.setFillColor('#ffffff');
  247. bgSt1.drawShape(c, this, w * 0.13, h * 0.12, w * 0.74, h * 0.76);
  248. this.style[mxConstants.STYLE_STROKEWIDTH] = strokeWidth;
  249. break;
  250. case 'dynamic2':
  251. var bgSt1 = mxStencilRegistry.getStencil('mxgraph.gcp2.outline_blank_2');
  252. c.setAlpha(opacity * 0.5 / 100);
  253. c.setStrokeColor('none');
  254. bgSt1.drawShape(c, this, w * 0.14, h * 0.01, w * 0.72, h * 0.98);
  255. var bgSt2 = mxStencilRegistry.getStencil('mxgraph.gcp2.outline_blank_1');
  256. this.style[mxConstants.STYLE_STROKEWIDTH] = iconSize * 0.01;
  257. c.setStrokeColor(fillColor);
  258. c.setAlpha(opacity / 100);
  259. c.setFillColor('#ffffff');
  260. bgSt2.drawShape(c, this, w * 0.13, h * 0.12, w * 0.74, h * 0.76);
  261. this.style[mxConstants.STYLE_STROKEWIDTH] = strokeWidth;
  262. break;
  263. case 'dynamic3':
  264. var bgSt1 = mxStencilRegistry.getStencil('mxgraph.gcp2.outline_blank_2');
  265. c.setStrokeColor('none');
  266. bgSt1.drawShape(c, this, w * 0.14, h * 0.01, w * 0.72, h * 0.98);
  267. var bgSt2 = mxStencilRegistry.getStencil('mxgraph.gcp2.outline_blank_1');
  268. this.style[mxConstants.STYLE_STROKEWIDTH] = iconSize * 0.01;
  269. c.setStrokeColor(fillColor);
  270. c.setAlpha(opacity / 100);
  271. c.setFillColor('#ffffff');
  272. bgSt2.drawShape(c, this, w * 0.13, h * 0.12, w * 0.74, h * 0.76);
  273. this.style[mxConstants.STYLE_STROKEWIDTH] = strokeWidth;
  274. break;
  275. case 'highmem':
  276. var bgSt1 = mxStencilRegistry.getStencil('mxgraph.gcp2.outline_highmem');
  277. c.setAlpha(opacity * 0.5 / 100);
  278. c.setStrokeColor('none');
  279. bgSt1.drawShape(c, this, 0, h * 0.56, w, h * 0.28);
  280. break;
  281. case 'highcomp':
  282. var bgSt1 = mxStencilRegistry.getStencil('mxgraph.gcp2.outline_highcomp');
  283. c.setAlpha(opacity * 0.5 / 100);
  284. c.setStrokeColor('none');
  285. bgSt1.drawShape(c, this, 0, h * 0.16, w, h * 0.28);
  286. break;
  287. case 'backend':
  288. var bgSt1 = mxStencilRegistry.getStencil('mxgraph.gcp2.outline_blank_1');
  289. c.setFillColor('#FCC64D');
  290. bgSt1.drawShape(c, this, w * 0.12, h * 0.11, w * 0.76, h * 0.78);
  291. break;
  292. case 'input':
  293. var bgSt1 = mxStencilRegistry.getStencil('mxgraph.gcp2.outline_blank_1');
  294. c.setFillColor('#A5DA40');
  295. bgSt1.drawShape(c, this, w * 0.12, h * 0.11, w * 0.76, h * 0.78);
  296. break;
  297. case 'standard':
  298. default:
  299. break;
  300. }
  301. c.setAlpha(opacity / 100);
  302. var stencil = mxStencilRegistry.getStencil('mxgraph.gcp2.' + prIcon);
  303. if (stencil != null)
  304. {
  305. c.setFillColor(fillColor);
  306. c.setStrokeColor('none');
  307. stencil.drawShape(c, this, w * 0.17, h * 0.16, w * 0.66, h * 0.68);
  308. }
  309. if (instNum > 0)
  310. {
  311. c.setFillColor('#ffffff');
  312. c.setStrokeColor('#ffffff');
  313. c.setStrokeWidth(iconSize * 0.038);
  314. c.ellipse(w * 0.2, 0, w * 0.18, h * 0.22);
  315. c.fillAndStroke();
  316. c.setAlpha(opacity * 0.5 / 100);
  317. c.setStrokeColor(fillColor);
  318. c.ellipse(w * 0.2, 0, w * 0.18, h * 0.22);
  319. c.stroke();
  320. c.setAlpha(opacity / 100);
  321. c.setFontColor('#4E6B89');
  322. c.setFontStyle(1);
  323. c.setFontSize(Math.min(w, h) * 0.1);
  324. c.text(w * 0.29, h * 0.11 + 1, 0, 0, instNum.toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  325. }
  326. };
  327. mxCellRenderer.registerShape(mxShapeGCP2HexIcon.prototype.cst.HEX_ICON, mxShapeGCP2HexIcon);
  328. mxShapeGCP2HexIcon.prototype.getConstraints = function(style, w, h)
  329. {
  330. var constr = [];
  331. constr.push(new mxConnectionConstraint(new mxPoint(0.825, 0.5), false));
  332. constr.push(new mxConnectionConstraint(new mxPoint(0.175, 0.5), false));
  333. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0.16), false));
  334. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0.84), false));
  335. constr.push(new mxConnectionConstraint(new mxPoint(0.66, 0.17), false));
  336. constr.push(new mxConnectionConstraint(new mxPoint(0.66, 0.83), false));
  337. constr.push(new mxConnectionConstraint(new mxPoint(0.34, 0.17), false));
  338. constr.push(new mxConnectionConstraint(new mxPoint(0.34, 0.83), false));
  339. constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0.33), false));
  340. constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0.67), false));
  341. constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0.33), false));
  342. constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0.67), false));
  343. return (constr);
  344. };