mxArchiMate.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989
  1. /**
  2. * $Id: mxArchiMate.js,v 1.0 2014/03/17 07:05:39 mate Exp $
  3. * Copyright (c) 2006-2014, JGraph Ltd
  4. */
  5. //**********************************************************************************************************************************************************
  6. //Location
  7. //**********************************************************************************************************************************************************
  8. /**
  9. * Extends mxShape.
  10. */
  11. function mxArchiMateLocation(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(mxArchiMateLocation, mxShape);
  23. mxArchiMateLocation.prototype.cst = {
  24. LOCATION : 'mxgraph.archimate.location'
  25. };
  26. /**
  27. * Function: paintVertexShape
  28. *
  29. * Paints the vertex shape.
  30. */
  31. mxArchiMateLocation.prototype.paintVertexShape = function(c, x, y, w, h)
  32. {
  33. c.translate(x, y);
  34. this.background(c, 0, 0, w, h);
  35. c.setShadow(false);
  36. c.translate(w - 20, 5);
  37. this.foreground(c, w - 20, 5, 15, 15);
  38. };
  39. mxArchiMateLocation.prototype.background = function(c, x, y, w, h)
  40. {
  41. c.rect(0, 0, w, h);
  42. c.fillAndStroke();
  43. };
  44. mxArchiMateLocation.prototype.foreground = function(c, x, y, w, h)
  45. {
  46. c.setDashed(false);
  47. c.translate(3 ,0);
  48. w = w - 6;
  49. c.begin();
  50. c.moveTo(w * 0.5, h);
  51. c.arcTo(w * 0.1775, h * 0.3, 0, 0, 0, w * 0.345, h * 0.7);
  52. c.arcTo(w * 0.538, h * 0.364, 0, 0, 1, w * 0.5, 0);
  53. c.arcTo(w * 0.538, h * 0.364, 0, 0, 1, w * 0.655, h * 0.7);
  54. c.arcTo(w * 0.1775, h * 0.3, 0, 0, 0, w * 0.5, h);
  55. c.stroke();
  56. };
  57. mxCellRenderer.registerShape(mxArchiMateLocation.prototype.cst.LOCATION, mxArchiMateLocation);
  58. //**********************************************************************************************************************************************************
  59. //Business
  60. //**********************************************************************************************************************************************************
  61. /**
  62. * Extends mxShape.
  63. */
  64. function mxArchiMateBusiness(bounds, fill, stroke, strokewidth)
  65. {
  66. mxShape.call(this);
  67. this.bounds = bounds;
  68. this.fill = fill;
  69. this.stroke = stroke;
  70. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  71. };
  72. /**
  73. * Extends mxShape.
  74. */
  75. mxUtils.extend(mxArchiMateBusiness, mxShape);
  76. mxArchiMateBusiness.prototype.cst = {
  77. BUSINESS : 'mxgraph.archimate.business',
  78. TYPE : 'busType',
  79. PROCESS : 'process',
  80. FUNCTION : 'function',
  81. INTERACTION : 'interaction',
  82. EVENT : 'event',
  83. SERVICE : 'service'
  84. };
  85. /**
  86. * Function: paintVertexShape
  87. *
  88. * Paints the vertex shape.
  89. */
  90. mxArchiMateBusiness.prototype.paintVertexShape = function(c, x, y, w, h)
  91. {
  92. c.translate(x, y);
  93. this.background(c, 0, 0, w, h);
  94. c.setShadow(false);
  95. c.translate(w - 20, 5);
  96. this.foreground(c, w - 20, 5, 15, 15);
  97. };
  98. mxArchiMateBusiness.prototype.background = function(c, x, y, w, h)
  99. {
  100. c.roundrect(0, 0, w, h, 10, 10);
  101. c.fillAndStroke();
  102. };
  103. mxArchiMateBusiness.prototype.foreground = function(c, x, y, w, h)
  104. {
  105. var type = mxUtils.getValue(this.style, mxArchiMateBusiness.prototype.cst.TYPE, mxArchiMateBusiness.prototype.cst.PROCESS);
  106. c.setDashed(false);
  107. if (type === mxArchiMateBusiness.prototype.cst.PROCESS)
  108. {
  109. c.translate(0, 2);
  110. h = h - 4;
  111. c.begin();
  112. c.moveTo(0, h * 0.15);
  113. c.lineTo(w * 0.65, h * 0.15);
  114. c.lineTo(w * 0.65, 0);
  115. c.lineTo(w, h * 0.5);
  116. c.lineTo(w * 0.65, h);
  117. c.lineTo(w * 0.65, h * 0.85);
  118. c.lineTo(0, h * 0.85);
  119. c.close();
  120. c.stroke();
  121. }
  122. else if (type === mxArchiMateBusiness.prototype.cst.FUNCTION)
  123. {
  124. c.translate(2, 0);
  125. w = w - 4;
  126. c.begin();
  127. c.moveTo(0, h * 0.15);
  128. c.lineTo(w * 0.5, 0);
  129. c.lineTo(w, h * 0.15);
  130. c.lineTo(w, h);
  131. c.lineTo(w * 0.5, h * 0.85);
  132. c.lineTo(0, h);
  133. c.close();
  134. c.stroke();
  135. }
  136. else if (type === mxArchiMateBusiness.prototype.cst.INTERACTION)
  137. {
  138. c.begin();
  139. c.moveTo(w * 0.55, 0);
  140. c.arcTo(w * 0.45, h * 0.5, 0, 0, 1, w * 0.55, h);
  141. c.close();
  142. c.moveTo(w * 0.45, 0);
  143. c.arcTo(w * 0.45, h * 0.5, 0, 0, 0, w * 0.45, h);
  144. c.close();
  145. c.stroke();
  146. }
  147. else if (type === mxArchiMateBusiness.prototype.cst.EVENT)
  148. {
  149. c.translate(0, 3);
  150. h = h - 6;
  151. c.begin();
  152. c.moveTo(w - h * 0.5, 0);
  153. c.arcTo(h * 0.5, h * 0.5, 0, 0, 1, w - h * 0.5, h);
  154. c.lineTo(0, h);
  155. c.arcTo(h * 0.5, h * 0.5, 0, 0, 0, 0, 0);
  156. c.close();
  157. c.stroke();
  158. }
  159. else if (type === mxArchiMateBusiness.prototype.cst.SERVICE)
  160. {
  161. c.translate(0, 3);
  162. h = h - 6;
  163. c.begin();
  164. c.moveTo(w - h * 0.5, 0);
  165. c.arcTo(h * 0.5, h * 0.5, 0, 0, 1, w - h * 0.5, h);
  166. c.lineTo(0, h);
  167. c.arcTo(h * 0.5, h * 0.5, 0, 0, 1, 0, 0);
  168. c.close();
  169. c.stroke();
  170. }
  171. };
  172. mxCellRenderer.registerShape(mxArchiMateBusiness.prototype.cst.BUSINESS, mxArchiMateBusiness);
  173. //**********************************************************************************************************************************************************
  174. //Business Object
  175. //**********************************************************************************************************************************************************
  176. /**
  177. * Extends mxShape.
  178. */
  179. function mxArchiMateBusinessObject(bounds, fill, stroke, strokewidth)
  180. {
  181. mxShape.call(this);
  182. this.bounds = bounds;
  183. this.fill = fill;
  184. this.stroke = stroke;
  185. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  186. };
  187. /**
  188. * Extends mxShape.
  189. */
  190. mxUtils.extend(mxArchiMateBusinessObject, mxShape);
  191. mxArchiMateBusinessObject.prototype.cst = {
  192. BUSINESS_OBJECT : 'mxgraph.archimate.businessObject'
  193. };
  194. /**
  195. * Function: paintVertexShape
  196. *
  197. * Paints the vertex shape.
  198. */
  199. mxArchiMateBusinessObject.prototype.paintVertexShape = function(c, x, y, w, h)
  200. {
  201. c.translate(x, y);
  202. this.background(c, 0, 0, w, h);
  203. c.setShadow(false);
  204. this.foreground(c, 0, 0, w, h);
  205. };
  206. mxArchiMateBusinessObject.prototype.background = function(c, x, y, w, h)
  207. {
  208. c.rect(0, 0, w, h);
  209. c.fillAndStroke();
  210. };
  211. mxArchiMateBusinessObject.prototype.foreground = function(c, x, y, w, h)
  212. {
  213. if (h >= 15)
  214. {
  215. c.begin();
  216. c.moveTo(0, 15);
  217. c.lineTo(w, 15);
  218. c.stroke();
  219. }
  220. };
  221. mxCellRenderer.registerShape(mxArchiMateBusinessObject.prototype.cst.BUSINESS_OBJECT, mxArchiMateBusinessObject);
  222. //**********************************************************************************************************************************************************
  223. //Representation
  224. //**********************************************************************************************************************************************************
  225. /**
  226. * Extends mxShape.
  227. */
  228. function mxArchiMateRepresentation(bounds, fill, stroke, strokewidth)
  229. {
  230. mxShape.call(this);
  231. this.bounds = bounds;
  232. this.fill = fill;
  233. this.stroke = stroke;
  234. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  235. };
  236. /**
  237. * Extends mxShape.
  238. */
  239. mxUtils.extend(mxArchiMateRepresentation, mxShape);
  240. mxArchiMateRepresentation.prototype.cst = {
  241. REPRESENTATION : 'mxgraph.archimate.representation'
  242. };
  243. /**
  244. * Function: paintVertexShape
  245. *
  246. * Paints the vertex shape.
  247. */
  248. mxArchiMateRepresentation.prototype.paintVertexShape = function(c, x, y, w, h)
  249. {
  250. c.translate(x, y);
  251. this.background(c, 0, 0, w, h);
  252. };
  253. mxArchiMateRepresentation.prototype.background = function(c, x, y, w, h)
  254. {
  255. c.begin();
  256. c.moveTo(0, 0);
  257. c.lineTo(w, 0);
  258. c.lineTo(w, h * 0.85);
  259. c.arcTo(w * 0.35, h * 0.35, 0, 0, 0, w * 0.5, h * 0.85);
  260. c.arcTo(w * 0.35, h * 0.35, 0, 0, 1, 0, h * 0.85);
  261. c.close();
  262. c.fillAndStroke();
  263. };
  264. mxCellRenderer.registerShape(mxArchiMateRepresentation.prototype.cst.REPRESENTATION, mxArchiMateRepresentation);
  265. //**********************************************************************************************************************************************************
  266. //Product
  267. //**********************************************************************************************************************************************************
  268. /**
  269. * Extends mxShape.
  270. */
  271. function mxArchiMateProduct(bounds, fill, stroke, strokewidth)
  272. {
  273. mxShape.call(this);
  274. this.bounds = bounds;
  275. this.fill = fill;
  276. this.stroke = stroke;
  277. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  278. };
  279. /**
  280. * Extends mxShape.
  281. */
  282. mxUtils.extend(mxArchiMateProduct, mxShape);
  283. mxArchiMateProduct.prototype.cst = {
  284. PRODUCT : 'mxgraph.archimate.product'
  285. };
  286. /**
  287. * Function: paintVertexShape
  288. *
  289. * Paints the vertex shape.
  290. */
  291. mxArchiMateProduct.prototype.paintVertexShape = function(c, x, y, w, h)
  292. {
  293. c.translate(x, y);
  294. this.background(c, 0, 0, w, h);
  295. c.setShadow(false);
  296. this.foreground(c, 0, 0, w, h);
  297. };
  298. mxArchiMateProduct.prototype.background = function(c, x, y, w, h)
  299. {
  300. c.rect(0, 0, w, h);
  301. c.fillAndStroke();
  302. };
  303. mxArchiMateProduct.prototype.foreground = function(c, x, y, w, h)
  304. {
  305. if (h >= 15)
  306. {
  307. c.begin();
  308. c.moveTo(0, 15);
  309. c.lineTo(w * 0.6, 15);
  310. c.lineTo(w * 0.6, 0);
  311. c.stroke();
  312. }
  313. };
  314. mxCellRenderer.registerShape(mxArchiMateProduct.prototype.cst.PRODUCT, mxArchiMateProduct);
  315. //**********************************************************************************************************************************************************
  316. //Application
  317. //**********************************************************************************************************************************************************
  318. /**
  319. * Extends mxShape.
  320. */
  321. function mxArchiMateApplication(bounds, fill, stroke, strokewidth)
  322. {
  323. mxShape.call(this);
  324. this.bounds = bounds;
  325. this.fill = fill;
  326. this.stroke = stroke;
  327. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  328. };
  329. /**
  330. * Extends mxShape.
  331. */
  332. mxUtils.extend(mxArchiMateApplication, mxShape);
  333. mxArchiMateApplication.prototype.cst = {
  334. APPLICATION : 'mxgraph.archimate.application',
  335. TYPE : 'appType',
  336. COMPONENT : 'comp',
  337. INTERFACE : 'interface',
  338. INTERFACE2 : 'interface2',
  339. FUNCTION : 'function',
  340. INTERACTION : 'interaction',
  341. SERVICE : 'service',
  342. NODE : 'node',
  343. NETWORK : 'network',
  344. COMM_PATH : 'commPath',
  345. SYS_SW : 'sysSw',
  346. ARTIFACT : 'artifact',
  347. ACTOR : 'actor',
  348. ROLE : 'role',
  349. COLLABORATION : 'collab'
  350. };
  351. /**
  352. * Function: paintVertexShape
  353. *
  354. * Paints the vertex shape.
  355. */
  356. mxArchiMateApplication.prototype.paintVertexShape = function(c, x, y, w, h)
  357. {
  358. c.translate(x, y);
  359. this.background(c, 0, 0, w, h);
  360. c.setShadow(false);
  361. c.translate(w - 20, 5);
  362. this.foreground(c, w - 20, 5, 15, 15);
  363. };
  364. mxArchiMateApplication.prototype.background = function(c, x, y, w, h)
  365. {
  366. c.rect(0, 0, w, h);
  367. c.fillAndStroke();
  368. };
  369. mxArchiMateApplication.prototype.foreground = function(c, x, y, w, h)
  370. {
  371. var type = mxUtils.getValue(this.style, mxArchiMateApplication.prototype.cst.TYPE, mxArchiMateApplication.prototype.cst.COMPONENT);
  372. c.setDashed(false);
  373. if (type === mxArchiMateApplication.prototype.cst.COMPONENT)
  374. {
  375. c.translate(1, 0);
  376. w = w - 2;
  377. c.rect(w * 0.25, 0, w * 0.75, h);
  378. c.stroke();
  379. c.rect(0, h * 0.25, w * 0.5, h * 0.15);
  380. c.fillAndStroke();
  381. c.rect(0, h * 0.6, w * 0.5, h * 0.15);
  382. c.fillAndStroke();
  383. }
  384. else if (type === mxArchiMateApplication.prototype.cst.COLLABORATION)
  385. {
  386. c.translate(0, 3);
  387. h = h - 6;
  388. c.ellipse(0, 0, w * 0.6, h);
  389. c.stroke();
  390. c.ellipse(w * 0.4, 0, w * 0.6, h);
  391. c.fillAndStroke();
  392. }
  393. else if (type === mxArchiMateApplication.prototype.cst.INTERFACE)
  394. {
  395. c.translate(0, 4);
  396. h = h - 8;
  397. c.ellipse(w * 0.5, 0, w * 0.5, h);
  398. c.stroke();
  399. c.begin();
  400. c.moveTo(0, h * 0.5);
  401. c.lineTo(w * 0.5, h * 0.5);
  402. c.stroke();
  403. }
  404. else if (type === mxArchiMateApplication.prototype.cst.INTERFACE2)
  405. {
  406. c.translate(0, 1);
  407. h = h - 2;
  408. c.begin();
  409. c.moveTo(0, h * 0.5);
  410. c.lineTo(w * 0.6, h * 0.5);
  411. c.moveTo(w, 0);
  412. c.arcTo(w * 0.4, h * 0.5, 0, 0, 0, w, h);
  413. c.stroke();
  414. }
  415. else if (type === mxArchiMateApplication.prototype.cst.FUNCTION)
  416. {
  417. c.begin();
  418. c.moveTo(w * 0.5, 0);
  419. c.lineTo(w, h * 0.2);
  420. c.lineTo(w, h);
  421. c.lineTo(w * 0.5, h * 0.8);
  422. c.lineTo(0, h);
  423. c.lineTo(0, h * 0.2);
  424. c.close();
  425. c.stroke();
  426. }
  427. else if (type === mxArchiMateApplication.prototype.cst.INTERACTION)
  428. {
  429. c.begin();
  430. c.moveTo(w * 0.55, 0);
  431. c.arcTo(w * 0.45, h * 0.5, 0, 0, 1, w * 0.55, h);
  432. c.close();
  433. c.moveTo(w * 0.45, 0);
  434. c.arcTo(w * 0.45, h * 0.5, 0, 0, 0, w * 0.45, h);
  435. c.close();
  436. c.stroke();
  437. }
  438. else if (type === mxArchiMateApplication.prototype.cst.SERVICE)
  439. {
  440. c.translate(0, 3);
  441. h = h - 6;
  442. c.begin();
  443. c.moveTo(w - h * 0.5, 0);
  444. c.arcTo(h * 0.5, h * 0.5, 0, 0, 1, w - h * 0.5, h);
  445. c.lineTo(0, h);
  446. c.arcTo(h * 0.5, h * 0.5, 0, 0, 1, 0, 0);
  447. c.close();
  448. c.stroke();
  449. }
  450. else if (type === mxArchiMateApplication.prototype.cst.NODE)
  451. {
  452. c.begin();
  453. c.moveTo(0, h * 0.25);
  454. c.lineTo(w * 0.25, 0);
  455. c.lineTo(w, 0);
  456. c.lineTo(w, h * 0.75);
  457. c.lineTo(w * 0.75, h);
  458. c.lineTo(0, h);
  459. c.close();
  460. c.moveTo(0, h * 0.25);
  461. c.lineTo(w * 0.75, h * 0.25);
  462. c.lineTo(w * 0.75, h);
  463. c.moveTo(w, 0);
  464. c.lineTo(w * 0.75, h * 0.25);
  465. c.stroke();
  466. }
  467. else if (type === mxArchiMateApplication.prototype.cst.NETWORK)
  468. {
  469. c.translate(0, 2);
  470. h = h - 4;
  471. c.begin();
  472. c.moveTo(w * 0.4, h * 0.2);
  473. c.lineTo(w * 0.85, h * 0.2);
  474. c.lineTo(w * 0.6, h * 0.8);
  475. c.lineTo(w * 0.15, h * 0.8);
  476. c.close();
  477. c.stroke();
  478. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  479. c.setFillColor(strokeColor);
  480. c.ellipse(w * 0.25, 0, w * 0.3, h * 0.4);
  481. c.fill();
  482. c.ellipse(w * 0.7, 0, w * 0.3, h * 0.4);
  483. c.fill();
  484. c.ellipse(0, h * 0.6, w * 0.3, h * 0.4);
  485. c.fill();
  486. c.ellipse(w * 0.45, h * 0.6, w * 0.3, h * 0.4);
  487. c.fill();
  488. }
  489. else if (type === mxArchiMateApplication.prototype.cst.COMM_PATH)
  490. {
  491. c.translate(0, 5);
  492. h = h - 10;
  493. c.begin();
  494. c.moveTo(w * 0.1, 0);
  495. c.lineTo(0, h * 0.5);
  496. c.lineTo(w * 0.1, h);
  497. c.moveTo(w * 0.9, 0);
  498. c.lineTo(w, h * 0.5);
  499. c.lineTo(w * 0.9, h);
  500. c.stroke();
  501. c.setDashed(true);
  502. c.begin();
  503. c.moveTo(0, h * 0.5);
  504. c.lineTo(w, h * 0.5);
  505. c.stroke();
  506. }
  507. else if (type === mxArchiMateApplication.prototype.cst.SYS_SW)
  508. {
  509. c.ellipse(w * 0.3, 0, w * 0.7, h * 0.7);
  510. c.stroke();
  511. c.ellipse(0, h * 0.02, w * 0.98, h * 0.98);
  512. c.fillAndStroke();
  513. }
  514. else if (type === mxArchiMateApplication.prototype.cst.ARTIFACT)
  515. {
  516. c.translate(2, 0);
  517. w = w - 4;
  518. c.begin();
  519. c.moveTo(0, 0);
  520. c.lineTo(w * 0.7, 0);
  521. c.lineTo(w, h * 0.22);
  522. c.lineTo(w, h);
  523. c.lineTo(0, h);
  524. c.close();
  525. c.moveTo(w * 0.7, 0);
  526. c.lineTo(w * 0.7, h * 0.22);
  527. c.lineTo(w, h * 0.22);
  528. c.stroke();
  529. }
  530. else if (type === mxArchiMateApplication.prototype.cst.ACTOR)
  531. {
  532. c.translate(3, 0);
  533. w = w - 6;
  534. c.ellipse(w * 0.2, 0, w * 0.6, h * 0.3);
  535. c.stroke();
  536. c.begin();
  537. c.moveTo(w * 0.5, h * 0.3);
  538. c.lineTo(w * 0.5, h * 0.75);
  539. c.moveTo(0, h * 0.45);
  540. c.lineTo(w, h * 0.45);
  541. c.moveTo(0, h);
  542. c.lineTo(w * 0.5, h * 0.75);
  543. c.lineTo(w, h);
  544. c.stroke();
  545. }
  546. if (type === mxArchiMateApplication.prototype.cst.ROLE)
  547. {
  548. c.translate(0, 4);
  549. h = h - 8;
  550. c.begin();
  551. c.moveTo(w * 0.8, 0);
  552. c.lineTo(w * 0.2, 0);
  553. c.arcTo(w * 0.2, h * 0.5, 0, 0, 0, w * 0.2, h);
  554. c.lineTo(w * 0.8, h);
  555. c.stroke();
  556. c.ellipse(w * 0.6, 0, w * 0.4, h);
  557. c.stroke();
  558. }
  559. // else if (type === mxArchiMateApplication.prototype.cst.COLLABORATION)
  560. // {
  561. // c.translate(0, 3);
  562. // h = h - 6;
  563. //
  564. // c.ellipse(0, 0, w * 0.6, h);
  565. // c.stroke();
  566. // c.ellipse(w * 0.4, 0, w * 0.6, h);
  567. // c.stroke();
  568. // }
  569. };
  570. mxCellRenderer.registerShape(mxArchiMateApplication.prototype.cst.APPLICATION, mxArchiMateApplication);
  571. //**********************************************************************************************************************************************************
  572. //Tech
  573. //**********************************************************************************************************************************************************
  574. /**
  575. * Extends mxShape.
  576. */
  577. function mxArchiMateTech(bounds, fill, stroke, strokewidth)
  578. {
  579. mxShape.call(this);
  580. this.bounds = bounds;
  581. this.fill = fill;
  582. this.stroke = stroke;
  583. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  584. };
  585. /**
  586. * Extends mxShape.
  587. */
  588. mxUtils.extend(mxArchiMateTech, mxShape);
  589. mxArchiMateTech.prototype.cst = {
  590. TECH : 'mxgraph.archimate.tech',
  591. TYPE : 'techType',
  592. DEVICE : 'device',
  593. PLATEAU : 'plateau'
  594. };
  595. /**
  596. * Function: paintVertexShape
  597. *
  598. * Paints the vertex shape.
  599. */
  600. mxArchiMateTech.prototype.paintVertexShape = function(c, x, y, w, h)
  601. {
  602. c.translate(x, y);
  603. this.background(c, 0, 0, w, h);
  604. c.setShadow(false);
  605. c.translate(w - 30, 15);
  606. this.foreground(c, w - 30, 15, 15, 15);
  607. };
  608. mxArchiMateTech.prototype.background = function(c, x, y, w, h)
  609. {
  610. c.begin();
  611. c.moveTo(0, 10);
  612. c.lineTo(10, 0);
  613. c.lineTo(w, 0);
  614. c.lineTo(w, h - 10);
  615. c.lineTo(w - 10, h);
  616. c.lineTo(0, h);
  617. c.close();
  618. c.moveTo(0, 10);
  619. c.lineTo(w - 10, 10);
  620. c.lineTo(w - 10, h);
  621. c.moveTo(w, 0);
  622. c.lineTo(w - 10, 10);
  623. c.fillAndStroke();
  624. };
  625. mxArchiMateTech.prototype.foreground = function(c, x, y, w, h)
  626. {
  627. var type = mxUtils.getValue(this.style, mxArchiMateTech.prototype.cst.TYPE, mxArchiMateTech.prototype.cst.DEVICE);
  628. c.setDashed(false);
  629. if (type === mxArchiMateTech.prototype.cst.DEVICE)
  630. {
  631. c.roundrect(0, 0, w, h * 0.88, w * 0.05, h * 0.05);
  632. c.stroke();
  633. c.begin();
  634. c.moveTo(w * 0.1, h * 0.88);
  635. c.lineTo(0, h);
  636. c.lineTo(w, h);
  637. c.lineTo(w * 0.9, h * 0.88);
  638. c.stroke();
  639. }
  640. else if (type === mxArchiMateTech.prototype.cst.PLATEAU)
  641. {
  642. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  643. c.setFillColor(strokeColor);
  644. c.rect(w * 0.4, 0, w * 0.6, h * 0.2);
  645. c.fill();
  646. c.rect(w * 0.2, h * 0.4, w * 0.6, h * 0.2);
  647. c.fill();
  648. c.rect(0, h * 0.8, w * 0.6, h * 0.2);
  649. c.fill();
  650. }
  651. };
  652. mxCellRenderer.registerShape(mxArchiMateTech.prototype.cst.TECH, mxArchiMateTech);
  653. //**********************************************************************************************************************************************************
  654. //Motivational
  655. //**********************************************************************************************************************************************************
  656. /**
  657. * Extends mxShape.
  658. */
  659. function mxArchiMateMotivational(bounds, fill, stroke, strokewidth)
  660. {
  661. mxShape.call(this);
  662. this.bounds = bounds;
  663. this.fill = fill;
  664. this.stroke = stroke;
  665. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  666. };
  667. /**
  668. * Extends mxShape.
  669. */
  670. mxUtils.extend(mxArchiMateMotivational, mxShape);
  671. mxArchiMateMotivational.prototype.cst = {
  672. MOTIV : 'mxgraph.archimate.motiv',
  673. TYPE : 'motivType',
  674. STAKE : 'stake',
  675. DRIVER : 'driver',
  676. ASSESSMENT : 'assess',
  677. GOAL : 'goal',
  678. REQUIREMENT : 'req',
  679. CONSTRAINT : 'const',
  680. PRINCIPLE : 'princ'
  681. };
  682. /**
  683. * Function: paintVertexShape
  684. *
  685. * Paints the vertex shape.
  686. */
  687. mxArchiMateMotivational.prototype.paintVertexShape = function(c, x, y, w, h)
  688. {
  689. c.translate(x, y);
  690. this.background(c, 0, 0, w, h);
  691. c.setShadow(false);
  692. c.translate(w - 20, 5);
  693. this.foreground(c, w - 20, 5, 15, 15);
  694. };
  695. mxArchiMateMotivational.prototype.background = function(c, x, y, w, h)
  696. {
  697. c.begin();
  698. c.moveTo(10, 0);
  699. c.lineTo(w - 10, 0);
  700. c.lineTo(w, 10);
  701. c.lineTo(w, h - 10);
  702. c.lineTo(w - 10, h);
  703. c.lineTo(10, h);
  704. c.lineTo(0, h - 10);
  705. c.lineTo(0, 10);
  706. c.close();
  707. c.fillAndStroke();
  708. };
  709. mxArchiMateMotivational.prototype.foreground = function(c, x, y, w, h)
  710. {
  711. var type = mxUtils.getValue(this.style, mxArchiMateMotivational.prototype.cst.TYPE, mxArchiMateMotivational.prototype.cst.STAKE);
  712. c.setDashed(false);
  713. if (type === mxArchiMateMotivational.prototype.cst.STAKE)
  714. {
  715. c.translate(0, 4);
  716. h = h - 8;
  717. c.begin();
  718. c.moveTo(w * 0.8, 0);
  719. c.lineTo(w * 0.2, 0);
  720. c.arcTo(w * 0.2, h * 0.5, 0, 0, 0, w * 0.2, h);
  721. c.lineTo(w * 0.8, h);
  722. c.stroke();
  723. c.ellipse(w * 0.6, 0, w * 0.4, h);
  724. c.stroke();
  725. }
  726. else if (type === mxArchiMateMotivational.prototype.cst.DRIVER)
  727. {
  728. c.ellipse(w * 0.1, h * 0.1, w * 0.8, h * 0.8);
  729. c.stroke();
  730. c.begin();
  731. c.moveTo(0, h * 0.5);
  732. c.lineTo(w, h * 0.5);
  733. c.moveTo(w * 0.5, 0);
  734. c.lineTo(w * 0.5, h);
  735. c.moveTo(w * 0.145, h * 0.145);
  736. c.lineTo(w * 0.855, h * 0.855);
  737. c.moveTo(w * 0.145, h * 0.855);
  738. c.lineTo(w * 0.855, h * 0.145);
  739. c.stroke();
  740. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  741. c.setFillColor(strokeColor);
  742. c.ellipse(w * 0.35, h * 0.35, w * 0.3, h * 0.3);
  743. c.fillAndStroke();
  744. }
  745. else if (type === mxArchiMateMotivational.prototype.cst.ASSESSMENT)
  746. {
  747. c.ellipse(w * 0.2, 0, w * 0.8, h * 0.8);
  748. c.stroke();
  749. c.begin();
  750. c.moveTo(0, h);
  751. c.lineTo(w * 0.32, h * 0.68);
  752. c.stroke();
  753. }
  754. else if (type === mxArchiMateMotivational.prototype.cst.GOAL)
  755. {
  756. c.ellipse(0, 0, w, h);
  757. c.stroke();
  758. c.ellipse(w * 0.15, h * 0.15, w * 0.7, h * 0.7);
  759. c.stroke();
  760. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  761. c.setFillColor(strokeColor);
  762. c.ellipse(w * 0.3, h * 0.3, w * 0.4, h * 0.4);
  763. c.fillAndStroke();
  764. }
  765. else if (type === mxArchiMateMotivational.prototype.cst.REQUIREMENT)
  766. {
  767. c.translate(0, 4);
  768. h = h - 8;
  769. c.begin();
  770. c.moveTo(w * 0.25, 0);
  771. c.lineTo(w, 0);
  772. c.lineTo(w * 0.75, h);
  773. c.lineTo(0, h);
  774. c.close();
  775. c.stroke();
  776. }
  777. else if (type === mxArchiMateMotivational.prototype.cst.CONSTRAINT)
  778. {
  779. c.translate(0, 4);
  780. h = h - 8;
  781. c.begin();
  782. c.moveTo(w * 0.25, 0);
  783. c.lineTo(w, 0);
  784. c.lineTo(w * 0.75, h);
  785. c.lineTo(0, h);
  786. c.close();
  787. c.moveTo(w * 0.45, 0);
  788. c.lineTo(w * 0.2, h);
  789. c.stroke();
  790. }
  791. else if (type === mxArchiMateMotivational.prototype.cst.PRINCIPLE)
  792. {
  793. c.begin();
  794. c.moveTo(w * 0.05, h * 0.05);
  795. c.arcTo(w * 2.3, h * 2.3, 0, 0, 1, w * 0.95, h * 0.05);
  796. c.arcTo(w * 2.3, h * 2.3, 0, 0, 1, w * 0.95, h * 0.95);
  797. c.arcTo(w * 2.3, h * 2.3, 0, 0, 1, w * 0.05, h * 0.95);
  798. c.arcTo(w * 2.3, h * 2.3, 0, 0, 1, w * 0.05, h * 0.05);
  799. c.close();
  800. c.stroke();
  801. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  802. c.setFillColor(strokeColor);
  803. c.begin();
  804. c.moveTo(w * 0.45, h * 0.7);
  805. c.lineTo(w * 0.42, h * 0.15);
  806. c.lineTo(w * 0.58, h * 0.15);
  807. c.lineTo(w * 0.55, h * 0.7);
  808. c.close();
  809. c.fill();
  810. c.rect(w * 0.45, h * 0.75, w * 0.1, h * 0.1);
  811. c.fill();
  812. }
  813. };
  814. mxCellRenderer.registerShape(mxArchiMateMotivational.prototype.cst.MOTIV, mxArchiMateMotivational);
  815. //**********************************************************************************************************************************************************
  816. //Representation
  817. //**********************************************************************************************************************************************************
  818. /**
  819. * Extends mxShape.
  820. */
  821. function mxArchiMateGap(bounds, fill, stroke, strokewidth)
  822. {
  823. mxShape.call(this);
  824. this.bounds = bounds;
  825. this.fill = fill;
  826. this.stroke = stroke;
  827. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  828. };
  829. /**
  830. * Extends mxShape.
  831. */
  832. mxUtils.extend(mxArchiMateGap, mxShape);
  833. mxArchiMateGap.prototype.cst = {
  834. GAP : 'mxgraph.archimate.gap'
  835. };
  836. /**
  837. * Function: paintVertexShape
  838. *
  839. * Paints the vertex shape.
  840. */
  841. mxArchiMateGap.prototype.paintVertexShape = function(c, x, y, w, h)
  842. {
  843. c.translate(x, y);
  844. this.background(c, 0, 0, w, h);
  845. c.setShadow(false);
  846. c.translate(w - 20, 5);
  847. this.foreground(c, w - 20, 5, 15, 15);
  848. };
  849. mxArchiMateGap.prototype.background = function(c, x, y, w, h)
  850. {
  851. c.begin();
  852. c.moveTo(0, 0);
  853. c.lineTo(w, 0);
  854. c.lineTo(w, h * 0.85);
  855. c.arcTo(w * 0.35, h * 0.35, 0, 0, 0, w * 0.5, h * 0.85);
  856. c.arcTo(w * 0.35, h * 0.35, 0, 0, 1, 0, h * 0.85);
  857. c.close();
  858. c.fillAndStroke();
  859. };
  860. mxArchiMateGap.prototype.foreground = function(c, x, y, w, h)
  861. {
  862. c.setDashed(false);
  863. c.translate(0, 2);
  864. h = h - 4;
  865. c.ellipse(w * 0.15, 0, w * 0.7, h);
  866. c.stroke();
  867. c.begin();
  868. c.moveTo(0, h * 0.35);
  869. c.lineTo(w, h * 0.35);
  870. c.moveTo(0, h * 0.65);
  871. c.lineTo(w, h * 0.65);
  872. c.stroke();
  873. };
  874. mxCellRenderer.registerShape(mxArchiMateGap.prototype.cst.GAP, mxArchiMateGap);