Revize d2d5eac2
Přidáno uživatelem Tomáš Šimandl před více než 6 roky(ů)
sources/src/main/webapp/js/graphExporter.js | ||
---|---|---|
22 | 22 |
return group.export(); |
23 | 23 |
}); |
24 | 24 |
|
25 |
// positions of nodes |
|
26 |
var positions = app.nodeList.map(function(node) { |
|
27 |
if (node instanceof Vertex) { |
|
28 |
var id = 'vertex' + node.id; |
|
29 |
} else if (node instanceof Group) { |
|
30 |
var id = 'group' + node.id; |
|
31 |
} else { |
|
32 |
var id = node.id; |
|
33 |
} |
|
34 |
|
|
35 |
var position = node.getPosition(); |
|
36 |
|
|
37 |
return { |
|
38 |
id: id, |
|
39 |
x: position.x, |
|
40 |
y: position.y, |
|
41 |
}; |
|
42 |
}); |
|
43 |
|
|
44 | 25 |
// nodes excluded to the sidebar |
45 | 26 |
var excludedNodeList = app.sidebarComponent.excludedNodeListComponent.getNodeList(); |
46 | 27 |
var sideBar = excludedNodeList.map(function(node) { |
... | ... | |
57 | 38 |
vertices: vertices, |
58 | 39 |
edges: edges, |
59 | 40 |
possibleEnumValues: app.possibleEnumValues, |
60 |
archetypeIcons: app.archetype.icon, |
|
61 | 41 |
groups: groups, |
62 |
positions: positions, |
|
63 | 42 |
sideBar: sideBar, |
64 | 43 |
selectedVertex: null, // TODO: selected == highlighted |
65 | 44 |
selectedEdge: null, // TODO selected == highlighted |
sources/src/main/webapp/js/graphLoader.js | ||
---|---|---|
27 | 27 |
data.vertices.forEach(function(component) { |
28 | 28 |
var vertex = new Vertex(component); |
29 | 29 |
|
30 |
// position |
|
31 |
var position = data.positions.find(function(position) { |
|
32 |
return position.id === ('vertex' + vertex.id); |
|
33 |
}); |
|
30 |
var position = component.position |
|
34 | 31 |
|
35 |
if (app.utils.isDefined(position)) { |
|
36 |
vertex.setPosition(new Coordinates(position.x, position.y)); |
|
32 |
if (position === null) { |
|
33 |
// set random |
|
34 |
vertex.setPosition(new Coordinates( |
|
35 |
Math.floor(Math.random() * canvasSize), |
|
36 |
Math.floor(Math.random() * canvasSize), |
|
37 |
)); |
|
37 | 38 |
|
38 |
} else { |
|
39 |
// set random |
|
40 |
vertex.setPosition(new Coordinates( |
|
41 |
Math.floor(Math.random() * canvasSize), |
|
42 |
Math.floor(Math.random() * canvasSize), |
|
43 |
)); |
|
39 |
} else { |
|
40 |
vertex.setPosition(new Coordinates(position.x, position.y)); |
|
44 | 41 |
} |
45 | 42 |
|
46 | 43 |
app.nodeList.push(vertex); |
... | ... | |
102 | 99 |
}); |
103 | 100 |
|
104 | 101 |
// position |
105 |
var position = data.positions.find(function(position) { |
|
106 |
return position.id === ('group' + group.id); |
|
107 |
}); |
|
108 |
|
|
109 |
if (app.utils.isDefined(position)) { |
|
110 |
group.setPosition(new Coordinates(position.x, position.y)); |
|
111 |
|
|
112 |
} else { |
|
113 |
// set random |
|
114 |
group.setPosition(new Coordinates( |
|
115 |
Math.floor(Math.random() * canvasSize), |
|
116 |
Math.floor(Math.random() * canvasSize), |
|
117 |
)); |
|
118 |
} |
|
102 |
var position = component.position |
|
103 |
if (position === null) { |
|
104 |
// set random |
|
105 |
group.setPosition(new Coordinates( |
|
106 |
Math.floor(Math.random() * canvasSize), |
|
107 |
Math.floor(Math.random() * canvasSize), |
|
108 |
)); |
|
109 |
|
|
110 |
} else { |
|
111 |
group.setPosition(new Coordinates(position.x, position.y)); |
|
112 |
} |
|
119 | 113 |
|
120 | 114 |
app.nodeList.push(group); |
121 | 115 |
app.groupList.push(group); |
Také k dispozici: Unified diff
Move positions to vertex.position and group.position