all files / diagram/load-utility/ portProperties.js

98.25% Statements 56/57
100% Branches 24/24
85.71% Functions 6/7
98.25% Lines 56/57
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83   1308×   75× 75× 18× 18× 18× 18× 18×   18× 18× 18×     18×     18× 18× 18× 18× 18× 18× 18×   18×     17×   18× 18×     75×   18× 18×   18×   18×   18× 18×   18×   18×   18×   18×            
define(["require", "exports", "../enum/enum"], function (require, exports, enum_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var PortProperties = (function () {
        function PortProperties(modelProperties) {
            this.modelProperties = modelProperties;
        }
        PortProperties.prototype.setPortProperties = function (oldPorts) {
            var portCollection = [];
            if (oldPorts.length > 0) {
                for (var i = 0; i < oldPorts.length; i++) {
                    var port = oldPorts[parseInt(i.toString(), 10)];
                    var newPort = {};
                    newPort.style = {};
                    newPort.id = port.name;
                    if (port.addInfo) {
                        newPort.addInfo = port.addInfo;
                    }
                    newPort.height = port.size;
                    newPort.width = port.size;
                    if (port.horizontalAlignment) {
                        newPort.horizontalAlignment = port.horizontalAlignment.charAt(0).toUpperCase() +
                            port.horizontalAlignment.slice(1);
                    }
                    if (port.verticalAlignment) {
                        newPort.verticalAlignment = port.verticalAlignment.charAt(0).toUpperCase() +
                            port.verticalAlignment.slice(1);
                    }
                    newPort.margin = { left: port.margin.left, right: port.margin.right, top: port.margin.top, bottom: port.margin.bottom };
                    newPort.offset = { x: port.offset.x, y: port.offset.y };
                    newPort.style.strokeColor = port.borderColor;
                    newPort.style.strokeWidth = port.borderWidth;
                    newPort.style.fill = port.fillColor;
                    newPort.constraints = this.setPortConstraints(port.constraints);
                    if (port.pathData) {
                        newPort.pathData = port.pathData;
                    }
                    if (port.shape === 'path') {
                        newPort.shape = 'Custom';
                    }
                    else {
                        newPort.shape = port.shape.charAt(0).toUpperCase() + (port.shape).slice(1);
                    }
                    newPort.visibility = this.setPortVisibility(port.visibility);
                    portCollection.push(newPort);
                }
            }
            return portCollection;
        };
        PortProperties.prototype.setPortConstraints = function (constraints) {
            var portConstraints = enum_1.PortConstraints.Default;
            if (constraints & enum_1.PortConstraints.Draw) {
                portConstraints = portConstraints | enum_1.PortConstraints.Draw;
            }
            if (constraints & enum_1.PortConstraints.None) {
                portConstraints = enum_1.PortConstraints.None;
            }
            return portConstraints;
        };
        PortProperties.prototype.setPortVisibility = function (visibility) {
            var portVisibility;
            if (visibility & enum_1.PortVisibility.Visible) {
                portVisibility = portVisibility | enum_1.PortVisibility.Visible;
            }
            if (visibility & enum_1.PortVisibility.Hidden) {
                portVisibility = portVisibility | enum_1.PortVisibility.Hidden;
            }
            if (visibility & enum_1.PortVisibility.Hover) {
                portVisibility = portVisibility | enum_1.PortVisibility.Hover;
            }
            if (visibility & enum_1.PortVisibility.Connect) {
                portVisibility = portVisibility | enum_1.PortVisibility.Connect;
            }
            return portVisibility;
        };
        PortProperties.prototype.getModuleName = function () {
            return 'PortProperties';
        };
        return PortProperties;
    }());
    exports.PortProperties = PortProperties;
});