Przeglądaj źródła

Merge remote-tracking branch 'origin/master'

sybotan 5 lat temu
rodzic
commit
4658dbf1b8

+ 1 - 1
saga-web-base/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/base",
-    "version": "2.1.21",
+    "version": "2.1.22",
     "description": "上格云Web基础库。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",

+ 2 - 2
saga-web-big/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/big",
-    "version": "1.0.46",
+    "version": "1.0.49",
     "description": "上格云建筑信息化库",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -42,6 +42,6 @@
         "typescript": "^3.9.3"
     },
     "dependencies": {
-        "@saga-web/graph": "2.1.90"
+        "@saga-web/graph": "2.1.92"
     }
 }

+ 42 - 11
saga-web-big/src/items/SIconTextItem.ts

@@ -22,6 +22,19 @@ export class SIconTextItem extends SObjectItem {
     }
     set status(v: SItemStatus) {
       this._status = v;
+      if (v == SItemStatus.Normal) {
+        this.moveable = true;
+        this.textItem.moveable = false;
+        this.img.moveable = false;
+      } else if (v == SItemStatus.Edit) {
+        this.moveable = false;
+        this.textItem.moveable = true;
+        this.img.moveable = true;
+      } else if (v == SItemStatus.Create) {
+        this.moveable = true;
+        this.textItem.moveable = false;
+        this.img.moveable = false;
+      }
       this.update();
     }
 
@@ -98,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();
     }
@@ -125,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);
@@ -136,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;
     }
 
     /**
@@ -176,7 +188,15 @@ export class SIconTextItem extends SObjectItem {
      * @return  是否处理事件
      * */
     onDoubleClick(event: SMouseEvent): boolean {
-      this.status = SItemStatus.Edit;
+      // 如果位show状态 双击改对象则需改为编辑状态
+      if (SItemStatus.Normal == this.status) {
+        this.status = SItemStatus.Edit;
+        this.grabItem(this);
+      } else if (SItemStatus.Edit == this.status) {
+        this.status = SItemStatus.Normal;
+        this.releaseItem();
+      }
+      this.update();
       return true;
     } // Function onDoubleClick()
 
@@ -199,13 +219,24 @@ export class SIconTextItem extends SObjectItem {
      * @param   painter painter对象
      */
     onDraw(painter: SPainter): void {
-      if (this.selected) {
+      if (this.status == SItemStatus.Normal) {
+        if (this.selected) {
+          painter.pen.lineWidth = painter.toPx(1);
+          painter.pen.lineDash = [
+            painter.toPx(3),
+            painter.toPx(7)
+          ];
+          painter.pen.color = SColor.Black;
+          painter.brush.color = SColor.Transparent;
+          painter.drawRect(this.boundingRect());
+        }
+      } else if (this.status == SItemStatus.Edit) {
         painter.pen.lineWidth = painter.toPx(1);
         painter.pen.lineDash = [
           painter.toPx(3),
           painter.toPx(7)
         ];
-        painter.pen.color = new SColor("#000000");
+        painter.pen.color = SColor.Red;
         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));
             });

+ 20 - 10
saga-web-big/src/items/floor/SSpaceItem.ts

@@ -62,6 +62,14 @@ export class SSpaceItem extends SGraphItem {
         this._highLightFlag = value;
         this.update();
     } // Set highLightFlag
