clone

a browser-first diagram editor with live svg previews, local drafts and encrypted, accountless sharing

main
diagramzip / renderers / browser-run / frames / diagramsnet / vendor / assets / shapes / rack / mxRack.js
mxRack.js 42.6K
1/**2 * Copyright (c) 2006-2013, JGraph Holdings Ltd3 */4//**********************************************************************************************************************************************************5//Rack Numbering6//**********************************************************************************************************************************************************78//**********************************************************************************************************************************************************9// v2 Rack cabinet, old versions below this10//**********************************************************************************************************************************************************1112//**********************************************************************************************************************************************************13//START LEGACY RACKS14//**********************************************************************************************************************************************************15function mxRackContainer(bounds, fill, stroke, strokewidth)16{17 mxShape.call(this);18 this.bounds = bounds;19 this.fill = fill;20 this.stroke = stroke;21 this.strokewidth = (strokewidth != null) ? strokewidth : 1;22};2324/**25 * Extends mxShape.26 */27mxUtils.extend(mxRackContainer, mxShape);2829mxRackContainer.prototype.unitSize = 20;3031mxRackContainer.prototype.cst = 32{33 SHAPE_RACK_CONTAINER : 'mxgraph.rackGeneral.container',34 TEXT_COLOR : 'textColor',35 NUMBER_DISPLAY : 'numDisp',36 OFF : 'off',37 DIR_ASC : 'ascend',38 DIR_DESC : 'descend'39};4041mxRackContainer.prototype.customProperties = [42 {name: 'fillColor2', dispName: 'Cabinet Color', type: 'color'},43 {name: 'textColor', dispName: 'Numbers Color', type: 'color'},44 {name: 'numDisp', dispName: 'Display Numbers', type: 'enum',45 enumList: [{val: 'off', dispName: 'Off'}, {val: 'ascend', dispName: 'Ascending'}, {val: 'descend', dispName: 'Descending'}],46 onChange: function(graph, newValue)47 {48 graph.setCellStyles('marginLeft', (newValue == 'off') ? 9 : 33, graph.getSelectionCells());49 }50 },51 {name: 'rackUnitSize', dispName: 'Unit size', type: 'int'}52];5354/**55 * Function: paintVertexShape56 * 57 * Paints the vertex shape.58 */59mxRackContainer.prototype.paintVertexShape = function(c, x, y, w, h)60{61 var fontSize = 12;62 var displayNumbers = mxUtils.getValue(this.style, mxRackContainer.prototype.cst.NUMBER_DISPLAY, mxRackContainer.prototype.cst.DIR_ASC);63 var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');64 var fillColor2 = mxUtils.getValue(this.style, 'fillColor2', '#f4f4f4');6566 if (displayNumbers !== mxRackContainer.prototype.cst.OFF)67 {68 c.translate(x + fontSize * 2, y);69 w = Math.max(w - fontSize * 2, 0);70 }71 else72 {73 c.translate(x, y);74 };7576 c.setFillColor(fillColor);77 this.background(c, w, h, fontSize);78 c.setShadow(false);79 c.setFillColor(fillColor2);80 this.foreground(c, w, h, fontSize);8182 if (displayNumbers !== mxRackContainer.prototype.cst.OFF && w > 18 + fontSize * 2)83 {84 this.sideText(c, w, h, fontSize);85 };86};8788mxRackContainer.prototype.background = function(c, w, h, fontSize)89{90 c.rect(0, 0, w, h);91 c.fillAndStroke();92};9394mxRackContainer.prototype.foreground = function(c, w, h, fontSize)95{96 if (w > 18 + fontSize * 2 && h > 42)97 {98 c.rect(0, 0, w, 21);99 c.fillAndStroke();100 c.rect(0, h - 21, w, 21);101 c.fillAndStroke();102 c.rect(0, 21, 9, h - 42);103 c.fillAndStroke();104 c.rect(w - 9, 21, 9, h - 42);105 c.fillAndStroke();106 c.ellipse(2.5, 7.5, 6, 6);107 c.stroke();108 c.ellipse(w - 8.5, 7.5, 6, 6);109 c.stroke();110 c.ellipse(2.5, h - 13.5, 6, 6);111 c.stroke();112 c.ellipse(w - 8.5, h - 13.5, 6, 6);113 c.stroke();114 }115};116117mxRackContainer.prototype.sideText = function(c, w, h, fontSize)118{119 var fontColor = mxUtils.getValue(this.style, mxRackContainer.prototype.cst.TEXT_COLOR, '#666666');120 var displayNumbers = mxUtils.getValue(this.style, mxRackContainer.prototype.cst.NUMBER_DISPLAY, mxRackContainer.prototype.cst.DIR_ASC);121 var unitSize = parseFloat(mxUtils.getValue(this.style, 'rackUnitSize', mxRackContainer.prototype.unitSize));122 this.unitSize = unitSize;123 124 c.setFontSize(fontSize);125 c.setFontColor(fontColor);126127 // Calculate number of units128 var units = Math.floor((Math.abs(h) - 42) / unitSize);129130 for (var i = 0; i < units; i++)131 {132 var displayNumber = (displayNumbers === mxRackContainer.prototype.cst.DIR_DESC) ? (i + 1).toString() : (units - i).toString();133 c.text(-fontSize, 21 + unitSize * 0.5 + i * unitSize, 0, 0, displayNumber, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);134 }135136 c.begin();137138 for (var i = 0; i < units + 1; i++)139 {140 c.moveTo(-2 * fontSize, 21 + i * unitSize);141 c.lineTo(0, 21 + i * unitSize);142 };143144 c.stroke();145};146147/**148* Extends mxShape.149*/150function mxRackPlate(bounds, fill, stroke, strokewidth)151{152 mxShape.call(this);153 this.bounds = bounds;154 this.fill = fill;155 this.stroke = stroke;156 this.strokewidth = 1;157};158159/**160* Extends mxShape.161*/162mxUtils.extend(mxRackPlate, mxShape);163164mxRackPlate.prototype.cst = 165{166 SHAPE_RACK_PLATE : 'mxgraph.rackGeneral.plate'167};168169/**170* Function: paintVertexShape171* 172* Paints the vertex shape.173*/174mxRackPlate.prototype.paintVertexShape = function(c, x, y, w, h)175{176 c.translate(x, y);177 this.background(c, w, h);178 c.setShadow(false);179 this.foreground(c, w, h);180};181182mxRackPlate.prototype.background = function(c, w, h)183{184 c.begin();185 c.rect(0, 0, w, h);186 c.fillAndStroke();187};188189mxRackPlate.prototype.foreground = function(c, w, h)190{191 var bufferSize = 9;192193 if (w > bufferSize * 2)194 {195 c.save();196 c.setFillColor('#000000');197 c.setAlpha(0.23);198 c.rect(0,0, bufferSize, h);199 c.fill();200 c.rect(w - bufferSize,0, bufferSize, h);201 c.fill();202 c.restore();203 c.rect(0, 0, w, h);204 c.stroke();205 c.rect(bufferSize, 0, w - bufferSize * 2, h);206 c.stroke();207 }208};209210//**********************************************************************************************************************************************************211//Horizontal Cable Duct212//**********************************************************************************************************************************************************213/**214* Extends mxShape.215*/216function mxRackHorCableDuct(bounds, fill, stroke, strokewidth)217{218 mxShape.call(this);219 this.bounds = bounds;220 this.fill = fill;221 this.stroke = stroke;222 this.strokewidth = (strokewidth != null) ? strokewidth : 1;223};224225/**226* Extends mxShape.227*/228mxUtils.extend(mxRackHorCableDuct, mxShape);229230mxRackHorCableDuct.prototype.cst = 231{232 SHAPE_RACK_HOR_CABLE_DUCT : 'mxgraph.rackGeneral.horCableDuct'233};234235/**236* Function: paintVertexShape237* 238* Paints the vertex shape.239*/240mxRackHorCableDuct.prototype.paintVertexShape = function(c, x, y, w, h)241{242 c.translate(x, y);243 this.background(c, w, h);244 c.setShadow(false);245 this.foreground(c, w, h);246};247248mxRackHorCableDuct.prototype.background = function(c, w, h)249{250 c.rect(0, 0, w, h);251 c.fillAndStroke();252};253254mxRackHorCableDuct.prototype.foreground = function(c, w, h)255{256 // Divide the space equally with 33 between each duct257 var spaceBuffer = 20;258 var unitSpacing = 33;259 var unitsAcross = Math.floor((w - spaceBuffer) / unitSpacing);260 var buffer = spaceBuffer / 2 + Math.floor(((w - spaceBuffer) - unitsAcross * unitSpacing) / 2);261262 if (unitsAcross > 0)263 {264 for (var i = 0; i <= unitsAcross; i++)265 {266 c.rect(buffer, 0, 3, 7);267 c.stroke();268 c.rect(buffer, 7, 3, 7.8);269 c.stroke();270 271 buffer += unitSpacing;272 }273 }274};275276function mxRackHorRoutingBank(bounds, fill, stroke, strokewidth)277{278 mxShape.call(this);279 this.bounds = bounds;280 this.fill = fill;281 this.stroke = stroke;282 this.strokewidth = (strokewidth != null) ? strokewidth : 1;283};284285/**286* Extends mxShape.287*/288mxUtils.extend(mxRackHorRoutingBank, mxShape);289290mxRackHorRoutingBank.prototype.cst = 291{292 SHAPE_RACK_HOR_ROUTING_BANK : 'mxgraph.rackGeneral.horRoutingBank'293};294295/**296* Function: paintVertexShape297* 298* Paints the vertex shape.299*/300mxRackHorRoutingBank.prototype.paintVertexShape = function(c, x, y, w, h)301{302 c.translate(x, y);303 this.background(c, w, h);304 c.setShadow(false);305 this.foreground(c, w, h);306};307308mxRackHorRoutingBank.prototype.background = function(c, w, h)309{310 c.rect(0, 0, w, h);311 c.fillAndStroke();312};313314mxRackHorRoutingBank.prototype.foreground = function(c, w, h)315{316 // Divide the space equally with 33 between each duct317 var spaceBuffer = 20;318 var unitSpacing = 22;319 var rectWidth = 16;320 var unitsAcross = Math.floor((w - spaceBuffer - rectWidth) / unitSpacing);321 var unitsDown = Math.floor(h / mxRackContainer.unitSize);322323 if (unitsAcross > 0 && unitsDown > 0)324 {325 for (var i = 0; i < unitsDown; i++)326 {327 var buffer = (spaceBuffer + rectWidth) / 2 + Math.floor(((w - spaceBuffer - rectWidth) - unitsAcross * unitSpacing) / 2) - rectWidth / 2;328329 for (var j = 0; j <= unitsAcross; j++)330 {331 c.rect(buffer, 4 + (i * mxRackContainer.unitSize), rectWidth, 6.8);332 c.stroke();333 334 buffer += unitSpacing;335 }336 }337 }338};339340function mxRackNeatPatch(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};348349/**350* Extends mxShape.351*/352mxUtils.extend(mxRackNeatPatch, mxShape);353354mxRackNeatPatch.prototype.cst = 355{356 SHAPE_RACK_NEAT_PATCH : 'mxgraph.rackGeneral.neatPatch'357};358359/**360* Function: paintVertexShape361* 362* Paints the vertex shape.363*/364mxRackNeatPatch.prototype.paintVertexShape = function(c, x, y, w, h)365{366 c.translate(x, y);367 this.background(c, w, h);368 c.setShadow(false);369 this.mainText(c, w, h);370};371372mxRackNeatPatch.prototype.background = function(c, w, h)373{374 c.setFillColor('#666666');375 c.rect(0, 0, w, h);376 c.fillAndStroke();377};378379mxRackNeatPatch.prototype.mainText = function(c, w, h)380{381 c.setFontSize('12');382 c.setFontColor('#ffffff');383 c.setFontStyle(mxConstants.FONT_BOLD);384 c.text(w / 2, h - 6, 0, 0, 'NEAT-PATCH', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);385};386387function mxRackShelf(bounds, fill, stroke, strokewidth)388{389 mxShape.call(this);390 this.bounds = bounds;391 this.fill = fill;392 this.stroke = stroke;393 this.strokewidth = (strokewidth != null) ? strokewidth : 1;394};395396/**397* Extends mxShape.398*/399mxUtils.extend(mxRackShelf, mxShape);400401mxRackShelf.prototype.cst = 402{403 SHAPE_RACK_SHELF : 'mxgraph.rackGeneral.shelf'404};405406/**407* Function: paintVertexShape408* 409* Paints the vertex shape.410*/411mxRackShelf.prototype.paintVertexShape = function(c, x, y, w, h)412{413 c.translate(x, y);414 this.background(c, w, h);415};416417mxRackShelf.prototype.background = function(c, w, h)418{419 c.setStrokeWidth(2);420 c.begin();421 c.moveTo(1, 0);422 c.lineTo(1, h - 1);423 c.lineTo(w - 1, h - 1);424 c.lineTo(w - 1, 1);425 c.fillAndStroke();426};427428function mxRackRackNumbering(bounds, fill, stroke, strokewidth)429{430 mxShape.call(this);431 this.bounds = bounds;432 this.fill = fill;433 this.stroke = stroke;434 this.strokewidth = (strokewidth != null) ? strokewidth : 1;435};436437/**438 * Extends mxShape.439 */440mxUtils.extend(mxRackRackNumbering, mxShape);441442mxRackRackNumbering.prototype.cst = 443{444 SHAPE_RACK_RACK_NUMBERING : 'mxgraph.rackGeneral.rackNumbering',445 UNIT_NUM : 'unitNum',446 UNIT_HEIGHT : 'unitHeight',447 TEXT_COLOR : 'textColor',448 NUM_DIR : 'numDir',449 DIR_ASC : 'ascend',450 DIR_DESC : 'descend',451 TEXT_SIZE : 'textSize'452};453454/**455 * Function: paintVertexShape456 * 457 * Paints the vertex shape.458 */459mxRackRackNumbering.prototype.paintVertexShape = function(c, x, y, w, h)460{461 var unitNum = parseFloat(mxUtils.getValue(this.style, mxRackRackNumbering.prototype.cst.UNIT_NUM, '42'));462 var unitH = parseFloat(mxUtils.getValue(this.style, mxRackRackNumbering.prototype.cst.UNIT_HEIGHT, '14.8'));463 var fontSize = parseFloat(mxUtils.getValue(this.style, mxRackRackNumbering.prototype.cst.TEXT_SIZE, '12'));464 c.translate(x, y);465466 var h = unitNum * unitH;467 this.background(c, w, h, fontSize);468 c.setShadow(false);469 this.sideText(c, w, h, unitNum, unitH, fontSize);470};471472mxRackRackNumbering.prototype.background = function(c, w, h, fontSize)473{474 c.rect(fontSize * 3, 0, 160.9, h);475 c.fillAndStroke();476};477478mxRackRackNumbering.prototype.sideText = function(c, w, h, unitNum, unitH, fontSize)479{480 var fontColor = mxUtils.getValue(this.style, mxRackRackNumbering.prototype.cst.TEXT_COLOR, '#666666');481 var numDir = mxUtils.getValue(this.style, mxRackRackNumbering.prototype.cst.NUM_DIR, mxRackRackNumbering.prototype.cst.DIR_DESC);482 c.setFontSize(fontSize);483 c.setFontColor(fontColor);484485 if (numDir === mxRackRackNumbering.prototype.cst.DIR_ASC)486 {487 for (var i = 0; i < unitNum; i++)488 {489 c.text(fontSize, unitH * 0.5 + i * unitH, 0, 0, (i + 1).toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);490 };491 }492 else493 {494 for (var i = 0; i < unitNum; i++)495 {496 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);497 };498 };499500 c.setStrokeColor('#dddddd');501502 c.begin();503504 for (var i = 0; i < unitNum + 1; i++)505 {506 c.moveTo(0, i * unitH);507 c.lineTo(fontSize * 3, i * unitH);508 };509510 c.stroke();511};512513//**********************************************************************************************************************************************************514//Rack Cabinet515//**********************************************************************************************************************************************************516/**517 * Extends mxShape.518 */519function mxRackRackCabinet(bounds, fill, stroke, strokewidth)520{521 mxShape.call(this);522 this.bounds = bounds;523 this.fill = fill;524 this.stroke = stroke;525 this.strokewidth = (strokewidth != null) ? strokewidth : 1;526};527528/**529 * Extends mxShape.530 */531mxUtils.extend(mxRackRackCabinet, mxShape);532533mxRackRackCabinet.prototype.cst = 534{535 SHAPE_RACK_RACK_CABINET : 'mxgraph.rackGeneral.rackCabinet',536 UNIT_NUM : 'unitNum',537 UNIT_HEIGHT : 'unitHeight',538 TEXT_COLOR : 'textColor',539 NUM_DIR : 'numDir',540 NUMBER_DISPLAY : 'numDisp',541 ON : 'on',542 OFF : 'off',543 DIR_ASC : 'ascend',544 DIR_DESC : 'descend',545 TEXT_SIZE : 'textSize'546};547548mxRackRackCabinet.prototype.customProperties = [549 {name: 'unitNum', dispName: 'Number of units', type: 'int', defVal: 12},550 {name: 'startUnit', dispName: 'Starting unit', type: 'int', defVal: 1},551 {name: 'unitHeight', dispName: 'Unit height', type: 'float', defVal: 14.8},552 {name: 'textColor', dispName: 'Number text color', type: 'color', defVal: '#666666'},553 {name: 'textSize', dispName: 'Text size', type: 'float', defVal: '12'},554 {name: 'numDisp', dispName: 'Display Numbers', type: 'enum', defVal: 'descend',555 enumList: [{val: 'off', dispName: 'Off'}, {val: 'ascend', dispName: 'Ascending'}, {val: 'descend', dispName: 'Descending'}],556 onChange: function(graph, newValue)557 {558 graph.setCellStyles('marginLeft', (newValue == 'off') ? 9 : 33, graph.getSelectionCells());559 }560 }561];562563564/**565 * Function: paintVertexShape566 * 567 * Paints the vertex shape.568 */569mxRackRackCabinet.prototype.paintVertexShape = function(c, x, y, w, h)570{571 var unitNum = parseFloat(mxUtils.getValue(this.style, mxRackRackCabinet.prototype.cst.UNIT_NUM, '12'));572 var unitH = parseFloat(mxUtils.getValue(this.style, mxRackRackCabinet.prototype.cst.UNIT_HEIGHT, '14.8'));573 var fontSize = parseFloat(mxUtils.getValue(this.style, mxRackRackCabinet.prototype.cst.TEXT_SIZE, '12'));574 var numDisp = mxUtils.getValue(this.style, mxRackRackCabinet.prototype.cst.NUMBER_DISPLAY, mxRackRackCabinet.prototype.cst.ON);575576 if (numDisp !== mxRackRackCabinet.prototype.cst.OFF)577 {578 c.translate(x + fontSize * 2, y);579 }580 else581 {582 c.translate(x, y);583 };584585 var h = unitNum * unitH + 42;586 this.background(c, h);587 c.setShadow(false);588 this.foreground(c, h);589590 if (numDisp !== mxRackRackCabinet.prototype.cst.OFF)591 {592 this.sideText(c, h, unitNum, unitH, fontSize, numDisp);593 };594};595596mxRackRackCabinet.prototype.background = function(c, h)597{598 c.setFillColor('#ffffff');599 c.rect(0, 0, 180, h);600 c.fillAndStroke();601};602603mxRackRackCabinet.prototype.foreground = function(c, h)604{605 c.setFillColor('#f4f4f4');606 c.rect(0, 0, 180, 21);607 c.fillAndStroke();608 c.rect(0, h - 21, 180, 21);609 c.fillAndStroke();610 c.rect(0, 21, 9, h - 42);611 c.fillAndStroke();612 c.rect(171, 21, 9, h - 42);613 c.fillAndStroke();614 c.ellipse(2.5, 7.5, 6, 6);615 c.stroke();616 c.ellipse(171.5, 7.5, 6, 6);617 c.stroke();618 c.ellipse(2.5, h - 13.5, 6, 6);619 c.stroke();620 c.ellipse(171.5, h - 13.5, 6, 6);621 c.stroke();622};623624mxRackRackCabinet.prototype.sideText = function(c, h, unitNum, unitH, fontSize, numDisp)625{626 var fontColor = mxUtils.getValue(this.style, mxRackRackCabinet.prototype.cst.TEXT_COLOR, '#666666');627 var startUnit = mxUtils.getValue(this.style, 'startUnit', 1);628 c.setFontSize(fontSize);629 c.setFontColor(fontColor);630631 if (numDisp === mxRackRackCabinet.prototype.cst.DIR_ASC)632 {633 for (var i = 0; i < unitNum; i++)634 {635 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);636 };637 }638 else if (numDisp === mxRackRackCabinet.prototype.cst.DIR_DESC || numDisp === mxRackRackCabinet.prototype.cst.DIR_ON)639 {640 for (var i = 0; i < unitNum; i++)641 {642 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);643 };644 };645646 c.setStrokeColor(fontColor);647648 c.begin();649650 for (var i = 0; i < unitNum + 1; i++)651 {652 c.moveTo(-2 * fontSize, 21 + i * unitH);653 c.lineTo(0, 21 + i * unitH);654 };655656 c.stroke();657};658659//**********************************************************************************************************************************************************660//Rack Cabinet v2661//**********************************************************************************************************************************************************662/**663 * Extends mxShape.664 */665function mxRackRackCabinet2(bounds, fill, stroke, strokewidth)666{667 mxShape.call(this);668 this.bounds = bounds;669 this.fill = fill;670 this.stroke = stroke;671 this.strokewidth = (strokewidth != null) ? strokewidth : 1;672};673674/**675 * Extends mxShape.676 */677mxUtils.extend(mxRackRackCabinet2, mxShape);678679mxRackRackCabinet2.prototype.cst = 680{681 SHAPE_RACK_RACK_CABINET : 'mxgraph.rackGeneral.rackCabinet2',682 UNIT_NUM : 'unitNum',683 UNIT_HEIGHT : 'rackUnitSize',684 TEXT_COLOR : 'textColor',685 NUM_DIR : 'numDir',686 NUMBER_DISPLAY : 'numDisp',687 ON : 'on',688 OFF : 'off',689 DIR_ASC : 'ascend',690 DIR_DESC : 'descend',691 TEXT_SIZE : 'textSize'692};693694mxRackRackCabinet2.prototype.customProperties = [695 {name: 'unitNum', dispName: 'Number of units', type: 'int', defVal: 12},696 {name: 'startUnit', dispName: 'Starting unit', type: 'int', defVal: 1},697 {name: 'rackUnitSize', dispName: 'Unit height', type: 'float', defVal: 14.8},698 {name: 'fillColor2', dispName: 'Panel Color', type: 'color', defVal: '#ffffff'},699 {name: 'textColor', dispName: 'Number text color', type: 'color', defVal: '#666666'},700 {name: 'textSize', dispName: 'Text size', type: 'float', defVal: '12'},701 {name: 'numDisp', dispName: 'Display Numbers', type: 'enum', defVal: 'descend',702 enumList: [{val: 'off', dispName: 'Off'}, {val: 'ascend', dispName: 'Ascending'}, {val: 'descend', dispName: 'Descending'}],703 onChange: function(graph, newValue)704 {705 graph.setCellStyles('marginLeft', (newValue == 'off') ? 9 : 33, graph.getSelectionCells());706 }707 }708];709710711/**712 * Function: paintVertexShape713 * 714 * Paints the vertex shape.715 */716mxRackRackCabinet2.prototype.paintVertexShape = function(c, x, y, w, h)717{718 var unitNum = parseFloat(mxUtils.getValue(this.style, mxRackRackCabinet2.prototype.cst.UNIT_NUM, '12'));719 var unitH = parseFloat(mxUtils.getValue(this.style, mxRackRackCabinet2.prototype.cst.UNIT_HEIGHT, '14.8'));720 var fontSize = parseFloat(mxUtils.getValue(this.style, mxRackRackCabinet2.prototype.cst.TEXT_SIZE, '12'));721 var numDisp = mxUtils.getValue(this.style, mxRackRackCabinet2.prototype.cst.NUMBER_DISPLAY, mxRackRackCabinet2.prototype.cst.ON);722723 if (numDisp !== mxRackRackCabinet2.prototype.cst.OFF)724 {725 c.translate(x + fontSize * 2, y);726 w = w - fontSize * 2;727 }728 else729 {730 c.translate(x, y);731 };732733 var h = unitNum * unitH + 42;734 this.background(c, w, h);735 c.setShadow(false);736 this.foreground(c, w, h);737738 if (numDisp !== mxRackRackCabinet2.prototype.cst.OFF)739 {740 this.sideText(c, h, unitNum, unitH, fontSize, numDisp);741 };742};743744mxRackRackCabinet2.prototype.background = function(c, w, h)745{746 var fillC = mxUtils.getValue(this.style, 'fillColor2', '#ffffff');747 c.setFillColor(fillC);748 c.rect(0, 0, w, h);749 c.fillAndStroke();750};751752mxRackRackCabinet2.prototype.foreground = function(c, w, h)753{754 var fillC = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#f4f4f4');755 c.setFillColor(fillC);756 c.rect(0, 0, w, 21);757 c.fillAndStroke();758 c.rect(0, h - 21, w, 21);759 c.fillAndStroke();760 c.rect(0, 21, 9, h - 42);761 c.fillAndStroke();762 c.rect(w - 9, 21, 9, h - 42);763 c.fillAndStroke();764 c.ellipse(2.5, 7.5, 6, 6);765 c.stroke();766 c.ellipse(w - 8.5, 7.5, 6, 6);767 c.stroke();768 c.ellipse(2.5, h - 13.5, 6, 6);769 c.stroke();770 c.ellipse(w - 8.5, h - 13.5, 6, 6);771 c.stroke();772};773774mxRackRackCabinet2.prototype.sideText = function(c, h, unitNum, unitH, fontSize, numDisp)775{776 var fontColor = mxUtils.getValue(this.style, mxRackRackCabinet2.prototype.cst.TEXT_COLOR, '#666666');777 var startUnit = mxUtils.getValue(this.style, 'startUnit', 1);778 c.setFontSize(fontSize);779 c.setFontColor(fontColor);780781 if (numDisp === mxRackRackCabinet2.prototype.cst.DIR_ASC)782 {783 for (var i = 0; i < unitNum; i++)784 {785 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);786 };787 }788 else if (numDisp === mxRackRackCabinet2.prototype.cst.DIR_DESC || numDisp === mxRackRackCabinet2.prototype.cst.DIR_ON)789 {790 for (var i = 0; i < unitNum; i++)791 {792 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);793 };794 };795796 c.setStrokeColor(fontColor);797798 c.begin();799800 for (var i = 0; i < unitNum + 1; i++)801 {802 c.moveTo(-2 * fontSize, 21 + i * unitH);803 c.lineTo(0, 21 + i * unitH);804 };805806 c.stroke();807};808809//**********************************************************************************************************************************************************810//Rack Cabinet v3811//**********************************************************************************************************************************************************812/**813 * Extends mxShape.814 */815function mxRackRackCabinet3(bounds, fill, stroke, strokewidth)816{817 mxShape.call(this);818 this.bounds = bounds;819 this.fill = fill;820 this.stroke = stroke;821 this.strokewidth = (strokewidth != null) ? strokewidth : 1;822};823824/**825 * Extends mxShape.826 */827mxUtils.extend(mxRackRackCabinet3, mxShape);828829mxRackRackCabinet3.prototype.cst = 830{831 SHAPE_RACK_RACK_CABINET : 'mxgraph.rackGeneral.rackCabinet3',832 UNIT_NUM : 'unitNum',833 UNIT_HEIGHT : 'rackUnitSize',834 UNIT_DIR_LEFT : 'rackUnitDirLeft',835 TEXT_COLOR : 'textColor',836 NUM_DIR : 'numDir',837 NUMBER_DISPLAY : 'numDisp',838 ON : 'on',839 OFF : 'off',840 DIR_ASC : 'ascend',841 DIR_DESC : 'descend',842 TEXT_SIZE : 'textSize'843};844845mxRackRackCabinet3.prototype.customProperties = [846 {name: 'startUnit', dispName: 'Starting unit', type: 'int', defVal: 1},847 {name: 'rackUnitDirLeft', dispName: 'Numbering on left', type: 'boolean', defVal: true},848 {name: 'rackUnitSize', dispName: 'Unit height', type: 'float', defVal: 14.8},849 {name: 'fillColor2', dispName: 'Panel Color', type: 'color', defVal: '#ffffff', primary: true},850 {name: 'textColor', dispName: 'Number text color', type: 'color', defVal: '#666666', primary: true},851 {name: 'textSize', dispName: 'Text size', type: 'float', defVal: '12'},852 {name: 'numDisp', dispName: 'Display Numbers', type: 'enum', defVal: 'descend',853 enumList: [{val: 'off', dispName: 'Off'}, {val: 'ascend', dispName: 'Ascending'}, {val: 'descend', dispName: 'Descending'}],854 onChange: function(graph, newValue)855 {856 graph.setCellStyles('marginLeft', (newValue == 'off') ? 9 : 33, graph.getSelectionCells());857 }858 }859];860861862/**863 * Function: paintVertexShape864 * 865 * Paints the vertex shape.866 */867mxRackRackCabinet3.prototype.paintVertexShape = function(c, x, y, w, h)868{869 var unitH = parseFloat(mxUtils.getValue(this.style, mxRackRackCabinet3.prototype.cst.UNIT_HEIGHT, '14.8'));870 var unitNum = Math.round((h - 42) / unitH);871 var fontSize = parseFloat(mxUtils.getValue(this.style, mxRackRackCabinet3.prototype.cst.TEXT_SIZE, '12'));872 var numDisp = mxUtils.getValue(this.style, mxRackRackCabinet3.prototype.cst.NUMBER_DISPLAY, mxRackRackCabinet3.prototype.cst.ON);873 var unitDirLeft = mxUtils.getValue(this.style, mxRackRackCabinet3.prototype.cst.UNIT_DIR_LEFT, true);874875 if (numDisp !== mxRackRackCabinet3.prototype.cst.OFF)876 {877 if (unitDirLeft)878 { // numbering on left879 c.translate(x + fontSize * 2, y);880 }881 else882 { // numbering on right883 c.translate(x, y);884 }885886 w = w - fontSize * 2;887 }888 else889 {890 c.translate(x, y);891 };892893 var h = unitNum * unitH + 42;894 this.background(c, w, h);895 c.setShadow(false);896 this.foreground(c, w, h);897898 if (numDisp !== mxRackRackCabinet3.prototype.cst.OFF)899 {900 this.sideText(c, h, w, unitNum, unitH, fontSize, numDisp, unitDirLeft);901 };902};903904mxRackRackCabinet3.prototype.background = function(c, w, h)905{906 var fillC = mxUtils.getValue(this.style, 'fillColor2', '#ffffff');907 c.setFillColor(fillC);908 c.rect(0, 0, w, h);909 c.fillAndStroke();910};911912mxRackRackCabinet3.prototype.foreground = function(c, w, h)913{914 var fillC = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#f4f4f4');915 c.setFillColor(fillC);916 c.rect(0, 0, w, 21);917 c.fillAndStroke();918 c.rect(0, h - 21, w, 21);919 c.fillAndStroke();920 c.rect(0, 21, 9, h - 42);921 c.fillAndStroke();922 c.rect(w - 9, 21, 9, h - 42);923 c.fillAndStroke();924 c.ellipse(2.5, 7.5, 6, 6);925 c.stroke();926 c.ellipse(w - 8.5, 7.5, 6, 6);927 c.stroke();928 c.ellipse(2.5, h - 13.5, 6, 6);929 c.stroke();930 c.ellipse(w - 8.5, h - 13.5, 6, 6);931 c.stroke();932};933934mxRackRackCabinet3.prototype.sideText = function(c, h, w, unitNum, unitH, fontSize, numDisp, unitDirLeft)935{936 var fontColor = mxUtils.getValue(this.style, mxRackRackCabinet3.prototype.cst.TEXT_COLOR, '#666666');937 var startUnit = mxUtils.getValue(this.style, 'startUnit', 1);938 c.setFontSize(fontSize);939 c.setFontColor(fontColor);940 var x = 0;941 if (!unitDirLeft)942 {943 x = w + 2 * fontSize;944 }945946 if (numDisp === mxRackRackCabinet3.prototype.cst.DIR_ASC)947 {948 for (var i = 0; i < unitNum; i++)949 {950 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);951 };952 }953 else if (numDisp === mxRackRackCabinet3.prototype.cst.DIR_DESC || numDisp === mxRackRackCabinet3.prototype.cst.DIR_ON)954 {955 for (var i = 0; i < unitNum; i++)956 {957 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);958 };959 };960961 c.setStrokeColor(fontColor);962963 c.begin();964965 for (var i = 0; i < unitNum + 1; i++)966 {967 c.moveTo(x - 2 * fontSize, 21 + i * unitH);968 c.lineTo(x, 21 + i * unitH);969 };970971 c.stroke();972};973974//**********************************************************************************************************************************************************975//1U Horizontal Cable Duct976//**********************************************************************************************************************************************************977/**978* Extends mxShape.979*/980function mxRackHorCableDuct1U(bounds, fill, stroke, strokewidth)981{982 mxShape.call(this);983 this.bounds = bounds;984 this.fill = fill;985 this.stroke = stroke;986 this.strokewidth = (strokewidth != null) ? strokewidth : 1;987};988989/**990* Extends mxShape.991*/992mxUtils.extend(mxRackHorCableDuct1U, mxShape);993994mxRackHorCableDuct1U.prototype.cst = 995{996 SHAPE_RACK_HOR_CABLE_DUCT_1U : 'mxgraph.rackGeneral.horCableDuct1U'997};998999/**1000* Function: paintVertexShape1001* 1002* Paints the vertex shape.1003*/1004mxRackHorCableDuct1U.prototype.paintVertexShape = function(c, x, y, w, h)1005{1006 c.translate(x, y);1007 this.background(c, w, h);1008 c.setShadow(false);1009 this.foreground(c, w, h);1010};10111012mxRackHorCableDuct1U.prototype.background = function(c, w, h)1013{1014 c.rect(0, 0, 160.9, 14.8);1015 c.fillAndStroke();1016};10171018mxRackHorCableDuct1U.prototype.foreground = function(c, w, h)1019{1020 c.rect(12, 0, 3, 7);1021 c.stroke();1022 c.rect(12, 7, 3, 7.8);1023 c.stroke();10241025 c.rect(45.5, 0, 3, 7);1026 c.stroke();1027 c.rect(45.5, 7, 3, 7.8);1028 c.stroke();1029 1030 c.rect(79, 0, 3, 7);1031 c.stroke();1032 c.rect(79, 7, 3, 7.8);1033 c.stroke();1034 1035 c.rect(112.5, 0, 3, 7);1036 c.stroke();1037 c.rect(112.5, 7, 3, 7.8);1038 c.stroke();1039 1040 c.rect(146, 0, 3, 7);1041 c.stroke();1042 c.rect(146, 7, 3, 7.8);1043 c.stroke();1044};10451046//**********************************************************************************************************************************************************1047//2U Horizontal Cable Duct1048//**********************************************************************************************************************************************************1049/**1050* Extends mxShape.1051*/1052function mxRackHorCableDuct2U(bounds, fill, stroke, strokewidth)1053{1054 mxShape.call(this);1055 this.bounds = bounds;1056 this.fill = fill;1057 this.stroke = stroke;1058 this.strokewidth = (strokewidth != null) ? strokewidth : 1;1059};10601061/**1062* Extends mxShape.1063*/1064mxUtils.extend(mxRackHorCableDuct2U, mxShape);10651066mxRackHorCableDuct2U.prototype.cst = 1067{1068 SHAPE_RACK_HOR_CABLE_DUCT_2U : 'mxgraph.rackGeneral.horCableDuct2U'1069};10701071/**1072* Function: paintVertexShape1073* 1074* Paints the vertex shape.1075*/1076mxRackHorCableDuct2U.prototype.paintVertexShape = function(c, x, y, w, h)1077{1078 c.translate(x, y);1079 this.background(c, w, h);1080 c.setShadow(false);1081 this.foreground(c, w, h);1082};10831084mxRackHorCableDuct2U.prototype.background = function(c, w, h)1085{1086 c.rect(0, 0, 160.9, 29.6);1087 c.fillAndStroke();1088};10891090mxRackHorCableDuct2U.prototype.foreground = function(c, w, h)1091{1092 c.rect(12, 0, 3, 7);1093 c.stroke();1094 c.rect(12, 7, 3, 22.6);1095 c.stroke();10961097 c.rect(45.5, 0, 3, 7);1098 c.stroke();1099 c.rect(45.5, 7, 3, 22.6);1100 c.stroke();1101 1102 c.rect(79, 0, 3, 7);1103 c.stroke();1104 c.rect(79, 7, 3, 22.6);1105 c.stroke();1106 1107 c.rect(112.5, 0, 3, 7);1108 c.stroke();1109 c.rect(112.5, 7, 3, 22.6);1110 c.stroke();1111 1112 c.rect(146, 0, 3, 7);1113 c.stroke();1114 c.rect(146, 7, 3, 22.6);1115 c.stroke();1116};11171118//**********************************************************************************************************************************************************1119//1U Cable Routing Bank1120//**********************************************************************************************************************************************************1121/**1122* Extends mxShape.1123*/1124function mxRackHorRoutingBank1U(bounds, fill, stroke, strokewidth)1125{1126 mxShape.call(this);1127 this.bounds = bounds;1128 this.fill = fill;1129 this.stroke = stroke;1130 this.strokewidth = (strokewidth != null) ? strokewidth : 1;1131};11321133/**1134* Extends mxShape.1135*/1136mxUtils.extend(mxRackHorRoutingBank1U, mxShape);11371138mxRackHorRoutingBank1U.prototype.cst = 1139{1140 SHAPE_RACK_HOR_ROUTING_BANK_1U : 'mxgraph.rackGeneral.horRoutingBank1U'1141};11421143/**1144* Function: paintVertexShape1145* 1146* Paints the vertex shape.1147*/1148mxRackHorRoutingBank1U.prototype.paintVertexShape = function(c, x, y, w, h)1149{1150 c.translate(x, y);1151 this.background(c, w, h);1152 c.setShadow(false);1153 this.foreground(c, w, h);1154};11551156mxRackHorRoutingBank1U.prototype.background = function(c, w, h)1157{1158 c.rect(0, 0, 160.9, 14.8);1159 c.fillAndStroke();1160};11611162mxRackHorRoutingBank1U.prototype.foreground = function(c, w, h)1163{1164 c.rect(10, 4, 17, 6.8);1165 c.stroke();1166 c.rect(31, 4, 17, 6.8);1167 c.stroke();1168 c.rect(52, 4, 17, 6.8);1169 c.stroke();1170 c.rect(73, 4, 17, 6.8);1171 c.stroke();1172 c.rect(94, 4, 17, 6.8);1173 c.stroke();1174 c.rect(115, 4, 17, 6.8);1175 c.stroke();1176 c.rect(136, 4, 17, 6.8);1177 c.stroke();1178};11791180//**********************************************************************************************************************************************************1181//2U Cable Routing Bank1182//**********************************************************************************************************************************************************1183/**1184* Extends mxShape.1185*/1186function mxRackHorRoutingBank2U(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};11941195/**1196* Extends mxShape.1197*/1198mxUtils.extend(mxRackHorRoutingBank2U, mxShape);11991200mxRackHorRoutingBank2U.prototype.cst = 1201{1202 SHAPE_RACK_HOR_ROUTING_BANK_2U : 'mxgraph.rackGeneral.horRoutingBank2U'1203};12041205/**1206* Function: paintVertexShape1207* 1208* Paints the vertex shape.1209*/1210mxRackHorRoutingBank2U.prototype.paintVertexShape = function(c, x, y, w, h)1211{1212 c.translate(x, y);1213 this.background(c, w, h);1214 c.setShadow(false);1215 this.foreground(c, w, h);1216};12171218mxRackHorRoutingBank2U.prototype.background = function(c, w, h)1219{1220 c.rect(0, 0, 160.9, 29.6);1221 c.fillAndStroke();1222};12231224mxRackHorRoutingBank2U.prototype.foreground = function(c, w, h)1225{1226 c.rect(10, 4, 17, 6.8);1227 c.stroke();1228 c.rect(31, 4, 17, 6.8);1229 c.stroke();1230 c.rect(52, 4, 17, 6.8);1231 c.stroke();1232 c.rect(73, 4, 17, 6.8);1233 c.stroke();1234 c.rect(94, 4, 17, 6.8);1235 c.stroke();1236 c.rect(115, 4, 17, 6.8);1237 c.stroke();1238 c.rect(136, 4, 17, 6.8);1239 c.stroke();12401241 c.rect(10, 18.8, 17, 6.8);1242 c.stroke();1243 c.rect(31, 18.8, 17, 6.8);1244 c.stroke();1245 c.rect(52, 18.8, 17, 6.8);1246 c.stroke();1247 c.rect(73, 18.8, 17, 6.8);1248 c.stroke();1249 c.rect(94, 18.8, 17, 6.8);1250 c.stroke();1251 c.rect(115, 18.8, 17, 6.8);1252 c.stroke();1253 c.rect(136, 18.8, 17, 6.8);1254 c.stroke();1255};12561257//**********************************************************************************************************************************************************1258//2U Neat-Patch1259//**********************************************************************************************************************************************************1260/**1261* Extends mxShape.1262*/1263function mxRackNeatPatch2U(bounds, fill, stroke, strokewidth)1264{1265 mxShape.call(this);1266 this.bounds = bounds;1267 this.fill = fill;1268 this.stroke = stroke;1269 this.strokewidth = (strokewidth != null) ? strokewidth : 1;1270};12711272/**1273* Extends mxShape.1274*/1275mxUtils.extend(mxRackNeatPatch2U, mxShape);12761277mxRackNeatPatch2U.prototype.cst = 1278{1279 SHAPE_RACK_NEAT_PATCH_2U : 'mxgraph.rackGeneral.neatPatch2U'1280};12811282/**1283* Function: paintVertexShape1284* 1285* Paints the vertex shape.1286*/1287mxRackNeatPatch2U.prototype.paintVertexShape = function(c, x, y, w, h)1288{1289 c.translate(x, y);1290 this.background(c, w, h);1291 c.setShadow(false);1292 this.mainText(c, w, h);1293};12941295mxRackNeatPatch2U.prototype.background = function(c, w, h)1296{1297 c.setFillColor('#666666');1298 c.rect(0, 0, 160.9, 29.6);1299 c.fillAndStroke();1300};13011302mxRackNeatPatch2U.prototype.mainText = function(c, w, h)1303{1304 c.setFontSize('12');1305 c.setFontColor('#ffffff');1306 c.setFontStyle(mxConstants.FONT_BOLD);1307 c.text(80.45, 24, 0, 0, 'NEAT-PATCH', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);1308};13091310//**********************************************************************************************************************************************************1311//1U shelf1312//**********************************************************************************************************************************************************1313/**1314* Extends mxShape.1315*/1316function mxRackShelf1U(bounds, fill, stroke, strokewidth)1317{1318 mxShape.call(this);1319 this.bounds = bounds;1320 this.fill = fill;1321 this.stroke = stroke;1322 this.strokewidth = (strokewidth != null) ? strokewidth : 1;1323};13241325/**1326* Extends mxShape.1327*/1328mxUtils.extend(mxRackShelf1U, mxShape);13291330mxRackShelf1U.prototype.cst = 1331{1332 SHAPE_RACK_SHELF_1U : 'mxgraph.rackGeneral.shelf1U'1333};13341335/**1336* Function: paintVertexShape1337* 1338* Paints the vertex shape.1339*/1340mxRackShelf1U.prototype.paintVertexShape = function(c, x, y, w, h)1341{1342 c.translate(x, y);1343 this.background(c, w, h);1344};13451346mxRackShelf1U.prototype.background = function(c, w, h)1347{1348 c.setStrokeWidth(2);1349 c.begin();1350 c.moveTo(0, 0);1351 c.lineTo(0, 14.8);1352 c.lineTo(160.9, 14.8);1353 c.lineTo(160.9, 0);1354 c.fillAndStroke();1355};13561357//**********************************************************************************************************************************************************1358//2U shelf1359//**********************************************************************************************************************************************************1360/**1361* Extends mxShape.1362*/1363function mxRackShelf2U(bounds, fill, stroke, strokewidth)1364{1365 mxShape.call(this);1366 this.bounds = bounds;1367 this.fill = fill;1368 this.stroke = stroke;1369 this.strokewidth = (strokewidth != null) ? strokewidth : 1;1370};13711372/**1373* Extends mxShape.1374*/1375mxUtils.extend(mxRackShelf2U, mxShape);13761377mxRackShelf2U.prototype.cst = 1378{1379 SHAPE_RACK_SHELF_2U : 'mxgraph.rackGeneral.shelf2U'1380};13811382/**1383* Function: paintVertexShape1384* 1385* Paints the vertex shape.1386*/1387mxRackShelf2U.prototype.paintVertexShape = function(c, x, y, w, h)1388{1389 c.translate(x, y);1390 this.background(c, w, h);1391};13921393mxRackShelf2U.prototype.background = function(c, w, h)1394{1395 c.setStrokeWidth(2);1396 c.begin();1397 c.moveTo(0, 0);1398 c.lineTo(0, 29.6);1399 c.lineTo(160.9, 29.6);1400 c.lineTo(160.9, 0);1401 c.fillAndStroke();1402};14031404//**********************************************************************************************************************************************************1405//4U shelf1406//**********************************************************************************************************************************************************1407/**1408* Extends mxShape.1409*/1410function mxRackShelf4U(bounds, fill, stroke, strokewidth)1411{1412 mxShape.call(this);1413 this.bounds = bounds;1414 this.fill = fill;1415 this.stroke = stroke;1416 this.strokewidth = (strokewidth != null) ? strokewidth : 1;1417};14181419/**1420* Extends mxShape.1421*/1422mxUtils.extend(mxRackShelf4U, mxShape);14231424mxRackShelf4U.prototype.cst = 1425{1426 SHAPE_RACK_SHELF_4U : 'mxgraph.rackGeneral.shelf4U'1427};14281429/**1430* Function: paintVertexShape1431* 1432* Paints the vertex shape.1433*/1434mxRackShelf4U.prototype.paintVertexShape = function(c, x, y, w, h)1435{1436 c.translate(x, y);1437 this.background(c, w, h);1438};14391440mxRackShelf4U.prototype.background = function(c, w, h)1441{1442 c.setStrokeWidth(2);1443 c.begin();1444 c.moveTo(0, 0);1445 c.lineTo(0, 59.2);1446 c.lineTo(160.9, 59.2);1447 c.lineTo(160.9, 0);1448 c.fillAndStroke();1449};14501451//**********************************************************************************************************************************************************1452//END LEGACY RACKS1453//**********************************************************************************************************************************************************145414551456//**********************************************************************************************************************************************************1457//Channel Base1458//**********************************************************************************************************************************************************1459/**1460* Extends mxShape.1461*/1462function mxRackChannelBase(bounds, fill, stroke, strokewidth)1463{1464 mxShape.call(this);1465 this.bounds = bounds;1466 this.fill = fill;1467 this.stroke = stroke;1468 this.strokewidth = (strokewidth != null) ? strokewidth : 1;1469};14701471/**1472 * Extends mxShape.1473 */1474mxUtils.extend(mxRackChannelBase, mxShape);14751476mxRackChannelBase.prototype.cst = 1477{1478 SHAPE_RACK_CHANNEL_BASE : 'mxgraph.rackGeneral.channelBase'1479};14801481/**1482 * Function: paintVertexShape1483 * 1484 * Paints the vertex shape.1485 */1486mxRackChannelBase.prototype.paintVertexShape = function(c, x, y, w, h)1487{1488 w = Math.max(w, 20);1489 h = Math.max(h, 20);1490 c.translate(x, y);14911492 this.background(c, w, h);1493 c.setShadow(false);1494 this.foreground(c, w, h);1495};14961497mxRackChannelBase.prototype.background = function(c, w, h)1498{1499 c.rect(10, h - 15, 5, 15);1500 c.fillAndStroke();1501 c.rect(w - 15, h - 15, 5, 15);1502 c.fillAndStroke();1503 c.rect(0, 0, w, h - 5);1504 c.fillAndStroke();1505};15061507mxRackChannelBase.prototype.foreground = function(c, w, h)1508{1509 c.setFillColor('#000000');1510 c.rect(10, h - 15, 5, 15);1511 c.fillAndStroke();1512 c.rect(w - 15, h - 15, 5, 15);1513 c.fillAndStroke();1514};15151516//**********************************************************************************************************************************************************1517//Cabinet Leg1518//**********************************************************************************************************************************************************1519/**1520* Extends mxShape.1521*/1522function mxRackCabinetLeg(bounds, fill, stroke, strokewidth)1523{1524 mxShape.call(this);1525 this.bounds = bounds;1526 this.fill = fill;1527 this.stroke = stroke;1528 this.strokewidth = (strokewidth != null) ? strokewidth : 1;1529};15301531/**1532* Extends mxShape.1533*/1534mxUtils.extend(mxRackCabinetLeg, mxShape);15351536mxRackCabinetLeg.prototype.cst = 1537{1538 SHAPE_RACK_CABINET_LEG : 'mxgraph.rackGeneral.cabinetLeg'1539};15401541/**1542* Function: paintVertexShape1543* 1544* Paints the vertex shape.1545*/1546mxRackCabinetLeg.prototype.paintVertexShape = function(c, x, y, w, h)1547{1548 w = Math.max(w, 20);1549 h = Math.max(h, 20);1550 c.translate(x, y);15511552 this.background(c, w, h);1553};15541555mxRackCabinetLeg.prototype.background = function(c, w, h)1556{1557 c.begin();1558 c.moveTo(0, h - 10);1559 c.lineTo(5, h - 10);1560 c.lineTo(5, h - 12);1561 c.lineTo(9, h - 12);1562 c.lineTo(9, h - 10);1563 c.lineTo(w - 10, h - 10);1564 c.lineTo(w - 10, 9);1565 c.lineTo(w - 12, 9);1566 c.lineTo(w - 12, 5);1567 c.lineTo(w - 10, 5);1568 c.lineTo(w - 10, 0);1569 c.lineTo(w, 0);1570 c.lineTo(w, h);1571 c.lineTo(0, h);1572 c.close();1573 c.fillAndStroke();1574};15751576mxCellRenderer.registerShape(mxRackRackCabinet3.prototype.cst.SHAPE_RACK_RACK_CABINET, mxRackRackCabinet3);15771578// New generic unit size implementations1579mxCellRenderer.registerShape(mxRackContainer.prototype.cst.SHAPE_RACK_CONTAINER, mxRackContainer);1580mxCellRenderer.registerShape(mxRackRackCabinet2.prototype.cst.SHAPE_RACK_RACK_CABINET, mxRackRackCabinet2);1581mxCellRenderer.registerShape(mxRackHorCableDuct.prototype.cst.SHAPE_RACK_HOR_CABLE_DUCT, mxRackHorCableDuct);1582mxCellRenderer.registerShape(mxRackHorRoutingBank.prototype.cst.SHAPE_RACK_HOR_ROUTING_BANK, mxRackHorRoutingBank);1583mxCellRenderer.registerShape(mxRackNeatPatch.prototype.cst.SHAPE_RACK_NEAT_PATCH, mxRackNeatPatch);1584mxCellRenderer.registerShape(mxRackShelf.prototype.cst.SHAPE_RACK_SHELF, mxRackShelf);1585mxCellRenderer.registerShape(mxRackPlate.prototype.cst.SHAPE_RACK_PLATE, mxRackPlate);15861587// Legacy resizable / fixed unit size implementations1588mxCellRenderer.registerShape(mxRackRackNumbering.prototype.cst.SHAPE_RACK_RACK_NUMBERING, mxRackRackNumbering);1589mxCellRenderer.registerShape(mxRackRackCabinet.prototype.cst.SHAPE_RACK_RACK_CABINET, mxRackRackCabinet);1590mxCellRenderer.registerShape(mxRackHorCableDuct1U.prototype.cst.SHAPE_RACK_HOR_CABLE_DUCT_1U, mxRackHorCableDuct1U);1591mxCellRenderer.registerShape(mxRackHorCableDuct2U.prototype.cst.SHAPE_RACK_HOR_CABLE_DUCT_2U, mxRackHorCableDuct2U);1592mxCellRenderer.registerShape(mxRackHorRoutingBank1U.prototype.cst.SHAPE_RACK_HOR_ROUTING_BANK_1U, mxRackHorRoutingBank1U);1593mxCellRenderer.registerShape(mxRackHorRoutingBank2U.prototype.cst.SHAPE_RACK_HOR_ROUTING_BANK_2U, mxRackHorRoutingBank2U);1594mxCellRenderer.registerShape(mxRackNeatPatch2U.prototype.cst.SHAPE_RACK_NEAT_PATCH_2U, mxRackNeatPatch2U);1595mxCellRenderer.registerShape(mxRackShelf1U.prototype.cst.SHAPE_RACK_SHELF_1U, mxRackShelf1U);1596mxCellRenderer.registerShape(mxRackShelf2U.prototype.cst.SHAPE_RACK_SHELF_2U, mxRackShelf2U);1597mxCellRenderer.registerShape(mxRackShelf4U.prototype.cst.SHAPE_RACK_SHELF_4U, mxRackShelf4U);15981599mxCellRenderer.registerShape(mxRackChannelBase.prototype.cst.SHAPE_RACK_CHANNEL_BASE, mxRackChannelBase);1600mxCellRenderer.registerShape(mxRackCabinetLeg.prototype.cst.SHAPE_RACK_CABINET_LEG, mxRackCabinetLeg);