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.

238 lines 10.5 kB
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 { RectangleF, Path, EqualsOfFloatNumbers } from "../../Math/index"; import { ParagraphSettings } from "./ParagraphSettings"; import { FitMode, ShrinkMode, OverflowStrategy, TextVerticalAlignment, FirstBaselineOffset } from "./TextEnums"; import { equals } from "../../Utils/Utils"; import { Property } from "../Decorators/Property"; import { ObjectPropertyFactory } from "../Decorators/Factory"; export class BoundedTextItem extends BaseTextItem { constructor(text, rectangle, postScriptFontName, fontSize) { super(text, postScriptFontName, fontSize); this._textRectangle = new RectangleF(); this._verticalAlignment = TextVerticalAlignment.Top; this._isVertical = false; this._paragraphSettings = new ParagraphSettings(); this._wrappingPath = null; this._wrappingMargin = 7; this._scheduledFitMode = null; this._shrinkMode = ShrinkMode.Size; this._overflowStrategy = OverflowStrategy.Clip; this._originalVerticalScale = 1; this._originalHorizontalScale = 1; this._firstBaselineOffset = FirstBaselineOffset.Ascent; this._firstBaselineMinOffset = 0; this.type = BoundedTextItem.type; if (rectangle != null) { this.textRectangle = rectangle; this.sourcePath = Path.rectangle(rectangle.left, rectangle.top, rectangle.width, rectangle.height); } } get textRectangle() { return this._textRectangle; } set textRectangle(value) { if (RectangleF.isEqual(this._textRectangle, value)) return; this._textRectangle = value; this._propertyChanged.notify(this, "textRectangle"); } get verticalAlignment() { return this._verticalAlignment; } set verticalAlignment(value) { if (this._verticalAlignment === value) return; this._verticalAlignment = value; this._propertyChanged.notify(this, "verticalAlignment"); } get isVertical() { return this._isVertical; } set isVertical(value) { if (this._isVertical === value) return; this._isVertical = value; this._propertyChanged.notify(this, "isVertical"); } get paragraphSettings() { return this._paragraphSettings; } set paragraphSettings(value) { if (this._paragraphSettings.equals(value)) return; this._paragraphSettings = value; this._propertyChanged.notify(this, "paragraphSettings"); } get wrappingPath() { return this._wrappingPath; } set wrappingPath(value) { if (this._wrappingPath == null && value == null || this._wrappingPath != null && this._wrappingPath.isEqual(value)) return; this._wrappingPath = value; this._propertyChanged.notify(this, "wrappingPath"); } get wrappingMargin() { return this._wrappingMargin; } set wrappingMargin(value) { if (this._wrappingMargin === value) return; this._wrappingMargin = value; this._propertyChanged.notify(this, "wrappingMargin"); } get scheduledFitMode() { return this._scheduledFitMode; } set scheduledFitMode(value) { if (this._scheduledFitMode === value) return; this._scheduledFitMode = value; if (value != null) this._propertyChanged.notify(this, "scheduledFitMode"); } get shrinkMode() { return this._shrinkMode; } set shrinkMode(value) { if (this._shrinkMode === value) return; this._shrinkMode = value; if (value != null) this._propertyChanged.notify(this, "shrinkMode"); } get overflowStrategy() { return this._overflowStrategy; } set overflowStrategy(value) { if (this._overflowStrategy === value) return; this._overflowStrategy = value; if (value != null) this._propertyChanged.notify(this, "overflowStrategy"); } get originalVerticalScale() { return this._originalVerticalScale; } set originalVerticalScale(value) { if (this._originalVerticalScale === value) return; this._originalVerticalScale = value; if (value != null) this._propertyChanged.notify(this, "originalVerticalScale"); } get originalHorizontalScale() { return this._originalHorizontalScale; } set originalHorizontalScale(value) { if (this._originalHorizontalScale === value) return; this._originalHorizontalScale = value; if (value != null) this._propertyChanged.notify(this, "originalHorizontalScale"); } get firstBaselineOffset() { return this._firstBaselineOffset; } set firstBaselineOffset(value) { if (this._firstBaselineOffset === value) return; this._firstBaselineOffset = value; if (value != null) this._propertyChanged.notify(this, "firstBaselineOffset"); } get firstBaselineMinOffset() { return this._firstBaselineMinOffset; } set firstBaselineMinOffset(value) { if (EqualsOfFloatNumbers(this._firstBaselineMinOffset, value)) return; this._firstBaselineMinOffset = value; if (value != null) this._propertyChanged.notify(this, "firstBaselineMinOffset"); } _copy(source, destination, generateNewIds, appropriateParentContainer) { super._copy(source, destination, generateNewIds, appropriateParentContainer); if (destination.type == "AutoScaledTextItem" || destination.type == "BoundedTextItem" || destination.type == "PathBoundedTextItem" || destination.type == "PlainTextItem") { destination["isVertical"] = source.isVertical; } if (destination.type == "BoundedTextItem" || destination.type == "PathBoundedTextItem") { destination["paragraphSettings"] = source.paragraphSettings.clone(); destination["wrappingPath"] = source.wrappingPath != null ? source.wrappingPath.clone() : null; destination["wrappingMargin"] = source.wrappingMargin; destination["firstBaselineOffset"] = source.firstBaselineOffset; destination["firstBaselineMinOffset"] = source.firstBaselineMinOffset; } if (destination instanceof BoundedTextItem) { destination.textRectangle = source.textRectangle.clone(); destination.verticalAlignment = source.verticalAlignment; destination.scheduledFitMode = source.scheduledFitMode; destination.shrinkMode = source.shrinkMode; destination.overflowStrategy = source.overflowStrategy; destination.originalVerticalScale = source.originalVerticalScale; destination.originalHorizontalScale = source.originalHorizontalScale; } } equals(other) { return super.equals(other) && equals(this._isVertical, other._isVertical) && equals(this._textRectangle, other._textRectangle) && equals(this._verticalAlignment, other._verticalAlignment) && equals(this._paragraphSettings, other._paragraphSettings) && equals(this._wrappingPath, other._wrappingPath) && equals(this._wrappingMargin, other._wrappingMargin) && equals(this._scheduledFitMode, other._scheduledFitMode) && equals(this._shrinkMode, other._shrinkMode) && equals(this._overflowStrategy, other._overflowStrategy) && equals(this._originalVerticalScale, other._originalVerticalScale) && equals(this._originalHorizontalScale, other._originalHorizontalScale) && equals(this.firstBaselineOffset, other.firstBaselineOffset) && equals(this.firstBaselineMinOffset, other.firstBaselineMinOffset); } clone(generateNewIds = false, appropriateParentContainer = false) { const item = new BoundedTextItem(); this._copy(this, item, generateNewIds, appropriateParentContainer); return item; } } BoundedTextItem.type = "BoundedTextItem"; __decorate([ Property({ enumObject: TextVerticalAlignment }), __metadata("design:type", Number), __metadata("design:paramtypes", [Number]) ], BoundedTextItem.prototype, "verticalAlignment", null); __decorate([ Property({ factory: new ObjectPropertyFactory(Path), displayName: "Wrapping path" }), __metadata("design:type", Path), __metadata("design:paramtypes", [Path]) ], BoundedTextItem.prototype, "wrappingPath", null); __decorate([ Property({ enumObject: FitMode }), __metadata("design:type", Number), __metadata("design:paramtypes", [Number]) ], BoundedTextItem.prototype, "scheduledFitMode", null); __decorate([ Property({ enumObject: ShrinkMode }), __metadata("design:type", Number), __metadata("design:paramtypes", [Number]) ], BoundedTextItem.prototype, "shrinkMode", null); __decorate([ Property({ enumObject: OverflowStrategy }), __metadata("design:type", Number), __metadata("design:paramtypes", [Number]) ], BoundedTextItem.prototype, "overflowStrategy", null); __decorate([ Property({ enumObject: FirstBaselineOffset }), __metadata("design:type", Number), __metadata("design:paramtypes", [Number]) ], BoundedTextItem.prototype, "firstBaselineOffset", null); //# sourceMappingURL=BoundedTextItem.js.map