@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.
68 lines • 2.47 kB
JavaScript
import { Item } from "./Item";
import { PointF } from "../../Math/PointF";
import { WrappingMode } from "./WrappingMode";
import { Color, RgbColor } from "../../Colors";
import { EqualsOfFloatNumbers } from "../../Math/Common";
import { equals } from "../../Utils/Utils";
import { arraysIsEqual } from "@aurigma/utils-js/algorithms/array";
export class PolylineItem extends Item {
constructor(points) {
super();
this._width = 20;
this._color = new RgbColor(255, 255, 61, 255);
this._points = [];
this.type = PolylineItem.type;
this._points = [];
if (points && points.length && points.length > 0) {
for (var i = 0; i < points.length; i++) {
if (points[i] instanceof PointF)
this._points.push(points[i]);
}
}
this.textWrappingMode = WrappingMode.None;
}
get width() {
return this._width;
}
set width(value) {
if (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 sourcePoints() {
return this._points;
}
set sourcePoints(value) {
this._points = value;
this._propertyChanged.notify(this, "sourcePoints");
}
_copy(source, destination, generateNewIds, appropriateParentContainer) {
super._copy(source, destination, generateNewIds, appropriateParentContainer);
destination.width = source.width;
destination.color = source.color.clone();
destination.sourcePoints = source.sourcePoints.map(p => p.clone());
}
equals(other) {
return super.equals(other) &&
equals(this._width, other._width) &&
equals(this._color, other._color) &&
arraysIsEqual(this._points, other._points, equals);
}
clone(generateNewIds = false, appropriateParentContainer = false) {
const item = new PolylineItem();
this._copy(this, item, generateNewIds, appropriateParentContainer);
return item;
}
}
PolylineItem.type = "PolylineItem";
//# sourceMappingURL=PolylineItem.js.map