12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- import { SGraphItem } from "@saga-web/graph/lib";
- import { SPolygonItem } from "@/components/mapClass/SPolygonItem";
- import { Legend } from '../types/Legend';
- import { SPainter, SColor, SFont } from "@saga-web/draw";
- import { STextItem } from '@saga-web/graph/lib';
- /**
- * 图例节点Item(区域类型)
- *
- * * @author 张宇(taohuzy@163.com)
- */
- export class SZoneLegendItem extends SPolygonItem {
- /** 图例节点对象数据 */
- data: Legend;
- /** text item */
- textItem: STextItem = new STextItem(this);
- get text(): string {
- return this.textItem.text;
- }
- set text(v: string) {
- this.textItem.text = v;
- this.update();
- }
- get color(): string {
- return this.textItem.color;
- }
- set color(v: string) {
- this.textItem.color = v
- }
- get font(): SFont {
- return this.textItem.font
- }
- set font(v: SFont) {
- this.textItem.font = v
- }
- /** 是否显示文字 */
- _showText: boolean = true;
- get showText(): boolean {
- return this._showText;
- }
- set showText(v: boolean) {
- if (v === this._showText) {
- return
- }
- this._showText = v;
- if (v) {
- this.textItem.show();
- } else {
- this.textItem.hide();
- }
- }
- /**
- * 构造函数
- *
- * @param parent 指向父对象
- * @param data 图例节点对象数据
- */
- constructor(parent: SGraphItem | null, data: Legend) {
- super(parent);
- this.data = data;
- this.id = data.ID;
- if (data) {
- // 设置轮廓线
- this.setPointList = data.OutLine ? data.OutLine[0] : [];
- // 设置线宽
- this.lineWidth = data.Properties.lineWidth;
- // 设置线宽颜色
- this.strokeColor = new SColor(data.Properties.strokeColor)
- //
- this.fillColor = new SColor(data.Properties.fillColor) ;
- }
- }
- toData(): any {
- this.data.Properties.fillColor = this.fillColor;
- this.data.Properties.strokeColor = this.strokeColor;
- this.data.Properties.lineWidth = this.lineWidth;
- this.data.OutLine = [this.getPointList];
- return this.data;
- }
- } // Class SZoneLegendItem
|