SLineLegendItem.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // @ts-nocheck
  2. import { SGraphItem } from "@saga-web/graph/lib";
  3. import { SPoint } from "@saga-web/draw/lib";
  4. import { SPolylineItem } from '@saga-web/big/lib';
  5. import { Legend } from '../types/Legend';
  6. /**
  7. * 图例节点Item(线类型)
  8. *
  9. * * @author 张宇(taohuzy@163.com)
  10. */
  11. export class SLineLegendItem extends SPolylineItem {
  12. /** 图例节点对象数据 */
  13. data: Legend;
  14. /**
  15. * 构造函数
  16. *
  17. * @param parent 指向父对象
  18. * @param data 图例节点对象数据
  19. */
  20. constructor(parent: SGraphItem | null, data: Legend) {
  21. super(parent,[]);
  22. this.data = data;
  23. this.id = data.ID;
  24. this.name = data.Name;
  25. this.moveTo(data.Pos.X, data.Pos.Y);
  26. if (data.Properties.Zorder) {
  27. this.zOrder = data.Properties.Zorder;
  28. }
  29. if (data.Properties && data.Properties.Line) {
  30. let setPointList: SPoint[];
  31. setPointList = data.Properties.Line.map(i => {
  32. return new SPoint(i.x, i.y)
  33. })
  34. this.pointList = setPointList;
  35. }
  36. if (data.Properties && data.Properties.LineWidth) {
  37. this.lineWidth = data.Properties.LineWidth;
  38. }
  39. if (data.Properties && data.Properties.StrokeColor) {
  40. this.strokeColor = data.Properties.StrokeColor;
  41. }
  42. }
  43. toData(): Legend {
  44. this.data.Pos = {X: this.x, Y: this.y};
  45. this.data.Properties.Line = this.pointList.map(pos => {
  46. return {
  47. X: pos.x,
  48. Y: pos.y
  49. }
  50. });
  51. this.data.Properties.Zorder = this.zOrder;
  52. this.data.Properties.LineWidth = this.lineWidth;
  53. this.data.Properties.StrokeColor = this.strokeColor;
  54. return this.data;
  55. }
  56. } // Class SLineLegendItem