Browse Source

'图片item修改'

zhangyu 5 years ago
parent
commit
241b7f465e
1 changed files with 31 additions and 12 deletions
  1. 31 12
      saga-web-graph/src/items/SImageItem.ts

+ 31 - 12
saga-web-graph/src/items/SImageItem.ts

@@ -23,6 +23,26 @@ export class SImageItem extends SObjectItem {
         this.update();
     }
 
+    /** 边框色 */
+    private _strokeColor: SColor = new SColor("#c0ccda");
+    get strokeColor(): SColor {
+        return this._strokeColor;
+    }
+    set strokeColor(v: SColor) {
+        this._strokeColor = v;
+        this.update();
+    }
+
+    /** 边框宽度 */
+    private _lineWidth: number = 1;
+    get lineWidth(): number {
+        return this._lineWidth;
+    }
+    set lineWidth(v: number) {
+        this._lineWidth = v;
+        this.update();
+    }
+
     /** 图片加载是否完成 */
     isLoadOver: boolean = false;
 
@@ -144,19 +164,18 @@ export class SImageItem extends SObjectItem {
         if (this.isLoadOver) {
             // @ts-ignore
             painter.drawImage(this.img, -this.imgWidth / 2, -this.imgHeight / 2, this.imgWidth, this.imgHeight);
-            if (this.selected) {
-              painter.pen.lineWidth = 4;
-              painter.pen.lineDash = [12, 28];
-              painter.pen.color = new SColor("#c0ccda");
-              painter.brush.color = SColor.Transparent;
-              painter.drawRect(this.boundingRect());
-            }
+        }
+        if (this.selected) {
+            painter.shadow.shadowBlur = 10;
+            painter.shadow.shadowColor = new SColor(`#00000033`);
+            painter.shadow.shadowOffsetX = 5;
+            painter.shadow.shadowOffsetY = 5;
         } else {
-            painter.pen.lineWidth = 1;
-            painter.pen.lineDash = [3, 7];
-            painter.pen.color = new SColor("#c0ccda");
-            painter.brush.color = SColor.Transparent;
-            painter.drawRect(this.boundingRect());
+            painter.shadow.shadowColor = SColor.Transparent;
         }
+        painter.pen.lineWidth = this.lineWidth;
+        painter.pen.color = this.strokeColor;
+        painter.brush.color = SColor.Transparent;
+        painter.drawRect(this.boundingRect());
     } // Function onDraw()
 } // Class SImageItem