Revize d7cfe537
Přidáno uživatelem Pavel Fidranský před více než 6 roky(ů)
sources/src/main/webapp/js/app.js | ||
---|---|---|
242 | 242 |
}); |
243 | 243 |
|
244 | 244 |
if (verticesWithMostEdges.length > 0) { |
245 |
var group = new Group; |
|
245 |
var group = new Group({});
|
|
246 | 246 |
|
247 | 247 |
verticesWithMostEdges.forEach(function(vertex) { |
248 | 248 |
group.addVertex(vertex); |
sources/src/main/webapp/js/components/edge.js | ||
---|---|---|
6 | 6 |
function Edge(props) { |
7 | 7 |
/** @prop {integer} id Unique identifier of the edge. */ |
8 | 8 |
this.id = props.id; |
9 |
/** @prop {integer} archetype Archetype of the edge. */ |
|
10 |
this.archetype = app.archetype.edge[props.subedgeInfo.archetype];
|
|
9 |
/** @prop {integer} archetype Archetype of the edge. TODO: why is there multiple subedgeInfo for one edge? */
|
|
10 |
this.archetype = -1;
|
|
11 | 11 |
|
12 | 12 |
var rootElement; |
13 | 13 |
|
sources/src/main/webapp/js/components/group.js | ||
---|---|---|
5 | 5 |
*/ |
6 | 6 |
function Group(props) { |
7 | 7 |
/** @prop {integer} id Unique identifier of the group. */ |
8 |
this.id = app.groupList.length + 1; |
|
8 |
this.id = props.hasOwnProperty('id') ? props.id : app.groupList.length + 1;
|
|
9 | 9 |
/** @prop {string} name Name of the group. */ |
10 | 10 |
this.name = props.hasOwnProperty('name') ? props.name : 'Group ' + this.id; |
11 | 11 |
/** @prop {array} symbol Symbol of the group. */ |
sources/src/main/webapp/js/components/vertex.js | ||
---|---|---|
6 | 6 |
function Vertex(props) { |
7 | 7 |
/** @prop {integer} id Unique identifier of the vertex. */ |
8 | 8 |
this.id = props.id; |
9 |
/** @prop {integer} archetype Archetype of the vertex. */
|
|
10 |
this.archetype = app.archetype.vertex[props.archetype];
|
|
9 |
/** @prop {integer} archetype Identifier of the vertex archetype. */
|
|
10 |
this.archetype = props.archetype;
|
|
11 | 11 |
/** @prop {string} name Name of the vertex. */ |
12 |
this.name = props.name.split(':')[1];
|
|
12 |
this.name = props.title.split(':')[1];
|
|
13 | 13 |
/** @prop {array} symbol Symbol of the group. */ |
14 | 14 |
this.symbol = app.markSymbol.getMarkSymbol(); |
15 | 15 |
|
sources/src/main/webapp/js/components/vertexContextMenuList.js | ||
---|---|---|
104 | 104 |
function nodeListItemClick(e) { |
105 | 105 |
if (this instanceof Vertex) { |
106 | 106 |
// create a new group |
107 |
var group = new Group; |
|
107 |
var group = new Group({});
|
|
108 | 108 |
group.setExcluded(true); |
109 | 109 |
group.addVertex(this); |
110 | 110 |
|
sources/src/main/webapp/js/components/vertexPopover.js | ||
---|---|---|
11 | 11 |
/** |
12 | 12 |
* Sets the contents of the popover. |
13 | 13 |
* @param {string} name Title of the popover. |
14 |
* @param {array} attributes List of attributes.
|
|
14 |
* @param {array} attributeList List of attributes.
|
|
15 | 15 |
*/ |
16 |
this.setContent = function(name, attributes) {
|
|
16 |
this.setContent = function(name, attributeList) {
|
|
17 | 17 |
popoverTitle.innerText = name; |
18 | 18 |
|
19 |
if (attributes.length > 0) { |
|
20 |
attributes.forEach(function(attributes) { |
|
21 |
var listItem = app.utils.createHtmlElement('li', {}); |
|
22 |
listItem.appendChild(document.createTextNode(attributes)); |
|
19 |
if (attributeList.length === 0) return; |
|
23 | 20 |
|
24 |
detailsListElement.appendChild(listItem); |
|
25 |
}); |
|
26 |
} |
|
21 |
attributeList.forEach(function(attribute) { |
|
22 |
var listItem = app.utils.createHtmlElement('li', {}); |
|
23 |
listItem.appendChild(document.createTextNode(`${attribute[0]}: ${attribute[1]}`)); |
|
24 |
|
|
25 |
detailsListElement.appendChild(listItem); |
|
26 |
}); |
|
27 | 27 |
}; |
28 | 28 |
|
29 | 29 |
/** |
sources/src/main/webapp/js/graphLoader.js | ||
---|---|---|
20 | 20 |
|
21 | 21 |
var canvasSize = ((data.vertices.length * 75) / Math.round(Math.sqrt(data.vertices.length))) + 1000; |
22 | 22 |
|
23 |
// archetypes |
|
23 |
// store archetypes
|
|
24 | 24 |
app.archetype.vertex = data.vertexArchetypes; |
25 | 25 |
app.archetype.edge = data.edgeArchetypes; |
26 | 26 |
app.archetype.icon = data.archetypeIcons; |
27 | 27 |
|
28 |
// vertices |
|
28 |
// construct vertices
|
|
29 | 29 |
var vertexMap = {}; |
30 | 30 |
data.vertices.forEach(function(component) { |
31 | 31 |
var vertex = new Vertex(component); |
... | ... | |
55 | 55 |
app.nodeList.push(vertex); |
56 | 56 |
app.vertexList.push(vertex); |
57 | 57 |
|
58 |
vertexMap[component.symbolicName] = vertex; |
|
59 |
|
|
60 |
app.viewportComponent.addVertex(vertex); |
|
58 |
vertexMap[component.originalId] = vertex; |
|
61 | 59 |
}); |
62 | 60 |
|
63 |
// edges |
|
61 |
// construct edges
|
|
64 | 62 |
data.edges.forEach(function(component) { |
65 | 63 |
var edge = new Edge(component); |
66 | 64 |
|
... | ... | |
74 | 72 |
toNode.addInEdge(edge); |
75 | 73 |
} |
76 | 74 |
|
77 |
app.edgeList.push(edge); |
|
75 |
if (fromNode && toNode) { |
|
76 |
fromNode.incrementRelatedArchetype(toNode.archetype); |
|
77 |
toNode.incrementRelatedArchetype(fromNode.archetype); |
|
78 |
} |
|
78 | 79 |
|
79 |
app.viewportComponent.addEdge(edge);
|
|
80 |
app.edgeList.push(edge);
|
|
80 | 81 |
}); |
81 | 82 |
|
82 | 83 |
delete vertexMap; |
83 | 84 |
|
85 |
// render components |
|
86 |
app.vertexList.forEach(function(vertex) { |
|
87 |
app.viewportComponent.addVertex(vertex); |
|
88 |
}); |
|
89 |
|
|
90 |
app.edgeList.forEach(function(edge) { |
|
91 |
app.viewportComponent.addEdge(edge); |
|
92 |
}); |
|
93 |
|
|
84 | 94 |
// center viewport |
85 | 95 |
app.viewportComponent.center(); |
86 | 96 |
|
... | ... | |
92 | 102 |
app.sidebarComponent.unconnectedNodeListComponent.add(vertex); |
93 | 103 |
}); |
94 | 104 |
|
95 |
// group vertex archetypes |
|
96 |
var archetypeGroupMap = {}; |
|
105 |
// construct groups |
|
106 |
data.groups.forEach(function(component) { |
|
107 |
var group = new Group(component); |
|
108 |
group.setExcluded(true); |
|
97 | 109 |
|
98 |
data.defaultGroupArchetypes.forEach(function(archetypeIndex) { |
|
99 | 110 |
app.vertexList.filter(function(vertex) { |
100 |
return vertex.archetype === app.archetype.vertex[archetypeIndex];
|
|
111 |
return component.verticesId.indexOf(vertex.id) > -1;
|
|
101 | 112 |
}).forEach(function(vertex) { |
102 |
if (archetypeGroupMap[archetypeIndex] instanceof Group) { |
|
103 |
// group of the archetype vertices already exists |
|
104 |
var group = archetypeGroupMap[archetypeIndex]; |
|
105 |
|
|
106 |
} else { |
|
107 |
// create a new group |
|
108 |
var group = new Group({ |
|
109 |
name: `${app.archetype.vertex[archetypeIndex].name} vertices`, |
|
110 |
}); |
|
111 |
group.setExcluded(true); |
|
112 |
|
|
113 |
app.nodeList.push(group); |
|
114 |
app.groupList.push(group); |
|
115 |
|
|
116 |
app.sidebarComponent.excludedNodeListComponent.add(group); |
|
117 |
|
|
118 |
archetypeGroupMap[archetypeIndex] = group; |
|
119 |
} |
|
120 |
|
|
121 | 113 |
group.addVertex(vertex); |
122 | 114 |
}); |
115 |
|
|
116 |
app.nodeList.push(group); |
|
117 |
app.groupList.push(group); |
|
118 |
|
|
119 |
app.sidebarComponent.excludedNodeListComponent.add(group); |
|
123 | 120 |
}); |
124 | 121 |
|
125 | 122 |
// update status bar |
Také k dispozici: Unified diff
new JSON format compatibility fixes