@yanqirenshi/d3.deployment 0.3.1 → 0.4.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/components/D3Deployment.js +3 -11
- package/dist/index.js +4 -13
- package/dist/js/Rectum.js +91 -166
- package/dist/js/datamodels/Edge.js +73 -0
- package/dist/js/datamodels/Node.js +132 -0
- package/dist/js/datamodels/Port.js +40 -0
- package/dist/js/painters/Edges.js +54 -0
- package/dist/js/{Node.js → painters/Nodes.js} +20 -136
- package/dist/js/painters/Ports.js +40 -0
- package/jest.config.js +18 -0
- package/package.json +46 -40
- package/tests/Rectum.test.js +18 -0
- package/tests/d3-stub.js +4 -0
- package/dist/js/Core.js +0 -463
- package/dist/js/Edge.js +0 -119
- package/dist/js/Port.js +0 -64
package/dist/js/Core.js
DELETED
|
@@ -1,463 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = void 0;
|
|
9
|
-
|
|
10
|
-
var _assh0le = _interopRequireWildcard(require("@yanqirenshi/assh0le"));
|
|
11
|
-
|
|
12
|
-
var _Node = _interopRequireDefault(require("./Node.js"));
|
|
13
|
-
|
|
14
|
-
var _Edge = _interopRequireDefault(require("./Edge.js"));
|
|
15
|
-
|
|
16
|
-
var _Port = _interopRequireDefault(require("./Port.js"));
|
|
17
|
-
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
-
|
|
20
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
21
|
-
|
|
22
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
-
|
|
24
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, 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 normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
25
|
-
|
|
26
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
27
|
-
|
|
28
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
29
|
-
|
|
30
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
31
|
-
|
|
32
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
33
|
-
|
|
34
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
35
|
-
|
|
36
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
37
|
-
|
|
38
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
39
|
-
|
|
40
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
41
|
-
|
|
42
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
43
|
-
|
|
44
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
45
|
-
|
|
46
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
47
|
-
|
|
48
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
49
|
-
|
|
50
|
-
var Core = /*#__PURE__*/function (_Asshole) {
|
|
51
|
-
_inherits(Core, _Asshole);
|
|
52
|
-
|
|
53
|
-
var _super = _createSuper(Core);
|
|
54
|
-
|
|
55
|
-
function Core(params) {
|
|
56
|
-
var _this;
|
|
57
|
-
|
|
58
|
-
_classCallCheck(this, Core);
|
|
59
|
-
|
|
60
|
-
_this = _super.call(this, params);
|
|
61
|
-
_this._nodes = {
|
|
62
|
-
list: [],
|
|
63
|
-
ht: {},
|
|
64
|
-
tree: []
|
|
65
|
-
};
|
|
66
|
-
_this._edges = {
|
|
67
|
-
list: [],
|
|
68
|
-
ht: {}
|
|
69
|
-
};
|
|
70
|
-
_this._ports = {
|
|
71
|
-
list: [],
|
|
72
|
-
ht: {}
|
|
73
|
-
};
|
|
74
|
-
_this.id_counter = 1;
|
|
75
|
-
_this._calculator = new _assh0le.Geometry();
|
|
76
|
-
_this._node = new _Node["default"]();
|
|
77
|
-
_this._port = new _Port["default"]();
|
|
78
|
-
_this._edge = new _Edge["default"]();
|
|
79
|
-
_this._painter = {
|
|
80
|
-
NODE: _this._node,
|
|
81
|
-
EDGE: _this._edge,
|
|
82
|
-
PORT: _this._port
|
|
83
|
-
};
|
|
84
|
-
return _this;
|
|
85
|
-
}
|
|
86
|
-
/* **************************** */
|
|
87
|
-
|
|
88
|
-
/* Overwrite Asshole function */
|
|
89
|
-
|
|
90
|
-
/* **************************** */
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
_createClass(Core, [{
|
|
94
|
-
key: "makeSvgAfter",
|
|
95
|
-
value: function makeSvgAfter() {
|
|
96
|
-
this._node.addFilterShadow(this.getSvgElement());
|
|
97
|
-
}
|
|
98
|
-
/* ******** */
|
|
99
|
-
|
|
100
|
-
/* DATA */
|
|
101
|
-
|
|
102
|
-
/* ******** */
|
|
103
|
-
|
|
104
|
-
}, {
|
|
105
|
-
key: "data2pool",
|
|
106
|
-
value: function data2pool(trees, pool) {
|
|
107
|
-
var _iterator = _createForOfIteratorHelper(trees),
|
|
108
|
-
_step;
|
|
109
|
-
|
|
110
|
-
try {
|
|
111
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
112
|
-
var tree = _step.value;
|
|
113
|
-
var id = tree._id;
|
|
114
|
-
pool.ht[id] = tree;
|
|
115
|
-
pool.list.push(tree);
|
|
116
|
-
if (tree.children) this.data2pool(tree.children, pool);
|
|
117
|
-
}
|
|
118
|
-
} catch (err) {
|
|
119
|
-
_iterator.e(err);
|
|
120
|
-
} finally {
|
|
121
|
-
_iterator.f();
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return pool;
|
|
125
|
-
}
|
|
126
|
-
}, {
|
|
127
|
-
key: "importNodes",
|
|
128
|
-
value: function importNodes(nodes) {
|
|
129
|
-
var node = this._node;
|
|
130
|
-
var tmp = (nodes || []).map(function (d) {
|
|
131
|
-
return node.normalize(d);
|
|
132
|
-
});
|
|
133
|
-
var h = new _assh0le.Hierarchy();
|
|
134
|
-
|
|
135
|
-
var _iterator2 = _createForOfIteratorHelper(tmp),
|
|
136
|
-
_step2;
|
|
137
|
-
|
|
138
|
-
try {
|
|
139
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
140
|
-
var data = _step2.value;
|
|
141
|
-
h.fitting(data);
|
|
142
|
-
}
|
|
143
|
-
} catch (err) {
|
|
144
|
-
_iterator2.e(err);
|
|
145
|
-
} finally {
|
|
146
|
-
_iterator2.f();
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
var pool = this.data2pool(tmp, this._nodes);
|
|
150
|
-
pool.tree = tmp;
|
|
151
|
-
return pool;
|
|
152
|
-
}
|
|
153
|
-
}, {
|
|
154
|
-
key: "importEdges",
|
|
155
|
-
value: function importEdges(edges) {
|
|
156
|
-
var _this2 = this;
|
|
157
|
-
|
|
158
|
-
var edge = this._edge;
|
|
159
|
-
var id = 1;
|
|
160
|
-
var tmp = (edges || []).map(function (d) {
|
|
161
|
-
d._id = _this2.id_counter++;
|
|
162
|
-
return edge.normalize(d, id++);
|
|
163
|
-
});
|
|
164
|
-
return this.data2pool(tmp, this._edges);
|
|
165
|
-
}
|
|
166
|
-
}, {
|
|
167
|
-
key: "makePort",
|
|
168
|
-
value: function makePort(type, node, edge) {
|
|
169
|
-
var port = this._port.normalize({
|
|
170
|
-
node: node,
|
|
171
|
-
edge: edge,
|
|
172
|
-
_id: this.id_counter++,
|
|
173
|
-
_class: 'PORT',
|
|
174
|
-
_type: type
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
this._ports.list.push(port);
|
|
178
|
-
|
|
179
|
-
this._ports.ht[port._id] = port;
|
|
180
|
-
return port;
|
|
181
|
-
}
|
|
182
|
-
}, {
|
|
183
|
-
key: "makePorts",
|
|
184
|
-
value: function makePorts(edges) {
|
|
185
|
-
var nodes = this._nodes.ht;
|
|
186
|
-
|
|
187
|
-
var _iterator3 = _createForOfIteratorHelper(edges),
|
|
188
|
-
_step3;
|
|
189
|
-
|
|
190
|
-
try {
|
|
191
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
192
|
-
var edge = _step3.value;
|
|
193
|
-
var node_from = nodes[edge.from.id];
|
|
194
|
-
var node_to = nodes[edge.to.id];
|
|
195
|
-
edge.from.node = node_from;
|
|
196
|
-
edge.to.node = node_to;
|
|
197
|
-
edge.from.port = this.makePort('FROM', edge.from.node, edge);
|
|
198
|
-
edge.to.port = this.makePort('TO', edge.to.node, edge);
|
|
199
|
-
}
|
|
200
|
-
} catch (err) {
|
|
201
|
-
_iterator3.e(err);
|
|
202
|
-
} finally {
|
|
203
|
-
_iterator3.f();
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}, {
|
|
207
|
-
key: "getPortLineFrom",
|
|
208
|
-
value: function getPortLineFrom(node) {
|
|
209
|
-
return {
|
|
210
|
-
x: Math.floor(node._size.w / 2) + node._position.x,
|
|
211
|
-
y: Math.floor(node._size.h / 2) + node._position.y
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
}, {
|
|
215
|
-
key: "getPortLineToPoint",
|
|
216
|
-
value: function getPortLineToPoint(node) {
|
|
217
|
-
var w = node._size.w;
|
|
218
|
-
var h = node._size.h;
|
|
219
|
-
return {
|
|
220
|
-
x: 0,
|
|
221
|
-
y: Math.floor(Math.sqrt(w * w + h * h))
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
}, {
|
|
225
|
-
key: "getPortLineTo",
|
|
226
|
-
value: function getPortLineTo(degree, node) {
|
|
227
|
-
var point = this.getPortLineToPoint(node);
|
|
228
|
-
var x = point.x;
|
|
229
|
-
var y = point.y;
|
|
230
|
-
var degree_tmp;
|
|
231
|
-
if (degree === 0) degree_tmp = degree;else if (!degree) degree_tmp = 90;else degree_tmp = degree % 360;
|
|
232
|
-
|
|
233
|
-
var radian = this._calculator.deg2rad(degree_tmp);
|
|
234
|
-
|
|
235
|
-
var cos = Math.cos(radian);
|
|
236
|
-
var sin = Math.sin(radian);
|
|
237
|
-
return {
|
|
238
|
-
x: Math.floor(x * cos - y * sin),
|
|
239
|
-
y: Math.floor(x * sin + y * cos)
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Port の位置を計算するため、Port と Nodeの中心の直線を算出する。
|
|
244
|
-
*
|
|
245
|
-
* @param {object} port Line を算出する対象の Port。 TODO: これ、つこてなくない?
|
|
246
|
-
* @param {number} port_pos_degree Port の位置。
|
|
247
|
-
* @param {object} node port の Node。 算出した Line の位置を補正するための Node
|
|
248
|
-
*/
|
|
249
|
-
|
|
250
|
-
}, {
|
|
251
|
-
key: "makePortLine",
|
|
252
|
-
value: function makePortLine(degree, node) {
|
|
253
|
-
var from = this.getPortLineFrom(node);
|
|
254
|
-
var to = this.getPortLineTo(degree, node);
|
|
255
|
-
return {
|
|
256
|
-
from: {
|
|
257
|
-
x: from.x,
|
|
258
|
-
y: from.y
|
|
259
|
-
},
|
|
260
|
-
to: {
|
|
261
|
-
x: to.x + from.x,
|
|
262
|
-
y: to.y + from.y
|
|
263
|
-
}
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
}, {
|
|
267
|
-
key: "positioningPort",
|
|
268
|
-
value: function positioningPort(port, port_pos_degree, node) {
|
|
269
|
-
var calc = this._calculator;
|
|
270
|
-
|
|
271
|
-
var lines_entity = this._node.getFourSides(node);
|
|
272
|
-
|
|
273
|
-
var line_port = this.makePortLine(port_pos_degree, node);
|
|
274
|
-
return calc.getCrossPoint(lines_entity, line_port) || {
|
|
275
|
-
x: 0,
|
|
276
|
-
y: 0
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
}, {
|
|
280
|
-
key: "fittingPort",
|
|
281
|
-
value: function fittingPort(port) {
|
|
282
|
-
var port_pos;
|
|
283
|
-
if (port._type === 'FROM') port_pos = port.edge._core.from.position;else port_pos = port.edge._core.to.position;
|
|
284
|
-
var position = this.positioningPort(port, port_pos, port.node);
|
|
285
|
-
port.position = position;
|
|
286
|
-
}
|
|
287
|
-
}, {
|
|
288
|
-
key: "fittingEdge",
|
|
289
|
-
value: function fittingEdge(edge) {
|
|
290
|
-
edge.from.position = {
|
|
291
|
-
x: edge.from.port.position.x,
|
|
292
|
-
y: edge.from.port.position.y
|
|
293
|
-
};
|
|
294
|
-
edge.to.position = {
|
|
295
|
-
x: edge.to.port.position.x,
|
|
296
|
-
y: edge.to.port.position.y
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* data を元に描画用のデータに変換する。
|
|
301
|
-
* 変換したデータを保管する。
|
|
302
|
-
* data.edge を元に port のデータも作成する。
|
|
303
|
-
* @param {object} data { node: [], edges: [] }
|
|
304
|
-
*/
|
|
305
|
-
|
|
306
|
-
}, {
|
|
307
|
-
key: "data",
|
|
308
|
-
value: function data(_data) {
|
|
309
|
-
if (arguments.length === 0) return this._nodes.list;
|
|
310
|
-
this.importNodes(_data.nodes);
|
|
311
|
-
this.importEdges(_data.edges);
|
|
312
|
-
this.makePorts(this._edges.list); // fitting ports
|
|
313
|
-
|
|
314
|
-
var _iterator4 = _createForOfIteratorHelper(this._ports.list),
|
|
315
|
-
_step4;
|
|
316
|
-
|
|
317
|
-
try {
|
|
318
|
-
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
319
|
-
var port = _step4.value;
|
|
320
|
-
this.fittingPort(port);
|
|
321
|
-
} // fitting edges
|
|
322
|
-
|
|
323
|
-
} catch (err) {
|
|
324
|
-
_iterator4.e(err);
|
|
325
|
-
} finally {
|
|
326
|
-
_iterator4.f();
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
var _iterator5 = _createForOfIteratorHelper(this._edges.list),
|
|
330
|
-
_step5;
|
|
331
|
-
|
|
332
|
-
try {
|
|
333
|
-
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
334
|
-
var edge = _step5.value;
|
|
335
|
-
this.fittingEdge(edge);
|
|
336
|
-
}
|
|
337
|
-
} catch (err) {
|
|
338
|
-
_iterator5.e(err);
|
|
339
|
-
} finally {
|
|
340
|
-
_iterator5.f();
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
this.draw();
|
|
344
|
-
return this;
|
|
345
|
-
}
|
|
346
|
-
}, {
|
|
347
|
-
key: "elementDataList",
|
|
348
|
-
value: function elementDataList() {
|
|
349
|
-
return [].concat(this._nodes.list, this._edges.list, this._ports.list);
|
|
350
|
-
} ///// ////////////////////////////////////////////////////////////////
|
|
351
|
-
///// Flatten
|
|
352
|
-
///// ////////////////////////////////////////////////////////////////
|
|
353
|
-
|
|
354
|
-
}, {
|
|
355
|
-
key: "flattenCore",
|
|
356
|
-
value: function flattenCore(data, lev) {
|
|
357
|
-
var _this3 = this;
|
|
358
|
-
|
|
359
|
-
var out = [data];
|
|
360
|
-
var children = data.children.reduce(function (acc, val) {
|
|
361
|
-
val._level = lev;
|
|
362
|
-
return acc.concat(_this3.flattenCore(val, lev * 10));
|
|
363
|
-
}, []);
|
|
364
|
-
return out.concat(children);
|
|
365
|
-
}
|
|
366
|
-
}, {
|
|
367
|
-
key: "flatten",
|
|
368
|
-
value: function flatten() {
|
|
369
|
-
var _this4 = this;
|
|
370
|
-
|
|
371
|
-
var data = this._nodes.tree;
|
|
372
|
-
if (!data) return [];
|
|
373
|
-
var lev = 10;
|
|
374
|
-
return data.reduce(function (acc, val) {
|
|
375
|
-
val._level = lev;
|
|
376
|
-
return acc.concat(_this4.flattenCore(val, lev * 10));
|
|
377
|
-
}, []);
|
|
378
|
-
}
|
|
379
|
-
}, {
|
|
380
|
-
key: "getDrawElements",
|
|
381
|
-
value: function getDrawElements() {
|
|
382
|
-
var out = this.flatten(); // port に level を設定
|
|
383
|
-
|
|
384
|
-
var _iterator6 = _createForOfIteratorHelper(this._ports.list),
|
|
385
|
-
_step6;
|
|
386
|
-
|
|
387
|
-
try {
|
|
388
|
-
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
389
|
-
var port = _step6.value;
|
|
390
|
-
port._level = port.node._level;
|
|
391
|
-
out.push(port);
|
|
392
|
-
} // edge に level を設定
|
|
393
|
-
|
|
394
|
-
} catch (err) {
|
|
395
|
-
_iterator6.e(err);
|
|
396
|
-
} finally {
|
|
397
|
-
_iterator6.f();
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
var _iterator7 = _createForOfIteratorHelper(this._edges.list),
|
|
401
|
-
_step7;
|
|
402
|
-
|
|
403
|
-
try {
|
|
404
|
-
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
405
|
-
var edge = _step7.value;
|
|
406
|
-
var lev_from = edge.from.port._level;
|
|
407
|
-
var lev_to = edge.to.port._level;
|
|
408
|
-
if (lev_from > lev_to) edge._level = lev_from - 1;else edge._level = lev_to - 1;
|
|
409
|
-
out.push(edge);
|
|
410
|
-
} // ソートして返す
|
|
411
|
-
|
|
412
|
-
} catch (err) {
|
|
413
|
-
_iterator7.e(err);
|
|
414
|
-
} finally {
|
|
415
|
-
_iterator7.f();
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
return out.sort(function (a, b) {
|
|
419
|
-
return a._level < b._level ? -1 : 1;
|
|
420
|
-
});
|
|
421
|
-
} ///// ////////////////////////////////////////////////////////////////
|
|
422
|
-
///// Draw
|
|
423
|
-
///// ////////////////////////////////////////////////////////////////
|
|
424
|
-
|
|
425
|
-
}, {
|
|
426
|
-
key: "painter",
|
|
427
|
-
value: function painter(element_class) {
|
|
428
|
-
var painter = this._painter[element_class];
|
|
429
|
-
return painter || null;
|
|
430
|
-
}
|
|
431
|
-
}, {
|
|
432
|
-
key: "drawElement",
|
|
433
|
-
value: function drawElement(place, element) {
|
|
434
|
-
var painter = this.painter(element._class);
|
|
435
|
-
if (!painter) return;
|
|
436
|
-
painter.draw(place, element);
|
|
437
|
-
}
|
|
438
|
-
}, {
|
|
439
|
-
key: "draw",
|
|
440
|
-
value: function draw() {
|
|
441
|
-
var place = this.getLayerForeground();
|
|
442
|
-
var elements = this.getDrawElements();
|
|
443
|
-
|
|
444
|
-
var _iterator8 = _createForOfIteratorHelper(elements),
|
|
445
|
-
_step8;
|
|
446
|
-
|
|
447
|
-
try {
|
|
448
|
-
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
449
|
-
var element = _step8.value;
|
|
450
|
-
this.drawElement(place, element);
|
|
451
|
-
}
|
|
452
|
-
} catch (err) {
|
|
453
|
-
_iterator8.e(err);
|
|
454
|
-
} finally {
|
|
455
|
-
_iterator8.f();
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
}]);
|
|
459
|
-
|
|
460
|
-
return Core;
|
|
461
|
-
}(_assh0le["default"]);
|
|
462
|
-
|
|
463
|
-
exports["default"] = Core;
|
package/dist/js/Edge.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = void 0;
|
|
9
|
-
|
|
10
|
-
var d3 = _interopRequireWildcard(require("d3"));
|
|
11
|
-
|
|
12
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
13
|
-
|
|
14
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
-
|
|
16
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
17
|
-
|
|
18
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
19
|
-
|
|
20
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
21
|
-
|
|
22
|
-
var Edge = /*#__PURE__*/function () {
|
|
23
|
-
function Edge() {
|
|
24
|
-
_classCallCheck(this, Edge);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
_createClass(Edge, [{
|
|
28
|
-
key: "dataTemplate",
|
|
29
|
-
value: function dataTemplate() {
|
|
30
|
-
return {
|
|
31
|
-
from: {
|
|
32
|
-
id: null,
|
|
33
|
-
port: null,
|
|
34
|
-
node: null,
|
|
35
|
-
position: {
|
|
36
|
-
x: 0,
|
|
37
|
-
y: 0
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
to: {
|
|
41
|
-
id: null,
|
|
42
|
-
port: null,
|
|
43
|
-
node: null,
|
|
44
|
-
position: {
|
|
45
|
-
x: 0,
|
|
46
|
-
y: 0
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
stroke: {
|
|
50
|
-
color: '#333',
|
|
51
|
-
width: 1.5,
|
|
52
|
-
marker: {
|
|
53
|
-
start: false,
|
|
54
|
-
end: true
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
_id: null,
|
|
58
|
-
_core: null,
|
|
59
|
-
_class: 'EDGE'
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
}, {
|
|
63
|
-
key: "normalize",
|
|
64
|
-
value: function normalize(data) {
|
|
65
|
-
var new_data = this.dataTemplate();
|
|
66
|
-
new_data._core = data;
|
|
67
|
-
if (data.id) new_data._id = data.id;
|
|
68
|
-
if (data.from.id) new_data.from.id = data.from.id;
|
|
69
|
-
if (data.to.id) new_data.to.id = data.to.id;
|
|
70
|
-
|
|
71
|
-
if (data.stroke) {
|
|
72
|
-
if (data.stroke.color) new_data.stroke.color = data.stroke.color;
|
|
73
|
-
if (data.stroke.width) new_data.stroke.width = data.stroke.width;
|
|
74
|
-
if (data.stroke.marker) new_data.stroke.marker = data.stroke.marker;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
data._edge = new_data;
|
|
78
|
-
return new_data;
|
|
79
|
-
} ///// ////////////////////////////////////////////////////////////////
|
|
80
|
-
///// Draw
|
|
81
|
-
///// ////////////////////////////////////////////////////////////////
|
|
82
|
-
|
|
83
|
-
}, {
|
|
84
|
-
key: "draw",
|
|
85
|
-
value: function draw(place, data) {
|
|
86
|
-
var lineData = [{
|
|
87
|
-
"x": data.from.position.x,
|
|
88
|
-
"y": data.from.position.y,
|
|
89
|
-
stroke: data.stroke
|
|
90
|
-
}, {
|
|
91
|
-
"x": data.to.position.x,
|
|
92
|
-
"y": data.to.position.y
|
|
93
|
-
}];
|
|
94
|
-
var lineFunction = d3.line().x(function (d) {
|
|
95
|
-
return d.x;
|
|
96
|
-
}).y(function (d) {
|
|
97
|
-
return d.y;
|
|
98
|
-
});
|
|
99
|
-
var path = place.append("path").datum(lineData).attr("fill", "none").attr("d", lineFunction).attr('marker-end', function (d) {
|
|
100
|
-
if (!d[0].stroke.marker || d[0].stroke.marker.end) return "url(#edge-arrow)";
|
|
101
|
-
return null;
|
|
102
|
-
}).style('stroke-linecap', 'round').style('fill', function (d) {
|
|
103
|
-
return d[0].stroke.color;
|
|
104
|
-
}).style("stroke", function (d) {
|
|
105
|
-
return d[0].stroke.color;
|
|
106
|
-
}).style("stroke-width", function (d) {
|
|
107
|
-
return d[0].stroke.width;
|
|
108
|
-
});
|
|
109
|
-
var len = path.node().getTotalLength();
|
|
110
|
-
var margin = 12;
|
|
111
|
-
var t = len - margin * 2;
|
|
112
|
-
path.attr('stroke-dasharray', "0 ".concat(margin, " ").concat(t, " ").concat(margin)).attr('stroke-dashoffset', 0);
|
|
113
|
-
}
|
|
114
|
-
}]);
|
|
115
|
-
|
|
116
|
-
return Edge;
|
|
117
|
-
}();
|
|
118
|
-
|
|
119
|
-
exports["default"] = Edge;
|
package/dist/js/Port.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
-
|
|
10
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
11
|
-
|
|
12
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
13
|
-
|
|
14
|
-
var Port = /*#__PURE__*/function () {
|
|
15
|
-
function Port() {
|
|
16
|
-
_classCallCheck(this, Port);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
_createClass(Port, [{
|
|
20
|
-
key: "dataTemplate",
|
|
21
|
-
value: function dataTemplate() {
|
|
22
|
-
return {
|
|
23
|
-
node: null,
|
|
24
|
-
edge: null,
|
|
25
|
-
_id: null,
|
|
26
|
-
_core: null,
|
|
27
|
-
_class: 'PORT'
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
}, {
|
|
31
|
-
key: "normalize",
|
|
32
|
-
value: function normalize(data) {
|
|
33
|
-
var tmp = this.dataTemplate();
|
|
34
|
-
tmp._core = data;
|
|
35
|
-
return data;
|
|
36
|
-
} ///// ////////////////////////////////////////////////////////////////
|
|
37
|
-
///// Draw
|
|
38
|
-
///// ////////////////////////////////////////////////////////////////
|
|
39
|
-
|
|
40
|
-
}, {
|
|
41
|
-
key: "draw",
|
|
42
|
-
value: function draw(place, data) {
|
|
43
|
-
place.selectAll('circle.port').data([data], function (d) {
|
|
44
|
-
return d._id;
|
|
45
|
-
}).enter().append('circle').attr('class', 'port').attr('cx', function (d) {
|
|
46
|
-
return d.position.x;
|
|
47
|
-
}).attr('cy', function (d) {
|
|
48
|
-
return d.position.y;
|
|
49
|
-
}).attr('r', function (d) {
|
|
50
|
-
return 6;
|
|
51
|
-
}).attr('level', function (d) {
|
|
52
|
-
return d._level;
|
|
53
|
-
}).style('fill', function (d) {
|
|
54
|
-
return '#fff';
|
|
55
|
-
}).style("stroke", function (d) {
|
|
56
|
-
return '#888';
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}]);
|
|
60
|
-
|
|
61
|
-
return Port;
|
|
62
|
-
}();
|
|
63
|
-
|
|
64
|
-
exports["default"] = Port;
|