@yanqirenshi/d3.pad 0.2.0 → 0.3.0

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.
Files changed (183) hide show
  1. package/README.md +86 -18
  2. package/dist/index.d.ts +7 -3
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +15 -6
  5. package/dist/pad/Pad.d.ts +21 -0
  6. package/dist/pad/Pad.d.ts.map +1 -0
  7. package/dist/pad/Pad.js +139 -0
  8. package/dist/pad/PadDiagram.d.ts +19 -0
  9. package/dist/pad/PadDiagram.d.ts.map +1 -0
  10. package/dist/pad/PadDiagram.js +64 -0
  11. package/dist/pad/Theme.d.ts +7 -0
  12. package/dist/pad/Theme.d.ts.map +1 -0
  13. package/dist/pad/Theme.js +10 -0
  14. package/dist/pad/datamodels/Assignment.d.ts +81 -0
  15. package/dist/pad/datamodels/Assignment.d.ts.map +1 -0
  16. package/dist/pad/datamodels/Assignment.js +51 -0
  17. package/dist/pad/datamodels/Call.d.ts +95 -0
  18. package/dist/pad/datamodels/Call.d.ts.map +1 -0
  19. package/dist/pad/datamodels/Call.js +83 -0
  20. package/dist/pad/datamodels/Connector.d.ts +35 -0
  21. package/dist/pad/datamodels/Connector.d.ts.map +1 -0
  22. package/dist/pad/datamodels/Connector.js +23 -0
  23. package/dist/pad/datamodels/Group.d.ts +78 -0
  24. package/dist/pad/datamodels/Group.d.ts.map +1 -0
  25. package/dist/pad/datamodels/Group.js +71 -0
  26. package/dist/pad/datamodels/Loop.d.ts +80 -0
  27. package/dist/pad/datamodels/Loop.d.ts.map +1 -0
  28. package/dist/pad/datamodels/Loop.js +77 -0
  29. package/dist/pad/datamodels/Parallel.d.ts +85 -0
  30. package/dist/pad/datamodels/Parallel.d.ts.map +1 -0
  31. package/dist/pad/datamodels/Parallel.js +80 -0
  32. package/dist/pad/datamodels/Process.d.ts +79 -0
  33. package/dist/pad/datamodels/Process.d.ts.map +1 -0
  34. package/dist/pad/datamodels/Process.js +59 -0
  35. package/dist/pad/datamodels/Selection.d.ts +76 -0
  36. package/dist/pad/datamodels/Selection.d.ts.map +1 -0
  37. package/dist/pad/datamodels/Selection.js +81 -0
  38. package/dist/pad/datamodels/Terminal.d.ts +61 -0
  39. package/dist/pad/datamodels/Terminal.d.ts.map +1 -0
  40. package/dist/pad/datamodels/Terminal.js +50 -0
  41. package/dist/pad/elements.d.ts +2 -0
  42. package/dist/pad/elements.d.ts.map +1 -0
  43. package/dist/pad/elements.js +32 -0
  44. package/dist/pad/painters/Assignment.d.ts +4 -0
  45. package/dist/pad/painters/Assignment.d.ts.map +1 -0
  46. package/dist/pad/painters/Assignment.js +72 -0
  47. package/dist/pad/painters/Call.d.ts +4 -0
  48. package/dist/pad/painters/Call.d.ts.map +1 -0
  49. package/dist/pad/painters/Call.js +134 -0
  50. package/dist/pad/painters/Connector.d.ts +4 -0
  51. package/dist/pad/painters/Connector.d.ts.map +1 -0
  52. package/dist/pad/painters/Connector.js +15 -0
  53. package/dist/pad/painters/Group.d.ts +4 -0
  54. package/dist/pad/painters/Group.d.ts.map +1 -0
  55. package/dist/pad/painters/Group.js +99 -0
  56. package/dist/pad/painters/Loop.d.ts +4 -0
  57. package/dist/pad/painters/Loop.d.ts.map +1 -0
  58. package/dist/pad/painters/Loop.js +126 -0
  59. package/dist/pad/painters/Parallel.d.ts +4 -0
  60. package/dist/pad/painters/Parallel.d.ts.map +1 -0
  61. package/dist/pad/painters/Parallel.js +102 -0
  62. package/dist/pad/painters/Process.d.ts +5 -0
  63. package/dist/pad/painters/Process.d.ts.map +1 -0
  64. package/dist/pad/painters/Process.js +132 -0
  65. package/dist/pad/painters/Selection.d.ts +4 -0
  66. package/dist/pad/painters/Selection.d.ts.map +1 -0
  67. package/dist/pad/painters/Selection.js +126 -0
  68. package/dist/pad/painters/Terminal.d.ts +4 -0
  69. package/dist/pad/painters/Terminal.d.ts.map +1 -0
  70. package/dist/pad/painters/Terminal.js +19 -0
  71. package/dist/pad/painters/interactive.d.ts +2 -0
  72. package/dist/pad/painters/interactive.d.ts.map +1 -0
  73. package/dist/pad/painters/interactive.js +15 -0
  74. package/dist/pad/registry.d.ts +14 -0
  75. package/dist/pad/registry.d.ts.map +1 -0
  76. package/dist/pad/registry.js +25 -0
  77. package/package.json +7 -5
  78. package/src/index.ts +15 -7
  79. package/src/pad/Pad.ts +157 -0
  80. package/src/pad/PadDiagram.tsx +126 -0
  81. package/src/pad/Theme.ts +11 -0
  82. package/src/pad/datamodels/Assignment.ts +55 -0
  83. package/src/pad/datamodels/Call.ts +91 -0
  84. package/src/pad/datamodels/Connector.ts +25 -0
  85. package/src/pad/datamodels/Group.ts +76 -0
  86. package/src/pad/datamodels/Loop.ts +82 -0
  87. package/src/pad/datamodels/Parallel.ts +85 -0
  88. package/src/pad/datamodels/Process.ts +63 -0
  89. package/src/pad/datamodels/Selection.ts +87 -0
  90. package/src/pad/datamodels/Terminal.ts +57 -0
  91. package/src/pad/elements.ts +34 -0
  92. package/src/pad/painters/Assignment.ts +87 -0
  93. package/src/pad/painters/Call.ts +152 -0
  94. package/src/pad/painters/Connector.ts +15 -0
  95. package/src/pad/painters/Group.ts +116 -0
  96. package/src/pad/painters/Loop.ts +144 -0
  97. package/src/pad/painters/Parallel.ts +115 -0
  98. package/src/pad/painters/Process.ts +153 -0
  99. package/src/pad/painters/Selection.ts +150 -0
  100. package/src/pad/painters/Terminal.ts +23 -0
  101. package/src/pad/painters/interactive.ts +15 -0
  102. package/src/pad/registry.ts +38 -0
  103. package/dist/renderers/D3PadRenderer.d.ts +0 -34
  104. package/dist/renderers/D3PadRenderer.d.ts.map +0 -1
  105. package/dist/renderers/D3PadRenderer.js +0 -112
  106. package/dist/renderers/PadNodeRenderer.d.ts +0 -145
  107. package/dist/renderers/PadNodeRenderer.d.ts.map +0 -1
  108. package/dist/renderers/PadNodeRenderer.js +0 -440
  109. package/dist/renderers/blocks/EndBlockGeometry.d.ts +0 -33
  110. package/dist/renderers/blocks/EndBlockGeometry.d.ts.map +0 -1
  111. package/dist/renderers/blocks/EndBlockGeometry.js +0 -44
  112. package/dist/renderers/blocks/EndRenderer.d.ts +0 -10
  113. package/dist/renderers/blocks/EndRenderer.d.ts.map +0 -1
  114. package/dist/renderers/blocks/EndRenderer.js +0 -38
  115. package/dist/renderers/blocks/EndRendererProps.d.ts +0 -6
  116. package/dist/renderers/blocks/EndRendererProps.d.ts.map +0 -1
  117. package/dist/renderers/blocks/EndRendererProps.js +0 -1
  118. package/dist/renderers/blocks/FunctionContainerGeometry.d.ts +0 -29
  119. package/dist/renderers/blocks/FunctionContainerGeometry.d.ts.map +0 -1
  120. package/dist/renderers/blocks/FunctionContainerGeometry.js +0 -46
  121. package/dist/renderers/blocks/FunctionContainerRenderer.d.ts +0 -13
  122. package/dist/renderers/blocks/FunctionContainerRenderer.d.ts.map +0 -1
  123. package/dist/renderers/blocks/FunctionContainerRenderer.js +0 -49
  124. package/dist/renderers/blocks/FunctionHeaderGeometry.d.ts +0 -20
  125. package/dist/renderers/blocks/FunctionHeaderGeometry.d.ts.map +0 -1
  126. package/dist/renderers/blocks/FunctionHeaderGeometry.js +0 -35
  127. package/dist/renderers/blocks/FunctionHeaderProps.d.ts +0 -7
  128. package/dist/renderers/blocks/FunctionHeaderProps.d.ts.map +0 -1
  129. package/dist/renderers/blocks/FunctionHeaderProps.js +0 -1
  130. package/dist/renderers/blocks/FunctionHeaderRenderer.d.ts +0 -11
  131. package/dist/renderers/blocks/FunctionHeaderRenderer.d.ts.map +0 -1
  132. package/dist/renderers/blocks/FunctionHeaderRenderer.js +0 -36
  133. package/dist/renderers/blocks/IfBlockGeometry.d.ts +0 -42
  134. package/dist/renderers/blocks/IfBlockGeometry.d.ts.map +0 -1
  135. package/dist/renderers/blocks/IfBlockGeometry.js +0 -83
  136. package/dist/renderers/blocks/IfRenderer.d.ts +0 -10
  137. package/dist/renderers/blocks/IfRenderer.d.ts.map +0 -1
  138. package/dist/renderers/blocks/IfRenderer.js +0 -69
  139. package/dist/renderers/blocks/IfRendererProps.d.ts +0 -7
  140. package/dist/renderers/blocks/IfRendererProps.d.ts.map +0 -1
  141. package/dist/renderers/blocks/IfRendererProps.js +0 -1
  142. package/dist/renderers/blocks/LoopRenderer.d.ts +0 -12
  143. package/dist/renderers/blocks/LoopRenderer.d.ts.map +0 -1
  144. package/dist/renderers/blocks/LoopRenderer.js +0 -37
  145. package/dist/renderers/blocks/LoopRendererProps.d.ts +0 -8
  146. package/dist/renderers/blocks/LoopRendererProps.d.ts.map +0 -1
  147. package/dist/renderers/blocks/LoopRendererProps.js +0 -1
  148. package/dist/renderers/blocks/Point.d.ts +0 -2
  149. package/dist/renderers/blocks/Point.d.ts.map +0 -1
  150. package/dist/renderers/blocks/Point.js +0 -1
  151. package/dist/renderers/blocks/StartBlockGeometry.d.ts +0 -38
  152. package/dist/renderers/blocks/StartBlockGeometry.d.ts.map +0 -1
  153. package/dist/renderers/blocks/StartBlockGeometry.js +0 -56
  154. package/dist/renderers/blocks/StartRenderer.d.ts +0 -10
  155. package/dist/renderers/blocks/StartRenderer.d.ts.map +0 -1
  156. package/dist/renderers/blocks/StartRenderer.js +0 -39
  157. package/dist/renderers/blocks/StartRendererProps.d.ts +0 -6
  158. package/dist/renderers/blocks/StartRendererProps.d.ts.map +0 -1
  159. package/dist/renderers/blocks/StartRendererProps.js +0 -1
  160. package/dist/utils/layout.d.ts +0 -14
  161. package/dist/utils/layout.d.ts.map +0 -1
  162. package/dist/utils/layout.js +0 -186
  163. package/src/renderers/D3PadRenderer.tsx +0 -145
  164. package/src/renderers/PadNodeRenderer.ts +0 -517
  165. package/src/renderers/blocks/EndBlockGeometry.ts +0 -52
  166. package/src/renderers/blocks/EndRenderer.tsx +0 -48
  167. package/src/renderers/blocks/EndRendererProps.ts +0 -5
  168. package/src/renderers/blocks/FunctionContainerGeometry.ts +0 -54
  169. package/src/renderers/blocks/FunctionContainerRenderer.tsx +0 -62
  170. package/src/renderers/blocks/FunctionHeaderGeometry.ts +0 -43
  171. package/src/renderers/blocks/FunctionHeaderProps.ts +0 -6
  172. package/src/renderers/blocks/FunctionHeaderRenderer.tsx +0 -47
  173. package/src/renderers/blocks/IfBlockGeometry.ts +0 -98
  174. package/src/renderers/blocks/IfRenderer.tsx +0 -88
  175. package/src/renderers/blocks/IfRendererProps.ts +0 -7
  176. package/src/renderers/blocks/LoopRenderer.tsx +0 -50
  177. package/src/renderers/blocks/LoopRendererProps.ts +0 -7
  178. package/src/renderers/blocks/Point.ts +0 -4
  179. package/src/renderers/blocks/README.md +0 -29
  180. package/src/renderers/blocks/StartBlockGeometry.ts +0 -66
  181. package/src/renderers/blocks/StartRenderer.tsx +0 -49
  182. package/src/renderers/blocks/StartRendererProps.ts +0 -5
  183. package/src/utils/layout.ts +0 -247
