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.

308 lines 14.2 kB
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 { Item } from "./Item"; import { Path } from "../../Math/Path"; import { RectangleF } from "../../Math/RectangleF"; import { ShapePermissions } from "./ShapePermissions"; import { ResizeGripsPermissions } from "./ResizeGripsPermissions"; import { Color, RgbColor, RgbColors } from "../../Colors"; import { EventObject } from "../../EventObject"; import { ArgumentException } from "../../Exception"; import * as _ from "underscore"; import { equals } from "../../Utils/Utils"; import { Property } from "../Decorators/Property"; import { ShapeViolationSettings } from "./ShapeViolationSettings"; import { ColorPropertyFactory } from "../Decorators/Factory"; var ShapeItem = /** @class */ (function (_super) { __extends(ShapeItem, _super); function ShapeItem(sourcePath) { var _this = _super.call(this) || this; _this._borderWidth = 1; _this._fillColor = new RgbColor(112, 112, 112, 255); _this._borderColor = RgbColors.black; _this._altBorderColor = null; _this._dash = []; _this._fixedBorderWidth = false; _this._overprintStroke = false; _this._overprintFill = false; _this.sourcePathId = null; _this.sourcePathLoaded = false; _this._stubPath = null; _this._pathLoadedEvent = new EventObject(); _this.type = ShapeItem.type; _this.sourcePath = sourcePath != null ? sourcePath : new Path(""); _this.sourceRectangle = new RectangleF(0, 0, 10, 10); _this.shapePermissions = new ShapePermissions(); _this._setViolationSettings(new ShapeViolationSettings(), true); _this._ignorePermissionsChange = true; _this.manipulationPermissions.resizeGrips = new ResizeGripsPermissions(true, true); _this.itemPermissions.itemToolbarPermissions.showEditButton = false; _this.itemPermissions.itemToolbarPermissions.showSelectButton = false; _this._ignorePermissionsChange = false; return _this; } Object.defineProperty(ShapeItem.prototype, "fixedBorderWidth", { get: function () { return this._fixedBorderWidth; }, set: function (value) { if (this._fixedBorderWidth !== value) { this._fixedBorderWidth = value; this._propertyChanged.notify(this, "fixedBorderWidth"); } }, enumerable: true, configurable: true }); Object.defineProperty(ShapeItem.prototype, "borderWidth", { get: function () { return this._borderWidth; }, set: function (value) { if (this._borderWidth !== value) { this._borderWidth = value; this._propertyChanged.notify(this, "borderWidth"); } }, enumerable: true, configurable: true }); Object.defineProperty(ShapeItem.prototype, "sourcePath", { get: function () { return this._sourcePath; }, set: function (value) { if (equals(this._sourcePath, value)) return; this._sourcePath = value; if (this.sourcePathLoaded !== true) this._propertyChanged.notify(this, "sourcePath"); }, enumerable: true, configurable: true }); Object.defineProperty(ShapeItem.prototype, "sourceRectangle", { get: function () { return this._sourceRectangle; }, set: function (value) { if (RectangleF.isEqual(this._sourceRectangle, value)) return; this._sourceRectangle = value; this._propertyChanged.notify(this, "sourceRectangle"); }, enumerable: true, configurable: true }); Object.defineProperty(ShapeItem.prototype, "borderColor", { get: function () { return this._borderColor; }, set: function (value) { if (!Color.equals(this._borderColor, value)) { this._borderColor = value; this._propertyChanged.notify(this, "borderColor"); } }, enumerable: true, configurable: true }); Object.defineProperty(ShapeItem.prototype, "overprintStroke", { get: function () { return this._overprintStroke; }, set: function (value) { if (this._overprintStroke === value) return; this._overprintStroke = value; this._propertyChanged.notify(this, "overprintStroke"); }, enumerable: true, configurable: true }); Object.defineProperty(ShapeItem.prototype, "fillColor", { get: function () { return this._fillColor; }, set: function (value) { if (!Color.equals(this._fillColor, value)) { this._fillColor = value; this._propertyChanged.notify(this, "fillColor"); } }, enumerable: true, configurable: true }); Object.defineProperty(ShapeItem.prototype, "overprintFill", { get: function () { return this._overprintFill; }, set: function (value) { if (this._overprintFill === value) return; this._overprintFill = value; this._propertyChanged.notify(this, "overprintFill"); }, enumerable: true, configurable: true }); Object.defineProperty(ShapeItem.prototype, "altBorderColor", { get: function () { return this._altBorderColor; }, set: function (value) { if (!Color.equals(this._altBorderColor, value)) { this._altBorderColor = value; this._propertyChanged.notify(this, "altBorderColor"); } }, enumerable: true, configurable: true }); Object.defineProperty(ShapeItem.prototype, "dash", { get: function () { return this._dash; }, set: function (value) { if (!_.isEqual(this._dash, value)) { this._dash = value; this._propertyChanged.notify(this, "dash"); } }, enumerable: true, configurable: true }); ShapeItem.prototype.applyPermissionsConstrain = function () { _super.prototype.applyPermissionsConstrain.call(this); this.itemPermissions.itemToolbarPermissions.showEditButtonConstraint = false; this.itemPermissions.itemToolbarPermissions.showSelectButtonConstraint = false; if (this.isRenderTypeIsNormal) return; this.shapePermissions.allowChangeBorderColor = false; this.shapePermissions.allowChangeFillColor = false; }; Object.defineProperty(ShapeItem.prototype, "shapePermissions", { get: function () { return this._shapePermissions; }, set: function (value) { if (value == null) throw new ArgumentException("shapePermissions cannot be null"); if (equals(this._shapePermissions, value)) return; if (this._shapePermissions != null) this._shapePermissions.propertyChanged.remove(this._onPermissionsChanged); this._shapePermissions = value; this.applyPermissionsConstrain(); this._shapePermissions.propertyChanged.add(this._onPermissionsChanged); this._propertyChanged.notify(this, "shapePermissions"); }, enumerable: true, configurable: true }); Object.defineProperty(ShapeItem.prototype, "violationSettings", { get: function () { return this._violationSettings; }, set: function (value) { this._setViolationSettings(value); }, enumerable: true, configurable: true }); ShapeItem.prototype._setViolationSettings = function (value, skipTypeCheck) { if (skipTypeCheck === void 0) { skipTypeCheck = false; } if (!skipTypeCheck && !(value instanceof ShapeViolationSettings)) throw new ArgumentException("Shape ViolationSettings property must has ShapeViolationSettings type!"); _super.prototype._setViolationSettings.call(this, value, skipTypeCheck); }; ShapeItem.prototype._copy = function (source, destination, generateNewIds, appropriateParentContainer) { _super.prototype._copy.call(this, source, destination, generateNewIds, appropriateParentContainer); destination.shapePermissions = source._shapePermissions != null ? source._shapePermissions.clone() : null; destination._stubPath = source._stubPath != null ? source._stubPath.clone() : null; destination.dash = _.clone(source._dash); destination.altBorderColor = source._altBorderColor != null ? source._altBorderColor.clone() : null; destination.fillColor = source._fillColor != null ? source._fillColor.clone() : null; destination.borderColor = source._borderColor != null ? source._borderColor.clone() : null; destination.sourceRectangle = source._sourceRectangle != null ? source._sourceRectangle.clone() : null; if (source.sourcePathId != null) { destination.sourcePathId = source.sourcePathId; } else { destination.sourcePath = source._sourcePath != null ? source._sourcePath.clone() : null; } destination.borderWidth = source._borderWidth; destination.fixedBorderWidth = source.fixedBorderWidth; destination.overprintStroke = source.overprintStroke; destination.overprintFill = source.overprintFill; }; ShapeItem.prototype.equals = function (other) { var superEquals = _super.prototype.equals.call(this, other); var shapePermissionsEq = equals(this._shapePermissions, other._shapePermissions); var stubPathEq = equals(this._stubPath, other._stubPath); var dashEq = equals(this._dash, other._dash); var altBorderColorEq = equals(this._altBorderColor, other._altBorderColor); var fillColorEq = equals(this._fillColor, other._fillColor); var borderColorEq = equals(this._borderColor, other._borderColor); var sourceRectEq = equals(this._sourceRectangle, other._sourceRectangle); var sourcePathIdEq = equals(this.sourcePathId, other.sourcePathId); var sourcePathEq = equals(this._sourcePath, other._sourcePath); var borderWidthEq = equals(this._borderWidth, other._borderWidth); var fixedBorderWidthEq = equals(this._fixedBorderWidth, other._fixedBorderWidth); var overprintStrokeEq = equals(this._overprintStroke, other._overprintStroke); var overprintFillEq = equals(this._overprintFill, other._overprintFill); return superEquals && shapePermissionsEq && stubPathEq && dashEq && altBorderColorEq && fillColorEq && borderColorEq && sourceRectEq && sourcePathIdEq && sourcePathEq && borderWidthEq && fixedBorderWidthEq && overprintStrokeEq && overprintFillEq; }; ShapeItem.prototype.clone = function (generateNewIds, appropriateParentContainer) { if (generateNewIds === void 0) { generateNewIds = false; } if (appropriateParentContainer === void 0) { appropriateParentContainer = false; } var item = new ShapeItem(); this._copy(this, item, generateNewIds, appropriateParentContainer); return item; }; ShapeItem.prototype.getSimplifiedObject = function (omitProperties) { var simplified = _super.prototype.getSimplifiedObject.call(this, ["shapePermissions"].concat(omitProperties)); simplified["shapePermissions"] = this.shapePermissions.getSimplifiedObject(); if (this.sourcePathId == null) simplified["sourcePath"] = this.sourcePath != null ? this.sourcePath.toString() : null; else simplified["sourcePath"] = null; return simplified; }; ShapeItem.prototype._onPathLoaded = function () { this._pathLoadedEvent.notify(this); }; ShapeItem.prototype.getPathLoadedEvent = function () { return this._pathLoadedEvent; }; ShapeItem.type = "ShapeItem"; __decorate([ Property({ factory: new ColorPropertyFactory(), displayName: "Alternative border color" }), __metadata("design:type", Color), __metadata("design:paramtypes", [Color]) ], ShapeItem.prototype, "altBorderColor", null); return ShapeItem; }(Item)); export { ShapeItem }; //# sourceMappingURL=ShapeItem.js.map