SLineMarkerItem.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { SGraphItem } from "@saga-web/graph/lib";
  2. import { SPoint } from "@saga-web/draw/lib";
  3. import { SLineItem } from '@saga-web/big/lib';
  4. import { Marker } from '../types/Marker';
  5. /**
  6. * 标识对象Item(线类型)
  7. *
  8. * * @author 张宇(taohuzy@163.com)
  9. */
  10. export class SLineMarkerItem extends SLineItem {
  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.data = data;
  22. this.id = data.ID;
  23. this.name = data.Name;
  24. this.moveTo(data.Pos.X, data.Pos.Y);
  25. if (data.Properties && data.Properties.Line) {
  26. this.line = data.Properties.Line;
  27. }
  28. if (data.Properties && data.Properties.LineWidth) {
  29. this.lineWidth = data.Properties.LineWidth;
  30. }
  31. if (data.Properties && data.Properties.LineStyle) {
  32. this.lineStyle = data.Properties.LineStyle;
  33. }
  34. if (data.Properties && data.Properties.StrokeColor) {
  35. this.strokeColor = data.Properties.StrokeColor;
  36. }
  37. } // Constructor
  38. toData(): Marker {
  39. this.data.Pos = {X: this.x, Y: this.y};
  40. this.data.Properties.Line = this.line;
  41. this.data.Properties.LineWidth = this.lineWidth;
  42. this.data.Properties.StrokeColor = this.strokeColor;
  43. this.data.Properties.LineStyle = this.lineStyle;
  44. return this.data;
  45. }
  46. } // Class SLineMarkerItem