@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.
189 lines • 8.14 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 __());
};
})();
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";
var LineItem = /** @class */ (function (_super) {
__extends(LineItem, _super);
function LineItem(sourcePoint0, sourcePoint1) {
var _this = _super.call(this) || this;
_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;
return _this;
}
Object.defineProperty(LineItem.prototype, "width", {
get: function () {
return this._width;
},
set: function (value) {
if (Math.EqualsOfFloatNumbers(this._width, value))
return;
this._width = value;
this._propertyChanged.notify(this, "width");
},
enumerable: true,
configurable: true
});
Object.defineProperty(LineItem.prototype, "color", {
get: function () {
return this._color;
},
set: function (value) {
if (Color.equals(this._color, value))
return;
this._color = value;
this._propertyChanged.notify(this, "color");
},
enumerable: true,
configurable: true
});
Object.defineProperty(LineItem.prototype, "sourcePoint0", {
get: function () {
return this._sourcePoint0;
},
set: function (value) {
if (PointF.isEqual(this._sourcePoint0, value))
return;
this._sourcePoint0 = value;
this._propertyChanged.notify(this, "sourcePoint0");
},
enumerable: true,
configurable: true
});
Object.defineProperty(LineItem.prototype, "sourcePoint1", {
get: function () {
return this._sourcePoint1;
},
set: function (value) {
if (PointF.isEqual(this._sourcePoint1, value))
return;
this._sourcePoint1 = value;
this._propertyChanged.notify(this, "sourcePoint1");
},
enumerable: true,
configurable: true
});
Object.defineProperty(LineItem.prototype, "fixedWidth", {
get: function () {
return this._fixedWidth;
},
set: function (value) {
if (this._fixedWidth === value)
return;
this._fixedWidth = value;
this._propertyChanged.notify(this, "fixedWidth");
},
enumerable: true,
configurable: true
});
Object.defineProperty(LineItem.prototype, "linePermissions", {
get: function () {
return this._linePermissions;
},
set: function (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();
},
enumerable: true,
configurable: true
});
Object.defineProperty(LineItem.prototype, "overprintStroke", {
get: function () {
return this._overprintStroke;
},
set: function (value) {
if (value == this._overprintStroke)
return;
this._overprintStroke = value;
this._propertyChanged.notify(this, "overprintStroke");
},
enumerable: true,
configurable: true
});
LineItem.prototype._subscribeToPermissionChanged = function () {
this._linePermissions.propertyChanged.add(this._onPermissionsChanged);
};
LineItem.prototype._unsubscribeFromPermissionChanged = function () {
this._linePermissions.propertyChanged.remove(this._onPermissionsChanged);
};
LineItem.prototype.applyPermissionsConstrain = function () {
_super.prototype.applyPermissionsConstrain.call(this);
this.itemPermissions.itemToolbarPermissions.showEditButton = false;
this.itemPermissions.itemToolbarPermissions.showSelectButton = false;
if (this.isRenderTypeIsNormal)
return;
this.linePermissions.allowChangeLineColor = false;
};
LineItem.prototype.getSimplifiedObject = function (omitProperties) {
var simplified = _super.prototype.getSimplifiedObject.call(this, ["linePermissions"].concat(omitProperties));
simplified["linePermissions"] = this.linePermissions.getSimplifiedObject();
return simplified;
};
LineItem.prototype._copy = function (source, destination, generateNewIds, appropriateParentContainer) {
_super.prototype._copy.call(this, 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;
};
LineItem.prototype.equals = function (other) {
return _super.prototype.equals.call(this, 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);
};
LineItem.prototype.clone = function (generateNewIds, appropriateParentContainer) {
if (generateNewIds === void 0) { generateNewIds = false; }
if (appropriateParentContainer === void 0) { appropriateParentContainer = false; }
var item = new LineItem();
this._copy(this, item, generateNewIds, appropriateParentContainer);
return item;
};
LineItem.type = "LineItem";
return LineItem;
}(Item));
export { LineItem };
//# sourceMappingURL=LineItem.js.map