@joint/core 4.0.0
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/LICENSE +376 -0
- package/README.md +49 -0
- package/dist/geometry.js +6486 -0
- package/dist/geometry.min.js +8 -0
- package/dist/joint.d.ts +5536 -0
- package/dist/joint.js +39629 -0
- package/dist/joint.min.js +8 -0
- package/dist/joint.nowrap.js +39626 -0
- package/dist/joint.nowrap.min.js +8 -0
- package/dist/vectorizer.js +9135 -0
- package/dist/vectorizer.min.js +8 -0
- package/dist/version.mjs +3 -0
- package/index.js +3 -0
- package/joint.mjs +27 -0
- package/package.json +192 -0
- package/src/V/annotation.mjs +0 -0
- package/src/V/index.mjs +2642 -0
- package/src/anchors/index.mjs +123 -0
- package/src/config/index.mjs +12 -0
- package/src/connectionPoints/index.mjs +202 -0
- package/src/connectionStrategies/index.mjs +73 -0
- package/src/connectors/curve.mjs +553 -0
- package/src/connectors/index.mjs +6 -0
- package/src/connectors/jumpover.mjs +452 -0
- package/src/connectors/normal.mjs +12 -0
- package/src/connectors/rounded.mjs +17 -0
- package/src/connectors/smooth.mjs +44 -0
- package/src/connectors/straight.mjs +110 -0
- package/src/dia/Cell.mjs +945 -0
- package/src/dia/CellView.mjs +1316 -0
- package/src/dia/Element.mjs +519 -0
- package/src/dia/ElementView.mjs +859 -0
- package/src/dia/Graph.mjs +1112 -0
- package/src/dia/HighlighterView.mjs +319 -0
- package/src/dia/Link.mjs +565 -0
- package/src/dia/LinkView.mjs +2207 -0
- package/src/dia/Paper.mjs +3171 -0
- package/src/dia/PaperLayer.mjs +75 -0
- package/src/dia/ToolView.mjs +69 -0
- package/src/dia/ToolsView.mjs +128 -0
- package/src/dia/attributes/calc.mjs +128 -0
- package/src/dia/attributes/connection.mjs +75 -0
- package/src/dia/attributes/defs.mjs +76 -0
- package/src/dia/attributes/eval.mjs +64 -0
- package/src/dia/attributes/index.mjs +69 -0
- package/src/dia/attributes/legacy.mjs +148 -0
- package/src/dia/attributes/offset.mjs +53 -0
- package/src/dia/attributes/props.mjs +30 -0
- package/src/dia/attributes/shape.mjs +92 -0
- package/src/dia/attributes/text.mjs +180 -0
- package/src/dia/index.mjs +13 -0
- package/src/dia/layers/GridLayer.mjs +176 -0
- package/src/dia/ports.mjs +874 -0
- package/src/elementTools/Control.mjs +153 -0
- package/src/elementTools/HoverConnect.mjs +37 -0
- package/src/elementTools/index.mjs +5 -0
- package/src/env/index.mjs +43 -0
- package/src/g/bezier.mjs +175 -0
- package/src/g/curve.mjs +956 -0
- package/src/g/ellipse.mjs +245 -0
- package/src/g/extend.mjs +64 -0
- package/src/g/geometry.helpers.mjs +58 -0
- package/src/g/index.mjs +17 -0
- package/src/g/intersection.mjs +511 -0
- package/src/g/line.bearing.mjs +30 -0
- package/src/g/line.length.mjs +5 -0
- package/src/g/line.mjs +356 -0
- package/src/g/line.squaredLength.mjs +10 -0
- package/src/g/path.mjs +2260 -0
- package/src/g/point.mjs +375 -0
- package/src/g/points.mjs +247 -0
- package/src/g/polygon.mjs +51 -0
- package/src/g/polyline.mjs +523 -0
- package/src/g/rect.mjs +556 -0
- package/src/g/types.mjs +10 -0
- package/src/highlighters/addClass.mjs +27 -0
- package/src/highlighters/index.mjs +5 -0
- package/src/highlighters/list.mjs +111 -0
- package/src/highlighters/mask.mjs +220 -0
- package/src/highlighters/opacity.mjs +17 -0
- package/src/highlighters/stroke.mjs +100 -0
- package/src/layout/index.mjs +4 -0
- package/src/layout/ports/port.mjs +188 -0
- package/src/layout/ports/portLabel.mjs +224 -0
- package/src/linkAnchors/index.mjs +76 -0
- package/src/linkTools/Anchor.mjs +235 -0
- package/src/linkTools/Arrowhead.mjs +103 -0
- package/src/linkTools/Boundary.mjs +48 -0
- package/src/linkTools/Button.mjs +121 -0
- package/src/linkTools/Connect.mjs +85 -0
- package/src/linkTools/HoverConnect.mjs +161 -0
- package/src/linkTools/Segments.mjs +393 -0
- package/src/linkTools/Vertices.mjs +253 -0
- package/src/linkTools/helpers.mjs +33 -0
- package/src/linkTools/index.mjs +8 -0
- package/src/mvc/Collection.mjs +560 -0
- package/src/mvc/Data.mjs +46 -0
- package/src/mvc/Dom/Dom.mjs +587 -0
- package/src/mvc/Dom/Event.mjs +130 -0
- package/src/mvc/Dom/animations.mjs +122 -0
- package/src/mvc/Dom/events.mjs +69 -0
- package/src/mvc/Dom/index.mjs +13 -0
- package/src/mvc/Dom/methods.mjs +392 -0
- package/src/mvc/Dom/props.mjs +77 -0
- package/src/mvc/Dom/vars.mjs +5 -0
- package/src/mvc/Events.mjs +337 -0
- package/src/mvc/Listener.mjs +33 -0
- package/src/mvc/Model.mjs +239 -0
- package/src/mvc/View.mjs +323 -0
- package/src/mvc/ViewBase.mjs +182 -0
- package/src/mvc/index.mjs +9 -0
- package/src/mvc/mvcUtils.mjs +90 -0
- package/src/polyfills/array.js +4 -0
- package/src/polyfills/base64.js +68 -0
- package/src/polyfills/index.mjs +5 -0
- package/src/polyfills/number.js +3 -0
- package/src/polyfills/string.js +3 -0
- package/src/polyfills/typedArray.js +47 -0
- package/src/routers/index.mjs +6 -0
- package/src/routers/manhattan.mjs +856 -0
- package/src/routers/metro.mjs +91 -0
- package/src/routers/normal.mjs +6 -0
- package/src/routers/oneSide.mjs +60 -0
- package/src/routers/orthogonal.mjs +323 -0
- package/src/routers/rightAngle.mjs +1056 -0
- package/src/shapes/index.mjs +3 -0
- package/src/shapes/standard.mjs +755 -0
- package/src/util/cloneCells.mjs +67 -0
- package/src/util/getRectPoint.mjs +65 -0
- package/src/util/index.mjs +5 -0
- package/src/util/svgTagTemplate.mjs +110 -0
- package/src/util/util.mjs +1754 -0
- package/src/util/utilHelpers.mjs +2402 -0
- package/src/util/wrappers.mjs +56 -0
- package/types/geometry.d.ts +815 -0
- package/types/index.d.ts +53 -0
- package/types/joint.d.ts +4391 -0
- package/types/joint.head.d.ts +12 -0
- package/types/vectorizer.d.ts +327 -0
|
@@ -0,0 +1,755 @@
|
|
|
1
|
+
import V from '../V/index.mjs';
|
|
2
|
+
import { Element } from '../dia/Element.mjs';
|
|
3
|
+
import { Link as LinkBase } from '../dia/Link.mjs';
|
|
4
|
+
import { isPercentage, assign } from '../util/index.mjs';
|
|
5
|
+
import { attributes } from '../dia/attributes/index.mjs';
|
|
6
|
+
import { env } from '../env/index.mjs';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// ELEMENTS
|
|
10
|
+
|
|
11
|
+
export const Rectangle = Element.define('standard.Rectangle', {
|
|
12
|
+
attrs: {
|
|
13
|
+
root: {
|
|
14
|
+
cursor: 'move'
|
|
15
|
+
},
|
|
16
|
+
body: {
|
|
17
|
+
width: 'calc(w)',
|
|
18
|
+
height: 'calc(h)',
|
|
19
|
+
strokeWidth: 2,
|
|
20
|
+
stroke: '#000000',
|
|
21
|
+
fill: '#FFFFFF'
|
|
22
|
+
},
|
|
23
|
+
label: {
|
|
24
|
+
textVerticalAnchor: 'middle',
|
|
25
|
+
textAnchor: 'middle',
|
|
26
|
+
x: 'calc(w/2)',
|
|
27
|
+
y: 'calc(h/2)',
|
|
28
|
+
fontSize: 14,
|
|
29
|
+
fill: '#333333'
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}, {
|
|
33
|
+
markup: [{
|
|
34
|
+
tagName: 'rect',
|
|
35
|
+
selector: 'body',
|
|
36
|
+
}, {
|
|
37
|
+
tagName: 'text',
|
|
38
|
+
selector: 'label'
|
|
39
|
+
}]
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export const Circle = Element.define('standard.Circle', {
|
|
43
|
+
attrs: {
|
|
44
|
+
root: {
|
|
45
|
+
cursor: 'move'
|
|
46
|
+
},
|
|
47
|
+
body: {
|
|
48
|
+
cx: 'calc(s/2)',
|
|
49
|
+
cy: 'calc(s/2)',
|
|
50
|
+
r: 'calc(s/2)',
|
|
51
|
+
strokeWidth: 2,
|
|
52
|
+
stroke: '#333333',
|
|
53
|
+
fill: '#FFFFFF'
|
|
54
|
+
},
|
|
55
|
+
label: {
|
|
56
|
+
textVerticalAnchor: 'middle',
|
|
57
|
+
textAnchor: 'middle',
|
|
58
|
+
x: 'calc(w/2)',
|
|
59
|
+
y: 'calc(h/2)',
|
|
60
|
+
fontSize: 14,
|
|
61
|
+
fill: '#333333'
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}, {
|
|
65
|
+
markup: [{
|
|
66
|
+
tagName: 'circle',
|
|
67
|
+
selector: 'body'
|
|
68
|
+
}, {
|
|
69
|
+
tagName: 'text',
|
|
70
|
+
selector: 'label'
|
|
71
|
+
}]
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
export const Ellipse = Element.define('standard.Ellipse', {
|
|
75
|
+
attrs: {
|
|
76
|
+
root: {
|
|
77
|
+
cursor: 'move'
|
|
78
|
+
},
|
|
79
|
+
body: {
|
|
80
|
+
cx: 'calc(w/2)',
|
|
81
|
+
cy: 'calc(h/2)',
|
|
82
|
+
rx: 'calc(w/2)',
|
|
83
|
+
ry: 'calc(h/2)',
|
|
84
|
+
strokeWidth: 2,
|
|
85
|
+
stroke: '#333333',
|
|
86
|
+
fill: '#FFFFFF'
|
|
87
|
+
},
|
|
88
|
+
label: {
|
|
89
|
+
textVerticalAnchor: 'middle',
|
|
90
|
+
textAnchor: 'middle',
|
|
91
|
+
x: 'calc(w/2)',
|
|
92
|
+
y: 'calc(h/2)',
|
|
93
|
+
fontSize: 14,
|
|
94
|
+
fill: '#333333'
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}, {
|
|
98
|
+
markup: [{
|
|
99
|
+
tagName: 'ellipse',
|
|
100
|
+
selector: 'body'
|
|
101
|
+
}, {
|
|
102
|
+
tagName: 'text',
|
|
103
|
+
selector: 'label'
|
|
104
|
+
}]
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
export const Path = Element.define('standard.Path', {
|
|
108
|
+
attrs: {
|
|
109
|
+
root: {
|
|
110
|
+
cursor: 'move'
|
|
111
|
+
},
|
|
112
|
+
body: {
|
|
113
|
+
d: 'M 0 0 H calc(w) V calc(h) H 0 Z',
|
|
114
|
+
strokeWidth: 2,
|
|
115
|
+
stroke: '#333333',
|
|
116
|
+
fill: '#FFFFFF'
|
|
117
|
+
},
|
|
118
|
+
label: {
|
|
119
|
+
textVerticalAnchor: 'middle',
|
|
120
|
+
textAnchor: 'middle',
|
|
121
|
+
x: 'calc(w/2)',
|
|
122
|
+
y: 'calc(h/2)',
|
|
123
|
+
fontSize: 14,
|
|
124
|
+
fill: '#333333'
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}, {
|
|
128
|
+
markup: [{
|
|
129
|
+
tagName: 'path',
|
|
130
|
+
selector: 'body'
|
|
131
|
+
}, {
|
|
132
|
+
tagName: 'text',
|
|
133
|
+
selector: 'label'
|
|
134
|
+
}]
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
export const Polygon = Element.define('standard.Polygon', {
|
|
138
|
+
attrs: {
|
|
139
|
+
root: {
|
|
140
|
+
cursor: 'move'
|
|
141
|
+
},
|
|
142
|
+
body: {
|
|
143
|
+
points: '0 0 calc(w) 0 calc(w) calc(h) 0 calc(h)',
|
|
144
|
+
strokeWidth: 2,
|
|
145
|
+
stroke: '#333333',
|
|
146
|
+
fill: '#FFFFFF'
|
|
147
|
+
},
|
|
148
|
+
label: {
|
|
149
|
+
textVerticalAnchor: 'middle',
|
|
150
|
+
textAnchor: 'middle',
|
|
151
|
+
x: 'calc(w/2)',
|
|
152
|
+
y: 'calc(h/2)',
|
|
153
|
+
fontSize: 14,
|
|
154
|
+
fill: '#333333'
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}, {
|
|
158
|
+
markup: [{
|
|
159
|
+
tagName: 'polygon',
|
|
160
|
+
selector: 'body'
|
|
161
|
+
}, {
|
|
162
|
+
tagName: 'text',
|
|
163
|
+
selector: 'label'
|
|
164
|
+
}]
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
export const Polyline = Element.define('standard.Polyline', {
|
|
168
|
+
attrs: {
|
|
169
|
+
root: {
|
|
170
|
+
cursor: 'move'
|
|
171
|
+
},
|
|
172
|
+
body: {
|
|
173
|
+
points: '0 0 calc(w) 0 calc(w) calc(h) 0 calc(h)',
|
|
174
|
+
strokeWidth: 2,
|
|
175
|
+
stroke: '#333333',
|
|
176
|
+
fill: '#FFFFFF'
|
|
177
|
+
},
|
|
178
|
+
label: {
|
|
179
|
+
textVerticalAnchor: 'middle',
|
|
180
|
+
textAnchor: 'middle',
|
|
181
|
+
x: 'calc(w/2)',
|
|
182
|
+
y: 'calc(h/2)',
|
|
183
|
+
fontSize: 14,
|
|
184
|
+
fill: '#333333'
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}, {
|
|
188
|
+
markup: [{
|
|
189
|
+
tagName: 'polyline',
|
|
190
|
+
selector: 'body'
|
|
191
|
+
}, {
|
|
192
|
+
tagName: 'text',
|
|
193
|
+
selector: 'label'
|
|
194
|
+
}]
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
export const Image = Element.define('standard.Image', {
|
|
198
|
+
attrs: {
|
|
199
|
+
root: {
|
|
200
|
+
cursor: 'move'
|
|
201
|
+
},
|
|
202
|
+
image: {
|
|
203
|
+
width: 'calc(w)',
|
|
204
|
+
height: 'calc(h)',
|
|
205
|
+
// xlinkHref: '[URL]'
|
|
206
|
+
},
|
|
207
|
+
label: {
|
|
208
|
+
textVerticalAnchor: 'top',
|
|
209
|
+
textAnchor: 'middle',
|
|
210
|
+
x: 'calc(w/2)',
|
|
211
|
+
y: 'calc(h+10)',
|
|
212
|
+
fontSize: 14,
|
|
213
|
+
fill: '#333333'
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}, {
|
|
217
|
+
markup: [{
|
|
218
|
+
tagName: 'image',
|
|
219
|
+
selector: 'image'
|
|
220
|
+
}, {
|
|
221
|
+
tagName: 'text',
|
|
222
|
+
selector: 'label'
|
|
223
|
+
}]
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
export const BorderedImage = Element.define('standard.BorderedImage', {
|
|
227
|
+
attrs: {
|
|
228
|
+
root: {
|
|
229
|
+
cursor: 'move'
|
|
230
|
+
},
|
|
231
|
+
border: {
|
|
232
|
+
width: 'calc(w)',
|
|
233
|
+
height: 'calc(h)',
|
|
234
|
+
stroke: '#333333',
|
|
235
|
+
strokeWidth: 2
|
|
236
|
+
},
|
|
237
|
+
background: {
|
|
238
|
+
width: 'calc(w-1)',
|
|
239
|
+
height: 'calc(h-1)',
|
|
240
|
+
x: 0.5,
|
|
241
|
+
y: 0.5,
|
|
242
|
+
fill: '#FFFFFF'
|
|
243
|
+
},
|
|
244
|
+
image: {
|
|
245
|
+
// xlinkHref: '[URL]'
|
|
246
|
+
width: 'calc(w-1)',
|
|
247
|
+
height: 'calc(h-1)',
|
|
248
|
+
x: 0.5,
|
|
249
|
+
y: 0.5
|
|
250
|
+
},
|
|
251
|
+
label: {
|
|
252
|
+
textVerticalAnchor: 'top',
|
|
253
|
+
textAnchor: 'middle',
|
|
254
|
+
x: 'calc(w/2)',
|
|
255
|
+
y: 'calc(h+10)',
|
|
256
|
+
fontSize: 14,
|
|
257
|
+
fill: '#333333'
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}, {
|
|
261
|
+
markup: [{
|
|
262
|
+
tagName: 'rect',
|
|
263
|
+
selector: 'background',
|
|
264
|
+
attributes: {
|
|
265
|
+
'stroke': 'none'
|
|
266
|
+
}
|
|
267
|
+
}, {
|
|
268
|
+
tagName: 'image',
|
|
269
|
+
selector: 'image'
|
|
270
|
+
}, {
|
|
271
|
+
tagName: 'rect',
|
|
272
|
+
selector: 'border',
|
|
273
|
+
attributes: {
|
|
274
|
+
'fill': 'none'
|
|
275
|
+
}
|
|
276
|
+
}, {
|
|
277
|
+
tagName: 'text',
|
|
278
|
+
selector: 'label'
|
|
279
|
+
}]
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
export const EmbeddedImage = Element.define('standard.EmbeddedImage', {
|
|
283
|
+
attrs: {
|
|
284
|
+
root: {
|
|
285
|
+
cursor: 'move'
|
|
286
|
+
},
|
|
287
|
+
body: {
|
|
288
|
+
width: 'calc(w)',
|
|
289
|
+
height: 'calc(h)',
|
|
290
|
+
stroke: '#333333',
|
|
291
|
+
fill: '#FFFFFF',
|
|
292
|
+
strokeWidth: 2
|
|
293
|
+
},
|
|
294
|
+
image: {
|
|
295
|
+
// xlinkHref: '[URL]'
|
|
296
|
+
width: 'calc(0.3*w)',
|
|
297
|
+
height: 'calc(h-20)',
|
|
298
|
+
x: 10,
|
|
299
|
+
y: 10,
|
|
300
|
+
preserveAspectRatio: 'xMidYMin'
|
|
301
|
+
},
|
|
302
|
+
label: {
|
|
303
|
+
textVerticalAnchor: 'top',
|
|
304
|
+
textAnchor: 'left',
|
|
305
|
+
x: 'calc(0.3*w+20)', // 10 + 10
|
|
306
|
+
y: 10,
|
|
307
|
+
fontSize: 14,
|
|
308
|
+
fill: '#333333'
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}, {
|
|
312
|
+
markup: [{
|
|
313
|
+
tagName: 'rect',
|
|
314
|
+
selector: 'body'
|
|
315
|
+
}, {
|
|
316
|
+
tagName: 'image',
|
|
317
|
+
selector: 'image'
|
|
318
|
+
}, {
|
|
319
|
+
tagName: 'text',
|
|
320
|
+
selector: 'label'
|
|
321
|
+
}]
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
export const InscribedImage = Element.define('standard.InscribedImage', {
|
|
325
|
+
attrs: {
|
|
326
|
+
root: {
|
|
327
|
+
cursor: 'move'
|
|
328
|
+
},
|
|
329
|
+
border: {
|
|
330
|
+
rx: 'calc(w/2)',
|
|
331
|
+
ry: 'calc(h/2)',
|
|
332
|
+
cx: 'calc(w/2)',
|
|
333
|
+
cy: 'calc(h/2)',
|
|
334
|
+
stroke: '#333333',
|
|
335
|
+
strokeWidth: 2
|
|
336
|
+
},
|
|
337
|
+
background: {
|
|
338
|
+
rx: 'calc(w/2)',
|
|
339
|
+
ry: 'calc(h/2)',
|
|
340
|
+
cx: 'calc(w/2)',
|
|
341
|
+
cy: 'calc(h/2)',
|
|
342
|
+
fill: '#FFFFFF'
|
|
343
|
+
},
|
|
344
|
+
image: {
|
|
345
|
+
// The image corners touch the border when its size is Math.sqrt(2) / 2 = 0.707.. ~= 70%
|
|
346
|
+
width: 'calc(0.68*w)',
|
|
347
|
+
height: 'calc(0.68*h)',
|
|
348
|
+
// The image offset is calculated as (100% - 68%) / 2
|
|
349
|
+
x: 'calc(0.16*w)',
|
|
350
|
+
y: 'calc(0.16*h)',
|
|
351
|
+
preserveAspectRatio: 'xMidYMid'
|
|
352
|
+
// xlinkHref: '[URL]'
|
|
353
|
+
},
|
|
354
|
+
label: {
|
|
355
|
+
textVerticalAnchor: 'top',
|
|
356
|
+
textAnchor: 'middle',
|
|
357
|
+
x: 'calc(w/2)',
|
|
358
|
+
y: 'calc(h+10)',
|
|
359
|
+
fontSize: 14,
|
|
360
|
+
fill: '#333333'
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}, {
|
|
364
|
+
markup: [{
|
|
365
|
+
tagName: 'ellipse',
|
|
366
|
+
selector: 'background'
|
|
367
|
+
}, {
|
|
368
|
+
tagName: 'image',
|
|
369
|
+
selector: 'image'
|
|
370
|
+
}, {
|
|
371
|
+
tagName: 'ellipse',
|
|
372
|
+
selector: 'border',
|
|
373
|
+
attributes: {
|
|
374
|
+
'fill': 'none'
|
|
375
|
+
}
|
|
376
|
+
}, {
|
|
377
|
+
tagName: 'text',
|
|
378
|
+
selector: 'label'
|
|
379
|
+
}]
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
export const HeaderedRectangle = Element.define('standard.HeaderedRectangle', {
|
|
383
|
+
attrs: {
|
|
384
|
+
root: {
|
|
385
|
+
cursor: 'move'
|
|
386
|
+
},
|
|
387
|
+
body: {
|
|
388
|
+
width: 'calc(w)',
|
|
389
|
+
height: 'calc(h)',
|
|
390
|
+
strokeWidth: 2,
|
|
391
|
+
stroke: '#000000',
|
|
392
|
+
fill: '#FFFFFF'
|
|
393
|
+
},
|
|
394
|
+
header: {
|
|
395
|
+
width: 'calc(w)',
|
|
396
|
+
height: 30,
|
|
397
|
+
strokeWidth: 2,
|
|
398
|
+
stroke: '#000000',
|
|
399
|
+
fill: '#FFFFFF'
|
|
400
|
+
},
|
|
401
|
+
headerText: {
|
|
402
|
+
textVerticalAnchor: 'middle',
|
|
403
|
+
textAnchor: 'middle',
|
|
404
|
+
x: 'calc(w/2)',
|
|
405
|
+
y: 15,
|
|
406
|
+
fontSize: 16,
|
|
407
|
+
fill: '#333333'
|
|
408
|
+
},
|
|
409
|
+
bodyText: {
|
|
410
|
+
textVerticalAnchor: 'middle',
|
|
411
|
+
textAnchor: 'middle',
|
|
412
|
+
x: 'calc(w/2)',
|
|
413
|
+
y: 'calc(h/2+15)',
|
|
414
|
+
fontSize: 14,
|
|
415
|
+
fill: '#333333'
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}, {
|
|
419
|
+
markup: [{
|
|
420
|
+
tagName: 'rect',
|
|
421
|
+
selector: 'body'
|
|
422
|
+
}, {
|
|
423
|
+
tagName: 'rect',
|
|
424
|
+
selector: 'header'
|
|
425
|
+
}, {
|
|
426
|
+
tagName: 'text',
|
|
427
|
+
selector: 'headerText'
|
|
428
|
+
}, {
|
|
429
|
+
tagName: 'text',
|
|
430
|
+
selector: 'bodyText'
|
|
431
|
+
}]
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
var CYLINDER_TILT = 10;
|
|
435
|
+
|
|
436
|
+
export const Cylinder = Element.define('standard.Cylinder', {
|
|
437
|
+
attrs: {
|
|
438
|
+
root: {
|
|
439
|
+
cursor: 'move'
|
|
440
|
+
},
|
|
441
|
+
body: {
|
|
442
|
+
lateralArea: CYLINDER_TILT,
|
|
443
|
+
fill: '#FFFFFF',
|
|
444
|
+
stroke: '#333333',
|
|
445
|
+
strokeWidth: 2
|
|
446
|
+
},
|
|
447
|
+
top: {
|
|
448
|
+
cx: 'calc(w/2)',
|
|
449
|
+
cy: CYLINDER_TILT,
|
|
450
|
+
rx: 'calc(w/2)',
|
|
451
|
+
ry: CYLINDER_TILT,
|
|
452
|
+
fill: '#FFFFFF',
|
|
453
|
+
stroke: '#333333',
|
|
454
|
+
strokeWidth: 2
|
|
455
|
+
},
|
|
456
|
+
label: {
|
|
457
|
+
textVerticalAnchor: 'middle',
|
|
458
|
+
textAnchor: 'middle',
|
|
459
|
+
x: 'calc(w/2)',
|
|
460
|
+
y: 'calc(h+15)',
|
|
461
|
+
fontSize: 14,
|
|
462
|
+
fill: '#333333'
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}, {
|
|
466
|
+
markup: [{
|
|
467
|
+
tagName: 'path',
|
|
468
|
+
selector: 'body'
|
|
469
|
+
}, {
|
|
470
|
+
tagName: 'ellipse',
|
|
471
|
+
selector: 'top'
|
|
472
|
+
}, {
|
|
473
|
+
tagName: 'text',
|
|
474
|
+
selector: 'label'
|
|
475
|
+
}],
|
|
476
|
+
|
|
477
|
+
topRy: function(t, opt) {
|
|
478
|
+
// getter
|
|
479
|
+
if (t === undefined) return this.attr('body/lateralArea');
|
|
480
|
+
|
|
481
|
+
// setter
|
|
482
|
+
var bodyAttrs = { lateralArea: t };
|
|
483
|
+
|
|
484
|
+
var isPercentageSetter = isPercentage(t);
|
|
485
|
+
var ty = (isPercentageSetter) ? `calc(${parseFloat(t) / 100}*h)` : t;
|
|
486
|
+
var topAttrs = { cy: ty, ry: ty };
|
|
487
|
+
|
|
488
|
+
return this.attr({ body: bodyAttrs, top: topAttrs }, opt);
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
}, {
|
|
492
|
+
attributes: {
|
|
493
|
+
'lateral-area': {
|
|
494
|
+
set: function(t, refBBox) {
|
|
495
|
+
var isPercentageSetter = isPercentage(t);
|
|
496
|
+
if (isPercentageSetter) t = parseFloat(t) / 100;
|
|
497
|
+
|
|
498
|
+
var x = refBBox.x;
|
|
499
|
+
var y = refBBox.y;
|
|
500
|
+
var w = refBBox.width;
|
|
501
|
+
var h = refBBox.height;
|
|
502
|
+
|
|
503
|
+
// curve control point variables
|
|
504
|
+
var rx = w / 2;
|
|
505
|
+
var ry = isPercentageSetter ? (h * t) : t;
|
|
506
|
+
|
|
507
|
+
var kappa = V.KAPPA;
|
|
508
|
+
var cx = kappa * rx;
|
|
509
|
+
var cy = kappa * (isPercentageSetter ? (h * t) : t);
|
|
510
|
+
|
|
511
|
+
// shape variables
|
|
512
|
+
var xLeft = x;
|
|
513
|
+
var xCenter = x + (w / 2);
|
|
514
|
+
var xRight = x + w;
|
|
515
|
+
|
|
516
|
+
var ySideTop = y + ry;
|
|
517
|
+
var yCurveTop = ySideTop - ry;
|
|
518
|
+
var ySideBottom = y + h - ry;
|
|
519
|
+
var yCurveBottom = y + h;
|
|
520
|
+
|
|
521
|
+
// return calculated shape
|
|
522
|
+
var data = [
|
|
523
|
+
'M', xLeft, ySideTop,
|
|
524
|
+
'L', xLeft, ySideBottom,
|
|
525
|
+
'C', x, (ySideBottom + cy), (xCenter - cx), yCurveBottom, xCenter, yCurveBottom,
|
|
526
|
+
'C', (xCenter + cx), yCurveBottom, xRight, (ySideBottom + cy), xRight, ySideBottom,
|
|
527
|
+
'L', xRight, ySideTop,
|
|
528
|
+
'C', xRight, (ySideTop - cy), (xCenter + cx), yCurveTop, xCenter, yCurveTop,
|
|
529
|
+
'C', (xCenter - cx), yCurveTop, xLeft, (ySideTop - cy), xLeft, ySideTop,
|
|
530
|
+
'Z'
|
|
531
|
+
];
|
|
532
|
+
return { d: data.join(' ') };
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
|
|
538
|
+
var foLabelMarkup = {
|
|
539
|
+
tagName: 'foreignObject',
|
|
540
|
+
selector: 'foreignObject',
|
|
541
|
+
attributes: {
|
|
542
|
+
'overflow': 'hidden'
|
|
543
|
+
},
|
|
544
|
+
children: [{
|
|
545
|
+
tagName: 'div',
|
|
546
|
+
namespaceURI: 'http://www.w3.org/1999/xhtml',
|
|
547
|
+
selector: 'label',
|
|
548
|
+
style: {
|
|
549
|
+
width: '100%',
|
|
550
|
+
height: '100%',
|
|
551
|
+
position: 'static',
|
|
552
|
+
backgroundColor: 'transparent',
|
|
553
|
+
textAlign: 'center',
|
|
554
|
+
margin: 0,
|
|
555
|
+
padding: '0px 5px',
|
|
556
|
+
boxSizing: 'border-box',
|
|
557
|
+
display: 'flex',
|
|
558
|
+
alignItems: 'center',
|
|
559
|
+
justifyContent: 'center'
|
|
560
|
+
}
|
|
561
|
+
}]
|
|
562
|
+
};
|
|
563
|
+
|
|
564
|
+
var svgLabelMarkup = {
|
|
565
|
+
tagName: 'text',
|
|
566
|
+
selector: 'label',
|
|
567
|
+
attributes: {
|
|
568
|
+
'text-anchor': 'middle'
|
|
569
|
+
}
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
var labelMarkup = (env.test('svgforeignobject')) ? foLabelMarkup : svgLabelMarkup;
|
|
573
|
+
|
|
574
|
+
export const TextBlock = Element.define('standard.TextBlock', {
|
|
575
|
+
attrs: {
|
|
576
|
+
root: {
|
|
577
|
+
cursor: 'move'
|
|
578
|
+
},
|
|
579
|
+
body: {
|
|
580
|
+
width: 'calc(w)',
|
|
581
|
+
height: 'calc(h)',
|
|
582
|
+
stroke: '#333333',
|
|
583
|
+
fill: '#ffffff',
|
|
584
|
+
strokeWidth: 2
|
|
585
|
+
},
|
|
586
|
+
foreignObject: {
|
|
587
|
+
width: 'calc(w)',
|
|
588
|
+
height: 'calc(h)',
|
|
589
|
+
},
|
|
590
|
+
label: {
|
|
591
|
+
style: {
|
|
592
|
+
fontSize: 14
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}, {
|
|
597
|
+
markup: [{
|
|
598
|
+
tagName: 'rect',
|
|
599
|
+
selector: 'body'
|
|
600
|
+
}, labelMarkup]
|
|
601
|
+
}, {
|
|
602
|
+
attributes: {
|
|
603
|
+
text: {
|
|
604
|
+
set: function(text, refBBox, node, attrs) {
|
|
605
|
+
if (node instanceof HTMLElement) {
|
|
606
|
+
node.textContent = text;
|
|
607
|
+
} else {
|
|
608
|
+
// No foreign object
|
|
609
|
+
var style = attrs['style'] || {};
|
|
610
|
+
var wrapValue = { text, width: -5, height: '100%' };
|
|
611
|
+
var wrapAttrs = assign({ 'text-vertical-anchor': 'middle' }, style);
|
|
612
|
+
attributes['text-wrap'].set.call(this, wrapValue, refBBox, node, wrapAttrs);
|
|
613
|
+
return { fill: style.color || null };
|
|
614
|
+
}
|
|
615
|
+
},
|
|
616
|
+
position: function(text, refBBox, node) {
|
|
617
|
+
// No foreign object
|
|
618
|
+
if (node instanceof SVGElement) return refBBox.center();
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
});
|
|
623
|
+
|
|
624
|
+
// LINKS
|
|
625
|
+
|
|
626
|
+
export const Link = LinkBase.define('standard.Link', {
|
|
627
|
+
attrs: {
|
|
628
|
+
line: {
|
|
629
|
+
connection: true,
|
|
630
|
+
stroke: '#333333',
|
|
631
|
+
strokeWidth: 2,
|
|
632
|
+
strokeLinejoin: 'round',
|
|
633
|
+
targetMarker: {
|
|
634
|
+
'type': 'path',
|
|
635
|
+
'd': 'M 10 -5 0 0 10 5 z'
|
|
636
|
+
}
|
|
637
|
+
},
|
|
638
|
+
wrapper: {
|
|
639
|
+
connection: true,
|
|
640
|
+
strokeWidth: 10,
|
|
641
|
+
strokeLinejoin: 'round'
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
}, {
|
|
645
|
+
markup: [{
|
|
646
|
+
tagName: 'path',
|
|
647
|
+
selector: 'wrapper',
|
|
648
|
+
attributes: {
|
|
649
|
+
'fill': 'none',
|
|
650
|
+
'cursor': 'pointer',
|
|
651
|
+
'stroke': 'transparent',
|
|
652
|
+
'stroke-linecap': 'round'
|
|
653
|
+
}
|
|
654
|
+
}, {
|
|
655
|
+
tagName: 'path',
|
|
656
|
+
selector: 'line',
|
|
657
|
+
attributes: {
|
|
658
|
+
'fill': 'none',
|
|
659
|
+
'pointer-events': 'none'
|
|
660
|
+
}
|
|
661
|
+
}]
|
|
662
|
+
});
|
|
663
|
+
|
|
664
|
+
export const DoubleLink = LinkBase.define('standard.DoubleLink', {
|
|
665
|
+
attrs: {
|
|
666
|
+
line: {
|
|
667
|
+
connection: true,
|
|
668
|
+
stroke: '#DDDDDD',
|
|
669
|
+
strokeWidth: 4,
|
|
670
|
+
strokeLinejoin: 'round',
|
|
671
|
+
targetMarker: {
|
|
672
|
+
type: 'path',
|
|
673
|
+
stroke: '#000000',
|
|
674
|
+
d: 'M 10 -3 10 -10 -2 0 10 10 10 3'
|
|
675
|
+
}
|
|
676
|
+
},
|
|
677
|
+
outline: {
|
|
678
|
+
connection: true,
|
|
679
|
+
stroke: '#000000',
|
|
680
|
+
strokeWidth: 6,
|
|
681
|
+
strokeLinejoin: 'round'
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
}, {
|
|
685
|
+
markup: [{
|
|
686
|
+
tagName: 'path',
|
|
687
|
+
selector: 'outline',
|
|
688
|
+
attributes: {
|
|
689
|
+
'fill': 'none',
|
|
690
|
+
'cursor': 'pointer'
|
|
691
|
+
}
|
|
692
|
+
}, {
|
|
693
|
+
tagName: 'path',
|
|
694
|
+
selector: 'line',
|
|
695
|
+
attributes: {
|
|
696
|
+
'fill': 'none',
|
|
697
|
+
'pointer-events': 'none'
|
|
698
|
+
}
|
|
699
|
+
}]
|
|
700
|
+
});
|
|
701
|
+
|
|
702
|
+
export const ShadowLink = LinkBase.define('standard.ShadowLink', {
|
|
703
|
+
attrs: {
|
|
704
|
+
line: {
|
|
705
|
+
connection: true,
|
|
706
|
+
stroke: '#FF0000',
|
|
707
|
+
strokeWidth: 20,
|
|
708
|
+
strokeLinejoin: 'round',
|
|
709
|
+
targetMarker: {
|
|
710
|
+
'type': 'path',
|
|
711
|
+
'stroke': 'none',
|
|
712
|
+
'd': 'M 0 -10 -10 0 0 10 z'
|
|
713
|
+
},
|
|
714
|
+
sourceMarker: {
|
|
715
|
+
'type': 'path',
|
|
716
|
+
'stroke': 'none',
|
|
717
|
+
'd': 'M -10 -10 0 0 -10 10 0 10 0 -10 z'
|
|
718
|
+
}
|
|
719
|
+
},
|
|
720
|
+
shadow: {
|
|
721
|
+
connection: true,
|
|
722
|
+
transform: 'translate(3,6)',
|
|
723
|
+
stroke: '#000000',
|
|
724
|
+
strokeOpacity: 0.2,
|
|
725
|
+
strokeWidth: 20,
|
|
726
|
+
strokeLinejoin: 'round',
|
|
727
|
+
targetMarker: {
|
|
728
|
+
'type': 'path',
|
|
729
|
+
'd': 'M 0 -10 -10 0 0 10 z',
|
|
730
|
+
'stroke': 'none'
|
|
731
|
+
},
|
|
732
|
+
sourceMarker: {
|
|
733
|
+
'type': 'path',
|
|
734
|
+
'stroke': 'none',
|
|
735
|
+
'd': 'M -10 -10 0 0 -10 10 0 10 0 -10 z'
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
}, {
|
|
740
|
+
markup: [{
|
|
741
|
+
tagName: 'path',
|
|
742
|
+
selector: 'shadow',
|
|
743
|
+
attributes: {
|
|
744
|
+
'fill': 'none',
|
|
745
|
+
'pointer-events': 'none'
|
|
746
|
+
}
|
|
747
|
+
}, {
|
|
748
|
+
tagName: 'path',
|
|
749
|
+
selector: 'line',
|
|
750
|
+
attributes: {
|
|
751
|
+
'fill': 'none',
|
|
752
|
+
'cursor': 'pointer'
|
|
753
|
+
}
|
|
754
|
+
}]
|
|
755
|
+
});
|