mxCabinets.js 6.2 KB

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