@yanqirenshi/d3.wireframe 0.0.7 → 0.1.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/dist/DataBackground.js +37 -0
- package/dist/DataFont.js +39 -0
- package/dist/DataPosition.js +39 -0
- package/dist/DataRectangle.js +37 -0
- package/dist/DataStroke.js +37 -0
- package/dist/Digestion.js +320 -0
- package/dist/Drawer.js +317 -0
- package/dist/Element.js +98 -0
- package/dist/ElementButton.js +128 -0
- package/dist/ElementDialog.js +112 -0
- package/dist/ElementFounder.js +116 -0
- package/dist/ElementFrame.js +112 -0
- package/dist/ElementIcon.js +83 -0
- package/dist/ElementImage.js +112 -0
- package/dist/ElementLabel.js +82 -0
- package/dist/ElementModal.js +93 -0
- package/dist/Rectum.js +161 -0
- package/dist/components/D3Wireframe.js +16 -0
- package/dist/index.js +16 -0
- package/package.json +45 -35
- package/src/{D3Wireframe.js → Rectum.js} +115 -111
- package/src/components/D3Wireframe.js +9 -0
- package/src/index.js +9 -0
- package/babel.config.js +0 -14
- package/docs/asset-manifest.json +0 -23
- package/docs/favicon.ico +0 -0
- package/docs/index.html +0 -1
- package/docs/logo192.png +0 -0
- package/docs/logo512.png +0 -0
- package/docs/manifest.json +0 -25
- package/docs/precache-manifest.5f1fad934ed0507dbc92de6788eff788.js +0 -30
- package/docs/robots.txt +0 -3
- package/docs/service-worker.js +0 -39
- package/docs/static/css/main.5f361e03.chunk.css +0 -2
- package/docs/static/css/main.5f361e03.chunk.css.map +0 -1
- package/docs/static/js/2.e2326255.chunk.js +0 -3
- package/docs/static/js/2.e2326255.chunk.js.LICENSE.txt +0 -32
- package/docs/static/js/2.e2326255.chunk.js.map +0 -1
- package/docs/static/js/main.7f51684e.chunk.js +0 -2
- package/docs/static/js/main.7f51684e.chunk.js.map +0 -1
- package/docs/static/js/runtime-main.0c5b98f9.js +0 -2
- package/docs/static/js/runtime-main.0c5b98f9.js.map +0 -1
- package/docs/static/media/logo.5d5d9eef.svg +0 -7
- package/documents/README.md +0 -68
- package/documents/package-lock.json +0 -13792
- package/documents/package.json +0 -34
- package/documents/public/favicon.ico +0 -0
- package/documents/public/index.html +0 -43
- package/documents/public/logo192.png +0 -0
- package/documents/public/logo512.png +0 -0
- package/documents/public/manifest.json +0 -25
- package/documents/public/robots.txt +0 -3
- package/documents/src/App.css +0 -38
- package/documents/src/App.js +0 -26
- package/documents/src/App.test.js +0 -9
- package/documents/src/index.css +0 -13
- package/documents/src/index.js +0 -17
- package/documents/src/logo.svg +0 -7
- package/documents/src/serviceWorker.js +0 -141
- package/documents/src/setupTests.js +0 -5
- package/example/README.md +0 -68
- package/example/package-lock.json +0 -14729
- package/example/package.json +0 -36
- package/example/public/favicon.ico +0 -0
- package/example/public/index.html +0 -43
- package/example/public/logo192.png +0 -0
- package/example/public/logo512.png +0 -0
- package/example/public/manifest.json +0 -25
- package/example/public/robots.txt +0 -3
- package/example/src/App.css +0 -38
- package/example/src/App.js +0 -14
- package/example/src/App.test.js +0 -9
- package/example/src/data/WIREFRAME_DATA.js +0 -11
- package/example/src/data/WIREFRAME_DATA_DIALOG.js +0 -65
- package/example/src/data/WIREFRAME_DATA_FRAME.js +0 -70
- package/example/src/data/WIREFRAME_DATA_MODAL.js +0 -10
- package/example/src/index.css +0 -13
- package/example/src/index.js +0 -17
- package/example/src/js/D3Wireframe.js +0 -111
- package/example/src/js/DataBackground.js +0 -23
- package/example/src/js/DataFont.js +0 -25
- package/example/src/js/DataPosition.js +0 -21
- package/example/src/js/DataRectangle.js +0 -20
- package/example/src/js/DataStroke.js +0 -23
- package/example/src/js/Digestion.js +0 -273
- package/example/src/js/Drawer.js +0 -270
- package/example/src/js/Element.js +0 -67
- package/example/src/js/ElementButton.js +0 -94
- package/example/src/js/ElementDialog.js +0 -77
- package/example/src/js/ElementFounder.js +0 -85
- package/example/src/js/ElementFrame.js +0 -77
- package/example/src/js/ElementIcon.js +0 -56
- package/example/src/js/ElementImage.js +0 -77
- package/example/src/js/ElementLabel.js +0 -51
- package/example/src/js/ElementModal.js +0 -65
- package/example/src/pages/ExampleGraph.js +0 -39
- package/example/src/pages/Explanation.js +0 -43
- package/example/src/pages/PageExample.js +0 -41
- package/example/src/serviceWorker.js +0 -141
- package/example/src/setupTests.js +0 -5
- package/index.js +0 -3
- package/jest.config.js +0 -17
- package/riot.v3/index.html +0 -21
- package/riot.v3/index.js +0 -86
- package/riot.v3/scketch.js +0 -96
- package/riot.v3/wireframe.js +0 -11
- package/tests/D3Wireframe.test.js +0 -7
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
// https://yanqirenshi.github.io/D3.Sketch/dist/edge/Drawer.js
|
|
2
|
-
/**
|
|
3
|
-
* 幾何学計算するための Drawer です。
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* let drawer = new DrawerHierarchy();
|
|
7
|
-
*/
|
|
8
|
-
export class DigestionGeometry {
|
|
9
|
-
///// ////////////////////////////////////////////////////////////////
|
|
10
|
-
///// Utilities
|
|
11
|
-
///// ////////////////////////////////////////////////////////////////
|
|
12
|
-
deg2rad (degree) {
|
|
13
|
-
return degree * ( Math.PI / 180 );
|
|
14
|
-
}
|
|
15
|
-
///// ////////////////////////////////////////////////////////////////
|
|
16
|
-
///// Cross Point of two lines
|
|
17
|
-
///// ////////////////////////////////////////////////////////////////
|
|
18
|
-
isCorss(A, B, C, D) {
|
|
19
|
-
// 二つの線分の交差チェック
|
|
20
|
-
// https://www.hiramine.com/programming/graphics/2d_segmentintersection.html
|
|
21
|
-
let ACx = C.x - A.x;
|
|
22
|
-
let ACy = C.y - A.y;
|
|
23
|
-
let BUNBO = (B.x - A.x) * (D.y - C.y) - (B.y - A.y) * (D.x - C.x);
|
|
24
|
-
|
|
25
|
-
if (BUNBO===0)
|
|
26
|
-
return false;
|
|
27
|
-
|
|
28
|
-
let r = ((D.y - C.y) * ACx - (D.x - C.x) * ACy) / BUNBO;
|
|
29
|
-
let s = ((B.y - A.y) * ACx - (B.x - A.x) * ACy) / BUNBO;
|
|
30
|
-
|
|
31
|
-
return ((0 <= r && r <= 1) && (0 <= s && s <= 1));
|
|
32
|
-
}
|
|
33
|
-
// 2直線の交点を求める。(具)
|
|
34
|
-
getCrossPointCore (line, line_port) {
|
|
35
|
-
let out = { x:0, y:0 };
|
|
36
|
-
|
|
37
|
-
let A = line.from;
|
|
38
|
-
let B = line.to;
|
|
39
|
-
let C = line_port.from;
|
|
40
|
-
let D = line_port.to;
|
|
41
|
-
|
|
42
|
-
let bunbo = (B.y - A.y) * (D.x - C.x) - (B.x - A.x) * (D.y - C.y);
|
|
43
|
-
|
|
44
|
-
if (!this.isCorss(A, B, C, D))
|
|
45
|
-
return null;
|
|
46
|
-
|
|
47
|
-
// 二つの線分の交点を算出する。
|
|
48
|
-
// http://mf-atelier.sakura.ne.jp/mf-atelier/modules/tips/program/algorithm/a1.html
|
|
49
|
-
let d1, d2;
|
|
50
|
-
|
|
51
|
-
d1 = (C.y * D.x) - (C.x * D.y);
|
|
52
|
-
d2 = (A.y * B.x) - (A.x * B.y);
|
|
53
|
-
|
|
54
|
-
out.x = (d1 * (B.x - A.x) - d2 * (D.x - C.x)) / bunbo;
|
|
55
|
-
out.y = (d1 * (B.y - A.y) - d2 * (D.y - C.y)) / bunbo;
|
|
56
|
-
|
|
57
|
-
return out;
|
|
58
|
-
}
|
|
59
|
-
// 2直線の交点を求める。
|
|
60
|
-
getCrossPoint (lines, line_port) {
|
|
61
|
-
for (let line of lines) {
|
|
62
|
-
let point = this.getCrossPointCore(line, line_port);
|
|
63
|
-
|
|
64
|
-
if (point)
|
|
65
|
-
return point;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Drawer の共通要素とての Core です。
|
|
74
|
-
* 各 Drawer の要素を整えるメッソッドをまとめているクラスです。
|
|
75
|
-
* いろいろと共通なものがあると思うので。
|
|
76
|
-
* また見通しも良くなるかと。
|
|
77
|
-
* 作る必要があるのかはアレですが。。。
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* let drawer = new DrawerHierarchy();
|
|
81
|
-
*/
|
|
82
|
-
export class DigestionCore {
|
|
83
|
-
///// ////////////////////////////////////////////////////////////////
|
|
84
|
-
///// normalize
|
|
85
|
-
///// ////////////////////////////////////////////////////////////////
|
|
86
|
-
normalizeFont (font_core) {
|
|
87
|
-
let template = { size: 16, color: '#333333' };
|
|
88
|
-
|
|
89
|
-
if (!font_core)
|
|
90
|
-
return template;
|
|
91
|
-
|
|
92
|
-
return font_core;
|
|
93
|
-
}
|
|
94
|
-
normalizeLabel (label_core) {
|
|
95
|
-
let label = {
|
|
96
|
-
contents: '',
|
|
97
|
-
position: { x: 20, y: 20 },
|
|
98
|
-
font: { size: 16, color: '#333333' },
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
if (!label_core)
|
|
102
|
-
return label;
|
|
103
|
-
|
|
104
|
-
if (label_core.contents)
|
|
105
|
-
label.contents = label_core.contents;
|
|
106
|
-
|
|
107
|
-
let label_tmp = label_core.position ? label_core.position : label.position;
|
|
108
|
-
label.position = this.normalizePosition(label_tmp);
|
|
109
|
-
|
|
110
|
-
label.font = this.normalizeFont(label_core.font);
|
|
111
|
-
|
|
112
|
-
return label;
|
|
113
|
-
}
|
|
114
|
-
normalizeSize (size_core) {
|
|
115
|
-
let size = { w: 0, h: 0 };
|
|
116
|
-
|
|
117
|
-
if (!size_core)
|
|
118
|
-
return size;
|
|
119
|
-
|
|
120
|
-
if (size_core.w || size_core.w===0)
|
|
121
|
-
size.w = size_core.w;
|
|
122
|
-
|
|
123
|
-
if (size_core.h || size_core.h===0)
|
|
124
|
-
size.h = size_core.h;
|
|
125
|
-
|
|
126
|
-
return size;
|
|
127
|
-
}
|
|
128
|
-
normalizePosition (position_core) {
|
|
129
|
-
let position = { x: 0, y: 0 };
|
|
130
|
-
|
|
131
|
-
if (!position_core)
|
|
132
|
-
return position;
|
|
133
|
-
|
|
134
|
-
if (position_core.x || position_core.x===0)
|
|
135
|
-
position.x = position_core.x;
|
|
136
|
-
|
|
137
|
-
if (position_core.y || position_core.y===0)
|
|
138
|
-
position.y = position_core.y;
|
|
139
|
-
|
|
140
|
-
return position;
|
|
141
|
-
}
|
|
142
|
-
normalizeBackground (background_core) {
|
|
143
|
-
let background = {
|
|
144
|
-
color: '#ffffff'
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
if (!background_core)
|
|
148
|
-
return background;
|
|
149
|
-
|
|
150
|
-
if (background_core.color)
|
|
151
|
-
background.color = background_core.color;
|
|
152
|
-
|
|
153
|
-
return background;
|
|
154
|
-
}
|
|
155
|
-
normalizeBorder (border_core) {
|
|
156
|
-
let border = {
|
|
157
|
-
width: 1,
|
|
158
|
-
type: 'solid',
|
|
159
|
-
color: '#666666'
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
if (!border_core)
|
|
163
|
-
return border;
|
|
164
|
-
|
|
165
|
-
if (border_core.width || border_core.width===0)
|
|
166
|
-
border.width = border_core.width;
|
|
167
|
-
|
|
168
|
-
if (border_core.color)
|
|
169
|
-
border.color = border_core.color;
|
|
170
|
-
|
|
171
|
-
if (border_core.type)
|
|
172
|
-
border.type = border_core.type;
|
|
173
|
-
|
|
174
|
-
return border;
|
|
175
|
-
}
|
|
176
|
-
normalizePadding (padding_core) {
|
|
177
|
-
let template = { top: 0, left: 0, bottom: 0, right: 0 };
|
|
178
|
-
|
|
179
|
-
if (!padding_core)
|
|
180
|
-
return template;
|
|
181
|
-
|
|
182
|
-
return padding_core;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* 階層構造のデータの Drawer です。
|
|
188
|
-
* Data の 位置、サイズ を整えます。
|
|
189
|
-
*
|
|
190
|
-
* @example
|
|
191
|
-
* let drawer = new DrawerHierarchy();
|
|
192
|
-
*/
|
|
193
|
-
export class DigestionHierarchy extends DigestionCore {
|
|
194
|
-
///// ////////////////////////////////////////////////////////////////
|
|
195
|
-
///// Utilities
|
|
196
|
-
///// ////////////////////////////////////////////////////////////////
|
|
197
|
-
data2rect (data) {
|
|
198
|
-
return {
|
|
199
|
-
from: {
|
|
200
|
-
x: data.position.x,
|
|
201
|
-
y: data.position.y,
|
|
202
|
-
},
|
|
203
|
-
to: {
|
|
204
|
-
x: data.position.x + data.size.w,
|
|
205
|
-
y: data.position.y + data.size.h,
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
///// ////////////////////////////////////////////////////////////////
|
|
210
|
-
///// Fitting
|
|
211
|
-
///// ////////////////////////////////////////////////////////////////
|
|
212
|
-
fittingCalSizeCore (rect_a, rect_b) {
|
|
213
|
-
if (!rect_a.from) {
|
|
214
|
-
rect_a.from = { x: rect_b.from.x, y: rect_b.from.y };
|
|
215
|
-
} else {
|
|
216
|
-
if (rect_a.from.x > rect_b.from.x)
|
|
217
|
-
rect_a.from.x = rect_b.from.x;
|
|
218
|
-
|
|
219
|
-
if (rect_a.from.y > rect_b.from.y)
|
|
220
|
-
rect_a.from.y = rect_b.from.y;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
if (!rect_a.to) {
|
|
224
|
-
rect_a.to = {
|
|
225
|
-
x: rect_b.to.x,
|
|
226
|
-
y: rect_b.to.y,
|
|
227
|
-
};
|
|
228
|
-
} else {
|
|
229
|
-
if (rect_a.to.x < rect_b.to.x)
|
|
230
|
-
rect_a.to.x = rect_b.to.x;
|
|
231
|
-
|
|
232
|
-
if (rect_a.to.y < rect_b.to.y)
|
|
233
|
-
rect_a.to.y = rect_b.to.y;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
fittingCalSize (rect, child) {
|
|
237
|
-
let rect_a = rect;
|
|
238
|
-
let rect_b = this.data2rect(child);
|
|
239
|
-
|
|
240
|
-
this.fittingCalSizeCore(rect_a, rect_b);
|
|
241
|
-
}
|
|
242
|
-
fitting (data, parent) {
|
|
243
|
-
// parent からの相対位置で補正
|
|
244
|
-
if (parent) {
|
|
245
|
-
data.position.x = parent.position.x + data.position.x;
|
|
246
|
-
data.position.y = parent.position.y + data.position.y;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// children も同様に。
|
|
250
|
-
let rect = {
|
|
251
|
-
from: null,
|
|
252
|
-
to: null,
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
// children の fitting 合せて data のサイズも計測。
|
|
256
|
-
let children = data.children;
|
|
257
|
-
if (children && children.length > 0) {
|
|
258
|
-
for (let child of data.children) {
|
|
259
|
-
this.fitting(child, data);
|
|
260
|
-
|
|
261
|
-
this.fittingCalSize(rect, child); // rect は破壊的
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// children 内容で data のサイズを補正
|
|
265
|
-
this.fittingCalSizeCore(rect, this.data2rect(data));
|
|
266
|
-
data.size.w = rect.to.x - rect.from.x;
|
|
267
|
-
data.size.h = rect.to.y - rect.from.y;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
export default class Digestion {
|
|
273
|
-
}
|
package/example/src/js/Drawer.js
DELETED
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
// https://yanqirenshi.github.io/D3.Sketch/dist/edge/Drawer.js
|
|
2
|
-
/**
|
|
3
|
-
* 幾何学計算するための Drawer です。
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* let drawer = new DrawerHierarchy();
|
|
7
|
-
*/
|
|
8
|
-
export class DrawerGeometry {
|
|
9
|
-
///// ////////////////////////////////////////////////////////////////
|
|
10
|
-
///// Utilities
|
|
11
|
-
///// ////////////////////////////////////////////////////////////////
|
|
12
|
-
deg2rad (degree) {
|
|
13
|
-
return degree * ( Math.PI / 180 );
|
|
14
|
-
}
|
|
15
|
-
///// ////////////////////////////////////////////////////////////////
|
|
16
|
-
///// Cross Point of two lines
|
|
17
|
-
///// ////////////////////////////////////////////////////////////////
|
|
18
|
-
isCorss(A, B, C, D) {
|
|
19
|
-
// 二つの線分の交差チェック
|
|
20
|
-
// https://www.hiramine.com/programming/graphics/2d_segmentintersection.html
|
|
21
|
-
let ACx = C.x - A.x;
|
|
22
|
-
let ACy = C.y - A.y;
|
|
23
|
-
let BUNBO = (B.x - A.x) * (D.y - C.y) - (B.y - A.y) * (D.x - C.x);
|
|
24
|
-
|
|
25
|
-
if (BUNBO===0)
|
|
26
|
-
return false;
|
|
27
|
-
|
|
28
|
-
let r = ((D.y - C.y) * ACx - (D.x - C.x) * ACy) / BUNBO;
|
|
29
|
-
let s = ((B.y - A.y) * ACx - (B.x - A.x) * ACy) / BUNBO;
|
|
30
|
-
|
|
31
|
-
return ((0 <= r && r <= 1) && (0 <= s && s <= 1));
|
|
32
|
-
}
|
|
33
|
-
// 2直線の交点を求める。(具)
|
|
34
|
-
getCrossPointCore (line, line_port) {
|
|
35
|
-
let out = { x:0, y:0 };
|
|
36
|
-
|
|
37
|
-
let A = line.from;
|
|
38
|
-
let B = line.to;
|
|
39
|
-
let C = line_port.from;
|
|
40
|
-
let D = line_port.to;
|
|
41
|
-
|
|
42
|
-
let bunbo = (B.y - A.y) * (D.x - C.x) - (B.x - A.x) * (D.y - C.y);
|
|
43
|
-
|
|
44
|
-
if (!this.isCorss(A, B, C, D))
|
|
45
|
-
return null;
|
|
46
|
-
|
|
47
|
-
// 二つの線分の交点を算出する。
|
|
48
|
-
// http://mf-atelier.sakura.ne.jp/mf-atelier/modules/tips/program/algorithm/a1.html
|
|
49
|
-
let d1, d2;
|
|
50
|
-
|
|
51
|
-
d1 = (C.y * D.x) - (C.x * D.y);
|
|
52
|
-
d2 = (A.y * B.x) - (A.x * B.y);
|
|
53
|
-
|
|
54
|
-
out.x = (d1 * (B.x - A.x) - d2 * (D.x - C.x)) / bunbo;
|
|
55
|
-
out.y = (d1 * (B.y - A.y) - d2 * (D.y - C.y)) / bunbo;
|
|
56
|
-
|
|
57
|
-
return out;
|
|
58
|
-
}
|
|
59
|
-
// 2直線の交点を求める。
|
|
60
|
-
getCrossPoint (lines, line_port) {
|
|
61
|
-
for (let line of lines) {
|
|
62
|
-
let point = this.getCrossPointCore(line, line_port);
|
|
63
|
-
|
|
64
|
-
if (point)
|
|
65
|
-
return point;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Drawer の共通要素とての Core です。
|
|
74
|
-
* 各 Drawer の要素を整えるメッソッドをまとめているクラスです。
|
|
75
|
-
* いろいろと共通なものがあると思うので。
|
|
76
|
-
* また見通しも良くなるかと。
|
|
77
|
-
* 作る必要があるのかはアレですが。。。
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* let drawer = new DrawerHierarchy();
|
|
81
|
-
*/
|
|
82
|
-
export class Drawer {
|
|
83
|
-
///// ////////////////////////////////////////////////////////////////
|
|
84
|
-
///// normalize
|
|
85
|
-
///// ////////////////////////////////////////////////////////////////
|
|
86
|
-
normalizeFont (font_core) {
|
|
87
|
-
let template = { size: 16, color: '#333333' };
|
|
88
|
-
|
|
89
|
-
if (!font_core)
|
|
90
|
-
return template;
|
|
91
|
-
|
|
92
|
-
return font_core;
|
|
93
|
-
}
|
|
94
|
-
normalizeLabel (label_core) {
|
|
95
|
-
let label = {
|
|
96
|
-
contents: '',
|
|
97
|
-
position: { x: 20, y: 20 },
|
|
98
|
-
font: { size: 16, color: '#333333' },
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
if (!label_core)
|
|
102
|
-
return label;
|
|
103
|
-
|
|
104
|
-
if (label_core.contents)
|
|
105
|
-
label.contents = label_core.contents;
|
|
106
|
-
|
|
107
|
-
let label_tmp = label_core.position ? label_core.position : label.position;
|
|
108
|
-
label.position = this.normalizePosition(label_tmp);
|
|
109
|
-
|
|
110
|
-
label.font = this.normalizeFont(label_core.font);
|
|
111
|
-
|
|
112
|
-
return label;
|
|
113
|
-
}
|
|
114
|
-
normalizeSize (size_core) {
|
|
115
|
-
let size = { w: 0, h: 0 };
|
|
116
|
-
|
|
117
|
-
if (!size_core)
|
|
118
|
-
return size;
|
|
119
|
-
|
|
120
|
-
if (size_core.w || size_core.w===0)
|
|
121
|
-
size.w = size_core.w;
|
|
122
|
-
|
|
123
|
-
if (size_core.h || size_core.h===0)
|
|
124
|
-
size.h = size_core.h;
|
|
125
|
-
|
|
126
|
-
return size;
|
|
127
|
-
}
|
|
128
|
-
normalizePosition (position_core) {
|
|
129
|
-
let position = { x: 0, y: 0 };
|
|
130
|
-
|
|
131
|
-
if (!position_core)
|
|
132
|
-
return position;
|
|
133
|
-
|
|
134
|
-
if (position_core.x || position_core.x===0)
|
|
135
|
-
position.x = position_core.x;
|
|
136
|
-
|
|
137
|
-
if (position_core.y || position_core.y===0)
|
|
138
|
-
position.y = position_core.y;
|
|
139
|
-
|
|
140
|
-
return position;
|
|
141
|
-
}
|
|
142
|
-
normalizeBackground (background_core) {
|
|
143
|
-
let background = {
|
|
144
|
-
color: '#ffffff'
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
if (!background_core)
|
|
148
|
-
return background;
|
|
149
|
-
|
|
150
|
-
if (background_core.color)
|
|
151
|
-
background.color = background_core.color;
|
|
152
|
-
|
|
153
|
-
return background;
|
|
154
|
-
}
|
|
155
|
-
normalizeBorder (border_core) {
|
|
156
|
-
let border = {
|
|
157
|
-
width: 1,
|
|
158
|
-
type: 'solid',
|
|
159
|
-
color: '#666666'
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
if (!border_core)
|
|
163
|
-
return border;
|
|
164
|
-
|
|
165
|
-
if (border_core.width || border_core.width===0)
|
|
166
|
-
border.width = border_core.width;
|
|
167
|
-
|
|
168
|
-
if (border_core.color)
|
|
169
|
-
border.color = border_core.color;
|
|
170
|
-
|
|
171
|
-
if (border_core.type)
|
|
172
|
-
border.type = border_core.type;
|
|
173
|
-
|
|
174
|
-
return border;
|
|
175
|
-
}
|
|
176
|
-
normalizePadding (padding_core) {
|
|
177
|
-
let template = { top: 0, left: 0, bottom: 0, right: 0 };
|
|
178
|
-
|
|
179
|
-
if (!padding_core)
|
|
180
|
-
return template;
|
|
181
|
-
|
|
182
|
-
return padding_core;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* 階層構造のデータの Drawer です。
|
|
188
|
-
* Data の 位置、サイズ を整えます。
|
|
189
|
-
*
|
|
190
|
-
* @example
|
|
191
|
-
* let drawer = new DrawerHierarchy();
|
|
192
|
-
*/
|
|
193
|
-
export class DrawerHierarchy extends Drawer {
|
|
194
|
-
///// ////////////////////////////////////////////////////////////////
|
|
195
|
-
///// Utilities
|
|
196
|
-
///// ////////////////////////////////////////////////////////////////
|
|
197
|
-
data2rect (data) {
|
|
198
|
-
return {
|
|
199
|
-
from: {
|
|
200
|
-
x: data.position.x,
|
|
201
|
-
y: data.position.y,
|
|
202
|
-
},
|
|
203
|
-
to: {
|
|
204
|
-
x: data.position.x + data.rectangle.w,
|
|
205
|
-
y: data.position.y + data.rectangle.h,
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
///// ////////////////////////////////////////////////////////////////
|
|
210
|
-
///// Fitting
|
|
211
|
-
///// ////////////////////////////////////////////////////////////////
|
|
212
|
-
fittingCalSizeCore (rect_a, rect_b) {
|
|
213
|
-
if (!rect_a.from) {
|
|
214
|
-
rect_a.from = { x: rect_b.from.x, y: rect_b.from.y };
|
|
215
|
-
} else {
|
|
216
|
-
if (rect_a.from.x > rect_b.from.x)
|
|
217
|
-
rect_a.from.x = rect_b.from.x;
|
|
218
|
-
|
|
219
|
-
if (rect_a.from.y > rect_b.from.y)
|
|
220
|
-
rect_a.from.y = rect_b.from.y;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
if (!rect_a.to) {
|
|
224
|
-
rect_a.to = {
|
|
225
|
-
x: rect_b.to.x,
|
|
226
|
-
y: rect_b.to.y,
|
|
227
|
-
};
|
|
228
|
-
} else {
|
|
229
|
-
if (rect_a.to.x < rect_b.to.x)
|
|
230
|
-
rect_a.to.x = rect_b.to.x;
|
|
231
|
-
|
|
232
|
-
if (rect_a.to.y < rect_b.to.y)
|
|
233
|
-
rect_a.to.y = rect_b.to.y;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
fittingCalSize (rect, child) {
|
|
237
|
-
let rect_a = rect;
|
|
238
|
-
let rect_b = this.data2rect(child);
|
|
239
|
-
|
|
240
|
-
this.fittingCalSizeCore(rect_a, rect_b);
|
|
241
|
-
}
|
|
242
|
-
fitting (data, parent) {
|
|
243
|
-
// parent からの相対位置で補正
|
|
244
|
-
if (parent) {
|
|
245
|
-
data.position.x = parent.position.x + data.position.x;
|
|
246
|
-
data.position.y = parent.position.y + data.position.y;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// children も同様に。
|
|
250
|
-
let rect = {
|
|
251
|
-
from: null,
|
|
252
|
-
to: null,
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
// children の fitting 合せて data のサイズも計測。
|
|
256
|
-
let children = data.children;
|
|
257
|
-
if (children && children.length > 0) {
|
|
258
|
-
for (let child of data.children) {
|
|
259
|
-
this.fitting(child, data);
|
|
260
|
-
|
|
261
|
-
this.fittingCalSize(rect, child); // rect は破壊的
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// children 内容で data のサイズを補正
|
|
265
|
-
this.fittingCalSizeCore(rect, this.data2rect(data));
|
|
266
|
-
data.rectangle.w = rect.to.x - rect.from.x;
|
|
267
|
-
data.rectangle.h = rect.to.y - rect.from.y;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import ElementFrame from './ElementFrame';
|
|
2
|
-
import ElementImage from './ElementImage';
|
|
3
|
-
import ElementButton from './ElementButton';
|
|
4
|
-
import ElementModal from './ElementModal';
|
|
5
|
-
import ElementDialog from './ElementDialog';
|
|
6
|
-
|
|
7
|
-
export default class Element {
|
|
8
|
-
constructor () {
|
|
9
|
-
this._id = 0;
|
|
10
|
-
|
|
11
|
-
const params = { idm: this };
|
|
12
|
-
|
|
13
|
-
this.element_classes = {
|
|
14
|
-
frame: new ElementFrame(params),
|
|
15
|
-
image: new ElementImage(params),
|
|
16
|
-
button: new ElementButton(params),
|
|
17
|
-
modal: new ElementModal(params),
|
|
18
|
-
dialog: new ElementDialog(params),
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
nextID () {
|
|
22
|
-
return ++this._id;
|
|
23
|
-
};
|
|
24
|
-
/* **************************************************************** *
|
|
25
|
-
* Element Class
|
|
26
|
-
* **************************************************************** */
|
|
27
|
-
elementClass (data) {
|
|
28
|
-
const element_type = data.element_type;
|
|
29
|
-
|
|
30
|
-
const element_class = this.element_classes[data.element_type];
|
|
31
|
-
|
|
32
|
-
if (!element_class)
|
|
33
|
-
throw new Error('Not supported yet. element_type=' + element_type);
|
|
34
|
-
|
|
35
|
-
return element_class;
|
|
36
|
-
}
|
|
37
|
-
/* **************************************************************** *
|
|
38
|
-
* Element Class
|
|
39
|
-
* **************************************************************** */
|
|
40
|
-
makeElement (core) {
|
|
41
|
-
const element_class = this.elementClass(core);
|
|
42
|
-
|
|
43
|
-
const element = element_class.makeElement(core);
|
|
44
|
-
|
|
45
|
-
const children = core.children || [];
|
|
46
|
-
element.children = children
|
|
47
|
-
.map(d => this.makeElement(d))
|
|
48
|
-
.filter(d => d.visible);
|
|
49
|
-
|
|
50
|
-
return element;
|
|
51
|
-
}
|
|
52
|
-
mergeCore (core, element) {
|
|
53
|
-
const element_class = this.elementClass(core);
|
|
54
|
-
|
|
55
|
-
return element_class.merge(core, element);
|
|
56
|
-
}
|
|
57
|
-
/* **************************************************************** *
|
|
58
|
-
* Draw
|
|
59
|
-
* **************************************************************** */
|
|
60
|
-
draw (place, list) {
|
|
61
|
-
for (let data of list) {
|
|
62
|
-
const ec = this.elementClass(data);
|
|
63
|
-
|
|
64
|
-
ec.draw(place, data);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|