SLineLegendItem.ts 1.8 KB

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