@yanqirenshi/d3.wireframe 0.0.7 → 0.1.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.
- package/babel.config.js +10 -14
- 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/jest.config.js +23 -17
- package/package.json +41 -35
- package/src/{D3Wireframe.js → Rectum.js} +115 -111
- package/src/components/D3Wireframe.js +9 -0
- package/src/index.js +9 -0
- package/tests/D3Wireframe.test.js +54 -7
- package/tests/d3-stub.js +4 -0
- 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/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/dist/Drawer.js
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DrawerHierarchy = exports.DrawerGeometry = exports.Drawer = void 0;
|
|
7
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
8
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
9
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
10
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
11
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
12
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
13
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
14
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
15
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
16
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
17
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
18
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
19
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
20
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
21
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
22
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
23
|
+
// https://yanqirenshi.github.io/D3.Sketch/dist/edge/Drawer.js
|
|
24
|
+
/**
|
|
25
|
+
* 幾何学計算するための Drawer です。
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* let drawer = new DrawerHierarchy();
|
|
29
|
+
*/
|
|
30
|
+
var DrawerGeometry = exports.DrawerGeometry = /*#__PURE__*/function () {
|
|
31
|
+
function DrawerGeometry() {
|
|
32
|
+
_classCallCheck(this, DrawerGeometry);
|
|
33
|
+
}
|
|
34
|
+
return _createClass(DrawerGeometry, [{
|
|
35
|
+
key: "deg2rad",
|
|
36
|
+
value:
|
|
37
|
+
///// ////////////////////////////////////////////////////////////////
|
|
38
|
+
///// Utilities
|
|
39
|
+
///// ////////////////////////////////////////////////////////////////
|
|
40
|
+
function deg2rad(degree) {
|
|
41
|
+
return degree * (Math.PI / 180);
|
|
42
|
+
}
|
|
43
|
+
///// ////////////////////////////////////////////////////////////////
|
|
44
|
+
///// Cross Point of two lines
|
|
45
|
+
///// ////////////////////////////////////////////////////////////////
|
|
46
|
+
}, {
|
|
47
|
+
key: "isCorss",
|
|
48
|
+
value: function isCorss(A, B, C, D) {
|
|
49
|
+
// 二つの線分の交差チェック
|
|
50
|
+
// https://www.hiramine.com/programming/graphics/2d_segmentintersection.html
|
|
51
|
+
var ACx = C.x - A.x;
|
|
52
|
+
var ACy = C.y - A.y;
|
|
53
|
+
var BUNBO = (B.x - A.x) * (D.y - C.y) - (B.y - A.y) * (D.x - C.x);
|
|
54
|
+
if (BUNBO === 0) return false;
|
|
55
|
+
var r = ((D.y - C.y) * ACx - (D.x - C.x) * ACy) / BUNBO;
|
|
56
|
+
var s = ((B.y - A.y) * ACx - (B.x - A.x) * ACy) / BUNBO;
|
|
57
|
+
return 0 <= r && r <= 1 && 0 <= s && s <= 1;
|
|
58
|
+
}
|
|
59
|
+
// 2直線の交点を求める。(具)
|
|
60
|
+
}, {
|
|
61
|
+
key: "getCrossPointCore",
|
|
62
|
+
value: function getCrossPointCore(line, line_port) {
|
|
63
|
+
var out = {
|
|
64
|
+
x: 0,
|
|
65
|
+
y: 0
|
|
66
|
+
};
|
|
67
|
+
var A = line.from;
|
|
68
|
+
var B = line.to;
|
|
69
|
+
var C = line_port.from;
|
|
70
|
+
var D = line_port.to;
|
|
71
|
+
var bunbo = (B.y - A.y) * (D.x - C.x) - (B.x - A.x) * (D.y - C.y);
|
|
72
|
+
if (!this.isCorss(A, B, C, D)) return null;
|
|
73
|
+
|
|
74
|
+
// 二つの線分の交点を算出する。
|
|
75
|
+
// http://mf-atelier.sakura.ne.jp/mf-atelier/modules/tips/program/algorithm/a1.html
|
|
76
|
+
var d1, d2;
|
|
77
|
+
d1 = C.y * D.x - C.x * D.y;
|
|
78
|
+
d2 = A.y * B.x - A.x * B.y;
|
|
79
|
+
out.x = (d1 * (B.x - A.x) - d2 * (D.x - C.x)) / bunbo;
|
|
80
|
+
out.y = (d1 * (B.y - A.y) - d2 * (D.y - C.y)) / bunbo;
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
// 2直線の交点を求める。
|
|
84
|
+
}, {
|
|
85
|
+
key: "getCrossPoint",
|
|
86
|
+
value: function getCrossPoint(lines, line_port) {
|
|
87
|
+
var _iterator = _createForOfIteratorHelper(lines),
|
|
88
|
+
_step;
|
|
89
|
+
try {
|
|
90
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
91
|
+
var line = _step.value;
|
|
92
|
+
var point = this.getCrossPointCore(line, line_port);
|
|
93
|
+
if (point) return point;
|
|
94
|
+
}
|
|
95
|
+
} catch (err) {
|
|
96
|
+
_iterator.e(err);
|
|
97
|
+
} finally {
|
|
98
|
+
_iterator.f();
|
|
99
|
+
}
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
}]);
|
|
103
|
+
}();
|
|
104
|
+
/**
|
|
105
|
+
* Drawer の共通要素とての Core です。
|
|
106
|
+
* 各 Drawer の要素を整えるメッソッドをまとめているクラスです。
|
|
107
|
+
* いろいろと共通なものがあると思うので。
|
|
108
|
+
* また見通しも良くなるかと。
|
|
109
|
+
* 作る必要があるのかはアレですが。。。
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* let drawer = new DrawerHierarchy();
|
|
113
|
+
*/
|
|
114
|
+
var Drawer = exports.Drawer = /*#__PURE__*/function () {
|
|
115
|
+
function Drawer() {
|
|
116
|
+
_classCallCheck(this, Drawer);
|
|
117
|
+
}
|
|
118
|
+
return _createClass(Drawer, [{
|
|
119
|
+
key: "normalizeFont",
|
|
120
|
+
value:
|
|
121
|
+
///// ////////////////////////////////////////////////////////////////
|
|
122
|
+
///// normalize
|
|
123
|
+
///// ////////////////////////////////////////////////////////////////
|
|
124
|
+
function normalizeFont(font_core) {
|
|
125
|
+
var template = {
|
|
126
|
+
size: 16,
|
|
127
|
+
color: '#333333'
|
|
128
|
+
};
|
|
129
|
+
if (!font_core) return template;
|
|
130
|
+
return font_core;
|
|
131
|
+
}
|
|
132
|
+
}, {
|
|
133
|
+
key: "normalizeLabel",
|
|
134
|
+
value: function normalizeLabel(label_core) {
|
|
135
|
+
var label = {
|
|
136
|
+
contents: '',
|
|
137
|
+
position: {
|
|
138
|
+
x: 20,
|
|
139
|
+
y: 20
|
|
140
|
+
},
|
|
141
|
+
font: {
|
|
142
|
+
size: 16,
|
|
143
|
+
color: '#333333'
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
if (!label_core) return label;
|
|
147
|
+
if (label_core.contents) label.contents = label_core.contents;
|
|
148
|
+
var label_tmp = label_core.position ? label_core.position : label.position;
|
|
149
|
+
label.position = this.normalizePosition(label_tmp);
|
|
150
|
+
label.font = this.normalizeFont(label_core.font);
|
|
151
|
+
return label;
|
|
152
|
+
}
|
|
153
|
+
}, {
|
|
154
|
+
key: "normalizeSize",
|
|
155
|
+
value: function normalizeSize(size_core) {
|
|
156
|
+
var size = {
|
|
157
|
+
w: 0,
|
|
158
|
+
h: 0
|
|
159
|
+
};
|
|
160
|
+
if (!size_core) return size;
|
|
161
|
+
if (size_core.w || size_core.w === 0) size.w = size_core.w;
|
|
162
|
+
if (size_core.h || size_core.h === 0) size.h = size_core.h;
|
|
163
|
+
return size;
|
|
164
|
+
}
|
|
165
|
+
}, {
|
|
166
|
+
key: "normalizePosition",
|
|
167
|
+
value: function normalizePosition(position_core) {
|
|
168
|
+
var position = {
|
|
169
|
+
x: 0,
|
|
170
|
+
y: 0
|
|
171
|
+
};
|
|
172
|
+
if (!position_core) return position;
|
|
173
|
+
if (position_core.x || position_core.x === 0) position.x = position_core.x;
|
|
174
|
+
if (position_core.y || position_core.y === 0) position.y = position_core.y;
|
|
175
|
+
return position;
|
|
176
|
+
}
|
|
177
|
+
}, {
|
|
178
|
+
key: "normalizeBackground",
|
|
179
|
+
value: function normalizeBackground(background_core) {
|
|
180
|
+
var background = {
|
|
181
|
+
color: '#ffffff'
|
|
182
|
+
};
|
|
183
|
+
if (!background_core) return background;
|
|
184
|
+
if (background_core.color) background.color = background_core.color;
|
|
185
|
+
return background;
|
|
186
|
+
}
|
|
187
|
+
}, {
|
|
188
|
+
key: "normalizeBorder",
|
|
189
|
+
value: function normalizeBorder(border_core) {
|
|
190
|
+
var border = {
|
|
191
|
+
width: 1,
|
|
192
|
+
type: 'solid',
|
|
193
|
+
color: '#666666'
|
|
194
|
+
};
|
|
195
|
+
if (!border_core) return border;
|
|
196
|
+
if (border_core.width || border_core.width === 0) border.width = border_core.width;
|
|
197
|
+
if (border_core.color) border.color = border_core.color;
|
|
198
|
+
if (border_core.type) border.type = border_core.type;
|
|
199
|
+
return border;
|
|
200
|
+
}
|
|
201
|
+
}, {
|
|
202
|
+
key: "normalizePadding",
|
|
203
|
+
value: function normalizePadding(padding_core) {
|
|
204
|
+
var template = {
|
|
205
|
+
top: 0,
|
|
206
|
+
left: 0,
|
|
207
|
+
bottom: 0,
|
|
208
|
+
right: 0
|
|
209
|
+
};
|
|
210
|
+
if (!padding_core) return template;
|
|
211
|
+
return padding_core;
|
|
212
|
+
}
|
|
213
|
+
}]);
|
|
214
|
+
}();
|
|
215
|
+
/**
|
|
216
|
+
* 階層構造のデータの Drawer です。
|
|
217
|
+
* Data の 位置、サイズ を整えます。
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* let drawer = new DrawerHierarchy();
|
|
221
|
+
*/
|
|
222
|
+
var DrawerHierarchy = exports.DrawerHierarchy = /*#__PURE__*/function (_Drawer) {
|
|
223
|
+
function DrawerHierarchy() {
|
|
224
|
+
_classCallCheck(this, DrawerHierarchy);
|
|
225
|
+
return _callSuper(this, DrawerHierarchy, arguments);
|
|
226
|
+
}
|
|
227
|
+
_inherits(DrawerHierarchy, _Drawer);
|
|
228
|
+
return _createClass(DrawerHierarchy, [{
|
|
229
|
+
key: "data2rect",
|
|
230
|
+
value:
|
|
231
|
+
///// ////////////////////////////////////////////////////////////////
|
|
232
|
+
///// Utilities
|
|
233
|
+
///// ////////////////////////////////////////////////////////////////
|
|
234
|
+
function data2rect(data) {
|
|
235
|
+
return {
|
|
236
|
+
from: {
|
|
237
|
+
x: data.position.x,
|
|
238
|
+
y: data.position.y
|
|
239
|
+
},
|
|
240
|
+
to: {
|
|
241
|
+
x: data.position.x + data.rectangle.w,
|
|
242
|
+
y: data.position.y + data.rectangle.h
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
///// ////////////////////////////////////////////////////////////////
|
|
247
|
+
///// Fitting
|
|
248
|
+
///// ////////////////////////////////////////////////////////////////
|
|
249
|
+
}, {
|
|
250
|
+
key: "fittingCalSizeCore",
|
|
251
|
+
value: function fittingCalSizeCore(rect_a, rect_b) {
|
|
252
|
+
if (!rect_a.from) {
|
|
253
|
+
rect_a.from = {
|
|
254
|
+
x: rect_b.from.x,
|
|
255
|
+
y: rect_b.from.y
|
|
256
|
+
};
|
|
257
|
+
} else {
|
|
258
|
+
if (rect_a.from.x > rect_b.from.x) rect_a.from.x = rect_b.from.x;
|
|
259
|
+
if (rect_a.from.y > rect_b.from.y) rect_a.from.y = rect_b.from.y;
|
|
260
|
+
}
|
|
261
|
+
if (!rect_a.to) {
|
|
262
|
+
rect_a.to = {
|
|
263
|
+
x: rect_b.to.x,
|
|
264
|
+
y: rect_b.to.y
|
|
265
|
+
};
|
|
266
|
+
} else {
|
|
267
|
+
if (rect_a.to.x < rect_b.to.x) rect_a.to.x = rect_b.to.x;
|
|
268
|
+
if (rect_a.to.y < rect_b.to.y) rect_a.to.y = rect_b.to.y;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}, {
|
|
272
|
+
key: "fittingCalSize",
|
|
273
|
+
value: function fittingCalSize(rect, child) {
|
|
274
|
+
var rect_a = rect;
|
|
275
|
+
var rect_b = this.data2rect(child);
|
|
276
|
+
this.fittingCalSizeCore(rect_a, rect_b);
|
|
277
|
+
}
|
|
278
|
+
}, {
|
|
279
|
+
key: "fitting",
|
|
280
|
+
value: function fitting(data, parent) {
|
|
281
|
+
// parent からの相対位置で補正
|
|
282
|
+
if (parent) {
|
|
283
|
+
data.position.x = parent.position.x + data.position.x;
|
|
284
|
+
data.position.y = parent.position.y + data.position.y;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// children も同様に。
|
|
288
|
+
var rect = {
|
|
289
|
+
from: null,
|
|
290
|
+
to: null
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
// children の fitting 合せて data のサイズも計測。
|
|
294
|
+
var children = data.children;
|
|
295
|
+
if (children && children.length > 0) {
|
|
296
|
+
var _iterator2 = _createForOfIteratorHelper(data.children),
|
|
297
|
+
_step2;
|
|
298
|
+
try {
|
|
299
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
300
|
+
var child = _step2.value;
|
|
301
|
+
this.fitting(child, data);
|
|
302
|
+
this.fittingCalSize(rect, child); // rect は破壊的
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// children 内容で data のサイズを補正
|
|
306
|
+
} catch (err) {
|
|
307
|
+
_iterator2.e(err);
|
|
308
|
+
} finally {
|
|
309
|
+
_iterator2.f();
|
|
310
|
+
}
|
|
311
|
+
this.fittingCalSizeCore(rect, this.data2rect(data));
|
|
312
|
+
data.rectangle.w = rect.to.x - rect.from.x;
|
|
313
|
+
data.rectangle.h = rect.to.y - rect.from.y;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}]);
|
|
317
|
+
}(Drawer);
|
package/dist/Element.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _ElementFrame = _interopRequireDefault(require("./ElementFrame"));
|
|
8
|
+
var _ElementImage = _interopRequireDefault(require("./ElementImage"));
|
|
9
|
+
var _ElementButton = _interopRequireDefault(require("./ElementButton"));
|
|
10
|
+
var _ElementModal = _interopRequireDefault(require("./ElementModal"));
|
|
11
|
+
var _ElementDialog = _interopRequireDefault(require("./ElementDialog"));
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
13
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
14
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
15
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
16
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
17
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
18
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
19
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
20
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
21
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
22
|
+
var Element = exports["default"] = /*#__PURE__*/function () {
|
|
23
|
+
function Element() {
|
|
24
|
+
_classCallCheck(this, Element);
|
|
25
|
+
this._id = 0;
|
|
26
|
+
var params = {
|
|
27
|
+
idm: this
|
|
28
|
+
};
|
|
29
|
+
this.element_classes = {
|
|
30
|
+
frame: new _ElementFrame["default"](params),
|
|
31
|
+
image: new _ElementImage["default"](params),
|
|
32
|
+
button: new _ElementButton["default"](params),
|
|
33
|
+
modal: new _ElementModal["default"](params),
|
|
34
|
+
dialog: new _ElementDialog["default"](params)
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return _createClass(Element, [{
|
|
38
|
+
key: "nextID",
|
|
39
|
+
value: function nextID() {
|
|
40
|
+
return ++this._id;
|
|
41
|
+
}
|
|
42
|
+
}, {
|
|
43
|
+
key: "elementClass",
|
|
44
|
+
value:
|
|
45
|
+
/* **************************************************************** *
|
|
46
|
+
* Element Class
|
|
47
|
+
* **************************************************************** */
|
|
48
|
+
function elementClass(data) {
|
|
49
|
+
var element_type = data.element_type;
|
|
50
|
+
var element_class = this.element_classes[data.element_type];
|
|
51
|
+
if (!element_class) throw new Error('Not supported yet. element_type=' + element_type);
|
|
52
|
+
return element_class;
|
|
53
|
+
}
|
|
54
|
+
/* **************************************************************** *
|
|
55
|
+
* Element Class
|
|
56
|
+
* **************************************************************** */
|
|
57
|
+
}, {
|
|
58
|
+
key: "makeElement",
|
|
59
|
+
value: function makeElement(core) {
|
|
60
|
+
var _this = this;
|
|
61
|
+
var element_class = this.elementClass(core);
|
|
62
|
+
var element = element_class.makeElement(core);
|
|
63
|
+
var children = core.children || [];
|
|
64
|
+
element.children = children.map(function (d) {
|
|
65
|
+
return _this.makeElement(d);
|
|
66
|
+
}).filter(function (d) {
|
|
67
|
+
return d.visible;
|
|
68
|
+
});
|
|
69
|
+
return element;
|
|
70
|
+
}
|
|
71
|
+
}, {
|
|
72
|
+
key: "mergeCore",
|
|
73
|
+
value: function mergeCore(core, element) {
|
|
74
|
+
var element_class = this.elementClass(core);
|
|
75
|
+
return element_class.merge(core, element);
|
|
76
|
+
}
|
|
77
|
+
/* **************************************************************** *
|
|
78
|
+
* Draw
|
|
79
|
+
* **************************************************************** */
|
|
80
|
+
}, {
|
|
81
|
+
key: "draw",
|
|
82
|
+
value: function draw(place, list) {
|
|
83
|
+
var _iterator = _createForOfIteratorHelper(list),
|
|
84
|
+
_step;
|
|
85
|
+
try {
|
|
86
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
87
|
+
var data = _step.value;
|
|
88
|
+
var ec = this.elementClass(data);
|
|
89
|
+
ec.draw(place, data);
|
|
90
|
+
}
|
|
91
|
+
} catch (err) {
|
|
92
|
+
_iterator.e(err);
|
|
93
|
+
} finally {
|
|
94
|
+
_iterator.f();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}]);
|
|
98
|
+
}();
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _ElementFounder2 = _interopRequireDefault(require("./ElementFounder"));
|
|
9
|
+
var _ElementLabel = _interopRequireDefault(require("./ElementLabel"));
|
|
10
|
+
var _ElementIcon = _interopRequireDefault(require("./ElementIcon"));
|
|
11
|
+
var _DataStroke = _interopRequireDefault(require("./DataStroke"));
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
13
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
14
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
15
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
16
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
17
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
18
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
19
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
20
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
21
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
22
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
23
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
24
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
25
|
+
var ElementButton = exports["default"] = /*#__PURE__*/function (_ElementFounder) {
|
|
26
|
+
function ElementButton(params) {
|
|
27
|
+
var _this;
|
|
28
|
+
_classCallCheck(this, ElementButton);
|
|
29
|
+
_this = _callSuper(this, ElementButton, ['button', params]);
|
|
30
|
+
_this.label = new _ElementLabel["default"]({
|
|
31
|
+
idm: _this.idm
|
|
32
|
+
});
|
|
33
|
+
_this.icon = new _ElementIcon["default"]({
|
|
34
|
+
idm: _this.idm
|
|
35
|
+
});
|
|
36
|
+
return _this;
|
|
37
|
+
}
|
|
38
|
+
/* **************************************************************** *
|
|
39
|
+
* Data
|
|
40
|
+
* **************************************************************** */
|
|
41
|
+
_inherits(ElementButton, _ElementFounder);
|
|
42
|
+
return _createClass(ElementButton, [{
|
|
43
|
+
key: "templateElement",
|
|
44
|
+
value: function templateElement() {
|
|
45
|
+
return this.makeTemplateElement({
|
|
46
|
+
round: 10,
|
|
47
|
+
stroke: {
|
|
48
|
+
color: '#afafb0',
|
|
49
|
+
width: 1
|
|
50
|
+
},
|
|
51
|
+
labels: [],
|
|
52
|
+
children: [],
|
|
53
|
+
icon: null
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}, {
|
|
57
|
+
key: "makeElement",
|
|
58
|
+
value: function makeElement(core, parent) {
|
|
59
|
+
var element = this.templateElement();
|
|
60
|
+
this.initElement(element, core, parent);
|
|
61
|
+
if (core.round) element.round = core.round;
|
|
62
|
+
this.fittingRectangle(element, core);
|
|
63
|
+
this.fittingPosition(element, core);
|
|
64
|
+
this.fittingBackground(element, core);
|
|
65
|
+
if (core.stroke === null) element.stroke = null;else this.fittingStroke(element, core);
|
|
66
|
+
element.labels = this.label.makeElements(core.labels);
|
|
67
|
+
element.icons = this.icon.makeElements(core.icons, element);
|
|
68
|
+
return element;
|
|
69
|
+
}
|
|
70
|
+
}, {
|
|
71
|
+
key: "mergeCore",
|
|
72
|
+
value: function mergeCore(core, element) {
|
|
73
|
+
element._core = core;
|
|
74
|
+
core._element = element;
|
|
75
|
+
}
|
|
76
|
+
/* **************************************************************** *
|
|
77
|
+
* Draw
|
|
78
|
+
* **************************************************************** */
|
|
79
|
+
}, {
|
|
80
|
+
key: "drawAdd",
|
|
81
|
+
value: function drawAdd(place, data) {
|
|
82
|
+
var _this2 = this;
|
|
83
|
+
var g = place.selectAll("g.".concat(this.name)).data([data], function (d) {
|
|
84
|
+
return d._id;
|
|
85
|
+
}).enter().append('g').attr('class', this.name).attr("transform", function (d) {
|
|
86
|
+
return "translate(".concat(d.position.x, ", ").concat(d.position.y, ")");
|
|
87
|
+
});
|
|
88
|
+
g.append('rect').attr('class', 'base').attr('width', function (d) {
|
|
89
|
+
return d.rectangle.w;
|
|
90
|
+
}).attr('height', function (d) {
|
|
91
|
+
return d.rectangle.h;
|
|
92
|
+
}).attr('rx', function (d) {
|
|
93
|
+
return d.round || 0;
|
|
94
|
+
}).attr('ry', function (d) {
|
|
95
|
+
return d.round || 0;
|
|
96
|
+
}).attr('fill', function (d) {
|
|
97
|
+
return d.background.color;
|
|
98
|
+
}).attr('stroke', function (d) {
|
|
99
|
+
return _this2.stroke(d);
|
|
100
|
+
}).attr('stroke-width', function (d) {
|
|
101
|
+
return _this2.strokeWidth(d);
|
|
102
|
+
});
|
|
103
|
+
this.icon.draw(g, data);
|
|
104
|
+
this.label.draw(g, data);
|
|
105
|
+
}
|
|
106
|
+
}, {
|
|
107
|
+
key: "drawUpdate",
|
|
108
|
+
value: function drawUpdate(place, data) {
|
|
109
|
+
place.selectAll("g.".concat(this.name)).data([data], function (d) {
|
|
110
|
+
return d._id;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}, {
|
|
114
|
+
key: "drawDelete",
|
|
115
|
+
value: function drawDelete(place, data) {
|
|
116
|
+
place.selectAll("g.".concat(this.name)).data([data], function (d) {
|
|
117
|
+
return d._id;
|
|
118
|
+
}).exit().remove();
|
|
119
|
+
}
|
|
120
|
+
}, {
|
|
121
|
+
key: "draw",
|
|
122
|
+
value: function draw(place, data) {
|
|
123
|
+
// this.drawDelete(place, data);
|
|
124
|
+
this.drawUpdate(place, data);
|
|
125
|
+
this.drawAdd(place, data);
|
|
126
|
+
}
|
|
127
|
+
}]);
|
|
128
|
+
}(_ElementFounder2["default"]);
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _ElementFounder2 = _interopRequireDefault(require("./ElementFounder"));
|
|
9
|
+
var _ElementLabel = _interopRequireDefault(require("./ElementLabel"));
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
11
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
12
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
13
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
14
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
15
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
16
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
17
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
18
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
19
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
20
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
21
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
22
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
23
|
+
var ElementDialog = exports["default"] = /*#__PURE__*/function (_ElementFounder) {
|
|
24
|
+
function ElementDialog(params) {
|
|
25
|
+
var _this;
|
|
26
|
+
_classCallCheck(this, ElementDialog);
|
|
27
|
+
_this = _callSuper(this, ElementDialog, ['dialog', params]);
|
|
28
|
+
_this.label = new _ElementLabel["default"]({
|
|
29
|
+
idm: _this.idm
|
|
30
|
+
});
|
|
31
|
+
return _this;
|
|
32
|
+
}
|
|
33
|
+
/* **************************************************************** *
|
|
34
|
+
* Data
|
|
35
|
+
* **************************************************************** */
|
|
36
|
+
_inherits(ElementDialog, _ElementFounder);
|
|
37
|
+
return _createClass(ElementDialog, [{
|
|
38
|
+
key: "templateElement",
|
|
39
|
+
value: function templateElement() {
|
|
40
|
+
return this.makeTemplateElement({
|
|
41
|
+
rectangle: null,
|
|
42
|
+
position: null,
|
|
43
|
+
background: null,
|
|
44
|
+
stroke: null,
|
|
45
|
+
labels: [],
|
|
46
|
+
children: []
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}, {
|
|
50
|
+
key: "makeElement",
|
|
51
|
+
value: function makeElement(core, parent) {
|
|
52
|
+
var element = this.templateElement();
|
|
53
|
+
this.initElement(element, core, parent);
|
|
54
|
+
this.fittingRectangle(element, core);
|
|
55
|
+
this.fittingPosition(element, core);
|
|
56
|
+
this.fittingBackground(element, core);
|
|
57
|
+
this.fittingStroke(element, core);
|
|
58
|
+
element.labels = this.label.makeElements(core.labels);
|
|
59
|
+
return element;
|
|
60
|
+
}
|
|
61
|
+
/* **************************************************************** *
|
|
62
|
+
* Draw
|
|
63
|
+
* **************************************************************** */
|
|
64
|
+
}, {
|
|
65
|
+
key: "drawAdd",
|
|
66
|
+
value: function drawAdd(place, data) {
|
|
67
|
+
var _this2 = this;
|
|
68
|
+
var g = place.selectAll("g.".concat(this.name)).data([data], function (d) {
|
|
69
|
+
return d._id;
|
|
70
|
+
}).enter().append('g').attr('class', this.name).attr("transform", function (d) {
|
|
71
|
+
return "translate(".concat(d.position.x, ", ").concat(d.position.y, ")");
|
|
72
|
+
});
|
|
73
|
+
g.append('rect').attr('class', 'base').attr('width', function (d) {
|
|
74
|
+
return d.rectangle.w;
|
|
75
|
+
}).attr('height', function (d) {
|
|
76
|
+
return d.rectangle.h;
|
|
77
|
+
}).attr('rx', function (d) {
|
|
78
|
+
return d.round || 0;
|
|
79
|
+
}).attr('ry', function (d) {
|
|
80
|
+
return d.round || 0;
|
|
81
|
+
}).attr('fill', function (d) {
|
|
82
|
+
return d.background.color;
|
|
83
|
+
}).attr('stroke', function (d) {
|
|
84
|
+
return _this2.stroke(d);
|
|
85
|
+
}).attr('stroke-width', function (d) {
|
|
86
|
+
return _this2.strokeWidth(d);
|
|
87
|
+
});
|
|
88
|
+
this.label.draw(g, data);
|
|
89
|
+
}
|
|
90
|
+
}, {
|
|
91
|
+
key: "drawUpdate",
|
|
92
|
+
value: function drawUpdate(place, data) {
|
|
93
|
+
place.selectAll("g.".concat(this.name)).data([data], function (d) {
|
|
94
|
+
return d._id;
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}, {
|
|
98
|
+
key: "drawDelete",
|
|
99
|
+
value: function drawDelete(place, data) {
|
|
100
|
+
place.selectAll("g.".concat(this.name)).data([data], function (d) {
|
|
101
|
+
return d._id;
|
|
102
|
+
}).exit().remove();
|
|
103
|
+
}
|
|
104
|
+
}, {
|
|
105
|
+
key: "draw",
|
|
106
|
+
value: function draw(place, data) {
|
|
107
|
+
// this.drawDelete(place, data);
|
|
108
|
+
this.drawUpdate(place, data);
|
|
109
|
+
this.drawAdd(place, data);
|
|
110
|
+
}
|
|
111
|
+
}]);
|
|
112
|
+
}(_ElementFounder2["default"]);
|