UNPKG

@aurigma/design-atoms

Version:

Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.

127 lines 5.25 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 __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; }; var __spread = (this && this.__spread) || function () { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); return ar; }; import { LineItemHandler } from "./LineItemHandler"; import { Graphics } from "../Graphics"; var DashedLineItemHandler = /** @class */ (function (_super) { __extends(DashedLineItemHandler, _super); function DashedLineItemHandler(item, textWhizz, colorPreviewService) { if (textWhizz === void 0) { textWhizz = null; } return _super.call(this, item, textWhizz, colorPreviewService) || this; } Object.defineProperty(DashedLineItemHandler.prototype, "item", { get: function () { return this._getItem(); }, enumerable: true, configurable: true }); Object.defineProperty(DashedLineItemHandler.prototype, "dashWidth", { get: function () { return this.item.dashWidth; }, set: function (value) { this.item.dashWidth = value; }, enumerable: true, configurable: true }); Object.defineProperty(DashedLineItemHandler.prototype, "altDashWidth", { get: function () { return this.item.altDashWidth; }, set: function (value) { this.item.altDashWidth = value; }, enumerable: true, configurable: true }); Object.defineProperty(DashedLineItemHandler.prototype, "altColor", { get: function () { return this.item.altColor; }, set: function (value) { this.item.altColor = value; }, enumerable: true, configurable: true }); DashedLineItemHandler.prototype.drawItemHandler = function (itemHandlerCtx) { var width = this._getActualWidth(); if (itemHandlerCtx == null || width <= 0) { return; } if (!this._isReadyToDraw) { this.canvas.drawWaitClock(itemHandlerCtx, this.rectangle.center); return; } var _a = this._getItemColorPreviews(), colorPreview = _a.colorPreview, altColorPreview = _a.altColorPreview; var startPoint = this.point0; var endPoint = this.point1; var dashWidth = this.dashWidth; var altDashWidth = this.altDashWidth; if (this.fixedWidth) { var zoom = this.canvas.zoom; dashWidth /= zoom; altDashWidth /= zoom; } Graphics.drawDashedLine(itemHandlerCtx, startPoint.x, startPoint.y, endPoint.x, endPoint.y, width, colorPreview === null || colorPreview === void 0 ? void 0 : colorPreview.toString(), altColorPreview === null || altColorPreview === void 0 ? void 0 : altColorPreview.toString(), dashWidth, altDashWidth, this.item.opacity); }; DashedLineItemHandler.prototype._getColors = function () { return __spread([this.color, this.altColor], _super.prototype._getColors.call(this)); }; DashedLineItemHandler.prototype._getItemColorPreviews = function () { var colorPreview = _super.prototype._getItemColorPreviews.call(this).colorPreview; var altColorPreview = this._colorPreviewService.getPreview(this.item.altColor); if (this.item.altColor != null && altColorPreview == null) { this._colorPreviewService.subscribeToPreviewLoaded(this.item.altColor, this._onColorPreviewLoaded); } return { colorPreview: colorPreview, altColorPreview: altColorPreview }; }; DashedLineItemHandler.prototype._onItemPropertyChanged = function (sender, propertyName) { switch (propertyName) { case "altColor": case "dashWidth": case "altDashWidth": this.canvas.redraw(); break; } _super.prototype._onItemPropertyChanged.call(this, sender, propertyName); }; return DashedLineItemHandler; }(LineItemHandler)); export { DashedLineItemHandler }; //# sourceMappingURL=DashedLineItemHandler.js.map