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.

142 lines 5.74 kB
import { Item } from "./Item"; import { PointF } from "../../Math/PointF"; import { LinePermissions } from "./LinePermissions"; import { Color, RgbColors } from "../../Colors"; import { ArgumentException } from "../../Exception"; import * as Math from "../../Math/Common"; import { equals } from "../../Utils/Utils"; export class LineItem extends Item { constructor(sourcePoint0, sourcePoint1) { super(); this._width = 4; this._color = RgbColors.black; this._sourcePoint0 = new PointF(); this._sourcePoint1 = new PointF(); this._fixedWidth = false; this._overprintStroke = false; this.lineColorForAbnormalRendering = RgbColors.black; this.type = LineItem.type; this._sourcePoint0 = sourcePoint0 != null ? sourcePoint0 : new PointF(); this._sourcePoint1 = sourcePoint1 != null ? sourcePoint1 : new PointF(); this._linePermissions = new LinePermissions(); this._linePermissions.propertyChanged.add(this._onPermissionsChanged); this._ignorePermissionsChange = true; this.itemPermissions.itemToolbarPermissions.showEditButton = false; this.itemPermissions.itemToolbarPermissions.showSelectButton = false; this._ignorePermissionsChange = false; } get width() { return this._width; } set width(value) { if (Math.EqualsOfFloatNumbers(this._width, value)) return; this._width = value; this._propertyChanged.notify(this, "width"); } get color() { return this._color; } set color(value) { if (Color.equals(this._color, value)) return; this._color = value; this._propertyChanged.notify(this, "color"); } get sourcePoint0() { return this._sourcePoint0; } set sourcePoint0(value) { if (PointF.isEqual(this._sourcePoint0, value)) return; this._sourcePoint0 = value; this._propertyChanged.notify(this, "sourcePoint0"); } get sourcePoint1() { return this._sourcePoint1; } set sourcePoint1(value) { if (PointF.isEqual(this._sourcePoint1, value)) return; this._sourcePoint1 = value; this._propertyChanged.notify(this, "sourcePoint1"); } get fixedWidth() { return this._fixedWidth; } set fixedWidth(value) { if (this._fixedWidth === value) return; this._fixedWidth = value; this._propertyChanged.notify(this, "fixedWidth"); } get linePermissions() { return this._linePermissions; } set linePermissions(value) { if (value == null) { throw new ArgumentException("linePermissions cannot be null"); } if (equals(this._linePermissions, value)) return; this._linePermissions.propertyChanged.remove(this._onPermissionsChanged); this._linePermissions = value; this._linePermissions.propertyChanged.add(this._onPermissionsChanged); this._onPermissionsChanged(); } get overprintStroke() { return this._overprintStroke; } set overprintStroke(value) { if (value == this._overprintStroke) return; this._overprintStroke = value; this._propertyChanged.notify(this, "overprintStroke"); } _subscribeToPermissionChanged() { this._linePermissions.propertyChanged.add(this._onPermissionsChanged); } _unsubscribeFromPermissionChanged() { this._linePermissions.propertyChanged.remove(this._onPermissionsChanged); } applyPermissionsConstrain() { super.applyPermissionsConstrain(); this.itemPermissions.itemToolbarPermissions.showEditButton = false; this.itemPermissions.itemToolbarPermissions.showSelectButton = false; if (this.isRenderTypeIsNormal) return; this.linePermissions.allowChangeLineColor = false; } getSimplifiedObject(omitProperties) { const simplified = super.getSimplifiedObject(["linePermissions"].concat(omitProperties)); simplified["linePermissions"] = this.linePermissions.getSimplifiedObject(); return simplified; } _copy(source, destination, generateNewIds, appropriateParentContainer) { super._copy(source, destination, generateNewIds, appropriateParentContainer); destination.width = source.width; destination.color = source.color.clone(); destination.sourcePoint0 = source.sourcePoint0.clone(); destination.sourcePoint1 = source.sourcePoint1.clone(); destination.fixedWidth = source.fixedWidth; destination.linePermissions = source._linePermissions != null ? source._linePermissions.clone() : null; destination.overprintStroke = source.overprintStroke; } equals(other) { return super.equals(other) && equals(this._width, other._width) && equals(this._color, other._color) && equals(this._sourcePoint0, other._sourcePoint0) && equals(this._sourcePoint1, other._sourcePoint1) && equals(this._fixedWidth, other._fixedWidth) && equals(this._linePermissions, other._linePermissions) && equals(this._overprintStroke, other._overprintStroke); } clone(generateNewIds = false, appropriateParentContainer = false) { const item = new LineItem(); this._copy(this, item, generateNewIds, appropriateParentContainer); return item; } } LineItem.type = "LineItem"; //# sourceMappingURL=LineItem.js.map