mxCabinets.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. /**
  2. * Copyright (c) 2006-2014, JGraph Holdings Ltd
  3. */
  4. //**********************************************************************************************************************************************************
  5. //Cabinet
  6. //**********************************************************************************************************************************************************
  7. /**
  8. * Extends mxShape.
  9. */
  10. function mxCabinetsCabinet(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(mxCabinetsCabinet, mxShape);
  22. mxCabinetsCabinet.prototype.cst = {
  23. HAS_STAND : 'hasStand',
  24. CABINET : 'mxgraph.cabinets.cabinet'
  25. };
  26. mxCabinetsCabinet.prototype.customProperties = [
  27. {name: 'hasStand', dispName:'Has Stand', type:'bool', defVal:true}
  28. ];
  29. /**
  30. * Function: paintVertexShape
  31. *
  32. * Paints the vertex shape.
  33. */
  34. mxCabinetsCabinet.prototype.paintVertexShape = function(c, x, y, w, h)
  35. {
  36. c.translate(x, y);
  37. this.background(c, 0, 0, w, h);
  38. c.setShadow(false);
  39. this.foreground(c, 0, 0, w, h);
  40. };
  41. mxCabinetsCabinet.prototype.background = function(c, x, y, w, h)
  42. {
  43. c.rect(0, 0, w, h);
  44. c.fillAndStroke();
  45. };
  46. mxCabinetsCabinet.prototype.foreground = function(c, x, y, w, h)
  47. {
  48. var wallTh = 15;
  49. c.rect(0, 0, w, wallTh);
  50. c.stroke();
  51. c.begin();
  52. c.moveTo(wallTh, wallTh);
  53. c.lineTo(wallTh, h);
  54. c.moveTo(w - wallTh, wallTh);
  55. c.lineTo(w - wallTh, h);
  56. c.stroke();
  57. var hasStand = mxUtils.getValue(this.style, mxCabinetsCabinet.prototype.cst.HAS_STAND, '1');
  58. if (hasStand === 1)
  59. {
  60. c.rect(0, h - 40, w, 40);
  61. c.fillAndStroke();
  62. }
  63. else
  64. {
  65. c.rect(0, h - wallTh, w, wallTh);
  66. c.fillAndStroke();
  67. };
  68. };
  69. mxCellRenderer.registerShape(mxCabinetsCabinet.prototype.cst.CABINET, mxCabinetsCabinet);
  70. //**********************************************************************************************************************************************************
  71. //Cover Plate
  72. //**********************************************************************************************************************************************************
  73. /**
  74. * Extends mxShape.
  75. */
  76. function mxCabinetsCoverPlate(bounds, fill, stroke, strokewidth)
  77. {
  78. mxShape.call(this);
  79. this.bounds = bounds;
  80. this.fill = fill;
  81. this.stroke = stroke;
  82. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  83. };
  84. /**
  85. * Extends mxShape.
  86. */
  87. mxUtils.extend(mxCabinetsCoverPlate, mxShape);
  88. mxCabinetsCoverPlate.prototype.cst = {
  89. COVER_PLATE : 'mxgraph.cabinets.coverPlate'
  90. };
  91. /**
  92. * Function: paintVertexShape
  93. *
  94. * Paints the vertex shape.
  95. */
  96. mxCabinetsCoverPlate.prototype.paintVertexShape = function(c, x, y, w, h)
  97. {
  98. c.translate(x, y);
  99. this.background(c, 0, 0, w, h);
  100. c.setShadow(false);
  101. this.foreground(c, 0, 0, w, h);
  102. };
  103. mxCabinetsCoverPlate.prototype.background = function(c, x, y, w, h)
  104. {
  105. c.begin();
  106. c.moveTo(0, 0);
  107. c.lineTo(w, 0);
  108. c.lineTo(w, h);
  109. c.lineTo(0, h);
  110. c.close();
  111. c.moveTo(10, h * 0.5 - 12.5);
  112. c.lineTo(10, h * 0.5 + 12.5);
  113. c.lineTo(w - 10, h * 0.5 + 12.5);
  114. c.lineTo(w - 10, h * 0.5 - 12.5);
  115. c.close();
  116. c.fillAndStroke();
  117. };
  118. mxCabinetsCoverPlate.prototype.foreground = function(c, x, y, w, h)
  119. {
  120. };
  121. mxCellRenderer.registerShape(mxCabinetsCoverPlate.prototype.cst.COVER_PLATE, mxCabinetsCoverPlate);
  122. //**********************************************************************************************************************************************************
  123. //Dimension
  124. //**********************************************************************************************************************************************************
  125. /**
  126. * Extends mxShape.
  127. */
  128. function mxCabinetsDimension(bounds, fill, stroke, strokewidth)
  129. {
  130. mxShape.call(this);
  131. this.bounds = bounds;
  132. this.fill = fill;
  133. this.stroke = stroke;
  134. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  135. };
  136. /**
  137. * Extends mxShape.
  138. */
  139. mxUtils.extend(mxCabinetsDimension, mxShape);
  140. mxCabinetsDimension.prototype.cst = {
  141. DIMENSION : 'mxgraph.cabinets.dimension'
  142. };
  143. /**
  144. * Function: paintVertexShape
  145. *
  146. * Paints the vertex shape.
  147. */
  148. mxCabinetsDimension.prototype.paintVertexShape = function(c, x, y, w, h)
  149. {
  150. c.translate(x, y);
  151. this.background(c, x, y, w, h);
  152. };
  153. mxCabinetsDimension.prototype.background = function(c, x, y, w, h)
  154. {
  155. c.begin();
  156. c.moveTo(0, 20);
  157. c.lineTo(w, 20);
  158. c.moveTo(10, 15);
  159. c.lineTo(0, 20);
  160. c.lineTo(10, 25);
  161. c.moveTo(w - 10, 15);
  162. c.lineTo(w, 20);
  163. c.lineTo(w - 10, 25);
  164. c.moveTo(0, 15);
  165. c.lineTo(0, h);
  166. c.moveTo(w, 15);
  167. c.lineTo(w, h);
  168. c.stroke();
  169. };
  170. mxCellRenderer.registerShape(mxCabinetsDimension.prototype.cst.DIMENSION, mxCabinetsDimension);
  171. //**********************************************************************************************************************************************************
  172. //Dimension Bottom
  173. //**********************************************************************************************************************************************************
  174. /**
  175. * Extends mxShape.
  176. */
  177. function mxCabinetsDimensionBottom(bounds, fill, stroke, strokewidth)
  178. {
  179. mxShape.call(this);
  180. this.bounds = bounds;
  181. this.fill = fill;
  182. this.stroke = stroke;
  183. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  184. };
  185. /**
  186. * Extends mxShape.
  187. */
  188. mxUtils.extend(mxCabinetsDimensionBottom, mxShape);
  189. mxCabinetsDimensionBottom.prototype.cst = {
  190. DIMENSION : 'mxgraph.cabinets.dimensionBottom'
  191. };
  192. /**
  193. * Function: paintVertexShape
  194. *
  195. * Paints the vertex shape.
  196. */
  197. mxCabinetsDimensionBottom.prototype.paintVertexShape = function(c, x, y, w, h)
  198. {
  199. c.translate(x, y);
  200. this.background(c, x, y, w, h);
  201. };
  202. mxCabinetsDimensionBottom.prototype.background = function(c, x, y, w, h)
  203. {
  204. c.begin();
  205. c.moveTo(0, h - 20);
  206. c.lineTo(w, h - 20);
  207. c.moveTo(10, h - 15);
  208. c.lineTo(0, h - 20);
  209. c.lineTo(10, h - 25);
  210. c.moveTo(w - 10, h - 15);
  211. c.lineTo(w, h - 20);
  212. c.lineTo(w - 10, h - 25);
  213. c.moveTo(0, h - 15);
  214. c.lineTo(0, 0);
  215. c.moveTo(w, h - 15);
  216. c.lineTo(w, 0);
  217. c.stroke();
  218. };
  219. mxCellRenderer.registerShape(mxCabinetsDimensionBottom.prototype.cst.DIMENSION, mxCabinetsDimensionBottom);