From 2bd0754133a4819c795557d98357dec3d86c230f Mon Sep 17 00:00:00 2001 From: Waiting Date: Sat, 11 Mar 2023 12:46:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B9=E6=B3=95=E5=90=8D=E7=A8=B1=E5=8D=80?= =?UTF-8?q?=E5=A1=8A=E4=BD=8D=E7=BD=AE=E5=84=AA=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ClassShape.ts | 13 ++++++++----- src/Graph.ts | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/ClassShape.ts b/src/ClassShape.ts index 14bfc67..5db0f79 100644 --- a/src/ClassShape.ts +++ b/src/ClassShape.ts @@ -3,6 +3,11 @@ import {Utils} from './Utils' const myUtils = new Utils() +// 類名稱區塊高度 +const classNameBoxHeight = 30; +// 方法名稱區塊高度 +const funcNameBoxHeight = 40; + /** * 註冊 類聲明 中 方法名稱位置 計算函數 */ @@ -13,7 +18,7 @@ Graph.registerPortLayout( return { position: { x: 0, - y: (index + 1) * elemBBox.height, + y: classNameBoxHeight + index * funcNameBoxHeight, }, angle: 0, } @@ -142,8 +147,6 @@ class ClassShape { */ public createClassShape(className: string, funcNames: string[]) { - const height = 30 - // 計算 類聲明 圖形寬度 let maxWidth = 100 maxWidth = Math.max(maxWidth, myUtils.getTextWidth(className, "14px bold") + 60) @@ -157,7 +160,7 @@ class ClassShape { "shape": 'clazz-shape', "label": className, "width": maxWidth, - "height": height, + "height": classNameBoxHeight, "fontSize": 14, "position": { "x": 100, @@ -178,7 +181,7 @@ class ClassShape { "attrs": { "func": { width: maxWidth, - height: height + 10, + height: funcNameBoxHeight, }, "funcName": { ref: 'func', diff --git a/src/Graph.ts b/src/Graph.ts index 0cc3d4c..f21842f 100644 --- a/src/Graph.ts +++ b/src/Graph.ts @@ -74,6 +74,7 @@ export let initGraph = function (codeBlocks: String[]) { const posY = e.offsetY - (codeBlock.getProp().size.height / 2) codeBlock.prop("position", {x: posX, y: posY}) + // 顯示 代碼塊,並更新按鈕內容 codeBlock.show() toggleText.textContent = '-' toggleText.setAttribute('dy', '0.3em')