@yanqirenshi/d3.ter 0.0.4 → 0.0.8
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/js/EntityTailor.js +4 -4
- package/dist/js/Painter.js +66 -37
- package/dist/js/Port.js +3 -1
- package/dist/js/Rectum.js +20 -7
- package/package.json +3 -2
package/dist/js/EntityTailor.js
CHANGED
|
@@ -524,9 +524,9 @@ var EntityTailor = /*#__PURE__*/function (_Builder) {
|
|
|
524
524
|
key: "positioningColumnItems",
|
|
525
525
|
value: function positioningColumnItems(d) {
|
|
526
526
|
var padding = d.padding;
|
|
527
|
-
var start = d.position.y;
|
|
527
|
+
var start = d.position.y + padding;
|
|
528
528
|
var line_height = this._default.line.height;
|
|
529
|
-
var
|
|
529
|
+
var num = 0;
|
|
530
530
|
|
|
531
531
|
var _iterator3 = _createForOfIteratorHelper(d.contents.list),
|
|
532
532
|
_step3;
|
|
@@ -536,8 +536,8 @@ var EntityTailor = /*#__PURE__*/function (_Builder) {
|
|
|
536
536
|
var item = _step3.value;
|
|
537
537
|
item.position.x = d.position.x + padding;
|
|
538
538
|
var item_h = line_height + item.name.padding * 2;
|
|
539
|
-
item.position.y = start +
|
|
540
|
-
|
|
539
|
+
item.position.y = start + num * item_h + item.name.padding;
|
|
540
|
+
num++;
|
|
541
541
|
}
|
|
542
542
|
} catch (err) {
|
|
543
543
|
_iterator3.e(err);
|
package/dist/js/Painter.js
CHANGED
|
@@ -20,9 +20,12 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
20
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
21
|
|
|
22
22
|
var Painter = /*#__PURE__*/function () {
|
|
23
|
-
function Painter() {
|
|
23
|
+
function Painter(foreground, background, callbacks) {
|
|
24
24
|
_classCallCheck(this, Painter);
|
|
25
25
|
|
|
26
|
+
this.foreground = foreground;
|
|
27
|
+
this.background = background;
|
|
28
|
+
this.callbacks = callbacks;
|
|
26
29
|
this._default = {
|
|
27
30
|
line: {
|
|
28
31
|
height: 14,
|
|
@@ -39,48 +42,70 @@ var Painter = /*#__PURE__*/function () {
|
|
|
39
42
|
|
|
40
43
|
_createClass(Painter, [{
|
|
41
44
|
key: "dragStart",
|
|
42
|
-
value: function dragStart(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
value: function dragStart(event, entity) {
|
|
46
|
+
entity._drag = {
|
|
47
|
+
start: {
|
|
48
|
+
x: event.x,
|
|
49
|
+
y: event.y
|
|
50
|
+
}
|
|
51
|
+
};
|
|
49
52
|
}
|
|
50
53
|
}, {
|
|
51
54
|
key: "dragged",
|
|
52
|
-
value: function dragged(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
value: function dragged(event, entity) {
|
|
56
|
+
entity.position.x += event.x - entity._drag.start.x;
|
|
57
|
+
entity.position.y += event.y - entity._drag.start.y;
|
|
58
|
+
this.moveEntity(entity);
|
|
59
|
+
this.moveEdges(entity);
|
|
56
60
|
}
|
|
57
61
|
}, {
|
|
58
62
|
key: "dragEnd",
|
|
59
|
-
value: function dragEnd(entity) {
|
|
60
|
-
//
|
|
61
|
-
// ACTIONS.saveTerEntityPosition(campus, entity);
|
|
63
|
+
value: function dragEnd(event, entity) {
|
|
64
|
+
// let campus = STORE.get('active.ter.campus');
|
|
65
|
+
delete entity._drag; // ACTIONS.saveTerEntityPosition(campus, entity);
|
|
62
66
|
}
|
|
63
67
|
}, {
|
|
64
|
-
key: "
|
|
65
|
-
value: function
|
|
68
|
+
key: "addMoveEvents",
|
|
69
|
+
value: function addMoveEvents(body) {
|
|
66
70
|
var _this = this;
|
|
67
71
|
|
|
68
|
-
return body.call(d3.drag().on("start", function (d) {
|
|
69
|
-
return _this.dragStart(d);
|
|
70
|
-
}).on("drag", function (d) {
|
|
71
|
-
return _this.dragged(d);
|
|
72
|
-
}).on("end", function (d) {
|
|
73
|
-
return _this.dragEnd(d);
|
|
72
|
+
return body.call(d3.drag().on("start", function (e, d) {
|
|
73
|
+
return _this.dragStart(e, d);
|
|
74
|
+
}).on("drag", function (e, d) {
|
|
75
|
+
return _this.dragged(e, d);
|
|
76
|
+
}).on("end", function (e, d) {
|
|
77
|
+
return _this.dragEnd(e, d);
|
|
74
78
|
}));
|
|
75
79
|
}
|
|
80
|
+
}, {
|
|
81
|
+
key: "moveEntity",
|
|
82
|
+
value: function moveEntity(entity) {
|
|
83
|
+
var selection = this.foreground.selectAll('g.entity').data([entity], function (d) {
|
|
84
|
+
return d._id;
|
|
85
|
+
});
|
|
86
|
+
selection.attr('transform', function (d) {
|
|
87
|
+
return 'translate(' + d.position.x + ',' + d.position.y + ')';
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}, {
|
|
91
|
+
key: "moveEdges",
|
|
92
|
+
value: function moveEdges(entity) {
|
|
93
|
+
var edges = entity.ports.items.list.map(function (p) {
|
|
94
|
+
return p._relationship;
|
|
95
|
+
});
|
|
96
|
+
var selection = this.background.selectAll('line.connector').data(edges, function (d) {
|
|
97
|
+
return d._id;
|
|
98
|
+
});
|
|
99
|
+
this.drawRelationshipsCore(selection);
|
|
100
|
+
}
|
|
76
101
|
/* **************************************************************** *
|
|
77
102
|
* Draw this.entity
|
|
78
103
|
* **************************************************************** */
|
|
79
104
|
|
|
80
105
|
}, {
|
|
81
106
|
key: "drawGroup",
|
|
82
|
-
value: function drawGroup(
|
|
83
|
-
return
|
|
107
|
+
value: function drawGroup(data) {
|
|
108
|
+
return this.foreground.selectAll('g.entity').data(data, function (d) {
|
|
84
109
|
return d._id;
|
|
85
110
|
}).enter().append('g').attr('class', 'entity').attr('entity-id', function (d) {
|
|
86
111
|
return d._id;
|
|
@@ -116,7 +141,7 @@ var Painter = /*#__PURE__*/function () {
|
|
|
116
141
|
value: function drawBody(groups) {
|
|
117
142
|
var body = groups.append('rect');
|
|
118
143
|
this.drawBodyCore(body);
|
|
119
|
-
return
|
|
144
|
+
return body;
|
|
120
145
|
}
|
|
121
146
|
/* ************************************ *
|
|
122
147
|
* Name *
|
|
@@ -146,7 +171,7 @@ var Painter = /*#__PURE__*/function () {
|
|
|
146
171
|
value: function drawNameText(texts) {
|
|
147
172
|
var _this2 = this;
|
|
148
173
|
|
|
149
|
-
|
|
174
|
+
texts.attr('class', 'entity-title').attr("x", function (d) {
|
|
150
175
|
return d.padding + d.name.padding;
|
|
151
176
|
}).attr("y", function (d) {
|
|
152
177
|
return d.padding + d.name.padding + _this2._default.line.font.size;
|
|
@@ -157,16 +182,19 @@ var Painter = /*#__PURE__*/function () {
|
|
|
157
182
|
}).text(function (d) {
|
|
158
183
|
return d.name.val();
|
|
159
184
|
});
|
|
185
|
+
this.addMoveEvents(texts);
|
|
186
|
+
return texts;
|
|
160
187
|
}
|
|
161
188
|
}, {
|
|
162
189
|
key: "drawName",
|
|
163
|
-
value: function drawName(groups
|
|
164
|
-
var
|
|
190
|
+
value: function drawName(groups) {
|
|
191
|
+
var callbacks = this.callbacks;
|
|
192
|
+
var rects = groups.append('rect').on("click", function (event, d) {
|
|
165
193
|
var func = callbacks.entity.click;
|
|
166
194
|
if (func) func(d);
|
|
167
195
|
}).attr('class', 'entity-title');
|
|
168
196
|
this.drawNameRect(rects);
|
|
169
|
-
var texts = groups.append('text').on("click", function (d) {
|
|
197
|
+
var texts = groups.append('text').on("click", function (event, d) {
|
|
170
198
|
var func = callbacks.entity.click;
|
|
171
199
|
if (func) func(d);
|
|
172
200
|
}).attr('class', 'entity-title');
|
|
@@ -245,9 +273,9 @@ var Painter = /*#__PURE__*/function () {
|
|
|
245
273
|
}).attr('height', function (d) {
|
|
246
274
|
return d.identifiers.size.h;
|
|
247
275
|
}).attr('rx', function (d) {
|
|
248
|
-
return
|
|
276
|
+
return 2;
|
|
249
277
|
}).attr('ry', function (d) {
|
|
250
|
-
return
|
|
278
|
+
return 2;
|
|
251
279
|
}).attr('fill', function (d) {
|
|
252
280
|
return d.identifiers.background.color;
|
|
253
281
|
});
|
|
@@ -379,7 +407,8 @@ var Painter = /*#__PURE__*/function () {
|
|
|
379
407
|
}
|
|
380
408
|
}, {
|
|
381
409
|
key: "drawRelationships",
|
|
382
|
-
value: function drawRelationships(
|
|
410
|
+
value: function drawRelationships(relationships) {
|
|
411
|
+
var place = this.background;
|
|
383
412
|
var data = relationships.list.filter(function (edge) {
|
|
384
413
|
return edge.from._class === 'PORT-FROM' && edge.to._class === 'PORT-TO';
|
|
385
414
|
});
|
|
@@ -407,10 +436,10 @@ var Painter = /*#__PURE__*/function () {
|
|
|
407
436
|
}
|
|
408
437
|
}, {
|
|
409
438
|
key: "draw",
|
|
410
|
-
value: function draw(
|
|
411
|
-
var groups = this.drawGroup(
|
|
439
|
+
value: function draw(entities, relationsihps) {
|
|
440
|
+
var groups = this.drawGroup(entities.list);
|
|
412
441
|
this.drawBody(groups);
|
|
413
|
-
this.drawName(groups
|
|
442
|
+
this.drawName(groups);
|
|
414
443
|
this.drawType(groups);
|
|
415
444
|
this.drawIdentifiers(groups);
|
|
416
445
|
this.drawAttributes(groups); // resizing & redraw
|
|
@@ -420,7 +449,7 @@ var Painter = /*#__PURE__*/function () {
|
|
|
420
449
|
});
|
|
421
450
|
this.redraw(groups);
|
|
422
451
|
this.drawPorts(groups);
|
|
423
|
-
this.drawRelationships(
|
|
452
|
+
this.drawRelationships(relationsihps);
|
|
424
453
|
}
|
|
425
454
|
}]);
|
|
426
455
|
|
package/dist/js/Port.js
CHANGED
|
@@ -45,6 +45,8 @@ var Port = /*#__PURE__*/function (_Atman) {
|
|
|
45
45
|
_this._id = owner._id; // Idenrifier-Instance
|
|
46
46
|
|
|
47
47
|
_this._owner = owner;
|
|
48
|
+
_this._type = type;
|
|
49
|
+
_this._core = data[type];
|
|
48
50
|
_this.position = data.position || {
|
|
49
51
|
x: 0,
|
|
50
52
|
y: 0
|
|
@@ -59,7 +61,7 @@ var Port = /*#__PURE__*/function (_Atman) {
|
|
|
59
61
|
_createClass(Port, [{
|
|
60
62
|
key: "position_degree",
|
|
61
63
|
value: function position_degree() {
|
|
62
|
-
return this.
|
|
64
|
+
return this._core.position % 360;
|
|
63
65
|
}
|
|
64
66
|
}]);
|
|
65
67
|
|
package/dist/js/Rectum.js
CHANGED
|
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports["default"] = void 0;
|
|
9
9
|
|
|
10
|
+
var _deepmerge = _interopRequireDefault(require("deepmerge"));
|
|
11
|
+
|
|
10
12
|
var _assh0le = require("@yanqirenshi/assh0le");
|
|
11
13
|
|
|
12
14
|
var _Entity = _interopRequireDefault(require("./Entity.js"));
|
|
@@ -68,6 +70,7 @@ var Rectum = /*#__PURE__*/function (_Colon) {
|
|
|
68
70
|
_classCallCheck(this, Rectum);
|
|
69
71
|
|
|
70
72
|
_this = _super.call(this, params);
|
|
73
|
+
_this.callbacks = _this.ensureCallbacks(params.callbacks);
|
|
71
74
|
_this._entities = POOL.make();
|
|
72
75
|
_this._relationships = POOL.make();
|
|
73
76
|
_this._default = {
|
|
@@ -82,6 +85,16 @@ var Rectum = /*#__PURE__*/function (_Colon) {
|
|
|
82
85
|
}
|
|
83
86
|
|
|
84
87
|
_createClass(Rectum, [{
|
|
88
|
+
key: "ensureCallbacks",
|
|
89
|
+
value: function ensureCallbacks(callbacks) {
|
|
90
|
+
var template = {
|
|
91
|
+
entity: {
|
|
92
|
+
click: null
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
return (0, _deepmerge["default"])(template, callbacks);
|
|
96
|
+
}
|
|
97
|
+
}, {
|
|
85
98
|
key: "entities",
|
|
86
99
|
value: function entities() {
|
|
87
100
|
return this._entities;
|
|
@@ -126,12 +139,12 @@ var Rectum = /*#__PURE__*/function (_Colon) {
|
|
|
126
139
|
|
|
127
140
|
try {
|
|
128
141
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
129
|
-
var
|
|
130
|
-
var id_from = this.getIdentifier(
|
|
131
|
-
var id_to = this.getIdentifier(
|
|
132
|
-
var port_from = new _Port["default"]('from', id_from,
|
|
133
|
-
var port_to = new _Port["default"]('to', id_to,
|
|
134
|
-
var element = new _Relationship["default"](
|
|
142
|
+
var r = _step2.value;
|
|
143
|
+
var id_from = this.getIdentifier(r.from.id, entities);
|
|
144
|
+
var id_to = this.getIdentifier(r.to.id, entities);
|
|
145
|
+
var port_from = new _Port["default"]('from', id_from, r);
|
|
146
|
+
var port_to = new _Port["default"]('to', id_to, r);
|
|
147
|
+
var element = new _Relationship["default"](r, port_from, port_to);
|
|
135
148
|
var entity_from = id_from._entity;
|
|
136
149
|
var entity_to = id_to._entity;
|
|
137
150
|
port_from._entity = entity_from;
|
|
@@ -181,7 +194,7 @@ var Rectum = /*#__PURE__*/function (_Colon) {
|
|
|
181
194
|
value: function draw() {
|
|
182
195
|
var fore = this.layer('foreground');
|
|
183
196
|
var back = this.layer('background');
|
|
184
|
-
new _Painter["default"](
|
|
197
|
+
new _Painter["default"](fore, back, this.callbacks).draw(this.entities(), this._relationships);
|
|
185
198
|
}
|
|
186
199
|
}]);
|
|
187
200
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yanqirenshi/d3.ter",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"author": "yanqirenshi@gmail.com",
|
|
5
5
|
"license": "GPL-3.0-or-later",
|
|
6
6
|
"description": "See `src/index.html`",
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"react-dom": "^17.0.1"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@yanqirenshi/assh0le": "0.2.10"
|
|
29
|
+
"@yanqirenshi/assh0le": "0.2.10",
|
|
30
|
+
"deepmerge": "^4.2.2"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
33
|
"@babel/cli": "^7.12.10",
|