SLineLegendItem.js 1.4 KB

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