Sidebar-Advanced.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. (function()
  2. {
  3. // Adds containers
  4. var sidebarCreateAdvancedShapes = Sidebar.prototype.createAdvancedShapes;
  5. Sidebar.prototype.createAdvancedShapes = function()
  6. {
  7. var fns = sidebarCreateAdvancedShapes.apply(this, arguments);
  8. // Avoids having to bind all functions to "this"
  9. var sb = this;
  10. // Reusable cells
  11. var flow = new mxCell('Vertical Flow Layout', new mxGeometry(0, 0, 270, 280),
  12. 'swimlane;html=1;startSize=20;horizontal=1;childLayout=flowLayout;flowOrientation=north;resizable=0;interRankCellSpacing=50;');
  13. flow.vertex = true;
  14. var flow1 = new mxCell('Start', new mxGeometry(20, 20, 100, 40), 'whiteSpace=wrap;html=1;');
  15. flow1.vertex = true;
  16. flow.insert(flow1);
  17. var flow2 = new mxCell('Task', new mxGeometry(20, 20, 100, 40), 'whiteSpace=wrap;html=1;');
  18. flow2.vertex = true;
  19. flow.insert(flow2);
  20. var edge = new mxCell('', new mxGeometry(0, 0, 0, 0), 'html=1;curved=1;');
  21. edge.geometry.relative = true;
  22. edge.edge = true;
  23. flow1.insertEdge(edge, true);
  24. flow2.insertEdge(edge, false);
  25. flow.insert(edge);
  26. var flow3 = new mxCell('Task', new mxGeometry(20, 20, 100, 40), 'whiteSpace=wrap;html=1;');
  27. flow3.vertex = true;
  28. flow.insert(flow3);
  29. edge = edge.clone();
  30. flow1.insertEdge(edge, true);
  31. flow3.insertEdge(edge, false);
  32. flow.insert(edge);
  33. var flow4 = new mxCell('End', new mxGeometry(20, 20, 100, 40), 'whiteSpace=wrap;html=1;');
  34. flow4.vertex = true;
  35. flow.insert(flow4);
  36. edge = edge.clone();
  37. flow2.insertEdge(edge, true);
  38. flow4.insertEdge(edge, false);
  39. flow.insert(edge);
  40. edge = edge.clone();
  41. flow3.insertEdge(edge, true);
  42. flow4.insertEdge(edge, false);
  43. flow.insert(edge);
  44. return fns.concat(
  45. [
  46. this.addEntry('container swimlane pool horizontal', function()
  47. {
  48. var cell = new mxCell('Pool', new mxGeometry(0, 0, 480, 380),
  49. 'swimlane;html=1;childLayout=stackLayout;horizontal=1;startSize=20;horizontalStack=0;');
  50. cell.vertex = true;
  51. var cell1 = new mxCell('Lane 1', new mxGeometry(0, 20, 480, 120), 'swimlane;html=1;startSize=20;horizontal=0;');
  52. cell1.vertex = true;
  53. cell.insert(cell1);
  54. var cell2 = new mxCell('Lane 2', new mxGeometry(0, 140, 480, 120), 'swimlane;html=1;startSize=20;horizontal=0;');
  55. cell2.vertex = true;
  56. cell.insert(cell2);
  57. var cell3 = new mxCell('Lane 3', new mxGeometry(0, 260, 480, 120), 'swimlane;html=1;startSize=20;horizontal=0;');
  58. cell3.vertex = true;
  59. cell.insert(cell3);
  60. return sb.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'Horizontal Pool 1', true);
  61. }),
  62. this.addEntry('container swimlane pool horizontal', function()
  63. {
  64. var cell = new mxCell('Pool', new mxGeometry(0, 0, 480, 360),
  65. 'swimlane;html=1;childLayout=stackLayout;horizontal=0;startSize=20;horizontalStack=0;');
  66. cell.vertex = true;
  67. var cell1 = new mxCell('Lane 1', new mxGeometry(20, 0, 460, 120), 'swimlane;html=1;startSize=20;horizontal=0;');
  68. cell1.vertex = true;
  69. cell.insert(cell1);
  70. var cell2 = new mxCell('Lane 2', new mxGeometry(20, 120, 460, 120), 'swimlane;html=1;startSize=20;horizontal=0;');
  71. cell2.vertex = true;
  72. cell.insert(cell2);
  73. var cell3 = new mxCell('Lane 3', new mxGeometry(20, 240, 460, 120), 'swimlane;html=1;startSize=20;horizontal=0;');
  74. cell3.vertex = true;
  75. cell.insert(cell3);
  76. return sb.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'Horizontal Pool 2', true);
  77. }),
  78. this.addEntry('container swimlane pool vertical', function()
  79. {
  80. var cell = new mxCell('Pool', new mxGeometry(0, 0, 360, 480),
  81. 'swimlane;html=1;childLayout=stackLayout;startSize=20;');
  82. cell.vertex = true;
  83. var cell1 = new mxCell('Lane 1', new mxGeometry(0, 20, 120, 460), 'swimlane;html=1;startSize=20;');
  84. cell1.vertex = true;
  85. cell.insert(cell1);
  86. var cell2 = new mxCell('Lane 2', new mxGeometry(120, 20, 120, 460), 'swimlane;html=1;startSize=20;');
  87. cell2.vertex = true;
  88. cell.insert(cell2);
  89. var cell3 = new mxCell('Lane 3', new mxGeometry(240, 20, 120, 460), 'swimlane;html=1;startSize=20;');
  90. cell3.vertex = true;
  91. cell.insert(cell3);
  92. return sb.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'Vertical Pool 1', true);
  93. }),
  94. this.addEntry('container swimlane pool vertical', function()
  95. {
  96. var cell = new mxCell('Pool', new mxGeometry(0, 0, 380, 480),
  97. 'swimlane;html=1;childLayout=stackLayout;startSize=20;horizontal=0;horizontalStack=1;');
  98. cell.vertex = true;
  99. var cell1 = new mxCell('Lane 1', new mxGeometry(20, 0, 120, 480), 'swimlane;html=1;startSize=20;');
  100. cell1.vertex = true;
  101. cell.insert(cell1);
  102. var cell2 = new mxCell('Lane 2', new mxGeometry(140, 0, 120, 480), 'swimlane;html=1;startSize=20;');
  103. cell2.vertex = true;
  104. cell.insert(cell2);
  105. var cell3 = new mxCell('Lane 3', new mxGeometry(260, 0, 120, 480), 'swimlane;html=1;startSize=20;');
  106. cell3.vertex = true;
  107. cell.insert(cell3);
  108. return sb.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'Vertical Pool 2', true);
  109. }),
  110. this.addEntry('vertical tree layout', function()
  111. {
  112. var cell = new mxCell('Vertical Tree Layout', new mxGeometry(0, 0, 280, 190),
  113. 'swimlane;html=1;startSize=20;horizontal=1;childLayout=treeLayout;horizontalTree=0;resizable=0;');
  114. cell.vertex = true;
  115. var cell1 = new mxCell('Root', new mxGeometry(20, 20, 100, 40), 'whiteSpace=wrap;html=1;');
  116. cell1.vertex = true;
  117. cell.insert(cell1);
  118. var cell2 = new mxCell('Child 1', new mxGeometry(20, 20, 100, 40), 'whiteSpace=wrap;html=1;');
  119. cell2.vertex = true;
  120. cell.insert(cell2);
  121. var edge1 = new mxCell('', new mxGeometry(0, 0, 0, 0), 'edgeStyle=elbowEdgeStyle;elbow=vertical;html=1;rounded=0;');
  122. edge1.geometry.relative = true;
  123. edge1.edge = true;
  124. cell1.insertEdge(edge1, true);
  125. cell2.insertEdge(edge1, false);
  126. cell.insert(edge1);
  127. var cell3 = new mxCell('Child 2', new mxGeometry(20, 20, 100, 40), 'whiteSpace=wrap;html=1;');
  128. cell3.vertex = true;
  129. cell.insert(cell3);
  130. var edge2 = new mxCell('', new mxGeometry(0, 0, 0, 0), 'edgeStyle=elbowEdgeStyle;elbow=vertical;html=1;rounded=0;');
  131. edge2.geometry.relative = true;
  132. edge2.edge = true;
  133. cell1.insertEdge(edge2, true);
  134. cell3.insertEdge(edge2, false);
  135. cell.insert(edge2);
  136. return sb.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'Vertical Tree Layout', true);
  137. }),
  138. this.addEntry('horizontal tree layout', function()
  139. {
  140. var cell = new mxCell('Horizontal Tree Layout', new mxGeometry(0, 0, 310, 160),
  141. 'swimlane;html=1;startSize=20;horizontal=0;childLayout=treeLayout;horizontalTree=1;resizable=0;');
  142. cell.vertex = true;
  143. var cell1 = new mxCell('Root', new mxGeometry(20, 20, 100, 40), 'whiteSpace=wrap;html=1;');
  144. cell1.vertex = true;
  145. cell.insert(cell1);
  146. var cell2 = new mxCell('Child 1', new mxGeometry(20, 20, 100, 40), 'whiteSpace=wrap;html=1;');
  147. cell2.vertex = true;
  148. cell.insert(cell2);
  149. var edge1 = new mxCell('', new mxGeometry(0, 0, 0, 0), 'edgeStyle=elbowEdgeStyle;elbow=horizontal;html=1;rounded=0;');
  150. edge1.geometry.relative = true;
  151. edge1.edge = true;
  152. cell1.insertEdge(edge1, true);
  153. cell2.insertEdge(edge1, false);
  154. cell.insert(edge1);
  155. var cell3 = new mxCell('Child 2', new mxGeometry(20, 20, 100, 40), 'whiteSpace=wrap;html=1;');
  156. cell3.vertex = true;
  157. cell.insert(cell3);
  158. var edge2 = new mxCell('', new mxGeometry(0, 0, 0, 0), 'edgeStyle=elbowEdgeStyle;elbow=horizontal;html=1;rounded=0;');
  159. edge2.geometry.relative = true;
  160. edge2.edge = true;
  161. cell1.insertEdge(edge2, true);
  162. cell3.insertEdge(edge2, false);
  163. cell.insert(edge2);
  164. return sb.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'Horizontal Tree Layout', true);
  165. }),
  166. this.addEntry('vertical flow layout', function()
  167. {
  168. return sb.createVertexTemplateFromCells([flow], flow.geometry.width, flow.geometry.height, 'Vertical Flow Layout', true);
  169. }),
  170. this.addEntry('horizontal flow layout', function()
  171. {
  172. var cell = sb.graph.cloneCells([flow])[0];
  173. cell.geometry = new mxGeometry(0, 0, 460, 150);
  174. cell.style = 'swimlane;html=1;startSize=20;horizontal=0;childLayout=flowLayout;flowOrientation=west;resizable=0;interRankCellSpacing=50;';
  175. cell.value = 'Horizontal Flow Layout';
  176. return sb.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'Horizontal Flow Layout', true);
  177. })
  178. ]);
  179. };
  180. })();