SGraphyImgItem.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. var __extends = (this && this.__extends) || (function () {
  2. var extendStatics = function (d, b) {
  3. extendStatics = Object.setPrototypeOf ||
  4. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6. return extendStatics(d, b);
  7. };
  8. return function (d, b) {
  9. extendStatics(d, b);
  10. function __() { this.constructor = d; }
  11. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  12. };
  13. })();
  14. import { SGraphyItem } from '@sybotan-web/graphy';
  15. import { SRect } from "@sybotan-web/base";
  16. /**
  17. * 图形Item类 todo
  18. *
  19. */
  20. var SGraphyImgItem = /** @class */ (function (_super) {
  21. __extends(SGraphyImgItem, _super);
  22. /**
  23. * 构造函数
  24. *
  25. * @param width 图片宽度
  26. * @param height 图片高度
  27. * @param imgSource 图片源
  28. * @param X 图片向x轴的偏移量
  29. * @param Y 图片向y轴的偏移量
  30. * @param parent 指向父元素
  31. */
  32. function SGraphyImgItem(parent, imgSource, X, Y, width, height) {
  33. var _this = _super.call(this, parent) || this;
  34. _this.width = 0;
  35. _this.height = 0;
  36. _this.imgSource = imgSource;
  37. _this.X = X;
  38. _this.Y = Y;
  39. _this.width = width;
  40. _this.height = height;
  41. _this.img = new Image();
  42. _this.img.src = _this.imgSource;
  43. return _this;
  44. } // Constructor()
  45. /**
  46. * Item对象边界区域
  47. *
  48. * @return SRect
  49. */
  50. SGraphyImgItem.prototype.boundingRect = function () {
  51. return new SRect(this.X, this.Y, this.width, this.height);
  52. }; // Function boundingRect()
  53. // contains(x: number, y: number): boolean {
  54. // return this.boundingRect().contains(x - this.X, y - this.Y);
  55. // }
  56. SGraphyImgItem.prototype.onClick = function (event) {
  57. this.$emit('click', event);
  58. return true;
  59. }; // Function onClick()
  60. /**
  61. * 鼠标双击事件
  62. *
  63. * @param event 保存事件参数
  64. * @return boolean
  65. */
  66. SGraphyImgItem.prototype.onDoubleClick = function (event) {
  67. this.$emit('doubleClick', event);
  68. return true;
  69. };
  70. /**
  71. * 鼠标按下事件
  72. *
  73. * @param event 保存事件参数
  74. * @return boolean
  75. */
  76. SGraphyImgItem.prototype.onMouseDown = function (event) {
  77. this.$emit('mouseDown', event);
  78. return true;
  79. }; // Function onMouseDown()
  80. /**
  81. * 鼠标移动事件
  82. *
  83. * @param event 保存事件参数
  84. * @return boolean
  85. */
  86. SGraphyImgItem.prototype.onMouseMove = function (event) {
  87. this.$emit('mouseMove', event);
  88. return true;
  89. }; // Function onMouseMove()
  90. /**
  91. * 释放鼠标事件
  92. *
  93. * @param event 保存事件参数
  94. * @return boolean
  95. */
  96. SGraphyImgItem.prototype.onMouseUp = function (event) {
  97. this.$emit('mouseUp', event);
  98. return true;
  99. };
  100. /**
  101. * Item绘制操作
  102. *
  103. * @param painter painter对象
  104. * @param rect 绘制区域
  105. */
  106. SGraphyImgItem.prototype.onDraw = function (painter, rect) {
  107. painter.drawImage(this.img, this.X, this.Y, this.width, this.height);
  108. };
  109. return SGraphyImgItem;
  110. }(SGraphyItem)); // Class SGraphyImgItem
  111. export { SGraphyImgItem };