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 { SGraphyItem } from '@sybotan-web/graphy'; import { SRect } from "@sybotan-web/base"; /** * 图形Item类 todo * */ var SGraphyImgItem = /** @class */ (function (_super) { __extends(SGraphyImgItem, _super); /** * 构造函数 * * @param width 图片宽度 * @param height 图片高度 * @param imgSource 图片源 * @param X 图片向x轴的偏移量 * @param Y 图片向y轴的偏移量 * @param parent 指向父元素 */ function SGraphyImgItem(parent, imgSource, X, Y, width, height) { var _this = _super.call(this, parent) || this; _this.width = 0; _this.height = 0; _this.imgSource = imgSource; _this.X = X; _this.Y = Y; _this.width = width; _this.height = height; _this.img = new Image(); _this.img.src = _this.imgSource; return _this; } // Constructor() /** * Item对象边界区域 * * @return SRect */ SGraphyImgItem.prototype.boundingRect = function () { return new SRect(this.X, this.Y, this.width, this.height); }; // Function boundingRect() // contains(x: number, y: number): boolean { // return this.boundingRect().contains(x - this.X, y - this.Y); // } SGraphyImgItem.prototype.onClick = function (event) { this.$emit('click', event); return true; }; // Function onClick() /** * 鼠标双击事件 * * @param event 保存事件参数 * @return boolean */ SGraphyImgItem.prototype.onDoubleClick = function (event) { this.$emit('doubleClick', event); return true; }; /** * 鼠标按下事件 * * @param event 保存事件参数 * @return boolean */ SGraphyImgItem.prototype.onMouseDown = function (event) { this.$emit('mouseDown', event); return true; }; // Function onMouseDown() /** * 鼠标移动事件 * * @param event 保存事件参数 * @return boolean */ SGraphyImgItem.prototype.onMouseMove = function (event) { this.$emit('mouseMove', event); return true; }; // Function onMouseMove() /** * 释放鼠标事件 * * @param event 保存事件参数 * @return boolean */ SGraphyImgItem.prototype.onMouseUp = function (event) { this.$emit('mouseUp', event); return true; }; /** * Item绘制操作 * * @param painter painter对象 * @param rect 绘制区域 */ SGraphyImgItem.prototype.onDraw = function (painter, rect) { painter.drawImage(this.img, this.X, this.Y, this.width, this.height); }; return SGraphyImgItem; }(SGraphyItem)); // Class SGraphyImgItem export { SGraphyImgItem };