image.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { __assign, __extends } from "tslib";
  2. import GroupComponent from '../abstract/group-component';
  3. import { regionToBBox } from '../util/util';
  4. var ImageAnnotation = /** @class */ (function (_super) {
  5. __extends(ImageAnnotation, _super);
  6. function ImageAnnotation() {
  7. return _super !== null && _super.apply(this, arguments) || this;
  8. }
  9. /**
  10. * @protected
  11. * 默认的配置项
  12. * @returns {object} 默认的配置项
  13. */
  14. ImageAnnotation.prototype.getDefaultCfg = function () {
  15. var cfg = _super.prototype.getDefaultCfg.call(this);
  16. return __assign(__assign({}, cfg), { name: 'annotation', type: 'image', locationType: 'region', start: null, end: null, src: null, style: {} });
  17. };
  18. ImageAnnotation.prototype.renderInner = function (group) {
  19. this.renderImage(group);
  20. };
  21. ImageAnnotation.prototype.getImageAttrs = function () {
  22. var start = this.get('start');
  23. var end = this.get('end');
  24. var style = this.get('style');
  25. var bbox = regionToBBox({ start: start, end: end });
  26. var src = this.get('src');
  27. return __assign({ x: bbox.x, y: bbox.y, img: src, width: bbox.width, height: bbox.height }, style);
  28. };
  29. // 绘制图片
  30. ImageAnnotation.prototype.renderImage = function (group) {
  31. this.addShape(group, {
  32. type: 'image',
  33. id: this.getElementId('image'),
  34. name: 'annotation-image',
  35. attrs: this.getImageAttrs(),
  36. });
  37. };
  38. return ImageAnnotation;
  39. }(GroupComponent));
  40. export default ImageAnnotation;
  41. //# sourceMappingURL=image.js.map