UNPKG

@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.

140 lines 5.1 kB
import { BaseTextItem } from "./BaseTextItem"; import { Path, EqualsOfFloatNumbers } from "../../Math/index"; import { InvalidOperationException } from "../../Exception"; import { equals } from "../../Utils/Utils"; const MAX_LINE_CONST = 1; export class CurvedTextItem extends BaseTextItem { constructor(text, path, postScriptFontName, fontSize) { super(text, postScriptFontName, fontSize); 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; } get textPath() { return this._textPath; } set textPath(value) { this.setTextPath(value); } setTextPath(value, suppressPropertyChanged = false) { if (this._textPath.equals(value)) return; this._textPath = value; if (!suppressPropertyChanged) this._propertyChanged.notify(this, "textPath"); } get fitToPath() { return this._fitToPath; } set fitToPath(value) { if (this._fitToPath === value) return; this._fitToPath = value; this._propertyChanged.notify(this, "fitToPath"); } get stretch() { return this._stretch; } set stretch(value) { if (this._stretch === value) return; this._stretch = value; this._propertyChanged.notify(this, "stretch"); } get start() { return this._start; } set start(value) { if (this._start === value) return; this._start = value; this._propertyChanged.notify(this, "start"); } get end() { return this._end; } set end(value) { if (this._end === value) return; this._end = value; this._propertyChanged.notify(this, "end"); } get originalFontSize() { return this._originalFontSize; } set originalFontSize(value) { if (EqualsOfFloatNumbers(this._originalFontSize, value)) return; this._originalFontSize = value; this._propertyChanged.notify(this, "originalFontSize"); } get fitToPathStep() { return this._fitToPathStep; } set fitToPathStep(value) { if (EqualsOfFloatNumbers(this._fitToPathStep, value)) return; this._fitToPathStep = value; this._propertyChanged.notify(this, "fitToPathStep"); } /** * @override getter in BaseTextItem * @returns {number} Returns ths._maxLineCount */ get maxLineCount() { return MAX_LINE_CONST; } set maxLineCount(value) { throw new InvalidOperationException("Max Line Count of Curved Text can not be redefined!"); } getSimplifiedObject(omitProperties) { return super.getSimplifiedObject(["maxLineCount"].concat(omitProperties)); } applyPermissionsConstrain() { super.applyPermissionsConstrain(); if (this.manipulationPermissions != null) { this.manipulationPermissions.resizeGrips.setCornerArbitrary(false); this.manipulationPermissions.resizeGrips.edge = false; } } _copy(source, destination, generateNewIds, appropriateParentContainer) { super._copy(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; } } equals(other) { return super.equals(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); } clone(generateNewIds = false, appropriateParentContainer = false) { const item = new CurvedTextItem(); this._copy(this, item, generateNewIds, appropriateParentContainer); return item; } } CurvedTextItem.type = "CurvedTextItem"; //# sourceMappingURL=CurvedTextItem.js.map