mxCabinets.js 6.1 KB

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