mxMockupMarkup.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. /**
  2. * Copyright (c) 2006-2010, JGraph Holdings Ltd
  3. */
  4. //**********************************************************************************************************************************************************
  5. //Horizontal Curly Brace
  6. //**********************************************************************************************************************************************************
  7. /**
  8. * Extends mxShape.
  9. */
  10. function mxShapeMockupCurlyBrace(bounds, fill, stroke, strokewidth)
  11. {
  12. mxShape.call(this);
  13. this.bounds = bounds;
  14. this.fill = fill;
  15. this.stroke = stroke;
  16. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  17. };
  18. /**
  19. * Extends mxShape.
  20. */
  21. mxUtils.extend(mxShapeMockupCurlyBrace, mxShape);
  22. mxShapeMockupCurlyBrace.prototype.cst = {
  23. SHAPE_CURLY_BRACE : 'mxgraph.mockup.markup.curlyBrace'
  24. };
  25. /**
  26. * Function: paintVertexShape
  27. *
  28. * Paints the vertex shape.
  29. */
  30. mxShapeMockupCurlyBrace.prototype.paintVertexShape = function(c, x, y, w, h)
  31. {
  32. c.translate(x, y);
  33. this.background(c, x, y, w, h);
  34. };
  35. mxShapeMockupCurlyBrace.prototype.background = function(c, x, y, w, h)
  36. {
  37. var midY = h * 0.5;
  38. var rSize = Math.min(w * 0.125, midY);
  39. c.begin();
  40. c.moveTo(0, midY + rSize);
  41. c.arcTo(rSize, rSize, 0, 0, 1, rSize, midY);
  42. c.lineTo(w * 0.5 - rSize, midY);
  43. c.arcTo(rSize, rSize, 0, 0, 0, w * 0.5, midY - rSize);
  44. c.arcTo(rSize, rSize, 0, 0, 0, w * 0.5 + rSize, midY);
  45. c.lineTo(w - rSize, midY);
  46. c.arcTo(rSize, rSize, 0, 0, 1, w, midY + rSize);
  47. c.stroke();
  48. };
  49. mxCellRenderer.registerShape(mxShapeMockupCurlyBrace.prototype.cst.SHAPE_CURLY_BRACE, mxShapeMockupCurlyBrace);
  50. //**********************************************************************************************************************************************************
  51. //Line
  52. //**********************************************************************************************************************************************************
  53. /**
  54. * Extends mxShape.
  55. */
  56. function mxShapeMockupLine(bounds, fill, stroke, strokewidth)
  57. {
  58. mxShape.call(this);
  59. this.bounds = bounds;
  60. this.fill = fill;
  61. this.stroke = stroke;
  62. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  63. };
  64. /**
  65. * Extends mxShape.
  66. */
  67. mxUtils.extend(mxShapeMockupLine, mxShape);
  68. mxShapeMockupLine.prototype.cst = {
  69. SHAPE_LINE : 'mxgraph.mockup.markup.line'
  70. };
  71. /**
  72. * Function: paintVertexShape
  73. *
  74. * Paints the vertex shape.
  75. */
  76. mxShapeMockupLine.prototype.paintVertexShape = function(c, x, y, w, h)
  77. {
  78. c.translate(x, y);
  79. c.begin();
  80. c.moveTo(0, h * 0.5);
  81. c.lineTo(w, h * 0.5);
  82. c.stroke();
  83. };
  84. mxCellRenderer.registerShape(mxShapeMockupLine.prototype.cst.SHAPE_LINE, mxShapeMockupLine);
  85. //**********************************************************************************************************************************************************
  86. //Scratch Out
  87. //**********************************************************************************************************************************************************
  88. /**
  89. * Extends mxShape.
  90. */
  91. function mxShapeMockupScratchOut(bounds, fill, stroke, strokewidth)
  92. {
  93. mxShape.call(this);
  94. this.bounds = bounds;
  95. this.fill = fill;
  96. this.stroke = stroke;
  97. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  98. };
  99. /**
  100. * Extends mxShape.
  101. */
  102. mxUtils.extend(mxShapeMockupScratchOut, mxShape);
  103. mxShapeMockupScratchOut.prototype.cst = {
  104. SHAPE_SCRATCH_OUT : 'mxgraph.mockup.markup.scratchOut'
  105. };
  106. /**
  107. * Function: paintVertexShape
  108. *
  109. * Paints the vertex shape.
  110. */
  111. mxShapeMockupScratchOut.prototype.paintVertexShape = function(c, x, y, w, h)
  112. {
  113. c.translate(x, y);
  114. c.begin();
  115. c.moveTo(w * 0.038, h * 0.095);
  116. c.curveTo(w * 0.038, h * 0.095, w * 0.289, h * -0.045, w * 0.186, h * 0.05);
  117. c.curveTo(w * 0.084, h * 0.145, w * -0.046, h * 0.251, w * 0.072, h * 0.208);
  118. c.curveTo(w * 0.191, h * 0.164, w * 0.522, h * -0.09, w * 0.366, h * 0.062);
  119. c.curveTo(w * 0.21, h * 0.215, w * -0.094, h * 0.38, w * 0.108, h * 0.304);
  120. c.curveTo(w * 0.309, h * 0.228, w * 0.73, h * -0.126, w * 0.544, h * 0.096);
  121. c.curveTo(w * 0.358, h * 0.319, w * -0.168, h * 0.592, w * 0.108, h * 0.476);
  122. c.curveTo(w * 0.382, h * 0.36, w * 0.972, h * -0.138, w * 0.779, h * 0.114);
  123. c.curveTo(w * 0.585, h * 0.365, w * -0.12, h * 0.688, w * 0.071, h * 0.639);
  124. c.curveTo(w * 0.262, h * 0.59, w * 1.174, h * 0.012, w * 0.936, h * 0.238);
  125. c.curveTo(w * 0.699, h * 0.462, w * -0.216, h * 0.855, w * 0.085, h * 0.806);
  126. c.curveTo(w * 0.386, h * 0.758, w * 1.185, h * 0.26, w * 0.935, h * 0.534);
  127. c.curveTo(w * 0.685, h * 0.808, w * -0.186, h * 0.94, w * 0.236, h * 0.895);
  128. c.curveTo(w * 0.659, h * 0.85, w * 1.095, h * 0.608, w * 0.905, h * 0.769);
  129. c.curveTo(w * 0.715, h * 0.93, w * 0.286, h * 0.962, w * 0.661, h * 0.931);
  130. c.stroke();
  131. };
  132. mxCellRenderer.registerShape(mxShapeMockupScratchOut.prototype.cst.SHAPE_SCRATCH_OUT, mxShapeMockupScratchOut);
  133. //**********************************************************************************************************************************************************
  134. //Red X
  135. //**********************************************************************************************************************************************************
  136. /**
  137. * Extends mxShape.
  138. */
  139. function mxShapeMockupRedX(bounds, fill, stroke, strokewidth)
  140. {
  141. mxShape.call(this);
  142. this.bounds = bounds;
  143. this.fill = fill;
  144. this.stroke = stroke;
  145. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  146. };
  147. /**
  148. * Extends mxShape.
  149. */
  150. mxUtils.extend(mxShapeMockupRedX, mxShape);
  151. mxShapeMockupRedX.prototype.cst = {
  152. SHAPE_RED_X : 'mxgraph.mockup.markup.redX'
  153. };
  154. /**
  155. * Function: paintVertexShape
  156. *
  157. * Paints the vertex shape.
  158. */
  159. mxShapeMockupRedX.prototype.paintVertexShape = function(c, x, y, w, h)
  160. {
  161. c.translate(x, y);
  162. c.begin();
  163. c.moveTo(w * 0.1, 0);
  164. c.lineTo(w * 0.5, h * 0.4);
  165. c.lineTo(w * 0.9, 0);
  166. c.lineTo(w, h * 0.1);
  167. c.lineTo(w * 0.6, h * 0.5);
  168. c.lineTo(w, h * 0.9);
  169. c.lineTo(w * 0.9, h);
  170. c.lineTo(w * 0.5, h * 0.6);
  171. c.lineTo(w * 0.1, h);
  172. c.lineTo(0, h * 0.9);
  173. c.lineTo(w * 0.4, h * 0.5);
  174. c.lineTo(0, h * 0.1);
  175. c.close();
  176. c.fillAndStroke();
  177. };
  178. mxCellRenderer.registerShape(mxShapeMockupRedX.prototype.cst.SHAPE_RED_X, mxShapeMockupRedX);