+    private _showBaseName: boolean = false;
+    get showBaseName(): boolean {
+        return this._showBaseName;
+    } // Get showBaseName
+    set showBaseName(value: boolean) {
+        this._showBaseName = value;
+        this.update();
+    } // Set showBaseName
 
     /**
      * 构造函数
@@ -188,16 +196,18 @@ export class SSpaceItem extends SGraphItem {
         painter.pen.lineWidth = painter.toPx(1);
         painter.drawPath(this.path);
 
-        if (this.data.Name && this.data.Name != "null") {
-            painter.brush.color = SColor.Black;
-            painter.font.size = painter.toPx(10);
-            // painter.font.size = 500;
-            painter.font.textAlign = STextAlign.Center;
-            painter.drawText(
-                this.data.Name,
-                this.data.Location.Points[0].X,
-                -this.data.Location.Points[0].Y
-            );
+        if (this.showBaseName) {
+            if (this.data.Name && this.data.Name != "null") {
+                painter.brush.color = SColor.Black;
+                painter.font.size = painter.toPx(10);
+                // painter.font.size = 500;
+                painter.font.textAlign = STextAlign.Center;
+                painter.drawText(
+                    this.data.Name,
+                    this.data.Location.Points[0].X,
+                    -this.data.Location.Points[0].Y
+                );
+            }
         }
     } // Function onDraw()
 } // Class SSpaceItem

+ 2 - 2
saga-web-draw/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/draw",
-    "version": "2.1.97",
+    "version": "2.1.100",
     "description": "上格云绘制引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -33,7 +33,7 @@
         "typescript": "^3.5.3"
     },
     "dependencies": {
-        "@saga-web/base": "^2.1.21"
+        "@saga-web/base": "^2.1.22"
     },
     "jest": {
         "setupFiles": [

+ 75 - 47
saga-web-draw/src/SColor.ts

@@ -6,24 +6,24 @@ import { SStringUtil } from "@saga-web/base/lib";
  * @author  庞利祥(sybotan@126.com)
  */
 export class SColor {
-    static Transparent = new SColor("#00000000");
-    static Black = new SColor("#000000");
-    static DarkBlue = new SColor("#000080");
-    static Blue = new SColor("#0000FF");
-    static DarkGreen = new SColor("#008000");
-    static Green = new SColor("#00FF00");
-    static DarkCyan = new SColor("#008080");
-    static Cyan = new SColor("#00FFFF");
-    static DarkRed = new SColor("#800000");
-    static Red = new SColor("#FF0000");
-    static DarkMagenta = new SColor("#800080");
-    static Magenta = new SColor("#FF00FF");
-    static DarkYellow = new SColor("#808000");
-    static Yellow = new SColor("#FFFF00");
-    static White = new SColor("#FFFFFF");
-    static DarkGray = new SColor("#808080");
-    static Gray = new SColor("#A0A0A0");
-    static LightGray = new SColor("#C0C0C0");
+    static readonly Transparent = new SColor("#00000000");
+    static readonly Black = new SColor("#000000");
+    static readonly DarkBlue = new SColor("#000080");
+    static readonly Blue = new SColor("#0000FF");
+    static readonly DarkGreen = new SColor("#008000");
+    static readonly Green = new SColor("#00FF00");
+    static readonly DarkCyan = new SColor("#008080");
+    static readonly Cyan = new SColor("#00FFFF");
+    static readonly DarkRed = new SColor("#800000");
+    static readonly Red = new SColor("#FF0000");
+    static readonly DarkMagenta = new SColor("#800080");
+    static readonly Magenta = new SColor("#FF00FF");
+    static readonly DarkYellow = new SColor("#808000");
+    static readonly Yellow = new SColor("#FFFF00");
+    static readonly White = new SColor("#FFFFFF");
+    static readonly DarkGray = new SColor("#808080");
+    static readonly Gray = new SColor("#A0A0A0");
+    static readonly LightGray = new SColor("#C0C0C0");
 
     /**
      * 根据rgb分量生成颜色
@@ -35,7 +35,7 @@ export class SColor {
      */
     static rgb(r: number, g: number, b: number): SColor {
         return new SColor(r, g, b);
-    } // Function rgb()
+    }
 
     /**
      * 根据rgba分量生成颜色
@@ -55,28 +55,56 @@ export class SColor {
     /** 红色分量 */
     get red(): number {
         return (this._value >> 24) & 0xff;
-    } // Get red
+    }
+    set red(v: number) {
+        const r = (Math.floor(v) & 0xff) << 24;
+        this._value = (this._value & 0x00ffffff) | r;
+    }
 
     /** 绿色分量 */
     get green(): number {
         return (this._value >> 16) & 0xff;
-    } // Get green
+    }
+    set green(v: number) {
+        const r = (Math.floor(v) & 0xff) << 16;
+        this._value = (this._value & 0xff00ffff) | r;
+    }
 
     /** 蓝色分量 */
     get blue(): number {
         return (this._value >> 8) & 0xff;
-    } // Get blue
+    }
+    set blue(v: number) {
+        const r = (Math.floor(v) & 0xff) << 8;
+        this._value = (this._value & 0xffff00ff) | r;
+    }
 
     /** 透明度 */
     get alpha(): number {
         return this._value & 0xff;
-    } // Get alpha
+    }
+    set alpha(v: number) {
+        const r = Math.floor(v) & 0xff;
+        this._value = (this._value & 0xffffff00) | r;
+    }
 
     /** 颜色 */
