Sfoglia il codice sorgente

graph:fix:多边形组和区域组从styleitem派生,暴露属性,不再使用传入style的方式该样式了

haojianlong 4 anni fa
parent
commit
38f9edb0b9

+ 1 - 1
persagy-web-graph/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@persagy-web/graph",
-    "version": "2.2.27",
+    "version": "2.2.28",
     "description": "博锐尚格二维图形引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",

+ 6 - 4
persagy-web-graph/src/items/SGraphAreaGroupItem.ts

@@ -32,15 +32,15 @@ import {
     SPolygonUtil,
     SRect
 } from "@persagy-web/draw/lib";
-import { SGraphShape } from "./SGraphShape";
 import { AreaGroup } from "../types/AreaGroup";
+import { SGraphStyleItem } from "./SGraphStyleItem";
 
 /**
  * 区域组
  *
  * @author  郝建龙 <haojianlong@sagacloud.cn>
  */
-export class SGraphAreaGroupItem extends SGraphShape {
+export class SGraphAreaGroupItem extends SGraphStyleItem {
     /** X 坐标最小值 */
     private minX = Number.MAX_SAFE_INTEGER;
     /** X 坐标最大值 */
@@ -61,7 +61,7 @@ export class SGraphAreaGroupItem extends SGraphShape {
      * @param data    轮廓线及风格数据
      */
     constructor(parent: SGraphItem | null, data: AreaGroup) {
-        super(parent, data.style);
+        super(parent);
         if (data.outline.length && data.outline[0] && data.outline[0].length) {
             let tempArr = data.outline;
             this.minX = tempArr[0][0][0].x;
@@ -151,7 +151,9 @@ export class SGraphAreaGroupItem extends SGraphShape {
      * @param painter    绘制对象
      */
     onDraw(painter: SPainter): void {
-        super.onDraw(painter);
+        painter.pen.color = this.strokeColor;
+        painter.brush.color = this.fillColor;
+        painter.pen.lineWidth = this.lineWidth;
         this.pathList.forEach((t): void => {
             painter.drawPath(t);
         });

+ 6 - 5
persagy-web-graph/src/items/SGraphPolyGroupItem.ts

@@ -26,15 +26,14 @@
 
 import { SGraphItem } from "../SGraphItem";
 import { SPainter, SPoint, SPolygonUtil, SRect } from "@persagy-web/draw/lib";
-import { SGraphShape } from "./SGraphShape";
-import { PolyGroup } from "..";
+import { PolyGroup, SGraphStyleItem } from "..";
 
 /**
  * 多边形组
  *
  * @author  郝建龙 <haojianlong@sagacloud.cn>
  */
-export class SGraphPolyGroupItem extends SGraphShape {
+export class SGraphPolyGroupItem extends SGraphStyleItem {
     /** X 坐标最小值 */
     private minX = Number.MAX_SAFE_INTEGER;
     /** X 坐标最大值 */
@@ -53,7 +52,7 @@ export class SGraphPolyGroupItem extends SGraphShape {
      * @param data    轮廓线及风格数据
      */
     constructor(parent: SGraphItem | null, data: PolyGroup) {
-        super(parent, data.style);
+        super(parent);
         if (data.outline.length && data.outline[0] && data.outline[0].length) {
             this.minX = data.outline[0][0].x;
             this.maxX = this.minX;
@@ -120,7 +119,9 @@ export class SGraphPolyGroupItem extends SGraphShape {
      * @param painter    绘制对象
      */
     onDraw(painter: SPainter): void {
-        super.onDraw(painter);
+        painter.pen.color = this.strokeColor;
+        painter.brush.color = this.fillColor;
+        painter.pen.lineWidth = this.lineWidth;
         this.pointList.forEach((t): void => {
             painter.drawPolygon(t);
         });