SZoneLegendItem.ts 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import { SGraphItem } from "@saga-web/graph/lib";
  2. import { SPolygonItem } from "@/components/mapClass/SPolygonItem";
  3. import { Legend } from '../types/Legend';
  4. import { SPainter, SColor, SFont } from "@saga-web/draw";
  5. import { STextItem } from '@saga-web/graph/lib';
  6. /**
  7. * 图例节点Item(区域类型)
  8. *
  9. * * @author 张宇(taohuzy@163.com)
  10. */
  11. export class SZoneLegendItem extends SPolygonItem {
  12. /** 图例节点对象数据 */
  13. data: Legend;
  14. /** text item */
  15. textItem: STextItem = new STextItem(this);
  16. get text(): string {
  17. return this.textItem.text;
  18. }
  19. set text(v: string) {
  20. this.textItem.text = v;
  21. this.update();
  22. }
  23. get color(): string {
  24. return this.textItem.color;
  25. }
  26. set color(v: string) {
  27. this.textItem.color = v
  28. }
  29. get font(): SFont {
  30. return this.textItem.font
  31. }
  32. set font(v: SFont) {
  33. this.textItem.font = v
  34. }
  35. /** 是否显示文字 */
  36. _showText: boolean = true;
  37. get showText(): boolean {
  38. return this._showText;
  39. }
  40. set showText(v: boolean) {
  41. if (v === this._showText) {
  42. return
  43. }
  44. this._showText = v;
  45. if (v) {
  46. this.textItem.show();
  47. } else {
  48. this.textItem.hide();
  49. }
  50. }
  51. /**
  52. * 构造函数
  53. *
  54. * @param parent 指向父对象
  55. * @param data 图例节点对象数据
  56. */
  57. constructor(parent: SGraphItem | null, data: Legend) {
  58. super(parent);
  59. this.data = data;
  60. this.id = data.ID;
  61. if (data) {
  62. // 设置轮廓线
  63. this.setPointList = data.OutLine ? data.OutLine[0] : [];
  64. // 设置线宽
  65. this.lineWidth = data.Properties.lineWidth;
  66. // 设置线宽颜色
  67. this.strokeColor = new SColor(data.Properties.strokeColor)
  68. //
  69. this.fillColor = new SColor(data.Properties.fillColor) ;
  70. }
  71. }
  72. toData(): any {
  73. this.data.Properties.fillColor = this.fillColor;
  74. this.data.Properties.strokeColor = this.strokeColor;
  75. this.data.Properties.lineWidth = this.lineWidth;
  76. this.data.OutLine = [this.getPointList];
  77. return this.data;
  78. }
  79. } // Class SZoneLegendItem