STextMarkerItem.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { SGraphItem, STextItem, SLineStyle } from "@saga-web/graph/lib";
  2. import { SPainter, SColor,SFont } from "@saga-web/draw";
  3. import { Marker } from '../types/Marker';
  4. import { ItemOrder } from '@saga-web/big/lib';
  5. /**
  6. * 标识对象Item(文本类型)
  7. *
  8. * * @author 张宇(taohuzy@163.com)
  9. */
  10. export class STextMarkerItem extends STextItem {
  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.textOrder;
  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.Size) {
  27. this.width = data.Size.Width;
  28. this.height = data.Size.Height;
  29. }
  30. if (data.Properties && data.Properties.Text) {
  31. this.text = data.Properties.Text;
  32. }
  33. if (data.Properties && data.Properties.Color) {
  34. this.color = new SColor(data.Properties.Color);
  35. }
  36. if (data.Properties && data.Properties.Font) {
  37. this.font = new SFont("sans-serif", data.Properties.Font);;
  38. }
  39. if (data.Properties && data.Properties.BackgroundColor) {
  40. this.backgroundColor = new SColor(data.Properties.BackgroundColor);
  41. }
  42. } // Constructor
  43. toData(): Marker {
  44. this.data.Pos = {X: this.x, Y: this.y};
  45. this.data.Size = {Width: this.width, Height: this.height};
  46. this.data.Properties.Text = this.text;
  47. this.data.Properties.Color = this.color.value;
  48. this.data.Properties.Font = this.font.size;
  49. this.data.Properties.BackgroundColor = this.backgroundColor.value;
  50. return this.data;
  51. }
  52. } // Class STextMarkerItem