@yanqirenshi/d3.pad 0.2.1 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -18
- package/dist/index.d.ts +9 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -6
- package/dist/pad/Pad.d.ts +22 -0
- package/dist/pad/Pad.d.ts.map +1 -0
- package/dist/pad/Pad.js +141 -0
- package/dist/pad/PadDiagram.d.ts +19 -0
- package/dist/pad/PadDiagram.d.ts.map +1 -0
- package/dist/pad/PadDiagram.js +64 -0
- package/dist/pad/Theme.d.ts +7 -0
- package/dist/pad/Theme.d.ts.map +1 -0
- package/dist/pad/Theme.js +10 -0
- package/dist/pad/datamodels/Assignment.d.ts +81 -0
- package/dist/pad/datamodels/Assignment.d.ts.map +1 -0
- package/dist/pad/datamodels/Assignment.js +51 -0
- package/dist/pad/datamodels/Call.d.ts +95 -0
- package/dist/pad/datamodels/Call.d.ts.map +1 -0
- package/dist/pad/datamodels/Call.js +83 -0
- package/dist/pad/datamodels/Connector.d.ts +35 -0
- package/dist/pad/datamodels/Connector.d.ts.map +1 -0
- package/dist/pad/datamodels/Connector.js +23 -0
- package/dist/pad/datamodels/Group.d.ts +78 -0
- package/dist/pad/datamodels/Group.d.ts.map +1 -0
- package/dist/pad/datamodels/Group.js +71 -0
- package/dist/pad/datamodels/Loop.d.ts +80 -0
- package/dist/pad/datamodels/Loop.d.ts.map +1 -0
- package/dist/pad/datamodels/Loop.js +77 -0
- package/dist/pad/datamodels/Parallel.d.ts +85 -0
- package/dist/pad/datamodels/Parallel.d.ts.map +1 -0
- package/dist/pad/datamodels/Parallel.js +80 -0
- package/dist/pad/datamodels/Process.d.ts +79 -0
- package/dist/pad/datamodels/Process.d.ts.map +1 -0
- package/dist/pad/datamodels/Process.js +59 -0
- package/dist/pad/datamodels/Selection.d.ts +76 -0
- package/dist/pad/datamodels/Selection.d.ts.map +1 -0
- package/dist/pad/datamodels/Selection.js +81 -0
- package/dist/pad/datamodels/Terminal.d.ts +61 -0
- package/dist/pad/datamodels/Terminal.d.ts.map +1 -0
- package/dist/pad/datamodels/Terminal.js +50 -0
- package/dist/pad/elements.d.ts +2 -0
- package/dist/pad/elements.d.ts.map +1 -0
- package/dist/pad/elements.js +32 -0
- package/dist/pad/painters/Assignment.d.ts +4 -0
- package/dist/pad/painters/Assignment.d.ts.map +1 -0
- package/dist/pad/painters/Assignment.js +72 -0
- package/dist/pad/painters/Call.d.ts +4 -0
- package/dist/pad/painters/Call.d.ts.map +1 -0
- package/dist/pad/painters/Call.js +134 -0
- package/dist/pad/painters/Connector.d.ts +4 -0
- package/dist/pad/painters/Connector.d.ts.map +1 -0
- package/dist/pad/painters/Connector.js +15 -0
- package/dist/pad/painters/Group.d.ts +4 -0
- package/dist/pad/painters/Group.d.ts.map +1 -0
- package/dist/pad/painters/Group.js +99 -0
- package/dist/pad/painters/Loop.d.ts +4 -0
- package/dist/pad/painters/Loop.d.ts.map +1 -0
- package/dist/pad/painters/Loop.js +126 -0
- package/dist/pad/painters/Parallel.d.ts +4 -0
- package/dist/pad/painters/Parallel.d.ts.map +1 -0
- package/dist/pad/painters/Parallel.js +102 -0
- package/dist/pad/painters/Process.d.ts +5 -0
- package/dist/pad/painters/Process.d.ts.map +1 -0
- package/dist/pad/painters/Process.js +132 -0
- package/dist/pad/painters/Selection.d.ts +4 -0
- package/dist/pad/painters/Selection.d.ts.map +1 -0
- package/dist/pad/painters/Selection.js +126 -0
- package/dist/pad/painters/Terminal.d.ts +4 -0
- package/dist/pad/painters/Terminal.d.ts.map +1 -0
- package/dist/pad/painters/Terminal.js +19 -0
- package/dist/pad/painters/interactive.d.ts +2 -0
- package/dist/pad/painters/interactive.d.ts.map +1 -0
- package/dist/pad/painters/interactive.js +15 -0
- package/dist/pad/registry.d.ts +14 -0
- package/dist/pad/registry.d.ts.map +1 -0
- package/dist/pad/registry.js +25 -0
- package/dist/pad/types.d.ts +16 -0
- package/dist/pad/types.d.ts.map +1 -0
- package/package.json +7 -9
- package/src/index.ts +19 -9
- package/src/pad/Pad.ts +160 -0
- package/src/pad/PadDiagram.tsx +126 -0
- package/src/pad/Theme.ts +11 -0
- package/src/pad/datamodels/Assignment.ts +55 -0
- package/src/pad/datamodels/Call.ts +91 -0
- package/src/pad/datamodels/Connector.ts +25 -0
- package/src/pad/datamodels/Group.ts +76 -0
- package/src/pad/datamodels/Loop.ts +82 -0
- package/src/pad/datamodels/Parallel.ts +85 -0
- package/src/pad/datamodels/Process.ts +63 -0
- package/src/pad/datamodels/Selection.ts +87 -0
- package/src/pad/datamodels/Terminal.ts +57 -0
- package/src/pad/elements.ts +34 -0
- package/src/pad/painters/Assignment.ts +87 -0
- package/src/pad/painters/Call.ts +152 -0
- package/src/pad/painters/Connector.ts +15 -0
- package/src/pad/painters/Group.ts +116 -0
- package/src/pad/painters/Loop.ts +144 -0
- package/src/pad/painters/Parallel.ts +115 -0
- package/src/pad/painters/Process.ts +153 -0
- package/src/pad/painters/Selection.ts +150 -0
- package/src/pad/painters/Terminal.ts +23 -0
- package/src/pad/painters/interactive.ts +15 -0
- package/src/pad/registry.ts +38 -0
- package/src/pad/types.ts +21 -0
- package/dist/renderers/D3PadRenderer.d.ts +0 -34
- package/dist/renderers/D3PadRenderer.d.ts.map +0 -1
- package/dist/renderers/D3PadRenderer.js +0 -112
- package/dist/renderers/PadNodeRenderer.d.ts +0 -145
- package/dist/renderers/PadNodeRenderer.d.ts.map +0 -1
- package/dist/renderers/PadNodeRenderer.js +0 -440
- package/dist/renderers/blocks/EndBlockGeometry.d.ts +0 -33
- package/dist/renderers/blocks/EndBlockGeometry.d.ts.map +0 -1
- package/dist/renderers/blocks/EndBlockGeometry.js +0 -44
- package/dist/renderers/blocks/EndRenderer.d.ts +0 -10
- package/dist/renderers/blocks/EndRenderer.d.ts.map +0 -1
- package/dist/renderers/blocks/EndRenderer.js +0 -38
- package/dist/renderers/blocks/EndRendererProps.d.ts +0 -6
- package/dist/renderers/blocks/EndRendererProps.d.ts.map +0 -1
- package/dist/renderers/blocks/FunctionContainerGeometry.d.ts +0 -29
- package/dist/renderers/blocks/FunctionContainerGeometry.d.ts.map +0 -1
- package/dist/renderers/blocks/FunctionContainerGeometry.js +0 -46
- package/dist/renderers/blocks/FunctionContainerRenderer.d.ts +0 -13
- package/dist/renderers/blocks/FunctionContainerRenderer.d.ts.map +0 -1
- package/dist/renderers/blocks/FunctionContainerRenderer.js +0 -49
- package/dist/renderers/blocks/FunctionHeaderGeometry.d.ts +0 -20
- package/dist/renderers/blocks/FunctionHeaderGeometry.d.ts.map +0 -1
- package/dist/renderers/blocks/FunctionHeaderGeometry.js +0 -35
- package/dist/renderers/blocks/FunctionHeaderProps.d.ts +0 -7
- package/dist/renderers/blocks/FunctionHeaderProps.d.ts.map +0 -1
- package/dist/renderers/blocks/FunctionHeaderProps.js +0 -1
- package/dist/renderers/blocks/FunctionHeaderRenderer.d.ts +0 -11
- package/dist/renderers/blocks/FunctionHeaderRenderer.d.ts.map +0 -1
- package/dist/renderers/blocks/FunctionHeaderRenderer.js +0 -36
- package/dist/renderers/blocks/IfBlockGeometry.d.ts +0 -42
- package/dist/renderers/blocks/IfBlockGeometry.d.ts.map +0 -1
- package/dist/renderers/blocks/IfBlockGeometry.js +0 -83
- package/dist/renderers/blocks/IfRenderer.d.ts +0 -10
- package/dist/renderers/blocks/IfRenderer.d.ts.map +0 -1
- package/dist/renderers/blocks/IfRenderer.js +0 -69
- package/dist/renderers/blocks/IfRendererProps.d.ts +0 -7
- package/dist/renderers/blocks/IfRendererProps.d.ts.map +0 -1
- package/dist/renderers/blocks/IfRendererProps.js +0 -1
- package/dist/renderers/blocks/LoopRenderer.d.ts +0 -12
- package/dist/renderers/blocks/LoopRenderer.d.ts.map +0 -1
- package/dist/renderers/blocks/LoopRenderer.js +0 -37
- package/dist/renderers/blocks/LoopRendererProps.d.ts +0 -8
- package/dist/renderers/blocks/LoopRendererProps.d.ts.map +0 -1
- package/dist/renderers/blocks/LoopRendererProps.js +0 -1
- package/dist/renderers/blocks/Point.d.ts +0 -2
- package/dist/renderers/blocks/Point.d.ts.map +0 -1
- package/dist/renderers/blocks/Point.js +0 -1
- package/dist/renderers/blocks/StartBlockGeometry.d.ts +0 -38
- package/dist/renderers/blocks/StartBlockGeometry.d.ts.map +0 -1
- package/dist/renderers/blocks/StartBlockGeometry.js +0 -56
- package/dist/renderers/blocks/StartRenderer.d.ts +0 -10
- package/dist/renderers/blocks/StartRenderer.d.ts.map +0 -1
- package/dist/renderers/blocks/StartRenderer.js +0 -39
- package/dist/renderers/blocks/StartRendererProps.d.ts +0 -6
- package/dist/renderers/blocks/StartRendererProps.d.ts.map +0 -1
- package/dist/renderers/blocks/StartRendererProps.js +0 -1
- package/dist/utils/layout.d.ts +0 -14
- package/dist/utils/layout.d.ts.map +0 -1
- package/dist/utils/layout.js +0 -186
- package/src/renderers/D3PadRenderer.tsx +0 -145
- package/src/renderers/PadNodeRenderer.ts +0 -517
- package/src/renderers/blocks/EndBlockGeometry.ts +0 -52
- package/src/renderers/blocks/EndRenderer.tsx +0 -48
- package/src/renderers/blocks/EndRendererProps.ts +0 -5
- package/src/renderers/blocks/FunctionContainerGeometry.ts +0 -54
- package/src/renderers/blocks/FunctionContainerRenderer.tsx +0 -62
- package/src/renderers/blocks/FunctionHeaderGeometry.ts +0 -43
- package/src/renderers/blocks/FunctionHeaderProps.ts +0 -6
- package/src/renderers/blocks/FunctionHeaderRenderer.tsx +0 -47
- package/src/renderers/blocks/IfBlockGeometry.ts +0 -98
- package/src/renderers/blocks/IfRenderer.tsx +0 -88
- package/src/renderers/blocks/IfRendererProps.ts +0 -7
- package/src/renderers/blocks/LoopRenderer.tsx +0 -50
- package/src/renderers/blocks/LoopRendererProps.ts +0 -7
- package/src/renderers/blocks/Point.ts +0 -4
- package/src/renderers/blocks/README.md +0 -29
- package/src/renderers/blocks/StartBlockGeometry.ts +0 -66
- package/src/renderers/blocks/StartRenderer.tsx +0 -49
- package/src/renderers/blocks/StartRendererProps.ts +0 -5
- package/src/utils/layout.ts +0 -247
- /package/dist/{renderers/blocks/EndRendererProps.js → pad/types.js} +0 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// CALL(呼び出し)の描画クラス。箱自体は PROCESS と全く同じ見た目
|
|
2
|
+
// (painters/Process.ts の drawCells をそのまま再利用)。cells の位置にリンク(links)を付けられる。
|
|
3
|
+
// 呼び出し先のノードの配列(callee。さらにその先の呼び出しも含めて全階層分)があり、かつ「開く」状態
|
|
4
|
+
// (data.expanded)のときは、箱の右側に呼び出し先の丸ごとの PAD(開始~終了ターミネータ込み。呼び出し先自身が
|
|
5
|
+
// さらに CALL を持っていれば、その箱も同じ規則で再帰的に展開される)を別の Pad インスタンスとして描画し、
|
|
6
|
+
// 「複数処理の実行」と同じ規則(実行元となるこの箱から、横線を 1 本、呼び出し先 PAD の縦線へ好きな高さで
|
|
7
|
+
// つなぐ)に従って 1 本の横線を引く。callee が無ければ、箱だけを描画する。
|
|
8
|
+
//
|
|
9
|
+
// callee がある場合は、箱の右側、呼び出し先につなぐ横線の上に「開く/閉じる」のテキストリンク(文言は data.labels で
|
|
10
|
+
// 差し替えられる)を添え(展開・折りたたみのどちらでも常に同じ位置。#309。もとは箱の左の外で、最上位では SVG の左端で切れ、
|
|
11
|
+
// GROUP・LOOP・SELECTION の中では枠や文字に重なった)、クリックで data._core.expanded を反転し、data.redraw()
|
|
12
|
+
// (この PAD 全体を描き直す関数。Pad.ts と、LOOP・SELECTION・PARALLEL・GROUP の各 painter が data.redraw
|
|
13
|
+
// として伝播させる。呼び出し先の Pad にも、calleePad.draw(calleeG, data.redraw) で渡す)を呼んで、
|
|
14
|
+
// いちばん外の Pad からレイアウトをやり直す。
|
|
15
|
+
import { drawCells } from './Process.js';
|
|
16
|
+
import { attachClick } from './interactive.js';
|
|
17
|
+
import { START_RADIUS, BORDER_WIDTH } from '../datamodels/Terminal.js';
|
|
18
|
+
import { buildCalleePad } from '../datamodels/Call.js';
|
|
19
|
+
const CALLEE_GAP = 40;
|
|
20
|
+
const CALLEE_Y_OFFSET = START_RADIUS + BORDER_WIDTH;
|
|
21
|
+
const TOGGLE_LABEL_GAP = 6; // 箱の右端とラベルの間隔
|
|
22
|
+
const TOGGLE_LABEL_RISE = 16; // ラベルの中心を、横線(箱の高さの中央)より上に置く量
|
|
23
|
+
const TOGGLE_LABEL_CLEARANCE = 2; // ラベルの右端と、呼び出し先の開始の丸の左端の、最低の間隔
|
|
24
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
25
|
+
// 「開く」「閉じる」のクリック可能なテキストラベルを、箱の右端から TOGGLE_LABEL_GAP だけ離れた位置、
|
|
26
|
+
// 呼び出し先につなぐ横線(箱の高さの中央)の TOGGLE_LABEL_RISE だけ上に、左揃え(text-anchor:start)で描画する。
|
|
27
|
+
// ページ遷移ではないため <a> にはせず、下線付きテキストにクリックハンドラを直接つける。
|
|
28
|
+
// クリックは、開閉だけにする(箱へ伝えない。伝わると、開閉のたびに、箱のクリック〔onElementClick〕も呼ばれる。#309)。
|
|
29
|
+
function drawToggleLabel(g, x, y, text, data, onClick) {
|
|
30
|
+
return g.append('text')
|
|
31
|
+
.attr('x', x).attr('y', y)
|
|
32
|
+
.attr('text-anchor', 'start')
|
|
33
|
+
.attr('dominant-baseline', 'central')
|
|
34
|
+
.style('font-family', data.font.family)
|
|
35
|
+
.style('font-size', data.font.size)
|
|
36
|
+
.style('text-decoration', 'underline')
|
|
37
|
+
.style('cursor', 'pointer')
|
|
38
|
+
.attr('fill', data.font.color)
|
|
39
|
+
.text(text)
|
|
40
|
+
.on('click', (event) => {
|
|
41
|
+
if (event && event.stopPropagation)
|
|
42
|
+
event.stopPropagation();
|
|
43
|
+
onClick();
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
export default class Call {
|
|
47
|
+
draw(place, data) {
|
|
48
|
+
const g = place.append('g').attr('class', 'pad-call');
|
|
49
|
+
const totalWidth = drawCells(g, {
|
|
50
|
+
cells: data.cells,
|
|
51
|
+
dividers: data.dividers,
|
|
52
|
+
links: data.links,
|
|
53
|
+
font: data.font,
|
|
54
|
+
stroke: data.stroke,
|
|
55
|
+
chevron_depth: data.chevron_depth,
|
|
56
|
+
height: data.size.h,
|
|
57
|
+
});
|
|
58
|
+
// 外枠(テキストより先に挿入し、下に来るようにする)
|
|
59
|
+
g.insert('rect', ':first-child')
|
|
60
|
+
.attr('width', totalWidth)
|
|
61
|
+
.attr('height', data.size.h)
|
|
62
|
+
.attr('fill', '#fff')
|
|
63
|
+
.attr('stroke', data.stroke.color)
|
|
64
|
+
.attr('stroke-width', data.stroke.width);
|
|
65
|
+
// 呼び出し先がある場合、後続の要素(同じ本体内の次の行、または Pad 本体の次の要素)と重ならないよう、
|
|
66
|
+
// 自分の高さ(anchors.bottom.y)を datamodels/Call.ts の normalize() と同じ式で広げておく。
|
|
67
|
+
// ここで先に確定させないと、呼び出し元コンテナ(LOOP/SELECTION/PARALLEL/GROUP)側の行間隔の計算が
|
|
68
|
+
// この描画結果(post-draw)の anchors を参照するため、広げた分が反映されない。
|
|
69
|
+
let anchorHeight = data.size.h;
|
|
70
|
+
let calleePadMargin = 0;
|
|
71
|
+
let calleeG = null;
|
|
72
|
+
let calleeLine = null;
|
|
73
|
+
let calleeX = totalWidth + CALLEE_GAP;
|
|
74
|
+
const hasCallee = !!(data.callee && data.callee.length);
|
|
75
|
+
const toggle = () => {
|
|
76
|
+
if (data._core)
|
|
77
|
+
data._core.expanded = !data.expanded;
|
|
78
|
+
if (data.redraw)
|
|
79
|
+
data.redraw();
|
|
80
|
+
};
|
|
81
|
+
if (hasCallee && data.expanded) {
|
|
82
|
+
const calleePad = buildCalleePad(data.callee);
|
|
83
|
+
const calleeHeight = calleePad.layout().height;
|
|
84
|
+
calleePadMargin = calleePad._margin;
|
|
85
|
+
anchorHeight = Math.max(data.size.h, calleeHeight);
|
|
86
|
+
// 呼び出し元の箱の上端に揃えて(下方向にだけ)呼び出し先 PAD を並べる。上方向にはほぼ広がらないため、
|
|
87
|
+
// 直前の行(の呼び出し先 PAD)と重なることがない。開始ターミネータの中心が横線の高さに来るよう、
|
|
88
|
+
// 開始円の半径+枠線の太さ分だけ上にずらす。横線は箱の高さの中央から、呼び出し先 PAD の縦線へつなぐ
|
|
89
|
+
// (縦線のどの高さでつないでも良いという「複数処理の実行」の規則を満たす配置)。
|
|
90
|
+
calleeG = g.append('g').attr('transform', `translate(${calleeX}, ${-CALLEE_Y_OFFSET})`);
|
|
91
|
+
calleePad.onElementClick(data.onElementClick);
|
|
92
|
+
// 呼び出し先の中の CALL を開閉したときも、いちばん外の Pad から描き直す(自分用の redraw だと、
|
|
93
|
+
// 呼び出し先の中だけが描き直され、この CALL が確保した高さと、後ろの要素の位置が、そのまま残る。#307)
|
|
94
|
+
calleePad.draw(calleeG, data.redraw);
|
|
95
|
+
calleeLine = g.append('line')
|
|
96
|
+
.attr('x1', totalWidth).attr('y1', data.size.h / 2)
|
|
97
|
+
.attr('x2', calleeX + calleePadMargin).attr('y2', data.size.h / 2)
|
|
98
|
+
.attr('stroke', data.stroke.color)
|
|
99
|
+
.attr('stroke-width', data.stroke.width);
|
|
100
|
+
}
|
|
101
|
+
// 「開く」「閉じる」は展開・折りたたみのどちらでも箱の右側(横線の上)の同じ位置に添える
|
|
102
|
+
// (畳んだ状態では呼び出し先ぶんのスペースは確保しない=anchorHeight は箱自身の高さのまま)。
|
|
103
|
+
if (hasCallee) {
|
|
104
|
+
const labelX = totalWidth + TOGGLE_LABEL_GAP;
|
|
105
|
+
const label = drawToggleLabel(g, labelX, data.size.h / 2 - TOGGLE_LABEL_RISE, data.expanded ? data.labels.close : data.labels.open, data, toggle);
|
|
106
|
+
// 文言が長く、呼び出し先の開始の丸に届くときだけ、足りない分だけ呼び出し先を右へ寄せる(横方向だけ。高さは変わらない)。
|
|
107
|
+
// 既定の文言(「開く」「閉じる」)は、箱から丸まで 50px の中に収まるので、寄せない(寄せ幅が 0.5px 以下なら、実測の揺れとして寄せない)。
|
|
108
|
+
// 丸の左端は、呼び出し先の Pad の margin から開始の丸の半径を引いた位置。
|
|
109
|
+
if (calleeG) {
|
|
110
|
+
const node = label.node();
|
|
111
|
+
const labelWidth = node && node.getBBox ? node.getBBox().width : 0;
|
|
112
|
+
const circleLeft = calleeX + calleePadMargin - START_RADIUS;
|
|
113
|
+
const need = labelX + labelWidth + TOGGLE_LABEL_CLEARANCE - circleLeft;
|
|
114
|
+
if (need > 0.5) {
|
|
115
|
+
calleeX += Math.ceil(need);
|
|
116
|
+
calleeG.attr('transform', `translate(${calleeX}, ${-CALLEE_Y_OFFSET})`);
|
|
117
|
+
calleeLine.attr('x2', calleeX + calleePadMargin);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const x = data.position.x;
|
|
122
|
+
g.attr('transform', `translate(${x},${data.position.y})`);
|
|
123
|
+
data.size.w = totalWidth;
|
|
124
|
+
// anchor_at_spine=true(PAD 全体を 1 本の縦線でつなぐ用途)のときは縦線の位置(=左端)をそのまま
|
|
125
|
+
// anchor にする。false のときは自分自身の中央を anchor にする(単体表示ページ用)。
|
|
126
|
+
const anchorX = data.anchor_at_spine ? x : x + totalWidth / 2;
|
|
127
|
+
data.anchors = {
|
|
128
|
+
top: { x: anchorX, y: data.position.y },
|
|
129
|
+
bottom: { x: anchorX, y: data.position.y + anchorHeight },
|
|
130
|
+
};
|
|
131
|
+
attachClick(g, data);
|
|
132
|
+
return g;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Connector.d.ts","sourceRoot":"","sources":["../../../src/pad/painters/Connector.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,OAAO,SAAS;IAC1B,IAAI,CAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG;CAU9B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Connector(要素間をつなぐ縦線)の描画クラス。
|
|
2
|
+
// 正規化済みデータ(datamodels/Connector.ts の出力)を、d3 のセレクション
|
|
3
|
+
// (place) に対して描画する。
|
|
4
|
+
export default class Connector {
|
|
5
|
+
draw(place, data) {
|
|
6
|
+
return place.append('line')
|
|
7
|
+
.attr('class', 'pad-connector')
|
|
8
|
+
.attr('x1', data.from.x)
|
|
9
|
+
.attr('y1', data.from.y)
|
|
10
|
+
.attr('x2', data.to.x)
|
|
11
|
+
.attr('y2', data.to.y)
|
|
12
|
+
.attr('stroke', data.stroke.color)
|
|
13
|
+
.attr('stroke-width', data.stroke.width);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Group.d.ts","sourceRoot":"","sources":["../../../src/pad/painters/Group.ts"],"names":[],"mappings":"AAiBA,MAAM,CAAC,OAAO,OAAO,KAAK;IACtB,IAAI,CAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG;CAiG9B"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// GROUP(まとまり)の描画クラス。
|
|
2
|
+
// 正規化済みデータ(datamodels/Group.ts の出力)を、d3 のセレクション
|
|
3
|
+
// (place) に対して描画する。データの正規化には関知しない。
|
|
4
|
+
//
|
|
5
|
+
// 「複数処理の実行」の基本形そのもの: まとまりの名前(labelを表示する単純な1つの
|
|
6
|
+
// ボックス。LOOPのようなブラケット装飾は付けない)から横線を「連続性の
|
|
7
|
+
// ある処理のベース」(縦線)まで引き、その線の上に本体(rows)の左端を
|
|
8
|
+
// 揃えて積み重ねる。本体が複数行のときは、Pad.ts本体の要素間と同じ
|
|
9
|
+
// Connector要素で行間をつなぐ。行が1つしかない場合はベースの縦線・行間の
|
|
10
|
+
// Connectorのどちらも不要(つなぐ相手がいないため)。
|
|
11
|
+
import { ELEMENTS } from '../registry.js';
|
|
12
|
+
import { attachClick } from './interactive.js';
|
|
13
|
+
const LABEL_HEIGHT = 44; // 実行元ボックスの高さ
|
|
14
|
+
const LABEL_PADDING = 12; // 実行元ボックス内の左右余白
|
|
15
|
+
const CONNECTOR_GAP = 14; // 実行元ボックス右端から本体(ベースの線)までの横線の長さ
|
|
16
|
+
export default class Group {
|
|
17
|
+
draw(place, data) {
|
|
18
|
+
const g = place.append('g').attr('class', 'pad-group');
|
|
19
|
+
const rowGap = data.row_gap;
|
|
20
|
+
const connectorModel = new ELEMENTS.CONNECTOR.datamodel();
|
|
21
|
+
const connectorPainter = new ELEMENTS.CONNECTOR.painter();
|
|
22
|
+
const labelText = g.append('text')
|
|
23
|
+
.attr('x', LABEL_PADDING)
|
|
24
|
+
.attr('y', LABEL_HEIGHT / 2)
|
|
25
|
+
.attr('dominant-baseline', 'central')
|
|
26
|
+
.style('font-family', data.font.family)
|
|
27
|
+
.style('font-size', data.font.size)
|
|
28
|
+
.attr('fill', data.font.color)
|
|
29
|
+
.text(data.label);
|
|
30
|
+
const labelTextWidth = labelText.node().getBBox().width;
|
|
31
|
+
const labelBoxWidth = labelTextWidth + LABEL_PADDING * 2;
|
|
32
|
+
const bodyX = labelBoxWidth + CONNECTOR_GAP;
|
|
33
|
+
// 実行元ボックスの枠(テキストより先に挿入し、下に来るようにする)
|
|
34
|
+
g.insert('rect', 'text')
|
|
35
|
+
.attr('x', 0).attr('y', 0)
|
|
36
|
+
.attr('width', labelBoxWidth).attr('height', LABEL_HEIGHT)
|
|
37
|
+
.attr('fill', '#fff')
|
|
38
|
+
.attr('stroke', data.stroke.color)
|
|
39
|
+
.attr('stroke-width', data.stroke.width);
|
|
40
|
+
// 本体(各行。_classごとにregistry.tsで対応するデータクラス/描画クラスを引く)
|
|
41
|
+
let y = 0;
|
|
42
|
+
let maxRowWidth = 0;
|
|
43
|
+
let prevRowData = null;
|
|
44
|
+
let drawnRows = 0; // 実際に描いた行の数(知らない _class の行は、数えない)
|
|
45
|
+
data.rows.forEach((row) => {
|
|
46
|
+
const rowClass = row._class || 'PROCESS';
|
|
47
|
+
const entry = ELEMENTS[rowClass];
|
|
48
|
+
if (!entry)
|
|
49
|
+
return;
|
|
50
|
+
const model = new entry.datamodel();
|
|
51
|
+
const painter = new entry.painter();
|
|
52
|
+
// center:trueにして、行のanchorを自身の中心ではなく左端(=bodyX)に
|
|
53
|
+
// する。「連続性のある処理のベース」の規則(要素の左端を線上に
|
|
54
|
+
// 配置する)に合わせ、行同士を結ぶConnectorがまっすぐな縦線になる
|
|
55
|
+
// ようにする。
|
|
56
|
+
const rowData = model.normalize(row, { x: bodyX, y, width: 0, center: true });
|
|
57
|
+
rowData.redraw = data.redraw;
|
|
58
|
+
rowData.onElementClick = data.onElementClick;
|
|
59
|
+
painter.draw(g, rowData);
|
|
60
|
+
if (prevRowData) {
|
|
61
|
+
const connector = connectorModel.normalize(prevRowData.anchors.bottom, rowData.anchors.top);
|
|
62
|
+
connectorPainter.draw(g, connector);
|
|
63
|
+
}
|
|
64
|
+
prevRowData = rowData;
|
|
65
|
+
maxRowWidth = Math.max(maxRowWidth, rowData.size ? rowData.size.w : 0);
|
|
66
|
+
y = rowData.anchors.bottom.y + rowGap;
|
|
67
|
+
drawnRows++;
|
|
68
|
+
});
|
|
69
|
+
// 本体の高さ(描いた行だけ)。条件・ラベルの箱は、行が無くても描くので、それを最低の高さとする(datamodels と同じ式。#307)
|
|
70
|
+
const bodyHeight = drawnRows ? y - rowGap : 0;
|
|
71
|
+
const totalHeight = Math.max(LABEL_HEIGHT, bodyHeight);
|
|
72
|
+
const totalWidth = bodyX + maxRowWidth;
|
|
73
|
+
// 実行元ボックスとベースの線をつなぐ横線(ボックスの高さの中央)
|
|
74
|
+
g.append('line')
|
|
75
|
+
.attr('x1', labelBoxWidth).attr('y1', LABEL_HEIGHT / 2)
|
|
76
|
+
.attr('x2', bodyX).attr('y2', LABEL_HEIGHT / 2)
|
|
77
|
+
.attr('stroke', data.stroke.color)
|
|
78
|
+
.attr('stroke-width', data.stroke.width);
|
|
79
|
+
// 「連続性のある処理のベース」(縦線、本体全高)。行が1つしかない
|
|
80
|
+
// 場合はつなぐ相手がいないため描画しない。
|
|
81
|
+
if (drawnRows >= 2) {
|
|
82
|
+
g.append('line')
|
|
83
|
+
.attr('x1', bodyX).attr('y1', 0)
|
|
84
|
+
.attr('x2', bodyX).attr('y2', bodyHeight)
|
|
85
|
+
.attr('stroke', data.stroke.color)
|
|
86
|
+
.attr('stroke-width', data.stroke.width);
|
|
87
|
+
}
|
|
88
|
+
const x = data.position.x;
|
|
89
|
+
g.attr('transform', `translate(${x},${data.position.y})`);
|
|
90
|
+
data.size = { w: totalWidth, h: totalHeight };
|
|
91
|
+
const anchorX = data.anchor_at_spine ? x : x + totalWidth / 2;
|
|
92
|
+
data.anchors = {
|
|
93
|
+
top: { x: anchorX, y: data.position.y },
|
|
94
|
+
bottom: { x: anchorX, y: data.position.y + totalHeight },
|
|
95
|
+
};
|
|
96
|
+
attachClick(g, data);
|
|
97
|
+
return g;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Loop.d.ts","sourceRoot":"","sources":["../../../src/pad/painters/Loop.ts"],"names":[],"mappings":"AAwBA,MAAM,CAAC,OAAO,OAAO,IAAI;IACrB,IAAI,CAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG;CAsH9B"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// LOOP(反復)の描画クラス。
|
|
2
|
+
// 正規化済みデータ(datamodels/Loop.ts の出力)を、d3 のセレクション
|
|
3
|
+
// (place) に対して描画する。データの正規化には関知しない。
|
|
4
|
+
//
|
|
5
|
+
// 反復の条件のラベル(本体の先頭行に揃えて配置): 条件の箱の片側にブラケット(矩形、
|
|
6
|
+
// ラベルの高さぶんのみ)を添え、条件の箱とブラケットで二重線を成す。
|
|
7
|
+
// 前判定(test: 'pre'。既定)は二重線が条件の箱の左、後判定(test: 'post')は右。
|
|
8
|
+
// 二重線の外側の端から横線で内側セパレータへつなぐ。
|
|
9
|
+
// 内側セパレータ(縦線、本体全高)が本体の縦の連続性を表すため、ブラケット
|
|
10
|
+
// 自体はラベルの高さぶんだけでよい(SELECTIONの条件列のような「その場所自体が
|
|
11
|
+
// スパインの一部」ではなく、ブラケットの横に本体が続く構造のため)。
|
|
12
|
+
// 内側セパレータの右に本体(各行はregistry.tsで対応するクラスを引き、その
|
|
13
|
+
// painterでそのまま描画する。_class省略時はPROCESS扱い。これによりPARALLEL
|
|
14
|
+
// 等を本体の1行として入れ子にできる)を積み重ねる。本体が複数行のときは、
|
|
15
|
+
// Pad.ts本体の要素間と同じConnector要素で行間をつなぎ、処理の連続性を表す。
|
|
16
|
+
import { ELEMENTS } from '../registry.js';
|
|
17
|
+
import { attachClick } from './interactive.js';
|
|
18
|
+
const BRACKET_WIDTH = 12; // 条件ラベルに添えるブラケット(矩形)の幅
|
|
19
|
+
const LABEL_PADDING = 12; // 条件ラベル内の左右余白
|
|
20
|
+
const LABEL_HEIGHT = 44; // 条件ラベルの高さ(本体行の実際の高さに関わらず固定)
|
|
21
|
+
const INNER_GAP = 14; // 条件ラベルと内側セパレータの間隔
|
|
22
|
+
const BODY_GAP = 0; // 内側セパレータと本体の間隔
|
|
23
|
+
export default class Loop {
|
|
24
|
+
draw(place, data) {
|
|
25
|
+
const g = place.append('g').attr('class', 'pad-loop');
|
|
26
|
+
const rowGap = data.row_gap;
|
|
27
|
+
const connectorModel = new ELEMENTS.CONNECTOR.datamodel();
|
|
28
|
+
const connectorPainter = new ELEMENTS.CONNECTOR.painter();
|
|
29
|
+
// 前判定は [ブラケット][条件の箱]、後判定は [条件の箱][ブラケット](箱とブラケットで二重線)。
|
|
30
|
+
const isPost = data.test === 'post';
|
|
31
|
+
const varBoxX = isPost ? 0 : BRACKET_WIDTH;
|
|
32
|
+
const varBoxY = 0;
|
|
33
|
+
const varBoxHeight = LABEL_HEIGHT;
|
|
34
|
+
// 条件ラベルに添えるブラケット(矩形。ラベルの高さぶんのみ)。
|
|
35
|
+
// 後判定のときは、条件の箱の幅が分かってから x を決める(下)。
|
|
36
|
+
const bracket = g.append('rect')
|
|
37
|
+
.attr('x', 0).attr('y', varBoxY)
|
|
38
|
+
.attr('width', BRACKET_WIDTH).attr('height', varBoxHeight)
|
|
39
|
+
.attr('fill', 'none')
|
|
40
|
+
.attr('stroke', data.stroke.color)
|
|
41
|
+
.attr('stroke-width', data.stroke.width);
|
|
42
|
+
const varText = g.append('text')
|
|
43
|
+
.attr('x', varBoxX + LABEL_PADDING)
|
|
44
|
+
.attr('y', varBoxY + varBoxHeight / 2)
|
|
45
|
+
.attr('dominant-baseline', 'central')
|
|
46
|
+
.style('font-family', data.font.family)
|
|
47
|
+
.style('font-size', data.font.size)
|
|
48
|
+
.attr('fill', data.font.color)
|
|
49
|
+
.text(data.condition);
|
|
50
|
+
const varTextWidth = varText.node().getBBox().width;
|
|
51
|
+
const varBoxWidth = varTextWidth + LABEL_PADDING * 2;
|
|
52
|
+
// 条件の箱の右端から、二重線(後判定ならブラケットを含む)の外側の端まで
|
|
53
|
+
const labelRightX = varBoxX + varBoxWidth + (isPost ? BRACKET_WIDTH : 0);
|
|
54
|
+
const innerSeparatorX = (isPost ? labelRightX : varBoxX + varBoxWidth) + INNER_GAP;
|
|
55
|
+
if (isPost)
|
|
56
|
+
bracket.attr('x', varBoxWidth);
|
|
57
|
+
const bodyX = innerSeparatorX + BODY_GAP;
|
|
58
|
+
// 条件ラベルの枠(ブラケットより上、テキストより下に挿入する)
|
|
59
|
+
g.insert('rect', 'text')
|
|
60
|
+
.attr('x', varBoxX).attr('y', varBoxY)
|
|
61
|
+
.attr('width', varBoxWidth).attr('height', varBoxHeight)
|
|
62
|
+
.attr('fill', '#fff')
|
|
63
|
+
.attr('stroke', data.stroke.color)
|
|
64
|
+
.attr('stroke-width', data.stroke.width);
|
|
65
|
+
// 本体(各行。_classごとにregistry.tsで対応するデータクラス/描画クラスを引く)
|
|
66
|
+
let y = 0;
|
|
67
|
+
let maxRowWidth = 0;
|
|
68
|
+
let prevRowData = null;
|
|
69
|
+
let drawnRows = 0; // 実際に描いた行の数(知らない _class の行は、数えない)
|
|
70
|
+
data.rows.forEach((row) => {
|
|
71
|
+
const rowClass = row._class || 'PROCESS';
|
|
72
|
+
const entry = ELEMENTS[rowClass];
|
|
73
|
+
if (!entry)
|
|
74
|
+
return;
|
|
75
|
+
const model = new entry.datamodel();
|
|
76
|
+
const painter = new entry.painter();
|
|
77
|
+
// center:trueにして、行のanchor(Connector計算に使う)を自身の
|
|
78
|
+
// 中心ではなく左端(=内側セパレータの位置)にする。「連続性のある
|
|
79
|
+
// 処理のベース」の規則(要素の左端を線上に配置する)に合わせる
|
|
80
|
+
// ことで、行同士を結ぶConnectorがまっすぐな縦線になる。
|
|
81
|
+
const rowData = model.normalize(row, { x: bodyX, y, width: 0, center: true });
|
|
82
|
+
rowData.redraw = data.redraw;
|
|
83
|
+
rowData.onElementClick = data.onElementClick;
|
|
84
|
+
painter.draw(g, rowData);
|
|
85
|
+
if (prevRowData) {
|
|
86
|
+
const connector = connectorModel.normalize(prevRowData.anchors.bottom, rowData.anchors.top);
|
|
87
|
+
connectorPainter.draw(g, connector);
|
|
88
|
+
}
|
|
89
|
+
prevRowData = rowData;
|
|
90
|
+
maxRowWidth = Math.max(maxRowWidth, rowData.size ? rowData.size.w : 0);
|
|
91
|
+
y = rowData.anchors.bottom.y + rowGap;
|
|
92
|
+
drawnRows++;
|
|
93
|
+
});
|
|
94
|
+
// 本体の高さ(描いた行だけ)。条件・ラベルの箱は、行が無くても描くので、それを最低の高さとする(datamodels と同じ式。#307)
|
|
95
|
+
const bodyHeight = drawnRows ? y - rowGap : 0;
|
|
96
|
+
const totalHeight = Math.max(varBoxHeight, bodyHeight);
|
|
97
|
+
const totalWidth = bodyX + maxRowWidth;
|
|
98
|
+
// 条件ラベルと内側セパレータをつなぐ横線(ラベルの高さの中央)
|
|
99
|
+
g.append('line')
|
|
100
|
+
.attr('x1', labelRightX).attr('y1', varBoxY + varBoxHeight / 2)
|
|
101
|
+
.attr('x2', innerSeparatorX).attr('y2', varBoxY + varBoxHeight / 2)
|
|
102
|
+
.attr('stroke', data.stroke.color)
|
|
103
|
+
.attr('stroke-width', data.stroke.width);
|
|
104
|
+
// 内側セパレータ(縦線、本体全高。「連続性のある処理のベース」=
|
|
105
|
+
// 複数の処理をつなぐための線のため、行が1つしかない場合はつなぐ
|
|
106
|
+
// 相手がおらず不要。ラベルからの横線が行自身の左端まで届いている
|
|
107
|
+
// ため、それだけで十分)。
|
|
108
|
+
if (drawnRows >= 2) {
|
|
109
|
+
g.append('line')
|
|
110
|
+
.attr('x1', innerSeparatorX).attr('y1', 0)
|
|
111
|
+
.attr('x2', innerSeparatorX).attr('y2', bodyHeight)
|
|
112
|
+
.attr('stroke', data.stroke.color)
|
|
113
|
+
.attr('stroke-width', data.stroke.width);
|
|
114
|
+
}
|
|
115
|
+
const x = data.position.x;
|
|
116
|
+
g.attr('transform', `translate(${x},${data.position.y})`);
|
|
117
|
+
data.size = { w: totalWidth, h: totalHeight };
|
|
118
|
+
const anchorX = data.anchor_at_spine ? x : x + totalWidth / 2;
|
|
119
|
+
data.anchors = {
|
|
120
|
+
top: { x: anchorX, y: data.position.y },
|
|
121
|
+
bottom: { x: anchorX, y: data.position.y + totalHeight },
|
|
122
|
+
};
|
|
123
|
+
attachClick(g, data);
|
|
124
|
+
return g;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Parallel.d.ts","sourceRoot":"","sources":["../../../src/pad/painters/Parallel.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,OAAO,OAAO,QAAQ;IACzB,IAAI,CAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG;CA+F9B"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// Parallel(PARALLEL { TASK{...} TASK{...} })の描画クラス。
|
|
2
|
+
// 正規化済みデータ(datamodels/Parallel.ts の出力)を、d3 のセレクション
|
|
3
|
+
// (place) に対して描画する。データの正規化には関知しない。
|
|
4
|
+
//
|
|
5
|
+
// 各TASKは、{rows: [...]}を持つ場合はLOOP/SELECTIONの本体と同じくregistry.ts
|
|
6
|
+
// 経由で行ごとに描画し(複数の文が連続するTASKを表す)、持たない場合は
|
|
7
|
+
// 従来通りpainters/Process.tsのProcessクラスをそのまま流用して1行の矩形として
|
|
8
|
+
// 描画する(要素間・行間はrow_gapぶんの余白を空けて縦に並べる)。
|
|
9
|
+
// 左端には、並行実行であることを表す矩形のブラケット
|
|
10
|
+
// (元のPADには無い、このプロジェクト独自の拡張記号)を添える。
|
|
11
|
+
// {rows: [...]}を持つTASKで複数行を描画するときは、Pad.ts本体の要素間と
|
|
12
|
+
// 同じConnector要素で行間をつなぎ、処理の連続性を表す。
|
|
13
|
+
import Process from './Process.js';
|
|
14
|
+
import { ELEMENTS } from '../registry.js';
|
|
15
|
+
import { attachClick } from './interactive.js';
|
|
16
|
+
const processPainter = new Process();
|
|
17
|
+
export default class Parallel {
|
|
18
|
+
draw(place, data) {
|
|
19
|
+
// 幅がテキスト実測に依存するため、先にローカル座標(0,0起点)で内容を
|
|
20
|
+
// 描いてから、実測幅を使ってg全体の配置(x)とanchorsを確定する。
|
|
21
|
+
const g = place.append('g').attr('class', 'pad-parallel');
|
|
22
|
+
const bodyX = data.bracket.width + data.bracket.margin;
|
|
23
|
+
const rowHeight = data.row_height;
|
|
24
|
+
const rowGap = data.row_gap;
|
|
25
|
+
const connectorModel = new ELEMENTS.CONNECTOR.datamodel();
|
|
26
|
+
const connectorPainter = new ELEMENTS.CONNECTOR.painter();
|
|
27
|
+
let y = 0;
|
|
28
|
+
let maxWidth = 0;
|
|
29
|
+
data.tasks.forEach((task) => {
|
|
30
|
+
if (task.rows) {
|
|
31
|
+
let rowY = y;
|
|
32
|
+
let drawnRows = 0; // 実際に描いた行の数(知らない _class の行は、数えない)
|
|
33
|
+
let prevRowData = null;
|
|
34
|
+
task.rows.forEach((row) => {
|
|
35
|
+
const rowClass = row._class || 'PROCESS';
|
|
36
|
+
const entry = ELEMENTS[rowClass];
|
|
37
|
+
if (!entry)
|
|
38
|
+
return;
|
|
39
|
+
const model = new entry.datamodel();
|
|
40
|
+
const painter = new entry.painter();
|
|
41
|
+
// center:trueにして、行のanchorを自身の中心ではなく左端
|
|
42
|
+
// (=bodyX)にする。「連続性のある処理のベース」の規則
|
|
43
|
+
// (要素の左端を線上に配置する)に合わせ、行同士を結ぶ
|
|
44
|
+
// Connectorがまっすぐな縦線になるようにする。
|
|
45
|
+
const rowData = model.normalize(row, { x: bodyX, y: rowY, width: 0, center: true });
|
|
46
|
+
rowData.redraw = data.redraw;
|
|
47
|
+
rowData.onElementClick = data.onElementClick;
|
|
48
|
+
painter.draw(g, rowData);
|
|
49
|
+
if (prevRowData) {
|
|
50
|
+
const connector = connectorModel.normalize(prevRowData.anchors.bottom, rowData.anchors.top);
|
|
51
|
+
connectorPainter.draw(g, connector);
|
|
52
|
+
}
|
|
53
|
+
prevRowData = rowData;
|
|
54
|
+
maxWidth = Math.max(maxWidth, rowData.size ? rowData.size.w : 0);
|
|
55
|
+
rowY = rowData.anchors.bottom.y + rowGap;
|
|
56
|
+
drawnRows++;
|
|
57
|
+
});
|
|
58
|
+
// 行の後ろに足したrowGapは、行間としては正しいが末尾の行の後ろ分は
|
|
59
|
+
// TASK自身の高さには含めない(直後の共通のy += rowGapと二重に
|
|
60
|
+
// なり、次のTASK/要素と重なってしまうため。datamodels/Parallel.ts
|
|
61
|
+
// のtaskHeight()と同じ考え方)。
|
|
62
|
+
// 描いた行が無いTASK(rows: []・知らない_classだけ)は、rowHeightぶん進める(datamodels/Parallel.tsと同じ。#307)
|
|
63
|
+
y = drawnRows ? rowY - rowGap : y + rowHeight;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
const rowData = {
|
|
67
|
+
cells: task.cells,
|
|
68
|
+
dividers: task.dividers,
|
|
69
|
+
font: data.font,
|
|
70
|
+
stroke: data.stroke,
|
|
71
|
+
chevron_depth: data.chevron_depth,
|
|
72
|
+
position: { x: bodyX, y },
|
|
73
|
+
size: { w: 0, h: rowHeight },
|
|
74
|
+
onElementClick: data.onElementClick,
|
|
75
|
+
};
|
|
76
|
+
processPainter.draw(g, rowData);
|
|
77
|
+
maxWidth = Math.max(maxWidth, rowData.size.w);
|
|
78
|
+
y += rowHeight;
|
|
79
|
+
}
|
|
80
|
+
y += rowGap;
|
|
81
|
+
});
|
|
82
|
+
const totalHeight = data.tasks.length ? y - rowGap : 0;
|
|
83
|
+
const totalWidth = bodyX + maxWidth;
|
|
84
|
+
// 左端のブラケット(並行実行を表す矩形。先頭に挿入し、下に来るようにする)
|
|
85
|
+
g.insert('rect', ':first-child')
|
|
86
|
+
.attr('x', 0).attr('y', 0)
|
|
87
|
+
.attr('width', data.bracket.width).attr('height', totalHeight)
|
|
88
|
+
.attr('fill', 'none')
|
|
89
|
+
.attr('stroke', data.stroke.color)
|
|
90
|
+
.attr('stroke-width', data.stroke.width);
|
|
91
|
+
const x = data.position.x;
|
|
92
|
+
g.attr('transform', `translate(${x},${data.position.y})`);
|
|
93
|
+
data.size = { w: totalWidth, h: totalHeight };
|
|
94
|
+
const anchorX = data.anchor_at_spine ? x : x + totalWidth / 2;
|
|
95
|
+
data.anchors = {
|
|
96
|
+
top: { x: anchorX, y: data.position.y },
|
|
97
|
+
bottom: { x: anchorX, y: data.position.y + totalHeight },
|
|
98
|
+
};
|
|
99
|
+
attachClick(g, data);
|
|
100
|
+
return g;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Process.d.ts","sourceRoot":"","sources":["../../../src/pad/painters/Process.ts"],"names":[],"mappings":"AAuBA,wBAAgB,SAAS,CAAE,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,UAyE3C;AAED,MAAM,CAAC,OAAO,OAAO,OAAO;IACxB,IAAI,CAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG;CAqD9B"}
|