Shapes.js 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240
  1. /**
  2. *$id:Action 。JS,V 2017-12-19
  3. *$author shen.zhi
  4. */
  5. /**
  6. * Registers shapes.
  7. */
  8. (function()
  9. {
  10. // Cube Shape, supports size style
  11. function CubeShape() { };
  12. CubeShape.prototype = new mxCylinder();
  13. CubeShape.prototype.constructor = CubeShape;
  14. CubeShape.prototype.size = 20;
  15. CubeShape.prototype.redrawPath = function(path, x, y, w, h, isForeground)
  16. {
  17. var s = Math.min(w, Math.min(h, mxUtils.getValue(this.style, 'size', this.size) * this.scale));
  18. if (isForeground)
  19. {
  20. path.moveTo(s, h);
  21. path.lineTo(s, s);
  22. path.lineTo(0, 0);
  23. path.moveTo(s, s);
  24. path.lineTo(w, s);
  25. path.end();
  26. }
  27. else
  28. {
  29. path.moveTo(0, 0);
  30. path.lineTo(w - s, 0);
  31. path.lineTo(w, s);
  32. path.lineTo(w, h);
  33. path.lineTo(s, h);
  34. path.lineTo(0, h - s);
  35. path.lineTo(0, 0);
  36. path.close();
  37. path.end();
  38. }
  39. };
  40. mxCellRenderer.prototype.defaultShapes['cube'] = CubeShape;
  41. // Note Shape, supports size style
  42. function NoteShape() { };
  43. NoteShape.prototype = new mxCylinder();
  44. NoteShape.prototype.constructor = NoteShape;
  45. NoteShape.prototype.size = 30;
  46. NoteShape.prototype.redrawPath = function(path, x, y, w, h, isForeground)
  47. {
  48. var s = Math.min(w, Math.min(h, mxUtils.getValue(this.style, 'size', this.size) * this.scale));
  49. if (isForeground)
  50. {
  51. path.moveTo(w - s, 0);
  52. path.lineTo(w - s, s);
  53. path.lineTo(w, s);
  54. path.end();
  55. }
  56. else
  57. {
  58. path.moveTo(0, 0);
  59. path.lineTo(w - s, 0);
  60. path.lineTo(w, s);
  61. path.lineTo(w, h);
  62. path.lineTo(0, h);
  63. path.lineTo(0, 0);
  64. path.close();
  65. path.end();
  66. }
  67. };
  68. mxCellRenderer.prototype.defaultShapes['note'] = NoteShape;
  69. // Folder Shape, supports tabWidth, tabHeight styles
  70. function FolderShape() { };
  71. FolderShape.prototype = new mxCylinder();
  72. FolderShape.prototype.constructor = FolderShape;
  73. FolderShape.prototype.tabWidth = 60;
  74. FolderShape.prototype.tabHeight = 20;
  75. FolderShape.prototype.tabPosition = 'right';
  76. FolderShape.prototype.redrawPath = function(path, x, y, w, h, isForeground)
  77. {
  78. var tw = mxUtils.getValue(this.style, 'tabWidth', this.tabWidth);
  79. var th = mxUtils.getValue(this.style, 'tabHeight', this.tabHeight);
  80. var tp = mxUtils.getValue(this.style, 'tabPosition', this.tabPosition);
  81. var dx = Math.min(w, tw * this.scale);
  82. var dy = Math.min(h, th * this.scale);
  83. if (isForeground)
  84. {
  85. if (tp == 'left')
  86. {
  87. path.moveTo(0, dy);
  88. path.lineTo(dx, dy);
  89. }
  90. // Right is default
  91. else
  92. {
  93. path.moveTo(w - dx, dy);
  94. path.lineTo(w, dy);
  95. }
  96. path.end();
  97. }
  98. else
  99. {
  100. if (tp == 'left')
  101. {
  102. path.moveTo(0, 0);
  103. path.lineTo(dx, 0);
  104. path.lineTo(dx, dy);
  105. path.lineTo(w, dy);
  106. }
  107. // Right is default
  108. else
  109. {
  110. path.moveTo(0, dy);
  111. path.lineTo(w - dx, dy);
  112. path.lineTo(w - dx, 0);
  113. path.lineTo(w, 0);
  114. }
  115. path.lineTo(w, h);
  116. path.lineTo(0, h);
  117. path.lineTo(0, dy);
  118. path.close();
  119. path.end();
  120. }
  121. };
  122. mxCellRenderer.prototype.defaultShapes['folder'] = FolderShape;
  123. // Card Shape, supports size style
  124. function CardShape() { };
  125. CardShape.prototype = new mxCylinder();
  126. CardShape.prototype.constructor = CardShape;
  127. CardShape.prototype.size = 30;
  128. CardShape.prototype.redrawPath = function(path, x, y, w, h, isForeground)
  129. {
  130. var s = Math.min(w, Math.min(h, mxUtils.getValue(this.style, 'size', this.size) * this.scale));
  131. if (!isForeground)
  132. {
  133. path.moveTo(s, 0);
  134. path.lineTo(w, 0);
  135. path.lineTo(w, h);
  136. path.lineTo(0, h);
  137. path.lineTo(0, s);
  138. path.lineTo(s, 0);
  139. path.close();
  140. path.end();
  141. }
  142. };
  143. mxCellRenderer.prototype.defaultShapes['card'] = CardShape;
  144. // Tape Shape, supports size style
  145. function TapeShape() { };
  146. TapeShape.prototype = new mxCylinder();
  147. TapeShape.prototype.constructor = TapeShape;
  148. TapeShape.prototype.size = 0.4;
  149. TapeShape.prototype.redrawPath = function(path, x, y, w, h, isForeground)
  150. {
  151. var s = mxUtils.getValue(this.style, 'size', this.size);
  152. var dy = h * s;
  153. var fy = 1.4;
  154. if (!isForeground)
  155. {
  156. path.moveTo(0, dy / 2);
  157. path.quadTo(w / 4, dy * fy, w / 2, dy / 2);
  158. path.quadTo(w * 3 / 4, dy * (1 - fy), w, dy / 2);
  159. path.lineTo(w, h - dy / 2);
  160. path.quadTo(w * 3 / 4, h - dy * fy, w / 2, h - dy / 2);
  161. path.quadTo(w / 4, h - dy * (1 - fy), 0, h - dy / 2);
  162. path.lineTo(0, dy / 2);
  163. path.close();
  164. path.end();
  165. }
  166. };
  167. mxCellRenderer.prototype.defaultShapes['tape'] = TapeShape;
  168. // Tape Shape, supports size style
  169. function StepShape() { };
  170. StepShape.prototype = new mxCylinder();
  171. StepShape.prototype.constructor = StepShape;
  172. StepShape.prototype.size = 0.2;
  173. StepShape.prototype.redrawPath = function(path, x, y, w, h, isForeground)
  174. {
  175. var s = w * mxUtils.getValue(this.style, 'size', this.size);
  176. if (!isForeground)
  177. {
  178. path.moveTo(0, 0);
  179. path.lineTo(w - s, 0);
  180. path.lineTo(w, h / 2);
  181. path.lineTo(w - s, h);
  182. path.lineTo(0, h);
  183. path.lineTo(s, h / 2);
  184. path.close();
  185. path.end();
  186. }
  187. };
  188. mxCellRenderer.prototype.defaultShapes['step'] = StepShape;
  189. // Tape Shape, supports size style
  190. function PlusShape() { };
  191. PlusShape.prototype = new mxCylinder();
  192. PlusShape.prototype.constructor = PlusShape;
  193. PlusShape.prototype.redrawPath = function(path, x, y, w, h, isForeground)
  194. {
  195. var border = Math.min(w / 5, h / 5) + 1;
  196. if (isForeground)
  197. {
  198. path.moveTo(w / 2, border);
  199. path.lineTo(w / 2, h - border);
  200. path.moveTo(border, h / 2);
  201. path.lineTo(w - border, h / 2);
  202. path.end();
  203. }
  204. else
  205. {
  206. path.moveTo(0, 0);
  207. path.lineTo(w, 0);
  208. path.lineTo(w, h);
  209. path.lineTo(0, h);
  210. path.close();
  211. }
  212. };
  213. mxCellRenderer.prototype.defaultShapes['plus'] = PlusShape;
  214. // Tape Shape, supports size style
  215. function MessageShape() { };
  216. MessageShape.prototype = new mxCylinder();
  217. MessageShape.prototype.constructor = MessageShape;
  218. MessageShape.prototype.redrawPath = function(path, x, y, w, h, isForeground)
  219. {
  220. if (isForeground)
  221. {
  222. path.moveTo(0, 0);
  223. path.lineTo(w / 2, h / 2);
  224. path.lineTo(w, 0);
  225. path.end();
  226. }
  227. else
  228. {
  229. path.moveTo(0, 0);
  230. path.lineTo(w, 0);
  231. path.lineTo(w, h);
  232. path.lineTo(0, h);
  233. path.close();
  234. }
  235. };
  236. mxCellRenderer.prototype.defaultShapes['message'] = MessageShape;
  237. // New Actor Shape
  238. function UmlActorShape() { };
  239. UmlActorShape.prototype = new mxCylinder();
  240. UmlActorShape.prototype.constructor = UmlActorShape;
  241. UmlActorShape.prototype.addPipe = true;
  242. UmlActorShape.prototype.redrawPath = function(path, x, y, w, h, isForeground)
  243. {
  244. var width = w / 3;
  245. var height = h / 4;
  246. if (!isForeground)
  247. {
  248. path.moveTo(w / 2, height);
  249. path.curveTo(w / 2 - width, height, w / 2 - width, 0, w / 2, 0);
  250. path.curveTo(w / 2 + width, 0, w / 2 + width, height, w / 2, height);
  251. path.close();
  252. path.moveTo(w / 2, height);
  253. path.lineTo(w / 2, 2 * h / 3);
  254. // Arms
  255. path.moveTo(w / 2, h / 3);
  256. path.lineTo(0, h / 3);
  257. path.moveTo(w / 2, h / 3);
  258. path.lineTo(w, h / 3);
  259. // Legs
  260. path.moveTo(w / 2, 2 * h / 3);
  261. path.lineTo(0, h);
  262. path.moveTo(w / 2, 2 * h / 3);
  263. path.lineTo(w, h);
  264. path.end();
  265. }
  266. };
  267. // Replaces existing actor shape
  268. mxCellRenderer.prototype.defaultShapes['umlActor'] = UmlActorShape;
  269. // New Actor Shape
  270. function LollipopShape() { };
  271. LollipopShape.prototype = new mxCylinder();
  272. LollipopShape.prototype.constructor = LollipopShape;
  273. LollipopShape.prototype.size = 10;
  274. LollipopShape.prototype.addPipe = true;
  275. LollipopShape.prototype.redrawPath = function(path, x, y, w, h, isForeground)
  276. {
  277. var ss = this.scale * mxUtils.getValue(this.style, 'size', this.size);
  278. var width = ss * 2 / 3;
  279. var height = ss;
  280. if (!isForeground)
  281. {
  282. path.moveTo(w / 2, height);
  283. path.curveTo(w / 2 - width, height, w / 2 - width, 0, w / 2, 0);
  284. path.curveTo(w / 2 + width, 0, w / 2 + width, height, w / 2, height);
  285. path.close();
  286. path.moveTo(w / 2, height);
  287. path.lineTo(w / 2, h);
  288. path.end();
  289. }
  290. };
  291. // Replaces existing actor shape
  292. mxCellRenderer.prototype.defaultShapes['lollipop'] = LollipopShape;
  293. // Folder Shape, supports tabWidth, tabHeight styles
  294. function ComponentShape() { };
  295. ComponentShape.prototype = new mxCylinder();
  296. ComponentShape.prototype.constructor = ComponentShape;
  297. ComponentShape.prototype.jettyWidth = 32;
  298. ComponentShape.prototype.jettyHeight = 12;
  299. ComponentShape.prototype.redrawPath = function(path, x, y, w, h, isForeground)
  300. {
  301. var jw = mxUtils.getValue(this.style, 'jettyWidth', this.jettyWidth);
  302. var jh = mxUtils.getValue(this.style, 'jettyHeight', this.jettyHeight);
  303. var dx = jw * this.scale;
  304. var dy = jh * this.scale;
  305. var x0 = dx / 2;
  306. var x1 = x0 + dx / 2;
  307. var y0 = 0.3 * h - dy / 2;
  308. var y1 = 0.7 * h - dy / 2;
  309. if (isForeground)
  310. {
  311. path.moveTo(x0, y0);
  312. path.lineTo(x1, y0);
  313. path.lineTo(x1, y0 + dy);
  314. path.lineTo(x0, y0 + dy);
  315. path.moveTo(x0, y1);
  316. path.lineTo(x1, y1);
  317. path.lineTo(x1, y1 + dy);
  318. path.lineTo(x0, y1 + dy);
  319. path.end();
  320. }
  321. else
  322. {
  323. path.moveTo(x0, 0);
  324. path.lineTo(w, 0);
  325. path.lineTo(w, h);
  326. path.lineTo(x0, h);
  327. path.lineTo(x0, y1 + dy);
  328. path.lineTo(0, y1 + dy);
  329. path.lineTo(0, y1);
  330. path.lineTo(x0, y1);
  331. path.lineTo(x0, y0 + dy);
  332. path.lineTo(0, y0 + dy);
  333. path.lineTo(0, y0);
  334. path.lineTo(x0, y0);
  335. path.close();
  336. path.end();
  337. }
  338. };
  339. mxCellRenderer.prototype.defaultShapes['component'] = ComponentShape;
  340. // State Shapes derives from double ellipse
  341. function StateShape() { };
  342. StateShape.prototype = new mxDoubleEllipse();
  343. StateShape.prototype.constructor = StateShape;
  344. StateShape.prototype.outerStroke = true;
  345. StateShape.prototype.createSvg = function()
  346. {
  347. var g = mxDoubleEllipse.prototype.createSvg.apply(this, arguments);
  348. this.foreground.setAttribute('fill', this.innerNode.getAttribute('fill'));
  349. this.foreground.setAttribute('stroke', this.stroke);
  350. this.innerNode.setAttribute('fill', 'none');
  351. this.innerNode.setAttribute('stroke', (this.outerStroke) ? this.stroke : 'none');
  352. return g;
  353. };
  354. StateShape.prototype.redrawSvg = function()
  355. {
  356. mxDoubleEllipse.prototype.redrawSvg.apply(this, arguments);
  357. // Workaround for visible background
  358. this.innerNode.setAttribute('fill', 'none');
  359. if (this.shadowNode != null)
  360. {
  361. this.shadowNode.setAttribute('cx', this.foreground.getAttribute('cx'));
  362. this.shadowNode.setAttribute('cy', this.foreground.getAttribute('cy'));
  363. this.shadowNode.setAttribute('rx', this.foreground.getAttribute('rx'));
  364. this.shadowNode.setAttribute('ry', this.foreground.getAttribute('ry'));
  365. }
  366. };
  367. StateShape.prototype.createVml = function()
  368. {
  369. var result = mxDoubleEllipse.prototype.createVml.apply(this, arguments);
  370. if (this.fillNode != null)
  371. {
  372. this.foreground.appendChild(this.fillNode);
  373. this.foreground.filled = 'true';
  374. }
  375. this.background.filled = 'false';
  376. this.background.stroked = (this.outerStroke) ? 'true' : 'false';
  377. if (this.shadowNode != null)
  378. {
  379. this.foreground.appendChild(this.shadowNode);
  380. }
  381. return result;
  382. };
  383. StateShape.prototype.reconfigure = function()
  384. {
  385. mxShape.prototype.reconfigure.apply(this, arguments);
  386. if (this.dialect == mxConstants.DIALECT_SVG)
  387. {
  388. this.innerNode.setAttribute('fill', 'none');
  389. }
  390. else if (mxUtils.isVml(this.node))
  391. {
  392. this.background.filled = 'false';
  393. }
  394. };
  395. mxCellRenderer.prototype.defaultShapes['endState'] = StateShape;
  396. function StartStateShape() { };
  397. StartStateShape.prototype = new StateShape();
  398. StartStateShape.prototype.constructor = StartStateShape;
  399. StartStateShape.prototype.outerStroke = false;
  400. mxCellRenderer.prototype.defaultShapes['startState'] = StartStateShape;
  401. // Image export for state shapes
  402. var imageExportInitShapes = mxImageExport.prototype.initShapes;
  403. mxImageExport.prototype.initShapes = function()
  404. {
  405. imageExportInitShapes.apply(this, arguments);
  406. function createStateShape(outerStroke)
  407. {
  408. return {
  409. drawShape: function(canvas, state, bounds, background)
  410. {
  411. var x = bounds.x;
  412. var y = bounds.y;
  413. var w = bounds.width;
  414. var h = bounds.height;
  415. if (background)
  416. {
  417. var inset = Math.min(4, Math.min(w / 5, h / 5));
  418. x += inset;
  419. y += inset;
  420. w -= 2 * inset;
  421. h -= 2 * inset;
  422. if (w > 0 && h > 0)
  423. {
  424. canvas.ellipse(x, y, w, h);
  425. }
  426. return true;
  427. }
  428. else
  429. {
  430. canvas.fillAndStroke();
  431. if (outerStroke)
  432. {
  433. canvas.ellipse(x, y, w, h);
  434. canvas.stroke();
  435. }
  436. }
  437. }
  438. };
  439. };
  440. this.shapes['endState'] = createStateShape(true);
  441. this.shapes['startState'] = createStateShape(false);
  442. };
  443. // Custom edge shape
  444. function LinkShape() { };
  445. LinkShape.prototype = new mxArrow();
  446. LinkShape.prototype.constructor = LinkShape;
  447. LinkShape.prototype.enableFill = false;
  448. LinkShape.prototype.addPipe = true;
  449. LinkShape.prototype.augmentBoundingBox = function(bbox)
  450. {
  451. bbox.grow(10 * this.scale);
  452. mxShape.prototype.augmentBoundingBox.apply(this, arguments);
  453. };
  454. LinkShape.prototype.redrawPath = function(path, x, y, w, h)
  455. {
  456. // All points are offset
  457. path.translate.x -= x;
  458. path.translate.y -= y;
  459. // Geometry of arrow
  460. var width = 10 * this.scale;
  461. // Base vector (between end points)
  462. var p0 = this.points[0];
  463. var pe = this.points[this.points.length - 1];
  464. var dx = pe.x - p0.x;
  465. var dy = pe.y - p0.y;
  466. var dist = Math.sqrt(dx * dx + dy * dy);
  467. var length = dist;
  468. // Computes the norm and the inverse norm
  469. var nx = dx / dist;
  470. var ny = dy / dist;
  471. var basex = length * nx;
  472. var basey = length * ny;
  473. var floorx = width * ny/3;
  474. var floory = -width * nx/3;
  475. // Computes points
  476. var p0x = p0.x - floorx / 2;
  477. var p0y = p0.y - floory / 2;
  478. var p1x = p0x + floorx;
  479. var p1y = p0y + floory;
  480. var p2x = p1x + basex;
  481. var p2y = p1y + basey;
  482. var p3x = p2x + floorx;
  483. var p3y = p2y + floory;
  484. // p4 not needed
  485. var p5x = p3x - 3 * floorx;
  486. var p5y = p3y - 3 * floory;
  487. // LATER: Add support for n points
  488. path.moveTo(p1x, p1y);
  489. path.lineTo(p2x, p2y);
  490. path.moveTo(p5x + floorx, p5y + floory);
  491. path.lineTo(p0x, p0y);
  492. path.end();
  493. };
  494. mxCellRenderer.prototype.defaultShapes['link'] = LinkShape;
  495. // Defines custom marker
  496. mxMarker.markers['dash'] = function(node, type, pe, nx, ny, strokewidth, size, scale, isVml)
  497. {
  498. nx = nx * (size + strokewidth);
  499. ny = ny * (size + strokewidth);
  500. if (isVml)
  501. {
  502. node.setAttribute('path', 'm' + Math.floor(pe.x - nx / 2- ny / 2) + ' ' + Math.floor(pe.y - ny / 2 + nx / 2) +
  503. ' l ' + Math.floor(pe.x + ny / 2 - 3 * nx / 2) + ' ' + Math.floor(pe.y - 3 * ny / 2 - nx / 2) +
  504. ' e');
  505. }
  506. else
  507. {
  508. node.setAttribute('d', 'M ' + (pe.x - nx / 2 - ny / 2) + ' ' + (pe.y - ny / 2 + nx / 2) +
  509. ' L ' + (pe.x + ny / 2 - 3 * nx / 2) + ' ' + (pe.y - 3 * ny / 2 - nx / 2) +
  510. ' z');
  511. }
  512. // Returns the offset for the edge
  513. return new mxPoint(0, 0);
  514. };
  515. // Registers the marker in mxImageExport
  516. var mxImageExportInitMarkers = mxImageExport.prototype.initMarkers;
  517. mxImageExport.prototype.initMarkers = function()
  518. {
  519. mxImageExportInitMarkers.apply(this, arguments);
  520. this.markers['dash'] = function(canvas, state, type, pe, unitX, unitY, size, source, sw)
  521. {
  522. nx = unitX * (size + sw);
  523. ny = unitY * (size + sw);
  524. canvas.begin();
  525. canvas.moveTo(pe.x - nx / 2 - ny / 2, pe.y - ny / 2 + nx / 2);
  526. canvas.lineTo(pe.x + ny / 2 - 3 * nx / 2, pe.y - 3 * ny / 2 - nx / 2);
  527. canvas.stroke();
  528. // Returns the offset for the edge
  529. return new mxPoint(0, 0);
  530. };
  531. };
  532. // Enables crisp rendering in SVG except for connectors, actors, cylinder,
  533. // ellipses must be enabled after rendering the sidebar items
  534. mxShape.prototype.crisp = true;
  535. mxShape.prototype.roundedCrispSvg = false;
  536. mxActor.prototype.crisp = false;
  537. mxCylinder.prototype.crisp = false;
  538. mxEllipse.prototype.crisp = false;
  539. mxDoubleEllipse.prototype.crisp = false;
  540. mxConnector.prototype.crisp = false;
  541. FolderShape.prototype.crisp = true;
  542. ComponentShape.prototype.crisp = true;
  543. // Implements custom handlers
  544. var SPECIAL_HANDLE_INDEX = -99;
  545. // Handlers are only added if mxVertexHandler is defined (ie. not in embedded graph)
  546. if (typeof(mxVertexHandler) != 'undefined')
  547. {
  548. // Swimlane handler
  549. function mxSwimlaneHandler(state)
  550. {
  551. mxVertexHandler.call(this, state);
  552. };
  553. mxUtils.extend(mxSwimlaneHandler, mxVertexHandler);
  554. mxSwimlaneHandler.prototype.useGridForSpecialHandle = false;
  555. mxSwimlaneHandler.prototype.init = function()
  556. {
  557. this.horizontal = mxUtils.getValue(this.state.style, mxConstants.STYLE_HORIZONTAL, true);
  558. var graph = this.state.view.graph;
  559. if (this.handleImage != null)
  560. {
  561. var bounds = new mxRectangle(0, 0, this.handleImage.width, this.handleImage.height);
  562. this.specialHandle = new mxImageShape(bounds, this.handleImage.src);
  563. }
  564. else
  565. {
  566. var size = 10;
  567. var bounds = new mxRectangle(0, 0, size, size);
  568. this.specialHandle = new mxRhombus(bounds, mxConstants.HANDLE_FILLCOLOR, mxConstants.HANDLE_STROKECOLOR);
  569. this.specialHandle.crisp = this.crisp;
  570. }
  571. this.specialHandle.dialect = (graph.dialect != mxConstants.DIALECT_SVG) ?
  572. mxConstants.DIALECT_VML : mxConstants.DIALECT_SVG;
  573. this.specialHandle.init(graph.getView().getOverlayPane());
  574. this.specialHandle.node.style.cursor = this.getSpecialHandleCursor();
  575. mxEvent.redirectMouseEvents(this.specialHandle.node, graph, this.state);
  576. mxVertexHandler.prototype.init.apply(this, arguments);
  577. };
  578. mxSwimlaneHandler.prototype.getSpecialHandleCursor = function()
  579. {
  580. return (this.horizontal) ? 'n-resize' : 'w-resize';
  581. };
  582. mxSwimlaneHandler.prototype.redraw = function()
  583. {
  584. mxVertexHandler.prototype.redraw.apply(this, arguments);
  585. var size = this.specialHandle.bounds.width;
  586. this.specialHandle.bounds = this.getSpecialHandleBounds(size);
  587. this.specialHandle.redraw();
  588. };
  589. mxSwimlaneHandler.prototype.getSpecialHandleBounds = function(size)
  590. {
  591. var scale = this.graph.getView().scale;
  592. var start = this.state.view.graph.getStartSize(this.state.cell);
  593. if (this.horizontal)
  594. {
  595. return new mxRectangle(this.state.x + (this.state.width - size) / 2,
  596. this.state.y + start.height * scale - size / 2, size, size);
  597. }
  598. else
  599. {
  600. return new mxRectangle(this.state.x + start.width * scale - size / 2,
  601. this.state.y + (this.state.height - size) / 2, size, size);
  602. }
  603. };
  604. mxSwimlaneHandler.prototype.destroy = function()
  605. {
  606. mxVertexHandler.prototype.destroy.apply(this, arguments);
  607. if (this.specialHandle != null)
  608. {
  609. this.specialHandle.destroy();
  610. this.specialHandle = null;
  611. }
  612. };
  613. mxSwimlaneHandler.prototype.getHandleForEvent = function(me)
  614. {
  615. if (me.isSource(this.specialHandle))
  616. {
  617. return SPECIAL_HANDLE_INDEX;
  618. }
  619. return mxVertexHandler.prototype.getHandleForEvent.apply(this, arguments);
  620. };
  621. mxSwimlaneHandler.prototype.constrainPoint = function(point)
  622. {
  623. point.x = Math.max(this.state.x, Math.min(this.state.x + this.state.width, point.x));
  624. point.y = Math.max(this.state.y, Math.min(this.state.y + this.state.height, point.y));
  625. };
  626. mxSwimlaneHandler.prototype.mouseMove = function(sender, me)
  627. {
  628. if (!me.isConsumed() && this.index == SPECIAL_HANDLE_INDEX)
  629. {
  630. var point = new mxPoint(me.getGraphX(), me.getGraphY());
  631. this.constrainPoint(point);
  632. var gridEnabled = this.graph.isGridEnabledEvent(me.getEvent());
  633. var scale = this.graph.getView().scale;
  634. if (gridEnabled && this.useGridForSpecialHandle)
  635. {
  636. point.x = this.graph.snap(point.x / scale) * scale;
  637. point.y = this.graph.snap(point.y / scale) * scale;
  638. }
  639. this.updateStyle(point);
  640. this.moveSizerTo(this.specialHandle, point.x, point.y);
  641. this.state.view.graph.cellRenderer.redraw(this.state, true);
  642. me.consume();
  643. }
  644. else
  645. {
  646. mxVertexHandler.prototype.mouseMove.apply(this, arguments);
  647. }
  648. };
  649. mxSwimlaneHandler.prototype.updateStyle = function(point)
  650. {
  651. var startSize = 0;
  652. if (this.horizontal)
  653. {
  654. point.x = this.state.x + this.state.width / 2;
  655. startSize = point.y - this.state.y;
  656. }
  657. else
  658. {
  659. point.y = this.state.y + this.state.height / 2;
  660. startSize = point.x - this.state.x;
  661. }
  662. var scale = this.graph.getView().scale;
  663. this.state.style['startSize'] = Math.round(Math.max(1, startSize) / scale);
  664. };
  665. mxSwimlaneHandler.prototype.mouseUp = function(sender, me)
  666. {
  667. if (!me.isConsumed() && this.index == SPECIAL_HANDLE_INDEX)
  668. {
  669. this.applyStyle();
  670. this.reset();
  671. me.consume();
  672. }
  673. else
  674. {
  675. mxVertexHandler.prototype.mouseUp.apply(this, arguments);
  676. }
  677. };
  678. mxSwimlaneHandler.prototype.applyStyle = function()
  679. {
  680. this.state.view.graph.setCellStyles('startSize', this.state.style['startSize'], [this.state.cell]);
  681. };
  682. // Folder Handler
  683. function mxFolderHandler(state)
  684. {
  685. mxSwimlaneHandler.call(this, state);
  686. };
  687. mxUtils.extend(mxFolderHandler, mxSwimlaneHandler);
  688. mxFolderHandler.prototype.getSpecialHandleCursor = function()
  689. {
  690. return 'default';
  691. };
  692. mxFolderHandler.prototype.getSpecialHandleBounds = function(size)
  693. {
  694. var rotation = Number(this.state.style[mxConstants.STYLE_ROTATION] || '0');
  695. var direction = mxUtils.getValue(this.state.style, 'direction', 'east');
  696. if (direction != null)
  697. {
  698. if (direction == 'north')
  699. {
  700. rotation += 270;
  701. }
  702. else if (direction == 'west')
  703. {
  704. rotation += 180;
  705. }
  706. else if (direction == 'south')
  707. {
  708. rotation += 90;
  709. }
  710. }
  711. var alpha = mxUtils.toRadians(rotation);
  712. var cos = Math.cos(alpha);
  713. var sin = Math.sin(alpha);
  714. var bounds = new mxRectangle(this.state.x, this.state.y, this.state.width, this.state.height);
  715. if (direction == 'south' || direction == 'north')
  716. {
  717. bounds.x += (bounds.width - bounds.height) / 2;
  718. bounds.y += (bounds.height - bounds.width) / 2;
  719. var tmp = bounds.width;
  720. bounds.width = bounds.height;
  721. bounds.height = tmp;
  722. }
  723. var pt = this.getSpecialHandlePoint(bounds);
  724. pt = mxUtils.getRotatedPoint(pt, cos, sin,
  725. new mxPoint(this.state.getCenterX(), this.state.getCenterY()));
  726. return new mxRectangle(pt.x - size / 2, pt.y - size / 2, size, size);
  727. };
  728. mxFolderHandler.prototype.getSpecialHandlePoint = function(bounds)
  729. {
  730. var scale = this.graph.getView().scale;
  731. var tw = Math.min(bounds.width, mxUtils.getValue(this.state.style, 'tabWidth', 60) * scale);
  732. var th = Math.min(bounds.height, mxUtils.getValue(this.state.style, 'tabHeight', 20) * scale);
  733. var tp = mxUtils.getValue(this.state.style, 'tabPosition', 'right');
  734. var x = (tp == 'left') ? bounds.x + tw : bounds.x + bounds.width - tw;
  735. return new mxPoint(x, bounds.y + th);
  736. };
  737. mxFolderHandler.prototype.updateStyle = function(point)
  738. {
  739. var direction = mxUtils.getValue(this.state.style, 'direction', 'east');
  740. var rotation = Number(this.state.style[mxConstants.STYLE_ROTATION] || '0');
  741. if (direction != null)
  742. {
  743. if (direction == 'north')
  744. {
  745. rotation += 270;
  746. }
  747. else if (direction == 'west')
  748. {
  749. rotation += 180;
  750. }
  751. else if (direction == 'south')
  752. {
  753. rotation += 90;
  754. }
  755. }
  756. var alpha = mxUtils.toRadians(rotation);
  757. var cos = Math.cos(-alpha);
  758. var sin = Math.sin(-alpha);
  759. var bounds = new mxRectangle(this.state.x, this.state.y, this.state.width, this.state.height);
  760. if (direction == 'south' || direction == 'north')
  761. {
  762. bounds.x += (bounds.width - bounds.height) / 2;
  763. bounds.y += (bounds.height - bounds.width) / 2;
  764. var tmp = bounds.width;
  765. bounds.width = bounds.height;
  766. bounds.height = tmp;
  767. }
  768. var pt = new mxPoint(point.x, point.y);
  769. pt = mxUtils.getRotatedPoint(pt, cos, sin,
  770. new mxPoint(this.state.getCenterX(), this.state.getCenterY()));
  771. var result = this.updateStyleUnrotated(pt, bounds);
  772. // Modifies point to use rotated coordinates of return value
  773. if (result != null)
  774. {
  775. cos = Math.cos(alpha);
  776. sin = Math.sin(alpha);
  777. result = mxUtils.getRotatedPoint(result, cos, sin,
  778. new mxPoint(this.state.getCenterX(), this.state.getCenterY()));
  779. point.x = result.x;
  780. point.y = result.y;
  781. }
  782. };
  783. mxFolderHandler.prototype.updateStyleUnrotated = function(pt, bounds)
  784. {
  785. var tp = mxUtils.getValue(this.state.style, 'tabPosition', 'right');
  786. var tw = (tp == 'left') ? pt.x - bounds.x : bounds.x + bounds.width - pt.x;
  787. var th = pt.y - bounds.y;
  788. var scale = this.graph.getView().scale;
  789. this.state.style['tabWidth'] = Math.round(Math.max(1, tw) / scale);
  790. this.state.style['tabHeight'] = Math.round(Math.max(1, th) / scale);
  791. };
  792. mxFolderHandler.prototype.applyStyle = function()
  793. {
  794. var model = this.graph.getModel();
  795. model.beginUpdate();
  796. try
  797. {
  798. this.state.view.graph.setCellStyles('tabWidth', this.state.style['tabWidth'], [this.state.cell]);
  799. this.state.view.graph.setCellStyles('tabHeight', this.state.style['tabHeight'], [this.state.cell]);
  800. }
  801. finally
  802. {
  803. model.endUpdate();
  804. }
  805. };
  806. // Cube Handler
  807. function mxCubeHandler(state)
  808. {
  809. mxFolderHandler.call(this, state);
  810. };
  811. mxUtils.extend(mxCubeHandler, mxFolderHandler);
  812. mxCubeHandler.prototype.defaultValue = 20;
  813. mxCubeHandler.prototype.scaleFactor = 1;
  814. mxCubeHandler.prototype.getSpecialHandlePoint = function(bounds)
  815. {
  816. var scale = this.graph.getView().scale;
  817. var sz = Math.min(bounds.width, Math.min(bounds.height,
  818. mxUtils.getValue(this.state.style, 'size', this.defaultValue) * scale / this.scaleFactor));
  819. return new mxPoint(bounds.x + sz, bounds.y + sz);
  820. };
  821. mxCubeHandler.prototype.updateStyleUnrotated = function(pt, bounds)
  822. {
  823. var size = Math.min(Math.min(bounds.width / this.scaleFactor, pt.x - bounds.x),
  824. Math.min(bounds.height / this.scaleFactor, pt.y - bounds.y));
  825. var scale = this.graph.getView().scale;
  826. this.state.style['size'] = Math.round(Math.max(1, size) / scale) * this.scaleFactor;
  827. // Stays on the diagonal
  828. return new mxPoint(bounds.x + size, bounds.y + size);
  829. };
  830. mxCubeHandler.prototype.applyStyle = function()
  831. {
  832. this.state.view.graph.setCellStyles('size', this.state.style['size'], [this.state.cell]);
  833. };
  834. // Card Handler
  835. function mxCardHandler(state)
  836. {
  837. mxCubeHandler.call(this, state);
  838. };
  839. mxUtils.extend(mxCardHandler, mxCubeHandler);
  840. mxCardHandler.prototype.defaultValue = 30;
  841. mxCardHandler.prototype.scaleFactor = 2;
  842. // Note Handler
  843. function mxNoteHandler(state)
  844. {
  845. mxCubeHandler.call(this, state);
  846. };
  847. mxUtils.extend(mxNoteHandler, mxCubeHandler);
  848. mxNoteHandler.prototype.defaultValue = 30;
  849. mxNoteHandler.prototype.scaleFactor = 1;
  850. mxNoteHandler.prototype.getSpecialHandlePoint = function(bounds)
  851. {
  852. var scale = this.graph.getView().scale;
  853. var sz = Math.min(bounds.width, Math.min(bounds.height,
  854. mxUtils.getValue(this.state.style, 'size', this.defaultValue) * scale / this.scaleFactor));
  855. return new mxPoint(bounds.x + bounds.width - sz, bounds.y + sz);
  856. };
  857. mxNoteHandler.prototype.updateStyleUnrotated = function(pt, bounds)
  858. {
  859. var size = Math.min(Math.min(bounds.width / this.scaleFactor, pt.x - bounds.x + bounds.width),
  860. Math.min(bounds.height / this.scaleFactor, pt.y - bounds.y));
  861. var scale = this.graph.getView().scale;
  862. this.state.style['size'] = Math.round(Math.max(1, size) / scale) * this.scaleFactor;
  863. // Stays on the diagonal
  864. return new mxPoint(bounds.x + bounds.width - size, bounds.y + size);
  865. };
  866. // Step Handler
  867. function mxStepHandler(state)
  868. {
  869. mxCubeHandler.call(this, state);
  870. };
  871. mxUtils.extend(mxStepHandler, mxCubeHandler);
  872. mxStepHandler.prototype.defaultValue = 0.2;
  873. mxStepHandler.prototype.scaleFactor = 1;
  874. mxStepHandler.prototype.getSpecialHandlePoint = function(bounds)
  875. {
  876. var sz = mxUtils.getValue(this.state.style, 'size', this.defaultValue);
  877. return new mxPoint(bounds.x + bounds.width * sz, bounds.y + bounds.height / 2);
  878. };
  879. mxStepHandler.prototype.updateStyleUnrotated = function(pt, bounds)
  880. {
  881. var size = Math.min(1, (pt.x - bounds.x) / bounds.width);
  882. this.state.style['size'] = size;
  883. return new mxPoint(bounds.x + size * bounds.width, bounds.y + bounds.height / 2);
  884. };
  885. // Tape Handler
  886. function mxTapeHandler(state)
  887. {
  888. mxCubeHandler.call(this, state);
  889. };
  890. mxUtils.extend(mxTapeHandler, mxCubeHandler);
  891. mxTapeHandler.prototype.defaultValue = 0.4;
  892. mxTapeHandler.prototype.scaleFactor = 1;
  893. mxTapeHandler.prototype.getSpecialHandlePoint = function(bounds)
  894. {
  895. var sz = mxUtils.getValue(this.state.style, 'size', this.defaultValue);
  896. return new mxPoint(bounds.x + bounds.width / 2, bounds.y + sz * bounds.height / 2);
  897. };
  898. mxTapeHandler.prototype.updateStyleUnrotated = function(pt, bounds)
  899. {
  900. var size = Math.min(1, ((pt.y - bounds.y) / bounds.height) * 2);
  901. this.state.style['size'] = size;
  902. return new mxPoint(bounds.x + bounds.width / 2, bounds.y + size * bounds.height / 2);
  903. };
  904. var handlers = {'swimlane': mxSwimlaneHandler, 'folder': mxFolderHandler, 'cube': mxCubeHandler,
  905. 'card': mxCardHandler, 'note': mxNoteHandler, 'step': mxStepHandler, 'tape': mxTapeHandler};
  906. var mxGraphCreateHandler = mxGraph.prototype.createHandler;
  907. mxGraph.prototype.createHandler = function(state)
  908. {
  909. if (state != null)
  910. {
  911. var ctor = handlers[state.style['shape']];
  912. if (ctor != null)
  913. {
  914. return new ctor(state);
  915. }
  916. }
  917. return mxGraphCreateHandler.apply(this, arguments);
  918. };
  919. }
  920. // Constraints
  921. mxGraph.prototype.getAllConnectionConstraints = function(terminal, source)
  922. {
  923. if (terminal != null && terminal.shape != null)
  924. {
  925. if (terminal.shape instanceof mxStencilShape)
  926. {
  927. if (terminal.shape.stencil != null)
  928. {
  929. return terminal.shape.stencil.constraints;
  930. }
  931. }
  932. else if (terminal.shape.constraints != null)
  933. {
  934. return terminal.shape.constraints;
  935. }
  936. }
  937. return null;
  938. };
  939. mxRectangleShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0), true),
  940. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  941. new mxConnectionConstraint(new mxPoint(0.75, 0), true),
  942. new mxConnectionConstraint(new mxPoint(0, 0.25), true),
  943. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  944. new mxConnectionConstraint(new mxPoint(0, 0.75), true),
  945. new mxConnectionConstraint(new mxPoint(1, 0.25), true),
  946. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  947. new mxConnectionConstraint(new mxPoint(1, 0.75), true),
  948. new mxConnectionConstraint(new mxPoint(0.25, 1), true),
  949. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  950. new mxConnectionConstraint(new mxPoint(0.75, 1), true)];
  951. mxLabel.prototype.constraints = mxRectangleShape.prototype.constraints;
  952. mxImageShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  953. mxSwimlane.prototype.constraints = mxRectangleShape.prototype.constraints;
  954. PlusShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  955. NoteShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  956. CardShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  957. CubeShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  958. FolderShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  959. mxCylinder.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.15, 0.05), false),
  960. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  961. new mxConnectionConstraint(new mxPoint(0.85, 0.05), false),
  962. new mxConnectionConstraint(new mxPoint(0, 0.3), true),
  963. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  964. new mxConnectionConstraint(new mxPoint(0, 0.7), true),
  965. new mxConnectionConstraint(new mxPoint(1, 0.3), true),
  966. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  967. new mxConnectionConstraint(new mxPoint(1, 0.7), true),
  968. new mxConnectionConstraint(new mxPoint(0.15, 0.95), false),
  969. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  970. new mxConnectionConstraint(new mxPoint(0.85, 0.95), false)];
  971. UmlActorShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0), true),
  972. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  973. new mxConnectionConstraint(new mxPoint(0.75, 0), true),
  974. new mxConnectionConstraint(new mxPoint(0, 0.25), true),
  975. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  976. new mxConnectionConstraint(new mxPoint(0, 0.75), true),
  977. new mxConnectionConstraint(new mxPoint(1, 0.25), true),
  978. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  979. new mxConnectionConstraint(new mxPoint(1, 0.75), true),
  980. new mxConnectionConstraint(new mxPoint(0.25, 1), true),
  981. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  982. new mxConnectionConstraint(new mxPoint(0.75, 1), true)];
  983. ComponentShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0), true),
  984. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  985. new mxConnectionConstraint(new mxPoint(0.75, 0), true),
  986. new mxConnectionConstraint(new mxPoint(0, 0.3), true),
  987. new mxConnectionConstraint(new mxPoint(0, 0.7), true),
  988. new mxConnectionConstraint(new mxPoint(1, 0.25), true),
  989. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  990. new mxConnectionConstraint(new mxPoint(1, 0.75), true),
  991. new mxConnectionConstraint(new mxPoint(0.25, 1), true),
  992. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  993. new mxConnectionConstraint(new mxPoint(0.75, 1), true)];
  994. mxActor.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  995. new mxConnectionConstraint(new mxPoint(0.25, 0.2), false),
  996. new mxConnectionConstraint(new mxPoint(0.1, 0.5), false),
  997. new mxConnectionConstraint(new mxPoint(0, 0.75), true),
  998. new mxConnectionConstraint(new mxPoint(0.75, 0.25), false),
  999. new mxConnectionConstraint(new mxPoint(0.9, 0.5), false),
  1000. new mxConnectionConstraint(new mxPoint(1, 0.75), true),
  1001. new mxConnectionConstraint(new mxPoint(0.25, 1), true),
  1002. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  1003. new mxConnectionConstraint(new mxPoint(0.75, 1), true)];
  1004. TapeShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0.35), false),
  1005. new mxConnectionConstraint(new mxPoint(0, 0.5), false),
  1006. new mxConnectionConstraint(new mxPoint(0, 0.65), false),
  1007. new mxConnectionConstraint(new mxPoint(1, 0.35), false),
  1008. new mxConnectionConstraint(new mxPoint(1, 0.5), false),
  1009. new mxConnectionConstraint(new mxPoint(1, 0.65), false),
  1010. new mxConnectionConstraint(new mxPoint(0.25, 1), false),
  1011. new mxConnectionConstraint(new mxPoint(0.75, 0), false)];
  1012. // TODO: Relative ports
  1013. StepShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0), true),
  1014. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  1015. new mxConnectionConstraint(new mxPoint(0.75, 0), true),
  1016. new mxConnectionConstraint(new mxPoint(0.25, 1), true),
  1017. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  1018. new mxConnectionConstraint(new mxPoint(0.75, 1), true),
  1019. new mxConnectionConstraint(new mxPoint(0.1, 0.25), false),
  1020. new mxConnectionConstraint(new mxPoint(0.2, 0.5), false),
  1021. new mxConnectionConstraint(new mxPoint(0.1, 0.75), false),
  1022. new mxConnectionConstraint(new mxPoint(0.9, 0.25), false),
  1023. new mxConnectionConstraint(new mxPoint(1, 0.5), false),
  1024. new mxConnectionConstraint(new mxPoint(0.9, 0.75), false)];
  1025. mxLine.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0.5), false),
  1026. new mxConnectionConstraint(new mxPoint(0.25, 0.5), false),
  1027. new mxConnectionConstraint(new mxPoint(0.75, 0.5), false),
  1028. new mxConnectionConstraint(new mxPoint(1, 0.5), false)];
  1029. LollipopShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.5, 0), false),
  1030. new mxConnectionConstraint(new mxPoint(0.5, 1), false)];
  1031. mxEllipse.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0), true), new mxConnectionConstraint(new mxPoint(1, 0), true),
  1032. new mxConnectionConstraint(new mxPoint(0, 1), true), new mxConnectionConstraint(new mxPoint(1, 1), true),
  1033. new mxConnectionConstraint(new mxPoint(0.5, 0), true), new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  1034. new mxConnectionConstraint(new mxPoint(0, 0.5), true), new mxConnectionConstraint(new mxPoint(1, 0.5))];
  1035. mxDoubleEllipse.prototype.constraints = mxEllipse.prototype.constraints;
  1036. mxRhombus.prototype.constraints = mxEllipse.prototype.constraints;
  1037. mxTriangle.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0.25), true),
  1038. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  1039. new mxConnectionConstraint(new mxPoint(0, 0.75), true),
  1040. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  1041. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  1042. new mxConnectionConstraint(new mxPoint(1, 0.5), true)];
  1043. mxHexagon.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.375, 0), true),
  1044. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  1045. new mxConnectionConstraint(new mxPoint(0.625, 0), true),
  1046. new mxConnectionConstraint(new mxPoint(0.125, 0.25), false),
  1047. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  1048. new mxConnectionConstraint(new mxPoint(0.125, 0.75), false),
  1049. new mxConnectionConstraint(new mxPoint(0.875, 0.25), false),
  1050. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  1051. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  1052. new mxConnectionConstraint(new mxPoint(0.875, 0.75), false),
  1053. new mxConnectionConstraint(new mxPoint(0.375, 1), true),
  1054. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  1055. new mxConnectionConstraint(new mxPoint(0.625, 1), true)];
  1056. mxCloud.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0.25), false),
  1057. new mxConnectionConstraint(new mxPoint(0.4, 0.1), false),
  1058. new mxConnectionConstraint(new mxPoint(0.16, 0.55), false),
  1059. new mxConnectionConstraint(new mxPoint(0.07, 0.4), false),
  1060. new mxConnectionConstraint(new mxPoint(0.31, 0.8), false),
  1061. new mxConnectionConstraint(new mxPoint(0.13, 0.77), false),
  1062. new mxConnectionConstraint(new mxPoint(0.8, 0.8), false),
  1063. new mxConnectionConstraint(new mxPoint(0.55, 0.95), false),
  1064. new mxConnectionConstraint(new mxPoint(0.875, 0.5), false),
  1065. new mxConnectionConstraint(new mxPoint(0.96, 0.7), false),
  1066. new mxConnectionConstraint(new mxPoint(0.625, 0.2), false),
  1067. new mxConnectionConstraint(new mxPoint(0.88, 0.25), false)];
  1068. mxArrow.prototype.constraints = null;
  1069. })();