@@ -0,0 +1,80 @@
1
+ // Parallel(PARALLEL { TASK{...} TASK{...} })のデータクラス。
2
+ // 元のPAD(Problem Analysis Diagram)には無い記号だが、複数の処理が並行して
3
+ // 走ることを図示するためにこのプロジェクト独自に追加する。
4
+ // 各TASKは、従来通りPROCESS要素そのもの({cells, dividers})1行として
5
+ // 描画するか、あるいは複数の文が連続するTASK(例: 同じ処理を続けて2回
6
+ // 呼ぶ等)を表すために{rows: [...]}として複数行を持てる
7
+ // (rowsはLOOP/SELECTIONの本体と同じくregistry.ts経由で_classごとに描画する。
8
+ // _class省略時はPROCESS扱い)。
9
+ // 入力データの正規化のみを担当し、描画は painters/Parallel.ts が担当する
10
+ // (@yanqirenshi/d3.deployment の datamodels/painters 分離に倣う)。
11
+ import Theme from '../Theme.js';
12
+ import { ELEMENTS } from '../registry.js';
13
+ const ROW_HEIGHT = 44;
14
+ const ROW_GAP = 11; // TASK同士(要素間)・TASK内の行同士の余白
15
+ const BRACKET_WIDTH = 12; // 左のブラケット(矩形)の幅
16
+ const BRACKET_MARGIN = 0; // ブラケットと本体(行)の間隔
17
+ // 1つのTASKの高さを求める。{rows: [...]}を持つTASKは本体(LOOP/SELECTIONの
18
+ // bodyと同じ考え方)としてregistry.ts経由で各行の高さを積み上げる。
19
+ // 持たないTASK(従来通りの{cells, dividers})は固定のROW_HEIGHTとする。
20
+ // {rows: [...]}を持っても、描ける行が無い(空・知らない_classだけ)TASKは、painters/Parallel.tsと同じく
21
+ // ROW_HEIGHTとする(数えるのは、実際に描く行だけ。#307)。
22
+ function taskHeight(task, rowGap) {
23
+ if (!task.rows)
24
+ return ROW_HEIGHT;
25
+ let y = 0;
26
+ let drawn = 0;
27
+ for (const row of task.rows) {
28
+ const rowClass = row._class || 'PROCESS';
29
+ const entry = ELEMENTS[rowClass];
30
+ if (!entry)
31
+ continue;
32
+ const model = new entry.datamodel();
33
+ const rowData = model.normalize(row, { x: 0, y, width: 0, center: false });
34
+ y = rowData.anchors.bottom.y + rowGap;
35
+ drawn++;
36
+ }
37
+ return drawn ? y - rowGap : ROW_HEIGHT;
38
+ }
39
+ export default class Parallel {
40
+ dataTemplate() {
41
+ return {
42
+ // tasks: ({ cells: string[], dividers: (...)[] } | { rows: ({_class?, ...})[] })[]
43
+ tasks: [],
44
+ font: { family: '"Courier New", monospace', size: 14, color: Theme.text },
45
+ stroke: { color: Theme.stroke, width: 1 },
46
+ row_height: ROW_HEIGHT,
47
+ row_gap: ROW_GAP,
48
+ bracket: { width: BRACKET_WIDTH, margin: BRACKET_MARGIN },
49
+ chevron_depth: 12,
50
+ size: { w: 0, h: 0 }, // 幅・高さともに描画時(実測後)に確定する
51
+ position: { x: 0, y: 0 },
52
+ // trueのときConnector用のanchorをbox.x(PADの縦線位置)にする。
53
+ // 見た目(描画位置)は常にbox.xからの左詰め=変わらない。
54
+ anchor_at_spine: false,
55
+ // NOTE: 幅がテキスト実測依存のため、x座標は暫定値(yのみ確定)。
56
+ // painters/Parallel.ts が実測後に確定値へ更新する。
57
+ anchors: { top: { x: 0, y: 0 }, bottom: { x: 0, y: 0 } },
58
+ _id: null,
59
+ _core: null,
60
+ _class: 'PARALLEL',
61
+ };
62
+ }
63
+ normalize(core, box) {
64
+ if (!core)
65
+ return null;
66
+ const data = this.dataTemplate();
67
+ data._core = core;
68
+ data._id = core.id;
69
+ data.tasks = core.tasks || [];
70
+ data.position = { x: box.x, y: box.y };
71
+ data.anchor_at_spine = !!box.center;
72
+ const n = data.tasks.length;
73
+ const h = data.tasks.reduce((sum, task) => sum + taskHeight(task, ROW_GAP) + ROW_GAP, 0) - (n ? ROW_GAP : 0);
74
+ data.anchors = {
75
+ top: { x: box.x, y: box.y },
76
+ bottom: { x: box.x, y: box.y + h },
77
+ };
78
+ return data;
79
+ }
80
+ }
@@ -0,0 +1,79 @@
1
+ export default class Process {
2
+ dataTemplate(): {
3
+ cells: never[];
4
+ dividers: never[];
5
+ links: never[];
6
+ description: null;
7
+ font: {
8
+ family: string;
9
+ size: number;
10
+ color: string;
11
+ };
12
+ stroke: {
13
+ color: string;
14
+ width: number;
15
+ };
16
+ chevron_depth: number;
17
+ size: {
18
+ w: number;
19
+ h: number;
20
+ };
21
+ position: {
22
+ x: number;
23
+ y: number;
24
+ };
25
+ anchor_at_spine: boolean;
26
+ anchors: {
27
+ top: {
28
+ x: number;
29
+ y: number;
30
+ };
31
+ bottom: {
32
+ x: number;
33
+ y: number;
34
+ };
35
+ };
36
+ _id: null;
37
+ _core: null;
38
+ _class: string;
39
+ };
40
+ normalize(core: any, box: any): {
41
+ cells: never[];
42
+ dividers: never[];
43
+ links: never[];
44
+ description: null;
45
+ font: {
46
+ family: string;
47
+ size: number;
48
+ color: string;
49
+ };
50
+ stroke: {
51
+ color: string;
52
+ width: number;
53
+ };
54
+ chevron_depth: number;
55
+ size: {
56
+ w: number;
57
+ h: number;
58
+ };
59
+ position: {
60
+ x: number;
61
+ y: number;
62
+ };
63
+ anchor_at_spine: boolean;
64
+ anchors: {
65
+ top: {
66
+ x: number;
67
+ y: number;
68
+ };
69
+ bottom: {
70
+ x: number;
71
+ y: number;
72
+ };
73
+ };
74
+ _id: null;
75
+ _core: null;
76
+ _class: string;
77
+ } | null;
78
+ }
79
+ //# sourceMappingURL=Process.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Process.d.ts","sourceRoot":"","sources":["../../../src/pad/datamodels/Process.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,OAAO,OAAO,OAAO;IACxB,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA+BZ,SAAS,CAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmBjC"}
@@ -0,0 +1,59 @@
1
+ // PROCESS(処理)のデータクラス。
2
+ // 1つの処理を、四角い箱の中の「ラベル+引数」の並び(cells)として表す。
3
+ // セルの区切り(dividers)は点線・実線・山形、セルごとにリンク(links)も付けられる。
4
+ // 何をセルに入れるかは、使う側が決める(要素は文言を固定しない)。
5
+ // 入力データの正規化のみを担当し、描画は painters/Process.ts が担当する
6
+ // (@yanqirenshi/d3.deployment の datamodels/painters 分離に倣う)。
7
+ import Theme from '../Theme.js';
8
+ const HEIGHT = 44;
9
+ const CHEVRON_DEPTH = 12;
10
+ export default class Process {
11
+ dataTemplate() {
12
+ return {
13
+ // cells: string[](先頭はラベル。以降は表示する引数)
14
+ // dividers: ('dotted'|'solid'|{type:'chevron', direction:'left'|'right'})[]
15
+ // 要素数は cells.length - 1。dotted=ラベルと最初の引数の区切り、
16
+ // solid=引数同士の区切り、chevron=前の値が次の値へ流れ込む
17
+ // (Assignmentの「<」と同じ役割)ことを表す。
18
+ cells: [],
19
+ dividers: [],
20
+ // cellsと同じ長さの配列(省略可)。リンクさせたいセルの位置に
21
+ // URL文字列、それ以外はnullを入れる(例: dwmem_load/dwtab_rebuild
22
+ // が対象とするテーブル名セルをWBSページへのリンクにする)。
23
+ links: [],
24
+ description: null, // 箱の右に添える説明。無ければnull
25
+ font: { family: '"Courier New", monospace', size: 14, color: Theme.text },
26
+ stroke: { color: Theme.stroke, width: 1 },
27
+ chevron_depth: CHEVRON_DEPTH,
28
+ size: { w: 0, h: HEIGHT }, // 幅はテキスト実測後に painter が確定する
29
+ position: { x: 0, y: 0 },
30
+ // trueのときConnector用のanchorをbox.x(PADの縦線位置)にする。
31
+ // 見た目(描画位置)は常にbox.xからの左詰め=変わらない。
32
+ anchor_at_spine: false,
33
+ // NOTE: 幅がテキスト実測依存のため、x座標は暫定値(yのみ確定)。
34
+ // painters/Process.ts が実測後に確定値へ更新する。
35
+ anchors: { top: { x: 0, y: 0 }, bottom: { x: 0, y: HEIGHT } },
36
+ _id: null,
37
+ _core: null,
38
+ _class: 'PROCESS',
39
+ };
40
+ }
41
+ normalize(core, box) {
42
+ if (!core)
43
+ return null;
44
+ const data = this.dataTemplate();
45
+ data._core = core;
46
+ data._id = core.id;
47
+ data.cells = core.cells || [];
48
+ data.dividers = core.dividers || [];
49
+ data.links = core.links || [];
50
+ data.description = core.description || null;
51
+ data.position = { x: box.x, y: box.y };
52
+ data.anchor_at_spine = !!box.center;
53
+ data.anchors = {
54
+ top: { x: box.x, y: box.y },
55
+ bottom: { x: box.x, y: box.y + HEIGHT },
56
+ };
57
+ return data;
58
+ }
59
+ }
@@ -0,0 +1,76 @@
1
+ export default class Selection {
2
+ dataTemplate(): {
3
+ whens: never[];
4
+ font: {
5
+ family: string;
6
+ size: number;
7
+ color: string;
8
+ };
9
+ stroke: {
10
+ color: string;
11
+ width: number;
12
+ };
13
+ row_gap: number;
14
+ chevron_depth: number;
15
+ size: {
16
+ w: number;
17
+ h: number;
18
+ };
19
+ position: {
20
+ x: number;
21
+ y: number;
22
+ };
23
+ anchor_at_spine: boolean;
24
+ anchors: {
25
+ top: {
26
+ x: number;
27
+ y: number;
28
+ };
29
+ bottom: {
30
+ x: number;
31
+ y: number;
32
+ };
33
+ };
34
+ _id: null;
35
+ _core: null;
36
+ _class: string;
37
+ };
38
+ measureBodyHeight(body: any, rowGap: any): number;
39
+ normalize(core: any, box: any): {
40
+ whens: never[];
41
+ font: {
42
+ family: string;
43
+ size: number;
44
+ color: string;
45
+ };
46
+ stroke: {
47
+ color: string;
48
+ width: number;
49
+ };
50
+ row_gap: number;
51
+ chevron_depth: number;
52
+ size: {
53
+ w: number;
54
+ h: number;
55
+ };
56
+ position: {
57
+ x: number;
58
+ y: number;
59
+ };
60
+ anchor_at_spine: boolean;
61
+ anchors: {
62
+ top: {
63
+ x: number;
64
+ y: number;
65
+ };
66
+ bottom: {
67
+ x: number;
68
+ y: number;
69
+ };
70
+ };
71
+ _id: null;
72
+ _core: null;
73
+ _class: string;
74
+ } | null;
75
+ }
76
+ //# sourceMappingURL=Selection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Selection.d.ts","sourceRoot":"","sources":["../../../src/pad/datamodels/Selection.ts"],"names":[],"mappings":"AAsBA,MAAM,CAAC,OAAO,OAAO,SAAS;IAC1B,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAwBZ,iBAAiB,CAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG;IAczC,SAAS,CAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyBjC"}
@@ -0,0 +1,81 @@
1
+ // SELECTION(選択)のデータクラス。
2
+ // 元のPAD(Problem Analysis Diagram)が持つ「選択」記号に相当する
3
+ // (PARALLEL等とは異なり、拡張ではなく本来のPAD要素)。
4
+ // SELECTION { WHEN(条件){本体} WHEN(条件){本体} ... ELSE{本体} } のように、条件
5
+ // (WHEN)を複数持てる形で表す(構文上は複数許容される可能性があるため)。
6
+ // 末尾にELSE(どのWHENにも合致しない場合の処理)を1つ持てる。whens配列内で
7
+ // { else: true, body } と表す(条件式のかわりに固定ラベル「ELSE」を表示する
8
+ // だけで、構造上はWHENと同じ1行として扱う)。
9
+ // 各行の本体(body)は { _class?: string, ... }[] を持ち、Pad本体と同じ
10
+ // レジストリ(registry.ts)で対応するデータクラスに振り分ける(LOOPの
11
+ // rowsと同じ考え方。_class省略時はPROCESS扱い)。
12
+ // 入力データの正規化のみを担当し、描画は painters/Selection.ts が担当する
13
+ // (@yanqirenshi/d3.deployment の datamodels/painters 分離に倣う)。
14
+ import Theme from '../Theme.js';
15
+ import { ELEMENTS } from '../registry.js';
16
+ const CONDITION_HEIGHT = 44;
17
+ const ROW_GAP = 11;
18
+ // ブラケットが条件ボックスの上下にはみ出す量(painters/Selection.ts の BRACKET_MARGIN と同じ値)。
19
+ // はみ出しを自分の高さに含めるので、上下に BRACKET_MARGIN ずつの余白を持つ(#309)。
20
+ const BRACKET_MARGIN = 8;
21
+ export default class Selection {
22
+ dataTemplate() {
23
+ return {
24
+ whens: [], // ({ condition: string } | { else: true })[] & { body: ({_class?, ...})[] }[]
25
+ font: { family: '"Courier New", monospace', size: 14, color: Theme.text },
26
+ stroke: { color: Theme.stroke, width: 1 },
27
+ row_gap: ROW_GAP,
28
+ chevron_depth: 12,
29
+ size: { w: 0, h: 0 }, // 幅・高さともに描画時(実測後)に確定する
30
+ position: { x: 0, y: 0 },
31
+ // trueのときConnector用のanchorをbox.x(PADの縦線位置)にする。
32
+ // 見た目(描画位置)は常にbox.xからの左詰め=変わらない。
33
+ anchor_at_spine: false,
34
+ // NOTE: 幅がテキスト実測依存のため、x座標は暫定値(yのみ確定)。
35
+ // painters/Selection.ts が実測後に確定値へ更新する。
36
+ anchors: { top: { x: 0, y: 0 }, bottom: { x: 0, y: 0 } },
37
+ _id: null,
38
+ _core: null,
39
+ _class: 'SELECTION',
40
+ };
41
+ }
42
+ // 本体(body)のデータクラスにnormalizeさせて高さだけを求める。PROCESS/
43
+ // PARALLEL等どの要素も高さは常にデータから確定できるため、ここでは
44
+ // DOM計測を伴わない(幅の実測は描画時のみ必要)。
45
+ measureBodyHeight(body, rowGap) {
46
+ let y = 0;
47
+ for (const row of body) {
48
+ const rowClass = row._class || 'PROCESS';
49
+ const entry = ELEMENTS[rowClass];
50
+ if (!entry)
51
+ continue;
52
+ const model = new entry.datamodel();
53
+ const rowData = model.normalize(row, { x: 0, y, width: 0, center: false });
54
+ y = rowData.anchors.bottom.y + rowGap;
55
+ }
56
+ return body.length ? y - rowGap : 0;
57
+ }
58
+ // core: { id, whens: { condition: string, body: ({_class?, ...})[] }[] }
59
+ normalize(core, box) {
60
+ if (!core)
61
+ return null;
62
+ const data = this.dataTemplate();
63
+ data._core = core;
64
+ data._id = core.id;
65
+ data.whens = core.whens || [];
66
+ data.position = { x: box.x, y: box.y };
67
+ data.anchor_at_spine = !!box.center;
68
+ let y = BRACKET_MARGIN;
69
+ for (const when of data.whens) {
70
+ const bodyHeight = this.measureBodyHeight(when.body || [], data.row_gap);
71
+ const rowHeight = Math.max(CONDITION_HEIGHT, bodyHeight);
72
+ y += rowHeight + data.row_gap;
73
+ }
74
+ const totalHeight = data.whens.length ? y - data.row_gap + BRACKET_MARGIN : 0;
75
+ data.anchors = {
76
+ top: { x: box.x, y: box.y },
77
+ bottom: { x: box.x, y: box.y + totalHeight },
78
+ };
79
+ return data;
80
+ }
81
+ }
@@ -0,0 +1,61 @@
1
+ export declare const START_RADIUS = 14;
2
+ export declare const BORDER_WIDTH = 1.5;
3
+ export default class Terminal {
4
+ dataTemplate(): {
5
+ type: null;
6
+ radius: number;
7
+ center: {
8
+ x: number;
9
+ y: number;
10
+ };
11
+ background: {
12
+ color: string;
13
+ };
14
+ border: {
15
+ color: string;
16
+ width: number;
17
+ };
18
+ anchors: {
19
+ top: {
20
+ x: number;
21
+ y: number;
22
+ };
23
+ bottom: {
24
+ x: number;
25
+ y: number;
26
+ };
27
+ };
28
+ _id: null;
29
+ _core: null;
30
+ _class: string;
31
+ };
32
+ normalize(core: any, box: any): {
33
+ type: null;
34
+ radius: number;
35
+ center: {
36
+ x: number;
37
+ y: number;
38
+ };
39
+ background: {
40
+ color: string;
41
+ };
42
+ border: {
43
+ color: string;
44
+ width: number;
45
+ };
46
+ anchors: {
47
+ top: {
48
+ x: number;
49
+ y: number;
50
+ };
51
+ bottom: {
52
+ x: number;
53
+ y: number;
54
+ };
55
+ };
56
+ _id: null;
57
+ _core: null;
58
+ _class: string;
59
+ } | null;
60
+ }
61
+ //# sourceMappingURL=Terminal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Terminal.d.ts","sourceRoot":"","sources":["../../../src/pad/datamodels/Terminal.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,YAAY,KAAK,CAAC;AAC/B,eAAO,MAAM,YAAY,MAAM,CAAC;AAOhC,MAAM,CAAC,OAAO,OAAO,QAAQ;IACzB,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAgBZ,SAAS,CAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsBjC"}
@@ -0,0 +1,50 @@
1
+ // Terminal(開始/終了)のデータクラス。
2
+ // 元のPAD(Problem Analysis Diagram)には無い記号だが、スクリプト全体の
3
+ // 範囲を明示するためにこのプロジェクト独自に追加する。
4
+ // 開始=白丸、終了=黒丸(大きさは同じ、色だけで区別する)で表す。
5
+ // 入力データの正規化(既定値補完・位置決め)のみを担当し、描画は
6
+ // painters/Terminal.ts が担当する(@yanqirenshi/d3.deployment の
7
+ // datamodels/painters 分離に倣う)。
8
+ import Theme from '../Theme.js';
9
+ export const START_RADIUS = 14;
10
+ export const BORDER_WIDTH = 1.5;
11
+ const RADIUS = {
12
+ start: START_RADIUS,
13
+ end: START_RADIUS,
14
+ };
15
+ export default class Terminal {
16
+ dataTemplate() {
17
+ return {
18
+ type: null, // 'start' | 'end'
19
+ radius: 0,
20
+ center: { x: 0, y: 0 },
21
+ background: { color: '#fff' },
22
+ border: { color: Theme.stroke, width: BORDER_WIDTH },
23
+ anchors: { top: { x: 0, y: 0 }, bottom: { x: 0, y: 0 } },
24
+ _id: null,
25
+ _core: null,
26
+ _class: 'TERMINAL',
27
+ };
28
+ }
29
+ // box: { x, y, width, center } 配置先の左上座標と使用可能な幅。
30
+ // center未指定時は幅の中央、centerがtrueのときはbox.x(PADの縦線位置)に円を置く。
31
+ normalize(core, box) {
32
+ if (!core)
33
+ return null;
34
+ const data = this.dataTemplate();
35
+ data._core = core;
36
+ data._id = core.id;
37
+ data.type = core.type;
38
+ data.radius = RADIUS[core.type] || RADIUS.start;
39
+ const cx = box.center ? box.x : box.x + box.width / 2;
40
+ const cy = box.y + data.radius;
41
+ data.center = { x: cx, y: cy };
42
+ data.anchors = {
43
+ top: { x: cx, y: cy - data.radius },
44
+ bottom: { x: cx, y: cy + data.radius },
45
+ };
46
+ if ('end' === core.type)
47
+ data.background = { color: Theme.fill };
48
+ return data;
49
+ }
50
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=elements.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"elements.d.ts","sourceRoot":"","sources":["../../src/pad/elements.ts"],"names":[],"mappings":""}
@@ -0,0 +1,32 @@
1
+ // d3.pad が最初から持つ 9 つの要素を、レジストリ(registry.ts)に登録する。
2
+ // import されるだけで登録される(Pad.ts が import する)。
3
+ // 要素は registry.ts だけを import し、このファイルも Pad.ts も import しないので、循環参照にならない。
4
+ // (CALL は呼び出し先を別の Pad で描くが、Pad は registry.ts の PAD から取り出す。datamodels/Call.ts の buildCalleePad 参照)
5
+ import { registerElement } from './registry.js';
6
+ import Terminal from './datamodels/Terminal.js';
7
+ import TerminalPainter from './painters/Terminal.js';
8
+ import Assignment from './datamodels/Assignment.js';
9
+ import AssignmentPainter from './painters/Assignment.js';
10
+ import Process from './datamodels/Process.js';
11
+ import ProcessPainter from './painters/Process.js';
12
+ import Call from './datamodels/Call.js';
13
+ import CallPainter from './painters/Call.js';
14
+ import Parallel from './datamodels/Parallel.js';
15
+ import ParallelPainter from './painters/Parallel.js';
16
+ import Loop from './datamodels/Loop.js';
17
+ import LoopPainter from './painters/Loop.js';
18
+ import Selection from './datamodels/Selection.js';
19
+ import SelectionPainter from './painters/Selection.js';
20
+ import Group from './datamodels/Group.js';
21
+ import GroupPainter from './painters/Group.js';
22
+ import Connector from './datamodels/Connector.js';
23
+ import ConnectorPainter from './painters/Connector.js';
24
+ registerElement('TERMINAL', { datamodel: Terminal, painter: TerminalPainter });
25
+ registerElement('ASSIGNMENT', { datamodel: Assignment, painter: AssignmentPainter });
26
+ registerElement('PROCESS', { datamodel: Process, painter: ProcessPainter });
27
+ registerElement('CALL', { datamodel: Call, painter: CallPainter });
28
+ registerElement('PARALLEL', { datamodel: Parallel, painter: ParallelPainter });
29
+ registerElement('LOOP', { datamodel: Loop, painter: LoopPainter });
30
+ registerElement('SELECTION', { datamodel: Selection, painter: SelectionPainter });
31
+ registerElement('GROUP', { datamodel: Group, painter: GroupPainter });
32
+ registerElement('CONNECTOR', { datamodel: Connector, painter: ConnectorPainter });
@@ -0,0 +1,4 @@
1
+ export default class Assignment {
2
+ draw(place: any, data: any): any;
3
+ }
4
+ //# sourceMappingURL=Assignment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Assignment.d.ts","sourceRoot":"","sources":["../../../src/pad/painters/Assignment.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,OAAO,OAAO,UAAU;IAC3B,IAAI,CAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG;CAwE9B"}
@@ -0,0 +1,72 @@
1
+ // Assignment(代入文)の描画クラス。
2
+ // 正規化済みデータ(datamodels/Assignment.ts の出力)を、d3 のセレクション
3
+ // (place) に対して描画する。データの正規化には関知しない。
4
+ //
5
+ // 代入先・値のどちらもテキスト量に合わせて幅を可変にするため、まず両方の
6
+ // テキストを描画してから実測(getBBox)し、その幅を元に区切り(<)の位置・
7
+ // 全体幅を決める(PROCESSのセル描画と同じ考え方)。
8
+ import { attachClick } from './interactive.js';
9
+ const PADDING_LEFT = 12;
10
+ const PADDING_AFTER_TEXT = 14;
11
+ const DESCRIPTION_GAP = 16;
12
+ export default class Assignment {
13
+ draw(place, data) {
14
+ const g = place.append('g').attr('class', 'pad-assignment');
15
+ const h = data.size.h;
16
+ const notchDepth = data.notch.width;
17
+ const targetText = g.append('text')
18
+ .attr('x', PADDING_LEFT)
19
+ .attr('y', h / 2)
20
+ .attr('dominant-baseline', 'central')
21
+ .style('font-family', data.font.family)
22
+ .style('font-size', data.font.size)
23
+ .attr('fill', data.font.color)
24
+ .text(data.targets_text);
25
+ const targetWidth = targetText.node().getBBox().width;
26
+ const notchX = PADDING_LEFT + targetWidth + PADDING_AFTER_TEXT;
27
+ const valueX = notchX + notchDepth + PADDING_LEFT;
28
+ const valueText = g.append('text')
29
+ .attr('x', valueX)
30
+ .attr('y', h / 2)
31
+ .attr('dominant-baseline', 'central')
32
+ .style('font-family', data.font.family)
33
+ .style('font-size', data.font.size)
34
+ .attr('fill', data.font.color)
35
+ .text(data.value_text);
36
+ const valueWidth = valueText.node().getBBox().width;
37
+ const totalWidth = valueX + valueWidth + PADDING_LEFT;
38
+ const x = data.position.x;
39
+ g.attr('transform', `translate(${x},${data.position.y})`);
40
+ // 外枠(テキストより先に挿入し、下に来るようにする)
41
+ g.insert('rect', ':first-child')
42
+ .attr('width', totalWidth)
43
+ .attr('height', h)
44
+ .attr('fill', '#fff')
45
+ .attr('stroke', data.stroke.color)
46
+ .attr('stroke-width', data.stroke.width);
47
+ // 代入先と値を区切る「<」
48
+ g.append('path')
49
+ .attr('d', `M ${notchX + notchDepth} 0 L ${notchX} ${h / 2} L ${notchX + notchDepth} ${h}`)
50
+ .attr('fill', 'none')
51
+ .attr('stroke', data.stroke.color)
52
+ .attr('stroke-width', data.stroke.width);
53
+ if (data.description) {
54
+ g.append('text')
55
+ .attr('x', totalWidth + DESCRIPTION_GAP)
56
+ .attr('y', h / 2)
57
+ .attr('dominant-baseline', 'central')
58
+ .style('font-family', data.font.family)
59
+ .style('font-size', data.font.size)
60
+ .attr('fill', data.font.color)
61
+ .text(data.description);
62
+ }
63
+ data.size.w = totalWidth;
64
+ const anchorX = data.anchor_at_spine ? x : x + totalWidth / 2;
65
+ data.anchors = {
66
+ top: { x: anchorX, y: data.position.y },
67
+ bottom: { x: anchorX, y: data.position.y + h },
68
+ };
69
+ attachClick(g, data);
70
+ return g;
71
+ }
72
+ }
@@ -0,0 +1,4 @@
1
+ export default class Call {
2
+ draw(place: any, data: any): any;
3
+ }
4
+ //# sourceMappingURL=Call.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Call.d.ts","sourceRoot":"","sources":["../../../src/pad/painters/Call.ts"],"names":[],"mappings":"AAgDA,MAAM,CAAC,OAAO,OAAO,IAAI;IACrB,IAAI,CAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG;CAsG9B"}