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;
});
|