@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.
208 lines • 10.3 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { BaseTextItem } from "./BaseTextItem";
import { EqualsOfFloatNumbers } from "../../Math/index";
import { ParagraphSettings } from "./ParagraphSettings";
import { PathBoundedTextPermissions } from "./PathBoundedTextPermissions";
import { ArgumentException } from "../../Exception";
import { equals, arrayEquals } from "../../Utils/Utils";
import { FirstBaselineOffset } from "./TextEnums";
import { Property } from "../Decorators/Property";
var PathBoundedTextItem = /** @class */ (function (_super) {
__extends(PathBoundedTextItem, _super);
function PathBoundedTextItem(text, paths, postScriptFontName, fontSize) {
var _this = _super.call(this, text, postScriptFontName, fontSize) || this;
_this._boundingPaths = [];
_this._wrappingMargin = 7;
_this._wrappingPath = null;
_this._paragraphSettings = new ParagraphSettings();
_this._isVertical = false;
_this._firstBaselineOffset = FirstBaselineOffset.Ascent;
_this._firstBaselineMinOffset = 0;
_this.type = PathBoundedTextItem.type;
if (paths != null)
_this.boundingPaths = paths;
_this._pathBoundedTextPermissions = new PathBoundedTextPermissions();
_this._pathBoundedTextPermissions.propertyChanged.add(_this._onPermissionsChanged);
return _this;
}
Object.defineProperty(PathBoundedTextItem.prototype, "boundingPaths", {
get: function () {
return this._boundingPaths;
},
set: function (value) {
if (value.length === this.boundingPaths.length && this.boundingPaths.every(function (path, index) { return path.isEqual(value[index]); }))
return;
this._boundingPaths = value;
this._propertyChanged.notify(this, "boundingPaths");
},
enumerable: true,
configurable: true
});
Object.defineProperty(PathBoundedTextItem.prototype, "wrappingPath", {
get: function () {
return this._wrappingPath;
},
set: function (value) {
if (this._wrappingPath == null && value == null || this._wrappingPath != null && this._wrappingPath.isEqual(value))
return;
this._wrappingPath = value;
this._propertyChanged.notify(this, "wrappingPath");
},
enumerable: true,
configurable: true
});
Object.defineProperty(PathBoundedTextItem.prototype, "wrappingMargin", {
get: function () {
return this._wrappingMargin;
},
set: function (value) {
if (EqualsOfFloatNumbers(this._wrappingMargin, value))
return;
this._wrappingMargin = value;
this._propertyChanged.notify(this, "wrappingMargin");
},
enumerable: true,
configurable: true
});
Object.defineProperty(PathBoundedTextItem.prototype, "paragraphSettings", {
get: function () {
return this._paragraphSettings;
},
set: function (value) {
if (ParagraphSettings.equals(this._paragraphSettings, value))
return;
this._paragraphSettings = value;
this._propertyChanged.notify(this, "paragraphSettings");
},
enumerable: true,
configurable: true
});
Object.defineProperty(PathBoundedTextItem.prototype, "isVertical", {
get: function () {
return this._isVertical;
},
set: function (value) {
if (this._isVertical === value)
return;
this._isVertical = value;
this._propertyChanged.notify(this, "isVertical");
},
enumerable: true,
configurable: true
});
Object.defineProperty(PathBoundedTextItem.prototype, "pathBoundedTextPermissions", {
get: function () {
return this._pathBoundedTextPermissions;
},
set: function (value) {
if (value == null)
throw new ArgumentException("pathBoundedTextPermissions cannot be null");
if (equals(this._pathBoundedTextPermissions, value))
return;
this._pathBoundedTextPermissions.propertyChanged.remove(this._onPermissionsChanged);
this._pathBoundedTextPermissions = value;
this._pathBoundedTextPermissions.propertyChanged.add(this._onPermissionsChanged);
this._onPermissionsChanged();
},
enumerable: true,
configurable: true
});
Object.defineProperty(PathBoundedTextItem.prototype, "firstBaselineOffset", {
get: function () {
return this._firstBaselineOffset;
},
set: function (value) {
if (this._firstBaselineOffset === value)
return;
this._firstBaselineOffset = value;
if (value != null)
this._propertyChanged.notify(this, "firstBaselineOffset");
},
enumerable: true,
configurable: true
});
Object.defineProperty(PathBoundedTextItem.prototype, "firstBaselineMinOffset", {
get: function () {
return this._firstBaselineMinOffset;
},
set: function (value) {
if (EqualsOfFloatNumbers(this._firstBaselineMinOffset, value))
return;
this._firstBaselineMinOffset = value;
if (value != null)
this._propertyChanged.notify(this, "firstBaselineMinOffset");
},
enumerable: true,
configurable: true
});
PathBoundedTextItem.prototype.getSimplifiedObject = function (omitProperties) {
var simplified = _super.prototype.getSimplifiedObject.call(this, ["pathBoundedTextPermissions"].concat(omitProperties));
simplified["pathBoundedTextPermissions"] = this.pathBoundedTextPermissions.getSimplifiedObject();
return simplified;
};
PathBoundedTextItem.prototype._copy = function (source, destination, generateNewIds, appropriateParentContainer) {
_super.prototype._copy.call(this, source, destination, generateNewIds, appropriateParentContainer);
if (destination.type == "AutoScaledTextItem" || destination.type == "BoundedTextItem" || destination.type == "PathBoundedTextItem" || destination.type == "PlainTextItem") {
destination["isVertical"] = source.isVertical;
}
if (destination.type == "PathBoundedTextItem" || destination.type == "BoundedTextItem") {
destination["wrappingMargin"] = source.wrappingMargin;
destination["paragraphSettings"] = source.paragraphSettings.clone();
destination["wrappingPath"] = source.wrappingPath != null ? source.wrappingPath.clone() : null;
destination["firstBaselineOffset"] = source.firstBaselineOffset;
destination["firstBaselineMinOffset"] = source.firstBaselineMinOffset;
}
if (destination instanceof PathBoundedTextItem) {
destination.boundingPaths = source.boundingPaths.map(function (i) { return i.clone(); });
destination.pathBoundedTextPermissions = source.pathBoundedTextPermissions.clone();
}
};
PathBoundedTextItem.prototype.equals = function (other) {
return _super.prototype.equals.call(this, other) &&
arrayEquals(this._boundingPaths, other._boundingPaths) &&
equals(this._wrappingMargin, other._wrappingMargin) &&
equals(this._paragraphSettings, other._paragraphSettings) &&
equals(this._isVertical, other._isVertical) &&
equals(this._pathBoundedTextPermissions, other._pathBoundedTextPermissions) &&
equals(this._wrappingPath, other._wrappingPath) &&
equals(this.firstBaselineOffset, other.firstBaselineOffset) &&
equals(this.firstBaselineMinOffset, other.firstBaselineMinOffset);
};
PathBoundedTextItem.prototype.clone = function (generateNewIds, appropriateParentContainer) {
if (generateNewIds === void 0) { generateNewIds = false; }
if (appropriateParentContainer === void 0) { appropriateParentContainer = false; }
var item = new PathBoundedTextItem();
this._copy(this, item, generateNewIds, appropriateParentContainer);
return item;
};
PathBoundedTextItem.type = "PathBoundedTextItem";
__decorate([
Property({ enumObject: FirstBaselineOffset }),
__metadata("design:type", Number),
__metadata("design:paramtypes", [Number])
], PathBoundedTextItem.prototype, "firstBaselineOffset", null);
return PathBoundedTextItem;
}(BaseTextItem));
export { PathBoundedTextItem };
//# sourceMappingURL=PathBoundedTextItem.js.map