mxMockupMarkup.js 6.1 KB

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