-    private _value: number = 0xff;
+    private _value = 0xff;
     get value(): string {
         return "#" + SStringUtil.num2Hex(this._value, 8);
-    } // Get value
+    }
+    set value(v: string) {
+        if (v.substr(0, 1) != "#") {
+            return;
+        }
+
+        // 先去“#”,再转换16进制数
+        this._value = parseInt(v.substr(1), 16);
+        // 如果未写alpha值,则左移8位+0xff;
+        if (v.length == 7) {
+            this._value = (this._value << 8) + 0xff;
+        }
+    }
 
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // 构造函数
@@ -135,7 +163,7 @@ export class SColor {
         if (r == undefined) {
             this._value = 0xff;
         } else if (typeof r == "string") {
-            this.setColor(r);
+            this.value = r;
         } else if (r instanceof SColor) {
             this._value = r._value;
         } else if (a == undefined) {
@@ -143,7 +171,7 @@ export class SColor {
         } else {
             this.setRgba(r as number, g as number, b as number, a as number);
         }
-    } // Constructor
+    }
 
     /**
      * 设置颜色
@@ -158,7 +186,7 @@ export class SColor {
             ((g as number) << 16) +
             ((b as number) << 8) +
             0xff;
-    } // Function setRgb()
+    }
 
     /**
      * 设置颜色
@@ -174,23 +202,23 @@ export class SColor {
             ((g as number) << 16) +
             ((b as number) << 8) +
             (a as number);
-    } // Function setRgb()
-
-    /**
-     * 设置颜色
-     *
-     * @param   str     颜色字符串
-     */
-    private setColor(str: string): void {
-        if (str.substr(0, 1) != "#") {
-            return;
-        }
-
-        // 先去“#”,再转换16进制数
-        this._value = parseInt(str.substr(1), 16);
-        // 如果未写alpha值,则左移8位+0xff;
-        if (str.length == 7) {
-            this._value = (this._value << 8) + 0xff;
-        }
-    } // Function setColor()
+    }
+
+    // /**
+    //  * 设置颜色
+    //  *
+    //  * @param   str     颜色字符串
+    //  */
+    // private setColor(str: string): void {
+    //     if (str.substr(0, 1) != "#") {
+    //         return;
+    //     }
+    //
+    //     // 先去“#”,再转换16进制数
+    //     this._value = parseInt(str.substr(1), 16);
+    //     // 如果未写alpha值,则左移8位+0xff;
+    //     if (str.length == 7) {
+    //         this._value = (this._value << 8) + 0xff;
+    //     }
+    // }
 } // Class SColor

+ 1 - 0
saga-web-draw/src/SPainter.ts

@@ -50,6 +50,7 @@ export class SPainter extends SObject {
     } // Get font
     set font(value: SFont) {
         this.engine.state.font = value;
+        this.engine.changeFont(value);
     } // Set font
 
     /** 融合属性    */

+ 13 - 0
saga-web-draw/src/engines/SCanvasPaintEngine.ts

