Revize 96013335
Přidáno uživatelem Pavel Fidranský před více než 6 roky(ů)
sources/src/main/webapp/js/components/group.js | ||
---|---|---|
60 | 60 |
}); |
61 | 61 |
|
62 | 62 |
let vertexRelatedArchetypeMap = vertex.relatedArchetypeMap; |
63 |
for (let archetypeIndex in vertexRelatedArchetypeMap) { |
|
64 |
if (this.relatedArchetypeMap.hasOwnProperty(archetypeIndex) === false) { |
|
65 |
this.relatedArchetypeMap[archetypeIndex] = 0; |
|
66 |
} |
|
67 |
|
|
68 |
this.relatedArchetypeMap[archetypeIndex] += vertexRelatedArchetypeMap[archetypeIndex]; |
|
69 |
} |
|
63 |
vertexRelatedArchetypeMap.forEach((value, key) => { |
|
64 |
this._relatedArchetypeListComponent.add(key, value); |
|
65 |
}); |
|
70 | 66 |
|
71 | 67 |
app.viewportComponent.removeNode(vertex); |
72 | 68 |
|
... | ... | |
99 | 95 |
}); |
100 | 96 |
|
101 | 97 |
let vertexRelatedArchetypeMap = vertex.relatedArchetypeMap; |
102 |
for (let archetypeIndex in vertexRelatedArchetypeMap) {
|
|
103 |
this.relatedArchetypeMap[archetypeIndex] -= vertexRelatedArchetypeMap[archetypeIndex];
|
|
104 |
} |
|
98 |
vertexRelatedArchetypeMap.forEach((value, key) => {
|
|
99 |
this._relatedArchetypeListComponent.remove(key, value);
|
|
100 |
});
|
|
105 | 101 |
|
106 | 102 |
app.viewportComponent.addNode(vertex); |
107 | 103 |
|
... | ... | |
295 | 291 |
* @returns {HTMLElement} HTML DOM element. |
296 | 292 |
*/ |
297 | 293 |
_renderExcluded() { |
298 |
const svg = DOM.s('svg', { |
|
299 |
xmlns: 'http://www.w3.org/2000/svg', |
|
300 |
height: 60, |
|
301 |
width: 46, |
|
302 |
}); |
|
303 |
|
|
304 |
// related archetypes |
|
305 |
const relatedArchetypesGroup = DOM.s('g', { |
|
306 |
transform: 'translate(10, 15)', |
|
307 |
}); |
|
308 |
svg.appendChild(relatedArchetypesGroup); |
|
309 |
|
|
310 |
let archetypeIconOrder = 0; |
|
311 |
for (let archetypeIndex in this.relatedArchetypeMap) { |
|
312 |
relatedArchetypesGroup.appendChild(DOM.s('g', { |
|
313 |
class: 'related-archetype', |
|
314 |
transform: `translate(0, ${archetypeIconOrder * 20})`, |
|
315 |
}, [ |
|
316 |
// counter |
|
317 |
DOM.s('text', {}, [ |
|
318 |
DOM.t(this.relatedArchetypeMap[archetypeIndex]), |
|
319 |
]), |
|
320 |
// icon |
|
321 |
DOM.s('use', { |
|
322 |
href: '#vertexArchetypeIcon-' + app.archetype.vertex[archetypeIndex].name, |
|
323 |
class: 'archetype-icon', |
|
324 |
transform: `translate(15, -10)`, |
|
325 |
onClick: this._onRelatedArchetypeIconClick.bind(this, parseInt(archetypeIndex)), // TODO when icon == null can not click on item |
|
326 |
}), |
|
327 |
// line |
|
328 |
DOM.s('line', { |
|
329 |
x1: 30, |
|
330 |
y1: -5, |
|
331 |
x2: 36, |
|
332 |
y2: -5, |
|
333 |
}), |
|
334 |
])); |
|
335 |
|
|
336 |
archetypeIconOrder++; |
|
337 |
} |
|
338 |
|
|
339 | 294 |
// vertex list |
340 | 295 |
this._vertexListComponent = new GroupVertexList(this); |
341 | 296 |
|
... | ... | |
344 | 299 |
class: 'node group', |
345 | 300 |
'data-id': this.id, |
346 | 301 |
}, [ |
347 |
svg, |
|
302 |
// related archetypes |
|
303 |
DOM.s('svg', { |
|
304 |
height: this._relatedArchetypeListComponent.size.height, |
|
305 |
width: 46, |
|
306 |
}, [ |
|
307 |
this._relatedArchetypeListComponent.render(), |
|
308 |
]), |
|
348 | 309 |
// symbol |
349 | 310 |
DOM.h('span', { |
350 | 311 |
class: 'group-symbol', |
sources/src/main/webapp/js/components/node.js | ||
---|---|---|
18 | 18 |
|
19 | 19 |
// components |
20 | 20 |
this._symbolListComponent = new NodeSymbolList; |
21 |
this._relatedArchetypeListComponent = new NodeRelatedArchetypeList(this); |
|
21 | 22 |
|
22 | 23 |
this._position = null; |
23 | 24 |
this._size = null; |
... | ... | |
33 | 34 |
this._isProvidedNeighboursHighlighted = false; |
34 | 35 |
this._isArchetypeNeighboursHighlighted = false; |
35 | 36 |
this._isNeighbourIconsDisplayed = false; |
36 |
|
|
37 |
this._relatedArchetypeMap = {}; |
|
38 | 37 |
} |
39 | 38 |
|
40 | 39 |
/** |
... | ... | |
142 | 141 |
* @returns {object} Map with archetype indexes as keys and counters of their instances as values. |
143 | 142 |
*/ |
144 | 143 |
get relatedArchetypeMap() { |
145 |
return this._relatedArchetypeMap;
|
|
144 |
return this._relatedArchetypeListComponent.map;
|
|
146 | 145 |
} |
147 | 146 |
|
148 | 147 |
/** |
... | ... | |
508 | 507 |
* @param {integer} archetypeIndex Index of the vertex archetype. |
509 | 508 |
* @param {MouseEvent} e Click event. |
510 | 509 |
*/ |
511 |
_onRelatedArchetypeIconClick(archetypeIndex, e) {
|
|
510 |
onRelatedArchetypeIconClick(archetypeIndex, e) { |
|
512 | 511 |
e.stopPropagation(); |
513 | 512 |
|
514 | 513 |
this.isArchetypeNeighboursHighlighted = !this.isHighlighted; |
sources/src/main/webapp/js/components/nodeProxy.js | ||
---|---|---|
100 | 100 |
edgeOffsetY = 0; |
101 | 101 |
} |
102 | 102 |
|
103 |
let archetypeList = Object.keys(this._node.relatedArchetypeMap).map(archetypeIndex => parseInt(archetypeIndex));
|
|
103 |
let archetypeList = Array.from(this._node.relatedArchetypeMap.keys());
|
|
104 | 104 |
let archetypeIconOrder; |
105 | 105 |
|
106 | 106 |
// redraw dependent edges |
sources/src/main/webapp/js/components/nodeRelatedArchetypeList.js | ||
---|---|---|
1 |
/** |
|
2 |
* Class representing list of related archetypes displayed next to a node to mark its relation to another, excluded node. |
|
3 |
* @see Node |
|
4 |
*/ |
|
5 |
class NodeRelatedArchetypeList { |
|
6 |
/** |
|
7 |
* @constructor |
|
8 |
*/ |
|
9 |
constructor(node) { |
|
10 |
this._node = node; |
|
11 |
this._map = new Map; |
|
12 |
this._iconSize = 20; |
|
13 |
} |
|
14 |
|
|
15 |
get map() { |
|
16 |
return this._map; |
|
17 |
} |
|
18 |
|
|
19 |
get size() { |
|
20 |
return new Dimensions( |
|
21 |
this._node.isExcluded === true ? this._iconSize : (this._map.size * this._iconSize), |
|
22 |
this._node.isExcluded === true ? (this._map.size * this._iconSize) : this._iconSize, |
|
23 |
); |
|
24 |
} |
|
25 |
|
|
26 |
add(key, value = 1) { |
|
27 |
let currentValue; |
|
28 |
if (this._map.has(key) === true) { |
|
29 |
currentValue = this._map.get(key); |
|
30 |
} else { |
|
31 |
currentValue = 0; |
|
32 |
} |
|
33 |
|
|
34 |
this._map.set(key, currentValue + value); |
|
35 |
|
|
36 |
this._renderIcons(); |
|
37 |
} |
|
38 |
|
|
39 |
remove(key, value = 1) { |
|
40 |
let currentValue; |
|
41 |
if (this._map.has(key) === true) { |
|
42 |
currentValue = this._map.get(key); |
|
43 |
} else { |
|
44 |
currentValue = 0; |
|
45 |
} |
|
46 |
|
|
47 |
this._map.set(key, currentValue - value); |
|
48 |
|
|
49 |
this._renderIcons(); |
|
50 |
} |
|
51 |
|
|
52 |
render() { |
|
53 |
if (this._node.isExcluded === true) { |
|
54 |
this._rootElement = DOM.s('g', { |
|
55 |
transform: 'translate(10, 15)', |
|
56 |
}); |
|
57 |
} else { |
|
58 |
this._rootElement = DOM.s('g', { |
|
59 |
transform: `translate(${this._node.size.width}, 0)`, |
|
60 |
}); |
|
61 |
} |
|
62 |
|
|
63 |
this._renderIcons(); |
|
64 |
|
|
65 |
return this._rootElement; |
|
66 |
} |
|
67 |
|
|
68 |
_renderIcons() { |
|
69 |
if (Utils.isUndefined(this._rootElement)) return; |
|
70 |
|
|
71 |
this._rootElement.innerHTML = ''; |
|
72 |
|
|
73 |
let iconOrder = 0; |
|
74 |
this._map.forEach((value, key) => { |
|
75 |
if (this._node.isExcluded === true) { |
|
76 |
this._rootElement.appendChild(DOM.s('g', { |
|
77 |
class: 'related-archetype', |
|
78 |
transform: `translate(0, ${iconOrder * this._iconSize})`, |
|
79 |
}, [ |
|
80 |
// counter |
|
81 |
DOM.s('text', {}, [ |
|
82 |
DOM.t(value), |
|
83 |
]), |
|
84 |
// icon |
|
85 |
DOM.s('use', { |
|
86 |
href: '#vertexArchetypeIcon-' + app.archetype.vertex[key].name, |
|
87 |
class: 'archetype-icon', |
|
88 |
transform: `translate(15, -10)`, |
|
89 |
onClick: this._node.onRelatedArchetypeIconClick.bind(this._node, key), // TODO: when icon == null can not click on item |
|
90 |
}), |
|
91 |
// line |
|
92 |
DOM.s('line', { |
|
93 |
x1: 30, |
|
94 |
y1: -5, |
|
95 |
x2: 36, |
|
96 |
y2: -5, |
|
97 |
}), |
|
98 |
])); |
|
99 |
} else { |
|
100 |
this._rootElement.appendChild(DOM.s('use', { |
|
101 |
href: '#vertexArchetypeIcon-' + app.archetype.vertex[key].name, |
|
102 |
class: 'archetype-icon', |
|
103 |
transform: `translate(${iconOrder * this._iconSize}, 8)`, |
|
104 |
onClick: this._node.onRelatedArchetypeIconClick.bind(this._node, key), // TODO: when icon == null can not click on item |
|
105 |
})); |
|
106 |
} |
|
107 |
|
|
108 |
iconOrder++; |
|
109 |
}); |
|
110 |
} |
|
111 |
} |
sources/src/main/webapp/js/components/vertex.js | ||
---|---|---|
12 | 12 |
// constants |
13 | 13 |
this._oneCharacterWidth = 8.3; // approximate width (in pixels) of one character using Consolas at 15px font size |
14 | 14 |
this._minimumWidth = 200; |
15 |
this._relatedArchetypeIconWidth = 20; |
|
16 | 15 |
|
17 | 16 |
// properties |
18 | 17 |
/** @prop {integer} archetype Identifier of the vertex archetype. */ |
... | ... | |
107 | 106 |
* @param {integer} archetypeIndex Index of the vertex archetype. |
108 | 107 |
*/ |
109 | 108 |
incrementRelatedArchetype(archetypeIndex) { |
110 |
if (this.relatedArchetypeMap.hasOwnProperty(archetypeIndex) === false) { |
|
111 |
this.relatedArchetypeMap[archetypeIndex] = 0; |
|
112 |
} |
|
113 |
|
|
114 |
this.relatedArchetypeMap[archetypeIndex]++; |
|
109 |
this._relatedArchetypeListComponent.add(archetypeIndex); |
|
115 | 110 |
} |
116 | 111 |
|
117 | 112 |
/** |
... | ... | |
231 | 226 |
onMouseDown: this._onNodeMouseDown.bind(this), |
232 | 227 |
}, [ |
233 | 228 |
DOM.s('rect', { |
234 |
width: this.size.width + Object.keys(this.relatedArchetypeMap).length * this._relatedArchetypeIconWidth,
|
|
229 |
width: this.size.width + this._relatedArchetypeListComponent.size.width,
|
|
235 | 230 |
height: this.size.height, |
236 | 231 |
x: 1, |
237 | 232 |
y: 1, |
... | ... | |
253 | 248 |
]), |
254 | 249 |
// symbol list |
255 | 250 |
this._symbolListComponent.render(), |
251 |
// related archetype list |
|
252 |
this._relatedArchetypeListComponent.render(), |
|
256 | 253 |
]); |
257 | 254 |
|
258 |
// related archetype icons |
|
259 |
const relatedArchetypeListContainer = DOM.s('g', { |
|
260 |
transform: `translate(${this.size.width}, 0)`, |
|
261 |
}); |
|
262 |
this._rootElement.appendChild(relatedArchetypeListContainer); |
|
263 |
|
|
264 |
let archetypeIconOrder = 0; |
|
265 |
for (let archetypeIndex in this.relatedArchetypeMap) { |
|
266 |
relatedArchetypeListContainer.appendChild(DOM.s('use', { |
|
267 |
href: '#vertexArchetypeIcon-' + app.archetype.vertex[archetypeIndex].name, |
|
268 |
class: 'archetype-icon', |
|
269 |
transform: `translate(${archetypeIconOrder * this._relatedArchetypeIconWidth}, 8)`, |
|
270 |
onClick: this._onRelatedArchetypeIconClick.bind(this, parseInt(archetypeIndex)), // TODO when icon == null can not click on item |
|
271 |
})); |
|
272 |
|
|
273 |
archetypeIconOrder++; |
|
274 |
} |
|
275 |
|
|
276 | 255 |
return this._rootElement; |
277 | 256 |
} |
278 | 257 |
|
... | ... | |
280 | 259 |
* @returns {HTMLElement} HTML DOM element. |
281 | 260 |
*/ |
282 | 261 |
_renderExcluded() { |
283 |
const svg = DOM.s('svg', { |
|
284 |
xmlns: 'http://www.w3.org/2000/svg', |
|
285 |
height: 60, |
|
286 |
width: 46, |
|
287 |
}); |
|
288 |
|
|
289 |
// related archetypes |
|
290 |
const relatedArchetypesGroup = DOM.s('g', { |
|
291 |
transform: 'translate(10, 15)', |
|
292 |
}); |
|
293 |
svg.appendChild(relatedArchetypesGroup); |
|
294 |
|
|
295 |
let archetypeIconOrder = 0; |
|
296 |
for (let archetypeIndex in this.relatedArchetypeMap) { |
|
297 |
relatedArchetypesGroup.appendChild(DOM.s('g', { |
|
298 |
class: 'related-archetype', |
|
299 |
transform: `translate(0, ${archetypeIconOrder * 20})`, |
|
300 |
}, [ |
|
301 |
// counter |
|
302 |
DOM.s('text', {}, [ |
|
303 |
DOM.t(this.relatedArchetypeMap[archetypeIndex]), |
|
304 |
]), |
|
305 |
// icon |
|
306 |
DOM.s('use', { |
|
307 |
href: '#vertexArchetypeIcon-' + app.archetype.vertex[archetypeIndex].name, |
|
308 |
class: 'archetype-icon', |
|
309 |
transform: `translate(15, -10)`, |
|
310 |
onClick: this._onRelatedArchetypeIconClick.bind(this, parseInt(archetypeIndex)), // TODO when icon == null can not click on item |
|
311 |
}), |
|
312 |
// line |
|
313 |
DOM.s('line', { |
|
314 |
x1: 30, |
|
315 |
y1: -5, |
|
316 |
x2: 36, |
|
317 |
y2: -5, |
|
318 |
}), |
|
319 |
])); |
|
320 |
|
|
321 |
archetypeIconOrder++; |
|
322 |
} |
|
323 |
|
|
324 | 262 |
// root |
325 | 263 |
this._rootElement = DOM.h('li', { |
326 | 264 |
class: 'node vertex', |
327 | 265 |
'data-id': this.id, |
328 | 266 |
}, [ |
329 |
svg, |
|
267 |
// related archetypes |
|
268 |
DOM.s('svg', { |
|
269 |
height: this._relatedArchetypeListComponent.size.height, |
|
270 |
width: 46, |
|
271 |
}, [ |
|
272 |
this._relatedArchetypeListComponent.render(), |
|
273 |
]), |
|
330 | 274 |
// name |
331 | 275 |
DOM.h('div', { |
332 | 276 |
class: 'vertex-name', |
sources/src/main/webapp/showGraph.jsp | ||
---|---|---|
50 | 50 |
<script src="js/components/loginPopup.js"></script> |
51 | 51 |
<script src="js/components/minimap.js"></script> |
52 | 52 |
<script src="js/components/navbar.js"></script> |
53 |
<script src="js/components/nodeRelatedArchetypeList.js"></script> |
|
53 | 54 |
<script src="js/components/nodeSymbolList.js"></script> |
54 | 55 |
<script src="js/components/registerPopup.js"></script> |
55 | 56 |
<script src="js/components/saveDiagramModalWindow.js"></script> |
Také k dispozici: Unified diff
detach NodeRelatedArchetypeList to a separate component