Browse Source

'多边形添加边框样式'

zhangyu 5 years ago
parent
commit
1e9dca79bf
1 changed files with 31 additions and 6 deletions
  1. 31 6
      saga-web-big/src/items/SPolygonItem.ts

+ 31 - 6
saga-web-big/src/items/SPolygonItem.ts

@@ -2,7 +2,8 @@ import {
     SGraphItem,
     SGraphPointListDelete,
     SGraphPointListInsert,
-    SGraphPointListUpdate
+    SGraphPointListUpdate,
+    SLineStyle
 } from "@saga-web/graph/lib";
 import { SKeyCode, SMouseEvent, SUndoStack } from "@saga-web/base/";
 import {
@@ -31,6 +32,7 @@ export class SPolygonItem extends SGraphItem {
     private minY = Number.MAX_SAFE_INTEGER;
     /** Y坐标最大值  */
     private maxY = Number.MIN_SAFE_INTEGER;
+
     /** 轮廓线坐标  */
     private pointList: SPoint[] = [];
     // 获取当前状态
@@ -42,8 +44,7 @@ export class SPolygonItem extends SGraphItem {
         this.pointList = arr;
         this.update();
     }
-    /** 是否闭合    */
-    closeFlag: boolean = false;
+
     // 当前状态
     protected _status: number = SItemStatus.Normal;
     // 获取当前状态
@@ -61,7 +62,7 @@ export class SPolygonItem extends SGraphItem {
         }
         this.update();
     }
-    data: any | null = null;
+
     /** 边框颜色 */
     _strokeColor: SColor = new SColor("#0091FF");
     /**  画笔颜色 */
@@ -71,6 +72,7 @@ export class SPolygonItem extends SGraphItem {
     set strokeColor(v: SColor) {
         this._strokeColor = v;
     }
+
     /** 填充颜色 */
     _fillColor: SColor = new SColor("#1EE887");
     get fillColor(): SColor {
@@ -80,6 +82,16 @@ export class SPolygonItem extends SGraphItem {
         this._fillColor = v;
     }
 
+    /** 边框样式 */
+    _lineStyle: SLineStyle = SLineStyle.Soild;
+    get lineStyle(): SLineStyle {
+        return this._lineStyle;
+    }
+    set lineStyle(v: SLineStyle) {
+        this._lineStyle = v;
+        this.update();
+    }
+
     /** 边框的宽 只可输入像素宽*/
     _lineWidth: number = 4;
     get lineWidth(): number {
@@ -89,6 +101,9 @@ export class SPolygonItem extends SGraphItem {
         this._lineWidth = v;
         this.update();
     }
+
+    /** 是否闭合    */
+    closeFlag: boolean = false;
     /** 鼠标移动点  */
     private lastPoint: SPoint | null = null;
     /** 当前鼠标获取顶点对应索引 */
@@ -108,7 +123,6 @@ export class SPolygonItem extends SGraphItem {
      * 构造函数
      *
      * @param parent    指向父对象
-     * @param data      PolygonData数据
      */
     constructor(parent: SGraphItem | null) {
         super(parent);
@@ -208,8 +222,19 @@ export class SPolygonItem extends SGraphItem {
         painter.save();
         painter.pen.lineCapStyle = SLineCapStyle.Square;
         painter.pen.color = this._strokeColor;
-        painter.pen.lineWidth = painter.toPx(this._lineWidth);
         painter.brush.color = this._fillColor;
+        painter.pen.lineWidth = painter.toPx(this._lineWidth);
+        if (this.lineStyle == SLineStyle.Dashed) {
+            painter.pen.lineDash = [
+                painter.toPx(this.lineWidth * 3),
+                painter.toPx(this.lineWidth * 7)
+            ];
+        } else if (this.lineStyle == SLineStyle.Dotted) {
+            painter.pen.lineDash = [
+                painter.toPx(this.lineWidth),
+                painter.toPx(this.lineWidth)
+            ];
+        }
         if (this.selected) {
             painter.shadow.shadowBlur = 10;
             painter.shadow.shadowColor = new SColor(`#00000060`);