@@ -1,6 +1,7 @@
 import { SPaintEngine } from "./SPaintEngine";
 import {
     SBrushType,
+    SFont,
     SGradientStop,
     SLine,
     SLinearGradient,
@@ -397,6 +398,18 @@ export class SCanvasPaintEngine extends SPaintEngine {
     //     this.canvas.stroke();
     // } // Function drawRoundedRect()
 
+    /**
+     * 设置字体
+     *
+     * @param   font    字体
+     */
+    changeFont(font: SFont): void {
+        this._canvas.font = `${font.size}px ${font.name}`;
+        this.setTextAlign(font.textAlign);
+        this.setBaseLine(font.textBaseLine);
+        this.setTextDirection(font.textDirection);
+    } // Function changeFont()
+
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // 私有函数
     /**

+ 8 - 1
saga-web-draw/src/engines/SPaintEngine.ts

@@ -1,4 +1,4 @@
-import { SLine, SPaintEngineType, SPath2D, SPoint, SRect } from "..";
+import { SFont, SLine, SPaintEngineType, SPath2D, SPoint, SRect } from "..";
 import { SPaintState } from "./SPaintState";
 
 /**
@@ -280,4 +280,11 @@ export abstract class SPaintEngine {
      * @param   text    预测的文本
      * */
     abstract textWidth(text: string): number;
+
+    /**
+     * 修改字体
+     *
+     * @param   font    字体
+     * */
+    abstract changeFont(font: SFont): void;
 } // class SPaintEngine

+ 8 - 0
saga-web-draw/src/engines/SSvgPaintEngine.ts

@@ -2,6 +2,7 @@ import { SStringBuilder } from "@saga-web/base/lib";
 import { SPath2D } from "../SPath2D";
 import {
     SBrushType,
+    SFont,
     SGradientStop,
     SLine,
     SLinearGradient,
@@ -328,6 +329,13 @@ export class SSvgPaintEngine extends SPaintEngine {
     } // Function textWidth()
 
     /**
+     * 设置字体
+     *
+     * @param   font    字体
+     */
+    changeFont(font: SFont): void {} // Function changeFont()
+
+    /**
      * 获得svg需要的变形信息
      *
      * @return  变换信息

+ 2 - 2
saga-web-graph/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/graph",
-    "version": "2.1.90",
+    "version": "2.1.92",
     "description": "上格云二维图形引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -41,6 +41,6 @@
         "typescript": "^3.5.3"
     },
     "dependencies": {
-        "@saga-web/draw": "2.1.97"
+        "@saga-web/draw": "2.1.99"
     }
 }

+ 5 - 4
saga-web-graph/src/items/SImageItem.ts

@@ -54,6 +54,7 @@ export class SImageItem extends SObjectItem {
      */
     constructor(parent: SGraphItem | null, url?: string) {
         super(parent);
+        this.isTransform = false;
         if (url) this.url = url;
     } // Constructor
 
@@ -127,15 +128,15 @@ export class SImageItem extends SObjectItem {
             // @ts-ignore
             painter.drawImage(this.img, -width / 2, -height / 2, width, height);
             if (this.selected) {
-              painter.pen.lineWidth = painter.toPx(4);
-              painter.pen.lineDash = [painter.toPx(12), painter.toPx(28)];
+              painter.pen.lineWidth = 4;
+              painter.pen.lineDash = [12, 28];
               painter.pen.color = new SColor("#c0ccda");
               painter.brush.color = SColor.Transparent;
               painter.drawRect(this.boundingRect());
             }
         } else {
-            painter.pen.lineWidth = painter.toPx(1);
-            painter.pen.lineDash = [painter.toPx(3), painter.toPx(7)];
+            painter.pen.lineWidth = 1;
+            painter.pen.lineDash = [3, 7];
             painter.pen.color = new SColor("#c0ccda");
             painter.brush.color = SColor.Transparent;
             painter.drawRect(this.boundingRect());

+ 43 - 20
saga-web-graph/src/items/STextItem.ts

@@ -1,6 +1,7 @@
 import { SObjectItem } from "./SObjectItem";
 import { SPainter, SRect, SColor, SFont } from "@saga-web/draw/lib";
 import { SGraphItem } from "../SGraphItem";
+import { SLineStyle } from "../enums/SLineStyle";
 
 /**
  * 文本item
@@ -27,11 +28,11 @@ export class STextItem extends SObjectItem {
     private _textArr: string[] = [];
 
     /** 文本颜色 */
-    private _color: string = "#333333";
-    get color(): string {
+    private _color: SColor = new SColor("#333333");
+    get color(): SColor {
         return this._color;
     }
-    set color(v: string) {
+    set color(v: SColor) {
         this._color = v;
         this.update();
     }
@@ -48,7 +49,7 @@ export class STextItem extends SObjectItem {
     }
 
     /** 背景色 */
-    private _backgroundColor: SColor = new SColor("#00000000");
+    private _backgroundColor: SColor = SColor.Transparent;
     get backgroundColor(): SColor {
         return this._backgroundColor;
     }
@@ -58,7 +59,7 @@ export class STextItem extends SObjectItem {
     }
 
     /** 边框色 */
-    private _strokeColor: SColor = new SColor("#00000000");
+    private _strokeColor: SColor = SColor.Black;
     get strokeColor(): SColor {
         return this._strokeColor;
     }
@@ -67,15 +68,23 @@ export class STextItem extends SObjectItem {
         this.update();
     }
 
-    private _showBorder: boolean = false;
-    get showBorder(): boolean {
-        return this._showBorder;
+    /** 边框宽度 */
+    private _lineWidth: number = 1;
+    get lineWidth(): number {
+        return this._lineWidth;
     }
-    set showBorder(v: boolean) {
-        if (this._showBorder === v) {
-            return;
-        }
-        this._showBorder = v;
+    set lineWidth(v: number) {
+        this._lineWidth = v;
+        this.update();
+    }
+
+    /** 边框样式    */
+    private _borderStyle: SLineStyle = SLineStyle.None;
+    get borderStyle(): SLineStyle {
+        return this._borderStyle;
+    }
+    set borderStyle(v: SLineStyle) {
+        this._borderStyle = v;
         this.update();
     }
 
@@ -93,6 +102,7 @@ export class STextItem extends SObjectItem {
         this._text = str;
         this._font = new SFont("sans-serif", 12);
         this.height = 12;
+        this.isTransform = false;
     } // Constructor
 
     /**
@@ -121,7 +131,17 @@ export class STextItem extends SObjectItem {
      */
     protected drawShowText(painter: SPainter): void {
         //绘制矩形轮廓
-        if (this.showBorder) {
+        if (this.selected) {
+            this.borderStyle = SLineStyle.Dashed;
+        } else {
+            this.borderStyle = SLineStyle.None;
+        }
+        if (this.borderStyle == SLineStyle.Dashed) {
+            painter.pen.lineDash = [
+                this.lineWidth * 3,
+                this.lineWidth * 7
+            ];
+            painter.pen.lineWidth = this.lineWidth;
             painter.brush.color = this.backgroundColor;
             painter.pen.color = this.strokeColor;
             painter.drawRect(this.boundingRect());
@@ -133,8 +153,8 @@ export class STextItem extends SObjectItem {
         this._textArr.forEach((text: string, index: number) => {
             painter.drawText(
                 text,
-                2,
-                index * (this.font.size + 2) + 2,
+                (this.font.size / 4),
+                index * (this.font.size * 1.25) + (this.font.size / 4),
                 this.maxWidth
             );
         });
@@ -146,19 +166,22 @@ export class STextItem extends SObjectItem {
      */
     protected drawFormatText(): void {
         if (this._painter instanceof SPainter) {
+            this._painter.save();
+            this._painter.font = this.font;
             let textMaxWidth = 0;
-            let textHeight: number = this.font.size;
+            let fontSize: number = this.font.size;
             this._textArr.forEach((text: string, index: number) => {
                 let textWidth: number = this._painter
-                    ? this._painter.textWidth(text) + 4
-                    : 4;
+                    ? this._painter.textWidth(text) + (fontSize / 2)
+                    : (fontSize / 2);
                 if (textWidth > textMaxWidth) {
                     textMaxWidth = textWidth;
                 }
             });
             // 在绘制文本后计算文本的宽高
             this.width = textMaxWidth;
-            this.height = (textHeight + 2) * this._textArr.length;
+            this.height = (fontSize * 1.25) * this._textArr.length + (fontSize / 8);
+            this._painter.restore();
         }
     } // Function drawFormatText()