SImageMarkerItem.ts 1.8 KB

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