dcim-topology2d 2.2.3 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/activity-diagram/src/final/final.d.ts +1 -1
- package/activity-diagram/src/final/final.rect.d.ts +1 -1
- package/activity-diagram/src/final/final.rect.js +1 -1
- package/activity-diagram/src/fork/fork.anchor.d.ts +1 -1
- package/activity-diagram/src/fork/fork.anchor.js +1 -1
- package/activity-diagram/src/fork/fork.d.ts +1 -1
- package/activity-diagram/src/fork/fork.rect.d.ts +1 -1
- package/activity-diagram/src/fork/fork.rect.js +1 -1
- package/activity-diagram/src/register.js +1 -1
- package/activity-diagram/src/swimlaneH/swimlaneH.d.ts +1 -1
- package/activity-diagram/src/swimlaneH/swimlaneH.rect.d.ts +1 -1
- package/activity-diagram/src/swimlaneH/swimlaneH.rect.js +1 -1
- package/activity-diagram/src/swimlaneV/swimlaneV.d.ts +1 -1
- package/activity-diagram/src/swimlaneV/swimlaneV.rect.d.ts +1 -1
- package/activity-diagram/src/swimlaneV/swimlaneV.rect.js +1 -1
- package/chart-diagram/index.d.ts +1 -3
- package/chart-diagram/index.js +1 -2
- package/chart-diagram/src/echarts/index.d.ts +2 -1
- package/chart-diagram/src/echarts/index.js +78 -86
- package/chart-diagram/src/register.js +8 -9
- package/class-diagram/src/class/class.d.ts +1 -1
- package/class-diagram/src/class/class.rect.d.ts +1 -1
- package/class-diagram/src/class/class.rect.js +1 -1
- package/class-diagram/src/register.js +1 -1
- package/core/index.d.ts +0 -2
- package/core/index.js +18 -2
- package/core/src/activeLayer.d.ts +10 -2
- package/core/src/activeLayer.js +62 -57
- package/core/src/animateLayer.d.ts +7 -3
- package/core/src/animateLayer.js +12 -10
- package/core/src/calling.d.ts +4 -1
- package/core/src/calling.js +68 -69
- package/core/src/canvas.d.ts +6 -1
- package/core/src/canvas.js +21 -22
- package/core/src/common.d.ts +7 -7
- package/core/src/common.js +698 -397
- package/core/src/core.d.ts +4 -5
- package/core/src/core.js +385 -536
- package/core/src/divLayer.d.ts +36 -2
- package/core/src/divLayer.js +305 -33
- package/core/src/healps/changeData.d.ts +2 -1
- package/core/src/healps/changeData.js +100 -89
- package/core/src/hoverLayer.d.ts +9 -2
- package/core/src/hoverLayer.js +34 -31
- package/core/src/middles/default.d.ts +3 -1
- package/core/src/middles/default.js +51 -65
- package/core/src/middles/index.d.ts +2 -1
- package/core/src/middles/index.js +2 -4
- package/core/src/middles/nodes/arbitrarygraph.js +9 -11
- package/core/src/middles/nodes/pentagon.rect.js +1 -1
- package/core/src/middles/nodes/rectangle.js +15 -54
- package/core/src/middles/nodes/rectangle.rect.js +1 -1
- package/core/src/models/data.d.ts +26 -0
- package/core/src/models/data.js +77 -0
- package/core/src/models/data.js.map +1 -0
- package/core/src/models/index.d.ts +1 -0
- package/core/src/models/index.js +1 -0
- package/core/src/models/line.js +7 -7
- package/core/src/models/node.d.ts +0 -10
- package/core/src/models/node.js +101 -155
- package/core/src/models/pen.js +68 -37
- package/core/src/models/rect.js +2 -2
- package/core/src/mqtt.d.ts +14 -0
- package/core/src/mqtt.js +82 -0
- package/core/src/mqtt.js.map +1 -0
- package/core/src/offscreen.d.ts +4 -1
- package/core/src/offscreen.js +24 -26
- package/core/src/options.d.ts +1 -3
- package/core/src/options.js +0 -2
- package/core/src/poll.js +39 -0
- package/core/src/preview.d.ts +13 -2
- package/core/src/preview.js +54 -181
- package/core/src/renderLayer.d.ts +9 -11
- package/core/src/renderLayer.js +61 -60
- package/core/src/socket.d.ts +10 -0
- package/core/src/socket.js +51 -0
- package/core/src/socket.js.map +1 -0
- package/core/src/utils/canvas.js +1 -1
- package/core/src/utils/construction.d.ts +3 -36
- package/core/src/utils/construction.js +1 -29
- package/core/src/utils/conversion.d.ts +0 -15
- package/core/src/utils/conversion.js +0 -319
- package/core/src/utils/dom.d.ts +8 -0
- package/core/src/utils/dom.js +67 -0
- package/core/src/utils/dom.js.map +1 -0
- package/core/src/utils/index.d.ts +1 -2
- package/core/src/utils/index.js +1 -2
- package/core/src/utils/onmousevent.d.ts +0 -3
- package/core/src/utils/onmousevent.js +10 -42
- package/flow-diagram/src/comment/comment.anchor.d.ts +1 -1
- package/flow-diagram/src/comment/comment.anchor.js +1 -1
- package/flow-diagram/src/comment/comment.d.ts +1 -1
- package/flow-diagram/src/data/data.anchor.d.ts +1 -1
- package/flow-diagram/src/data/data.anchor.js +1 -1
- package/flow-diagram/src/data/data.d.ts +1 -1
- package/flow-diagram/src/data/data.rect.d.ts +1 -1
- package/flow-diagram/src/data/data.rect.js +1 -1
- package/flow-diagram/src/db/db.d.ts +1 -1
- package/flow-diagram/src/db/db.rect.d.ts +1 -1
- package/flow-diagram/src/db/db.rect.js +1 -1
- package/flow-diagram/src/display/display.anchor.d.ts +1 -1
- package/flow-diagram/src/display/display.anchor.js +1 -1
- package/flow-diagram/src/display/display.d.ts +1 -1
- package/flow-diagram/src/display/display.rect.d.ts +1 -1
- package/flow-diagram/src/display/display.rect.js +1 -1
- package/flow-diagram/src/document/document.anchor.d.ts +1 -1
- package/flow-diagram/src/document/document.anchor.js +1 -1
- package/flow-diagram/src/document/document.d.ts +1 -1
- package/flow-diagram/src/document/document.rect.d.ts +1 -1
- package/flow-diagram/src/document/document.rect.js +1 -1
- package/flow-diagram/src/externStorage/externStorage.anchor.d.ts +1 -1
- package/flow-diagram/src/externStorage/externStorage.anchor.js +1 -1
- package/flow-diagram/src/externStorage/externStorage.d.ts +1 -1
- package/flow-diagram/src/externStorage/externStorage.rect.d.ts +1 -1
- package/flow-diagram/src/externStorage/externStorage.rect.js +1 -1
- package/flow-diagram/src/internalStorage/internalStorage.d.ts +1 -1
- package/flow-diagram/src/internalStorage/internalStorage.rect.d.ts +1 -1
- package/flow-diagram/src/internalStorage/internalStorage.rect.js +1 -1
- package/flow-diagram/src/manually/manually.anchor.d.ts +1 -1
- package/flow-diagram/src/manually/manually.anchor.js +1 -1
- package/flow-diagram/src/manually/manually.d.ts +1 -1
- package/flow-diagram/src/manually/manually.rect.d.ts +1 -1
- package/flow-diagram/src/manually/manually.rect.js +1 -1
- package/flow-diagram/src/parallel/parallel.anchor.d.ts +1 -1
- package/flow-diagram/src/parallel/parallel.anchor.js +1 -1
- package/flow-diagram/src/parallel/parallel.d.ts +1 -1
- package/flow-diagram/src/queue/queue.d.ts +1 -1
- package/flow-diagram/src/queue/queue.rect.d.ts +1 -1
- package/flow-diagram/src/queue/queue.rect.js +1 -1
- package/flow-diagram/src/register.js +1 -1
- package/flow-diagram/src/subprocess/subprocess.d.ts +1 -1
- package/flow-diagram/src/subprocess/subprocess.rect.d.ts +1 -1
- package/flow-diagram/src/subprocess/subprocess.rect.js +1 -1
- package/layout/src/align.d.ts +1 -1
- package/layout/src/align.js +1 -1
- package/layout/src/layout.d.ts +1 -1
- package/layout/src/layout.js +1 -1
- package/myShape-diagram/{index.js → myShape.js} +1 -4
- package/package.json +1 -1
- package/sequence-diagram/src/focus/focus.anchor.d.ts +1 -1
- package/sequence-diagram/src/focus/focus.anchor.js +1 -1
- package/sequence-diagram/src/focus/focus.d.ts +1 -1
- package/sequence-diagram/src/focus/focus.rect.d.ts +1 -1
- package/sequence-diagram/src/focus/focus.rect.js +1 -1
- package/sequence-diagram/src/lifeline/lifeline.anchor.d.ts +1 -1
- package/sequence-diagram/src/lifeline/lifeline.anchor.js +1 -1
- package/sequence-diagram/src/lifeline/lifeline.d.ts +1 -1
- package/sequence-diagram/src/lifeline/lifeline.rect.d.ts +1 -1
- package/sequence-diagram/src/lifeline/lifeline.rect.js +1 -1
- package/sequence-diagram/src/register.js +1 -1
- package/chart-diagram/src/utils/changeOptions.d.ts +0 -8
- package/chart-diagram/src/utils/changeOptions.js +0 -273
- package/chart-diagram/src/utils/conversion.d.ts +0 -19
- package/chart-diagram/src/utils/conversion.js +0 -601
- package/chart-diagram/src/utils/drawGraphic.d.ts +0 -3
- package/chart-diagram/src/utils/drawGraphic.js +0 -97
- package/chart-diagram/src/utils/formatter.d.ts +0 -1
- package/chart-diagram/src/utils/formatter.js +0 -206
- package/chart-diagram/src/utils/index.d.ts +0 -5
- package/chart-diagram/src/utils/index.js +0 -5
- package/chart-diagram/src/utils/render.d.ts +0 -8
- package/chart-diagram/src/utils/render.js +0 -223
- package/chart-diagram/src/utils/surfaceParametricConversion.d.ts +0 -3
- package/chart-diagram/src/utils/surfaceParametricConversion.js +0 -252
- package/core/src/element/common.d.ts +0 -6
- package/core/src/element/common.js +0 -62
- package/core/src/element/datePicker.d.ts +0 -3
- package/core/src/element/datePicker.js +0 -44
- package/core/src/element/iframe.d.ts +0 -3
- package/core/src/element/iframe.js +0 -12
- package/core/src/element/index.d.ts +0 -5
- package/core/src/element/index.js +0 -6
- package/core/src/element/select.d.ts +0 -11
- package/core/src/element/select.js +0 -273
- package/core/src/element/tab.d.ts +0 -1
- package/core/src/element/tab.js +0 -20
- package/core/src/element/time.d.ts +0 -3
- package/core/src/element/time.js +0 -44
- package/core/src/middles/arrows/index.d.ts +0 -4
- package/core/src/middles/arrows/index.js +0 -5
- package/core/src/middles/lines/index.d.ts +0 -4
- package/core/src/middles/lines/index.js +0 -5
- package/core/src/middles/nodes/formDatePicker.d.ts +0 -2
- package/core/src/middles/nodes/formDatePicker.js +0 -108
- package/core/src/middles/nodes/formoverflow.js +0 -62
- package/core/src/middles/nodes/formselect.d.ts +0 -2
- package/core/src/middles/nodes/formselect.js +0 -111
- package/core/src/middles/nodes/iframe.d.ts +0 -2
- package/core/src/middles/nodes/iframe.js +0 -29
- package/core/src/middles/nodes/index.d.ts +0 -52
- package/core/src/middles/nodes/index.js +0 -54
- package/core/src/middles/nodes/progress.d.ts +0 -2
- package/core/src/middles/nodes/progress.js +0 -63
- package/core/src/middles/nodes/progress.js.map +0 -1
- package/core/src/middles/nodes/switchs.d.ts +0 -2
- package/core/src/middles/nodes/switchs.js +0 -46
- package/core/src/middles/nodes/time.d.ts +0 -2
- package/core/src/middles/nodes/time.js +0 -98
- package/core/src/store/common.d.ts +0 -9
- package/core/src/store/common.js +0 -5
- package/core/src/store/data.d.ts +0 -205
- package/core/src/store/data.js +0 -198
- package/core/src/store/index.d.ts +0 -2
- package/core/src/store/index.js +0 -2
- package/core/src/utils/assignment.d.ts +0 -7
- package/core/src/utils/assignment.js +0 -229
- package/core/src/utils/params.d.ts +0 -3
- package/core/src/utils/params.js +0 -136
- package/static/echartsDefaultData.js +0 -178
- package/static/element.js +0 -14
- package/static/form.js +0 -11
- package/static/index.js +0 -3
- package/store/actions.js +0 -2
- package/store/clear.js +0 -14
- package/store/default.js +0 -22
- package/store/index.js +0 -3
- package/style/common.css +0 -15
- package/style/datePicker.css +0 -44
- package/style/editor.css +0 -16
- package/style/index.css +0 -5
- package/style/select.css +0 -143
- /package/myShape-diagram/{index.d.ts → myShape.ts} +0 -0
package/core/src/calling.js
CHANGED
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
import {Store} from 'le5le-store';
|
|
2
|
+
import {DefalutOptions} from './options';
|
|
2
3
|
import {Offscreen} from './offscreen';
|
|
3
4
|
import {RenderLayer} from './renderLayer';
|
|
4
|
-
import {Node} from './models';
|
|
5
|
+
import {Node, Point, TopologyData, Rect} from './models';
|
|
5
6
|
import {s8, getRect, formatPadding} from './utils';
|
|
6
|
-
import { useStore, clearStore } from './store'
|
|
7
7
|
var Calling = (function () {
|
|
8
8
|
function Calling(parent, options) {
|
|
9
9
|
var _this = this;
|
|
10
|
+
this.data = new TopologyData();
|
|
10
11
|
this.lastTranlated = {x: 0, y: 0};
|
|
11
12
|
this.rendering = false;
|
|
12
13
|
this.id = s8();
|
|
13
|
-
this.
|
|
14
|
+
Store.set(this.generateStoreKey('topology-data'), this.data);
|
|
14
15
|
if (!options) {
|
|
15
16
|
options = {};
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
var font = Object.assign({}, DefalutOptions.font, options.font);
|
|
19
|
+
options.font = font;
|
|
20
|
+
this.options = Object.assign({}, DefalutOptions, options);
|
|
19
21
|
if (typeof parent === 'string') {
|
|
20
|
-
this.
|
|
22
|
+
this.parentElem = document.getElementById(parent);
|
|
21
23
|
} else {
|
|
22
|
-
this.
|
|
24
|
+
this.parentElem = parent;
|
|
23
25
|
}
|
|
24
|
-
this.
|
|
25
|
-
this.
|
|
26
|
-
|
|
27
|
-
this.
|
|
26
|
+
this.parentElem.style.position = 'relative';
|
|
27
|
+
this.parentElem.style.overflow = 'auto';
|
|
28
|
+
var id = this.id;
|
|
29
|
+
this.offscreen = new Offscreen(this.parentElem, this.options, id);
|
|
30
|
+
this.canvas = new RenderLayer(this.parentElem, this.options, id);
|
|
28
31
|
this.subcribeImage = Store.subscribe(this.generateStoreKey('LT:imageLoaded'), function () {
|
|
29
32
|
if (_this.imageTimer) {
|
|
30
33
|
clearTimeout(_this.imageTimer);
|
|
@@ -65,65 +68,52 @@ var Calling = (function () {
|
|
|
65
68
|
data = JSON.parse(data);
|
|
66
69
|
}
|
|
67
70
|
this.openCount = 0
|
|
68
|
-
this.
|
|
69
|
-
this.
|
|
71
|
+
this.data.scale = data.scale || 1;
|
|
72
|
+
this.data.pens = [];
|
|
70
73
|
// for old data.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
// }
|
|
84
|
-
// }
|
|
74
|
+
if (data.nodes) {
|
|
75
|
+
for (var _i = 0, _a = data.nodes; _i < _a.length; _i++) {
|
|
76
|
+
var item = _a[_i];
|
|
77
|
+
item.rect.x = 0;
|
|
78
|
+
item.rect.y = 0;
|
|
79
|
+
this.data.pens.push(new Node(item));
|
|
80
|
+
}
|
|
81
|
+
for (var _b = 0, _c = data.lines; _b < _c.length; _b++) {
|
|
82
|
+
var item = _c[_b];
|
|
83
|
+
this.data.pens.push(new Line(item));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
85
86
|
// end.
|
|
86
87
|
if (data.pens) {
|
|
87
88
|
for (var _d = 0, _e = data.pens; _d < _e.length; _d++) {
|
|
88
89
|
var item = _e[_d];
|
|
89
|
-
item.TID = this.id;
|
|
90
|
-
if(!this.store.options.isFitview) {
|
|
91
|
-
if(item.rect.x > 0) {
|
|
92
|
-
item.rect.ex -= item.rect.x;
|
|
93
|
-
item.rect.x = 0;
|
|
94
|
-
}
|
|
95
|
-
if(item.rect.y > 0) {
|
|
96
|
-
item.rect.ey -= item.rect.y;
|
|
97
|
-
item.rect.y = 0;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
90
|
if (!item.from) {
|
|
101
|
-
this.
|
|
91
|
+
this.data.pens.push(new Node(item));
|
|
102
92
|
} else {
|
|
103
|
-
this.
|
|
93
|
+
this.data.pens.push(new Line(item));
|
|
104
94
|
}
|
|
105
95
|
}
|
|
106
96
|
}
|
|
107
|
-
this.
|
|
108
|
-
this.
|
|
109
|
-
this.
|
|
110
|
-
this.
|
|
97
|
+
this.data.bkImageRect = data.bkImageRect || null;
|
|
98
|
+
this.data.bkImage = data.bkImage || '';
|
|
99
|
+
this.data.mqttOptions = data.mqttOptions || {clientId: s8()};
|
|
100
|
+
this.data.mqttTopics = data.mqttTopics || '';
|
|
111
101
|
if (typeof data.data === 'object') {
|
|
112
|
-
this.
|
|
102
|
+
this.data.data = data.data;
|
|
113
103
|
} else {
|
|
114
|
-
this.
|
|
104
|
+
this.data.data = data.data || '';
|
|
115
105
|
}
|
|
116
|
-
this.
|
|
117
|
-
this.
|
|
106
|
+
this.parentElem.scrollLeft = 0;
|
|
107
|
+
this.parentElem.scrollTop = 0;
|
|
118
108
|
this.overflow();
|
|
119
109
|
this.render(true);
|
|
120
110
|
};
|
|
121
111
|
Calling.prototype.overflow = function () {
|
|
122
|
-
this.
|
|
112
|
+
this.options.isFitview ? this.fitView() : this.bottomView();
|
|
123
113
|
};
|
|
124
114
|
Calling.prototype.getRect = function (pens) {
|
|
125
115
|
if (!pens) {
|
|
126
|
-
pens = this.
|
|
116
|
+
pens = this.data.pens;
|
|
127
117
|
}
|
|
128
118
|
return getRect(pens);
|
|
129
119
|
};
|
|
@@ -134,7 +124,7 @@ var Calling = (function () {
|
|
|
134
124
|
}
|
|
135
125
|
var offsetX = x - this.lastTranlated.x;
|
|
136
126
|
var offsetY = y - this.lastTranlated.y;
|
|
137
|
-
for (var _i = 0, _a = this.
|
|
127
|
+
for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
|
|
138
128
|
var item = _a[_i];
|
|
139
129
|
item.translate(offsetX, offsetY);
|
|
140
130
|
}
|
|
@@ -145,14 +135,13 @@ var Calling = (function () {
|
|
|
145
135
|
// > 1, expand
|
|
146
136
|
// < 1, reduce
|
|
147
137
|
Calling.prototype.scale = function (scale, center, w, h) {
|
|
148
|
-
if (this.
|
|
149
|
-
|
|
138
|
+
if (this.data.scale * scale < this.options.minScale ||
|
|
139
|
+
this.data.scale * scale > this.options.maxScale) {
|
|
150
140
|
return;
|
|
151
141
|
}
|
|
152
|
-
this.
|
|
142
|
+
this.data.scale *= scale;
|
|
153
143
|
!center && (center = this.getRect().center);
|
|
154
|
-
|
|
155
|
-
for (var _i = 0, _a = this.store.data.pens; _i < _a.length; _i++) {
|
|
144
|
+
for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
|
|
156
145
|
var item = _a[_i];
|
|
157
146
|
item.scale(scale, center, w, h);
|
|
158
147
|
}
|
|
@@ -161,17 +150,28 @@ var Calling = (function () {
|
|
|
161
150
|
var rect = this.getRect();
|
|
162
151
|
var viewCenter = this.getViewCenter(padding);
|
|
163
152
|
var center = rect.center;
|
|
164
|
-
var parentElem = this.
|
|
153
|
+
var parentElem = this.canvas.parentElem;
|
|
165
154
|
var x = (parentElem.offsetWidth - rect.width) / 2;
|
|
166
155
|
var y = parentElem.scrollHeight - rect.height;
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
156
|
+
var w = parentElem.offsetWidth / rect.width;
|
|
157
|
+
var h = parentElem.scrollHeight / rect.height;
|
|
158
|
+
var ratio = w;
|
|
159
|
+
if (w > h) {
|
|
160
|
+
ratio = h;
|
|
161
|
+
}
|
|
173
162
|
this.canvas.canvas.style.transform = `translate(${x}px, ${y}px)`;
|
|
174
|
-
this.
|
|
163
|
+
for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
|
|
164
|
+
var item = _a[_i];
|
|
165
|
+
if(item.rect.x > 0) {
|
|
166
|
+
item.rect.ex = item.rect.ex - item.rect.x;
|
|
167
|
+
item.rect.x = 0;
|
|
168
|
+
}
|
|
169
|
+
if(item.rect.y > 0) {
|
|
170
|
+
item.rect.ey = item.rect.ey - item.rect.y;
|
|
171
|
+
item.rect.y = 0;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
this.scale(ratio);
|
|
175
175
|
this.resize({width: rect.width, height: rect.height});
|
|
176
176
|
};
|
|
177
177
|
Calling.prototype.centerView = function (padding) {
|
|
@@ -181,7 +181,7 @@ var Calling = (function () {
|
|
|
181
181
|
var viewCenter = this.getViewCenter(padding);
|
|
182
182
|
var center = rect.center;
|
|
183
183
|
this.translate(viewCenter.x - center.x, viewCenter.y - center.y);
|
|
184
|
-
var parentElem = this.
|
|
184
|
+
var parentElem = this.canvas.parentElem;
|
|
185
185
|
var x = (parentElem.scrollWidth - parentElem.offsetWidth) / 2;
|
|
186
186
|
var y = (parentElem.scrollHeight - parentElem.offsetHeight) / 2;
|
|
187
187
|
parentElem.scrollTo(x, y);
|
|
@@ -191,7 +191,7 @@ var Calling = (function () {
|
|
|
191
191
|
if (!this.hasView())
|
|
192
192
|
return;
|
|
193
193
|
// 1. 重置画布尺寸为容器尺寸
|
|
194
|
-
var parentElem = this.
|
|
194
|
+
var parentElem = this.canvas.parentElem;
|
|
195
195
|
var width = parentElem.offsetWidth, height = parentElem.offsetHeight;
|
|
196
196
|
this.resize({
|
|
197
197
|
width: width,
|
|
@@ -200,7 +200,7 @@ var Calling = (function () {
|
|
|
200
200
|
// 2. 图形居中
|
|
201
201
|
this.centerView(viewPadding);
|
|
202
202
|
// 3. 获取设置的留白值
|
|
203
|
-
var padding = formatPadding(viewPadding || this.
|
|
203
|
+
var padding = formatPadding(viewPadding || this.options.viewPadding);
|
|
204
204
|
// 4. 获取图形尺寸
|
|
205
205
|
var rect = this.getRect();
|
|
206
206
|
// 6. 计算缩放比
|
|
@@ -217,7 +217,7 @@ var Calling = (function () {
|
|
|
217
217
|
return !(rect.width === 99999 || rect.height === 99999);
|
|
218
218
|
};
|
|
219
219
|
Calling.prototype.getViewCenter = function (viewPadding) {
|
|
220
|
-
var padding = formatPadding(viewPadding || this.
|
|
220
|
+
var padding = formatPadding(viewPadding || this.options.viewPadding);
|
|
221
221
|
var _a = this.canvas, width = _a.width, height = _a.height;
|
|
222
222
|
return {
|
|
223
223
|
x: (width - padding[1] - padding[3]) / 2 + padding[3],
|
|
@@ -228,7 +228,6 @@ var Calling = (function () {
|
|
|
228
228
|
return this.id + "-" + key;
|
|
229
229
|
};
|
|
230
230
|
Calling.prototype.destroy = function () {
|
|
231
|
-
clearStore(this.store);
|
|
232
231
|
this.subcribeImage.unsubscribe();
|
|
233
232
|
this.canvas.destroy();
|
|
234
233
|
//优化
|
package/core/src/canvas.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
import { TopologyData } from './models/data';
|
|
2
|
+
import { Options } from './options';
|
|
1
3
|
import { Layer } from './layer';
|
|
2
4
|
export declare class Canvas extends Layer {
|
|
5
|
+
parentElem: HTMLElement;
|
|
6
|
+
options: Options;
|
|
3
7
|
static dpiRatio: number;
|
|
8
|
+
protected data: TopologyData;
|
|
4
9
|
canvas: HTMLCanvasElement;
|
|
5
10
|
width: number;
|
|
6
11
|
height: number;
|
|
7
|
-
constructor(TID: String);
|
|
12
|
+
constructor(parentElem: HTMLElement, options: Options, TID: String);
|
|
8
13
|
resize(size?: {
|
|
9
14
|
width: number;
|
|
10
15
|
height: number;
|
package/core/src/canvas.js
CHANGED
|
@@ -13,59 +13,58 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
13
13
|
})();
|
|
14
14
|
import { Store } from 'le5le-store';
|
|
15
15
|
import { Layer } from './layer';
|
|
16
|
-
import { commonStore } from './store'
|
|
17
16
|
var Canvas = /** @class */ (function (_super) {
|
|
18
17
|
__extends(Canvas, _super);
|
|
19
|
-
function Canvas(TID) {
|
|
18
|
+
function Canvas(parentElem, options, TID) {
|
|
19
|
+
if (options === void 0) { options = {}; }
|
|
20
20
|
var _this = _super.call(this, TID) || this;
|
|
21
|
+
_this.parentElem = parentElem;
|
|
22
|
+
_this.options = options;
|
|
21
23
|
_this.canvas = document.createElement('canvas');
|
|
22
|
-
_this.
|
|
23
|
-
_this.
|
|
24
|
-
_this.
|
|
24
|
+
_this.width = parentElem.clientWidth;
|
|
25
|
+
_this.height = parentElem.clientHeight;
|
|
26
|
+
_this.data = Store.get(_this.generateStoreKey('topology-data'));
|
|
25
27
|
_this.canvas.style.position = 'absolute';
|
|
26
28
|
_this.canvas.style.left = '0';
|
|
27
29
|
_this.canvas.style.top = '0';
|
|
28
30
|
_this.canvas.style.outline = 'none';
|
|
29
31
|
if (!Canvas.dpiRatio) {
|
|
30
|
-
if (!
|
|
32
|
+
if (!options.extDpiRatio && options.extDpiRatio !== 0) {
|
|
31
33
|
if (window.devicePixelRatio > 1) {
|
|
32
|
-
|
|
34
|
+
options.extDpiRatio = 0.25;
|
|
33
35
|
}
|
|
34
36
|
else {
|
|
35
|
-
|
|
37
|
+
options.extDpiRatio = 0;
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
|
-
Canvas.dpiRatio = window.devicePixelRatio +
|
|
40
|
+
Canvas.dpiRatio = window.devicePixelRatio + options.extDpiRatio;
|
|
39
41
|
}
|
|
40
42
|
return _this;
|
|
41
43
|
}
|
|
42
44
|
Canvas.prototype.resize = function (size) {
|
|
43
45
|
if (size) {
|
|
44
|
-
this.width = size.width
|
|
46
|
+
this.width = size.width | 0;
|
|
45
47
|
this.height = size.height | 0;
|
|
46
48
|
}
|
|
47
49
|
else {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (commonStore[TID].options.width && commonStore[TID].options.width !== 'auto') {
|
|
51
|
-
this.width = commonStore[TID].options.width;
|
|
50
|
+
if (this.options.width && this.options.width !== 'auto') {
|
|
51
|
+
this.width = this.options.width;
|
|
52
52
|
}
|
|
53
53
|
else {
|
|
54
|
-
this.width =
|
|
54
|
+
this.width = this.parentElem.clientWidth;
|
|
55
55
|
}
|
|
56
|
-
if (
|
|
57
|
-
this.height =
|
|
56
|
+
if (this.options.height && this.options.height !== 'auto') {
|
|
57
|
+
this.height = this.options.height;
|
|
58
58
|
}
|
|
59
59
|
else {
|
|
60
|
-
this.height =
|
|
60
|
+
this.height = this.parentElem.clientHeight;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
this.canvas.style.width = this.width + 'px';
|
|
64
64
|
this.canvas.style.height = this.height + 'px';
|
|
65
|
-
|
|
66
|
-
this.canvas.
|
|
67
|
-
this.canvas.
|
|
68
|
-
this.canvas.getContext('2d').scale(dpr, dpr);
|
|
65
|
+
this.canvas.width = (this.width * Canvas.dpiRatio) | 0;
|
|
66
|
+
this.canvas.height = (this.height * Canvas.dpiRatio) | 0;
|
|
67
|
+
this.canvas.getContext('2d').scale(Canvas.dpiRatio, Canvas.dpiRatio);
|
|
69
68
|
Store.set(this.generateStoreKey('LT:size'), { width: this.canvas.width, height: this.canvas.height });
|
|
70
69
|
};
|
|
71
70
|
Canvas.prototype.render = function () {
|
package/core/src/common.d.ts
CHANGED
|
@@ -4,9 +4,9 @@ import { DivLayer } from './divLayer';
|
|
|
4
4
|
import { AnimateLayer } from './animateLayer';
|
|
5
5
|
import { RenderLayer } from './renderLayer';
|
|
6
6
|
import { Offscreen } from './offscreen';
|
|
7
|
-
import {Line, Node, Pen, Point, Rect} from './models';
|
|
7
|
+
import {Line, Node, Pen, Point, Rect, TopologyData} from './models';
|
|
8
8
|
import {Padding, Options} from './options';
|
|
9
|
-
import {
|
|
9
|
+
import { Socket } from './socket';
|
|
10
10
|
declare enum MoveInType {
|
|
11
11
|
None = 0,
|
|
12
12
|
Line = 1,
|
|
@@ -21,7 +21,8 @@ declare enum MoveInType {
|
|
|
21
21
|
}
|
|
22
22
|
export declare class Common {
|
|
23
23
|
//constructor(parent: HTMLElement, options: Options);
|
|
24
|
-
|
|
24
|
+
options: Options;
|
|
25
|
+
data: TopologyData;
|
|
25
26
|
moveInType: MoveInType;
|
|
26
27
|
id: String;
|
|
27
28
|
parentElem: HTMLElement;
|
|
@@ -32,6 +33,7 @@ export declare class Common {
|
|
|
32
33
|
input: HTMLTextAreaElement;
|
|
33
34
|
tipMarkdown: HTMLElement;
|
|
34
35
|
tipElem: HTMLElement;
|
|
36
|
+
socket: Socket;
|
|
35
37
|
private subcribe;
|
|
36
38
|
private subcribeRender;
|
|
37
39
|
private subcribeImage;
|
|
@@ -51,14 +53,11 @@ export declare class Common {
|
|
|
51
53
|
private showTip;
|
|
52
54
|
private hideTip;
|
|
53
55
|
inputObj: Pen;
|
|
54
|
-
tabsContentOptions: {};
|
|
55
56
|
mouseDown: {
|
|
56
57
|
x: number;
|
|
57
58
|
y: number;
|
|
58
59
|
restore?: boolean;
|
|
59
60
|
};
|
|
60
|
-
renderTimer: number;
|
|
61
|
-
lastRender: number;
|
|
62
61
|
lastTranlated: {
|
|
63
62
|
x: number;
|
|
64
63
|
y: number;
|
|
@@ -76,7 +75,8 @@ export declare class Common {
|
|
|
76
75
|
ratioCord: Object;
|
|
77
76
|
_emitter: Emitter;
|
|
78
77
|
conversionData(data?: any): void;
|
|
79
|
-
|
|
78
|
+
setSwitchTabData(node: Node | any, index: Number): void;
|
|
79
|
+
switchStaticsCheckType(node: Node | any): any;
|
|
80
80
|
canvasResize(size?: {
|
|
81
81
|
width: number;
|
|
82
82
|
height: number;
|