@yanqirenshi/d3.ter 0.1.19 → 0.1.21
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.d.ts +16 -0
- package/dist/js/Painters/PortCardinalities.js +3 -3
- package/dist/js/Painters/PortCircles.js +6 -5
- package/dist/js/Painters/PortOptionalities.js +6 -5
- package/dist/js/Painters/Ports.js +13 -0
- package/dist/js/Painters/Relationships.js +213 -6
- package/dist/js/Relationship.js +21 -2
- package/package.json +1 -1
- package/tests/Rectum.test.js +43 -0
package/dist/index.d.ts
CHANGED
|
@@ -97,6 +97,18 @@ export interface TerRelationshipDetail {
|
|
|
97
97
|
to: { id: number | string; description?: string };
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
/**
|
|
101
|
+
* サブセット結線の区分コード表記(TM)。
|
|
102
|
+
* kind 'same' → =区分コード(同一のサブセット: 属性構成が同じ)
|
|
103
|
+
* kind 'different' → ×区分コード(相違のサブセット: 属性構成が異なる)
|
|
104
|
+
* 線の中点にラベルとして描画される。
|
|
105
|
+
*/
|
|
106
|
+
export interface TerSubset {
|
|
107
|
+
kind: 'same' | 'different';
|
|
108
|
+
/** 区分コード名(例: '行種別') */
|
|
109
|
+
code: string;
|
|
110
|
+
}
|
|
111
|
+
|
|
100
112
|
/** エンティティ間のリレーションシップ */
|
|
101
113
|
export interface TerRelationship {
|
|
102
114
|
id: number | string;
|
|
@@ -105,6 +117,10 @@ export interface TerRelationship {
|
|
|
105
117
|
to: TerRelationshipEnd;
|
|
106
118
|
/** 省略時は先頭の識別子インスタンスに取り付く */
|
|
107
119
|
details?: TerRelationshipDetail[];
|
|
120
|
+
/** サブセットへの結線に区分コード(= / ×)を表示する(任意) */
|
|
121
|
+
subset?: TerSubset;
|
|
122
|
+
/** 結線の中点に表示するラベル(任意。subset 指定時は区分コードが優先され表示されない) */
|
|
123
|
+
label?: string;
|
|
108
124
|
description?: string;
|
|
109
125
|
}
|
|
110
126
|
|
|
@@ -35,7 +35,7 @@ var PortCardinalities = exports["default"] = /*#__PURE__*/function () {
|
|
|
35
35
|
value: function drawLine(g) {
|
|
36
36
|
var _this = this;
|
|
37
37
|
var lines = g.selectAll('line').data(function (d) {
|
|
38
|
-
return
|
|
38
|
+
return _this._parent.visiblePorts(d);
|
|
39
39
|
}, function (d) {
|
|
40
40
|
return d.id();
|
|
41
41
|
});
|
|
@@ -74,7 +74,7 @@ var PortCardinalities = exports["default"] = /*#__PURE__*/function () {
|
|
|
74
74
|
});
|
|
75
75
|
};
|
|
76
76
|
var cardinalities = g.selectAll('line.cardinality').data(function (d) {
|
|
77
|
-
return filter(
|
|
77
|
+
return filter(_this2._parent.visiblePorts(d));
|
|
78
78
|
}, function (d) {
|
|
79
79
|
return d.id();
|
|
80
80
|
});
|
|
@@ -111,7 +111,7 @@ var PortCardinalities = exports["default"] = /*#__PURE__*/function () {
|
|
|
111
111
|
});
|
|
112
112
|
};
|
|
113
113
|
var cardinalities = g.selectAll('path.cardinality').data(function (d) {
|
|
114
|
-
return filter(
|
|
114
|
+
return filter(_this3._parent.visiblePorts(d));
|
|
115
115
|
}, function (d) {
|
|
116
116
|
return d.id();
|
|
117
117
|
});
|
|
@@ -13,14 +13,14 @@ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r),
|
|
|
13
13
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
14
14
|
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); }
|
|
15
15
|
var PortCircles = exports["default"] = /*#__PURE__*/function () {
|
|
16
|
-
function PortCircles() {
|
|
16
|
+
function PortCircles(parent) {
|
|
17
17
|
_classCallCheck(this, PortCircles);
|
|
18
|
+
this._parent = parent;
|
|
18
19
|
}
|
|
20
|
+
// protected
|
|
19
21
|
return _createClass(PortCircles, [{
|
|
20
22
|
key: "drawPortsCore",
|
|
21
|
-
value:
|
|
22
|
-
// protected
|
|
23
|
-
function drawPortsCore(ports) {
|
|
23
|
+
value: function drawPortsCore(ports) {
|
|
24
24
|
ports.attr('class', 'entity-port').attr('cx', function (d) {
|
|
25
25
|
return d.position().x;
|
|
26
26
|
}).attr('cy', function (d) {
|
|
@@ -34,8 +34,9 @@ var PortCircles = exports["default"] = /*#__PURE__*/function () {
|
|
|
34
34
|
}, {
|
|
35
35
|
key: "draw",
|
|
36
36
|
value: function draw(groups_entity) {
|
|
37
|
+
var _this = this;
|
|
37
38
|
var ports = groups_entity.selectAll('circle.entity-port').data(function (d) {
|
|
38
|
-
return
|
|
39
|
+
return _this._parent.visiblePorts(d);
|
|
39
40
|
}).enter().append('circle');
|
|
40
41
|
this.drawPortsCore(ports);
|
|
41
42
|
}
|
|
@@ -30,8 +30,9 @@ var PortOptionalities = exports["default"] = /*#__PURE__*/function () {
|
|
|
30
30
|
}, {
|
|
31
31
|
key: "selections",
|
|
32
32
|
value: function selections(g, selector, filter) {
|
|
33
|
+
var _this = this;
|
|
33
34
|
return g.selectAll(selector).data(function (d) {
|
|
34
|
-
return filter(
|
|
35
|
+
return filter(_this._parent.visiblePorts(d));
|
|
35
36
|
}, function (d) {
|
|
36
37
|
return d.id();
|
|
37
38
|
});
|
|
@@ -39,7 +40,7 @@ var PortOptionalities = exports["default"] = /*#__PURE__*/function () {
|
|
|
39
40
|
}, {
|
|
40
41
|
key: "drawOptionalityOne",
|
|
41
42
|
value: function drawOptionalityOne(g) {
|
|
42
|
-
var
|
|
43
|
+
var _this2 = this;
|
|
43
44
|
var filter = function filter() {
|
|
44
45
|
var ports = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
45
46
|
return ports.filter(function (d) {
|
|
@@ -57,7 +58,7 @@ var PortOptionalities = exports["default"] = /*#__PURE__*/function () {
|
|
|
57
58
|
return d.optionalityPosition().to.x;
|
|
58
59
|
}).attr("y2", function (d) {
|
|
59
60
|
return d.optionalityPosition().to.y;
|
|
60
|
-
}).attr("stroke-width",
|
|
61
|
+
}).attr("stroke-width", _this2.style().port.stroke.width).attr("stroke", _this2.style().port.stroke.color);
|
|
61
62
|
};
|
|
62
63
|
|
|
63
64
|
// delete
|
|
@@ -73,7 +74,7 @@ var PortOptionalities = exports["default"] = /*#__PURE__*/function () {
|
|
|
73
74
|
}, {
|
|
74
75
|
key: "drawOptionalityZero",
|
|
75
76
|
value: function drawOptionalityZero(g) {
|
|
76
|
-
var
|
|
77
|
+
var _this3 = this;
|
|
77
78
|
var filter = function filter() {
|
|
78
79
|
var ports = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
79
80
|
return ports.filter(function (d) {
|
|
@@ -87,7 +88,7 @@ var PortOptionalities = exports["default"] = /*#__PURE__*/function () {
|
|
|
87
88
|
return d.optionalityPosition().x;
|
|
88
89
|
}).attr("cy", function (d) {
|
|
89
90
|
return d.optionalityPosition().y;
|
|
90
|
-
}).attr("r", 5).attr("fill", "#fefefe").attr("stroke-width",
|
|
91
|
+
}).attr("r", 5).attr("fill", "#fefefe").attr("stroke-width", _this3.style().port.stroke.width).attr("stroke", _this3.style().port.stroke.color);
|
|
91
92
|
};
|
|
92
93
|
|
|
93
94
|
// delete
|
|
@@ -37,6 +37,19 @@ var Ports = exports["default"] = /*#__PURE__*/function () {
|
|
|
37
37
|
value: function callbacks() {
|
|
38
38
|
return this._parent.callbacks;
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* ポート記号(円・カーディナリティ・オプショナリティ)を描く対象。
|
|
42
|
+
* サブセット結線(relationship.subset あり)は幹+バスのグループ線
|
|
43
|
+
* (Painters/Relationships.js)で描くため、個別ポートの記号は描かない。
|
|
44
|
+
*/
|
|
45
|
+
}, {
|
|
46
|
+
key: "visiblePorts",
|
|
47
|
+
value: function visiblePorts(entity) {
|
|
48
|
+
return entity.ports.items.list.filter(function (p) {
|
|
49
|
+
var r = p._relationship;
|
|
50
|
+
return !(r && r.subsetLabel && r.subsetLabel());
|
|
51
|
+
});
|
|
52
|
+
}
|
|
40
53
|
/* **************************************************************** *
|
|
41
54
|
* Old
|
|
42
55
|
* **************************************************************** */
|
|
@@ -6,6 +6,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports["default"] = void 0;
|
|
7
7
|
var _assh0le = require("@yanqirenshi/assh0le");
|
|
8
8
|
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); }
|
|
9
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
10
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
11
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
12
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
13
|
+
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; } } }; }
|
|
14
|
+
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; } }
|
|
15
|
+
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; }
|
|
9
16
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
10
17
|
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); } }
|
|
11
18
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
@@ -25,16 +32,16 @@ var Relationships = exports["default"] = /*#__PURE__*/function () {
|
|
|
25
32
|
return d._id;
|
|
26
33
|
},
|
|
27
34
|
x1: function x1(d) {
|
|
28
|
-
return
|
|
35
|
+
return _this.fromPoint(d).x;
|
|
29
36
|
},
|
|
30
37
|
y1: function y1(d) {
|
|
31
|
-
return
|
|
38
|
+
return _this.fromPoint(d).y;
|
|
32
39
|
},
|
|
33
40
|
x2: function x2(d) {
|
|
34
|
-
return
|
|
41
|
+
return _this.toPoint(d).x;
|
|
35
42
|
},
|
|
36
43
|
y2: function y2(d) {
|
|
37
|
-
return
|
|
44
|
+
return _this.toPoint(d).y;
|
|
38
45
|
},
|
|
39
46
|
stroke: function stroke() {
|
|
40
47
|
return '#888888';
|
|
@@ -63,14 +70,200 @@ var Relationships = exports["default"] = /*#__PURE__*/function () {
|
|
|
63
70
|
value: function callbacks() {
|
|
64
71
|
return this._parent.callbacks;
|
|
65
72
|
}
|
|
73
|
+
/** port の entity 相対座標を絶対座標にする。 */
|
|
74
|
+
}, {
|
|
75
|
+
key: "fromPoint",
|
|
76
|
+
value: function fromPoint(d) {
|
|
77
|
+
return {
|
|
78
|
+
x: d.from.position().x + d.from._owner.position.x,
|
|
79
|
+
y: d.from.position().y + d.from._owner.position.y
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}, {
|
|
83
|
+
key: "toPoint",
|
|
84
|
+
value: function toPoint(d) {
|
|
85
|
+
return {
|
|
86
|
+
x: d.to.position().x + d.to._owner.position.x,
|
|
87
|
+
y: d.to.position().y + d.to._owner.position.y
|
|
88
|
+
};
|
|
89
|
+
}
|
|
66
90
|
// public
|
|
67
91
|
}, {
|
|
68
92
|
key: "drawRelationships",
|
|
69
93
|
value: function drawRelationships(place, relationships) {
|
|
94
|
+
var _this2 = this;
|
|
70
95
|
var data = relationships.list.filter(function (edge) {
|
|
71
96
|
return edge.from._class === 'PORT-FROM' && edge.to._class === 'PORT-TO';
|
|
72
97
|
});
|
|
73
|
-
|
|
98
|
+
|
|
99
|
+
// サブセット結線は直線ではなく「幹 + 水平バス + 垂下」のグループ線
|
|
100
|
+
// (tm3-1 §5、組織図と同じ直交スタイル)で描くため、直線からは除外する
|
|
101
|
+
var plain = data.filter(function (d) {
|
|
102
|
+
return !_this2.isSubset(d);
|
|
103
|
+
});
|
|
104
|
+
this._lines.draw(place, plain);
|
|
105
|
+
this.drawSubsetTrees(place, data);
|
|
106
|
+
this.drawLabels(place, data);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* 結線のラベル(relationship.label)を線の中点の少し上に描く。
|
|
110
|
+
* enter/update join で冪等。サブセット結線は区分コード(=/×)を
|
|
111
|
+
* 分岐点に描くため対象外。
|
|
112
|
+
*/
|
|
113
|
+
}, {
|
|
114
|
+
key: "drawLabels",
|
|
115
|
+
value: function drawLabels(place, data) {
|
|
116
|
+
var _this3 = this;
|
|
117
|
+
var targets = data.filter(function (d) {
|
|
118
|
+
return !_this3.isSubset(d) && d.label && d.label();
|
|
119
|
+
});
|
|
120
|
+
var texts = place.selectAll('text.relationship-label').data(targets, function (d) {
|
|
121
|
+
return d._id;
|
|
122
|
+
});
|
|
123
|
+
texts.exit().remove();
|
|
124
|
+
var entered = texts.enter().append('text').attr('class', 'relationship-label').attr('text-anchor', 'middle').attr('font-size', '12px').attr('fill', '#333333');
|
|
125
|
+
this.applyLabels(entered.merge(texts));
|
|
126
|
+
}
|
|
127
|
+
/** ラベルの位置(線の中点の少し上)とテキストを適用する。 */
|
|
128
|
+
}, {
|
|
129
|
+
key: "applyLabels",
|
|
130
|
+
value: function applyLabels(selection) {
|
|
131
|
+
var _this4 = this;
|
|
132
|
+
selection.attr('x', function (d) {
|
|
133
|
+
return (_this4.fromPoint(d).x + _this4.toPoint(d).x) / 2;
|
|
134
|
+
}).attr('y', function (d) {
|
|
135
|
+
return (_this4.fromPoint(d).y + _this4.toPoint(d).y) / 2 - 6;
|
|
136
|
+
}).text(function (d) {
|
|
137
|
+
return d.label();
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}, {
|
|
141
|
+
key: "isSubset",
|
|
142
|
+
value: function isSubset(d) {
|
|
143
|
+
return !!(d.subsetLabel && d.subsetLabel());
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* サブセット結線のグループ化。同じ親エンティティ + 同じ区分コードの
|
|
147
|
+
* relationship を1つの分岐(幹 + バス + 垂下)として扱う。
|
|
148
|
+
*/
|
|
149
|
+
}, {
|
|
150
|
+
key: "subsetGroups",
|
|
151
|
+
value: function subsetGroups(data) {
|
|
152
|
+
var ht = new Map();
|
|
153
|
+
var _iterator = _createForOfIteratorHelper(data),
|
|
154
|
+
_step;
|
|
155
|
+
try {
|
|
156
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
157
|
+
var d = _step.value;
|
|
158
|
+
if (!this.isSubset(d)) continue;
|
|
159
|
+
var parent = d.from._owner;
|
|
160
|
+
var key = parent._id + '::' + d._core.subset.code;
|
|
161
|
+
if (!ht.has(key)) ht.set(key, {
|
|
162
|
+
key: key,
|
|
163
|
+
parent: parent,
|
|
164
|
+
label: d.subsetLabel(),
|
|
165
|
+
rels: []
|
|
166
|
+
});
|
|
167
|
+
ht.get(key).rels.push(d);
|
|
168
|
+
}
|
|
169
|
+
} catch (err) {
|
|
170
|
+
_iterator.e(err);
|
|
171
|
+
} finally {
|
|
172
|
+
_iterator.f();
|
|
173
|
+
}
|
|
174
|
+
return _toConsumableArray(ht.values());
|
|
175
|
+
}
|
|
176
|
+
/** 分岐の幾何: 幹(親下端中央) → バス(中間の高さ) → 各サブセット上端中央。 */
|
|
177
|
+
}, {
|
|
178
|
+
key: "subsetGeometry",
|
|
179
|
+
value: function subsetGeometry(group) {
|
|
180
|
+
var parent = group.parent;
|
|
181
|
+
var px = parent.position.x + parent.size.w / 2;
|
|
182
|
+
var py = parent.position.y + parent.size.h;
|
|
183
|
+
var drops = group.rels.map(function (d) {
|
|
184
|
+
var child = d.to._owner;
|
|
185
|
+
return {
|
|
186
|
+
x: child.position.x + child.size.w / 2,
|
|
187
|
+
y: child.position.y
|
|
188
|
+
};
|
|
189
|
+
});
|
|
190
|
+
var child_top = Math.min.apply(Math, _toConsumableArray(drops.map(function (p) {
|
|
191
|
+
return p.y;
|
|
192
|
+
})));
|
|
193
|
+
var busY = py + Math.max(16, (child_top - py) / 2);
|
|
194
|
+
var xs = [px].concat(_toConsumableArray(drops.map(function (p) {
|
|
195
|
+
return p.x;
|
|
196
|
+
})));
|
|
197
|
+
return {
|
|
198
|
+
px: px,
|
|
199
|
+
py: py,
|
|
200
|
+
busY: busY,
|
|
201
|
+
drops: drops,
|
|
202
|
+
minX: Math.min.apply(Math, _toConsumableArray(xs)),
|
|
203
|
+
maxX: Math.max.apply(Math, _toConsumableArray(xs))
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
}, {
|
|
207
|
+
key: "subsetPath",
|
|
208
|
+
value: function subsetPath(group) {
|
|
209
|
+
var g = this.subsetGeometry(group);
|
|
210
|
+
var path = 'M ' + g.px + ' ' + g.py + ' V ' + g.busY + ' M ' + g.minX + ' ' + g.busY + ' H ' + g.maxX;
|
|
211
|
+
var _iterator2 = _createForOfIteratorHelper(g.drops),
|
|
212
|
+
_step2;
|
|
213
|
+
try {
|
|
214
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
215
|
+
var p = _step2.value;
|
|
216
|
+
path += ' M ' + p.x + ' ' + g.busY + ' V ' + p.y;
|
|
217
|
+
}
|
|
218
|
+
} catch (err) {
|
|
219
|
+
_iterator2.e(err);
|
|
220
|
+
} finally {
|
|
221
|
+
_iterator2.f();
|
|
222
|
+
}
|
|
223
|
+
return path;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* サブセットの分岐(幹 + バス + 垂下)と、幹の分岐点に添える区分コード
|
|
227
|
+
* (=区分コード / ×区分コード)を描く。enter/update join で冪等。
|
|
228
|
+
*/
|
|
229
|
+
}, {
|
|
230
|
+
key: "drawSubsetTrees",
|
|
231
|
+
value: function drawSubsetTrees(place, data) {
|
|
232
|
+
this._subsetGroups = this.subsetGroups(data);
|
|
233
|
+
var paths = place.selectAll('path.subset-line').data(this._subsetGroups, function (d) {
|
|
234
|
+
return d.key;
|
|
235
|
+
});
|
|
236
|
+
paths.exit().remove();
|
|
237
|
+
var entered_paths = paths.enter().append('path').attr('class', 'subset-line').attr('fill', 'none').attr('stroke', '#888888').attr('stroke-width', 1);
|
|
238
|
+
var labels = place.selectAll('text.subset-code').data(this._subsetGroups, function (d) {
|
|
239
|
+
return d.key;
|
|
240
|
+
});
|
|
241
|
+
labels.exit().remove();
|
|
242
|
+
var entered_labels = labels.enter().append('text').attr('class', 'subset-code').attr('text-anchor', 'middle').attr('font-size', '12px').attr('fill', '#333333');
|
|
243
|
+
this.applySubsetTrees(entered_paths.merge(paths), entered_labels.merge(labels));
|
|
244
|
+
}
|
|
245
|
+
/** 分岐線の形状とラベル(バスの少し上・幹の位置)を適用する。 */
|
|
246
|
+
}, {
|
|
247
|
+
key: "applySubsetTrees",
|
|
248
|
+
value: function applySubsetTrees(paths, labels) {
|
|
249
|
+
var _this5 = this;
|
|
250
|
+
paths.attr('d', function (d) {
|
|
251
|
+
return _this5.subsetPath(d);
|
|
252
|
+
});
|
|
253
|
+
labels.attr('x', function (d) {
|
|
254
|
+
return _this5.subsetGeometry(d).px;
|
|
255
|
+
}).attr('y', function (d) {
|
|
256
|
+
return _this5.subsetGeometry(d).busY - 5;
|
|
257
|
+
}).text(function (d) {
|
|
258
|
+
return d.label;
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
/** ドラッグ追従: 分岐線・ラベル全体に現在のエンティティ位置を再適用する。 */
|
|
262
|
+
}, {
|
|
263
|
+
key: "updateSubsetTrees",
|
|
264
|
+
value: function updateSubsetTrees(place) {
|
|
265
|
+
if (!this._subsetGroups || this._subsetGroups.length === 0) return;
|
|
266
|
+
this.applySubsetTrees(place.selectAll('path.subset-line'), place.selectAll('text.subset-code'));
|
|
74
267
|
}
|
|
75
268
|
// Entity のドラッグ追従(Painters/Entities.js)から呼ばれる。
|
|
76
269
|
// 指定 entity に接続する線を選択して座標を再適用する。
|
|
@@ -78,13 +271,27 @@ var Relationships = exports["default"] = /*#__PURE__*/function () {
|
|
|
78
271
|
}, {
|
|
79
272
|
key: "redrawEntityEdges",
|
|
80
273
|
value: function redrawEntityEdges(place, entity) {
|
|
274
|
+
var _this6 = this;
|
|
81
275
|
var edges = entity.ports.items.list.map(function (p) {
|
|
82
276
|
return p._relationship;
|
|
83
277
|
});
|
|
84
|
-
var selection = place.selectAll('line.connector').data(edges
|
|
278
|
+
var selection = place.selectAll('line.connector').data(edges.filter(function (d) {
|
|
279
|
+
return !_this6.isSubset(d);
|
|
280
|
+
}), function (d) {
|
|
85
281
|
return d._id;
|
|
86
282
|
});
|
|
87
283
|
this._lines.update(selection);
|
|
284
|
+
|
|
285
|
+
// ラベルも追従させる
|
|
286
|
+
var labels = place.selectAll('text.relationship-label').data(edges.filter(function (d) {
|
|
287
|
+
return !_this6.isSubset(d) && d.label && d.label();
|
|
288
|
+
}), function (d) {
|
|
289
|
+
return d._id;
|
|
290
|
+
});
|
|
291
|
+
this.applyLabels(labels);
|
|
292
|
+
|
|
293
|
+
// サブセットの分岐線・区分コードも追従させる
|
|
294
|
+
this.updateSubsetTrees(place);
|
|
88
295
|
}
|
|
89
296
|
}]);
|
|
90
297
|
}();
|
package/dist/js/Relationship.js
CHANGED
|
@@ -7,11 +7,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports["default"] = void 0;
|
|
8
8
|
var _Atman2 = _interopRequireDefault(require("./Atman.js"));
|
|
9
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
10
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
10
11
|
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); } }
|
|
11
12
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
12
13
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
13
14
|
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); }
|
|
14
|
-
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
15
15
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
16
16
|
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); }
|
|
17
17
|
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
@@ -30,6 +30,25 @@ var Relationship = exports["default"] = /*#__PURE__*/function (_Atman) {
|
|
|
30
30
|
port_to._relationship = _this;
|
|
31
31
|
return _this;
|
|
32
32
|
}
|
|
33
|
+
/** 結線に表示するラベル(入力の relationship.label。無ければ null = 表示なし) */
|
|
33
34
|
_inherits(Relationship, _Atman);
|
|
34
|
-
return _createClass(Relationship
|
|
35
|
+
return _createClass(Relationship, [{
|
|
36
|
+
key: "label",
|
|
37
|
+
value: function label() {
|
|
38
|
+
return this._core.label || null;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* TM のサブセット結線に添える区分コードの表記。
|
|
42
|
+
* =区分コード … 同一のサブセット(kind: 'same')
|
|
43
|
+
* ×区分コード … 相違のサブセット(kind: 'different'。'same' 以外は×扱い)
|
|
44
|
+
* 入力の relationship.subset = { kind, code }。無ければ null(表示なし)。
|
|
45
|
+
*/
|
|
46
|
+
}, {
|
|
47
|
+
key: "subsetLabel",
|
|
48
|
+
value: function subsetLabel() {
|
|
49
|
+
var subset = this._core.subset;
|
|
50
|
+
if (!subset || !subset.code) return null;
|
|
51
|
+
return (subset.kind === 'same' ? '=' : '×') + subset.code;
|
|
52
|
+
}
|
|
53
|
+
}]);
|
|
35
54
|
}(_Atman2["default"]);
|
package/package.json
CHANGED
package/tests/Rectum.test.js
CHANGED
|
@@ -73,6 +73,49 @@ test('a CLASS relationship to a non-parent throws', () => {
|
|
|
73
73
|
.toThrow(/クラス\(CLASS\)は切り出し元\(親\)としか結線できません/);
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
+
// issue #15: サブセット結線の区分コード表記(=同一 / ×相違)
|
|
77
|
+
test('subsetLabel composes = / × with the code (default: different)', () => {
|
|
78
|
+
const rectum = new Rectum({});
|
|
79
|
+
rectum.data(DATA([
|
|
80
|
+
{
|
|
81
|
+
id: 1, type: null,
|
|
82
|
+
from: { entity: 30000, cardinality: 1, optionality: 0, position: 270 },
|
|
83
|
+
to: { entity: 30001, cardinality: 1, optionality: 0, position: 90 },
|
|
84
|
+
details: [{ from: { id: 3000001 }, to: { id: 3000101 } }],
|
|
85
|
+
subset: { kind: 'different', code: '状態区分' },
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
id: 2, type: null,
|
|
89
|
+
from: { entity: 30000, cardinality: 1, optionality: 0, position: 0 },
|
|
90
|
+
to: { entity: 30001, cardinality: 1, optionality: 0, position: 180 },
|
|
91
|
+
details: [{ from: { id: 3000001 }, to: { id: 3000101 } }],
|
|
92
|
+
subset: { kind: 'same', code: '行種別' },
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
id: 3, type: null,
|
|
96
|
+
from: { entity: 30000, cardinality: 1, optionality: 0, position: 315 },
|
|
97
|
+
to: { entity: 30001, cardinality: 1, optionality: 0, position: 45 },
|
|
98
|
+
details: [{ from: { id: 3000001 }, to: { id: 3000101 } }],
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: 4, type: null,
|
|
102
|
+
from: { entity: 30000, cardinality: 1, optionality: 0, position: 90 },
|
|
103
|
+
to: { entity: 30001, cardinality: 1, optionality: 0, position: 270 },
|
|
104
|
+
details: [{ from: { id: 3000001 }, to: { id: 3000101 } }],
|
|
105
|
+
label: 'defines',
|
|
106
|
+
},
|
|
107
|
+
]));
|
|
108
|
+
|
|
109
|
+
const rels = rectum._relationships.ht;
|
|
110
|
+
expect(rels[1].subsetLabel()).toBe('×状態区分');
|
|
111
|
+
expect(rels[2].subsetLabel()).toBe('=行種別');
|
|
112
|
+
expect(rels[3].subsetLabel()).toBeNull(); // subset 無し → 表示なし
|
|
113
|
+
|
|
114
|
+
// issue #16: 汎用ラベル(relationship.label)
|
|
115
|
+
expect(rels[3].label()).toBeNull(); // label 無し → 表示なし
|
|
116
|
+
expect(rels[4].label()).toBe('defines'); // 指定があればそのまま
|
|
117
|
+
});
|
|
118
|
+
|
|
76
119
|
test('a CLASS-to-CLASS relationship throws', () => {
|
|
77
120
|
const bad = [{
|
|
78
121
|
id: 1, type: null,
|