mxRack.js 43 KB

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