Jelajahi Sumber

'item颜色改为SColor类'

zhangyu 5 tahun lalu
induk
melakukan
91623c61b1

+ 8 - 9
saga-web-big/src/items/SIconTextItem.ts

@@ -111,10 +111,10 @@ export class SIconTextItem extends SObjectItem {
       this.textItem.text = v;
       this.update();
     }
-    get color(): string {
+    get color(): SColor {
       return this.textItem.color;
     }
-    set color(v: string) {
+    set color(v: SColor) {
       this.textItem.color = v;
       this.update();
     }
@@ -138,8 +138,8 @@ export class SIconTextItem extends SObjectItem {
     constructor(parent: SGraphItem | null) {
       super(parent);
       this.img.url = `http://adm.sagacloud.cn:8080/doc/assets/img/logo.png`;
-      this.img.width = 32;
-      this.img.height = 32;
+      this.img.width = 12;
+      this.img.height = 12;
       let anchorPoint = [{ x: 0, y: this.img.height / 2 }, { x: 0, y: -this.img.height / 2 }, { x: -this.img.width / 2, y: 0 }, { x: this.img.width / 2, y: 0 }];
       this.anchorList = anchorPoint.map(t => {
         let item = new SAnchorItem(this);
@@ -149,13 +149,12 @@ export class SIconTextItem extends SObjectItem {
       this.update();
       this.textItem.text = "";
       this.textItem.backgroundColor = SColor.White;
-      this.textItem.font.size = 24;
-      this.textItem.moveTo(26, -6);
+      this.textItem.font.size = 12;
+      // 偏移二分之一文本高度
+      this.textItem.moveTo(11, -(this.textItem.height * 0.5));
       this.moveable = true;
       this.selectable = true;
       this.isTransform = false;
-      // this.textItem.enabled = false;
-      // this.img.enabled = false;
     }
 
     /**
@@ -227,7 +226,7 @@ export class SIconTextItem extends SObjectItem {
             painter.toPx(3),
             painter.toPx(7)
           ];
-          painter.pen.color = new SColor("#000000");
+          painter.pen.color = SColor.Black;
           painter.brush.color = SColor.Transparent;
           painter.drawRect(this.boundingRect());
         }

+ 13 - 18
saga-web-big/src/items/SLineItem.ts

@@ -46,11 +46,11 @@ export class SLineItem extends SGraphItem {
     }
 
     /** 线条颜色    */
-    private _strokeColor: string = "#000000";
-    get strokeColor(): string {
+    private _strokeColor: SColor = SColor.Black;
+    get strokeColor(): SColor {
         return this._strokeColor;
     }
-    set strokeColor(v: string) {
+    set strokeColor(v: SColor) {
         this._strokeColor = v;
         this.update();
     }
@@ -66,21 +66,21 @@ export class SLineItem extends SGraphItem {
     }
 
     /** 端点填充色 */
-    private _fillColor: string = "#ffffff";
-    get fillColor(): string {
+    private _fillColor: SColor = SColor.White;
+    get fillColor(): SColor {
         return this._fillColor;
     }
-    set fillColor(v: string) {
+    set fillColor(v: SColor) {
         this._fillColor = v;
         this.update();
     }
 
     /** 选中端点填充色 */
-    private _activeFillColor: string = "#2196f3";
-    get activeFillColor(): string {
+    private _activeFillColor: SColor = new SColor("#2196f3");
+    get activeFillColor(): SColor {
         return this._activeFillColor;
     }
-    set activeFillColor(v: string) {
+    set activeFillColor(v: SColor) {
         this._activeFillColor = v;
         this.update();
     }
@@ -419,13 +419,8 @@ export class SLineItem extends SGraphItem {
     onDraw(painter: SPainter): void {
         this.sceneDis = painter.toPx(this.dis);
         painter.pen.lineWidth = painter.toPx(this.lineWidth);
-        painter.pen.color = new SColor(this.strokeColor);
+        painter.pen.color = this.strokeColor;
         if (this.line.length == 2) {
-            // 绘制外轮廓
-            // painter.brush.color = SColor.Transparent;
-            // painter.pen.color = new SColor("#128eee");
-            // painter.drawRect(this.boundingRect());
-
             // 绘制直线
             painter.pen.color = new SColor(this.strokeColor);
             if (this.lineStyle == SLineStyle.Dashed) {
@@ -453,9 +448,9 @@ export class SLineItem extends SGraphItem {
             ) {
                 // 绘制端点
                 this.line.forEach((p, i): void => {
-                    painter.brush.color = new SColor(this.fillColor);
+                    painter.brush.color = this.fillColor;
                     if (i == this.curIndex) {
-                        painter.brush.color = new SColor(this.activeFillColor);
+                        painter.brush.color = this.activeFillColor;
                     }
                     painter.drawCircle(p.x, p.y, painter.toPx(5));
                 });
@@ -466,7 +461,7 @@ export class SLineItem extends SGraphItem {
                 this.status == SItemStatus.Create
             ) {
                 // 绘制端点
-                painter.brush.color = new SColor(this.fillColor);
+                painter.brush.color = this.fillColor;
                 painter.drawCircle(
                     this.line[0].x,
                     this.line[0].y,

+ 1 - 0
saga-web-big/src/items/SPolygonItem.ts

@@ -645,6 +645,7 @@ export class SPolygonItem extends SGraphItem {
             this.moveToOrigin(this.x, this.y);
             return super.onMouseUp(event);
         }
+        super.onMouseUp(event);
         return true;
     } // Function onMouseUp()
 

+ 9 - 9
saga-web-big/src/items/SPolylineItem.ts

@@ -37,20 +37,20 @@ export class SPolylineItem extends SGraphItem {
     /** 鼠标移动时的点 */
     private lastPoint: SPoint | null = null;
     /** 线条颜色    */
-    _strokeColor: string = "#000000";
-    get strokeColor(): string {
+    _strokeColor: SColor = SColor.Black;
+    get strokeColor(): SColor {
         return this._strokeColor;
     }
-    set strokeColor(v: string) {
+    set strokeColor(v: SColor) {
         this._strokeColor = v;
         this.update();
     }
     /** 填充色 */
-    _fillColor: string = "#2196f3";
-    get fillColor(): string {
+    _fillColor: SColor = new SColor("#2196f3");
+    get fillColor(): SColor {
         return this._fillColor;
     }
-    set fillColor(v: string) {
+    set fillColor(v: SColor) {
         this._fillColor = v;
         this.update();
     }
@@ -480,7 +480,7 @@ export class SPolylineItem extends SGraphItem {
      * */
     drawBaseLine(painter: SPainter): void {
         // 绘制基本图形
-        painter.pen.color = new SColor(this.strokeColor);
+        painter.pen.color = this.strokeColor;
         painter.drawPolyline(this.pointList);
     } // Function drawBaseLine()
 
@@ -505,7 +505,7 @@ export class SPolylineItem extends SGraphItem {
             this.pointList.forEach((t, i): void => {
                 painter.brush.color = SColor.White;
                 if (i == this.curIndex) {
-                    painter.brush.color = new SColor(this.fillColor);
+                    painter.brush.color = this.fillColor;
                 }
                 painter.drawCircle(t.x, t.y, painter.toPx(5));
             });
@@ -516,7 +516,7 @@ export class SPolylineItem extends SGraphItem {
             this.pointList.forEach((t, i): void => {
                 painter.brush.color = SColor.White;
                 if (i == this.curIndex) {
-                    painter.brush.color = new SColor(this.fillColor);
+                    painter.brush.color = this.fillColor;
                 }
                 painter.drawCircle(t.x, t.y, painter.toPx(5));
             });