@yanqirenshi/d3.ter 0.1.4 → 0.1.6
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/README.md +68 -68
- package/dist/js/Entity.js +589 -8
- package/dist/js/Geometry.js +4 -6
- package/dist/js/IdentifierInstance.js +27 -3
- package/dist/js/Painter.js +33 -4
- package/dist/js/Painters/PortCardinality.js +132 -75
- package/dist/js/Painters/PortCircle.js +2 -2
- package/dist/js/Painters/PortOptionality.js +51 -42
- package/dist/js/Painters/Ports.js +16 -20
- package/dist/js/Painters/Relationships.js +19 -8
- package/dist/js/Port.js +286 -133
- package/dist/js/utils/Name.js +4 -11
- package/package.json +1 -1
package/dist/js/Port.js
CHANGED
|
@@ -49,7 +49,7 @@ var Port = /*#__PURE__*/function (_Atman) {
|
|
|
49
49
|
_this._owner = entity;
|
|
50
50
|
_this._type = type;
|
|
51
51
|
_this._core = relatihonship_data[type];
|
|
52
|
-
_this.
|
|
52
|
+
_this._position = relatihonship_data.position || {
|
|
53
53
|
x: 0,
|
|
54
54
|
y: 0
|
|
55
55
|
};
|
|
@@ -58,210 +58,363 @@ var Port = /*#__PURE__*/function (_Atman) {
|
|
|
58
58
|
|
|
59
59
|
_this._entity = null;
|
|
60
60
|
_this.geometry = new _Geometry["default"]();
|
|
61
|
+
_this._cardinality_distance = 11;
|
|
62
|
+
_this._optionality_distance = 22;
|
|
63
|
+
_this._line = null;
|
|
64
|
+
_this._cardinality = null;
|
|
65
|
+
_this._optionality = null;
|
|
61
66
|
return _this;
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
_createClass(Port, [{
|
|
70
|
+
key: "core",
|
|
71
|
+
value: function core() {
|
|
72
|
+
return this._core;
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
65
75
|
key: "degree",
|
|
66
76
|
value: function degree() {
|
|
67
77
|
return this._core.position || 0;
|
|
68
78
|
}
|
|
79
|
+
}, {
|
|
80
|
+
key: "position",
|
|
81
|
+
value: function position(v) {
|
|
82
|
+
if (arguments.length === 1) {
|
|
83
|
+
this._position = v;
|
|
84
|
+
var line = this.linePosition(this.calLinePoints());
|
|
85
|
+
this.cardinalityPosition(this.positionCardinality(line));
|
|
86
|
+
this.optionalityPosition(this.positionOptionality(line));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return this._position;
|
|
90
|
+
}
|
|
91
|
+
}, {
|
|
92
|
+
key: "positionOptionality",
|
|
93
|
+
value: function positionOptionality(line_port_to_entity) {
|
|
94
|
+
var distance = this.optionalityDistance(); // d.optionality: 1, 0
|
|
95
|
+
|
|
96
|
+
switch (this.optionality()) {
|
|
97
|
+
case 0:
|
|
98
|
+
return this.calCircle(line_port_to_entity.from, line_port_to_entity.to, distance);
|
|
99
|
+
|
|
100
|
+
case 1:
|
|
101
|
+
return this.calOneLine(line_port_to_entity.from, line_port_to_entity.to, distance);
|
|
102
|
+
|
|
103
|
+
default:
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}, {
|
|
108
|
+
key: "positionCardinality",
|
|
109
|
+
value: function positionCardinality(line_port_to_entity) {
|
|
110
|
+
var distance = this.cardinalityDistance(); // cardinality: 1, 3
|
|
111
|
+
|
|
112
|
+
switch (this.cardinality()) {
|
|
113
|
+
case 1:
|
|
114
|
+
return this.calOneLine(line_port_to_entity.from, line_port_to_entity.to, distance);
|
|
115
|
+
|
|
116
|
+
case 3:
|
|
117
|
+
return this.calThreeLine(line_port_to_entity.from, line_port_to_entity.to, distance);
|
|
118
|
+
|
|
119
|
+
default:
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}, {
|
|
124
|
+
key: "owner",
|
|
125
|
+
value: function owner() {
|
|
126
|
+
return this._owner;
|
|
127
|
+
}
|
|
128
|
+
}, {
|
|
129
|
+
key: "entity",
|
|
130
|
+
value: function entity() {
|
|
131
|
+
return this._entity;
|
|
132
|
+
}
|
|
133
|
+
}, {
|
|
134
|
+
key: "relationship",
|
|
135
|
+
value: function relationship() {
|
|
136
|
+
return this._relationship;
|
|
137
|
+
}
|
|
138
|
+
}, {
|
|
139
|
+
key: "cardinality",
|
|
140
|
+
value: function cardinality() {
|
|
141
|
+
return this.core().cardinality;
|
|
142
|
+
}
|
|
143
|
+
}, {
|
|
144
|
+
key: "optionality",
|
|
145
|
+
value: function optionality() {
|
|
146
|
+
return this.core().optionality;
|
|
147
|
+
}
|
|
148
|
+
}, {
|
|
149
|
+
key: "linePosition",
|
|
150
|
+
value: function linePosition(v) {
|
|
151
|
+
if (arguments.length === 1) this._line = v;
|
|
152
|
+
return this._line;
|
|
153
|
+
}
|
|
154
|
+
}, {
|
|
155
|
+
key: "cardinalityDistance",
|
|
156
|
+
value: function cardinalityDistance() {
|
|
157
|
+
return this._cardinality_distance;
|
|
158
|
+
}
|
|
159
|
+
}, {
|
|
160
|
+
key: "optionalityDistance",
|
|
161
|
+
value: function optionalityDistance() {
|
|
162
|
+
return this._optionality_distance;
|
|
163
|
+
}
|
|
164
|
+
}, {
|
|
165
|
+
key: "cardinalityPosition",
|
|
166
|
+
value: function cardinalityPosition(v) {
|
|
167
|
+
if (arguments.length === 1) this._cardinality = v;
|
|
168
|
+
return this._cardinality;
|
|
169
|
+
}
|
|
170
|
+
}, {
|
|
171
|
+
key: "optionalityPosition",
|
|
172
|
+
value: function optionalityPosition(v) {
|
|
173
|
+
if (arguments.length === 1) this._optionality = v;
|
|
174
|
+
return this._optionality;
|
|
175
|
+
}
|
|
69
176
|
/* **************************************************************** *
|
|
70
177
|
* Data manegement
|
|
71
178
|
* **************************************************************** */
|
|
72
179
|
|
|
180
|
+
/**
|
|
181
|
+
* entity と port
|
|
182
|
+
*/
|
|
183
|
+
|
|
73
184
|
}, {
|
|
74
185
|
key: "calLinePoints",
|
|
75
|
-
value: function calLinePoints(
|
|
76
|
-
var
|
|
186
|
+
value: function calLinePoints() {
|
|
187
|
+
var entity = this.owner();
|
|
188
|
+
var entity_position = entity.position;
|
|
189
|
+
var entity_size = entity.size;
|
|
77
190
|
var rect = {
|
|
78
191
|
position: {
|
|
79
|
-
x:
|
|
80
|
-
y:
|
|
192
|
+
x: entity_position.x,
|
|
193
|
+
y: entity_position.y
|
|
81
194
|
},
|
|
82
195
|
size: {
|
|
83
|
-
w:
|
|
84
|
-
h:
|
|
196
|
+
w: entity_size.w,
|
|
197
|
+
h: entity_size.h
|
|
85
198
|
}
|
|
86
199
|
};
|
|
87
|
-
var geometry = this.geometry;
|
|
88
|
-
|
|
89
|
-
var
|
|
90
|
-
|
|
91
|
-
var
|
|
200
|
+
var geometry = this.geometry; // entity の四辺
|
|
201
|
+
|
|
202
|
+
var four_side_lines = geometry.getFourSideLines(rect, 4, 33); // port と entityの中心との直線。
|
|
203
|
+
|
|
204
|
+
var line_port = geometry.getPortLine(this.degree(), rect); // port と entityの中心との直線 と entity の四辺の交点。
|
|
205
|
+
// 交点 と どの辺 が返ってくる。
|
|
206
|
+
|
|
207
|
+
var cross_point = geometry.getCrossPoint(four_side_lines, line_port); // entity と port との距離
|
|
208
|
+
|
|
209
|
+
var len = 33 + 4; // 33: ?, 4: ?
|
|
210
|
+
// point の位置を返す
|
|
211
|
+
|
|
92
212
|
var to_point = cross_point.point;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
213
|
+
|
|
214
|
+
var from_point = function from_point() {
|
|
215
|
+
switch (cross_point.target) {
|
|
216
|
+
case 'top':
|
|
217
|
+
return {
|
|
218
|
+
x: to_point.x,
|
|
219
|
+
y: to_point.y + len
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
case 'right':
|
|
223
|
+
return {
|
|
224
|
+
x: to_point.x - len,
|
|
225
|
+
y: to_point.y
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
case 'bottom':
|
|
229
|
+
return {
|
|
230
|
+
x: to_point.x,
|
|
231
|
+
y: to_point.y - len
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
case 'left':
|
|
235
|
+
return {
|
|
236
|
+
x: to_point.x + len,
|
|
237
|
+
y: to_point.y
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
default:
|
|
241
|
+
throw new Error('!!!');
|
|
242
|
+
}
|
|
243
|
+
};
|
|
116
244
|
|
|
117
245
|
return {
|
|
118
|
-
from: from_point,
|
|
246
|
+
from: from_point(),
|
|
119
247
|
to: to_point
|
|
120
248
|
};
|
|
121
249
|
}
|
|
250
|
+
/** **************************************************************** *
|
|
251
|
+
* port と entity の間の向きを返します。
|
|
252
|
+
* **************************************************************** */
|
|
253
|
+
|
|
254
|
+
}, {
|
|
255
|
+
key: "portDirection",
|
|
256
|
+
value: function portDirection(from, to) {
|
|
257
|
+
// 縦
|
|
258
|
+
if (from.x === to.x) {
|
|
259
|
+
if (from.y < to.y) return 'DOWN';
|
|
260
|
+
if (from.y > to.y) return 'UP';
|
|
261
|
+
} // 横
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
if (from.y === to.y) {
|
|
265
|
+
if (from.x < to.x) return 'RIGHT';
|
|
266
|
+
if (from.x > to.x) return 'LEFT';
|
|
267
|
+
} // これはありえないはず。
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
throw new Error('Can Not Found Direction.');
|
|
271
|
+
}
|
|
272
|
+
/** **************************************************************** *
|
|
273
|
+
* 1 line (cardinaly: 1)
|
|
274
|
+
* Cardinary: n ケースの座標を計算する。
|
|
275
|
+
*
|
|
276
|
+
* Line の from, to で向きを決める。
|
|
277
|
+
*
|
|
278
|
+
* d: port
|
|
279
|
+
* distance: between port and entity
|
|
280
|
+
* **************************************************************** */
|
|
281
|
+
|
|
122
282
|
}, {
|
|
123
283
|
key: "calOneLine",
|
|
124
|
-
value: function calOneLine(
|
|
284
|
+
value: function calOneLine(from, to, distance) {
|
|
125
285
|
var r = 11;
|
|
126
286
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if (d.line.from.y < d.line.to.y) {
|
|
130
|
-
// (2)
|
|
287
|
+
switch (this.portDirection(from, to)) {
|
|
288
|
+
case 'DOWN':
|
|
131
289
|
return {
|
|
132
290
|
from: {
|
|
133
|
-
x:
|
|
134
|
-
y:
|
|
291
|
+
x: from.x + r,
|
|
292
|
+
y: from.y + distance
|
|
135
293
|
},
|
|
136
294
|
to: {
|
|
137
|
-
x:
|
|
138
|
-
y:
|
|
295
|
+
x: from.x - r,
|
|
296
|
+
y: from.y + distance
|
|
139
297
|
}
|
|
140
298
|
};
|
|
141
|
-
|
|
142
|
-
|
|
299
|
+
|
|
300
|
+
case 'DOWN':
|
|
143
301
|
return {
|
|
144
302
|
from: {
|
|
145
|
-
x:
|
|
146
|
-
y:
|
|
303
|
+
x: from.x + r,
|
|
304
|
+
y: from.y - distance
|
|
147
305
|
},
|
|
148
306
|
to: {
|
|
149
|
-
x:
|
|
150
|
-
y:
|
|
307
|
+
x: from.x - r,
|
|
308
|
+
y: from.y - distance
|
|
151
309
|
}
|
|
152
310
|
};
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
// 横
|
|
156
|
-
if (d.line.from.x < d.line.to.x) {
|
|
157
|
-
// (2)
|
|
311
|
+
|
|
312
|
+
case 'RIGHT':
|
|
158
313
|
return {
|
|
159
314
|
from: {
|
|
160
|
-
x:
|
|
161
|
-
y:
|
|
315
|
+
x: from.x + distance,
|
|
316
|
+
y: from.y + r
|
|
162
317
|
},
|
|
163
318
|
to: {
|
|
164
|
-
x:
|
|
165
|
-
y:
|
|
319
|
+
x: from.x + distance,
|
|
320
|
+
y: from.y - r
|
|
166
321
|
}
|
|
167
322
|
};
|
|
168
|
-
|
|
169
|
-
|
|
323
|
+
|
|
324
|
+
case 'LEFT':
|
|
170
325
|
return {
|
|
171
326
|
from: {
|
|
172
|
-
x:
|
|
173
|
-
y:
|
|
327
|
+
x: from.x - distance,
|
|
328
|
+
y: from.y + r
|
|
174
329
|
},
|
|
175
330
|
to: {
|
|
176
|
-
x:
|
|
177
|
-
y:
|
|
331
|
+
x: from.x - distance,
|
|
332
|
+
y: from.y - r
|
|
178
333
|
}
|
|
179
334
|
};
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
335
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
336
|
+
default:
|
|
337
|
+
return {
|
|
338
|
+
from: {
|
|
339
|
+
x: 0,
|
|
340
|
+
y: 0
|
|
341
|
+
},
|
|
342
|
+
to: {
|
|
343
|
+
x: 0,
|
|
344
|
+
y: 0
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
}
|
|
193
348
|
}
|
|
194
349
|
}, {
|
|
195
350
|
key: "calThreeLine",
|
|
196
|
-
value:
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
return [[
|
|
210
|
-
}
|
|
211
|
-
}
|
|
351
|
+
value:
|
|
352
|
+
/**
|
|
353
|
+
* 3 line (cardinaly: n)
|
|
354
|
+
* Cardinary: n ケースの座標を計算する。
|
|
355
|
+
*
|
|
356
|
+
* Line の from, to で向きを決める。
|
|
357
|
+
*
|
|
358
|
+
* d: port
|
|
359
|
+
* distance: between port and entity
|
|
360
|
+
* **************************************************************** */
|
|
361
|
+
function calThreeLine(from, to, distance) {
|
|
362
|
+
switch (this.portDirection(from, to)) {
|
|
363
|
+
case 'DOWN':
|
|
364
|
+
return [[from.x - distance, from.y], [from.x, from.y + distance], [from.x + distance, from.y]];
|
|
212
365
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
y
|
|
221
|
-
|
|
222
|
-
|
|
366
|
+
case 'DOWN':
|
|
367
|
+
return [[from.x - distance, from.y], [from.x, from.y - distance], [from.x + distance, from.y]];
|
|
368
|
+
|
|
369
|
+
case 'RIGHT':
|
|
370
|
+
return [[from.x, from.y - distance], [from.x + distance, from.y], [from.x, from.y + distance]];
|
|
371
|
+
|
|
372
|
+
case 'LEFT':
|
|
373
|
+
return [[from.x, from.y - distance], [from.x - distance, from.y], [from.x, from.y + distance]];
|
|
374
|
+
|
|
375
|
+
default:
|
|
376
|
+
return [[0, 0], [0, 0], [0, 0]];
|
|
377
|
+
}
|
|
223
378
|
}
|
|
224
379
|
}, {
|
|
225
380
|
key: "calCircle",
|
|
226
|
-
value:
|
|
227
|
-
|
|
381
|
+
value:
|
|
382
|
+
/** **************************************************************** *
|
|
383
|
+
* null のための 丸
|
|
384
|
+
* **************************************************************** */
|
|
385
|
+
function calCircle(from, to, distance) {
|
|
386
|
+
// const distance = 28;
|
|
387
|
+
switch (this.portDirection(from, to)) {
|
|
388
|
+
case 'DOWN':
|
|
389
|
+
return {
|
|
390
|
+
x: from.x,
|
|
391
|
+
y: from.y + distance
|
|
392
|
+
};
|
|
228
393
|
|
|
229
|
-
|
|
230
|
-
// 縦
|
|
231
|
-
if (d.line.from.y < d.line.to.y) {
|
|
232
|
-
// (2)
|
|
394
|
+
case 'DOWN':
|
|
233
395
|
return {
|
|
234
|
-
x:
|
|
235
|
-
y:
|
|
396
|
+
x: from.x,
|
|
397
|
+
y: from.y - distance
|
|
236
398
|
};
|
|
237
|
-
|
|
238
|
-
|
|
399
|
+
|
|
400
|
+
case 'RIGHT':
|
|
239
401
|
return {
|
|
240
|
-
x:
|
|
241
|
-
y:
|
|
402
|
+
x: from.x + distance,
|
|
403
|
+
y: from.y
|
|
242
404
|
};
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
// 横
|
|
246
|
-
if (d.line.from.x < d.line.to.x) {
|
|
247
|
-
// (2)
|
|
405
|
+
|
|
406
|
+
case 'LEFT':
|
|
248
407
|
return {
|
|
249
|
-
x:
|
|
250
|
-
y:
|
|
408
|
+
x: from.x - distance,
|
|
409
|
+
y: from.y
|
|
251
410
|
};
|
|
252
|
-
|
|
253
|
-
|
|
411
|
+
|
|
412
|
+
default:
|
|
254
413
|
return {
|
|
255
|
-
x:
|
|
256
|
-
y:
|
|
414
|
+
x: 0,
|
|
415
|
+
y: 0
|
|
257
416
|
};
|
|
258
|
-
}
|
|
259
417
|
}
|
|
260
|
-
|
|
261
|
-
return {
|
|
262
|
-
x: 0,
|
|
263
|
-
y: 0
|
|
264
|
-
};
|
|
265
418
|
}
|
|
266
419
|
}, {
|
|
267
420
|
key: "addPort2Entity",
|
package/dist/js/utils/Name.js
CHANGED
|
@@ -34,24 +34,17 @@ var Name = /*#__PURE__*/function () {
|
|
|
34
34
|
_createClass(Name, [{
|
|
35
35
|
key: "set",
|
|
36
36
|
value: function set(v) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (
|
|
40
|
-
console.log(_typeof(v));
|
|
41
|
-
|
|
42
|
-
if ('string' === typeof v) {
|
|
37
|
+
if (arguments.lengh === 0 || !v) {
|
|
38
|
+
return this;
|
|
39
|
+
} else if ('string' === typeof v) {
|
|
43
40
|
var isLogical = function isLogical(str) {
|
|
44
41
|
return str.match(/^[^\x01-\x7E\xA1-\xDF]+$/);
|
|
45
42
|
};
|
|
46
43
|
|
|
47
44
|
if (isLogical) this.physical = v;else this.logical = v;
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if ("object" === _typeof(v)) {
|
|
45
|
+
} else if ("object" === _typeof(v)) {
|
|
52
46
|
this.physical = v.physical || null;
|
|
53
47
|
this.logical = v.logical || null;
|
|
54
|
-
return this;
|
|
55
48
|
}
|
|
56
49
|
|
|
57
50
|
return this;
|