@yanqirenshi/d3.ter 0.0.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/README.md +68 -0
- package/dist/App.js +19 -0
- package/dist/App.test.js +17 -0
- package/dist/index.css +13 -0
- package/dist/index.js +26 -0
- package/dist/js/AssholeD3TER.js +279 -0
- package/dist/js/Attribute.js +58 -0
- package/dist/js/AttributeInstance.js +72 -0
- package/dist/js/ColumnInstance.js +60 -0
- package/dist/js/Entity.js +430 -0
- package/dist/js/EntityTailor.js +696 -0
- package/dist/js/Identifier.js +58 -0
- package/dist/js/IdentifierInstance.js +73 -0
- package/dist/js/Pool.js +43 -0
- package/dist/js/Port.js +60 -0
- package/dist/js/Relationship.js +101 -0
- package/dist/pages/D3Ter.js +64 -0
- package/dist/pages/Home.js +32 -0
- package/dist/pages/HomeTerData.js +1 -0
- package/dist/pages/TER_DATA.js +130 -0
- package/dist/serviceWorker.js +124 -0
- package/dist/setupTests.js +3 -0
- package/package.json +39 -0
|
@@ -0,0 +1,696 @@
|
|
|
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
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
11
|
+
|
|
12
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
13
|
+
|
|
14
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
15
|
+
|
|
16
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
17
|
+
|
|
18
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
19
|
+
|
|
20
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
21
|
+
|
|
22
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
23
|
+
|
|
24
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
25
|
+
|
|
26
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
27
|
+
|
|
28
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
29
|
+
|
|
30
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, 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 normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
31
|
+
|
|
32
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
33
|
+
|
|
34
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
35
|
+
|
|
36
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
37
|
+
|
|
38
|
+
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); } }
|
|
39
|
+
|
|
40
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
41
|
+
|
|
42
|
+
var Builder = /*#__PURE__*/function () {
|
|
43
|
+
function Builder() {
|
|
44
|
+
_classCallCheck(this, Builder);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
_createClass(Builder, [{
|
|
48
|
+
key: "template",
|
|
49
|
+
value: function template() {
|
|
50
|
+
return {
|
|
51
|
+
_id: null,
|
|
52
|
+
_class: 'ENTITY',
|
|
53
|
+
description: {
|
|
54
|
+
contents: ''
|
|
55
|
+
},
|
|
56
|
+
position: {
|
|
57
|
+
x: 0,
|
|
58
|
+
y: 0,
|
|
59
|
+
z: 0
|
|
60
|
+
},
|
|
61
|
+
size: {
|
|
62
|
+
w: 0,
|
|
63
|
+
h: 0
|
|
64
|
+
},
|
|
65
|
+
padding: 11,
|
|
66
|
+
margin: 6,
|
|
67
|
+
bar: {
|
|
68
|
+
size: {
|
|
69
|
+
header: 11,
|
|
70
|
+
contents: 8
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
background: {
|
|
74
|
+
color: ''
|
|
75
|
+
},
|
|
76
|
+
name: {
|
|
77
|
+
position: {
|
|
78
|
+
x: 0,
|
|
79
|
+
y: 0,
|
|
80
|
+
z: 0
|
|
81
|
+
},
|
|
82
|
+
size: {
|
|
83
|
+
h: null,
|
|
84
|
+
w: null
|
|
85
|
+
},
|
|
86
|
+
padding: 11,
|
|
87
|
+
contents: ''
|
|
88
|
+
},
|
|
89
|
+
type: {
|
|
90
|
+
contents: '??',
|
|
91
|
+
position: {
|
|
92
|
+
x: 0,
|
|
93
|
+
y: 0,
|
|
94
|
+
z: 0
|
|
95
|
+
},
|
|
96
|
+
size: {
|
|
97
|
+
w: 0,
|
|
98
|
+
h: 0
|
|
99
|
+
},
|
|
100
|
+
padding: 11
|
|
101
|
+
},
|
|
102
|
+
identifiers: {
|
|
103
|
+
position: {
|
|
104
|
+
x: 0,
|
|
105
|
+
y: 0,
|
|
106
|
+
z: 0
|
|
107
|
+
},
|
|
108
|
+
size: {
|
|
109
|
+
w: null,
|
|
110
|
+
h: null
|
|
111
|
+
},
|
|
112
|
+
padding: 8,
|
|
113
|
+
items: {
|
|
114
|
+
list: [],
|
|
115
|
+
ht: {}
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
attributes: {
|
|
119
|
+
position: {
|
|
120
|
+
x: 0,
|
|
121
|
+
y: 0,
|
|
122
|
+
z: 0
|
|
123
|
+
},
|
|
124
|
+
size: {
|
|
125
|
+
w: null,
|
|
126
|
+
h: null
|
|
127
|
+
},
|
|
128
|
+
padding: 8,
|
|
129
|
+
items: {
|
|
130
|
+
list: [],
|
|
131
|
+
ht: {}
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
ports: {
|
|
135
|
+
items: {
|
|
136
|
+
list: [],
|
|
137
|
+
ht: {}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}, {
|
|
143
|
+
key: "entityTypeContents",
|
|
144
|
+
value: function entityTypeContents(core) {
|
|
145
|
+
switch (core.type) {
|
|
146
|
+
case 'RESOURCE':
|
|
147
|
+
return 'Rsc';
|
|
148
|
+
|
|
149
|
+
case 'RESOURCE-SUBSET':
|
|
150
|
+
return 'Rsc';
|
|
151
|
+
|
|
152
|
+
case 'COMPARATIVE':
|
|
153
|
+
return '対象';
|
|
154
|
+
|
|
155
|
+
case 'EVENT':
|
|
156
|
+
return 'Evt';
|
|
157
|
+
|
|
158
|
+
case 'EVENT-SUBSET':
|
|
159
|
+
return 'Evt';
|
|
160
|
+
|
|
161
|
+
default:
|
|
162
|
+
throw new Error(core._class + " は知らないよ。");
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}, {
|
|
166
|
+
key: "entityBackground",
|
|
167
|
+
value: function entityBackground(core) {
|
|
168
|
+
var background = {
|
|
169
|
+
"resource": {
|
|
170
|
+
color: '#89c3eb'
|
|
171
|
+
},
|
|
172
|
+
"resource-subset": {
|
|
173
|
+
color: '#a0d8ef'
|
|
174
|
+
},
|
|
175
|
+
"event": {
|
|
176
|
+
color: '#f09199'
|
|
177
|
+
},
|
|
178
|
+
"event-subset": {
|
|
179
|
+
color: '#f6bfbc'
|
|
180
|
+
},
|
|
181
|
+
"comparative": {
|
|
182
|
+
color: '#c8d5bb'
|
|
183
|
+
},
|
|
184
|
+
"correspondence": {
|
|
185
|
+
color: '#f2f2b0'
|
|
186
|
+
},
|
|
187
|
+
"recursion": {
|
|
188
|
+
color: '#dbd0e6'
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
return background[core.type.toLowerCase()];
|
|
192
|
+
}
|
|
193
|
+
}, {
|
|
194
|
+
key: "buildIdentifiers",
|
|
195
|
+
value: function buildIdentifiers(core, state, entity_element) {
|
|
196
|
+
var out = {
|
|
197
|
+
list: [],
|
|
198
|
+
ht: {}
|
|
199
|
+
};
|
|
200
|
+
var masters = state.identifiers.ht;
|
|
201
|
+
|
|
202
|
+
var _iterator = _createForOfIteratorHelper(core.identifiers),
|
|
203
|
+
_step;
|
|
204
|
+
|
|
205
|
+
try {
|
|
206
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
207
|
+
var identifier = _step.value;
|
|
208
|
+
var master = masters[identifier.identifier];
|
|
209
|
+
var element = this.identifier_instance.build(identifier, master);
|
|
210
|
+
element._entity = entity_element;
|
|
211
|
+
out.list.push(element);
|
|
212
|
+
out.ht[element._id] = element;
|
|
213
|
+
}
|
|
214
|
+
} catch (err) {
|
|
215
|
+
_iterator.e(err);
|
|
216
|
+
} finally {
|
|
217
|
+
_iterator.f();
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return {
|
|
221
|
+
contents: out,
|
|
222
|
+
position: {
|
|
223
|
+
x: 0,
|
|
224
|
+
y: 0
|
|
225
|
+
},
|
|
226
|
+
size: {
|
|
227
|
+
w: 0,
|
|
228
|
+
h: 0
|
|
229
|
+
},
|
|
230
|
+
background: {
|
|
231
|
+
color: '#ffffff'
|
|
232
|
+
},
|
|
233
|
+
padding: 11
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
}, {
|
|
237
|
+
key: "buildAttributes",
|
|
238
|
+
value: function buildAttributes(core, state, entity_element) {
|
|
239
|
+
var out = {
|
|
240
|
+
list: [],
|
|
241
|
+
ht: {}
|
|
242
|
+
};
|
|
243
|
+
var masters = state.attributes.ht;
|
|
244
|
+
|
|
245
|
+
var _iterator2 = _createForOfIteratorHelper(core.attributes),
|
|
246
|
+
_step2;
|
|
247
|
+
|
|
248
|
+
try {
|
|
249
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
250
|
+
var attribute = _step2.value;
|
|
251
|
+
var master = masters[attribute.attribute];
|
|
252
|
+
var element = this.attribute_instance.build(attribute, master);
|
|
253
|
+
element._entity = entity_element;
|
|
254
|
+
out.list.push(element);
|
|
255
|
+
out.ht[element._id] = element;
|
|
256
|
+
}
|
|
257
|
+
} catch (err) {
|
|
258
|
+
_iterator2.e(err);
|
|
259
|
+
} finally {
|
|
260
|
+
_iterator2.f();
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return {
|
|
264
|
+
contents: out,
|
|
265
|
+
position: {
|
|
266
|
+
x: 0,
|
|
267
|
+
y: 0
|
|
268
|
+
},
|
|
269
|
+
size: {
|
|
270
|
+
w: 0,
|
|
271
|
+
h: 0
|
|
272
|
+
},
|
|
273
|
+
background: {
|
|
274
|
+
color: '#ffffff'
|
|
275
|
+
},
|
|
276
|
+
padding: 11
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
}, {
|
|
280
|
+
key: "build",
|
|
281
|
+
value: function build(core, state) {
|
|
282
|
+
var element = this.template();
|
|
283
|
+
element._id = core.id;
|
|
284
|
+
element.name.contents = core.name;
|
|
285
|
+
element.description.contents = core.description;
|
|
286
|
+
element.position = _objectSpread({}, core.position);
|
|
287
|
+
element.size = _objectSpread({}, core.size);
|
|
288
|
+
element.type.contents = this.entityTypeContents(core);
|
|
289
|
+
element.identifiers = this.buildIdentifiers(core, state, element);
|
|
290
|
+
element.attributes = this.buildAttributes(core, state, element);
|
|
291
|
+
element.background = this.entityBackground(core);
|
|
292
|
+
element._core = core;
|
|
293
|
+
core._element = element;
|
|
294
|
+
return element;
|
|
295
|
+
}
|
|
296
|
+
}]);
|
|
297
|
+
|
|
298
|
+
return Builder;
|
|
299
|
+
}();
|
|
300
|
+
|
|
301
|
+
var EntityTailor = /*#__PURE__*/function (_Builder) {
|
|
302
|
+
_inherits(EntityTailor, _Builder);
|
|
303
|
+
|
|
304
|
+
var _super = _createSuper(EntityTailor);
|
|
305
|
+
|
|
306
|
+
function EntityTailor() {
|
|
307
|
+
_classCallCheck(this, EntityTailor);
|
|
308
|
+
|
|
309
|
+
return _super.apply(this, arguments);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
_createClass(EntityTailor, [{
|
|
313
|
+
key: "sizingType",
|
|
314
|
+
value:
|
|
315
|
+
/* **************************************************************** *
|
|
316
|
+
* Size
|
|
317
|
+
* **************************************************************** */
|
|
318
|
+
function sizingType(entity) {
|
|
319
|
+
var data = entity.type;
|
|
320
|
+
if (!data.contents) data.contents = '??';
|
|
321
|
+
data.size.h = this._default.line.height + data.padding * 2;
|
|
322
|
+
data.size.w = data.contents.length * this._default.line.font.size + data.padding * 2;
|
|
323
|
+
}
|
|
324
|
+
}, {
|
|
325
|
+
key: "sizingName",
|
|
326
|
+
value: function sizingName(entity) {
|
|
327
|
+
var data = entity.name;
|
|
328
|
+
if (!data.contents) data.contents = '????????';
|
|
329
|
+
data.size.h = this._default.line.height + data.padding * 2;
|
|
330
|
+
var type = entity.type;
|
|
331
|
+
data.size.w = entity.size.w - entity.padding * 2 - entity.bar.size.header - type.size.w;
|
|
332
|
+
}
|
|
333
|
+
}, {
|
|
334
|
+
key: "sizingIdentifiers",
|
|
335
|
+
value: function sizingIdentifiers(entity) {
|
|
336
|
+
var data = entity.identifiers;
|
|
337
|
+
var padding = entity.padding;
|
|
338
|
+
data.size.w = (entity.size.w - padding * 2) / 2 - entity.bar.size.contents / 2;
|
|
339
|
+
data.size.h = data.contents.list.length * (this._default.line.height + padding * 2);
|
|
340
|
+
}
|
|
341
|
+
}, {
|
|
342
|
+
key: "sizingAttributes",
|
|
343
|
+
value: function sizingAttributes(entity) {
|
|
344
|
+
var data = entity.attributes;
|
|
345
|
+
var padding = entity.padding;
|
|
346
|
+
data.size.w = (entity.size.w - entity.padding * 2) / 2 - entity.bar.size.contents / 2;
|
|
347
|
+
data.size.h = data.contents.list.length * (this._default.line.height + padding * 2);
|
|
348
|
+
}
|
|
349
|
+
}, {
|
|
350
|
+
key: "sizingContentsArea",
|
|
351
|
+
value: function sizingContentsArea(entity) {
|
|
352
|
+
var id_h = entity.identifiers.size.h;
|
|
353
|
+
var attr_h = entity.attributes.size.h;
|
|
354
|
+
if (id_h > attr_h) entity.attributes.size.h = id_h;else entity.identifiers.size.h = attr_h;
|
|
355
|
+
}
|
|
356
|
+
}, {
|
|
357
|
+
key: "sizingEntity",
|
|
358
|
+
value: function sizingEntity(entity) {
|
|
359
|
+
this.sizingType(entity);
|
|
360
|
+
this.sizingName(entity);
|
|
361
|
+
this.sizingIdentifiers(entity);
|
|
362
|
+
this.sizingAttributes(entity);
|
|
363
|
+
this.sizingContentsArea(entity);
|
|
364
|
+
var padding = entity.padding * 2;
|
|
365
|
+
var header = entity.name.size.h;
|
|
366
|
+
var margin = 11;
|
|
367
|
+
var contents = entity.attributes.size.h;
|
|
368
|
+
entity.size.h = padding + header + margin + contents;
|
|
369
|
+
}
|
|
370
|
+
}, {
|
|
371
|
+
key: "sizingEntities",
|
|
372
|
+
value: function sizingEntities(entities) {
|
|
373
|
+
var _iterator3 = _createForOfIteratorHelper(entities),
|
|
374
|
+
_step3;
|
|
375
|
+
|
|
376
|
+
try {
|
|
377
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
378
|
+
var entity = _step3.value;
|
|
379
|
+
this.sizingEntity(entity);
|
|
380
|
+
}
|
|
381
|
+
} catch (err) {
|
|
382
|
+
_iterator3.e(err);
|
|
383
|
+
} finally {
|
|
384
|
+
_iterator3.f();
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}, {
|
|
388
|
+
key: "sizing",
|
|
389
|
+
value: function sizing(entities) {
|
|
390
|
+
this.sizingEntities(entities);
|
|
391
|
+
return this;
|
|
392
|
+
}
|
|
393
|
+
}, {
|
|
394
|
+
key: "reSizingEntity",
|
|
395
|
+
value: function reSizingEntity(entity) {
|
|
396
|
+
entity.name.size.w = Math.ceil(entity._max_w.name) + entity.name.padding * 2;
|
|
397
|
+
entity.identifiers.size.w = Math.ceil(entity._max_w.identifier) + entity.identifiers.padding * 2;
|
|
398
|
+
entity.attributes.size.w = Math.ceil(entity._max_w.attribute) + entity.attributes.padding * 2;
|
|
399
|
+
var name_area_w = entity.name.size.w + entity.bar.size.header + entity.type.size.w + entity.padding * 2;
|
|
400
|
+
var contents_area_w = entity.identifiers.size.w + entity.bar.size.contents + entity.attributes.size.w + entity.padding * 2;
|
|
401
|
+
entity.size.w = contents_area_w > name_area_w ? contents_area_w : name_area_w; // fix size for attr area
|
|
402
|
+
|
|
403
|
+
if (entity._max_w.attribute === 0 || contents_area_w < name_area_w) {
|
|
404
|
+
entity.attributes.size.w = entity.size.w - entity.identifiers.size.w - entity.bar.size.contents - entity.padding * 2;
|
|
405
|
+
} // fix size for name area
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
if (contents_area_w > name_area_w) {
|
|
409
|
+
entity.name.size.w = entity.size.w - entity.bar.size.header - entity.type.size.w - entity.padding * 2;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}, {
|
|
413
|
+
key: "reSizing",
|
|
414
|
+
value: function reSizing(groups, entities) {
|
|
415
|
+
var _this = this;
|
|
416
|
+
|
|
417
|
+
groups.each(function (entity) {
|
|
418
|
+
_this.reSizingEntity(entity);
|
|
419
|
+
|
|
420
|
+
_this.positioningEntity(entity, entities);
|
|
421
|
+
});
|
|
422
|
+
this.redraw(groups);
|
|
423
|
+
}
|
|
424
|
+
/* **************************************************************** *
|
|
425
|
+
* Position
|
|
426
|
+
* **************************************************************** */
|
|
427
|
+
|
|
428
|
+
}, {
|
|
429
|
+
key: "positioningName",
|
|
430
|
+
value: function positioningName(entity) {
|
|
431
|
+
var d = entity.name;
|
|
432
|
+
d.position.x = entity.padding;
|
|
433
|
+
d.position.y = entity.padding;
|
|
434
|
+
}
|
|
435
|
+
}, {
|
|
436
|
+
key: "positioningType",
|
|
437
|
+
value: function positioningType(entity) {
|
|
438
|
+
var d = entity.type;
|
|
439
|
+
var margin = 11;
|
|
440
|
+
d.position.x = entity.padding + entity.name.size.w + margin;
|
|
441
|
+
d.position.y = entity.padding;
|
|
442
|
+
}
|
|
443
|
+
}, {
|
|
444
|
+
key: "positioningColumnItems",
|
|
445
|
+
value: function positioningColumnItems(d) {
|
|
446
|
+
var len = d.contents.list.length;
|
|
447
|
+
var padding = d.padding;
|
|
448
|
+
var start = d.position.y;
|
|
449
|
+
var line_height = this._default.line.height;
|
|
450
|
+
var item_h = line_height + padding * 2;
|
|
451
|
+
var magic_num = 3; // y軸の微調整係数
|
|
452
|
+
|
|
453
|
+
for (var i = 0; i < len; i++) {
|
|
454
|
+
var item = d.contents.list[i];
|
|
455
|
+
item.position.x = d.position.x + padding;
|
|
456
|
+
item.position.y = start + padding + line_height + i * item_h + magic_num;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}, {
|
|
460
|
+
key: "positioningIdentifiers",
|
|
461
|
+
value: function positioningIdentifiers(entity) {
|
|
462
|
+
var d = entity.identifiers;
|
|
463
|
+
var margin = 11;
|
|
464
|
+
d.position.x = entity.padding;
|
|
465
|
+
d.position.y = entity.padding + entity.name.size.h + margin;
|
|
466
|
+
this.positioningColumnItems(d);
|
|
467
|
+
}
|
|
468
|
+
}, {
|
|
469
|
+
key: "positioningAttributes",
|
|
470
|
+
value: function positioningAttributes(entity) {
|
|
471
|
+
var d = entity.attributes;
|
|
472
|
+
var margin1 = 4 * 2;
|
|
473
|
+
var margin2 = 11;
|
|
474
|
+
d.position.x = entity.padding + margin1 + entity.identifiers.size.w;
|
|
475
|
+
d.position.y = entity.padding + entity.name.size.h + margin2;
|
|
476
|
+
this.positioningColumnItems(d);
|
|
477
|
+
}
|
|
478
|
+
}, {
|
|
479
|
+
key: "deg2rad",
|
|
480
|
+
value: function deg2rad(degree) {
|
|
481
|
+
return degree * (Math.PI / 180);
|
|
482
|
+
}
|
|
483
|
+
}, {
|
|
484
|
+
key: "getPortLineLength",
|
|
485
|
+
value: function getPortLineLength(entity) {
|
|
486
|
+
var max_length = Math.floor(Math.sqrt(entity.size.w * entity.size.w + entity.size.h * entity.size.h));
|
|
487
|
+
return 0.8 * max_length;
|
|
488
|
+
}
|
|
489
|
+
}, {
|
|
490
|
+
key: "getPortLineFrom",
|
|
491
|
+
value: function getPortLineFrom(entity) {
|
|
492
|
+
return {
|
|
493
|
+
x: Math.floor(entity.size.w / 2),
|
|
494
|
+
y: Math.floor(entity.size.h / 2)
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
}, {
|
|
498
|
+
key: "makePortLine",
|
|
499
|
+
value: function makePortLine(entity, port) {
|
|
500
|
+
var out = {
|
|
501
|
+
from: {
|
|
502
|
+
x: 0,
|
|
503
|
+
y: 0
|
|
504
|
+
},
|
|
505
|
+
to: {
|
|
506
|
+
x: 0,
|
|
507
|
+
y: 0
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
var from = this.getPortLineFrom(entity);
|
|
511
|
+
out.from.x = from.x;
|
|
512
|
+
out.from.y = from.y;
|
|
513
|
+
var x = 0;
|
|
514
|
+
var y = this.getPortLineLength(entity);
|
|
515
|
+
var degree = port._position % 360;
|
|
516
|
+
var radian = this.deg2rad(degree);
|
|
517
|
+
var cos = Math.cos(radian);
|
|
518
|
+
var sin = Math.sin(radian);
|
|
519
|
+
out.to.x = Math.floor(x * cos - y * sin);
|
|
520
|
+
out.to.y = Math.floor(x * sin + y * cos);
|
|
521
|
+
out.to.x += out.from.x;
|
|
522
|
+
out.to.y += out.from.y;
|
|
523
|
+
port._from = out.from;
|
|
524
|
+
port._to = out.to;
|
|
525
|
+
return out;
|
|
526
|
+
}
|
|
527
|
+
}, {
|
|
528
|
+
key: "isCorss",
|
|
529
|
+
value: function isCorss(A, B, C, D) {
|
|
530
|
+
// 二つの線分の交差チェック
|
|
531
|
+
// https://www.hiramine.com/programming/graphics/2d_segmentintersection.html
|
|
532
|
+
var ACx = C.x - A.x;
|
|
533
|
+
var ACy = C.y - A.y;
|
|
534
|
+
var BUNBO = (B.x - A.x) * (D.y - C.y) - (B.y - A.y) * (D.x - C.x);
|
|
535
|
+
if (BUNBO === 0) return false;
|
|
536
|
+
var r = ((D.y - C.y) * ACx - (D.x - C.x) * ACy) / BUNBO;
|
|
537
|
+
var s = ((B.y - A.y) * ACx - (B.x - A.x) * ACy) / BUNBO;
|
|
538
|
+
return 0 <= r && r <= 1 && 0 <= s && s <= 1;
|
|
539
|
+
}
|
|
540
|
+
}, {
|
|
541
|
+
key: "getCrossPointCore",
|
|
542
|
+
value: function getCrossPointCore(line, line_port, port) {
|
|
543
|
+
// 2直線の交点を求める公式
|
|
544
|
+
var out = {
|
|
545
|
+
x: 0,
|
|
546
|
+
y: 0
|
|
547
|
+
};
|
|
548
|
+
var A = line.from;
|
|
549
|
+
var B = line.to;
|
|
550
|
+
var C = line_port.from;
|
|
551
|
+
var D = line_port.to;
|
|
552
|
+
var bunbo = (B.y - A.y) * (D.x - C.x) - (B.x - A.x) * (D.y - C.y);
|
|
553
|
+
if (!this.isCorss(A, B, C, D)) return null; // 二つの線分の交点を算出する。
|
|
554
|
+
// http://mf-atelier.sakura.ne.jp/mf-atelier/modules/tips/program/algorithm/a1.html
|
|
555
|
+
|
|
556
|
+
var d1, d2;
|
|
557
|
+
d1 = C.y * D.x - C.x * D.y;
|
|
558
|
+
d2 = A.y * B.x - A.x * B.y;
|
|
559
|
+
out.x = (d1 * (B.x - A.x) - d2 * (D.x - C.x)) / bunbo;
|
|
560
|
+
out.y = (d1 * (B.y - A.y) - d2 * (D.y - C.y)) / bunbo;
|
|
561
|
+
return out;
|
|
562
|
+
}
|
|
563
|
+
}, {
|
|
564
|
+
key: "getCrossPoint",
|
|
565
|
+
value: function getCrossPoint(lines, line_port, port) {
|
|
566
|
+
var _iterator4 = _createForOfIteratorHelper(lines),
|
|
567
|
+
_step4;
|
|
568
|
+
|
|
569
|
+
try {
|
|
570
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
571
|
+
var line = _step4.value;
|
|
572
|
+
var point = this.getCrossPointCore(line, line_port, port);
|
|
573
|
+
if (point) return point;
|
|
574
|
+
}
|
|
575
|
+
} catch (err) {
|
|
576
|
+
_iterator4.e(err);
|
|
577
|
+
} finally {
|
|
578
|
+
_iterator4.f();
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
return null;
|
|
582
|
+
}
|
|
583
|
+
}, {
|
|
584
|
+
key: "getEntityLines",
|
|
585
|
+
value: function getEntityLines(entity) {
|
|
586
|
+
var port_r = 4;
|
|
587
|
+
var margin = entity.margin + port_r;
|
|
588
|
+
var w = entity.size.w;
|
|
589
|
+
var h = entity.size.h;
|
|
590
|
+
var top_left = {
|
|
591
|
+
x: 0 - margin,
|
|
592
|
+
y: 0 - margin
|
|
593
|
+
};
|
|
594
|
+
var top_right = {
|
|
595
|
+
x: w + margin,
|
|
596
|
+
y: 0 - margin
|
|
597
|
+
};
|
|
598
|
+
var bottom_rigth = {
|
|
599
|
+
x: w + margin,
|
|
600
|
+
y: h + margin
|
|
601
|
+
};
|
|
602
|
+
var bottom_left = {
|
|
603
|
+
x: 0 - margin,
|
|
604
|
+
y: h + margin
|
|
605
|
+
};
|
|
606
|
+
return [{
|
|
607
|
+
from: top_left,
|
|
608
|
+
to: top_right
|
|
609
|
+
}, {
|
|
610
|
+
from: top_right,
|
|
611
|
+
to: bottom_rigth
|
|
612
|
+
}, {
|
|
613
|
+
from: bottom_rigth,
|
|
614
|
+
to: bottom_left
|
|
615
|
+
}, {
|
|
616
|
+
from: bottom_left,
|
|
617
|
+
to: top_left
|
|
618
|
+
}];
|
|
619
|
+
}
|
|
620
|
+
}, {
|
|
621
|
+
key: "positioningPort",
|
|
622
|
+
value: function positioningPort(entity, port) {
|
|
623
|
+
var line_port = this.makePortLine(entity, port);
|
|
624
|
+
var lines_entity = this.getEntityLines(entity);
|
|
625
|
+
var point = this.getCrossPoint(lines_entity, line_port, port);
|
|
626
|
+
if (!point) point = {
|
|
627
|
+
x: 0,
|
|
628
|
+
y: 0
|
|
629
|
+
};
|
|
630
|
+
port.position = point;
|
|
631
|
+
return port;
|
|
632
|
+
}
|
|
633
|
+
}, {
|
|
634
|
+
key: "positioningPorts",
|
|
635
|
+
value: function positioningPorts(entity, entities) {
|
|
636
|
+
var _iterator5 = _createForOfIteratorHelper(entities.list),
|
|
637
|
+
_step5;
|
|
638
|
+
|
|
639
|
+
try {
|
|
640
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
641
|
+
var _entity = _step5.value;
|
|
642
|
+
|
|
643
|
+
var _iterator6 = _createForOfIteratorHelper(_entity.ports.items.list),
|
|
644
|
+
_step6;
|
|
645
|
+
|
|
646
|
+
try {
|
|
647
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
648
|
+
var port = _step6.value;
|
|
649
|
+
this.positioningPort(_entity, port);
|
|
650
|
+
}
|
|
651
|
+
} catch (err) {
|
|
652
|
+
_iterator6.e(err);
|
|
653
|
+
} finally {
|
|
654
|
+
_iterator6.f();
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
} catch (err) {
|
|
658
|
+
_iterator5.e(err);
|
|
659
|
+
} finally {
|
|
660
|
+
_iterator5.f();
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
}, {
|
|
664
|
+
key: "positioningEntity",
|
|
665
|
+
value: function positioningEntity(entity, entities) {
|
|
666
|
+
this.positioningName(entity);
|
|
667
|
+
this.positioningType(entity);
|
|
668
|
+
this.positioningIdentifiers(entity);
|
|
669
|
+
this.positioningAttributes(entity);
|
|
670
|
+
this.positioningPorts(entity, entities);
|
|
671
|
+
}
|
|
672
|
+
}, {
|
|
673
|
+
key: "positioning",
|
|
674
|
+
value: function positioning() {
|
|
675
|
+
var _iterator7 = _createForOfIteratorHelper(this._data),
|
|
676
|
+
_step7;
|
|
677
|
+
|
|
678
|
+
try {
|
|
679
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
680
|
+
var entity = _step7.value;
|
|
681
|
+
this.positioningEntity(entity);
|
|
682
|
+
}
|
|
683
|
+
} catch (err) {
|
|
684
|
+
_iterator7.e(err);
|
|
685
|
+
} finally {
|
|
686
|
+
_iterator7.f();
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
return this;
|
|
690
|
+
}
|
|
691
|
+
}]);
|
|
692
|
+
|
|
693
|
+
return EntityTailor;
|
|
694
|
+
}(Builder);
|
|
695
|
+
|
|
696
|
+
exports["default"] = EntityTailor;
|