mxRack.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245
  1. /**
  2. * $Id: mxRack.js,v 1.5 2014/01/21 13:10:37 gaudenz Exp $
  3. * Copyright (c) 2006-2013, JGraph Ltd
  4. */
  5. //**********************************************************************************************************************************************************
  6. //Rack Numbering
  7. //**********************************************************************************************************************************************************
  8. //**********************************************************************************************************************************************************
  9. // v2 Rack cabinet, old versions below this
  10. //**********************************************************************************************************************************************************
  11. //**********************************************************************************************************************************************************
  12. //START LEGACY RACKS
  13. //**********************************************************************************************************************************************************
  14. function mxRackContainer(bounds, fill, stroke, strokewidth)
  15. {
  16. mxShape.call(this);
  17. this.bounds = bounds;
  18. this.fill = fill;
  19. this.stroke = stroke;
  20. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  21. };
  22. /**
  23. * Extends mxShape.
  24. */
  25. mxUtils.extend(mxRackContainer, mxShape);
  26. mxRackContainer.unitSize = 20;
  27. mxRackContainer.prototype.cst =
  28. {
  29. SHAPE_RACK_CONTAINER : 'mxgraph.rackGeneral.container',
  30. TEXT_COLOR : 'textColor',
  31. NUMBER_DISPLAY : 'numDisp',
  32. OFF : 'off',
  33. DIR_ASC : 'ascend',
  34. DIR_DESC : 'descend'
  35. };
  36. /**
  37. * Function: paintVertexShape
  38. *
  39. * Paints the vertex shape.
  40. */
  41. mxRackContainer.prototype.paintVertexShape = function(c, x, y, w, h)
  42. {
  43. var fontSize = 12;
  44. var displayNumbers = mxUtils.getValue(this.style, mxRackContainer.prototype.cst.NUMBER_DISPLAY, mxRackContainer.prototype.cst.DIR_ASC);
  45. if (displayNumbers !== mxRackContainer.prototype.cst.OFF)
  46. {
  47. c.translate(x + fontSize * 2, y);
  48. w = Math.max(w - fontSize * 2, 0);
  49. }
  50. else
  51. {
  52. c.translate(x, y);
  53. };
  54. this.background(c, w, h, fontSize);
  55. c.setShadow(false);
  56. this.foreground(c, w, h, fontSize);
  57. if (displayNumbers !== mxRackContainer.prototype.cst.OFF && w > 18 + fontSize * 2)
  58. {
  59. this.sideText(c, w, h, fontSize);
  60. };
  61. };
  62. mxRackContainer.prototype.background = function(c, w, h, fontSize)
  63. {
  64. c.setFillColor('#ffffff');
  65. c.rect(0, 0, w, h);
  66. c.fillAndStroke();
  67. };
  68. mxRackContainer.prototype.foreground = function(c, w, h, fontSize)
  69. {
  70. if (w > 18 + fontSize * 2 && h > 42)
  71. {
  72. c.setFillColor('#f4f4f4');
  73. c.rect(0, 0, w, 21);
  74. c.fillAndStroke();
  75. c.rect(0, h - 21, w, 21);
  76. c.fillAndStroke();
  77. c.rect(0, 21, 9, h - 42);
  78. c.fillAndStroke();
  79. c.rect(w - 9, 21, 9, h - 42);
  80. c.fillAndStroke();
  81. c.ellipse(2.5, 7.5, 6, 6);
  82. c.stroke();
  83. c.ellipse(w - 8.5, 7.5, 6, 6);
  84. c.stroke();
  85. c.ellipse(2.5, h - 13.5, 6, 6);
  86. c.stroke();
  87. c.ellipse(w - 8.5, h - 13.5, 6, 6);
  88. c.stroke();
  89. }
  90. };
  91. mxRackContainer.prototype.sideText = function(c, w, h, fontSize)
  92. {
  93. var fontColor = mxUtils.getValue(this.style, mxRackContainer.prototype.cst.TEXT_COLOR, '#666666');
  94. var displayNumbers = mxUtils.getValue(this.style, mxRackContainer.prototype.cst.NUMBER_DISPLAY, mxRackContainer.prototype.cst.DIR_ASC);
  95. c.setFontSize(fontSize);
  96. c.setFontColor(fontColor);
  97. // Calculate number of units
  98. var units = Math.floor((Math.abs(h) - 42) / mxRackContainer.unitSize);
  99. for (var i = 0; i < units; i++)
  100. {
  101. var displayNumber = (displayNumbers === mxRackContainer.prototype.cst.DIR_DESC) ? (i + 1).toString() : (units - i).toString();
  102. c.text(-fontSize, 21 + mxRackContainer.unitSize * 0.5 + i * mxRackContainer.unitSize, 0, 0, displayNumber, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  103. }
  104. c.setStrokeColor('#dddddd');
  105. c.begin();
  106. for (var i = 0; i < units + 1; i++)
  107. {
  108. c.moveTo(-2 * fontSize, 21 + i * mxRackContainer.unitSize);
  109. c.lineTo(0, 21 + i * mxRackContainer.unitSize);
  110. };
  111. c.stroke();
  112. };
  113. /**
  114. * Extends mxShape.
  115. */
  116. function mxRackPlate(bounds, fill, stroke, strokewidth)
  117. {
  118. mxShape.call(this);
  119. this.bounds = bounds;
  120. this.fill = fill;
  121. this.stroke = stroke;
  122. this.strokewidth = 1;
  123. };
  124. /**
  125. * Extends mxShape.
  126. */
  127. mxUtils.extend(mxRackPlate, mxShape);
  128. mxRackPlate.prototype.cst =
  129. {
  130. SHAPE_RACK_PLATE : 'mxgraph.rackGeneral.plate'
  131. };
  132. /**
  133. * Function: paintVertexShape
  134. *
  135. * Paints the vertex shape.
  136. */
  137. mxRackPlate.prototype.paintVertexShape = function(c, x, y, w, h)
  138. {
  139. c.translate(x, y);
  140. this.background(c, w, h);
  141. c.setShadow(false);
  142. this.foreground(c, w, h);
  143. };
  144. mxRackPlate.prototype.background = function(c, w, h)
  145. {
  146. c.rect(0, 0, w, h);
  147. c.fillAndStroke();
  148. };
  149. mxRackPlate.prototype.foreground = function(c, w, h)
  150. {
  151. var bufferSize = 9;
  152. if (w > bufferSize * 2)
  153. {
  154. c.save();
  155. c.setFillColor('#b4b4b4');
  156. c.rect(0, 0, w, h);
  157. c.fillAndStroke();
  158. c.restore();
  159. c.rect(bufferSize, 0, w - bufferSize * 2, h);
  160. c.fillAndStroke();
  161. }
  162. };
  163. //**********************************************************************************************************************************************************
  164. //Horizontal Cable Duct
  165. //**********************************************************************************************************************************************************
  166. /**
  167. * Extends mxShape.
  168. */
  169. function mxRackHorCableDuct(bounds, fill, stroke, strokewidth)
  170. {
  171. mxShape.call(this);
  172. this.bounds = bounds;
  173. this.fill = fill;
  174. this.stroke = stroke;
  175. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  176. };
  177. /**
  178. * Extends mxShape.
  179. */
  180. mxUtils.extend(mxRackHorCableDuct, mxShape);
  181. mxRackHorCableDuct.prototype.cst =
  182. {
  183. SHAPE_RACK_HOR_CABLE_DUCT : 'mxgraph.rackGeneral.horCableDuct'
  184. };
  185. /**
  186. * Function: paintVertexShape
  187. *
  188. * Paints the vertex shape.
  189. */
  190. mxRackHorCableDuct.prototype.paintVertexShape = function(c, x, y, w, h)
  191. {
  192. c.translate(x, y);
  193. this.background(c, w, h);
  194. c.setShadow(false);
  195. this.foreground(c, w, h);
  196. };
  197. mxRackHorCableDuct.prototype.background = function(c, w, h)
  198. {
  199. c.rect(0, 0, w, h);
  200. c.fillAndStroke();
  201. };
  202. mxRackHorCableDuct.prototype.foreground = function(c, w, h)
  203. {
  204. // Divide the space equally with 33 between each duct
  205. var spaceBuffer = 20;
  206. var unitSpacing = 33;
  207. var unitsAcross = Math.floor((w - spaceBuffer) / unitSpacing);
  208. var buffer = spaceBuffer / 2 + Math.floor(((w - spaceBuffer) - unitsAcross * unitSpacing) / 2);
  209. if (unitsAcross > 0)
  210. {
  211. for (var i = 0; i <= unitsAcross; i++)
  212. {
  213. c.rect(buffer, 0, 3, 7);
  214. c.stroke();
  215. c.rect(buffer, 7, 3, 7.8);
  216. c.stroke();
  217. buffer += unitSpacing;
  218. }
  219. }
  220. };
  221. function mxRackHorRoutingBank(bounds, fill, stroke, strokewidth)
  222. {
  223. mxShape.call(this);
  224. this.bounds = bounds;
  225. this.fill = fill;
  226. this.stroke = stroke;
  227. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  228. };
  229. /**
  230. * Extends mxShape.
  231. */
  232. mxUtils.extend(mxRackHorRoutingBank, mxShape);
  233. mxRackHorRoutingBank.prototype.cst =
  234. {
  235. SHAPE_RACK_HOR_ROUTING_BANK : 'mxgraph.rackGeneral.horRoutingBank'
  236. };
  237. /**
  238. * Function: paintVertexShape
  239. *
  240. * Paints the vertex shape.
  241. */
  242. mxRackHorRoutingBank.prototype.paintVertexShape = function(c, x, y, w, h)
  243. {
  244. c.translate(x, y);
  245. this.background(c, w, h);
  246. c.setShadow(false);
  247. this.foreground(c, w, h);
  248. };
  249. mxRackHorRoutingBank.prototype.background = function(c, w, h)
  250. {
  251. c.rect(0, 0, w, h);
  252. c.fillAndStroke();
  253. };
  254. mxRackHorRoutingBank.prototype.foreground = function(c, w, h)
  255. {
  256. // Divide the space equally with 33 between each duct
  257. var spaceBuffer = 20;
  258. var unitSpacing = 22;
  259. var rectWidth = 16;
  260. var unitsAcross = Math.floor((w - spaceBuffer - rectWidth) / unitSpacing);
  261. var unitsDown = Math.floor(h / mxRackContainer.unitSize);
  262. if (unitsAcross > 0 && unitsDown > 0)
  263. {
  264. for (var i = 0; i < unitsDown; i++)
  265. {
  266. var buffer = (spaceBuffer + rectWidth) / 2 + Math.floor(((w - spaceBuffer - rectWidth) - unitsAcross * unitSpacing) / 2) - rectWidth / 2;
  267. for (var j = 0; j <= unitsAcross; j++)
  268. {
  269. c.rect(buffer, 4 + (i * mxRackContainer.unitSize), rectWidth, 6.8);
  270. c.stroke();
  271. buffer += unitSpacing;
  272. }
  273. }
  274. }
  275. };
  276. function mxRackNeatPatch(bounds, fill, stroke, strokewidth)
  277. {
  278. mxShape.call(this);
  279. this.bounds = bounds;
  280. this.fill = fill;
  281. this.stroke = stroke;
  282. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  283. };
  284. /**
  285. * Extends mxShape.
  286. */
  287. mxUtils.extend(mxRackNeatPatch, mxShape);
  288. mxRackNeatPatch.prototype.cst =
  289. {
  290. SHAPE_RACK_NEAT_PATCH : 'mxgraph.rackGeneral.neatPatch'
  291. };
  292. /**
  293. * Function: paintVertexShape
  294. *
  295. * Paints the vertex shape.
  296. */
  297. mxRackNeatPatch.prototype.paintVertexShape = function(c, x, y, w, h)
  298. {
  299. c.translate(x, y);
  300. this.background(c, w, h);
  301. c.setShadow(false);
  302. this.mainText(c, w, h);
  303. };
  304. mxRackNeatPatch.prototype.background = function(c, w, h)
  305. {
  306. c.setFillColor('#666666');
  307. c.rect(0, 0, w, h);
  308. c.fillAndStroke();
  309. };
  310. mxRackNeatPatch.prototype.mainText = function(c, w, h)
  311. {
  312. c.setFontSize('12');
  313. c.setFontColor('#ffffff');
  314. c.setFontStyle(mxConstants.FONT_BOLD);
  315. c.text(w / 2, h - 6, 0, 0, 'NEAT-PATCH', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  316. };
  317. function mxRackShelf(bounds, fill, stroke, strokewidth)
  318. {
  319. mxShape.call(this);
  320. this.bounds = bounds;
  321. this.fill = fill;
  322. this.stroke = stroke;
  323. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  324. };
  325. /**
  326. * Extends mxShape.
  327. */
  328. mxUtils.extend(mxRackShelf, mxShape);
  329. mxRackShelf.prototype.cst =
  330. {
  331. SHAPE_RACK_SHELF : 'mxgraph.rackGeneral.shelf'
  332. };
  333. /**
  334. * Function: paintVertexShape
  335. *
  336. * Paints the vertex shape.
  337. */
  338. mxRackShelf.prototype.paintVertexShape = function(c, x, y, w, h)
  339. {
  340. c.translate(x, y);
  341. this.background(c, w, h);
  342. };
  343. mxRackShelf.prototype.background = function(c, w, h)
  344. {
  345. c.setStrokeWidth(2);
  346. c.begin();
  347. c.moveTo(1, 0);
  348. c.lineTo(1, h - 1);
  349. c.lineTo(w - 1, h - 1);
  350. c.lineTo(w - 1, 1);
  351. c.fillAndStroke();
  352. };
  353. function mxRackRackNumbering(bounds, fill, stroke, strokewidth)
  354. {
  355. mxShape.call(this);
  356. this.bounds = bounds;
  357. this.fill = fill;
  358. this.stroke = stroke;
  359. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  360. };
  361. /**
  362. * Extends mxShape.
  363. */
  364. mxUtils.extend(mxRackRackNumbering, mxShape);
  365. mxRackRackNumbering.prototype.cst =
  366. {
  367. SHAPE_RACK_RACK_NUMBERING : 'mxgraph.rackGeneral.rackNumbering',
  368. UNIT_NUM : 'unitNum',
  369. UNIT_HEIGHT : 'unitHeight',
  370. TEXT_COLOR : 'textColor',
  371. NUM_DIR : 'numDir',
  372. DIR_ASC : 'ascend',
  373. DIR_DESC : 'descend',
  374. TEXT_SIZE : 'textSize'
  375. };
  376. /**
  377. * Function: paintVertexShape
  378. *
  379. * Paints the vertex shape.
  380. */
  381. mxRackRackNumbering.prototype.paintVertexShape = function(c, x, y, w, h)
  382. {
  383. var unitNum = parseFloat(mxUtils.getValue(this.style, mxRackRackNumbering.prototype.cst.UNIT_NUM, '42'));
  384. var unitH = parseFloat(mxUtils.getValue(this.style, mxRackRackNumbering.prototype.cst.UNIT_HEIGHT, '14.8'));
  385. var fontSize = parseFloat(mxUtils.getValue(this.style, mxRackRackNumbering.prototype.cst.TEXT_SIZE, '12'));
  386. c.translate(x, y);
  387. var h = unitNum * unitH;
  388. this.background(c, w, h, fontSize);
  389. c.setShadow(false);
  390. this.sideText(c, w, h, unitNum, unitH, fontSize);
  391. };
  392. mxRackRackNumbering.prototype.background = function(c, w, h, fontSize)
  393. {
  394. c.rect(fontSize * 3, 0, 160.9, h);
  395. c.fillAndStroke();
  396. };
  397. mxRackRackNumbering.prototype.sideText = function(c, w, h, unitNum, unitH, fontSize)
  398. {
  399. var fontColor = mxUtils.getValue(this.style, mxRackRackNumbering.prototype.cst.TEXT_COLOR, '#666666');
  400. var numDir = mxUtils.getValue(this.style, mxRackRackNumbering.prototype.cst.NUM_DIR, mxRackRackNumbering.prototype.cst.DIR_DESC);
  401. c.setFontSize(fontSize);
  402. c.setFontColor(fontColor);
  403. if (numDir === mxRackRackNumbering.prototype.cst.DIR_ASC)
  404. {
  405. for (var i = 0; i < unitNum; i++)
  406. {
  407. c.text(fontSize, unitH * 0.5 + i * unitH, 0, 0, (i + 1).toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  408. };
  409. }
  410. else
  411. {
  412. for (var i = 0; i < unitNum; i++)
  413. {
  414. c.text(fontSize, h - unitH * 0.5 - i * unitH, 0, 0, (i + 1).toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  415. };
  416. };
  417. c.setStrokeColor('#dddddd');
  418. c.begin();
  419. for (var i = 0; i < unitNum + 1; i++)
  420. {
  421. c.moveTo(0, i * unitH);
  422. c.lineTo(fontSize * 3, i * unitH);
  423. };
  424. c.stroke();
  425. };
  426. //**********************************************************************************************************************************************************
  427. //Rack Cabinet
  428. //**********************************************************************************************************************************************************
  429. /**
  430. * Extends mxShape.
  431. */
  432. function mxRackRackCabinet(bounds, fill, stroke, strokewidth)
  433. {
  434. mxShape.call(this);
  435. this.bounds = bounds;
  436. this.fill = fill;
  437. this.stroke = stroke;
  438. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  439. };
  440. /**
  441. * Extends mxShape.
  442. */
  443. mxUtils.extend(mxRackRackCabinet, mxShape);
  444. mxRackRackCabinet.prototype.cst =
  445. {
  446. SHAPE_RACK_RACK_CABINET : 'mxgraph.rackGeneral.rackCabinet',
  447. UNIT_NUM : 'unitNum',
  448. UNIT_HEIGHT : 'unitHeight',
  449. TEXT_COLOR : 'textColor',
  450. NUM_DIR : 'numDir',
  451. NUMBER_DISPLAY : 'numDisp',
  452. ON : 'on',
  453. OFF : 'off',
  454. DIR_ASC : 'ascend',
  455. DIR_DESC : 'descend',
  456. TEXT_SIZE : 'textSize'
  457. };
  458. /**
  459. * Function: paintVertexShape
  460. *
  461. * Paints the vertex shape.
  462. */
  463. mxRackRackCabinet.prototype.paintVertexShape = function(c, x, y, w, h)
  464. {
  465. var unitNum = parseFloat(mxUtils.getValue(this.style, mxRackRackCabinet.prototype.cst.UNIT_NUM, '12'));
  466. var unitH = parseFloat(mxUtils.getValue(this.style, mxRackRackCabinet.prototype.cst.UNIT_HEIGHT, '14.8'));
  467. var fontSize = parseFloat(mxUtils.getValue(this.style, mxRackRackCabinet.prototype.cst.TEXT_SIZE, '12'));
  468. var numDis = mxUtils.getValue(this.style, mxRackRackCabinet.prototype.cst.NUMBER_DISPLAY, mxRackRackCabinet.prototype.cst.ON);
  469. if (numDis === mxRackRackCabinet.prototype.cst.ON)
  470. {
  471. c.translate(x + fontSize * 2, y);
  472. }
  473. else
  474. {
  475. c.translate(x, y);
  476. };
  477. var h = unitNum * unitH + 42;
  478. this.background(c, w, h, fontSize);
  479. c.setShadow(false);
  480. this.foreground(c, w, h, fontSize);
  481. if (numDis === mxRackRackCabinet.prototype.cst.ON)
  482. {
  483. this.sideText(c, w, h, unitNum, unitH, fontSize);
  484. };
  485. };
  486. mxRackRackCabinet.prototype.background = function(c, w, h, fontSize)
  487. {
  488. c.setFillColor('#ffffff');
  489. c.rect(0, 0, 180, h);
  490. c.fillAndStroke();
  491. };
  492. mxRackRackCabinet.prototype.foreground = function(c, w, h, fontSize)
  493. {
  494. c.setFillColor('#f4f4f4');
  495. c.rect(0, 0, 180, 21);
  496. c.fillAndStroke();
  497. c.rect(0, h - 21, 180, 21);
  498. c.fillAndStroke();
  499. c.rect(0, 21, 9, h - 42);
  500. c.fillAndStroke();
  501. c.rect(171, 21, 9, h - 42);
  502. c.fillAndStroke();
  503. c.ellipse(2.5, 7.5, 6, 6);
  504. c.stroke();
  505. c.ellipse(171.5, 7.5, 6, 6);
  506. c.stroke();
  507. c.ellipse(2.5, h - 13.5, 6, 6);
  508. c.stroke();
  509. c.ellipse(171.5, h - 13.5, 6, 6);
  510. c.stroke();
  511. };
  512. mxRackRackCabinet.prototype.sideText = function(c, w, h, unitNum, unitH, fontSize)
  513. {
  514. var fontColor = mxUtils.getValue(this.style, mxRackRackCabinet.prototype.cst.TEXT_COLOR, '#666666');
  515. var numDir = mxUtils.getValue(this.style, mxRackRackCabinet.prototype.cst.NUM_DIR, mxRackRackCabinet.prototype.cst.DIR_DESC);
  516. c.setFontSize(fontSize);
  517. c.setFontColor(fontColor);
  518. if (numDir === mxRackRackCabinet.prototype.cst.DIR_ASC)
  519. {
  520. for (var i = 0; i < unitNum; i++)
  521. {
  522. c.text(-fontSize, 21 + unitH * 0.5 + i * unitH, 0, 0, (i + 1).toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  523. };
  524. }
  525. else
  526. {
  527. for (var i = 0; i < unitNum; i++)
  528. {
  529. c.text(-fontSize, h - 21 - unitH * 0.5 - i * unitH, 0, 0, (i + 1).toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  530. };
  531. };
  532. c.setStrokeColor('#dddddd');
  533. c.begin();
  534. for (var i = 0; i < unitNum + 1; i++)
  535. {
  536. c.moveTo(-2 * fontSize, 21 + i * unitH);
  537. c.lineTo(0, 21 + i * unitH);
  538. };
  539. c.stroke();
  540. };
  541. //**********************************************************************************************************************************************************
  542. //1U Horizontal Cable Duct
  543. //**********************************************************************************************************************************************************
  544. /**
  545. * Extends mxShape.
  546. */
  547. function mxRackHorCableDuct1U(bounds, fill, stroke, strokewidth)
  548. {
  549. mxShape.call(this);
  550. this.bounds = bounds;
  551. this.fill = fill;
  552. this.stroke = stroke;
  553. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  554. };
  555. /**
  556. * Extends mxShape.
  557. */
  558. mxUtils.extend(mxRackHorCableDuct1U, mxShape);
  559. mxRackHorCableDuct1U.prototype.cst =
  560. {
  561. SHAPE_RACK_HOR_CABLE_DUCT_1U : 'mxgraph.rackGeneral.horCableDuct1U'
  562. };
  563. /**
  564. * Function: paintVertexShape
  565. *
  566. * Paints the vertex shape.
  567. */
  568. mxRackHorCableDuct1U.prototype.paintVertexShape = function(c, x, y, w, h)
  569. {
  570. c.translate(x, y);
  571. this.background(c, w, h);
  572. c.setShadow(false);
  573. this.foreground(c, w, h);
  574. };
  575. mxRackHorCableDuct1U.prototype.background = function(c, w, h)
  576. {
  577. c.rect(0, 0, 160.9, 14.8);
  578. c.fillAndStroke();
  579. };
  580. mxRackHorCableDuct1U.prototype.foreground = function(c, w, h)
  581. {
  582. c.rect(12, 0, 3, 7);
  583. c.stroke();
  584. c.rect(12, 7, 3, 7.8);
  585. c.stroke();
  586. c.rect(45.5, 0, 3, 7);
  587. c.stroke();
  588. c.rect(45.5, 7, 3, 7.8);
  589. c.stroke();
  590. c.rect(79, 0, 3, 7);
  591. c.stroke();
  592. c.rect(79, 7, 3, 7.8);
  593. c.stroke();
  594. c.rect(112.5, 0, 3, 7);
  595. c.stroke();
  596. c.rect(112.5, 7, 3, 7.8);
  597. c.stroke();
  598. c.rect(146, 0, 3, 7);
  599. c.stroke();
  600. c.rect(146, 7, 3, 7.8);
  601. c.stroke();
  602. };
  603. //**********************************************************************************************************************************************************
  604. //2U Horizontal Cable Duct
  605. //**********************************************************************************************************************************************************
  606. /**
  607. * Extends mxShape.
  608. */
  609. function mxRackHorCableDuct2U(bounds, fill, stroke, strokewidth)
  610. {
  611. mxShape.call(this);
  612. this.bounds = bounds;
  613. this.fill = fill;
  614. this.stroke = stroke;
  615. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  616. };
  617. /**
  618. * Extends mxShape.
  619. */
  620. mxUtils.extend(mxRackHorCableDuct2U, mxShape);
  621. mxRackHorCableDuct2U.prototype.cst =
  622. {
  623. SHAPE_RACK_HOR_CABLE_DUCT_2U : 'mxgraph.rackGeneral.horCableDuct2U'
  624. };
  625. /**
  626. * Function: paintVertexShape
  627. *
  628. * Paints the vertex shape.
  629. */
  630. mxRackHorCableDuct2U.prototype.paintVertexShape = function(c, x, y, w, h)
  631. {
  632. c.translate(x, y);
  633. this.background(c, w, h);
  634. c.setShadow(false);
  635. this.foreground(c, w, h);
  636. };
  637. mxRackHorCableDuct2U.prototype.background = function(c, w, h)
  638. {
  639. c.rect(0, 0, 160.9, 29.6);
  640. c.fillAndStroke();
  641. };
  642. mxRackHorCableDuct2U.prototype.foreground = function(c, w, h)
  643. {
  644. c.rect(12, 0, 3, 7);
  645. c.stroke();
  646. c.rect(12, 7, 3, 22.6);
  647. c.stroke();
  648. c.rect(45.5, 0, 3, 7);
  649. c.stroke();
  650. c.rect(45.5, 7, 3, 22.6);
  651. c.stroke();
  652. c.rect(79, 0, 3, 7);
  653. c.stroke();
  654. c.rect(79, 7, 3, 22.6);
  655. c.stroke();
  656. c.rect(112.5, 0, 3, 7);
  657. c.stroke();
  658. c.rect(112.5, 7, 3, 22.6);
  659. c.stroke();
  660. c.rect(146, 0, 3, 7);
  661. c.stroke();
  662. c.rect(146, 7, 3, 22.6);
  663. c.stroke();
  664. };
  665. //**********************************************************************************************************************************************************
  666. //1U Cable Routing Bank
  667. //**********************************************************************************************************************************************************
  668. /**
  669. * Extends mxShape.
  670. */
  671. function mxRackHorRoutingBank1U(bounds, fill, stroke, strokewidth)
  672. {
  673. mxShape.call(this);
  674. this.bounds = bounds;
  675. this.fill = fill;
  676. this.stroke = stroke;
  677. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  678. };
  679. /**
  680. * Extends mxShape.
  681. */
  682. mxUtils.extend(mxRackHorRoutingBank1U, mxShape);
  683. mxRackHorRoutingBank1U.prototype.cst =
  684. {
  685. SHAPE_RACK_HOR_ROUTING_BANK_1U : 'mxgraph.rackGeneral.horRoutingBank1U'
  686. };
  687. /**
  688. * Function: paintVertexShape
  689. *
  690. * Paints the vertex shape.
  691. */
  692. mxRackHorRoutingBank1U.prototype.paintVertexShape = function(c, x, y, w, h)
  693. {
  694. c.translate(x, y);
  695. this.background(c, w, h);
  696. c.setShadow(false);
  697. this.foreground(c, w, h);
  698. };
  699. mxRackHorRoutingBank1U.prototype.background = function(c, w, h)
  700. {
  701. c.rect(0, 0, 160.9, 14.8);
  702. c.fillAndStroke();
  703. };
  704. mxRackHorRoutingBank1U.prototype.foreground = function(c, w, h)
  705. {
  706. c.rect(10, 4, 17, 6.8);
  707. c.stroke();
  708. c.rect(31, 4, 17, 6.8);
  709. c.stroke();
  710. c.rect(52, 4, 17, 6.8);
  711. c.stroke();
  712. c.rect(73, 4, 17, 6.8);
  713. c.stroke();
  714. c.rect(94, 4, 17, 6.8);
  715. c.stroke();
  716. c.rect(115, 4, 17, 6.8);
  717. c.stroke();
  718. c.rect(136, 4, 17, 6.8);
  719. c.stroke();
  720. };
  721. //**********************************************************************************************************************************************************
  722. //2U Cable Routing Bank
  723. //**********************************************************************************************************************************************************
  724. /**
  725. * Extends mxShape.
  726. */
  727. function mxRackHorRoutingBank2U(bounds, fill, stroke, strokewidth)
  728. {
  729. mxShape.call(this);
  730. this.bounds = bounds;
  731. this.fill = fill;
  732. this.stroke = stroke;
  733. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  734. };
  735. /**
  736. * Extends mxShape.
  737. */
  738. mxUtils.extend(mxRackHorRoutingBank2U, mxShape);
  739. mxRackHorRoutingBank2U.prototype.cst =
  740. {
  741. SHAPE_RACK_HOR_ROUTING_BANK_2U : 'mxgraph.rackGeneral.horRoutingBank2U'
  742. };
  743. /**
  744. * Function: paintVertexShape
  745. *
  746. * Paints the vertex shape.
  747. */
  748. mxRackHorRoutingBank2U.prototype.paintVertexShape = function(c, x, y, w, h)
  749. {
  750. c.translate(x, y);
  751. this.background(c, w, h);
  752. c.setShadow(false);
  753. this.foreground(c, w, h);
  754. };
  755. mxRackHorRoutingBank2U.prototype.background = function(c, w, h)
  756. {
  757. c.rect(0, 0, 160.9, 29.6);
  758. c.fillAndStroke();
  759. };
  760. mxRackHorRoutingBank2U.prototype.foreground = function(c, w, h)
  761. {
  762. c.rect(10, 4, 17, 6.8);
  763. c.stroke();
  764. c.rect(31, 4, 17, 6.8);
  765. c.stroke();
  766. c.rect(52, 4, 17, 6.8);
  767. c.stroke();
  768. c.rect(73, 4, 17, 6.8);
  769. c.stroke();
  770. c.rect(94, 4, 17, 6.8);
  771. c.stroke();
  772. c.rect(115, 4, 17, 6.8);
  773. c.stroke();
  774. c.rect(136, 4, 17, 6.8);
  775. c.stroke();
  776. c.rect(10, 18.8, 17, 6.8);
  777. c.stroke();
  778. c.rect(31, 18.8, 17, 6.8);
  779. c.stroke();
  780. c.rect(52, 18.8, 17, 6.8);
  781. c.stroke();
  782. c.rect(73, 18.8, 17, 6.8);
  783. c.stroke();
  784. c.rect(94, 18.8, 17, 6.8);
  785. c.stroke();
  786. c.rect(115, 18.8, 17, 6.8);
  787. c.stroke();
  788. c.rect(136, 18.8, 17, 6.8);
  789. c.stroke();
  790. };
  791. //**********************************************************************************************************************************************************
  792. //2U Neat-Patch
  793. //**********************************************************************************************************************************************************
  794. /**
  795. * Extends mxShape.
  796. */
  797. function mxRackNeatPatch2U(bounds, fill, stroke, strokewidth)
  798. {
  799. mxShape.call(this);
  800. this.bounds = bounds;
  801. this.fill = fill;
  802. this.stroke = stroke;
  803. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  804. };
  805. /**
  806. * Extends mxShape.
  807. */
  808. mxUtils.extend(mxRackNeatPatch2U, mxShape);
  809. mxRackNeatPatch2U.prototype.cst =
  810. {
  811. SHAPE_RACK_NEAT_PATCH_2U : 'mxgraph.rackGeneral.neatPatch2U'
  812. };
  813. /**
  814. * Function: paintVertexShape
  815. *
  816. * Paints the vertex shape.
  817. */
  818. mxRackNeatPatch2U.prototype.paintVertexShape = function(c, x, y, w, h)
  819. {
  820. c.translate(x, y);
  821. this.background(c, w, h);
  822. c.setShadow(false);
  823. this.mainText(c, w, h);
  824. };
  825. mxRackNeatPatch2U.prototype.background = function(c, w, h)
  826. {
  827. c.setFillColor('#666666');
  828. c.rect(0, 0, 160.9, 29.6);
  829. c.fillAndStroke();
  830. };
  831. mxRackNeatPatch2U.prototype.mainText = function(c, w, h)
  832. {
  833. c.setFontSize('12');
  834. c.setFontColor('#ffffff');
  835. c.setFontStyle(mxConstants.FONT_BOLD);
  836. c.text(80.45, 24, 0, 0, 'NEAT-PATCH', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  837. };
  838. //**********************************************************************************************************************************************************
  839. //1U shelf
  840. //**********************************************************************************************************************************************************
  841. /**
  842. * Extends mxShape.
  843. */
  844. function mxRackShelf1U(bounds, fill, stroke, strokewidth)
  845. {
  846. mxShape.call(this);
  847. this.bounds = bounds;
  848. this.fill = fill;
  849. this.stroke = stroke;
  850. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  851. };
  852. /**
  853. * Extends mxShape.
  854. */
  855. mxUtils.extend(mxRackShelf1U, mxShape);
  856. mxRackShelf1U.prototype.cst =
  857. {
  858. SHAPE_RACK_SHELF_1U : 'mxgraph.rackGeneral.shelf1U'
  859. };
  860. /**
  861. * Function: paintVertexShape
  862. *
  863. * Paints the vertex shape.
  864. */
  865. mxRackShelf1U.prototype.paintVertexShape = function(c, x, y, w, h)
  866. {
  867. c.translate(x, y);
  868. this.background(c, w, h);
  869. };
  870. mxRackShelf1U.prototype.background = function(c, w, h)
  871. {
  872. c.setStrokeWidth(2);
  873. c.begin();
  874. c.moveTo(0, 0);
  875. c.lineTo(0, 14.8);
  876. c.lineTo(160.9, 14.8);
  877. c.lineTo(160.9, 0);
  878. c.fillAndStroke();
  879. };
  880. //**********************************************************************************************************************************************************
  881. //2U shelf
  882. //**********************************************************************************************************************************************************
  883. /**
  884. * Extends mxShape.
  885. */
  886. function mxRackShelf2U(bounds, fill, stroke, strokewidth)
  887. {
  888. mxShape.call(this);
  889. this.bounds = bounds;
  890. this.fill = fill;
  891. this.stroke = stroke;
  892. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  893. };
  894. /**
  895. * Extends mxShape.
  896. */
  897. mxUtils.extend(mxRackShelf2U, mxShape);
  898. mxRackShelf2U.prototype.cst =
  899. {
  900. SHAPE_RACK_SHELF_2U : 'mxgraph.rackGeneral.shelf2U'
  901. };
  902. /**
  903. * Function: paintVertexShape
  904. *
  905. * Paints the vertex shape.
  906. */
  907. mxRackShelf2U.prototype.paintVertexShape = function(c, x, y, w, h)
  908. {
  909. c.translate(x, y);
  910. this.background(c, w, h);
  911. };
  912. mxRackShelf2U.prototype.background = function(c, w, h)
  913. {
  914. c.setStrokeWidth(2);
  915. c.begin();
  916. c.moveTo(0, 0);
  917. c.lineTo(0, 29.6);
  918. c.lineTo(160.9, 29.6);
  919. c.lineTo(160.9, 0);
  920. c.fillAndStroke();
  921. };
  922. //**********************************************************************************************************************************************************
  923. //4U shelf
  924. //**********************************************************************************************************************************************************
  925. /**
  926. * Extends mxShape.
  927. */
  928. function mxRackShelf4U(bounds, fill, stroke, strokewidth)
  929. {
  930. mxShape.call(this);
  931. this.bounds = bounds;
  932. this.fill = fill;
  933. this.stroke = stroke;
  934. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  935. };
  936. /**
  937. * Extends mxShape.
  938. */
  939. mxUtils.extend(mxRackShelf4U, mxShape);
  940. mxRackShelf4U.prototype.cst =
  941. {
  942. SHAPE_RACK_SHELF_4U : 'mxgraph.rackGeneral.shelf4U'
  943. };
  944. /**
  945. * Function: paintVertexShape
  946. *
  947. * Paints the vertex shape.
  948. */
  949. mxRackShelf4U.prototype.paintVertexShape = function(c, x, y, w, h)
  950. {
  951. c.translate(x, y);
  952. this.background(c, w, h);
  953. };
  954. mxRackShelf4U.prototype.background = function(c, w, h)
  955. {
  956. c.setStrokeWidth(2);
  957. c.begin();
  958. c.moveTo(0, 0);
  959. c.lineTo(0, 59.2);
  960. c.lineTo(160.9, 59.2);
  961. c.lineTo(160.9, 0);
  962. c.fillAndStroke();
  963. };
  964. //**********************************************************************************************************************************************************
  965. //END LEGACY RACKS
  966. //**********************************************************************************************************************************************************
  967. //**********************************************************************************************************************************************************
  968. //Channel Base
  969. //**********************************************************************************************************************************************************
  970. /**
  971. * Extends mxShape.
  972. */
  973. function mxRackChannelBase(bounds, fill, stroke, strokewidth)
  974. {
  975. mxShape.call(this);
  976. this.bounds = bounds;
  977. this.fill = fill;
  978. this.stroke = stroke;
  979. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  980. };
  981. /**
  982. * Extends mxShape.
  983. */
  984. mxUtils.extend(mxRackChannelBase, mxShape);
  985. mxRackChannelBase.prototype.cst =
  986. {
  987. SHAPE_RACK_CHANNEL_BASE : 'mxgraph.rackGeneral.channelBase'
  988. };
  989. /**
  990. * Function: paintVertexShape
  991. *
  992. * Paints the vertex shape.
  993. */
  994. mxRackChannelBase.prototype.paintVertexShape = function(c, x, y, w, h)
  995. {
  996. w = Math.max(w, 20);
  997. h = Math.max(h, 20);
  998. c.translate(x, y);
  999. this.background(c, w, h);
  1000. c.setShadow(false);
  1001. this.foreground(c, w, h);
  1002. };
  1003. mxRackChannelBase.prototype.background = function(c, w, h)
  1004. {
  1005. c.rect(10, h - 15, 5, 15);
  1006. c.fillAndStroke();
  1007. c.rect(w - 15, h - 15, 5, 15);
  1008. c.fillAndStroke();
  1009. c.rect(0, 0, w, h - 5);
  1010. c.fillAndStroke();
  1011. };
  1012. mxRackChannelBase.prototype.foreground = function(c, w, h)
  1013. {
  1014. c.setFillColor('#000000');
  1015. c.rect(10, h - 15, 5, 15);
  1016. c.fillAndStroke();
  1017. c.rect(w - 15, h - 15, 5, 15);
  1018. c.fillAndStroke();
  1019. };
  1020. //**********************************************************************************************************************************************************
  1021. //Cabinet Leg
  1022. //**********************************************************************************************************************************************************
  1023. /**
  1024. * Extends mxShape.
  1025. */
  1026. function mxRackCabinetLeg(bounds, fill, stroke, strokewidth)
  1027. {
  1028. mxShape.call(this);
  1029. this.bounds = bounds;
  1030. this.fill = fill;
  1031. this.stroke = stroke;
  1032. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1033. };
  1034. /**
  1035. * Extends mxShape.
  1036. */
  1037. mxUtils.extend(mxRackCabinetLeg, mxShape);
  1038. mxRackCabinetLeg.prototype.cst =
  1039. {
  1040. SHAPE_RACK_CABINET_LEG : 'mxgraph.rackGeneral.cabinetLeg'
  1041. };
  1042. /**
  1043. * Function: paintVertexShape
  1044. *
  1045. * Paints the vertex shape.
  1046. */
  1047. mxRackCabinetLeg.prototype.paintVertexShape = function(c, x, y, w, h)
  1048. {
  1049. w = Math.max(w, 20);
  1050. h = Math.max(h, 20);
  1051. c.translate(x, y);
  1052. this.background(c, w, h);
  1053. };
  1054. mxRackCabinetLeg.prototype.background = function(c, w, h)
  1055. {
  1056. c.begin();
  1057. c.moveTo(0, h - 10);
  1058. c.lineTo(5, h - 10);
  1059. c.lineTo(5, h - 12);
  1060. c.lineTo(9, h - 12);
  1061. c.lineTo(9, h - 10);
  1062. c.lineTo(w - 10, h - 10);
  1063. c.lineTo(w - 10, 9);
  1064. c.lineTo(w - 12, 9);
  1065. c.lineTo(w - 12, 5);
  1066. c.lineTo(w - 10, 5);
  1067. c.lineTo(w - 10, 0);
  1068. c.lineTo(w, 0);
  1069. c.lineTo(w, h);
  1070. c.lineTo(0, h);
  1071. c.close();
  1072. c.fillAndStroke();
  1073. };
  1074. // New generic unit size implementations
  1075. mxCellRenderer.registerShape(mxRackContainer.prototype.cst.SHAPE_RACK_CONTAINER, mxRackContainer);
  1076. mxCellRenderer.registerShape(mxRackHorCableDuct.prototype.cst.SHAPE_RACK_HOR_CABLE_DUCT, mxRackHorCableDuct);
  1077. mxCellRenderer.registerShape(mxRackHorRoutingBank.prototype.cst.SHAPE_RACK_HOR_ROUTING_BANK, mxRackHorRoutingBank);
  1078. mxCellRenderer.registerShape(mxRackNeatPatch.prototype.cst.SHAPE_RACK_NEAT_PATCH, mxRackNeatPatch);
  1079. mxCellRenderer.registerShape(mxRackShelf.prototype.cst.SHAPE_RACK_SHELF, mxRackShelf);
  1080. mxCellRenderer.registerShape(mxRackPlate.prototype.cst.SHAPE_RACK_PLATE, mxRackPlate);
  1081. // Legacy resizable / fixed unit size implementations
  1082. mxCellRenderer.registerShape(mxRackRackNumbering.prototype.cst.SHAPE_RACK_RACK_NUMBERING, mxRackRackNumbering);
  1083. mxCellRenderer.registerShape(mxRackRackCabinet.prototype.cst.SHAPE_RACK_RACK_CABINET, mxRackRackCabinet);
  1084. mxCellRenderer.registerShape(mxRackHorCableDuct1U.prototype.cst.SHAPE_RACK_HOR_CABLE_DUCT_1U, mxRackHorCableDuct1U);
  1085. mxCellRenderer.registerShape(mxRackHorCableDuct2U.prototype.cst.SHAPE_RACK_HOR_CABLE_DUCT_2U, mxRackHorCableDuct2U);
  1086. mxCellRenderer.registerShape(mxRackHorRoutingBank1U.prototype.cst.SHAPE_RACK_HOR_ROUTING_BANK_1U, mxRackHorRoutingBank1U);
  1087. mxCellRenderer.registerShape(mxRackHorRoutingBank2U.prototype.cst.SHAPE_RACK_HOR_ROUTING_BANK_2U, mxRackHorRoutingBank2U);
  1088. mxCellRenderer.registerShape(mxRackNeatPatch2U.prototype.cst.SHAPE_RACK_NEAT_PATCH_2U, mxRackNeatPatch2U);
  1089. mxCellRenderer.registerShape(mxRackShelf1U.prototype.cst.SHAPE_RACK_SHELF_1U, mxRackShelf1U);
  1090. mxCellRenderer.registerShape(mxRackShelf2U.prototype.cst.SHAPE_RACK_SHELF_2U, mxRackShelf2U);
  1091. mxCellRenderer.registerShape(mxRackShelf4U.prototype.cst.SHAPE_RACK_SHELF_4U, mxRackShelf4U);
  1092. mxCellRenderer.registerShape(mxRackChannelBase.prototype.cst.SHAPE_RACK_CHANNEL_BASE, mxRackChannelBase);
  1093. mxCellRenderer.registerShape(mxRackCabinetLeg.prototype.cst.SHAPE_RACK_CABINET_LEG, mxRackCabinetLeg);