@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.
309 lines • 13.9 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 { 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";
var BoundedTextItem = /** @class */ (function (_super) {
__extends(BoundedTextItem, _super);
function BoundedTextItem(text, rectangle, postScriptFontName, fontSize) {
var _this = _super.call(this, text, postScriptFontName, fontSize) || this;
_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);
}
return _this;
}
Object.defineProperty(BoundedTextItem.prototype, "textRectangle", {
get: function () {
return this._textRectangle;
},
set: function (value) {
if (RectangleF.isEqual(this._textRectangle, value))
return;
this._textRectangle = value;
this._propertyChanged.notify(this, "textRectangle");
},
enumerable: true,
configurable: true
});
Object.defineProperty(BoundedTextItem.prototype, "verticalAlignment", {
get: function () {
return this._verticalAlignment;
},
set: function (value) {
if (this._verticalAlignment === value)
return;
this._verticalAlignment = value;
this._propertyChanged.notify(this, "verticalAlignment");
},
enumerable: true,
configurable: true
});
Object.defineProperty(BoundedTextItem.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(BoundedTextItem.prototype, "paragraphSettings", {
get: function () {
return this._paragraphSettings;
},
set: function (value) {
if (this._paragraphSettings.equals(value))
return;
this._paragraphSettings = value;
this._propertyChanged.notify(this, "paragraphSettings");
},
enumerable: true,
configurable: true
});
Object.defineProperty(BoundedTextItem.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(BoundedTextItem.prototype, "wrappingMargin", {
get: function () {
return this._wrappingMargin;
},
set: function (value) {
if (this._wrappingMargin === value)
return;
this._wrappingMargin = value;
this._propertyChanged.notify(this, "wrappingMargin");
},
enumerable: true,
configurable: true
});
Object.defineProperty(BoundedTextItem.prototype, "scheduledFitMode", {
get: function () {
return this._scheduledFitMode;
},
set: function (value) {
if (this._scheduledFitMode === value)
return;
this._scheduledFitMode = value;
if (value != null)
this._propertyChanged.notify(this, "scheduledFitMode");
},
enumerable: true,
configurable: true
});
Object.defineProperty(BoundedTextItem.prototype, "shrinkMode", {
get: function () {
return this._shrinkMode;
},
set: function (value) {
if (this._shrinkMode === value)
return;
this._shrinkMode = value;
if (value != null)
this._propertyChanged.notify(this, "shrinkMode");
},
enumerable: true,
configurable: true
});
Object.defineProperty(BoundedTextItem.prototype, "overflowStrategy", {
get: function () {
return this._overflowStrategy;
},
set: function (value) {
if (this._overflowStrategy === value)
return;
this._overflowStrategy = value;
if (value != null)
this._propertyChanged.notify(this, "overflowStrategy");
},
enumerable: true,
configurable: true
});
Object.defineProperty(BoundedTextItem.prototype, "originalVerticalScale", {
get: function () {
return this._originalVerticalScale;
},
set: function (value) {
if (this._originalVerticalScale === value)
return;
this._originalVerticalScale = value;
if (value != null)
this._propertyChanged.notify(this, "originalVerticalScale");
},
enumerable: true,
configurable: true
});
Object.defineProperty(BoundedTextItem.prototype, "originalHorizontalScale", {
get: function () {
return this._originalHorizontalScale;
},
set: function (value) {
if (this._originalHorizontalScale === value)
return;
this._originalHorizontalScale = value;
if (value != null)
this._propertyChanged.notify(this, "originalHorizontalScale");
},
enumerable: true,
configurable: true
});
Object.defineProperty(BoundedTextItem.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(BoundedTextItem.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
});
BoundedTextItem.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 == "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;
}
};
BoundedTextItem.prototype.equals = function (other) {
return _super.prototype.equals.call(this, 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);
};
BoundedTextItem.prototype.clone = function (generateNewIds, appropriateParentContainer) {
if (generateNewIds === void 0) { generateNewIds = false; }
if (appropriateParentContainer === void 0) { appropriateParentContainer = false; }
var 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);
return BoundedTextItem;
}(BaseTextItem));
export { BoundedTextItem };
//# sourceMappingURL=BoundedTextItem.js.map