SImageLegendItem.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import { SGraphItem } from "@saga-web/graph/lib";
  2. import { SIconTextItem } from '@saga-web/big/lib/items/SIconTextItem';
  3. import { Legend } from '../types/Legend';
  4. /**
  5. * 图例节点Item(图标类型)
  6. *
  7. * * @author 张宇(taohuzy@163.com)
  8. */
  9. export class SImageLegendItem extends SIconTextItem {
  10. /** 图例节点对象数据 */
  11. data: Legend;
  12. /** 图例数量 */
  13. _num: number = 0;
  14. get num(): number {
  15. return this._num;
  16. }
  17. set num(v: number) {
  18. this._num = v;
  19. this.data.Num = v;
  20. this.update();
  21. }
  22. set name(v: string) {
  23. this.data.Name = v;
  24. }
  25. set x(v: number) {
  26. this.data.Pos.X = v;
  27. }
  28. set y(v: number) {
  29. this.data.Pos.Y = v;
  30. }
  31. set width(v: number) {
  32. if (this.data.Size) {
  33. this.data.Size.Width = v;
  34. }
  35. }
  36. set height(v: number) {
  37. if (this.data.Size) {
  38. this.data.Size.Height = v;
  39. }
  40. }
  41. /**
  42. * 构造函数
  43. *
  44. * @param parent 指向父对象
  45. * @param data 图例节点对象数据
  46. */
  47. constructor(parent: SGraphItem | null, data: Legend) {
  48. super(parent);
  49. this.data = data;
  50. this.id = data.ID;
  51. this.moveTo(data.Pos.X, data.Pos.Y);
  52. if (data.Num) {
  53. this._num = data.Num;
  54. }
  55. if (data.Size) {
  56. this.width = data.Size.Width;
  57. this.height = data.Size.Height;
  58. }
  59. if (data.Properties && data.Properties.Text) {
  60. if (data.Properties.Text instanceof String) {
  61. this.text = `${data.Properties.Text}${data.Num?` × ${data.Num}`:''}`;
  62. }
  63. }
  64. if (data.Properties && data.Properties.Url) {
  65. if (data.Properties.Url instanceof String) {
  66. this.img.url = data.Properties.Url;
  67. }
  68. }
  69. }
  70. } // Class SImageLegendItem