SLineMarkerItem.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { SGraphItem } from "@saga-web/graph/lib";
  2. import { SPoint } from "@saga-web/draw/lib";
  3. import { SLineItem, ItemOrder } 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.zOrder = ItemOrder.lineOrder;
  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 && data.Properties.Line) {
  27. let setPointList: SPoint[];
  28. setPointList = data.Properties.Line.map(i => {
  29. return new SPoint(i.X, i.Y)
  30. })
  31. this.line = setPointList;
  32. }
  33. if (data.Properties && data.Properties.LineWidth) {
  34. this.lineWidth = data.Properties.LineWidth;
  35. }
  36. if (data.Properties && data.Properties.LineStyle) {
  37. this.lineStyle = data.Properties.LineStyle;
  38. }
  39. if (data.Properties && data.Properties.StrokeColor) {
  40. this.strokeColor = data.Properties.StrokeColor;
  41. }
  42. } // Constructor
  43. toData(): Marker {
  44. this.data.Pos = {X: this.x, Y: this.y};
  45. this.data.Properties.Line = this.line.map(pos => {
  46. return {
  47. X: pos.x,
  48. Y: pos.y
  49. }
  50. });
  51. this.data.Properties.LineWidth = this.lineWidth;
  52. this.data.Properties.StrokeColor = this.strokeColor;
  53. this.data.Properties.LineStyle = this.lineStyle;
  54. return this.data;
  55. }
  56. } // Class SLineMarkerItem