PathMap.d.ts 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. /**
  2. * Map containing SVG paths needed by BpmnRenderer
  3. */
  4. export default class PathMap {
  5. /**
  6. * Contains a map of path elements
  7. *
  8. * <h1>Path definition</h1>
  9. * A parameterized path is defined like this:
  10. * <pre>
  11. * 'GATEWAY_PARALLEL': {
  12. * d: 'm {mx},{my} {e.x0},0 0,{e.x1} {e.x1},0 0,{e.y0} -{e.x1},0 0,{e.y1} ' +
  13. '-{e.x0},0 0,-{e.y1} -{e.x1},0 0,-{e.y0} {e.x1},0 z',
  14. * height: 17.5,
  15. * width: 17.5,
  16. * heightElements: [2.5, 7.5],
  17. * widthElements: [2.5, 7.5]
  18. * }
  19. * </pre>
  20. * <p>It's important to specify a correct <b>height and width</b> for the path as the scaling
  21. * is based on the ratio between the specified height and width in this object and the
  22. * height and width that is set as scale target (Note x,y coordinates will be scaled with
  23. * individual ratios).</p>
  24. * <p>The '<b>heightElements</b>' and '<b>widthElements</b>' array must contain the values that will be scaled.
  25. * The scaling is based on the computed ratios.
  26. * Coordinates on the y axis should be in the <b>heightElement</b>'s array, they will be scaled using
  27. * the computed ratio coefficient.
  28. * In the parameterized path the scaled values can be accessed through the 'e' object in {} brackets.
  29. * <ul>
  30. * <li>The values for the y axis can be accessed in the path string using {e.y0}, {e.y1}, ....</li>
  31. * <li>The values for the x axis can be accessed in the path string using {e.x0}, {e.x1}, ....</li>
  32. * </ul>
  33. * The numbers x0, x1 respectively y0, y1, ... map to the corresponding array index.
  34. * </p>
  35. */
  36. pathMap: {
  37. EVENT_MESSAGE: {
  38. d: string;
  39. height: number;
  40. width: number;
  41. heightElements: number[];
  42. widthElements: number[];
  43. };
  44. EVENT_SIGNAL: {
  45. d: string;
  46. height: number;
  47. width: number;
  48. heightElements: number[];
  49. widthElements: number[];
  50. };
  51. EVENT_ESCALATION: {
  52. d: string;
  53. height: number;
  54. width: number;
  55. heightElements: number[];
  56. widthElements: number[];
  57. };
  58. EVENT_CONDITIONAL: {
  59. d: string;
  60. height: number;
  61. width: number;
  62. heightElements: number[];
  63. widthElements: number[];
  64. };
  65. EVENT_LINK: {
  66. d: string;
  67. height: number;
  68. width: number;
  69. heightElements: number[];
  70. widthElements: number[];
  71. };
  72. EVENT_ERROR: {
  73. d: string;
  74. height: number;
  75. width: number;
  76. heightElements: number[];
  77. widthElements: number[];
  78. };
  79. EVENT_CANCEL_45: {
  80. d: string;
  81. height: number;
  82. width: number;
  83. heightElements: number[];
  84. widthElements: number[];
  85. };
  86. EVENT_COMPENSATION: {
  87. d: string;
  88. height: number;
  89. width: number;
  90. heightElements: number[];
  91. widthElements: number[];
  92. };
  93. EVENT_TIMER_WH: {
  94. d: string;
  95. height: number;
  96. width: number;
  97. heightElements: number[];
  98. widthElements: number[];
  99. };
  100. EVENT_TIMER_LINE: {
  101. d: string;
  102. height: number;
  103. width: number;
  104. heightElements: number[];
  105. widthElements: number[];
  106. };
  107. EVENT_MULTIPLE: {
  108. d: string;
  109. height: number;
  110. width: number;
  111. heightElements: number[];
  112. widthElements: number[];
  113. };
  114. EVENT_PARALLEL_MULTIPLE: {
  115. d: string;
  116. height: number;
  117. width: number;
  118. heightElements: number[];
  119. widthElements: number[];
  120. };
  121. GATEWAY_EXCLUSIVE: {
  122. d: string;
  123. height: number;
  124. width: number;
  125. heightElements: number[];
  126. widthElements: number[];
  127. };
  128. GATEWAY_PARALLEL: {
  129. d: string;
  130. height: number;
  131. width: number;
  132. heightElements: number[];
  133. widthElements: number[];
  134. };
  135. GATEWAY_EVENT_BASED: {
  136. d: string;
  137. height: number;
  138. width: number;
  139. heightElements: number[];
  140. widthElements: number[];
  141. };
  142. GATEWAY_COMPLEX: {
  143. d: string;
  144. height: number;
  145. width: number;
  146. heightElements: number[];
  147. widthElements: number[];
  148. };
  149. DATA_OBJECT_PATH: {
  150. d: string;
  151. height: number;
  152. width: number;
  153. heightElements: number[];
  154. widthElements: number[];
  155. };
  156. DATA_OBJECT_COLLECTION_PATH: {
  157. d: string;
  158. height: number;
  159. width: number;
  160. heightElements: any[];
  161. widthElements: any[];
  162. };
  163. DATA_ARROW: {
  164. d: string;
  165. height: number;
  166. width: number;
  167. heightElements: any[];
  168. widthElements: any[];
  169. };
  170. DATA_STORE: {
  171. d: string;
  172. height: number;
  173. width: number;
  174. heightElements: number[];
  175. widthElements: number[];
  176. };
  177. TEXT_ANNOTATION: {
  178. d: string;
  179. height: number;
  180. width: number;
  181. heightElements: number[];
  182. widthElements: number[];
  183. };
  184. MARKER_SUB_PROCESS: {
  185. d: string;
  186. height: number;
  187. width: number;
  188. heightElements: any[];
  189. widthElements: any[];
  190. };
  191. MARKER_PARALLEL: {
  192. d: string;
  193. height: number;
  194. width: number;
  195. heightElements: any[];
  196. widthElements: any[];
  197. };
  198. MARKER_SEQUENTIAL: {
  199. d: string;
  200. height: number;
  201. width: number;
  202. heightElements: any[];
  203. widthElements: any[];
  204. };
  205. MARKER_COMPENSATION: {
  206. d: string;
  207. height: number;
  208. width: number;
  209. heightElements: any[];
  210. widthElements: any[];
  211. };
  212. MARKER_LOOP: {
  213. d: string;
  214. height: number;
  215. width: number;
  216. heightElements: any[];
  217. widthElements: any[];
  218. };
  219. MARKER_ADHOC: {
  220. d: string;
  221. height: number;
  222. width: number;
  223. heightElements: any[];
  224. widthElements: any[];
  225. };
  226. TASK_TYPE_SEND: {
  227. d: string;
  228. height: number;
  229. width: number;
  230. heightElements: number[];
  231. widthElements: number[];
  232. };
  233. TASK_TYPE_SCRIPT: {
  234. d: string;
  235. height: number;
  236. width: number;
  237. heightElements: number[];
  238. widthElements: number[];
  239. };
  240. TASK_TYPE_USER_1: {
  241. d: string;
  242. };
  243. TASK_TYPE_USER_2: {
  244. d: string;
  245. };
  246. TASK_TYPE_USER_3: {
  247. d: string;
  248. };
  249. TASK_TYPE_MANUAL: {
  250. d: string;
  251. };
  252. TASK_TYPE_INSTANTIATING_SEND: {
  253. d: string;
  254. };
  255. TASK_TYPE_SERVICE: {
  256. d: string;
  257. };
  258. TASK_TYPE_SERVICE_FILL: {
  259. d: string;
  260. };
  261. TASK_TYPE_BUSINESS_RULE_HEADER: {
  262. d: string;
  263. };
  264. TASK_TYPE_BUSINESS_RULE_MAIN: {
  265. d: string;
  266. };
  267. MESSAGE_FLOW_MARKER: {
  268. d: string;
  269. };
  270. };
  271. /**
  272. * Return raw path for the given ID.
  273. *
  274. * @param pathId
  275. *
  276. * @return raw path
  277. */
  278. getRawPath: (pathId: string) => string;
  279. /**
  280. * Scales the path to the given height and width.
  281. * <h1>Use case</h1>
  282. * <p>Use case is to scale the content of elements (event, gateways) based
  283. * on the element bounding box's size.
  284. * </p>
  285. * <h1>Why not transform</h1>
  286. * <p>Scaling a path with transform() will also scale the stroke and IE does not support
  287. * the option 'non-scaling-stroke' to prevent this.
  288. * Also there are use cases where only some parts of a path should be
  289. * scaled.</p>
  290. *
  291. * @param pathId The ID of the path.
  292. * @param param <p>
  293. * Example param object scales the path to 60% size of the container (data.width, data.height).
  294. * <pre>
  295. * {
  296. * xScaleFactor: 0.6,
  297. * yScaleFactor:0.6,
  298. * containerWidth: data.width,
  299. * containerHeight: data.height,
  300. * position: {
  301. * mx: 0.46,
  302. * my: 0.2,
  303. * }
  304. * }
  305. * </pre>
  306. * <ul>
  307. * <li>targetpathwidth = xScaleFactor * containerWidth</li>
  308. * <li>targetpathheight = yScaleFactor * containerHeight</li>
  309. * <li>Position is used to set the starting coordinate of the path. M is computed:
  310. * <ul>
  311. * <li>position.x * containerWidth</li>
  312. * <li>position.y * containerHeight</li>
  313. * </ul>
  314. * Center of the container <pre> position: {
  315. * mx: 0.5,
  316. * my: 0.5,
  317. * }</pre>
  318. * Upper left corner of the container
  319. * <pre> position: {
  320. * mx: 0.0,
  321. * my: 0.0,
  322. * }</pre>
  323. * </li>
  324. * </ul>
  325. * </p>
  326. *
  327. * @return scaled path
  328. */
  329. getScaledPath: (pathId: string, param: any) => string;
  330. }