@aurigma/design-atoms-model
Version:
Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.
49 lines • 1.83 kB
JavaScript
import * as _ from "underscore";
import { equals } from "../../Utils/Utils";
import { Size } from "./Size";
var ImageMetaData = /** @class */ (function () {
function ImageMetaData(rawData) {
this.storageId = null;
this.size = new Size();
this.name = null;
this.isUserImage = false;
this.isVector = false;
this.pageIndex = 0;
if (typeof rawData === "string") {
try {
rawData = JSON.parse(rawData);
}
catch (e) {
console.warn("Unable to parse ImageMetaData from string ", rawData, e);
rawData = null;
}
}
if (_.isObject(rawData)) {
//TODO Add a validation of raw objects.
_.extend(this, rawData);
}
}
ImageMetaData.fromInterface = function (value, name) {
var convertedData = new ImageMetaData();
convertedData.storageId = value.id;
convertedData.size = new Size(value.width, value.height);
convertedData.name = name !== undefined ? name : null;
if (value.isVector != null)
convertedData.isVector = value.isVector;
return convertedData;
};
ImageMetaData.prototype.clone = function () {
return new ImageMetaData(this);
};
ImageMetaData.prototype.equals = function (other) {
return this.storageId === other.storageId &&
equals(this.size, other.size) &&
equals(this.name, other.name) &&
equals(this.isUserImage, other.isUserImage) &&
equals(this.isVector, other.isVector) &&
equals(this.pageIndex, other.pageIndex);
};
return ImageMetaData;
}());
export { ImageMetaData };
//# sourceMappingURL=ImageMetaData.js.map