@yanqirenshi/d3.ter 0.1.2 → 0.1.3

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 CHANGED
@@ -1,68 +1,68 @@
1
- This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2
-
3
- ## Available Scripts
4
-
5
- In the project directory, you can run:
6
-
7
- ### `npm start`
8
-
9
- Runs the app in the development mode.<br />
10
- Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11
-
12
- The page will reload if you make edits.<br />
13
- You will also see any lint errors in the console.
14
-
15
- ### `npm test`
16
-
17
- Launches the test runner in the interactive watch mode.<br />
18
- See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19
-
20
- ### `npm run build`
21
-
22
- Builds the app for production to the `build` folder.<br />
23
- It correctly bundles React in production mode and optimizes the build for the best performance.
24
-
25
- The build is minified and the filenames include the hashes.<br />
26
- Your app is ready to be deployed!
27
-
28
- See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29
-
30
- ### `npm run eject`
31
-
32
- **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33
-
34
- If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35
-
36
- Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37
-
38
- You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39
-
40
- ## Learn More
41
-
42
- You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43
-
44
- To learn React, check out the [React documentation](https://reactjs.org/).
45
-
46
- ### Code Splitting
47
-
48
- This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49
-
50
- ### Analyzing the Bundle Size
51
-
52
- This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53
-
54
- ### Making a Progressive Web App
55
-
56
- This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57
-
58
- ### Advanced Configuration
59
-
60
- This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61
-
62
- ### Deployment
63
-
64
- This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65
-
66
- ### `npm run build` fails to minify
67
-
68
- This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
1
+ This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2
+
3
+ ## Available Scripts
4
+
5
+ In the project directory, you can run:
6
+
7
+ ### `npm start`
8
+
9
+ Runs the app in the development mode.<br />
10
+ Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11
+
12
+ The page will reload if you make edits.<br />
13
+ You will also see any lint errors in the console.
14
+
15
+ ### `npm test`
16
+
17
+ Launches the test runner in the interactive watch mode.<br />
18
+ See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19
+
20
+ ### `npm run build`
21
+
22
+ Builds the app for production to the `build` folder.<br />
23
+ It correctly bundles React in production mode and optimizes the build for the best performance.
24
+
25
+ The build is minified and the filenames include the hashes.<br />
26
+ Your app is ready to be deployed!
27
+
28
+ See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29
+
30
+ ### `npm run eject`
31
+
32
+ **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33
+
34
+ If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35
+
36
+ Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37
+
38
+ You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39
+
40
+ ## Learn More
41
+
42
+ You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43
+
44
+ To learn React, check out the [React documentation](https://reactjs.org/).
45
+
46
+ ### Code Splitting
47
+
48
+ This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49
+
50
+ ### Analyzing the Bundle Size
51
+
52
+ This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53
+
54
+ ### Making a Progressive Web App
55
+
56
+ This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57
+
58
+ ### Advanced Configuration
59
+
60
+ This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61
+
62
+ ### Deployment
63
+
64
+ This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65
+
66
+ ### `npm run build` fails to minify
67
+
68
+ This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
@@ -67,8 +67,11 @@ var Painter = /*#__PURE__*/function () {
67
67
  }, {
68
68
  key: "draw",
69
69
  value: function draw(entities, relationsihps) {
70
- var groups = this.entity().draw(entities.list);
71
- this.ports().drawPorts(groups);
70
+ // entity の描画
71
+ var groups = this.entity().draw(entities.list); // port の描画
72
+
73
+ this.ports().drawPorts(groups); // relationship の描画
74
+
72
75
  this.relationships().drawRelationships(this.background, relationsihps);
73
76
  }
74
77
  }]);
@@ -47,7 +47,7 @@ var Entity = /*#__PURE__*/function () {
47
47
  return this._parent._default;
48
48
  }
