diff options
Diffstat (limited to 'index.html')
-rwxr-xr-x | index.html | 185 |
1 files changed, 139 insertions, 46 deletions
@@ -16,6 +16,7 @@ <script type="text/javascript" src="details.js"></script> <script type="text/javascript" src="setup.js"></script> <script type="text/javascript" src="combined.js"></script> + <script type="text/javascript" src="orientation.js"></script> <script type="text/javascript"> // Stores edgeState for every recently created edge in updateFixedTerminalPoint() function @@ -189,22 +190,26 @@ }); menu.addItem('Selection to superblock', 'images/superblock.png', function() { - // @ToDo: Pooja: Functionality to be put. + // @ToDo: Functionality to be put. }); - var format = menu.addItem('Format', null, null); - + var formatMenu = menu.addItem('Format', null, null); menu.addItem('Rotate', 'images/rotate.png', function() { editor.execute('rotateCustom'); - }, format); + }, formatMenu); + menu.addItem('Flip', 'images/flip.png', function() { + editor.execute('flipCustom'); + }, formatMenu); + menu.addItem('Mirror', 'images/mirror.png', function() { + editor.execute('mirrorCustom'); + }, formatMenu); menu.addItem('Border Color', 'images/draw-brush.png', function() { showColorWheel(graph, cell, 'vertexStrokeColor'); - - }, format); + }, formatMenu); menu.addItem('Fill Color', 'images/edit.png', function() { showColorWheel(graph, cell, 'vertexFillColor'); - }, format); + }, formatMenu); menu.addItem('Details', null, function() { - // @ToDo: Pooja: Functionality to be put. + // @ToDo: Functionality to be put. }); } } else { @@ -723,13 +728,41 @@ } else { commandPort = cellvar.model.evtout.height; } + + var flip = false, + mirror = false; + var style = cell.style; + var styleObject = styleToObject(style); + if (styleObject['stencilFlipV'] == null) { + flip = false; + } else { + + if (styleObject['stencilFlipV'] == 0) { + flip = false; + } else { + flip = true; + } + + } + if (styleObject['stencilFlipH'] == null) { + mirror = false; + } else { + + if (styleObject['stencilFlipH'] == 0) { + mirror = false; + } else { + mirror = true; + } + + } + style = objectToStyle(styleObject); var geometry = cell.getGeometry(); text = 'Block Name : ' + cell.value.getAttribute('blockElementName') + "\n" + 'Simulation : ' + cell.value.getAttribute('simulationFunctionName') + "\n" + 'UID : ' + cell.id + "\n" + 'Style : ' + cell.style + "\n" + - 'Flip : ' + getData(cellvar.graphics.flip)[0] + "\n" + - 'Mirror : false' + "\n" + + 'Flip : ' + flip + "\n" + + 'Mirror : ' + mirror + "\n" + 'Input Ports : ' + inputPort + "\n" + 'Output Ports : ' + outputPort + "\n" + 'Control Ports : ' + controlPort + "\n" + @@ -752,12 +785,12 @@ if (mxUtils.isNode(cell.value)) { var stylesheet = graph.getStylesheet(); - var attribute = cell.value.getAttribute('style'); - if(attribute == null){ + var attribute = cell.value.getAttribute('style'); + if (attribute == null) { attribute = cell.value.getAttribute('interfaceFunctionName'); } var style = stylesheet.styles[attribute]; - var displayedLabel = style['displayedLabel']; + var displayedLabel = style['displayedLabel']; if (displayedLabel != null) { var displayParameter = cell.blockInstance.instance.displayParameter; for (i in displayParameter) { @@ -812,6 +845,29 @@ button.appendChild(titleName); }); + /* + * @jiteshjha, @pooja + * rotateCustom(@parameters) is defined in 'orientation.js' + */ + editor.addAction('rotateCustom', function(editor, cell) { + rotateCustom(editor, graph, cell); + }); + + /* + * @jiteshjha, @pooja + * flipCustom(@parameters) is defined in 'orientation.js' + */ + editor.addAction('flipCustom', function(editor, cell) { + flipCustom(editor, graph, cell); + }); + + /* + * @jiteshjha, @pooja + * mirrorCustom(@parameters) is defined in 'orientation.js' + */ + editor.addAction('mirrorCustom', function(editor, cell) { + mirrorCustom(editor, graph, cell); + }); // @jiteshjha, @pooja /* @@ -822,7 +878,6 @@ editor.addAction('deleteBlock', function(editor, cell) { graph.getModel().beginUpdate(); try { - // getEdgeId(@edgeObject) finds all the associated edges and split-block, and deletes them function getEdgeId(edgeObject) { @@ -925,6 +980,22 @@ // If the cell is a vertex, select the cell else { var portCount = selectionCells[k].getChildCount(); + /* + Maverick, Adhitya + switch-case statements to handle the ordering of following blocks. + The variables window.inBitMap and window.outBitMap are defined in + the file 'dependencies.js'. + */ + switch(selectionCells[k].value.nodeName){ + case 'ImplicitInBlock': + case 'ExplicitInBlock': + window.inBitMap = window.inBitMap.replaceAt(parseInt(selectionCells[k].value.getAttribute('ordering'))-1,'0') ; + break; + case 'ImplicitOutBlock': + case 'ExplicitOutBlock': + window.outBitMap = window.outBitMap.replaceAt(parseInt(selectionCells[k].value.getAttribute('ordering'))-1,'0') ; + break; + } cells.push(selectionCells[k]); for (var i = 0; i < portCount; i++) { var edgeCount = selectionCells[k].getChildAt(i).getEdgeCount(); @@ -943,7 +1014,6 @@ } } } - graph.removeCells(cells, true); } finally { graph.getModel().endUpdate(); @@ -1109,7 +1179,7 @@ button.type = "button"; button.name = "submit"; node.appendChild(button); - + /* Maverick Reference: www.htmlgoodies.com @@ -1239,7 +1309,7 @@ Ports will be automatically handled with the respective constructor calls. */ if (!(curNodeName.endsWith('Link') || curNodeName.endsWith('Port'))) { - var ifaceFuncName = cell.interfaceFunctionName; + var ifaceFuncName = null; /* Maverick @@ -1255,13 +1325,21 @@ temporaryMapObject.outputIds = []; temporaryMapObject.controlIds = []; temporaryMapObject.commandIds = []; + + switch(curNodeName){ + case 'ExplicitInBlock': ifaceFuncName='IN_f'; break; + case 'ExplicitOutBlock': ifaceFuncName='OUT_f'; break; + case 'ImplicitInBlock': ifaceFuncName='INIMPL_f'; break; + case 'ImplicitOutBlock': ifaceFuncName='OUTIMPL_f'; break; + default: ifaceFuncName=cell.interfaceFunctionName; + } - - var details_instance = null; + var details_instance=null if (ifaceFuncName != null) { - details_instance = new window[ifaceFuncName](); } + + if (details_instance != null) { var details = details_instance.define(); var enc = new mxCodec(mxUtils.createXmlDocument()); @@ -1269,8 +1347,10 @@ var temp = enc.encode(parent); var stylesheet = graph.getStylesheet(); var styleName = currentNode.getAttribute('style'); - if (styleName.indexOf(';') != -1) { - styleName = styleName.substring(0, styleName.indexOf(';')); + if(styleName!=null){ + if (styleName.indexOf(';') != -1) { + styleName = styleName.substring(0, styleName.indexOf(';')); + } } var style = stylesheet.styles[styleName]; @@ -1409,7 +1489,7 @@ Maverick Connecting the links. */ - + currentNode = rootNode.firstChild; while (currentNode != null) { var curNodeName = currentNode.nodeName; @@ -1623,10 +1703,10 @@ */ function styleToObject(style) { - if (style.indexOf(';') == -1) { + //To add semicolon at the end if it isn't already present. + if (style[style.length - 1] != ';') { style = style + ';'; } - var defaultStyle = style.substring(0, style.indexOf(';')); var styleObject = { "default": defaultStyle @@ -2404,28 +2484,37 @@ btn.style.cssText = 'margin-left: 75px'; // Executes when button 'btn' is clicked btn.onclick = function() { - var input = document.getElementById('color').value; - var style = graph.getModel().getStyle(cell); + var selectedCells = graph.getSelectionCells(); + graph.getModel().beginUpdate(); + try { + for (var count = 0; count < selectedCells.length; count++) { + var selectedCell = selectedCells[count]; + var input = document.getElementById('color').value; + var style = graph.getModel().getStyle(selectedCell); - if (style != null) { - var styleObject = styleToObject(style); - } + if (style != null) { + var styleObject = styleToObject(style); + } - if (selectProperty == "edgeStrokeColor") { - styleObject['strokeColor'] = input; - } else if (selectProperty == "bgColor") { - graph.container.style.backgroundColor = input; - } else if (selectProperty == "vertexStrokeColor") { - styleObject['strokeColor'] = input; - } else if (selectProperty == "vertexFillColor") { - styleObject['fillColor'] = input; - } else if (selectProperty == "edgeTextColor") { - styleObject['fontColor'] = input; - } + if (selectProperty == "edgeStrokeColor") { + styleObject['strokeColor'] = input; + } else if (selectProperty == "bgColor") { + graph.container.style.backgroundColor = input; + } else if (selectProperty == "vertexStrokeColor") { + styleObject['strokeColor'] = input; + } else if (selectProperty == "vertexFillColor") { + styleObject['fillColor'] = input; + } else if (selectProperty == "edgeTextColor") { + styleObject['fontColor'] = input; + } - if (style != null) { - style = objectToStyle(styleObject); - graph.getModel().setStyle(cell, style); + if (style != null) { + style = objectToStyle(styleObject); + graph.getModel().setStyle(selectedCell, style); + } + } + } finally { + graph.getModel().endUpdate(); } wind.destroy(); @@ -2549,7 +2638,6 @@ // Get the stylesheet for the graph var stylesheet = graph.getStylesheet(); - console.log(name); // From the stylesheet, get the style of the particular block var style = stylesheet.styles[name]; @@ -2571,6 +2659,8 @@ // Set label style['label'] = label; + style['imagePath'] = style['image']; + // Set image as null style['image'] = null; @@ -2635,6 +2725,9 @@ // @Chhavi: Additional attribute to store the block's instance v1.blockInstance = createInstanceTag(details_instance); + v1.currentAngle = 0; + v1.flipX = 1; + v1.flipY = 1; createPorts(graph, v1, inputPorts, controlPorts, outputPorts, commandPorts); v1.setConnectable(false); } finally { @@ -3283,4 +3376,4 @@ }); </script> -</html> +</html>
\ No newline at end of file |