"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SImageMarkerItem = void 0; const lib_1 = require("@persagy-web/graph/lib"); class SImageMarkerItem extends lib_1.SImageItem { constructor(parent, data) { super(parent); this._scaleX = 1; this._scaleY = 1; this._rolate = 0; this.data = data; this.moveTo(data.Pos.X, data.Pos.Y); if (this.data.Scale) { this.scaleX = this.data.Scale.X; this.scaleY = this.data.Scale.Y; } if (this.data.Rolate && this.data.Rolate.Z) { this.rolate = this.data.Rolate.Z; } if (this.data.Size) { this.width = this.data.Size.Width; this.height = this.data.Size.Height; } if (this.data.Properties && this.data.Properties.Url) { if (this.data.Properties.Url instanceof String) { this.url = this.data.Properties.Url; } } } get scaleX() { return this._scaleX; } set scaleX(v) { this._scaleX = v; if (this.data.Scale) { this.data.Scale.X = v; } this.update(); } get scaleY() { return this._scaleY; } set scaleY(v) { this._scaleY = v; if (this.data.Scale) { this.data.Scale.Y = v; } this.update(); } get rolate() { return this._rolate; } set rolate(v) { this._rolate = v; if (this.data.Rolate) { this.data.Rolate.Z = v; } this.update(); } set name(v) { this.data.Name = v; } set url(v) { if (this.data.Properties) { this.data.Properties.Url = v; } } set x(v) { this.data.Pos.X = v; } set y(v) { this.data.Pos.Y = v; } set width(v) { if (this.data.Size) { this.data.Size.Width = v; } } set height(v) { if (this.data.Size) { this.data.Size.Height = v; } } onDraw(painter) { if (this.img) { let width = 0; let height = 0; let itemAspectRatio = this.width / this.height; let imgAspectRatio = this.img.width / this.img.height; let imgHwRatio = this.img.height / this.img.width; if (this.showType == lib_1.SImageShowType.Full) { width = this.width; height = this.height; } else if (this.showType == lib_1.SImageShowType.Equivalency) { if (itemAspectRatio > imgAspectRatio) { height = this.height; width = imgAspectRatio * height; } else if (itemAspectRatio < imgAspectRatio) { width = this.width; height = width * imgHwRatio; } else { width = this.width; height = this.height; } } else if (this.showType == lib_1.SImageShowType.AutoFit) { this.width = this.img.width; this.height = this.img.height; width = this.width; height = this.height; } painter.scale(this.scaleX, this.scaleY); painter.rotate(this.rolate); painter.drawImage(this.img, -width / 2, -height / 2, width, height); } } } exports.SImageMarkerItem = SImageMarkerItem;