mxRack.js 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585
  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.prototype.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. mxRackContainer.prototype.customProperties = [
  37. {name: 'fillColor2', dispName: 'Cabinet Color', type: 'color'},
  38. {name: 'textColor', dispName: 'Numbers Color', type: 'color'},
  39. {name: 'numDisp', dispName: 'Display Numbers', type: 'enum',
  40. enumList: [{val: 'off', dispName: 'Off'}, {val: 'ascend', dispName: 'Ascending'}, {val: 'descend', dispName: 'Descending'}],
  41. onChange: function(graph, newValue)
  42. {
  43. graph.setCellStyles('marginLeft', (newValue == 'off') ? 9 : 33, graph.getSelectionCells());
  44. }
  45. },
  46. {name: 'rackUnitSize', dispName: 'Unit size', type: 'int'}
  47. ];
  48. /**
  49. * Function: paintVertexShape
  50. *
  51. * Paints the vertex shape.
  52. */
  53. mxRackContainer.prototype.paintVertexShape = function(c, x, y, w, h)
  54. {
  55. var fontSize = 12;
  56. var displayNumbers = mxUtils.getValue(this.style, mxRackContainer.prototype.cst.NUMBER_DISPLAY, mxRackContainer.prototype.cst.DIR_ASC);
  57. var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
  58. var fillColor2 = mxUtils.getValue(this.style, 'fillColor2', '#f4f4f4');
  59. if (displayNumbers !== mxRackContainer.prototype.cst.OFF)
  60. {
  61. c.translate(x + fontSize * 2, y);
  62. w = Math.max(w - fontSize * 2, 0);
  63. }
  64. else
  65. {
  66. c.translate(x, y);
  67. };
  68. c.setFillColor(fillColor);
  69. this.background(c, w, h, fontSize);
  70. c.setShadow(false);
  71. c.setFillColor(fillColor2);
  72. this.foreground(c, w, h, fontSize);
  73. if (displayNumbers !== mxRackContainer.prototype.cst.OFF && w > 18 + fontSize * 2)
  74. {
  75. this.sideText(c, w, h, fontSize);
  76. };
  77. };
  78. mxRackContainer.prototype.background = function(c, w, h, fontSize)
  79. {
  80. c.rect(0, 0, w, h);
  81. c.fillAndStroke();
  82. };
  83. mxRackContainer.prototype.foreground = function(c, w, h, fontSize)
  84. {
  85. if (w > 18 + fontSize * 2 && h > 42)
  86. {
  87. c.rect(0, 0, w, 21);
  88. c.fillAndStroke();
  89. c.rect(0, h - 21, w, 21);
  90. c.fillAndStroke();
  91. c.rect(0, 21, 9, h - 42);
  92. c.fillAndStroke();
  93. c.rect(w - 9, 21, 9, h - 42);
  94. c.fillAndStroke();
  95. c.ellipse(2.5, 7.5, 6, 6);
  96. c.stroke();
  97. c.ellipse(w - 8.5, 7.5, 6, 6);
  98. c.stroke();
  99. c.ellipse(2.5, h - 13.5, 6, 6);
  100. c.stroke();
  101. c.ellipse(w - 8.5, h - 13.5, 6, 6);
  102. c.stroke();
  103. }
  104. };
  105. mxRackContainer.prototype.sideText = function(c, w, h, fontSize)
  106. {
  107. var fontColor = mxUtils.getValue(this.style, mxRackContainer.prototype.cst.TEXT_COLOR, '#666666');
  108. var displayNumbers = mxUtils.getValue(this.style, mxRackContainer.prototype.cst.NUMBER_DISPLAY, mxRackContainer.prototype.cst.DIR_ASC);
  109. var unitSize = parseFloat(mxUtils.getValue(this.style, 'rackUnitSize', mxRackContainer.prototype.unitSize));
  110. this.unitSize = unitSize;
  111. c.setFontSize(fontSize);
  112. c.setFontColor(fontColor);
  113. // Calculate number of units
  114. var units = Math.floor((Math.abs(h) - 42) / unitSize);
  115. for (var i = 0; i < units; i++)
  116. {
  117. var displayNumber = (displayNumbers === mxRackContainer.prototype.cst.DIR_DESC) ? (i + 1).toString() : (units - i).toString();
  118. c.text(-fontSize, 21 + unitSize * 0.5 + i * unitSize, 0, 0, displayNumber, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  119. }
  120. c.begin();
  121. for (var i = 0; i < units + 1; i++)
  122. {
  123. c.moveTo(-2 * fontSize, 21 + i * unitSize);
  124. c.lineTo(0, 21 + i * unitSize);
  125. };
  126. c.stroke();
  127. };
  128. /**
  129. * Extends mxShape.
  130. */
  131. function mxRackPlate(bounds, fill, stroke, strokewidth)
  132. {
  133. mxShape.call(this);
  134. this.bounds = bounds;
  135. this.fill = fill;
  136. this.stroke = stroke;
  137. this.strokewidth = 1;
  138. };
  139. /**
  140. * Extends mxShape.
  141. */
  142. mxUtils.extend(mxRackPlate, mxShape);
  143. mxRackPlate.prototype.cst =
  144. {
  145. SHAPE_RACK_PLATE : 'mxgraph.rackGeneral.plate'
  146. };
  147. /**
  148. * Function: paintVertexShape
  149. *
  150. * Paints the vertex shape.
  151. */
  152. mxRackPlate.prototype.paintVertexShape = function(c, x, y, w, h)
  153. {
  154. c.translate(x, y);
  155. this.background(c, w, h);
  156. c.setShadow(false);
  157. this.foreground(c, w, h);
  158. };
  159. mxRackPlate.prototype.background = function(c, w, h)
  160. {
  161. c.begin();
  162. c.rect(0, 0, w, h);
  163. c.fillAndStroke();
  164. };
  165. mxRackPlate.prototype.foreground = function(c, w, h)
  166. {
  167. var bufferSize = 9;
  168. if (w > bufferSize * 2)
  169. {
  170. c.save();
  171. c.setFillColor('#000000');
  172. c.setAlpha(0.23);
  173. c.rect(0,0, bufferSize, h);
  174. c.fill();
  175. c.rect(w - bufferSize,0, bufferSize, h);
  176. c.fill();
  177. c.restore();
  178. c.rect(0, 0, w, h);
  179. c.stroke();
  180. c.rect(bufferSize, 0, w - bufferSize * 2, h);
  181. c.stroke();
  182. }
  183. };
  184. //**********************************************************************************************************************************************************
  185. //Horizontal Cable Duct
  186. //**********************************************************************************************************************************************************
  187. /**
  188. * Extends mxShape.
  189. */
  190. function mxRackHorCableDuct(bounds, fill, stroke, strokewidth)
  191. {
  192. mxShape.call(this);
  193. this.bounds = bounds;
  194. this.fill = fill;
  195. this.stroke = stroke;
  196. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  197. };
  198. /**
  199. * Extends mxShape.
  200. */
  201. mxUtils.extend(mxRackHorCableDuct, mxShape);
  202. mxRackHorCableDuct.prototype.cst =
  203. {
  204. SHAPE_RACK_HOR_CABLE_DUCT : 'mxgraph.rackGeneral.horCableDuct'
  205. };
  206. /**
  207. * Function: paintVertexShape
  208. *
  209. * Paints the vertex shape.
  210. */
  211. mxRackHorCableDuct.prototype.paintVertexShape = function(c, x, y, w, h)
  212. {
  213. c.translate(x, y);
  214. this.background(c, w, h);
  215. c.setShadow(false);
  216. this.foreground(c, w, h);
  217. };
  218. mxRackHorCableDuct.prototype.background = function(c, w, h)
  219. {
  220. c.rect(0, 0, w, h);
  221. c.fillAndStroke();
  222. };
  223. mxRackHorCableDuct.prototype.foreground = function(c, w, h)
  224. {
  225. // Divide the space equally with 33 between each duct
  226. var spaceBuffer = 20;
  227. var unitSpacing = 33;
  228. var unitsAcross = Math.floor((w - spaceBuffer) / unitSpacing);
  229. var buffer = spaceBuffer / 2 + Math.floor(((w - spaceBuffer) - unitsAcross * unitSpacing) / 2);
  230. if (unitsAcross > 0)
  231. {
  232. for (var i = 0; i <= unitsAcross; i++)
  233. {
  234. c.rect(buffer, 0, 3, 7);
  235. c.stroke();
  236. c.rect(buffer, 7, 3, 7.8);
  237. c.stroke();
  238. buffer += unitSpacing;
  239. }
  240. }
  241. };
  242. function mxRackHorRoutingBank(bounds, fill, stroke, strokewidth)
  243. {
  244. mxShape.call(this);
  245. this.bounds = bounds;
  246. this.fill = fill;
  247. this.stroke = stroke;
  248. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  249. };
  250. /**
  251. * Extends mxShape.
  252. */
  253. mxUtils.extend(mxRackHorRoutingBank, mxShape);
  254. mxRackHorRoutingBank.prototype.cst =
  255. {
  256. SHAPE_RACK_HOR_ROUTING_BANK : 'mxgraph.rackGeneral.horRoutingBank'
  257. };
  258. /**
  259. * Function: paintVertexShape
  260. *
  261. * Paints the vertex shape.
  262. */
  263. mxRackHorRoutingBank.prototype.paintVertexShape = function(c, x, y, w, h)
  264. {
  265. c.translate(x, y);
  266. this.background(c, w, h);
  267. c.setShadow(false);
  268. this.foreground(c, w, h);
  269. };
  270. mxRackHorRoutingBank.prototype.background = function(c, w, h)
  271. {
  272. c.rect(0, 0, w, h);
  273. c.fillAndStroke();
  274. };
  275. mxRackHorRoutingBank.prototype.foreground = function(c, w, h)
  276. {
  277. // Divide the space equally with 33 between each duct
  278. var spaceBuffer = 20;
  279. var unitSpacing = 22;
  280. var rectWidth = 16;
  281. var unitsAcross = Math.floor((w - spaceBuffer - rectWidth) / unitSpacing);
  282. var unitsDown = Math.floor(h / mxRackContainer.unitSize);
  283. if (unitsAcross > 0 && unitsDown > 0)
  284. {
  285. for (var i = 0; i < unitsDown; i++)
  286. {
  287. var buffer = (spaceBuffer + rectWidth) / 2 + Math.floor(((w - spaceBuffer - rectWidth) - unitsAcross * unitSpacing) / 2) - rectWidth / 2;
  288. for (var j = 0; j <= unitsAcross; j++)
  289. {
  290. c.rect(buffer, 4 + (i * mxRackContainer.unitSize), rectWidth, 6.8);
  291. c.stroke();
  292. buffer += unitSpacing;
  293. }
  294. }
  295. }
  296. };
  297. function mxRackNeatPatch(bounds, fill, stroke, strokewidth)
  298. {
  299. mxShape.call(this);
  300. this.bounds = bounds;
  301. this.fill = fill;
  302. this.stroke = stroke;
  303. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  304. };
  305. /**
  306. * Extends mxShape.
  307. */
  308. mxUtils.extend(mxRackNeatPatch, mxShape);
  309. mxRackNeatPatch.prototype.cst =
  310. {
  311. SHAPE_RACK_NEAT_PATCH : 'mxgraph.rackGeneral.neatPatch'
  312. };
  313. /**
  314. * Function: paintVertexShape
  315. *
  316. * Paints the vertex shape.
  317. */
  318. mxRackNeatPatch.prototype.paintVertexShape = function(c, x, y, w, h)
  319. {
  320. c.translate(x, y);
  321. this.background(c, w, h);
  322. c.setShadow(false);
  323. this.mainText(c, w, h);
  324. };
  325. mxRackNeatPatch.prototype.background = function(c, w, h)
  326. {
  327. c.setFillColor('#666666');
  328. c.rect(0, 0, w, h);
  329. c.fillAndStroke();
  330. };
  331. mxRackNeatPatch.prototype.mainText = function(c, w, h)
  332. {
  333. c.setFontSize('12');
  334. c.setFontColor('#ffffff');
  335. c.setFontStyle(mxConstants.FONT_BOLD);
  336. c.text(w / 2, h - 6, 0, 0, 'NEAT-PATCH', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  337. };
  338. function mxRackShelf(bounds, fill, stroke, strokewidth)
  339. {
  340. mxShape.call(this);
  341. this.bounds = bounds;
  342. this.fill = fill;
  343. this.stroke = stroke;
  344. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  345. };
  346. /**
  347. * Extends mxShape.
  348. */
  349. mxUtils.extend(mxRackShelf, mxShape);
  350. mxRackShelf.prototype.cst =
  351. {
  352. SHAPE_RACK_SHELF : 'mxgraph.rackGeneral.shelf'
  353. };
  354. /**
  355. * Function: paintVertexShape
  356. *
  357. * Paints the vertex shape.
  358. */
  359. mxRackShelf.prototype.paintVertexShape = function(c, x, y, w, h)
  360. {
  361. c.translate(x, y);
  362. this.background(c, w, h);
  363. };
  364. mxRackShelf.prototype.background = function(c, w, h)
  365. {
  366. c.setStrokeWidth(2);
  367. c.begin();
  368. c.moveTo(1, 0);
  369. c.lineTo(1, h - 1);
  370. c.lineTo(w - 1, h - 1);
  371. c.lineTo(w - 1, 1);
  372. c.fillAndStroke();
  373. };
  374. function mxRackRackNumbering(bounds, fill, stroke, strokewidth)
  375. {
  376. mxShape.call(this);
  377. this.bounds = bounds;
  378. this.fill = fill;
  379. this.stroke = stroke;
  380. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  381. };
  382. /**
  383. * Extends mxShape.
  384. */
  385. mxUtils.extend(mxRackRackNumbering, mxShape);
  386. mxRackRackNumbering.prototype.cst =
  387. {
  388. SHAPE_RACK_RACK_NUMBERING : 'mxgraph.rackGeneral.rackNumbering',
  389. UNIT_NUM : 'unitNum',
  390. UNIT_HEIGHT : 'unitHeight',
  391. TEXT_COLOR : 'textColor',
  392. NUM_DIR : 'numDir',
  393. DIR_ASC : 'ascend',
  394. DIR_DESC : 'descend',
  395. TEXT_SIZE : 'textSize'
  396. };
  397. /**
  398. * Function: paintVertexShape
  399. *
  400. * Paints the vertex shape.
  401. */
  402. mxRackRackNumbering.prototype.paintVertexShape = function(c, x, y, w, h)
  403. {
  404. var unitNum = parseFloat(mxUtils.getValue(this.style, mxRackRackNumbering.prototype.cst.UNIT_NUM, '42'));
  405. var unitH = parseFloat(mxUtils.getValue(this.style, mxRackRackNumbering.prototype.cst.UNIT_HEIGHT, '14.8'));
  406. var fontSize = parseFloat(mxUtils.getValue(this.style, mxRackRackNumbering.prototype.cst.TEXT_SIZE, '12'));
  407. c.translate(x, y);
  408. var h = unitNum * unitH;
  409. this.background(c, w, h, fontSize);
  410. c.setShadow(false);
  411. this.sideText(c, w, h, unitNum, unitH, fontSize);
  412. };
  413. mxRackRackNumbering.prototype.background = function(c, w, h, fontSize)
  414. {
  415. c.rect(fontSize * 3, 0, 160.9, h);
  416. c.fillAndStroke();
  417. };
  418. mxRackRackNumbering.prototype.sideText = function(c, w, h, unitNum, unitH, fontSize)
  419. {
  420. var fontColor = mxUtils.getValue(this.style, mxRackRackNumbering.prototype.cst.TEXT_COLOR, '#666666');
  421. var numDir = mxUtils.getValue(this.style, mxRackRackNumbering.prototype.cst.NUM_DIR, mxRackRackNumbering.prototype.cst.DIR_DESC);
  422. c.setFontSize(fontSize);
  423. c.setFontColor(fontColor);
  424. if (numDir === mxRackRackNumbering.prototype.cst.DIR_ASC)
  425. {
  426. for (var i = 0; i < unitNum; i++)
  427. {
  428. c.text(fontSize, unitH * 0.5 + i * unitH, 0, 0, (i + 1).toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  429. };
  430. }
  431. else
  432. {
  433. for (var i = 0; i < unitNum; i++)
  434. {
  435. 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);
  436. };
  437. };
  438. c.setStrokeColor('#dddddd');
  439. c.begin();
  440. for (var i = 0; i < unitNum + 1; i++)
  441. {
  442. c.moveTo(0, i * unitH);
  443. c.lineTo(fontSize * 3, i * unitH);
  444. };
  445. c.stroke();
  446. };
  447. //**********************************************************************************************************************************************************
  448. //Rack Cabinet
  449. //**********************************************************************************************************************************************************
  450. /**
  451. * Extends mxShape.
  452. */
  453. function mxRackRackCabinet(bounds, fill, stroke, strokewidth)
  454. {
  455. mxShape.call(this);
  456. this.bounds = bounds;
  457. this.fill = fill;
  458. this.stroke = stroke;
  459. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  460. };
  461. /**
  462. * Extends mxShape.
  463. */
  464. mxUtils.extend(mxRackRackCabinet, mxShape);
  465. mxRackRackCabinet.prototype.cst =
  466. {
  467. SHAPE_RACK_RACK_CABINET : 'mxgraph.rackGeneral.rackCabinet',
  468. UNIT_NUM : 'unitNum',
  469. UNIT_HEIGHT : 'unitHeight',
  470. TEXT_COLOR : 'textColor',
  471. NUM_DIR : 'numDir',
  472. NUMBER_DISPLAY : 'numDisp',
  473. ON : 'on',
  474. OFF : 'off',
  475. DIR_ASC : 'ascend',
  476. DIR_DESC : 'descend',
  477. TEXT_SIZE : 'textSize'
  478. };
  479. mxRackRackCabinet.prototype.customProperties = [
  480. {name: 'unitNum', dispName: 'Number of units', type: 'int', defVal: 12},
  481. {name: 'startUnit', dispName: 'Starting unit', type: 'int', defVal: 1},
  482. {name: 'unitHeight', dispName: 'Unit height', type: 'float', defVal: 14.8},
  483. {name: 'textColor', dispName: 'Number text color', type: 'color', defVal: '#666666'},
  484. {name: 'textSize', dispName: 'Text size', type: 'float', defVal: '12'},
  485. {name: 'numDisp', dispName: 'Display Numbers', type: 'enum', defVal: 'descend',
  486. enumList: [{val: 'off', dispName: 'Off'}, {val: 'ascend', dispName: 'Ascending'}, {val: 'descend', dispName: 'Descending'}],
  487. onChange: function(graph, newValue)
  488. {
  489. graph.setCellStyles('marginLeft', (newValue == 'off') ? 9 : 33, graph.getSelectionCells());
  490. }
  491. }
  492. ];
  493. /**
  494. * Function: paintVertexShape
  495. *
  496. * Paints the vertex shape.
  497. */
  498. mxRackRackCabinet.prototype.paintVertexShape = function(c, x, y, w, h)
  499. {
  500. var unitNum = parseFloat(mxUtils.getValue(this.style, mxRackRackCabinet.prototype.cst.UNIT_NUM, '12'));
  501. var unitH = parseFloat(mxUtils.getValue(this.style, mxRackRackCabinet.prototype.cst.UNIT_HEIGHT, '14.8'));
  502. var fontSize = parseFloat(mxUtils.getValue(this.style, mxRackRackCabinet.prototype.cst.TEXT_SIZE, '12'));
  503. var numDisp = mxUtils.getValue(this.style, mxRackRackCabinet.prototype.cst.NUMBER_DISPLAY, mxRackRackCabinet.prototype.cst.ON);
  504. if (numDisp !== mxRackRackCabinet.prototype.cst.OFF)
  505. {
  506. c.translate(x + fontSize * 2, y);
  507. }
  508. else
  509. {
  510. c.translate(x, y);
  511. };
  512. var h = unitNum * unitH + 42;
  513. this.background(c, h);
  514. c.setShadow(false);
  515. this.foreground(c, h);
  516. if (numDisp !== mxRackRackCabinet.prototype.cst.OFF)
  517. {
  518. this.sideText(c, h, unitNum, unitH, fontSize, numDisp);
  519. };
  520. };
  521. mxRackRackCabinet.prototype.background = function(c, h)
  522. {
  523. c.setFillColor('#ffffff');
  524. c.rect(0, 0, 180, h);
  525. c.fillAndStroke();
  526. };
  527. mxRackRackCabinet.prototype.foreground = function(c, h)
  528. {
  529. c.setFillColor('#f4f4f4');
  530. c.rect(0, 0, 180, 21);
  531. c.fillAndStroke();
  532. c.rect(0, h - 21, 180, 21);
  533. c.fillAndStroke();
  534. c.rect(0, 21, 9, h - 42);
  535. c.fillAndStroke();
  536. c.rect(171, 21, 9, h - 42);
  537. c.fillAndStroke();
  538. c.ellipse(2.5, 7.5, 6, 6);
  539. c.stroke();
  540. c.ellipse(171.5, 7.5, 6, 6);
  541. c.stroke();
  542. c.ellipse(2.5, h - 13.5, 6, 6);
  543. c.stroke();
  544. c.ellipse(171.5, h - 13.5, 6, 6);
  545. c.stroke();
  546. };
  547. mxRackRackCabinet.prototype.sideText = function(c, h, unitNum, unitH, fontSize, numDisp)
  548. {
  549. var fontColor = mxUtils.getValue(this.style, mxRackRackCabinet.prototype.cst.TEXT_COLOR, '#666666');
  550. var startUnit = mxUtils.getValue(this.style, 'startUnit', 1);
  551. c.setFontSize(fontSize);
  552. c.setFontColor(fontColor);
  553. if (numDisp === mxRackRackCabinet.prototype.cst.DIR_ASC)
  554. {
  555. for (var i = 0; i < unitNum; i++)
  556. {
  557. c.text(-fontSize, 21 + unitH * 0.5 + i * unitH, 0, 0, (i + startUnit).toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  558. };
  559. }
  560. else if (numDisp === mxRackRackCabinet.prototype.cst.DIR_DESC || numDisp === mxRackRackCabinet.prototype.cst.DIR_ON)
  561. {
  562. for (var i = 0; i < unitNum; i++)
  563. {
  564. c.text(-fontSize, h - 21 - unitH * 0.5 - i * unitH, 0, 0, (i + startUnit).toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  565. };
  566. };
  567. c.setStrokeColor(fontColor);
  568. c.begin();
  569. for (var i = 0; i < unitNum + 1; i++)
  570. {
  571. c.moveTo(-2 * fontSize, 21 + i * unitH);
  572. c.lineTo(0, 21 + i * unitH);
  573. };
  574. c.stroke();
  575. };
  576. //**********************************************************************************************************************************************************
  577. //Rack Cabinet v2
  578. //**********************************************************************************************************************************************************
  579. /**
  580. * Extends mxShape.
  581. */
  582. function mxRackRackCabinet2(bounds, fill, stroke, strokewidth)
  583. {
  584. mxShape.call(this);
  585. this.bounds = bounds;
  586. this.fill = fill;
  587. this.stroke = stroke;
  588. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  589. };
  590. /**
  591. * Extends mxShape.
  592. */
  593. mxUtils.extend(mxRackRackCabinet2, mxShape);
  594. mxRackRackCabinet2.prototype.cst =
  595. {
  596. SHAPE_RACK_RACK_CABINET : 'mxgraph.rackGeneral.rackCabinet2',
  597. UNIT_NUM : 'unitNum',
  598. UNIT_HEIGHT : 'rackUnitSize',
  599. TEXT_COLOR : 'textColor',
  600. NUM_DIR : 'numDir',
  601. NUMBER_DISPLAY : 'numDisp',
  602. ON : 'on',
  603. OFF : 'off',
  604. DIR_ASC : 'ascend',
  605. DIR_DESC : 'descend',
  606. TEXT_SIZE : 'textSize'
  607. };
  608. mxRackRackCabinet2.prototype.customProperties = [
  609. {name: 'unitNum', dispName: 'Number of units', type: 'int', defVal: 12},
  610. {name: 'startUnit', dispName: 'Starting unit', type: 'int', defVal: 1},
  611. {name: 'rackUnitSize', dispName: 'Unit height', type: 'float', defVal: 14.8},
  612. {name: 'fillColor2', dispName: 'Panel Color', type: 'color', defVal: '#ffffff'},
  613. {name: 'textColor', dispName: 'Number text color', type: 'color', defVal: '#666666'},
  614. {name: 'textSize', dispName: 'Text size', type: 'float', defVal: '12'},
  615. {name: 'numDisp', dispName: 'Display Numbers', type: 'enum', defVal: 'descend',
  616. enumList: [{val: 'off', dispName: 'Off'}, {val: 'ascend', dispName: 'Ascending'}, {val: 'descend', dispName: 'Descending'}],
  617. onChange: function(graph, newValue)
  618. {
  619. graph.setCellStyles('marginLeft', (newValue == 'off') ? 9 : 33, graph.getSelectionCells());
  620. }
  621. }
  622. ];
  623. /**
  624. * Function: paintVertexShape
  625. *
  626. * Paints the vertex shape.
  627. */
  628. mxRackRackCabinet2.prototype.paintVertexShape = function(c, x, y, w, h)
  629. {
  630. var unitNum = parseFloat(mxUtils.getValue(this.style, mxRackRackCabinet2.prototype.cst.UNIT_NUM, '12'));
  631. var unitH = parseFloat(mxUtils.getValue(this.style, mxRackRackCabinet2.prototype.cst.UNIT_HEIGHT, '14.8'));
  632. var fontSize = parseFloat(mxUtils.getValue(this.style, mxRackRackCabinet2.prototype.cst.TEXT_SIZE, '12'));
  633. var numDisp = mxUtils.getValue(this.style, mxRackRackCabinet2.prototype.cst.NUMBER_DISPLAY, mxRackRackCabinet2.prototype.cst.ON);
  634. if (numDisp !== mxRackRackCabinet2.prototype.cst.OFF)
  635. {
  636. c.translate(x + fontSize * 2, y);
  637. w = w - fontSize * 2;
  638. }
  639. else
  640. {
  641. c.translate(x, y);
  642. };
  643. var h = unitNum * unitH + 42;
  644. this.background(c, w, h);
  645. c.setShadow(false);
  646. this.foreground(c, w, h);
  647. if (numDisp !== mxRackRackCabinet2.prototype.cst.OFF)
  648. {
  649. this.sideText(c, h, unitNum, unitH, fontSize, numDisp);
  650. };
  651. };
  652. mxRackRackCabinet2.prototype.background = function(c, w, h)
  653. {
  654. var fillC = mxUtils.getValue(this.style, 'fillColor2', '#ffffff');
  655. c.setFillColor(fillC);
  656. c.rect(0, 0, w, h);
  657. c.fillAndStroke();
  658. };
  659. mxRackRackCabinet2.prototype.foreground = function(c, w, h)
  660. {
  661. var fillC = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#f4f4f4');
  662. c.setFillColor(fillC);
  663. c.rect(0, 0, w, 21);
  664. c.fillAndStroke();
  665. c.rect(0, h - 21, w, 21);
  666. c.fillAndStroke();
  667. c.rect(0, 21, 9, h - 42);
  668. c.fillAndStroke();
  669. c.rect(w - 9, 21, 9, h - 42);
  670. c.fillAndStroke();
  671. c.ellipse(2.5, 7.5, 6, 6);
  672. c.stroke();
  673. c.ellipse(w - 8.5, 7.5, 6, 6);
  674. c.stroke();
  675. c.ellipse(2.5, h - 13.5, 6, 6);
  676. c.stroke();
  677. c.ellipse(w - 8.5, h - 13.5, 6, 6);
  678. c.stroke();
  679. };
  680. mxRackRackCabinet2.prototype.sideText = function(c, h, unitNum, unitH, fontSize, numDisp)
  681. {
  682. var fontColor = mxUtils.getValue(this.style, mxRackRackCabinet2.prototype.cst.TEXT_COLOR, '#666666');
  683. var startUnit = mxUtils.getValue(this.style, 'startUnit', 1);
  684. c.setFontSize(fontSize);
  685. c.setFontColor(fontColor);
  686. if (numDisp === mxRackRackCabinet2.prototype.cst.DIR_ASC)
  687. {
  688. for (var i = 0; i < unitNum; i++)
  689. {
  690. c.text(-fontSize, 21 + unitH * 0.5 + i * unitH, 0, 0, (i + startUnit).toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  691. };
  692. }
  693. else if (numDisp === mxRackRackCabinet2.prototype.cst.DIR_DESC || numDisp === mxRackRackCabinet2.prototype.cst.DIR_ON)
  694. {
  695. for (var i = 0; i < unitNum; i++)
  696. {
  697. c.text(-fontSize, h - 21 - unitH * 0.5 - i * unitH, 0, 0, (i + startUnit).toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  698. };
  699. };
  700. c.setStrokeColor(fontColor);
  701. c.begin();
  702. for (var i = 0; i < unitNum + 1; i++)
  703. {
  704. c.moveTo(-2 * fontSize, 21 + i * unitH);
  705. c.lineTo(0, 21 + i * unitH);
  706. };
  707. c.stroke();
  708. };
  709. //**********************************************************************************************************************************************************
  710. //Rack Cabinet v3
  711. //**********************************************************************************************************************************************************
  712. /**
  713. * Extends mxShape.
  714. */
  715. function mxRackRackCabinet3(bounds, fill, stroke, strokewidth)
  716. {
  717. mxShape.call(this);
  718. this.bounds = bounds;
  719. this.fill = fill;
  720. this.stroke = stroke;
  721. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  722. };
  723. /**
  724. * Extends mxShape.
  725. */
  726. mxUtils.extend(mxRackRackCabinet3, mxShape);
  727. mxRackRackCabinet3.prototype.cst =
  728. {
  729. SHAPE_RACK_RACK_CABINET : 'mxgraph.rackGeneral.rackCabinet3',
  730. UNIT_NUM : 'unitNum',
  731. UNIT_HEIGHT : 'rackUnitSize',
  732. TEXT_COLOR : 'textColor',
  733. NUM_DIR : 'numDir',
  734. NUMBER_DISPLAY : 'numDisp',
  735. ON : 'on',
  736. OFF : 'off',
  737. DIR_ASC : 'ascend',
  738. DIR_DESC : 'descend',
  739. TEXT_SIZE : 'textSize'
  740. };
  741. mxRackRackCabinet3.prototype.customProperties = [
  742. {name: 'startUnit', dispName: 'Starting unit', type: 'int', defVal: 1},
  743. {name: 'rackUnitSize', dispName: 'Unit height', type: 'float', defVal: 14.8},
  744. {name: 'fillColor2', dispName: 'Panel Color', type: 'color', defVal: '#ffffff'},
  745. {name: 'textColor', dispName: 'Number text color', type: 'color', defVal: '#666666'},
  746. {name: 'textSize', dispName: 'Text size', type: 'float', defVal: '12'},
  747. {name: 'numDisp', dispName: 'Display Numbers', type: 'enum', defVal: 'descend',
  748. enumList: [{val: 'off', dispName: 'Off'}, {val: 'ascend', dispName: 'Ascending'}, {val: 'descend', dispName: 'Descending'}],
  749. onChange: function(graph, newValue)
  750. {
  751. graph.setCellStyles('marginLeft', (newValue == 'off') ? 9 : 33, graph.getSelectionCells());
  752. }
  753. }
  754. ];
  755. /**
  756. * Function: paintVertexShape
  757. *
  758. * Paints the vertex shape.
  759. */
  760. mxRackRackCabinet3.prototype.paintVertexShape = function(c, x, y, w, h)
  761. {
  762. var unitH = parseFloat(mxUtils.getValue(this.style, mxRackRackCabinet3.prototype.cst.UNIT_HEIGHT, '14.8'));
  763. var unitNum = Math.round((h - 42) / unitH);
  764. var fontSize = parseFloat(mxUtils.getValue(this.style, mxRackRackCabinet3.prototype.cst.TEXT_SIZE, '12'));
  765. var numDisp = mxUtils.getValue(this.style, mxRackRackCabinet3.prototype.cst.NUMBER_DISPLAY, mxRackRackCabinet3.prototype.cst.ON);
  766. if (numDisp !== mxRackRackCabinet3.prototype.cst.OFF)
  767. {
  768. c.translate(x + fontSize * 2, y);
  769. w = w - fontSize * 2;
  770. }
  771. else
  772. {
  773. c.translate(x, y);
  774. };
  775. var h = unitNum * unitH + 42;
  776. this.background(c, w, h);
  777. c.setShadow(false);
  778. this.foreground(c, w, h);
  779. if (numDisp !== mxRackRackCabinet3.prototype.cst.OFF)
  780. {
  781. this.sideText(c, h, unitNum, unitH, fontSize, numDisp);
  782. };
  783. };
  784. mxRackRackCabinet3.prototype.background = function(c, w, h)
  785. {
  786. var fillC = mxUtils.getValue(this.style, 'fillColor2', '#ffffff');
  787. c.setFillColor(fillC);
  788. c.rect(0, 0, w, h);
  789. c.fillAndStroke();
  790. };
  791. mxRackRackCabinet3.prototype.foreground = function(c, w, h)
  792. {
  793. var fillC = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#f4f4f4');
  794. c.setFillColor(fillC);
  795. c.rect(0, 0, w, 21);
  796. c.fillAndStroke();
  797. c.rect(0, h - 21, w, 21);
  798. c.fillAndStroke();
  799. c.rect(0, 21, 9, h - 42);
  800. c.fillAndStroke();
  801. c.rect(w - 9, 21, 9, h - 42);
  802. c.fillAndStroke();
  803. c.ellipse(2.5, 7.5, 6, 6);
  804. c.stroke();
  805. c.ellipse(w - 8.5, 7.5, 6, 6);
  806. c.stroke();
  807. c.ellipse(2.5, h - 13.5, 6, 6);
  808. c.stroke();
  809. c.ellipse(w - 8.5, h - 13.5, 6, 6);
  810. c.stroke();
  811. };
  812. mxRackRackCabinet3.prototype.sideText = function(c, h, unitNum, unitH, fontSize, numDisp)
  813. {
  814. var fontColor = mxUtils.getValue(this.style, mxRackRackCabinet3.prototype.cst.TEXT_COLOR, '#666666');
  815. var startUnit = mxUtils.getValue(this.style, 'startUnit', 1);
  816. c.setFontSize(fontSize);
  817. c.setFontColor(fontColor);
  818. if (numDisp === mxRackRackCabinet3.prototype.cst.DIR_ASC)
  819. {
  820. for (var i = 0; i < unitNum; i++)
  821. {
  822. c.text(-fontSize, 21 + unitH * 0.5 + i * unitH, 0, 0, (i + startUnit).toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  823. };
  824. }
  825. else if (numDisp === mxRackRackCabinet3.prototype.cst.DIR_DESC || numDisp === mxRackRackCabinet3.prototype.cst.DIR_ON)
  826. {
  827. for (var i = 0; i < unitNum; i++)
  828. {
  829. c.text(-fontSize, h - 21 - unitH * 0.5 - i * unitH, 0, 0, (i + startUnit).toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  830. };
  831. };
  832. c.setStrokeColor(fontColor);
  833. c.begin();
  834. for (var i = 0; i < unitNum + 1; i++)
  835. {
  836. c.moveTo(-2 * fontSize, 21 + i * unitH);
  837. c.lineTo(0, 21 + i * unitH);
  838. };
  839. c.stroke();
  840. };
  841. //**********************************************************************************************************************************************************
  842. //1U Horizontal Cable Duct
  843. //**********************************************************************************************************************************************************
  844. /**
  845. * Extends mxShape.
  846. */
  847. function mxRackHorCableDuct1U(bounds, fill, stroke, strokewidth)
  848. {
  849. mxShape.call(this);
  850. this.bounds = bounds;
  851. this.fill = fill;
  852. this.stroke = stroke;
  853. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  854. };
  855. /**
  856. * Extends mxShape.
  857. */
  858. mxUtils.extend(mxRackHorCableDuct1U, mxShape);
  859. mxRackHorCableDuct1U.prototype.cst =
  860. {
  861. SHAPE_RACK_HOR_CABLE_DUCT_1U : 'mxgraph.rackGeneral.horCableDuct1U'
  862. };
  863. /**
  864. * Function: paintVertexShape
  865. *
  866. * Paints the vertex shape.
  867. */
  868. mxRackHorCableDuct1U.prototype.paintVertexShape = function(c, x, y, w, h)
  869. {
  870. c.translate(x, y);
  871. this.background(c, w, h);
  872. c.setShadow(false);
  873. this.foreground(c, w, h);
  874. };
  875. mxRackHorCableDuct1U.prototype.background = function(c, w, h)
  876. {
  877. c.rect(0, 0, 160.9, 14.8);
  878. c.fillAndStroke();
  879. };
  880. mxRackHorCableDuct1U.prototype.foreground = function(c, w, h)
  881. {
  882. c.rect(12, 0, 3, 7);
  883. c.stroke();
  884. c.rect(12, 7, 3, 7.8);
  885. c.stroke();
  886. c.rect(45.5, 0, 3, 7);
  887. c.stroke();
  888. c.rect(45.5, 7, 3, 7.8);
  889. c.stroke();
  890. c.rect(79, 0, 3, 7);
  891. c.stroke();
  892. c.rect(79, 7, 3, 7.8);
  893. c.stroke();
  894. c.rect(112.5, 0, 3, 7);
  895. c.stroke();
  896. c.rect(112.5, 7, 3, 7.8);
  897. c.stroke();
  898. c.rect(146, 0, 3, 7);
  899. c.stroke();
  900. c.rect(146, 7, 3, 7.8);
  901. c.stroke();
  902. };
  903. //**********************************************************************************************************************************************************
  904. //2U Horizontal Cable Duct
  905. //**********************************************************************************************************************************************************
  906. /**
  907. * Extends mxShape.
  908. */
  909. function mxRackHorCableDuct2U(bounds, fill, stroke, strokewidth)
  910. {
  911. mxShape.call(this);
  912. this.bounds = bounds;
  913. this.fill = fill;
  914. this.stroke = stroke;
  915. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  916. };
  917. /**
  918. * Extends mxShape.
  919. */
  920. mxUtils.extend(mxRackHorCableDuct2U, mxShape);
  921. mxRackHorCableDuct2U.prototype.cst =
  922. {
  923. SHAPE_RACK_HOR_CABLE_DUCT_2U : 'mxgraph.rackGeneral.horCableDuct2U'
  924. };
  925. /**
  926. * Function: paintVertexShape
  927. *
  928. * Paints the vertex shape.
  929. */
  930. mxRackHorCableDuct2U.prototype.paintVertexShape = function(c, x, y, w, h)
  931. {
  932. c.translate(x, y);
  933. this.background(c, w, h);
  934. c.setShadow(false);
  935. this.foreground(c, w, h);
  936. };
  937. mxRackHorCableDuct2U.prototype.background = function(c, w, h)
  938. {
  939. c.rect(0, 0, 160.9, 29.6);
  940. c.fillAndStroke();
  941. };
  942. mxRackHorCableDuct2U.prototype.foreground = function(c, w, h)
  943. {
  944. c.rect(12, 0, 3, 7);
  945. c.stroke();
  946. c.rect(12, 7, 3, 22.6);
  947. c.stroke();
  948. c.rect(45.5, 0, 3, 7);
  949. c.stroke();
  950. c.rect(45.5, 7, 3, 22.6);
  951. c.stroke();
  952. c.rect(79, 0, 3, 7);
  953. c.stroke();
  954. c.rect(79, 7, 3, 22.6);
  955. c.stroke();
  956. c.rect(112.5, 0, 3, 7);
  957. c.stroke();
  958. c.rect(112.5, 7, 3, 22.6);
  959. c.stroke();
  960. c.rect(146, 0, 3, 7);
  961. c.stroke();
  962. c.rect(146, 7, 3, 22.6);
  963. c.stroke();
  964. };
  965. //**********************************************************************************************************************************************************
  966. //1U Cable Routing Bank
  967. //**********************************************************************************************************************************************************
  968. /**
  969. * Extends mxShape.
  970. */
  971. function mxRackHorRoutingBank1U(bounds, fill, stroke, strokewidth)
  972. {
  973. mxShape.call(this);
  974. this.bounds = bounds;
  975. this.fill = fill;
  976. this.stroke = stroke;
  977. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  978. };
  979. /**
  980. * Extends mxShape.
  981. */
  982. mxUtils.extend(mxRackHorRoutingBank1U, mxShape);
  983. mxRackHorRoutingBank1U.prototype.cst =
  984. {
  985. SHAPE_RACK_HOR_ROUTING_BANK_1U : 'mxgraph.rackGeneral.horRoutingBank1U'
  986. };
  987. /**
  988. * Function: paintVertexShape
  989. *
  990. * Paints the vertex shape.
  991. */
  992. mxRackHorRoutingBank1U.prototype.paintVertexShape = function(c, x, y, w, h)
  993. {
  994. c.translate(x, y);
  995. this.background(c, w, h);
  996. c.setShadow(false);
  997. this.foreground(c, w, h);
  998. };
  999. mxRackHorRoutingBank1U.prototype.background = function(c, w, h)
  1000. {
  1001. c.rect(0, 0, 160.9, 14.8);
  1002. c.fillAndStroke();
  1003. };
  1004. mxRackHorRoutingBank1U.prototype.foreground = function(c, w, h)
  1005. {
  1006. c.rect(10, 4, 17, 6.8);
  1007. c.stroke();
  1008. c.rect(31, 4, 17, 6.8);
  1009. c.stroke();
  1010. c.rect(52, 4, 17, 6.8);
  1011. c.stroke();
  1012. c.rect(73, 4, 17, 6.8);
  1013. c.stroke();
  1014. c.rect(94, 4, 17, 6.8);
  1015. c.stroke();
  1016. c.rect(115, 4, 17, 6.8);
  1017. c.stroke();
  1018. c.rect(136, 4, 17, 6.8);
  1019. c.stroke();
  1020. };
  1021. //**********************************************************************************************************************************************************
  1022. //2U Cable Routing Bank
  1023. //**********************************************************************************************************************************************************
  1024. /**
  1025. * Extends mxShape.
  1026. */
  1027. function mxRackHorRoutingBank2U(bounds, fill, stroke, strokewidth)
  1028. {
  1029. mxShape.call(this);
  1030. this.bounds = bounds;
  1031. this.fill = fill;
  1032. this.stroke = stroke;
  1033. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1034. };
  1035. /**
  1036. * Extends mxShape.
  1037. */
  1038. mxUtils.extend(mxRackHorRoutingBank2U, mxShape);
  1039. mxRackHorRoutingBank2U.prototype.cst =
  1040. {
  1041. SHAPE_RACK_HOR_ROUTING_BANK_2U : 'mxgraph.rackGeneral.horRoutingBank2U'
  1042. };
  1043. /**
  1044. * Function: paintVertexShape
  1045. *
  1046. * Paints the vertex shape.
  1047. */
  1048. mxRackHorRoutingBank2U.prototype.paintVertexShape = function(c, x, y, w, h)
  1049. {
  1050. c.translate(x, y);
  1051. this.background(c, w, h);
  1052. c.setShadow(false);
  1053. this.foreground(c, w, h);
  1054. };
  1055. mxRackHorRoutingBank2U.prototype.background = function(c, w, h)
  1056. {
  1057. c.rect(0, 0, 160.9, 29.6);
  1058. c.fillAndStroke();
  1059. };
  1060. mxRackHorRoutingBank2U.prototype.foreground = function(c, w, h)
  1061. {
  1062. c.rect(10, 4, 17, 6.8);
  1063. c.stroke();
  1064. c.rect(31, 4, 17, 6.8);
  1065. c.stroke();
  1066. c.rect(52, 4, 17, 6.8);
  1067. c.stroke();
  1068. c.rect(73, 4, 17, 6.8);
  1069. c.stroke();
  1070. c.rect(94, 4, 17, 6.8);
  1071. c.stroke();
  1072. c.rect(115, 4, 17, 6.8);
  1073. c.stroke();
  1074. c.rect(136, 4, 17, 6.8);
  1075. c.stroke();
  1076. c.rect(10, 18.8, 17, 6.8);
  1077. c.stroke();
  1078. c.rect(31, 18.8, 17, 6.8);
  1079. c.stroke();
  1080. c.rect(52, 18.8, 17, 6.8);
  1081. c.stroke();
  1082. c.rect(73, 18.8, 17, 6.8);
  1083. c.stroke();
  1084. c.rect(94, 18.8, 17, 6.8);
  1085. c.stroke();
  1086. c.rect(115, 18.8, 17, 6.8);
  1087. c.stroke();
  1088. c.rect(136, 18.8, 17, 6.8);
  1089. c.stroke();
  1090. };
  1091. //**********************************************************************************************************************************************************
  1092. //2U Neat-Patch
  1093. //**********************************************************************************************************************************************************
  1094. /**
  1095. * Extends mxShape.
  1096. */
  1097. function mxRackNeatPatch2U(bounds, fill, stroke, strokewidth)
  1098. {
  1099. mxShape.call(this);
  1100. this.bounds = bounds;
  1101. this.fill = fill;
  1102. this.stroke = stroke;
  1103. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1104. };
  1105. /**
  1106. * Extends mxShape.
  1107. */
  1108. mxUtils.extend(mxRackNeatPatch2U, mxShape);
  1109. mxRackNeatPatch2U.prototype.cst =
  1110. {
  1111. SHAPE_RACK_NEAT_PATCH_2U : 'mxgraph.rackGeneral.neatPatch2U'
  1112. };
  1113. /**
  1114. * Function: paintVertexShape
  1115. *
  1116. * Paints the vertex shape.
  1117. */
  1118. mxRackNeatPatch2U.prototype.paintVertexShape = function(c, x, y, w, h)
  1119. {
  1120. c.translate(x, y);
  1121. this.background(c, w, h);
  1122. c.setShadow(false);
  1123. this.mainText(c, w, h);
  1124. };
  1125. mxRackNeatPatch2U.prototype.background = function(c, w, h)
  1126. {
  1127. c.setFillColor('#666666');
  1128. c.rect(0, 0, 160.9, 29.6);
  1129. c.fillAndStroke();
  1130. };
  1131. mxRackNeatPatch2U.prototype.mainText = function(c, w, h)
  1132. {
  1133. c.setFontSize('12');
  1134. c.setFontColor('#ffffff');
  1135. c.setFontStyle(mxConstants.FONT_BOLD);
  1136. c.text(80.45, 24, 0, 0, 'NEAT-PATCH', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1137. };
  1138. //**********************************************************************************************************************************************************
  1139. //1U shelf
  1140. //**********************************************************************************************************************************************************
  1141. /**
  1142. * Extends mxShape.
  1143. */
  1144. function mxRackShelf1U(bounds, fill, stroke, strokewidth)
  1145. {
  1146. mxShape.call(this);
  1147. this.bounds = bounds;
  1148. this.fill = fill;
  1149. this.stroke = stroke;
  1150. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1151. };
  1152. /**
  1153. * Extends mxShape.
  1154. */
  1155. mxUtils.extend(mxRackShelf1U, mxShape);
  1156. mxRackShelf1U.prototype.cst =
  1157. {
  1158. SHAPE_RACK_SHELF_1U : 'mxgraph.rackGeneral.shelf1U'
  1159. };
  1160. /**
  1161. * Function: paintVertexShape
  1162. *
  1163. * Paints the vertex shape.
  1164. */
  1165. mxRackShelf1U.prototype.paintVertexShape = function(c, x, y, w, h)
  1166. {
  1167. c.translate(x, y);
  1168. this.background(c, w, h);
  1169. };
  1170. mxRackShelf1U.prototype.background = function(c, w, h)
  1171. {
  1172. c.setStrokeWidth(2);
  1173. c.begin();
  1174. c.moveTo(0, 0);
  1175. c.lineTo(0, 14.8);
  1176. c.lineTo(160.9, 14.8);
  1177. c.lineTo(160.9, 0);
  1178. c.fillAndStroke();
  1179. };
  1180. //**********************************************************************************************************************************************************
  1181. //2U shelf
  1182. //**********************************************************************************************************************************************************
  1183. /**
  1184. * Extends mxShape.
  1185. */
  1186. function mxRackShelf2U(bounds, fill, stroke, strokewidth)
  1187. {
  1188. mxShape.call(this);
  1189. this.bounds = bounds;
  1190. this.fill = fill;
  1191. this.stroke = stroke;
  1192. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1193. };
  1194. /**
  1195. * Extends mxShape.
  1196. */
  1197. mxUtils.extend(mxRackShelf2U, mxShape);
  1198. mxRackShelf2U.prototype.cst =
  1199. {
  1200. SHAPE_RACK_SHELF_2U : 'mxgraph.rackGeneral.shelf2U'
  1201. };
  1202. /**
  1203. * Function: paintVertexShape
  1204. *
  1205. * Paints the vertex shape.
  1206. */
  1207. mxRackShelf2U.prototype.paintVertexShape = function(c, x, y, w, h)
  1208. {
  1209. c.translate(x, y);
  1210. this.background(c, w, h);
  1211. };
  1212. mxRackShelf2U.prototype.background = function(c, w, h)
  1213. {
  1214. c.setStrokeWidth(2);
  1215. c.begin();
  1216. c.moveTo(0, 0);
  1217. c.lineTo(0, 29.6);
  1218. c.lineTo(160.9, 29.6);
  1219. c.lineTo(160.9, 0);
  1220. c.fillAndStroke();
  1221. };
  1222. //**********************************************************************************************************************************************************
  1223. //4U shelf
  1224. //**********************************************************************************************************************************************************
  1225. /**
  1226. * Extends mxShape.
  1227. */
  1228. function mxRackShelf4U(bounds, fill, stroke, strokewidth)
  1229. {
  1230. mxShape.call(this);
  1231. this.bounds = bounds;
  1232. this.fill = fill;
  1233. this.stroke = stroke;
  1234. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1235. };
  1236. /**
  1237. * Extends mxShape.
  1238. */
  1239. mxUtils.extend(mxRackShelf4U, mxShape);
  1240. mxRackShelf4U.prototype.cst =
  1241. {
  1242. SHAPE_RACK_SHELF_4U : 'mxgraph.rackGeneral.shelf4U'
  1243. };
  1244. /**
  1245. * Function: paintVertexShape
  1246. *
  1247. * Paints the vertex shape.
  1248. */
  1249. mxRackShelf4U.prototype.paintVertexShape = function(c, x, y, w, h)
  1250. {
  1251. c.translate(x, y);
  1252. this.background(c, w, h);
  1253. };
  1254. mxRackShelf4U.prototype.background = function(c, w, h)
  1255. {
  1256. c.setStrokeWidth(2);
  1257. c.begin();
  1258. c.moveTo(0, 0);
  1259. c.lineTo(0, 59.2);
  1260. c.lineTo(160.9, 59.2);
  1261. c.lineTo(160.9, 0);
  1262. c.fillAndStroke();
  1263. };
  1264. //**********************************************************************************************************************************************************
  1265. //END LEGACY RACKS
  1266. //**********************************************************************************************************************************************************
  1267. //**********************************************************************************************************************************************************
  1268. //Channel Base
  1269. //**********************************************************************************************************************************************************
  1270. /**
  1271. * Extends mxShape.
  1272. */
  1273. function mxRackChannelBase(bounds, fill, stroke, strokewidth)
  1274. {
  1275. mxShape.call(this);
  1276. this.bounds = bounds;
  1277. this.fill = fill;
  1278. this.stroke = stroke;
  1279. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1280. };
  1281. /**
  1282. * Extends mxShape.
  1283. */
  1284. mxUtils.extend(mxRackChannelBase, mxShape);
  1285. mxRackChannelBase.prototype.cst =
  1286. {
  1287. SHAPE_RACK_CHANNEL_BASE : 'mxgraph.rackGeneral.channelBase'
  1288. };
  1289. /**
  1290. * Function: paintVertexShape
  1291. *
  1292. * Paints the vertex shape.
  1293. */
  1294. mxRackChannelBase.prototype.paintVertexShape = function(c, x, y, w, h)
  1295. {
  1296. w = Math.max(w, 20);
  1297. h = Math.max(h, 20);
  1298. c.translate(x, y);
  1299. this.background(c, w, h);
  1300. c.setShadow(false);
  1301. this.foreground(c, w, h);
  1302. };
  1303. mxRackChannelBase.prototype.background = function(c, w, h)
  1304. {
  1305. c.rect(10, h - 15, 5, 15);
  1306. c.fillAndStroke();
  1307. c.rect(w - 15, h - 15, 5, 15);
  1308. c.fillAndStroke();
  1309. c.rect(0, 0, w, h - 5);
  1310. c.fillAndStroke();
  1311. };
  1312. mxRackChannelBase.prototype.foreground = function(c, w, h)
  1313. {
  1314. c.setFillColor('#000000');
  1315. c.rect(10, h - 15, 5, 15);
  1316. c.fillAndStroke();
  1317. c.rect(w - 15, h - 15, 5, 15);
  1318. c.fillAndStroke();
  1319. };
  1320. //**********************************************************************************************************************************************************
  1321. //Cabinet Leg
  1322. //**********************************************************************************************************************************************************
  1323. /**
  1324. * Extends mxShape.
  1325. */
  1326. function mxRackCabinetLeg(bounds, fill, stroke, strokewidth)
  1327. {
  1328. mxShape.call(this);
  1329. this.bounds = bounds;
  1330. this.fill = fill;
  1331. this.stroke = stroke;
  1332. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1333. };
  1334. /**
  1335. * Extends mxShape.
  1336. */
  1337. mxUtils.extend(mxRackCabinetLeg, mxShape);
  1338. mxRackCabinetLeg.prototype.cst =
  1339. {
  1340. SHAPE_RACK_CABINET_LEG : 'mxgraph.rackGeneral.cabinetLeg'
  1341. };
  1342. /**
  1343. * Function: paintVertexShape
  1344. *
  1345. * Paints the vertex shape.
  1346. */
  1347. mxRackCabinetLeg.prototype.paintVertexShape = function(c, x, y, w, h)
  1348. {
  1349. w = Math.max(w, 20);
  1350. h = Math.max(h, 20);
  1351. c.translate(x, y);
  1352. this.background(c, w, h);
  1353. };
  1354. mxRackCabinetLeg.prototype.background = function(c, w, h)
  1355. {
  1356. c.begin();
  1357. c.moveTo(0, h - 10);
  1358. c.lineTo(5, h - 10);
  1359. c.lineTo(5, h - 12);
  1360. c.lineTo(9, h - 12);
  1361. c.lineTo(9, h - 10);
  1362. c.lineTo(w - 10, h - 10);
  1363. c.lineTo(w - 10, 9);
  1364. c.lineTo(w - 12, 9);
  1365. c.lineTo(w - 12, 5);
  1366. c.lineTo(w - 10, 5);
  1367. c.lineTo(w - 10, 0);
  1368. c.lineTo(w, 0);
  1369. c.lineTo(w, h);
  1370. c.lineTo(0, h);
  1371. c.close();
  1372. c.fillAndStroke();
  1373. };
  1374. mxCellRenderer.registerShape(mxRackRackCabinet3.prototype.cst.SHAPE_RACK_RACK_CABINET, mxRackRackCabinet3);
  1375. // New generic unit size implementations
  1376. mxCellRenderer.registerShape(mxRackContainer.prototype.cst.SHAPE_RACK_CONTAINER, mxRackContainer);
  1377. mxCellRenderer.registerShape(mxRackRackCabinet2.prototype.cst.SHAPE_RACK_RACK_CABINET, mxRackRackCabinet2);
  1378. mxCellRenderer.registerShape(mxRackHorCableDuct.prototype.cst.SHAPE_RACK_HOR_CABLE_DUCT, mxRackHorCableDuct);
  1379. mxCellRenderer.registerShape(mxRackHorRoutingBank.prototype.cst.SHAPE_RACK_HOR_ROUTING_BANK, mxRackHorRoutingBank);
  1380. mxCellRenderer.registerShape(mxRackNeatPatch.prototype.cst.SHAPE_RACK_NEAT_PATCH, mxRackNeatPatch);
  1381. mxCellRenderer.registerShape(mxRackShelf.prototype.cst.SHAPE_RACK_SHELF, mxRackShelf);
  1382. mxCellRenderer.registerShape(mxRackPlate.prototype.cst.SHAPE_RACK_PLATE, mxRackPlate);
  1383. // Legacy resizable / fixed unit size implementations
  1384. mxCellRenderer.registerShape(mxRackRackNumbering.prototype.cst.SHAPE_RACK_RACK_NUMBERING, mxRackRackNumbering);
  1385. mxCellRenderer.registerShape(mxRackRackCabinet.prototype.cst.SHAPE_RACK_RACK_CABINET, mxRackRackCabinet);
  1386. mxCellRenderer.registerShape(mxRackHorCableDuct1U.prototype.cst.SHAPE_RACK_HOR_CABLE_DUCT_1U, mxRackHorCableDuct1U);
  1387. mxCellRenderer.registerShape(mxRackHorCableDuct2U.prototype.cst.SHAPE_RACK_HOR_CABLE_DUCT_2U, mxRackHorCableDuct2U);
  1388. mxCellRenderer.registerShape(mxRackHorRoutingBank1U.prototype.cst.SHAPE_RACK_HOR_ROUTING_BANK_1U, mxRackHorRoutingBank1U);
  1389. mxCellRenderer.registerShape(mxRackHorRoutingBank2U.prototype.cst.SHAPE_RACK_HOR_ROUTING_BANK_2U, mxRackHorRoutingBank2U);
  1390. mxCellRenderer.registerShape(mxRackNeatPatch2U.prototype.cst.SHAPE_RACK_NEAT_PATCH_2U, mxRackNeatPatch2U);
  1391. mxCellRenderer.registerShape(mxRackShelf1U.prototype.cst.SHAPE_RACK_SHELF_1U, mxRackShelf1U);
  1392. mxCellRenderer.registerShape(mxRackShelf2U.prototype.cst.SHAPE_RACK_SHELF_2U, mxRackShelf2U);
  1393. mxCellRenderer.registerShape(mxRackShelf4U.prototype.cst.SHAPE_RACK_SHELF_4U, mxRackShelf4U);
  1394. mxCellRenderer.registerShape(mxRackChannelBase.prototype.cst.SHAPE_RACK_CHANNEL_BASE, mxRackChannelBase);
  1395. mxCellRenderer.registerShape(mxRackCabinetLeg.prototype.cst.SHAPE_RACK_CABINET_LEG, mxRackCabinetLeg);