浏览代码

'包修改'

zhangyu 5 年之前
父节点
当前提交
c4fe4dfaee
共有 1 个文件被更改,包括 5 次插入18 次删除
  1. 5 18
      saga-web-big/src/items/STextItem.ts

+ 5 - 18
saga-web-big/src/items/STextItem.ts

@@ -7,7 +7,7 @@ import { SGraphItem } from "@saga-web/graph/lib";
  *
  * @author  张宇(taohuzy@163.com)
  */
-class TextItem extends SObjectItem {
+export class TextItem extends SObjectItem {
     /** 文本内容 */
     private _text: string = "";
     get text(): string {
@@ -52,9 +52,6 @@ class TextItem extends SObjectItem {
         this._text = str;
         this._font = new SFont("sans-serif", 12);
         this.height = 12;
-        this.moveable = true;
-        this.selectable = true;
-        this.selected = true;
     } // Constructor
 
     /**
@@ -67,16 +64,6 @@ class TextItem extends SObjectItem {
     } // Function boundingRect()
 
     /**
-     * 判断点是否在区域内
-     *
-     * @param x
-     * @param y
-     */
-    contains(x: number, y: number): boolean {
-        return this.boundingRect().contains(x, y);
-    } // Function contains()
-
-    /**
      * 绘制编辑和创建状态文本Item
      *
      * @param painter    绘制类
@@ -125,16 +112,16 @@ class TextItem extends SObjectItem {
         let textMaxWidth = 0;
         let textHeight: number = this.font.size;
         textArr.forEach((text: string, index: number) => {
-            let textWidth: number = painter.textWidth(text);
-            if (textWidth > textMaxWidth) {
-                textMaxWidth = textWidth;
-            }
             painter.drawText(
                 text,
                 0,
                 index * (textHeight + 2) + 2,
                 this.maxWidth
             );
+            let textWidth: number = painter.textWidth(text);
+            if (textWidth > textMaxWidth) {
+                textMaxWidth = textWidth;
+            }
         });
         // 在绘制文本后计算文本的宽高
         this.width = textMaxWidth;