SImageMarkerItem.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { SGraphItem, SImageItem } from "@saga-web/graph/lib";
  2. import { SPainter } from "@saga-web/draw";
  3. import { Marker } from '../types/Marker';
  4. import { ItemOrder } from '@saga-web/big/lib';
  5. /**
  6. * 标识对象Item(图标类型)
  7. *
  8. * * @author 张宇(taohuzy@163.com)
  9. */
  10. export class SImageMarkerItem extends SImageItem {
  11. /** 标识对象数据 */
  12. data: Marker;
  13. /**
  14. * 构造函数
  15. *
  16. * @param parent 指向父对象
  17. * @param data 标识对象数据
  18. */
  19. constructor(parent: SGraphItem | null, data: Marker) {
  20. super(parent);
  21. this.zOrder = ItemOrder.imageOrder;
  22. this.isTransform = false;
  23. this.data = data;
  24. this.id = data.ID;
  25. this.name = data.Name;
  26. this.moveTo(data.Pos.X, data.Pos.Y);
  27. if (data.Size) {
  28. this.width = data.Size.Width;
  29. this.height = data.Size.Height;
  30. }
  31. if (data.Properties && data.Properties.Url) {
  32. this.url = data.Properties.Url;
  33. }
  34. } // Constructor
  35. toData(): Marker {
  36. this.data.Pos = {X: this.x, Y: this.y};
  37. this.data.Size = {Width: this.width, Height: this.height};
  38. this.data.Properties.Url = this.url;
  39. return this.data;
  40. }
  41. } // Class SImageMarkerItem