@yanqirenshi/d3.deployment 0.3.0 → 0.4.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/dist/components/D3Deployment.js +3 -11
- package/dist/index.js +4 -13
- package/dist/js/Rectum.js +82 -157
- 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/Edge.js +54 -0
- package/dist/js/{Node.js → painters/Node.js} +18 -134
- package/dist/js/painters/Port.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
|
@@ -1,22 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
4
|
-
|
|
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); }
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = D3Deployment;
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
9
|
var _assh0le = _interopRequireDefault(require("@yanqirenshi/assh0le"));
|
|
13
|
-
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
17
|
-
|
|
18
|
-
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; }
|
|
19
|
-
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
11
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
20
12
|
function D3Deployment(props) {
|
|
21
13
|
var rectum = props.rectum;
|
|
22
14
|
return /*#__PURE__*/_react["default"].createElement(_assh0le["default"], {
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
4
|
-
|
|
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); }
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -12,17 +11,9 @@ Object.defineProperty(exports, "Rectum", {
|
|
|
12
11
|
}
|
|
13
12
|
});
|
|
14
13
|
exports["default"] = void 0;
|
|
15
|
-
|
|
16
14
|
var _D3Deployment = _interopRequireWildcard(require("./components/D3Deployment.js"));
|
|
17
|
-
|
|
18
15
|
var _Rectum = _interopRequireDefault(require("./js/Rectum.js"));
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
23
|
-
|
|
24
|
-
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; }
|
|
25
|
-
|
|
16
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
17
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
26
18
|
// export { Camera };
|
|
27
|
-
var _default = _D3Deployment["default"];
|
|
28
|
-
exports["default"] = _default;
|
|
19
|
+
var _default = exports["default"] = _D3Deployment["default"];
|
package/dist/js/Rectum.js
CHANGED
|
@@ -1,83 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
4
|
-
|
|
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); }
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
8
|
var _assh0le = require("@yanqirenshi/assh0le");
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
|
|
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 Rectum = /*#__PURE__*/function (_Colon) {
|
|
51
|
-
_inherits(Rectum, _Colon);
|
|
52
|
-
|
|
53
|
-
var _super = _createSuper(Rectum);
|
|
54
|
-
|
|
9
|
+
var _Node = _interopRequireDefault(require("./datamodels/Node.js"));
|
|
10
|
+
var _Edge = _interopRequireDefault(require("./datamodels/Edge.js"));
|
|
11
|
+
var _Port = _interopRequireDefault(require("./datamodels/Port.js"));
|
|
12
|
+
var _Node2 = _interopRequireDefault(require("./painters/Node.js"));
|
|
13
|
+
var _Edge2 = _interopRequireDefault(require("./painters/Edge.js"));
|
|
14
|
+
var _Port2 = _interopRequireDefault(require("./painters/Port.js"));
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
16
|
+
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; } } }; }
|
|
17
|
+
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; } }
|
|
18
|
+
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; }
|
|
19
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
20
|
+
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); } }
|
|
21
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
22
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
23
|
+
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); }
|
|
24
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
25
|
+
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); }
|
|
26
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
27
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
28
|
+
function _superPropGet(t, o, e, r) { var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
|
|
29
|
+
function _get() { return _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) { var p = _superPropBase(e, t); if (p) { var n = Object.getOwnPropertyDescriptor(p, t); return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value; } }, _get.apply(null, arguments); }
|
|
30
|
+
function _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); return t; }
|
|
31
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
32
|
+
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); }
|
|
33
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
34
|
+
var Rectum = exports["default"] = /*#__PURE__*/function (_Colon) {
|
|
55
35
|
function Rectum(params) {
|
|
56
36
|
var _this;
|
|
57
|
-
|
|
58
37
|
_classCallCheck(this, Rectum);
|
|
59
|
-
|
|
60
|
-
_this = _super.call(this, params);
|
|
38
|
+
_this = _callSuper(this, Rectum, [params]);
|
|
61
39
|
_this.id_counter = 1;
|
|
40
|
+
|
|
41
|
+
// データクラス(正規化・幾何)
|
|
62
42
|
_this._calculator = new _assh0le.Geometry();
|
|
63
43
|
_this._node = new _Node["default"]();
|
|
64
44
|
_this._port = new _Port["default"]();
|
|
65
45
|
_this._edge = new _Edge["default"]();
|
|
46
|
+
|
|
47
|
+
// 描画クラス(ペインタ)
|
|
66
48
|
_this._painter = {
|
|
67
|
-
NODE:
|
|
68
|
-
EDGE:
|
|
69
|
-
PORT:
|
|
49
|
+
NODE: new _Node2["default"](),
|
|
50
|
+
EDGE: new _Edge2["default"](),
|
|
51
|
+
PORT: new _Port2["default"]()
|
|
70
52
|
};
|
|
71
53
|
return _this;
|
|
72
54
|
}
|
|
73
55
|
/* ******** */
|
|
74
|
-
|
|
75
56
|
/* Getter */
|
|
76
|
-
|
|
77
57
|
/* ******** */
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
_createClass(Rectum, [{
|
|
58
|
+
_inherits(Rectum, _Colon);
|
|
59
|
+
return _createClass(Rectum, [{
|
|
81
60
|
key: "node",
|
|
82
61
|
value: function node() {
|
|
83
62
|
return this._node;
|
|
@@ -93,28 +72,21 @@ var Rectum = /*#__PURE__*/function (_Colon) {
|
|
|
93
72
|
return this._edge;
|
|
94
73
|
}
|
|
95
74
|
/* **************************** */
|
|
96
|
-
|
|
97
75
|
/* Overwrite Asshole function */
|
|
98
|
-
|
|
99
76
|
/* **************************** */
|
|
100
|
-
|
|
101
77
|
}, {
|
|
102
78
|
key: "selector_setAfter",
|
|
103
79
|
value: function selector_setAfter() {
|
|
104
|
-
this.
|
|
80
|
+
this._painter.NODE.addFilterShadow(this.d3Element());
|
|
105
81
|
}
|
|
106
82
|
/* ******** */
|
|
107
|
-
|
|
108
83
|
/* DATA */
|
|
109
|
-
|
|
110
84
|
/* ******** */
|
|
111
|
-
|
|
112
85
|
}, {
|
|
113
86
|
key: "data2pool",
|
|
114
87
|
value: function data2pool(trees, pool) {
|
|
115
88
|
var _iterator = _createForOfIteratorHelper(trees),
|
|
116
|
-
|
|
117
|
-
|
|
89
|
+
_step;
|
|
118
90
|
try {
|
|
119
91
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
120
92
|
var tree = _step.value;
|
|
@@ -128,7 +100,6 @@ var Rectum = /*#__PURE__*/function (_Colon) {
|
|
|
128
100
|
} finally {
|
|
129
101
|
_iterator.f();
|
|
130
102
|
}
|
|
131
|
-
|
|
132
103
|
return pool;
|
|
133
104
|
}
|
|
134
105
|
}, {
|
|
@@ -139,10 +110,8 @@ var Rectum = /*#__PURE__*/function (_Colon) {
|
|
|
139
110
|
return node.normalize(d);
|
|
140
111
|
});
|
|
141
112
|
var h = new _assh0le.Hierarchy();
|
|
142
|
-
|
|
143
113
|
var _iterator2 = _createForOfIteratorHelper(tmp),
|
|
144
|
-
|
|
145
|
-
|
|
114
|
+
_step2;
|
|
146
115
|
try {
|
|
147
116
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
148
117
|
var data = _step2.value;
|
|
@@ -153,7 +122,6 @@ var Rectum = /*#__PURE__*/function (_Colon) {
|
|
|
153
122
|
} finally {
|
|
154
123
|
_iterator2.f();
|
|
155
124
|
}
|
|
156
|
-
|
|
157
125
|
var pool = this.data2pool(tmp, {
|
|
158
126
|
list: [],
|
|
159
127
|
ht: {},
|
|
@@ -166,7 +134,6 @@ var Rectum = /*#__PURE__*/function (_Colon) {
|
|
|
166
134
|
key: "makeEdges",
|
|
167
135
|
value: function makeEdges(edges) {
|
|
168
136
|
var _this2 = this;
|
|
169
|
-
|
|
170
137
|
var edge = this.edge();
|
|
171
138
|
var id = 1;
|
|
172
139
|
var tmp = (edges || []).map(function (d) {
|
|
@@ -199,10 +166,8 @@ var Rectum = /*#__PURE__*/function (_Colon) {
|
|
|
199
166
|
list: [],
|
|
200
167
|
ht: {}
|
|
201
168
|
};
|
|
202
|
-
|
|
203
169
|
var _iterator3 = _createForOfIteratorHelper(edges),
|
|
204
|
-
|
|
205
|
-
|
|
170
|
+
_step3;
|
|
206
171
|
try {
|
|
207
172
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
208
173
|
var edge = _step3.value;
|
|
@@ -218,66 +183,38 @@ var Rectum = /*#__PURE__*/function (_Colon) {
|
|
|
218
183
|
} finally {
|
|
219
184
|
_iterator3.f();
|
|
220
185
|
}
|
|
221
|
-
|
|
222
186
|
return ports;
|
|
223
187
|
}
|
|
224
|
-
}, {
|
|
225
|
-
key: "getPortLineFrom",
|
|
226
|
-
value: function getPortLineFrom(node) {
|
|
227
|
-
return {
|
|
228
|
-
x: Math.floor(node._size.w / 2) + node._position.x,
|
|
229
|
-
y: Math.floor(node._size.h / 2) + node._position.y
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
}, {
|
|
233
|
-
key: "getPortLineToPoint",
|
|
234
|
-
value: function getPortLineToPoint(node) {
|
|
235
|
-
var w = node._size.w;
|
|
236
|
-
var h = node._size.h;
|
|
237
|
-
return {
|
|
238
|
-
x: 0,
|
|
239
|
-
y: Math.floor(Math.sqrt(w * w + h * h))
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
}, {
|
|
243
|
-
key: "getPortLineTo",
|
|
244
|
-
value: function getPortLineTo(degree, node) {
|
|
245
|
-
var point = this.getPortLineToPoint(node);
|
|
246
|
-
var x = point.x;
|
|
247
|
-
var y = point.y;
|
|
248
|
-
var degree_tmp;
|
|
249
|
-
if (degree === 0) degree_tmp = degree;else if (!degree) degree_tmp = 90;else degree_tmp = degree % 360;
|
|
250
|
-
|
|
251
|
-
var radian = this._calculator.deg2rad(degree_tmp);
|
|
252
|
-
|
|
253
|
-
var cos = Math.cos(radian);
|
|
254
|
-
var sin = Math.sin(radian);
|
|
255
|
-
return {
|
|
256
|
-
x: Math.floor(x * cos - y * sin),
|
|
257
|
-
y: Math.floor(x * sin + y * cos)
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
188
|
/**
|
|
261
189
|
* Port の位置を計算するため、Port と Nodeの中心の直線を算出する。
|
|
262
190
|
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
191
|
+
* 直線の構築は共有版(assh0le の Geometry.getPortLine)に委譲する。
|
|
192
|
+
* 共有版は box ローカル座標で返すため、node の絶対位置をオフセットして返す
|
|
193
|
+
* (旧インライン実装と数学的に等価)。
|
|
194
|
+
*
|
|
195
|
+
* @param {number} degree Port の位置(角度)。
|
|
265
196
|
* @param {object} node port の Node。 算出した Line の位置を補正するための Node
|
|
266
197
|
*/
|
|
267
|
-
|
|
268
198
|
}, {
|
|
269
199
|
key: "makePortLine",
|
|
270
200
|
value: function makePortLine(degree, node) {
|
|
271
|
-
var
|
|
272
|
-
|
|
201
|
+
var rect = {
|
|
202
|
+
size: {
|
|
203
|
+
w: node._size.w,
|
|
204
|
+
h: node._size.h
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
var line = this._calculator.getPortLine(degree, rect);
|
|
208
|
+
var px = node._position.x;
|
|
209
|
+
var py = node._position.y;
|
|
273
210
|
return {
|
|
274
211
|
from: {
|
|
275
|
-
x: from.x,
|
|
276
|
-
y: from.y
|
|
212
|
+
x: line.from.x + px,
|
|
213
|
+
y: line.from.y + py
|
|
277
214
|
},
|
|
278
215
|
to: {
|
|
279
|
-
x: to.x +
|
|
280
|
-
y: to.y +
|
|
216
|
+
x: line.to.x + px,
|
|
217
|
+
y: line.to.y + py
|
|
281
218
|
}
|
|
282
219
|
};
|
|
283
220
|
}
|
|
@@ -318,33 +255,31 @@ var Rectum = /*#__PURE__*/function (_Colon) {
|
|
|
318
255
|
* data.edge を元に port のデータも作成する。
|
|
319
256
|
* @param {object} data { node: [], edges: [] }
|
|
320
257
|
*/
|
|
321
|
-
|
|
322
258
|
}, {
|
|
323
259
|
key: "data",
|
|
324
260
|
value: function data(_data) {
|
|
325
|
-
if (arguments.length === 0) return
|
|
261
|
+
if (arguments.length === 0) return _superPropGet(Rectum, "data", this, 3)([]);
|
|
326
262
|
var nodes = this.makeNodes(_data.nodes);
|
|
327
263
|
var edges = this.makeEdges(_data.edges);
|
|
328
|
-
var ports = this.makePorts(nodes.ht, edges.list);
|
|
264
|
+
var ports = this.makePorts(nodes.ht, edges.list);
|
|
329
265
|
|
|
266
|
+
// fitting ports
|
|
330
267
|
var _iterator4 = _createForOfIteratorHelper(ports.list),
|
|
331
|
-
|
|
332
|
-
|
|
268
|
+
_step4;
|
|
333
269
|
try {
|
|
334
270
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
335
271
|
var port = _step4.value;
|
|
336
272
|
this.fittingPort(port);
|
|
337
|
-
}
|
|
273
|
+
}
|
|
338
274
|
|
|
275
|
+
// fitting edges
|
|
339
276
|
} catch (err) {
|
|
340
277
|
_iterator4.e(err);
|
|
341
278
|
} finally {
|
|
342
279
|
_iterator4.f();
|
|
343
280
|
}
|
|
344
|
-
|
|
345
281
|
var _iterator5 = _createForOfIteratorHelper(edges.list),
|
|
346
|
-
|
|
347
|
-
|
|
282
|
+
_step5;
|
|
348
283
|
try {
|
|
349
284
|
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
350
285
|
var edge = _step5.value;
|
|
@@ -355,21 +290,19 @@ var Rectum = /*#__PURE__*/function (_Colon) {
|
|
|
355
290
|
} finally {
|
|
356
291
|
_iterator5.f();
|
|
357
292
|
}
|
|
358
|
-
|
|
359
|
-
return _get(_getPrototypeOf(Rectum.prototype), "data", this).call(this, {
|
|
293
|
+
return _superPropGet(Rectum, "data", this, 3)([{
|
|
360
294
|
nodes: nodes,
|
|
361
295
|
edges: edges,
|
|
362
296
|
ports: ports
|
|
363
|
-
});
|
|
364
|
-
}
|
|
297
|
+
}]);
|
|
298
|
+
}
|
|
299
|
+
///// ////////////////////////////////////////////////////////////////
|
|
365
300
|
///// Flatten
|
|
366
301
|
///// ////////////////////////////////////////////////////////////////
|
|
367
|
-
|
|
368
302
|
}, {
|
|
369
303
|
key: "flattenCore",
|
|
370
304
|
value: function flattenCore(data, lev) {
|
|
371
305
|
var _this3 = this;
|
|
372
|
-
|
|
373
306
|
var out = [data];
|
|
374
307
|
var children = data.children.reduce(function (acc, val) {
|
|
375
308
|
val._level = lev;
|
|
@@ -381,7 +314,6 @@ var Rectum = /*#__PURE__*/function (_Colon) {
|
|
|
381
314
|
key: "flatten",
|
|
382
315
|
value: function flatten(data) {
|
|
383
316
|
var _this4 = this;
|
|
384
|
-
|
|
385
317
|
var nodes = data.nodes.tree;
|
|
386
318
|
if (!nodes) return [];
|
|
387
319
|
var lev = 10;
|
|
@@ -395,27 +327,26 @@ var Rectum = /*#__PURE__*/function (_Colon) {
|
|
|
395
327
|
value: function getDrawElements(data) {
|
|
396
328
|
var out = this.flatten(data);
|
|
397
329
|
var ports = data.ports.list;
|
|
398
|
-
var edges = data.edges.list;
|
|
330
|
+
var edges = data.edges.list;
|
|
399
331
|
|
|
332
|
+
// port に level を設定
|
|
400
333
|
var _iterator6 = _createForOfIteratorHelper(ports),
|
|
401
|
-
|
|
402
|
-
|
|
334
|
+
_step6;
|
|
403
335
|
try {
|
|
404
336
|
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
405
337
|
var port = _step6.value;
|
|
406
338
|
port._level = port.node._level;
|
|
407
339
|
out.push(port);
|
|
408
|
-
}
|
|
340
|
+
}
|
|
409
341
|
|
|
342
|
+
// edge に level を設定
|
|
410
343
|
} catch (err) {
|
|
411
344
|
_iterator6.e(err);
|
|
412
345
|
} finally {
|
|
413
346
|
_iterator6.f();
|
|
414
347
|
}
|
|
415
|
-
|
|
416
348
|
var _iterator7 = _createForOfIteratorHelper(edges),
|
|
417
|
-
|
|
418
|
-
|
|
349
|
+
_step7;
|
|
419
350
|
try {
|
|
420
351
|
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
421
352
|
var edge = _step7.value;
|
|
@@ -423,21 +354,21 @@ var Rectum = /*#__PURE__*/function (_Colon) {
|
|
|
423
354
|
var lev_to = edge.to.port._level;
|
|
424
355
|
if (lev_from > lev_to) edge._level = lev_from - 1;else edge._level = lev_to - 1;
|
|
425
356
|
out.push(edge);
|
|
426
|
-
}
|
|
357
|
+
}
|
|
427
358
|
|
|
359
|
+
// ソートして返す
|
|
428
360
|
} catch (err) {
|
|
429
361
|
_iterator7.e(err);
|
|
430
362
|
} finally {
|
|
431
363
|
_iterator7.f();
|
|
432
364
|
}
|
|
433
|
-
|
|
434
365
|
return out.sort(function (a, b) {
|
|
435
366
|
return a._level < b._level ? -1 : 1;
|
|
436
367
|
});
|
|
437
|
-
}
|
|
368
|
+
}
|
|
369
|
+
///// ////////////////////////////////////////////////////////////////
|
|
438
370
|
///// Draw
|
|
439
371
|
///// ////////////////////////////////////////////////////////////////
|
|
440
|
-
|
|
441
372
|
}, {
|
|
442
373
|
key: "painter",
|
|
443
374
|
value: function painter(element_class) {
|
|
@@ -457,10 +388,8 @@ var Rectum = /*#__PURE__*/function (_Colon) {
|
|
|
457
388
|
var place = this.layer('foreground');
|
|
458
389
|
var data = this.data();
|
|
459
390
|
var elements = this.getDrawElements(data);
|
|
460
|
-
|
|
461
391
|
var _iterator8 = _createForOfIteratorHelper(elements),
|
|
462
|
-
|
|
463
|
-
|
|
392
|
+
_step8;
|
|
464
393
|
try {
|
|
465
394
|
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
466
395
|
var element = _step8.value;
|
|
@@ -473,8 +402,4 @@ var Rectum = /*#__PURE__*/function (_Colon) {
|
|
|
473
402
|
}
|
|
474
403
|
}
|
|
475
404
|
}]);
|
|
476
|
-
|
|
477
|
-
return Rectum;
|
|
478
|
-
}(_assh0le.Colon);
|
|
479
|
-
|
|
480
|
-
exports["default"] = Rectum;
|
|
405
|
+
}(_assh0le.Colon);
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = 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 _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
9
|
+
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); } }
|
|
10
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
12
|
+
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); }
|
|
13
|
+
/**
|
|
14
|
+
* Edge のデータクラス。入力データの正規化(既定値補完)を行う。
|
|
15
|
+
* 描画は painters/Edge.js が担当する。
|
|
16
|
+
*/
|
|
17
|
+
var Edge = exports["default"] = /*#__PURE__*/function () {
|
|
18
|
+
function Edge() {
|
|
19
|
+
_classCallCheck(this, Edge);
|
|
20
|
+
}
|
|
21
|
+
return _createClass(Edge, [{
|
|
22
|
+
key: "dataTemplate",
|
|
23
|
+
value: function dataTemplate() {
|
|
24
|
+
return {
|
|
25
|
+
from: {
|
|
26
|
+
id: null,
|
|
27
|
+
port: null,
|
|
28
|
+
node: null,
|
|
29
|
+
position: {
|
|
30
|
+
x: 0,
|
|
31
|
+
y: 0
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
to: {
|
|
35
|
+
id: null,
|
|
36
|
+
port: null,
|
|
37
|
+
node: null,
|
|
38
|
+
position: {
|
|
39
|
+
x: 0,
|
|
40
|
+
y: 0
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
stroke: {
|
|
44
|
+
color: '#333',
|
|
45
|
+
width: 1.5,
|
|
46
|
+
marker: {
|
|
47
|
+
start: false,
|
|
48
|
+
end: true
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
_id: null,
|
|
52
|
+
_core: null,
|
|
53
|
+
_class: 'EDGE'
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}, {
|
|
57
|
+
key: "normalize",
|
|
58
|
+
value: function normalize(data) {
|
|
59
|
+
var new_data = this.dataTemplate();
|
|
60
|
+
new_data._core = data;
|
|
61
|
+
if (data.id) new_data._id = data.id;
|
|
62
|
+
if (data.from.id) new_data.from.id = data.from.id;
|
|
63
|
+
if (data.to.id) new_data.to.id = data.to.id;
|
|
64
|
+
if (data.stroke) {
|
|
65
|
+
if (data.stroke.color) new_data.stroke.color = data.stroke.color;
|
|
66
|
+
if (data.stroke.width) new_data.stroke.width = data.stroke.width;
|
|
67
|
+
if (data.stroke.marker) new_data.stroke.marker = data.stroke.marker;
|
|
68
|
+
}
|
|
69
|
+
data._edge = new_data;
|
|
70
|
+
return new_data;
|
|
71
|
+
}
|
|
72
|
+
}]);
|
|
73
|
+
}();
|