@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.
192 lines • 7.8 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 __());
};
})();
import { BaseTextItem } from "./BaseTextItem";
import { Path, EqualsOfFloatNumbers } from "../../Math/index";
import { InvalidOperationException } from "../../Exception";
import { equals } from "../../Utils/Utils";
var MAX_LINE_CONST = 1;
var CurvedTextItem = /** @class */ (function (_super) {
__extends(CurvedTextItem, _super);
function CurvedTextItem(text, path, postScriptFontName, fontSize) {
var _this = _super.call(this, text, postScriptFontName, fontSize) || this;
_this._textPath = new Path();
_this._fitToPath = false;
_this._stretch = false;
_this._originalFontSize = 0;
_this._fitToPathStep = 1;
_this._start = 0;
_this.type = CurvedTextItem.type;
if (path != null)
_this.textPath = path;
_this._ignorePermissionsChange = true;
_this.manipulationPermissions.resizeGrips.setCornerArbitrary(false);
_this.manipulationPermissions.resizeGrips.edge = false;
_this._ignorePermissionsChange = false;
return _this;
}
Object.defineProperty(CurvedTextItem.prototype, "textPath", {
get: function () {
return this._textPath;
},
set: function (value) {
this.setTextPath(value);
},
enumerable: true,
configurable: true
});
CurvedTextItem.prototype.setTextPath = function (value, suppressPropertyChanged) {
if (suppressPropertyChanged === void 0) { suppressPropertyChanged = false; }
if (this._textPath.equals(value))
return;
this._textPath = value;
if (!suppressPropertyChanged)
this._propertyChanged.notify(this, "textPath");
};
Object.defineProperty(CurvedTextItem.prototype, "fitToPath", {
get: function () {
return this._fitToPath;
},
set: function (value) {
if (this._fitToPath === value)
return;
this._fitToPath = value;
this._propertyChanged.notify(this, "fitToPath");
},
enumerable: true,
configurable: true
});
Object.defineProperty(CurvedTextItem.prototype, "stretch", {
get: function () {
return this._stretch;
},
set: function (value) {
if (this._stretch === value)
return;
this._stretch = value;
this._propertyChanged.notify(this, "stretch");
},
enumerable: true,
configurable: true
});
Object.defineProperty(CurvedTextItem.prototype, "start", {
get: function () {
return this._start;
},
set: function (value) {
if (this._start === value)
return;
this._start = value;
this._propertyChanged.notify(this, "start");
},
enumerable: true,
configurable: true
});
Object.defineProperty(CurvedTextItem.prototype, "end", {
get: function () {
return this._end;
},
set: function (value) {
if (this._end === value)
return;
this._end = value;
this._propertyChanged.notify(this, "end");
},
enumerable: true,
configurable: true
});
Object.defineProperty(CurvedTextItem.prototype, "originalFontSize", {
get: function () {
return this._originalFontSize;
},
set: function (value) {
if (EqualsOfFloatNumbers(this._originalFontSize, value))
return;
this._originalFontSize = value;
this._propertyChanged.notify(this, "originalFontSize");
},
enumerable: true,
configurable: true
});
Object.defineProperty(CurvedTextItem.prototype, "fitToPathStep", {
get: function () {
return this._fitToPathStep;
},
set: function (value) {
if (EqualsOfFloatNumbers(this._fitToPathStep, value))
return;
this._fitToPathStep = value;
this._propertyChanged.notify(this, "fitToPathStep");
},
enumerable: true,
configurable: true
});
Object.defineProperty(CurvedTextItem.prototype, "maxLineCount", {
/**
* @override getter in BaseTextItem
* @returns {number} Returns ths._maxLineCount
*/
get: function () {
return MAX_LINE_CONST;
},
set: function (value) {
throw new InvalidOperationException("Max Line Count of Curved Text can not be redefined!");
},
enumerable: true,
configurable: true
});
CurvedTextItem.prototype.getSimplifiedObject = function (omitProperties) {
return _super.prototype.getSimplifiedObject.call(this, ["maxLineCount"].concat(omitProperties));
};
CurvedTextItem.prototype.applyPermissionsConstrain = function () {
_super.prototype.applyPermissionsConstrain.call(this);
if (this.manipulationPermissions != null) {
this.manipulationPermissions.resizeGrips.setCornerArbitrary(false);
this.manipulationPermissions.resizeGrips.edge = false;
}
};
CurvedTextItem.prototype._copy = function (source, destination, generateNewIds, appropriateParentContainer) {
_super.prototype._copy.call(this, source, destination, generateNewIds, appropriateParentContainer);
if (destination instanceof CurvedTextItem) {
destination.textPath = source.textPath.clone();
destination.fitToPath = source.fitToPath;
destination.stretch = source.stretch;
destination.originalFontSize = source.originalFontSize;
destination.fitToPathStep = source.fitToPathStep;
destination.start = source.start;
destination.end = source.end;
}
};
CurvedTextItem.prototype.equals = function (other) {
return _super.prototype.equals.call(this, other) &&
equals(this._textPath, other._textPath) &&
equals(this._fitToPath, other._fitToPath) &&
equals(this._stretch, other._stretch) &&
equals(this._originalFontSize, other._originalFontSize) &&
equals(this._fitToPathStep, other._fitToPathStep) &&
equals(this._start, other._start) &&
equals(this._end, other._end) &&
equals(this._textPath, other._textPath);
};
CurvedTextItem.prototype.clone = function (generateNewIds, appropriateParentContainer) {
if (generateNewIds === void 0) { generateNewIds = false; }
if (appropriateParentContainer === void 0) { appropriateParentContainer = false; }
var item = new CurvedTextItem();
this._copy(this, item, generateNewIds, appropriateParentContainer);
return item;
};
CurvedTextItem.type = "CurvedTextItem";
return CurvedTextItem;
}(BaseTextItem));
export { CurvedTextItem };
//# sourceMappingURL=CurvedTextItem.js.map