49
49
  /* **************************************************************** *
50
- * Move
50
+ * Move
51
51
  * TODO: これは Painter に持っていくべきかも。全部じゃないにしても。
52
52
  * **************************************************************** */
53
53
 
@@ -306,11 +306,15 @@ var Entity = /*#__PURE__*/function () {
306
306
  }, {
307
307
  key: "drawIdentifiers",
308
308
  value: function drawIdentifiers(groups) {
309
+ var callbacks = this.callbacks();
309
310
  var rects = groups.append('rect').attr('class', 'entity-identifiers');
310
311
  this.drawIdentifiersRect(rects);
311
312
  var texts = groups.selectAll('text.identifier').data(function (d) {
312
313
  return d.identifiers.contents.list;
313
- }).enter().append('text').attr('class', 'identifier').attr('identifier-id', function (d) {
314
+ }).enter().append('text').on("click", function (event, d) {
315
+ var func = callbacks.identifier.click;
316
+ if (func) func(d);
317
+ }).attr('class', 'identifier').attr('identifier-id', function (d) {
314
318
  return d._id;
315
319
  });
316
320
  this.drawIdentifiersText(texts).each(function (identifier) {
@@ -355,11 +359,15 @@ var Entity = /*#__PURE__*/function () {
355
359
  }, {
356
360
  key: "drawAttributes",
357
361
  value: function drawAttributes(groups) {
362
+ var callbacks = this.callbacks();
358
363
  var rects = groups.append('rect').attr('class', 'entity-attributes');
359
364
  this.drawAttributesRect(rects);
360
365
  var texts = groups.selectAll('text.attribute').data(function (d) {
361
366
  return d.attributes.contents.list;
362
- }).enter().append('text').attr('class', 'attribute').attr('attribute-id', function (d) {
367
+ }).enter().append('text').on("click", function (event, d) {
368
+ var func = callbacks.attribute.click;
369
+ if (func) func(d);
370
+ }).attr('class', 'attribute').attr('attribute-id', function (d) {
363
371
  return d._id;
364
372
  });
365
373
  this.drawAttributesText(texts).each(function (attribute) {
@@ -0,0 +1,206 @@
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 PortCardinality = /*#__PURE__*/function () {
23
+ function PortCardinality() {
24
+ _classCallCheck(this, PortCardinality);
25
+ }
26
+
27
+ _createClass(PortCardinality, [{
28
+ key: "calLinePoints",
29
+ value: function calLinePoints(port) {
30
+ var table = port._column_instance._table;
31
+ var rect = {
32
+ position: {
33
+ x: table.x,
34
+ y: table.y
35
+ },
36
+ size: {
37
+ w: table.w,
38
+ h: table.h
39
+ }
40
+ };
41
+ var geometry = this.geometry;
42
+ var four_side_lines = geometry.getFourSideLines(rect);
43
+ var line_port = geometry.getPortLine(port, rect);
44
+ var cross_point = geometry.getCrossPoint(four_side_lines, line_port);
45
+ var len = 33 + 4;
46
+ var to_point = cross_point.point;
47
+ var from_point;
48
+
49
+ if (cross_point.target === 'top') {
50
+ from_point = {
51
+ x: to_point.x,
52
+ y: to_point.y + len
53
+ };
54
+ } else if (cross_point.target === 'right') {
55
+ from_point = {
56
+ x: to_point.x - len,
57
+ y: to_point.y
58
+ };
59
+ } else if (cross_point.target === 'bottom') {
60
+ from_point = {
61
+ x: to_point.x,
62
+ y: to_point.y - len
63
+ };
64
+ } else if (cross_point.target === 'left') {
65
+ from_point = {
66
+ x: to_point.x + len,
67
+ y: to_point.y
68
+ };
69
+ }
70
+
71
+ return {
72
+ from: from_point,
73
+ to: to_point
74
+ };
75
+ }
76
+ /* **************************************************************** *
77
+ * Draw Line (port to entity)
78
+ * **************************************************************** */
79
+
80
+ }, {
81
+ key: "drawLine",
82
+ value: function drawLine(g) {
83
+ var _this = this;
84
+
85
+ var lines = g.selectAll('line').data( // (d) => { return d._ports ? d._ports : []; },
86
+ function (d) {
87
+ return d._id;
88
+ }); // delete
89
+
90
+ lines.exit().remove(); // update
91
+
92
+ lines.each(function (d, i) {
93
+ var line = _this.calLinePoints(d);
94
+
95
+ d.position = line.to;
96
+ d.line = line;
97
+ }).attr("x1", function (d) {
98
+ return d.line.from.x;
99
+ }).attr("y1", function (d) {
100
+ return d.line.from.y;
101
+ }).attr("x2", function (d) {
102
+ return d.line.to.x;
103
+ }).attr("y2", function (d) {
104
+ return d.line.to.y;
105
+ }).attr("stroke-width", 3).attr("stroke", "#a3a3a2"); // add
106
+
107
+ lines.enter().each(function (d, i) {
108
+ var line = _this.calLinePoints(d);
109
+
110
+ d.position = line.to;
111
+ d.line = line;
112
+ }).append("line").attr("x1", function (d) {
113
+ return d.line.from.x;
114
+ }).attr("y1", function (d) {
115
+ return d.line.from.y;
116
+ }).attr("x2", function (d) {
117
+ return d.line.to.x;
118
+ }).attr("y2", function (d) {
119
+ return d.line.to.y;
120
+ }).attr("stroke-width", 3).attr("stroke", "#a3a3a2");
121
+ }
122
+ }, {
123
+ key: "drawCardinalityOne",
124
+ value: function drawCardinalityOne(g) {
125
+ var _this2 = this;
126
+
127
+ var filter = function filter() {
128
+ var ports = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
129
+ return ports.filter(function (d) {
130
+ return d.cardinality === 1;
131
+ });
132
+ };
133
+
134
+ var optionalities = g.selectAll('line.cardinality').data(function (d) {
135
+ return filter(d._ports);
136
+ }, function (d) {
137
+ return d._id;
138
+ });
139
+ optionalities.attr("x1", function (d) {
140
+ return d.line_cardinality.from.x;
141
+ }).attr("y1", function (d) {
142
+ return d.line_cardinality.from.y;
143
+ }).attr("x2", function (d) {
144
+ return d.line_cardinality.to.x;
145
+ }).attr("y2", function (d) {
146
+ return d.line_cardinality.to.y;
147
+ }).attr("stroke-width", 3).attr("stroke", "#a3a3a2");
148
+ optionalities.enter().each(function (d) {
149
+ return d.line_cardinality = _this2.calOneLine(d, 11);
150
+ }).append('line').classed("cardinality", true).attr("x1", function (d) {
151
+ return d.line_cardinality.from.x;
152
+ }).attr("y1", function (d) {
153
+ return d.line_cardinality.from.y;
154
+ }).attr("x2", function (d) {
155
+ return d.line_cardinality.to.x;
156
+ }).attr("y2", function (d) {
157
+ return d.line_cardinality.to.y;
158
+ }).attr("stroke-width", 3).attr("stroke", "#a3a3a2");
159
+ }
160
+ }, {
161
+ key: "drawCardinalityThree",
162
+ value: function drawCardinalityThree(g) {
163
+ var _this3 = this;
164
+
165
+ var filter = function filter() {
166
+ var ports = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
167
+ return ports.filter(function (d) {
168
+ return d.cardinality === 3;
169
+ });
170
+ };
171
+
172
+ var optionalities = g.selectAll('path.cardinality').data(function (d) {
173
+ return filter(d._ports);
174
+ }, function (d) {
175
+ return d._id;
176
+ });
177
+ var line = d3.line().x(function (d) {
178
+ return d[0];
179
+ }).y(function (d) {
180
+ return d[1];
181
+ });
182
+ optionalities.each(function (d) {
183
+ return d.line_cardinality_three = _this3.calThreeLine(d, 11);
184
+ }).attr('d', function (d) {
185
+ return line(d.line_cardinality_three);
186
+ }).attr("stroke-width", 3).attr("stroke", "#a3a3a2");
187
+ optionalities.enter().each(function (d) {
188
+ return d.line_cardinality_three = _this3.calThreeLine(d, 11);
189
+ }).append('path').classed("cardinality", true).attr('d', function (d) {
190
+ return line(d.line_cardinality_three);
191
+ }).attr("fill", 'none').attr("stroke-width", 3).attr("stroke", "#a3a3a2");
192
+ }
193
+ }, {
194
+ key: "draw",
195
+ value: function draw(g) {
196
+ // E1のインスタンス1つに対応する、E2のインスタンスの最大数
197
+ // this.drawLine(g);
198
+ this.drawCardinalityOne(g);
199
+ this.drawCardinalityThree(g);
200
+ }
201
+ }]);
202
+
203
+ return PortCardinality;
204
+ }();
205
+
206
+ exports["default"] = PortCardinality;
@@ -0,0 +1,54 @@
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 PortCircle = /*#__PURE__*/function () {
23
+ function PortCircle() {
24
+ _classCallCheck(this, PortCircle);
25
+ }
26
+
27
+ _createClass(PortCircle, [{
28
+ key: "drawPortsCore",
29
+ value: // protected
30
+ function drawPortsCore(ports) {
31
+ ports.attr('class', 'entity-port').attr('cx', function (d) {
32
+ return d.position.x;
33
+ }).attr('cy', function (d) {
34
+ return d.position.y;
35
+ }).attr('r', 4).attr('fill', '#fff').attr('stroke', '#000').attr('stroke-width', 0.5).attr('degree', function (d) {
36
+ return d._owner._core.position || 0;
37
+ }).attr('port-id', function (d) {
38
+ return d._id;
39
+ });
40
+ }
41
+ }, {
42
+ key: "draw",
43
+ value: function draw(groups_entity) {
44
+ var ports = groups_entity.selectAll('circle.entity-port').data(function (d) {
45
+ return d.ports.items.list;
46
+ }).enter().append('circle');
47
+ this.drawPortsCore(ports);
48
+ }
49
+ }]);
50
+
51
+ return PortCircle;
52
+ }();
53
+
54
+ exports["default"] = PortCircle;
@@ -0,0 +1,100 @@
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 PortOptionality = /*#__PURE__*/function () {
23
+ function PortOptionality() {
24
+ _classCallCheck(this, PortOptionality);
25
+ }
26
+
27
+ _createClass(PortOptionality, [{
28
+ key: "drawOptionalityOne",
29
+ value: function drawOptionalityOne(g) {
30
+ var _this = this;
31
+
32
+ var filter = function filter() {
33
+ var ports = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
34
+ return ports.filter(function (d) {
35
+ return d.optionality === 1;
36
+ });
37
+ };
38
+
39
+ var optionalities = g.selectAll('line.optionality').data(function (d) {
40
+ return filter(d._ports);
41
+ }, function (d) {
42
+ return d._id;
43
+ });
44
+ optionalities.enter().each(function (d) {
45
+ return d.line_optionality = _this.calOneLine(d, 22);
46
+ }).append('line').classed("optionality", true).attr("x1", function (d) {
47
+ return d.line_optionality.from.x;
48
+ }).attr("y1", function (d) {
49
+ return d.line_optionality.from.y;
50
+ }).attr("x2", function (d) {
51
+ return d.line_optionality.to.x;
52
+ }).attr("y2", function (d) {
53
+ return d.line_optionality.to.y;
54
+ }).attr("stroke-width", 3).attr("stroke", "#a3a3a2");
55
+ }
56
+ }, {
57
+ key: "drawOptionalityZero",
58
+ value: function drawOptionalityZero(g) {
59
+ var _this2 = this;
60
+
61
+ var filter = function filter() {
62
+ var ports = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
63
+ return ports.filter(function (d) {
64
+ return d.optionality === 0;
65
+ });
66
+ };
67
+
68
+ var optionalities = g.selectAll('circle.optionality').data(function (d) {
69
+ return filter(d._ports);
70
+ }, function (d) {
71
+ return d._id;
72
+ });
73
+ optionalities.each(function (d) {
74
+ return d.line_circle = _this2.calCircle(d);
75
+ }).attr("cx", function (d) {
76
+ return d.line_circle.x;
77
+ }).attr("cy", function (d) {
78
+ return d.line_circle.y;
79
+ }).attr("r", 5).attr("fill", "#fefefe").attr("stroke-width", 3).attr("stroke", "#a3a3a2");
80
+ optionalities.enter().each(function (d) {
81
+ return d.line_circle = _this2.calCircle(d);
82
+ }).append("circle").classed("optionality", true).attr("cx", function (d) {
83
+ return d.line_circle.x;
84
+ }).attr("cy", function (d) {
85
+ return d.line_circle.y;
86
+ }).attr("r", 5).attr("fill", "#fefefe").attr("stroke-width", 3).attr("stroke", "#a3a3a2");
87
+ }
88
+ }, {
89
+ key: "draw",
90
+ value: function draw(g) {
91
+ // E1のインスタンス1つに対応する、E2のインスタンスの最小数
92
+ this.drawOptionalityOne(g);
93
+ this.drawOptionalityZero(g);
94
+ }
95
+ }]);
96
+
97
+ return PortOptionality;
98
+ }();
99
+
100
+ exports["default"] = PortOptionality;
@@ -9,6 +9,16 @@ exports["default"] = void 0;
9
9
 
10
10
  var d3 = _interopRequireWildcard(require("d3"));
11
11
 
12
+ var _Geometry = _interopRequireDefault(require("../Geometry"));
13
+
14
+ var _PortCircle = _interopRequireDefault(require("./PortCircle.js"));
15
+
16
+ var _PortCardinality = _interopRequireDefault(require("./PortCardinality.js"));
17
+
18
+ var _PortOptionality = _interopRequireDefault(require("./PortOptionality.js"));
19
+
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
21
+
12
22
  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
23
 
14
24
  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; }
@@ -22,232 +32,32 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
22
32
  var Ports = /*#__PURE__*/function () {
23
33
  function Ports() {
24
34
  _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
35
 
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
- // }
36
+ this.cardinality = new _PortCardinality["default"]();
37
+ this.optionality = new _PortOptionality["default"]();
38
+ this.circle = new _PortCircle["default"]();
39
+ }
40
+ /* **************************************************************** *
41
+ * こんな感じで書いていた。
42
+ * **************************************************************** */
43
+ // draw (g) {
44
+ // this.drawLine(g);
45
+ // this.drawCardinality(g);
46
+ // this.drawOptionality(g);
47
+ // }
224
48
 
225
- /* **************************************************************** *
226
- * Old
227
- * **************************************************************** */
228
- // protected
49
+ /* **************************************************************** *
50
+ * Old
51
+ * **************************************************************** */
52
+ // public
229
53
 
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
54
 
244
- }, {
55
+ _createClass(Ports, [{
245
56
  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);
57
+ value: function drawPorts(groups_entity) {
58
+ // this.cardinality.draw(groups_entity);
59
+ // this.optionality.draw(groups_entity);
60
+ this.circle.draw(groups_entity);
251
61
  }
252
62
  }]);
253
63
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yanqirenshi/d3.ter",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "author": "yanqirenshi@gmail.com",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "description": "See `src/index.html`",