|
@@ -2,7 +2,7 @@
|
|
|
import { SGraphItem } from "@saga-web/graph/lib";
|
|
|
import { SPolygonItem } from "@/components/mapClass/SPolygonItem";
|
|
|
import { Legend } from '../types/Legend';
|
|
|
-import { SPainter, SColor, SFont, SPoint } from "@saga-web/draw";
|
|
|
+import { SPainter, SColor, SFont, SPoint, SLineCapStyle } from "@saga-web/draw";
|
|
|
import { STextItem } from '@saga-web/graph/lib';
|
|
|
import { hexify } from "@/components/mapClass/until"
|
|
|
import { SItemStatus, ItemOrder } from '@saga-web/big/lib';
|
|
@@ -84,11 +84,25 @@ export class SSCPZZoneLegendItem extends SPolygonItem {
|
|
|
this.textItem.hide();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /** 是否蒙版遮罩 */
|
|
|
+ _maskFlag: boolean = false;
|
|
|
+ get maskFlag(): boolean {
|
|
|
+ return this._maskFlag;
|
|
|
+ }
|
|
|
+ set maskFlag(v: boolean) {
|
|
|
+ if (v === this._maskFlag) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this._maskFlag = v;
|
|
|
+ this.update()
|
|
|
+ }
|
|
|
+
|
|
|
/** 图例说明 */
|
|
|
- set itemExplain(v:string){
|
|
|
- this.data.Properties.ItemExplain = v
|
|
|
+ set itemExplain(v: string) {
|
|
|
+ this.data.Properties.ItemExplain = v
|
|
|
}
|
|
|
- get itemExplain():string{
|
|
|
+ get itemExplain(): string {
|
|
|
return this.data.Properties.ItemExplain
|
|
|
}
|
|
|
|
|
@@ -136,27 +150,27 @@ export class SSCPZZoneLegendItem extends SPolygonItem {
|
|
|
this.color = data.Properties.color
|
|
|
}
|
|
|
if (data.Properties.font) {
|
|
|
- this.font =new SFont("sans-serif", data.Properties.font);
|
|
|
+ this.font = new SFont("sans-serif", data.Properties.font);
|
|
|
}
|
|
|
// if( data.Properties.LineDash){
|
|
|
// this.LineDash =this._legend.Properties.LineDash
|
|
|
// }
|
|
|
}
|
|
|
// 监听多边形创建完成事件,并动态计算文本位置
|
|
|
- this.connect("finishCreated",this, () => {
|
|
|
+ this.connect("finishCreated", this, () => {
|
|
|
// 计算文本位置
|
|
|
let x: number = this.getPointList.reduce((pre, cur, index, arr) => {
|
|
|
- return pre + (cur.x / arr.length)
|
|
|
- }, 0),
|
|
|
+ return pre + (cur.x / arr.length)
|
|
|
+ }, 0),
|
|
|
y: number = this.getPointList.reduce((pre, cur, index, arr) => {
|
|
|
- return pre + (cur.y / arr.length)
|
|
|
- }, 0);
|
|
|
+ return pre + (cur.y / arr.length)
|
|
|
+ }, 0);
|
|
|
this.textItem.moveTo(x, y);
|
|
|
})
|
|
|
}
|
|
|
|
|
|
toData(): any {
|
|
|
- this.data.Pos = {X: this.x, Y: this.y};
|
|
|
+ this.data.Pos = { X: this.x, Y: this.y };
|
|
|
this.data.Name = this.text;
|
|
|
this.data.Properties.FillColor = this.fillColor.value;
|
|
|
this.data.Properties.StrokeColor = this.strokeColor.value;
|
|
@@ -167,10 +181,26 @@ export class SSCPZZoneLegendItem extends SPolygonItem {
|
|
|
Y: pos.y
|
|
|
}
|
|
|
});
|
|
|
- this.data.Properties.TextPos = {X: this.textItem.x, Y: this.textItem.y};
|
|
|
- this.data.Properties.font = this.font.size;
|
|
|
- this.data.Properties.color = this.color;
|
|
|
+ this.data.Properties.TextPos = { X: this.textItem.x, Y: this.textItem.y };
|
|
|
+ this.data.Properties.font = this.font.size;
|
|
|
+ this.data.Properties.color = this.color;
|
|
|
return this.data;
|
|
|
}
|
|
|
|
|
|
+ onDraw(painter: SPainter) {
|
|
|
+ if (this.maskFlag && this.status == SItemStatus.Normal) {
|
|
|
+ let color = new SColor(this.strokeColor)
|
|
|
+ color.alpha = 100;
|
|
|
+ let brushcolor = new SColor(this.fillColor)
|
|
|
+ brushcolor.alpha = 100;
|
|
|
+ painter.pen.color = color;
|
|
|
+ painter.pen.lineCapStyle = SLineCapStyle.Square;
|
|
|
+ painter.pen.lineWidth = painter.toPx(this._lineWidth);
|
|
|
+ painter.brush.color = brushcolor;
|
|
|
+ // @ts-ignore
|
|
|
+ painter.drawPolygon([...this.pointList]);
|
|
|
+ } else {
|
|
|
+ super.onDraw(painter);
|
|
|
+ }
|
|
|
+ }
|
|
|
} // Class SZoneLegendItem
|