define(["require", "exports", "../enum/enum"], function (require, exports, enum_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var LabelProperties = (function () {
function LabelProperties(modelProperties) {
this.modelProperties = modelProperties;
}
LabelProperties.prototype.setLabelProperties = function (oldLabels, item) {
var labelCollection = [];
if (oldLabels.length > 0) {
for (var i = 0; i < oldLabels.length; i++) {
var label = oldLabels[parseInt(i.toString(), 10)];
var newLabel = {};
(newLabel).style = {};
if (label.name) {
newLabel.id = label.name;
}
if (label.addInfo) {
newLabel.addInfo = label.addInfo;
}
if (label.text) {
newLabel.content = label.text;
}
if (label.constraints) {
newLabel.constraints = this.setLabelConstraints(label.constraints);
}
if (label.readOnly) {
newLabel.constraints = newLabel.constraints | enum_1.AnnotationConstraints.ReadOnly;
}
if (label.dragLimit) {
newLabel.dragLimit = {
left: label.dragLimit.left, right: label.dragLimit.right,
top: label.dragLimit.top, bottom: label.dragLimit.bottom
};
}
if (label.height) {
newLabel.height = label.height;
}
if (label.horizontalAlignment) {
newLabel.horizontalAlignment = label.horizontalAlignment.charAt(0).toUpperCase() +
label.horizontalAlignment.slice(1).toLowerCase();
}
if (label.verticalAlignment) {
newLabel.verticalAlignment = label.verticalAlignment.charAt(0).toUpperCase() +
label.verticalAlignment.slice(1).toLowerCase();
}
if (label.hyperlink) {
newLabel.hyperlink = { link: label.hyperlink, color: 'blue' };
}
if (label.margin) {
newLabel.margin = {
left: label.margin.left, right: label.margin.right,
top: label.margin.top, bottom: label.margin.bottom
};
}
newLabel.rotateAngle = label.rotateAngle;
if (label.offset) {
if (item) {
newLabel.offset = label.offset.x;
}
else {
newLabel.offset = { x: label.offset.x, y: label.offset.y };
}
}
newLabel.style.color = label.fontColor;
newLabel.style.fontFamily = label.fontFamily;
newLabel.style.fontSize = label.fontSize;
newLabel.style.italic = label.italic;
newLabel.style.bold = label.bold;
if (label.borderColor) {
newLabel.style.strokeColor = label.borderColor;
}
Iif (label.borderWidth) {
newLabel.style.strokeWidth = label.borderWidth;
}
Iif (label.textWrapping) {
newLabel.style.textWrapping = label.textWrapping;
}
if (label.textAlign) {
newLabel.style.textAlign = label.textAlign.charAt(0).toUpperCase() +
label.textAlign.slice(1).toLowerCase();
}
if (label.textDecoration) {
newLabel.style.textDecoration = label.textDecoration.charAt(0).toUpperCase() +
label.textDecoration.slice(1).toLowerCase();
Iif (newLabel.style.textDecoration === 'Linethrough') {
newLabel.style.textDecoration = 'LineThrough';
}
}
var appearance = this.setLabelAppearance(newLabel, label);
newLabel.style.fill = appearance.fill;
newLabel.style.opacity = appearance.opacity;
newLabel.visibility = appearance.visibility;
if (label.width) {
newLabel.width = label.width;
}
labelCollection.push(newLabel);
}
}
return labelCollection;
};
LabelProperties.prototype.setLabelAppearance = function (newLabel, label) {
var appearance = {};
if (label.fillColor) {
appearance.fill = label.fillColor === 'white' ? 'transparent' : label.fillColor;
}
if (label.opacity) {
appearance.opacity = label.opacity;
}
if (label.visible) {
appearance.visibility = label.visible;
}
return appearance;
};
LabelProperties.prototype.setLabelConstraints = function (constraints) {
var annotationConstraints = enum_1.AnnotationConstraints.None;
Iif (constraints & enum_1.AnnotationConstraints.Select) {
annotationConstraints = annotationConstraints | enum_1.AnnotationConstraints.Select;
}
Iif (constraints & enum_1.AnnotationConstraints.Drag) {
annotationConstraints = annotationConstraints | enum_1.AnnotationConstraints.Drag;
}
Iif (constraints & enum_1.AnnotationConstraints.Resize) {
annotationConstraints = annotationConstraints | enum_1.AnnotationConstraints.Resize;
}
Iif (constraints & enum_1.AnnotationConstraints.Rotate) {
annotationConstraints = annotationConstraints | enum_1.AnnotationConstraints.Rotate;
}
return annotationConstraints;
};
LabelProperties.prototype.getModuleName = function () {
return 'LabelProperties';
};
return LabelProperties;
}());
exports.LabelProperties = LabelProperties;
});
|