@yanqirenshi/d3.ter 0.0.9 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -8
- package/dist/js/EntityTailor.js +106 -217
- package/dist/js/Geometry.js +212 -0
- package/dist/js/Painter.js +23 -403
- package/dist/js/Painters/Entity.js +408 -0
- package/dist/js/Painters/Ports.js +55 -0
- package/dist/js/Painters/Relationships.js +57 -0
- package/dist/js/Port.js +218 -7
- package/dist/js/Rectum.js +34 -32
- package/package.json +5 -6
package/dist/js/Port.js
CHANGED
|
@@ -9,6 +9,8 @@ exports["default"] = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _Atman2 = _interopRequireDefault(require("./Atman.js"));
|
|
11
11
|
|
|
12
|
+
var _Geometry = _interopRequireDefault(require("./Geometry.js"));
|
|
13
|
+
|
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
15
|
|
|
14
16
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
@@ -36,29 +38,238 @@ var Port = /*#__PURE__*/function (_Atman) {
|
|
|
36
38
|
|
|
37
39
|
var _super = _createSuper(Port);
|
|
38
40
|
|
|
39
|
-
function Port(type,
|
|
41
|
+
function Port(type, entity, relatihonship_data) {
|
|
40
42
|
var _this;
|
|
41
43
|
|
|
42
44
|
_classCallCheck(this, Port);
|
|
43
45
|
|
|
44
|
-
_this = _super.call(this, type === 'from' ? 'PORT-FROM' : 'PORT-TO',
|
|
45
|
-
_this._id =
|
|
46
|
+
_this = _super.call(this, type === 'from' ? 'PORT-FROM' : 'PORT-TO', relatihonship_data);
|
|
47
|
+
_this._id = relatihonship_data.id + '_' + entity._id; // Idenrifier-Instance
|
|
46
48
|
|
|
47
|
-
_this._owner =
|
|
49
|
+
_this._owner = entity;
|
|
48
50
|
_this._type = type;
|
|
49
|
-
_this._core =
|
|
50
|
-
_this.position =
|
|
51
|
+
_this._core = relatihonship_data[type];
|
|
52
|
+
_this.position = relatihonship_data.position || {
|
|
51
53
|
x: 0,
|
|
52
54
|
y: 0
|
|
53
55
|
};
|
|
54
56
|
|
|
55
|
-
|
|
57
|
+
_this.addPort2Entity(entity);
|
|
56
58
|
|
|
57
59
|
_this._entity = null;
|
|
60
|
+
_this.geometry = new _Geometry["default"]();
|
|
58
61
|
return _this;
|
|
59
62
|
}
|
|
63
|
+
/* **************************************************************** *
|
|
64
|
+
* Data manegement
|
|
65
|
+
* **************************************************************** */
|
|
66
|
+
|
|
60
67
|
|
|
61
68
|
_createClass(Port, [{
|
|
69
|
+
key: "calLinePoints",
|
|
70
|
+
value: function calLinePoints(port) {
|
|
71
|
+
var table = port._column_instance._table;
|
|
72
|
+
var rect = {
|
|
73
|
+
position: {
|
|
74
|
+
x: table.x,
|
|
75
|
+
y: table.y
|
|
76
|
+
},
|
|
77
|
+
size: {
|
|
78
|
+
w: table.w,
|
|
79
|
+
h: table.h
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
var geometry = this.geometry;
|
|
83
|
+
var four_side_lines = geometry.getFourSideLines(rect);
|
|
84
|
+
var line_port = geometry.getPortLine(port, rect);
|
|
85
|
+
var cross_point = geometry.getCrossPoint(four_side_lines, line_port);
|
|
86
|
+
var len = 33 + 4;
|
|
87
|
+
var to_point = cross_point.point;
|
|
88
|
+
var from_point;
|
|
89
|
+
|
|
90
|
+
if (cross_point.target === 'top') {
|
|
91
|
+
from_point = {
|
|
92
|
+
x: to_point.x,
|
|
93
|
+
y: to_point.y + len
|
|
94
|
+
};
|
|
95
|
+
} else if (cross_point.target === 'right') {
|
|
96
|
+
from_point = {
|
|
97
|
+
x: to_point.x - len,
|
|
98
|
+
y: to_point.y
|
|
99
|
+
};
|
|
100
|
+
} else if (cross_point.target === 'bottom') {
|
|
101
|
+
from_point = {
|
|
102
|
+
x: to_point.x,
|
|
103
|
+
y: to_point.y - len
|
|
104
|
+
};
|
|
105
|
+
} else if (cross_point.target === 'left') {
|
|
106
|
+
from_point = {
|
|
107
|
+
x: to_point.x + len,
|
|
108
|
+
y: to_point.y
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
from: from_point,
|
|
114
|
+
to: to_point
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}, {
|
|
118
|
+
key: "calOneLine",
|
|
119
|
+
value: function calOneLine(d, distance) {
|
|
120
|
+
var r = 11;
|
|
121
|
+
|
|
122
|
+
if (d.line.from.x === d.line.to.x) {
|
|
123
|
+
// 縦
|
|
124
|
+
if (d.line.from.y < d.line.to.y) {
|
|
125
|
+
// (2)
|
|
126
|
+
return {
|
|
127
|
+
from: {
|
|
128
|
+
x: d.line.from.x + r,
|
|
129
|
+
y: d.line.from.y + distance
|
|
130
|
+
},
|
|
131
|
+
to: {
|
|
132
|
+
x: d.line.from.x - r,
|
|
133
|
+
y: d.line.from.y + distance
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
} else if (d.line.from.y > d.line.to.y) {
|
|
137
|
+
// (1)
|
|
138
|
+
return {
|
|
139
|
+
from: {
|
|
140
|
+
x: d.line.from.x + r,
|
|
141
|
+
y: d.line.from.y - distance
|
|
142
|
+
},
|
|
143
|
+
to: {
|
|
144
|
+
x: d.line.from.x - r,
|
|
145
|
+
y: d.line.from.y - distance
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
} else if (d.line.from.y === d.line.to.y) {
|
|
150
|
+
// 横
|
|
151
|
+
if (d.line.from.x < d.line.to.x) {
|
|
152
|
+
// (2)
|
|
153
|
+
return {
|
|
154
|
+
from: {
|
|
155
|
+
x: d.line.from.x + distance,
|
|
156
|
+
y: d.line.from.y + r
|
|
157
|
+
},
|
|
158
|
+
to: {
|
|
159
|
+
x: d.line.from.x + distance,
|
|
160
|
+
y: d.line.from.y - r
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
} else if (d.line.from.x > d.line.to.x) {
|
|
164
|
+
// (1)
|
|
165
|
+
return {
|
|
166
|
+
from: {
|
|
167
|
+
x: d.line.from.x - distance,
|
|
168
|
+
y: d.line.from.y + r
|
|
169
|
+
},
|
|
170
|
+
to: {
|
|
171
|
+
x: d.line.from.x - distance,
|
|
172
|
+
y: d.line.from.y - r
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return {
|
|
179
|
+
from: {
|
|
180
|
+
x: 0,
|
|
181
|
+
y: 0
|
|
182
|
+
},
|
|
183
|
+
to: {
|
|
184
|
+
x: 0,
|
|
185
|
+
y: 0
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
}, {
|
|
190
|
+
key: "calThreeLine",
|
|
191
|
+
value: function calThreeLine(d, distance) {
|
|
192
|
+
if (d.line.from.x === d.line.to.x) {
|
|
193
|
+
// 縦
|
|
194
|
+
if (d.line.from.y < d.line.to.y) {
|
|
195
|
+
return [[d.line.from.x - distance, d.line.from.y], [d.line.from.x, d.line.from.y + distance], [d.line.from.x + distance, d.line.from.y]];
|
|
196
|
+
} else if (d.line.from.y > d.line.to.y) {
|
|
197
|
+
return [[d.line.from.x - distance, d.line.from.y], [d.line.from.x, d.line.from.y - distance], [d.line.from.x + distance, d.line.from.y]];
|
|
198
|
+
}
|
|
199
|
+
} else if (d.line.from.y === d.line.to.y) {
|
|
200
|
+
// 横
|
|
201
|
+
if (d.line.from.x < d.line.to.x) {
|
|
202
|
+
return [[d.line.from.x, d.line.from.y - distance], [d.line.from.x + distance, d.line.from.y], [d.line.from.x, d.line.from.y + distance]];
|
|
203
|
+
} else if (d.line.from.x > d.line.to.x) {
|
|
204
|
+
return [[d.line.from.x, d.line.from.y - distance], [d.line.from.x - distance, d.line.from.y], [d.line.from.x, d.line.from.y + distance]];
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return {
|
|
209
|
+
from: {
|
|
210
|
+
x: 0,
|
|
211
|
+
y: 0
|
|
212
|
+
},
|
|
213
|
+
to: {
|
|
214
|
+
x: 0,
|
|
215
|
+
y: 0
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
}, {
|
|
220
|
+
key: "calCircle",
|
|
221
|
+
value: function calCircle(d) {
|
|
222
|
+
var distance = 22;
|
|
223
|
+
|
|
224
|
+
if (d.line.from.x === d.line.to.x) {
|
|
225
|
+
// 縦
|
|
226
|
+
if (d.line.from.y < d.line.to.y) {
|
|
227
|
+
// (2)
|
|
228
|
+
return {
|
|
229
|
+
x: d.line.from.x,
|
|
230
|
+
y: d.line.from.y + distance
|
|
231
|
+
};
|
|
232
|
+
} else if (d.line.from.y > d.line.to.y) {
|
|
233
|
+
// (1)
|
|
234
|
+
return {
|
|
235
|
+
x: d.line.from.x,
|
|
236
|
+
y: d.line.from.y - distance
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
} else if (d.line.from.y === d.line.to.y) {
|
|
240
|
+
// 横
|
|
241
|
+
if (d.line.from.x < d.line.to.x) {
|
|
242
|
+
// (2)
|
|
243
|
+
return {
|
|
244
|
+
x: d.line.from.x + distance,
|
|
245
|
+
y: d.line.from.y
|
|
246
|
+
};
|
|
247
|
+
} else if (d.line.from.x > d.line.to.x) {
|
|
248
|
+
// (1)
|
|
249
|
+
return {
|
|
250
|
+
x: d.line.from.x - distance,
|
|
251
|
+
y: d.line.from.y
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return {
|
|
257
|
+
x: 0,
|
|
258
|
+
y: 0
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
}, {
|
|
262
|
+
key: "addPort2Entity",
|
|
263
|
+
value:
|
|
264
|
+
/* **************************************************************** *
|
|
265
|
+
*
|
|
266
|
+
* **************************************************************** */
|
|
267
|
+
function addPort2Entity(entity) {
|
|
268
|
+
var port = this;
|
|
269
|
+
entity.ports.items.ht[port.id()] = port;
|
|
270
|
+
entity.ports.items.list.push(port);
|
|
271
|
+
}
|
|
272
|
+
}, {
|
|
62
273
|
key: "position_degree",
|
|
63
274
|
value: function position_degree() {
|
|
64
275
|
return this._core.position % 360;
|
package/dist/js/Rectum.js
CHANGED
|
@@ -125,44 +125,46 @@ var Rectum = /*#__PURE__*/function (_Colon) {
|
|
|
125
125
|
|
|
126
126
|
return null;
|
|
127
127
|
}
|
|
128
|
+
}, {
|
|
129
|
+
key: "getEntity",
|
|
130
|
+
value: function getEntity(id) {
|
|
131
|
+
var entities = this.entities();
|
|
132
|
+
return entities.ht[id] || null;
|
|
133
|
+
}
|
|
128
134
|
}, {
|
|
129
135
|
key: "buildRelationshipsWithPort",
|
|
130
136
|
value: function buildRelationshipsWithPort(relationships) {
|
|
131
|
-
var
|
|
132
|
-
var out = {
|
|
133
|
-
list: [],
|
|
134
|
-
ht: {}
|
|
135
|
-
};
|
|
137
|
+
var _this2 = this;
|
|
136
138
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
+
return relationships.reduce(function (out, r) {
|
|
140
|
+
var from = r.from;
|
|
141
|
+
var to = r.to; // entity identifier を取得する。
|
|
139
142
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
var element = new _Relationship["default"](r, port_from, port_to);
|
|
148
|
-
var entity_from = id_from._entity;
|
|
149
|
-
var entity_to = id_to._entity;
|
|
150
|
-
port_from._entity = entity_from;
|
|
151
|
-
port_to._entity = entity_to;
|
|
152
|
-
entity_from.ports.items.ht[port_from._id] = port_from;
|
|
153
|
-
entity_from.ports.items.list.push(port_from);
|
|
154
|
-
entity_to.ports.items.ht[port_to._id] = port_to;
|
|
155
|
-
entity_to.ports.items.list.push(port_to);
|
|
156
|
-
out.list.push(element);
|
|
157
|
-
out.ht[element._id] = element;
|
|
158
|
-
}
|
|
159
|
-
} catch (err) {
|
|
160
|
-
_iterator2.e(err);
|
|
161
|
-
} finally {
|
|
162
|
-
_iterator2.f();
|
|
163
|
-
}
|
|
143
|
+
var entity_from = _this2.getEntity(from.entity);
|
|
144
|
+
|
|
145
|
+
var entity_to = _this2.getEntity(to.entity); // Port のクラスインスタンスを作成する。
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
var port_from = new _Port["default"]('from', entity_from, r);
|
|
149
|
+
var port_to = new _Port["default"]('to', entity_to, r); // Relationship のクラスインスタンスを作成する。
|
|
164
150
|
|
|
165
|
-
|
|
151
|
+
var element = new _Relationship["default"](r, port_from, port_to); // entity(from) に port をセットする。
|
|
152
|
+
// entity_from.ports.items.ht[port_from._id] = port_from;
|
|
153
|
+
// entity_from.ports.items.list.push(port_from);
|
|
154
|
+
// port_from._entity = entity_from;
|
|
155
|
+
// entity(to) に port をセットする。
|
|
156
|
+
// entity_to.ports.items.ht[port_to._id] = port_to;
|
|
157
|
+
// entity_to.ports.items.list.push(port_to);
|
|
158
|
+
// port_to._entity = entity_to;
|
|
159
|
+
// out
|
|
160
|
+
|
|
161
|
+
out.list.push(element);
|
|
162
|
+
out.ht[element._id] = element;
|
|
163
|
+
return out;
|
|
164
|
+
}, {
|
|
165
|
+
list: [],
|
|
166
|
+
ht: {}
|
|
167
|
+
});
|
|
166
168
|
}
|
|
167
169
|
}, {
|
|
168
170
|
key: "data",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yanqirenshi/d3.ter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"author": "yanqirenshi@gmail.com",
|
|
5
5
|
"license": "GPL-3.0-or-later",
|
|
6
6
|
"description": "See `src/index.html`",
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://github.com/yanqirenshi/D3.TER#readme",
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"react": "^
|
|
26
|
-
"react-dom": "^
|
|
25
|
+
"react": "^18.2.0",
|
|
26
|
+
"react-dom": "^18.2.0"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@yanqirenshi/assh0le": "^0.
|
|
29
|
+
"@yanqirenshi/assh0le": "^0.3.0",
|
|
30
30
|
"deepmerge": "^4.2.2"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
@@ -34,7 +34,6 @@
|
|
|
34
34
|
"@babel/core": "^7.12.10",
|
|
35
35
|
"@babel/preset-env": "^7.12.11",
|
|
36
36
|
"@babel/preset-react": "^7.12.10",
|
|
37
|
-
"babel-loader": "^8.2.2"
|
|
38
|
-
"react-dom": "^17.0.1"
|
|
37
|
+
"babel-loader": "^8.2.2"
|
|
39
38
|
}
|
|
40
39
|
}
|