浏览代码

修改结构发布

haojianlong 4 年之前
父节点
当前提交
56aa6cd84c

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

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/draw",
-    "version": "2.1.89",
+    "version": "2.1.90",
     "description": "上格云绘制引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",

+ 1 - 1
saga-web-draw/src/SFont.ts

@@ -19,7 +19,7 @@ export class SFont {
     textAlign = STextAlign.Start;
 
     /** 文本基线对齐选项 */
-    private textBaseLine = STextBaseLine.Top;
+    readonly textBaseLine = STextBaseLine.Top;
 
     /** 文本方向 */
     textDirection = STextDirection.Inherit;

+ 1 - 1
saga-web-draw/src/engines/SCanvasPaintEngine.ts

@@ -519,7 +519,7 @@ export class SCanvasPaintEngine extends SPaintEngine {
     private setFont(): void {
         this._canvas.font = `${this.state.font.size}px ${this.state.font.name}`;
         this.setTextAlign(this.state.font.textAlign);
-        // this.setBaseLine(this.state.font.textBaseLine);
+        this.setBaseLine(this.state.font.textBaseLine);
         this.setTextDirection(this.state.font.textDirection);
     } // Function setFont()
 

+ 1 - 1
saga-web-graph/.eslintrc.js

@@ -20,7 +20,7 @@ module.exports = {
     },
     rules: {
         // 缩进
-        'indent': ['error', 4],                         // 缩进控制4空格
+        'indent': ['error', 4, { SwitchCase: 1 }],      // 缩进控制4空格
         'max-len': ['error', 120],                      // 每行字符不超过120
         'no-mixed-spaces-and-tabs': 'error',            // 禁止使用空格和tab混合缩进
         // 语句

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

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

+ 9 - 7
saga-web-graph/src/SGraphItem.ts

@@ -373,18 +373,19 @@ export class SGraphItem extends SObject {
                 return true;
             }
         }
-
+        // 选择
+        let select = false;
         if (this.selectable) {
-            this.clickSelect(event);
+            select = this.clickSelect(event);
         }
-
+        // 移动
         if (this.moveable) {
             this._mouseDownPos = new SPoint(event.x, event.y);
             this._isMoving = true;
             this.grabItem(this);
             return true;
         }
-        return false;
+        return select;
     } // Function onMouseDown()
 
     /**
@@ -589,14 +590,14 @@ export class SGraphItem extends SObject {
      *
      * @param   event       事件参数
      */
-    private clickSelect(event: SMouseEvent): void {
+    private clickSelect(event: SMouseEvent): boolean {
         // 如果Item不可被选中,或没有按下鼠标左键,则直接返回
         if (!this.selectable || event.buttons != SMouseButton.LeftButton) {
-            return;
+            return false;
         }
         const scene = this.scene;
         if (scene == null) {
-            return;
+            return false;
         }
         // 如果按下Ctrl键,只改变当前item的选择标志
         if (event.ctrlKey) {
@@ -604,5 +605,6 @@ export class SGraphItem extends SObject {
         } else {
             scene.selectContainer.setItem(this);
         }
+        return true;
     } // Function clickSelect()
 } // Class SGraphItem

+ 82 - 1
saga-web-graph/src/SGraphSelectContainer.ts

@@ -88,5 +88,86 @@ export class SGraphSelectContainer extends SObject {
      *
      * @param   type    对齐方式
      * */
-    layout(type: SGraphLayoutType): void {} // Function clear()
+    layout(type: SGraphLayoutType): void {
+        if (this.itemList.length < 2) {
+            return;
+        }
+        switch (type) {
+            case SGraphLayoutType.Left:
+                this.alignLeft();
+                break;
+            case SGraphLayoutType.Bottom:
+                this.alignBottom();
+                break;
+            case SGraphLayoutType.center:
+                this.alignCenter();
+                break;
+            case SGraphLayoutType.Horizontal:
+                this.alignHorizontal();
+                break;
+            case SGraphLayoutType.middle:
+                this.alignMiddle();
+                break;
+            case SGraphLayoutType.Right:
+                this.alignRight();
+                break;
+            case SGraphLayoutType.Top:
+                this.alignTop();
+                break;
+            case SGraphLayoutType.Vertical:
+                this.alignVertical();
+                break;
+            default:
+                console.log("对齐类型不存在");
+                break;
+        }
+    } // Function layout()
+
+    /**
+     * 左对齐
+     *
+     * */
+    private alignLeft(): void {} // Function alignLeft()
+
+    /**
+     * 顶对齐
+     *
+     * */
+    private alignTop(): void {} // Function alignTop()
+
+    /**
+     * 右对齐
+     *
+     * */
+    private alignRight(): void {} // Function alignRight()
+
+    /**
+     * 底对齐
+     *
+     * */
+    private alignBottom(): void {} // Function alignBottom()
+
+    /**
+     * 水平居中对齐
+     *
+     * */
+    private alignCenter(): void {} // Function alignCenter()
+
+    /**
+     * 垂直居中对齐
+     *
+     * */
+    private alignMiddle(): void {} // Function alignMiddle()
+
+    /**
+     * 水平分散
+     *
+     * */
+    private alignVertical(): void {} // Function alignVertical()
+
+    /**
+     * 垂直分散
+     *
+     * */
+    private alignHorizontal(): void {} // Function alignHorizontal()
 } // Class SGraphSelectContainer

+ 1 - 1
saga-web-big/src/enums/SImageShowType.ts

@@ -9,5 +9,5 @@ export enum SImageShowType {
     /** 自适应 */
     AutoFit,
     /** 等比缩放 */
-    Equivalency,
+    Equivalency
 } // Enum SImageShowType

+ 11 - 1
saga-web-graph/src/index.ts

@@ -38,6 +38,11 @@ import { SGraphPointListDelete } from "./commands/SGraphPointListDelete";
 import { SGraphPointListInsert } from "./commands/SGraphPointListInsert";
 import { SGraphPointListUpdate } from "./commands/SGraphPointListUpdate";
 import { SGraphPropertyCommand } from "./commands/SGraphPropertyCommand";
+import { SImageItem } from "./items/SImageItem";
+import { SObjectItem } from "./items/SObjectItem";
+import { SAnchorItem } from "./items/SAnchorItem";
+import { STextItem } from "./items/STextItem";
+import { SImageShowType } from "./enums/SImageShowType";
 
 export {
     SGraphItem,
@@ -50,5 +55,10 @@ export {
     SGraphPointListDelete,
     SGraphPointListInsert,
     SGraphPointListUpdate,
-    SGraphPropertyCommand
+    SGraphPropertyCommand,
+    SImageItem,
+    SObjectItem,
+    SAnchorItem,
+    STextItem,
+    SImageShowType
 };

+ 1 - 1
saga-web-big/src/items/topology/SAnchorItem.ts

@@ -1,5 +1,5 @@
-import { SGraphItem } from "@saga-web/graph/lib";
 import { SPainter, SColor } from "@saga-web/draw/lib";
+import { SGraphItem } from "../SGraphItem";
 
 /**
  * 锚点item

+ 1 - 1
saga-web-big/src/items/SImageItem.ts

@@ -1,7 +1,7 @@
 import { SObjectItem } from "./SObjectItem";
 import { SPainter, SRect, SSize } from "@saga-web/draw/lib";
-import { SGraphItem } from "@saga-web/graph/lib";
 import { SImageShowType } from "../enums/SImageShowType";
+import { SGraphItem } from "../SGraphItem";
 
 /**
  * 图片item

+ 2 - 2
saga-web-big/src/items/SObjectItem.ts

@@ -1,6 +1,6 @@
-import { SAnchorItem } from "./topology/SAnchorItem";
+import { SAnchorItem } from "./SAnchorItem";
 import { SSize } from "@saga-web/draw/lib";
-import { SGraphItem } from "@saga-web/graph/lib";
+import { SGraphItem } from "..";
 
 /**
  * 对象item

+ 1 - 4
saga-web-big/src/items/STextItem.ts

@@ -1,6 +1,6 @@
 import { SObjectItem } from "./SObjectItem";
 import { SPainter, SRect, SColor, SFont } from "@saga-web/draw/lib";
-import { SGraphItem } from "@saga-web/graph/lib";
+import { SGraphItem } from "../SGraphItem";
 
 /**
  * 文本item
@@ -67,7 +67,6 @@ export class STextItem extends SObjectItem {
      * 绘制编辑和创建状态文本Item
      *
      * @param painter    绘制类
-     *
      */
     protected drawEditText(painter: SPainter): void {
         //绘制文本
@@ -87,7 +86,6 @@ export class STextItem extends SObjectItem {
      * 绘制显示状态文本Item
      *
      * @param painter    绘制类
-     *
      */
     protected drawShowText(painter: SPainter): void {
         // 绘制文本
@@ -105,7 +103,6 @@ export class STextItem extends SObjectItem {
      * 根据换行切割文本,绘制多行并计算外轮廓宽高
      *
      * @param painter    绘制类
-     *
      */
     protected drawFormatText(painter: SPainter): void {
         let textArr: string[] = this.text.split(/\n/g);