Browse Source

graph.big<feat>:适配底图数据

YaolongHan 4 năm trước cách đây
mục cha
commit
9f8b3557c5

+ 3 - 1
persagy-web-graph/src/index.ts

@@ -41,6 +41,7 @@ import { SImageItem } from "./items/SImageItem";
 import { SObjectItem } from "./items/SObjectItem";
 import { SAnchorItem } from "./items/SAnchorItem";
 import { STextItem } from "./items/STextItem";
+import { SGraphLineItem } from "./items/SGraphLineItem"
 import { SImageShowType } from "./enums/SImageShowType";
 import { SLineStyle } from "./enums/SLineStyle";
 import { SOrderSetType } from "./enums/SOrderSetType";
@@ -89,5 +90,6 @@ export {
     SGraphRect,
     SGraphRectItem,
     SGraphSvgItem,
-    SGraphSvg
+    SGraphSvg,
+    SGraphLineItem
 };

+ 41 - 2
persagy-web-graph/src/items/SGraphRectItem.ts

@@ -26,8 +26,8 @@
 
 import { SGraphShape } from "./SGraphShape";
 import { SGraphItem } from "../SGraphItem";
-import { SPainter, SRect } from "@persagy-web/draw";
-import { SGraphRect } from "..";
+import { SPainter, SRect,SColor } from "@persagy-web/draw";
+import { SGraphRect,SLineStyle } from "..";
 
 /**
  * 矩形(包含圆角矩形) item
@@ -71,6 +71,45 @@ export class SGraphRectItem extends SGraphShape {
         this._radius = v;
         this.update();
     }
+    /** 线条颜色 */
+    _strokeColor: SColor = SColor.Black;
+    get strokeColor(): SColor {
+        return this._strokeColor;
+    }
+    set strokeColor(v: SColor) {
+        this._strokeColor = v;
+        this.update();
+    }
+
+    /** 填充色 */
+    _fillColor: SColor = new SColor("#2196f3");
+    get fillColor(): SColor {
+        return this._fillColor;
+    }
+    set fillColor(v: SColor) {
+        this._fillColor = v;
+        this.update();
+    }
+
+    /** 边框样式 */
+    _lineStyle: SLineStyle = SLineStyle.Solid;
+    get lineStyle(): SLineStyle {
+        return this._lineStyle;
+    }
+    set lineStyle(v: SLineStyle) {
+        this._lineStyle = v;
+        this.update();
+    }
+
+    /** 线条宽度 */
+    _lineWidth: number = 1;
+    get lineWidth(): number {
+        return this._lineWidth;
+    }
+    set lineWidth(v: number) {
+        this._lineWidth = v;
+        this.update();
+    }
 
     /**
      * 构造函数

+ 24 - 1
persagy-web-graph/src/items/SImageItem.ts

@@ -26,7 +26,7 @@
 
 import { SObjectItem } from "./SObjectItem";
 import { SPainter, SRect, SSize, SColor, SPoint } from "@persagy-web/draw";
-import { SImageShowType, STextOrigin } from "..";
+import { SImageShowType, STextOrigin, SLineStyle } from "..";
 import { SGraphItem } from "../SGraphItem";
 
 /**
@@ -59,6 +59,16 @@ export class SImageItem extends SObjectItem {
         this.update();
     }
 
+    /** 线条样式 */
+    private _lineStyle: SLineStyle = SLineStyle.Solid;
+    get lineStyle(): SLineStyle {
+        return this._lineStyle;
+    }
+    set lineStyle(v: SLineStyle) {
+        this._lineStyle = v;
+        this.update();
+    }
+
     /** 边框宽度 */
     private _lineWidth: number = 1;
     get lineWidth(): number {
@@ -259,6 +269,19 @@ export class SImageItem extends SObjectItem {
         } else {
             painter.shadow.shadowColor = SColor.Transparent;
         }
+
+        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(2 * this.lineWidth),
+                painter.toPx(2 * this.lineWidth)
+            ];
+        }
+
         painter.pen.lineWidth = this.lineWidth;
         painter.pen.color = this.strokeColor;
         painter.brush.color = SColor.Transparent;