@yanqirenshi/d3.ter 0.1.0 → 0.1.2
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 +257 -0
- package/dist/js/Painters/Relationships.js +57 -0
- package/dist/js/Port.js +223 -7
- package/dist/js/Rectum.js +34 -32
- package/package.json +1 -1
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _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(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
+
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
21
|
+
|
|
22
|
+
var Entity = /*#__PURE__*/function () {
|
|
23
|
+
function Entity(parent) {
|
|
24
|
+
_classCallCheck(this, Entity);
|
|
25
|
+
|
|
26
|
+
this._parent = parent;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
_createClass(Entity, [{
|
|
30
|
+
key: "foreground",
|
|
31
|
+
value: function foreground() {
|
|
32
|
+
return this._parent.foreground;
|
|
33
|
+
}
|
|
34
|
+
}, {
|
|
35
|
+
key: "background",
|
|
36
|
+
value: function background() {
|
|
37
|
+
return this._parent.background;
|
|
38
|
+
}
|
|
39
|
+
}, {
|
|
40
|
+
key: "callbacks",
|
|
41
|
+
value: function callbacks() {
|
|
42
|
+
return this._parent.callbacks;
|
|
43
|
+
}
|
|
44
|
+
}, {
|
|
45
|
+
key: "default",
|
|
46
|
+
value: function _default() {
|
|
47
|
+
return this._parent._default;
|
|
48
|
+
}
|
|
49
|
+
/* **************************************************************** *
|
|
50
|
+
* Move
|
|
51
|
+
* TODO: これは Painter に持っていくべきかも。全部じゃないにしても。
|
|
52
|
+
* **************************************************************** */
|
|
53
|
+
|
|
54
|
+
}, {
|
|
55
|
+
key: "dragStart",
|
|
56
|
+
value: function dragStart(event, entity) {
|
|
57
|
+
entity._drag = {
|
|
58
|
+
start: {
|
|
59
|
+
x: event.x,
|
|
60
|
+
y: event.y
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}, {
|
|
65
|
+
key: "dragged",
|
|
66
|
+
value: function dragged(event, entity) {
|
|
67
|
+
entity.position.x += event.x - entity._drag.start.x;
|
|
68
|
+
entity.position.y += event.y - entity._drag.start.y;
|
|
69
|
+
this.moveEntity(entity);
|
|
70
|
+
this.moveEdges(entity);
|
|
71
|
+
}
|
|
72
|
+
}, {
|
|
73
|
+
key: "dragEnd",
|
|
74
|
+
value: function dragEnd(event, entity) {
|
|
75
|
+
// let campus = STORE.get('active.ter.campus');
|
|
76
|
+
delete entity._drag; // ACTIONS.saveTerEntityPosition(campus, entity);
|
|
77
|
+
}
|
|
78
|
+
}, {
|
|
79
|
+
key: "addMoveEvents",
|
|
80
|
+
value: function addMoveEvents(body) {
|
|
81
|
+
var _this = this;
|
|
82
|
+
|
|
83
|
+
return body.call(d3.drag().on("start", function (e, d) {
|
|
84
|
+
return _this.dragStart(e, d);
|
|
85
|
+
}).on("drag", function (e, d) {
|
|
86
|
+
return _this.dragged(e, d);
|
|
87
|
+
}).on("end", function (e, d) {
|
|
88
|
+
return _this.dragEnd(e, d);
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
}, {
|
|
92
|
+
key: "moveEntity",
|
|
93
|
+
value: function moveEntity(entity) {
|
|
94
|
+
var selection = this.foreground().selectAll('g.entity').data([entity], function (d) {
|
|
95
|
+
return d._id;
|
|
96
|
+
});
|
|
97
|
+
selection.attr('transform', function (d) {
|
|
98
|
+
return 'translate(' + d.position.x + ',' + d.position.y + ')';
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}, {
|
|
102
|
+
key: "moveEdges",
|
|
103
|
+
value: function moveEdges(entity) {
|
|
104
|
+
var edges = entity.ports.items.list.map(function (p) {
|
|
105
|
+
return p._relationship;
|
|
106
|
+
});
|
|
107
|
+
var selection = this.background().selectAll('line.connector').data(edges, function (d) {
|
|
108
|
+
return d._id;
|
|
109
|
+
}); // TODO: ここは分離したいな。
|
|
110
|
+
|
|
111
|
+
this._parent.relationships().drawRelationshipsCore(selection);
|
|
112
|
+
}
|
|
113
|
+
/* **************************************************************** *
|
|
114
|
+
* Draw this.entity
|
|
115
|
+
* **************************************************************** */
|
|
116
|
+
|
|
117
|
+
}, {
|
|
118
|
+
key: "drawGroup",
|
|
119
|
+
value: function drawGroup(entities) {
|
|
120
|
+
return this.foreground().selectAll('g.entity').data(entities, function (d) {
|
|
121
|
+
return d._id;
|
|
122
|
+
}).enter().append('g').attr('class', 'entity').attr('entity-id', function (d) {
|
|
123
|
+
return d._id;
|
|
124
|
+
}).attr('entity-code', function (d) {
|
|
125
|
+
return d._core.type;
|
|
126
|
+
}).attr('entity-type', function (d) {
|
|
127
|
+
return d._class;
|
|
128
|
+
}).attr("transform", function (d) {
|
|
129
|
+
return "translate(" + d.position.x + "," + d.position.y + ")";
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/* ************************************ *
|
|
133
|
+
* Body *
|
|
134
|
+
* ************************************ */
|
|
135
|
+
|
|
136
|
+
}, {
|
|
137
|
+
key: "drawBodyCore",
|
|
138
|
+
value: function drawBodyCore(body) {
|
|
139
|
+
body.attr('class', 'entity-body').attr('width', function (d) {
|
|
140
|
+
return d.size.w;
|
|
141
|
+
}).attr('height', function (d) {
|
|
142
|
+
return d.size.h;
|
|
143
|
+
}).attr('rx', function (d) {
|
|
144
|
+
return 5;
|
|
145
|
+
}).attr('ry', function (d) {
|
|
146
|
+
return 5;
|
|
147
|
+
}).attr('fill', function (d) {
|
|
148
|
+
return d.background.color;
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}, {
|
|
152
|
+
key: "drawBody",
|
|
153
|
+
value: function drawBody(groups) {
|
|
154
|
+
var body = groups.append('rect');
|
|
155
|
+
this.drawBodyCore(body);
|
|
156
|
+
return body;
|
|
157
|
+
}
|
|
158
|
+
/* ************************************ *
|
|
159
|
+
* Name *
|
|
160
|
+
* ************************************ */
|
|
161
|
+
|
|
162
|
+
}, {
|
|
163
|
+
key: "drawNameRect",
|
|
164
|
+
value: function drawNameRect(rects) {
|
|
165
|
+
rects.attr('x', function (d) {
|
|
166
|
+
return d.name.position.x;
|
|
167
|
+
}).attr('y', function (d) {
|
|
168
|
+
return d.name.position.y;
|
|
169
|
+
}).attr('width', function (d) {
|
|
170
|
+
return d.name.size.w;
|
|
171
|
+
}).attr('height', function (d) {
|
|
172
|
+
return d.name.size.h;
|
|
173
|
+
}).attr('rx', function (d) {
|
|
174
|
+
return 3;
|
|
175
|
+
}).attr('ry', function (d) {
|
|
176
|
+
return 3;
|
|
177
|
+
}).attr('fill', function (d) {
|
|
178
|
+
return d.background.color;
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}, {
|
|
182
|
+
key: "drawNameText",
|
|
183
|
+
value: function drawNameText(texts) {
|
|
184
|
+
var _this2 = this;
|
|
185
|
+
|
|
186
|
+
texts.attr('class', 'entity-title').attr("x", function (d) {
|
|
187
|
+
return d.padding + d.name.padding;
|
|
188
|
+
}).attr("y", function (d) {
|
|
189
|
+
return d.padding + d.name.padding + _this2["default"]().line.font.size;
|
|
190
|
+
}).attr("fill", function (d) {
|
|
191
|
+
return '#fff';
|
|
192
|
+
}).attr("font-size", function (d) {
|
|
193
|
+
return 24;
|
|
194
|
+
}).text(function (d) {
|
|
195
|
+
return d.name.val();
|
|
196
|
+
});
|
|
197
|
+
this.addMoveEvents(texts);
|
|
198
|
+
return texts;
|
|
199
|
+
}
|
|
200
|
+
}, {
|
|
201
|
+
key: "drawName",
|
|
202
|
+
value: function drawName(groups) {
|
|
203
|
+
var callbacks = this.callbacks();
|
|
204
|
+
var rects = groups.append('rect').on("click", function (event, d) {
|
|
205
|
+
var func = callbacks.entity.click;
|
|
206
|
+
if (func) func(d);
|
|
207
|
+
}).attr('class', 'entity-title');
|
|
208
|
+
this.drawNameRect(rects);
|
|
209
|
+
var texts = groups.append('text').on("click", function (event, d) {
|
|
210
|
+
var func = callbacks.entity.click;
|
|
211
|
+
if (func) func(d);
|
|
212
|
+
}).attr('class', 'entity-title');
|
|
213
|
+
this.drawNameText(texts).each(function (d) {
|
|
214
|
+
if (!d._max) d._max_w = {
|
|
215
|
+
name: 0,
|
|
216
|
+
identifier: 0,
|
|
217
|
+
attribute: 0
|
|
218
|
+
};
|
|
219
|
+
var w = this.getBBox().width;
|
|
220
|
+
if (w > d._max_w.name) d._max_w.name = w;
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
/* ************************************ *
|
|
224
|
+
* Type *
|
|
225
|
+
* ************************************ */
|
|
226
|
+
|
|
227
|
+
}, {
|
|
228
|
+
key: "drawTypeRect",
|
|
229
|
+
value: function drawTypeRect(selection) {
|
|
230
|
+
selection.attr('x', function (d) {
|
|
231
|
+
return d.type.position.x;
|
|
232
|
+
}).attr('y', function (d) {
|
|
233
|
+
return d.type.position.y;
|
|
234
|
+
}).attr('width', function (d) {
|
|
235
|
+
return d.type.size.w;
|
|
236
|
+
}).attr('height', function (d) {
|
|
237
|
+
return d.type.size.h;
|
|
238
|
+
}).attr('rx', function (d) {
|
|
239
|
+
return 3;
|
|
240
|
+
}).attr('ry', function (d) {
|
|
241
|
+
return 3;
|
|
242
|
+
}).attr('fill', function (d) {
|
|
243
|
+
return d.background.color;
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}, {
|
|
247
|
+
key: "drawTypeText",
|
|
248
|
+
value: function drawTypeText(selection) {
|
|
249
|
+
var _this3 = this;
|
|
250
|
+
|
|
251
|
+
return selection.attr("x", function (d) {
|
|
252
|
+
return d.padding + d.name.size.w + 11 + d.type.padding;
|
|
253
|
+
}).attr("y", function (d) {
|
|
254
|
+
return d.type.position.y + d.type.padding + _this3["default"]().line.font.size;
|
|
255
|
+
}).attr("fill", function (d) {
|
|
256
|
+
return '#fff';
|
|
257
|
+
}).text(function (d) {
|
|
258
|
+
return d.type.contents;
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
}, {
|
|
262
|
+
key: "drawType",
|
|
263
|
+
value: function drawType(groups) {
|
|
264
|
+
var rects = groups.append('rect').attr('class', 'entity-type');
|
|
265
|
+
this.drawTypeRect(rects);
|
|
266
|
+
var texts = groups.append('text').attr('class', 'entity-type');
|
|
267
|
+
this.drawTypeText(texts).each(function (d) {
|
|
268
|
+
var w = this.getBBox().width;
|
|
269
|
+
if (w > (d.type._max_w || 0)) d.type._max_w = w;
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
/* ************************************ *
|
|
273
|
+
* Identifiers *
|
|
274
|
+
* ************************************ */
|
|
275
|
+
|
|
276
|
+
}, {
|
|
277
|
+
key: "drawIdentifiersRect",
|
|
278
|
+
value: function drawIdentifiersRect(rects) {
|
|
279
|
+
rects.attr('x', function (d) {
|
|
280
|
+
return d.identifiers.position.x;
|
|
281
|
+
}).attr('y', function (d) {
|
|
282
|
+
return d.identifiers.position.y;
|
|
283
|
+
}).attr('width', function (d) {
|
|
284
|
+
return d.identifiers.size.w;
|
|
285
|
+
}).attr('height', function (d) {
|
|
286
|
+
return d.identifiers.size.h;
|
|
287
|
+
}).attr('rx', function (d) {
|
|
288
|
+
return 2;
|
|
289
|
+
}).attr('ry', function (d) {
|
|
290
|
+
return 2;
|
|
291
|
+
}).attr('fill', function (d) {
|
|
292
|
+
return d.identifiers.background.color;
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
}, {
|
|
296
|
+
key: "drawIdentifiersText",
|
|
297
|
+
value: function drawIdentifiersText(texts) {
|
|
298
|
+
return texts.attr("x", function (d) {
|
|
299
|
+
return d.position.x;
|
|
300
|
+
}).attr("y", function (d) {
|
|
301
|
+
return d.position.y;
|
|
302
|
+
}).text(function (d) {
|
|
303
|
+
return d.name.val();
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
}, {
|
|
307
|
+
key: "drawIdentifiers",
|
|
308
|
+
value: function drawIdentifiers(groups) {
|
|
309
|
+
var rects = groups.append('rect').attr('class', 'entity-identifiers');
|
|
310
|
+
this.drawIdentifiersRect(rects);
|
|
311
|
+
var texts = groups.selectAll('text.identifier').data(function (d) {
|
|
312
|
+
return d.identifiers.contents.list;
|
|
313
|
+
}).enter().append('text').attr('class', 'identifier').attr('identifier-id', function (d) {
|
|
314
|
+
return d._id;
|
|
315
|
+
});
|
|
316
|
+
this.drawIdentifiersText(texts).each(function (identifier) {
|
|
317
|
+
var w = this.getBBox().width;
|
|
318
|
+
if (w > identifier._entity._max_w.identifier) identifier._entity._max_w.identifier = w;
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
/* ************************************ *
|
|
322
|
+
* Attributes *
|
|
323
|
+
* ************************************ */
|
|
324
|
+
|
|
325
|
+
}, {
|
|
326
|
+
key: "drawAttributesRect",
|
|
327
|
+
value: function drawAttributesRect(rects) {
|
|
328
|
+
rects.attr('x', function (d) {
|
|
329
|
+
return d.attributes.position.x;
|
|
330
|
+
}).attr('y', function (d) {
|
|
331
|
+
return d.attributes.position.y;
|
|
332
|
+
}).attr('width', function (d) {
|
|
333
|
+
return d.attributes.size.w;
|
|
334
|
+
}).attr('height', function (d) {
|
|
335
|
+
return d.attributes.size.h;
|
|
336
|
+
}).attr('rx', function (d) {
|
|
337
|
+
return 3;
|
|
338
|
+
}).attr('ry', function (d) {
|
|
339
|
+
return 3;
|
|
340
|
+
}).attr('fill', function (d) {
|
|
341
|
+
return d.identifiers.background.color;
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
}, {
|
|
345
|
+
key: "drawAttributesText",
|
|
346
|
+
value: function drawAttributesText(texts) {
|
|
347
|
+
return texts.attr("x", function (d) {
|
|
348
|
+
return d.position.x;
|
|
349
|
+
}).attr("y", function (d) {
|
|
350
|
+
return d.position.y;
|
|
351
|
+
}).text(function (d) {
|
|
352
|
+
return d.name.val();
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
}, {
|
|
356
|
+
key: "drawAttributes",
|
|
357
|
+
value: function drawAttributes(groups) {
|
|
358
|
+
var rects = groups.append('rect').attr('class', 'entity-attributes');
|
|
359
|
+
this.drawAttributesRect(rects);
|
|
360
|
+
var texts = groups.selectAll('text.attribute').data(function (d) {
|
|
361
|
+
return d.attributes.contents.list;
|
|
362
|
+
}).enter().append('text').attr('class', 'attribute').attr('attribute-id', function (d) {
|
|
363
|
+
return d._id;
|
|
364
|
+
});
|
|
365
|
+
this.drawAttributesText(texts).each(function (attribute) {
|
|
366
|
+
var w = this.getBBox().width;
|
|
367
|
+
if (w > attribute._entity._max_w.attribute) attribute._entity._max_w.attribute = w;
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
/* ************************************ *
|
|
371
|
+
* Main
|
|
372
|
+
* ************************************ */
|
|
373
|
+
|
|
374
|
+
}, {
|
|
375
|
+
key: "redraw",
|
|
376
|
+
value: function redraw(groups) {
|
|
377
|
+
this.drawBodyCore(groups.selectAll('rect.entity-body'));
|
|
378
|
+
this.drawNameRect(groups.selectAll('rect.entity-title'));
|
|
379
|
+
this.drawNameText(groups.selectAll('text.entity-title'));
|
|
380
|
+
this.drawTypeRect(groups.selectAll('rect.entity-type'));
|
|
381
|
+
this.drawTypeText(groups.selectAll('text.entity-type'));
|
|
382
|
+
this.drawIdentifiersRect(groups.selectAll('rect.entity-identifiers'));
|
|
383
|
+
this.drawIdentifiersText(groups.selectAll('text.identifier'));
|
|
384
|
+
this.drawAttributesRect(groups.selectAll('rect.entity-attributes'));
|
|
385
|
+
this.drawAttributesText(groups.selectAll('text.attribute'));
|
|
386
|
+
}
|
|
387
|
+
}, {
|
|
388
|
+
key: "draw",
|
|
389
|
+
value: function draw(entities) {
|
|
390
|
+
var groups = this.drawGroup(entities);
|
|
391
|
+
this.drawBody(groups);
|
|
392
|
+
this.drawName(groups);
|
|
393
|
+
this.drawType(groups);
|
|
394
|
+
this.drawIdentifiers(groups);
|
|
395
|
+
this.drawAttributes(groups); // resizing & redraw
|
|
396
|
+
|
|
397
|
+
groups.each(function (entity) {
|
|
398
|
+
return entity.reSizing().positioning();
|
|
399
|
+
});
|
|
400
|
+
this.redraw(groups);
|
|
401
|
+
return groups;
|
|
402
|
+
}
|
|
403
|
+
}]);
|
|
404
|
+
|
|
405
|
+
return Entity;
|
|
406
|
+
}();
|
|
407
|
+
|
|
408
|
+
exports["default"] = Entity;
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _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(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
+
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
21
|
+
|
|
22
|
+
var Ports = /*#__PURE__*/function () {
|
|
23
|
+
function Ports() {
|
|
24
|
+
_classCallCheck(this, Ports);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
_createClass(Ports, [{
|
|
28
|
+
key: "drawLine",
|
|
29
|
+
value:
|
|
30
|
+
/* **************************************************************** *
|
|
31
|
+
* Draw
|
|
32
|
+
* **************************************************************** */
|
|
33
|
+
function drawLine(g) {
|
|
34
|
+
var _this = this;
|
|
35
|
+
|
|
36
|
+
var lines = g.selectAll('line').data(function (d) {
|
|
37
|
+
return d._ports ? d._ports : [];
|
|
38
|
+
}, function (d) {
|
|
39
|
+
return d._id;
|
|
40
|
+
}); // delete
|
|
41
|
+
|
|
42
|
+
lines.exit().remove(); // update
|
|
43
|
+
|
|
44
|
+
lines.each(function (d, i) {
|
|
45
|
+
var line = _this.calLinePoints(d);
|
|
46
|
+
|
|
47
|
+
d.position = line.to;
|
|
48
|
+
d.line = line;
|
|
49
|
+
}).attr("x1", function (d) {
|
|
50
|
+
return d.line.from.x;
|
|
51
|
+
}).attr("y1", function (d) {
|
|
52
|
+
return d.line.from.y;
|
|
53
|
+
}).attr("x2", function (d) {
|
|
54
|
+
return d.line.to.x;
|
|
55
|
+
}).attr("y2", function (d) {
|
|
56
|
+
return d.line.to.y;
|
|
57
|
+
}).attr("stroke-width", 3).attr("stroke", "#a3a3a2"); // add
|
|
58
|
+
|
|
59
|
+
lines.enter().each(function (d, i) {
|
|
60
|
+
var line = _this.calLinePoints(d);
|
|
61
|
+
|
|
62
|
+
d.position = line.to;
|
|
63
|
+
d.line = line;
|
|
64
|
+
}).append("line").attr("x1", function (d) {
|
|
65
|
+
return d.line.from.x;
|
|
66
|
+
}).attr("y1", function (d) {
|
|
67
|
+
return d.line.from.y;
|
|
68
|
+
}).attr("x2", function (d) {
|
|
69
|
+
return d.line.to.x;
|
|
70
|
+
}).attr("y2", function (d) {
|
|
71
|
+
return d.line.to.y;
|
|
72
|
+
}).attr("stroke-width", 3).attr("stroke", "#a3a3a2");
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
key: "drawCardinalityOne",
|
|
76
|
+
value: function drawCardinalityOne(g) {
|
|
77
|
+
var _this2 = this;
|
|
78
|
+
|
|
79
|
+
var filter = function filter() {
|
|
80
|
+
var ports = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
81
|
+
return ports.filter(function (d) {
|
|
82
|
+
return d.cardinality === 1;
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
var optionalities = g.selectAll('line.cardinality').data(function (d) {
|
|
87
|
+
return filter(d._ports);
|
|
88
|
+
}, function (d) {
|
|
89
|
+
return d._id;
|
|
90
|
+
});
|
|
91
|
+
optionalities.attr("x1", function (d) {
|
|
92
|
+
return d.line_cardinality.from.x;
|
|
93
|
+
}).attr("y1", function (d) {
|
|
94
|
+
return d.line_cardinality.from.y;
|
|
95
|
+
}).attr("x2", function (d) {
|
|
96
|
+
return d.line_cardinality.to.x;
|
|
97
|
+
}).attr("y2", function (d) {
|
|
98
|
+
return d.line_cardinality.to.y;
|
|
99
|
+
}).attr("stroke-width", 3).attr("stroke", "#a3a3a2");
|
|
100
|
+
optionalities.enter().each(function (d) {
|
|
101
|
+
return d.line_cardinality = _this2.calOneLine(d, 11);
|
|
102
|
+
}).append('line').classed("cardinality", true).attr("x1", function (d) {
|
|
103
|
+
return d.line_cardinality.from.x;
|
|
104
|
+
}).attr("y1", function (d) {
|
|
105
|
+
return d.line_cardinality.from.y;
|
|
106
|
+
}).attr("x2", function (d) {
|
|
107
|
+
return d.line_cardinality.to.x;
|
|
108
|
+
}).attr("y2", function (d) {
|
|
109
|
+
return d.line_cardinality.to.y;
|
|
110
|
+
}).attr("stroke-width", 3).attr("stroke", "#a3a3a2");
|
|
111
|
+
}
|
|
112
|
+
}, {
|
|
113
|
+
key: "drawCardinalityThree",
|
|
114
|
+
value: function drawCardinalityThree(g) {
|
|
115
|
+
var _this3 = this;
|
|
116
|
+
|
|
117
|
+
var filter = function filter() {
|
|
118
|
+
var ports = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
119
|
+
return ports.filter(function (d) {
|
|
120
|
+
return d.cardinality === 3;
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
var optionalities = g.selectAll('path.cardinality').data(function (d) {
|
|
125
|
+
return filter(d._ports);
|
|
126
|
+
}, function (d) {
|
|
127
|
+
return d._id;
|
|
128
|
+
});
|
|
129
|
+
var line = d3.line().x(function (d) {
|
|
130
|
+
return d[0];
|
|
131
|
+
}).y(function (d) {
|
|
132
|
+
return d[1];
|
|
133
|
+
});
|
|
134
|
+
optionalities.each(function (d) {
|
|
135
|
+
return d.line_cardinality_three = _this3.calThreeLine(d, 11);
|
|
136
|
+
}).attr('d', function (d) {
|
|
137
|
+
return line(d.line_cardinality_three);
|
|
138
|
+
}).attr("stroke-width", 3).attr("stroke", "#a3a3a2");
|
|
139
|
+
optionalities.enter().each(function (d) {
|
|
140
|
+
return d.line_cardinality_three = _this3.calThreeLine(d, 11);
|
|
141
|
+
}).append('path').classed("cardinality", true).attr('d', function (d) {
|
|
142
|
+
return line(d.line_cardinality_three);
|
|
143
|
+
}).attr("fill", 'none').attr("stroke-width", 3).attr("stroke", "#a3a3a2");
|
|
144
|
+
}
|
|
145
|
+
}, {
|
|
146
|
+
key: "drawCardinality",
|
|
147
|
+
value: function drawCardinality(g) {
|
|
148
|
+
// E1のインスタンス1つに対応する、E2のインスタンスの最大数
|
|
149
|
+
this.drawCardinalityOne(g);
|
|
150
|
+
this.drawCardinalityThree(g);
|
|
151
|
+
}
|
|
152
|
+
}, {
|
|
153
|
+
key: "drawOptionalityOne",
|
|
154
|
+
value: function drawOptionalityOne(g) {
|
|
155
|
+
var _this4 = this;
|
|
156
|
+
|
|
157
|
+
var filter = function filter() {
|
|
158
|
+
var ports = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
159
|
+
return ports.filter(function (d) {
|
|
160
|
+
return d.optionality === 1;
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
var optionalities = g.selectAll('line.optionality').data(function (d) {
|
|
165
|
+
return filter(d._ports);
|
|
166
|
+
}, function (d) {
|
|
167
|
+
return d._id;
|
|
168
|
+
});
|
|
169
|
+
optionalities.enter().each(function (d) {
|
|
170
|
+
return d.line_optionality = _this4.calOneLine(d, 22);
|
|
171
|
+
}).append('line').classed("optionality", true).attr("x1", function (d) {
|
|
172
|
+
return d.line_optionality.from.x;
|
|
173
|
+
}).attr("y1", function (d) {
|
|
174
|
+
return d.line_optionality.from.y;
|
|
175
|
+
}).attr("x2", function (d) {
|
|
176
|
+
return d.line_optionality.to.x;
|
|
177
|
+
}).attr("y2", function (d) {
|
|
178
|
+
return d.line_optionality.to.y;
|
|
179
|
+
}).attr("stroke-width", 3).attr("stroke", "#a3a3a2");
|
|
180
|
+
}
|
|
181
|
+
}, {
|
|
182
|
+
key: "drawOptionalityZero",
|
|
183
|
+
value: function drawOptionalityZero(g) {
|
|
184
|
+
var _this5 = this;
|
|
185
|
+
|
|
186
|
+
var filter = function filter() {
|
|
187
|
+
var ports = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
188
|
+
return ports.filter(function (d) {
|
|
189
|
+
return d.optionality === 0;
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
var optionalities = g.selectAll('circle.optionality').data(function (d) {
|
|
194
|
+
return filter(d._ports);
|
|
195
|
+
}, function (d) {
|
|
196
|
+
return d._id;
|
|
197
|
+
});
|
|
198
|
+
optionalities.each(function (d) {
|
|
199
|
+
return d.line_circle = _this5.calCircle(d);
|
|
200
|
+
}).attr("cx", function (d) {
|
|
201
|
+
return d.line_circle.x;
|
|
202
|
+
}).attr("cy", function (d) {
|
|
203
|
+
return d.line_circle.y;
|
|
204
|
+
}).attr("r", 5).attr("fill", "#fefefe").attr("stroke-width", 3).attr("stroke", "#a3a3a2");
|
|
205
|
+
optionalities.enter().each(function (d) {
|
|
206
|
+
return d.line_circle = _this5.calCircle(d);
|
|
207
|
+
}).append("circle").classed("optionality", true).attr("cx", function (d) {
|
|
208
|
+
return d.line_circle.x;
|
|
209
|
+
}).attr("cy", function (d) {
|
|
210
|
+
return d.line_circle.y;
|
|
211
|
+
}).attr("r", 5).attr("fill", "#fefefe").attr("stroke-width", 3).attr("stroke", "#a3a3a2");
|
|
212
|
+
}
|
|
213
|
+
}, {
|
|
214
|
+
key: "drawOptionality",
|
|
215
|
+
value: function drawOptionality(g) {
|
|
216
|
+
// E1のインスタンス1つに対応する、E2のインスタンスの最小数
|
|
217
|
+
this.drawOptionalityOne(g);
|
|
218
|
+
this.drawOptionalityZero(g);
|
|
219
|
+
} // draw (g) {
|
|
220
|
+
// this.drawLine(g);
|
|
221
|
+
// this.drawCardinality(g);
|
|
222
|
+
// this.drawOptionality(g);
|
|
223
|
+
// }
|
|
224
|
+
|
|
225
|
+
/* **************************************************************** *
|
|
226
|
+
* Old
|
|
227
|
+
* **************************************************************** */
|
|
228
|
+
// protected
|
|
229
|
+
|
|
230
|
+
}, {
|
|
231
|
+
key: "drawPortsCore",
|
|
232
|
+
value: function drawPortsCore(ports) {
|
|
233
|
+
ports.attr('class', 'entity-port').attr('cx', function (d) {
|
|
234
|
+
return d.position.x;
|
|
235
|
+
}).attr('cy', function (d) {
|
|
236
|
+
return d.position.y;
|
|
237
|
+
}).attr('r', 4).attr('fill', '#fff').attr('stroke', '#000').attr('stroke-width', 0.5).attr('degree', function (d) {
|
|
238
|
+
return d._owner._core.position || 0;
|
|
239
|
+
}).attr('port-id', function (d) {
|
|
240
|
+
return d._id;
|
|
241
|
+
});
|
|
242
|
+
} // public
|
|
243
|
+
|
|
244
|
+
}, {
|
|
245
|
+
key: "drawPorts",
|
|
246
|
+
value: function drawPorts(groups) {
|
|
247
|
+
var ports = groups.selectAll('circle.entity-port').data(function (d) {
|
|
248
|
+
return d.ports.items.list;
|
|
249
|
+
}).enter().append('circle');
|
|
250
|
+
this.drawPortsCore(ports);
|
|
251
|
+
}
|
|
252
|
+
}]);
|
|
253
|
+
|
|
254
|
+
return Ports;
|
|
255
|
+
}();
|
|
256
|
+
|
|
257
|
+
exports["default"] = Ports;
|