SImageMarkerItem.ts 1.2 KB

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