(nodeJson, nodeId)
| 244 | } |
| 245 | |
| 246 | function parseNode(nodeJson, nodeId) { |
| 247 | // Conditional hack for system components |
| 248 | if (isSystemComponent(nodeId)) { |
| 249 | nodeJson[":type"] = "system"; |
| 250 | } |
| 251 | |
| 252 | // Determine node color |
| 253 | var col = "#D2E5FF" |
| 254 | var selectedCol = "#97C2FC"; |
| 255 | var shape = "dot" |
| 256 | |
| 257 | if (nodeJson[":type"] === "bolt") { |
| 258 | // Determine color based on capacity |
| 259 | var cap = Math.min(nodeJson[":capacity"], 1); |
| 260 | var red = Math.floor(cap * 225) + 30; |
| 261 | var green = Math.floor(255 - red); |
| 262 | var blue = Math.floor(green/5); |
| 263 | col = "rgba(" + red + "," + green + "," + blue + ",1)" |
| 264 | selectedCol = "rgba(" + (red+2) + "," + (green) + "," + (green + 2) + ",1)" |
| 265 | } |
| 266 | if (nodeJson[":type"] === "spout") { |
| 267 | shape = "triangleDown"; |
| 268 | col = "#D2E5FF"; |
| 269 | selectedCol = "#97C2FC" |
| 270 | } |
| 271 | if (nodeJson[":type"] === "system") { |
| 272 | shape = "diamond"; |
| 273 | col = "#ffe6cc"; |
| 274 | selectedCol = "#ffc180"; |
| 275 | } |
| 276 | |
| 277 | // Generate title as DOM element (vis-network 10 does not render HTML strings) |
| 278 | var title = tooltipElement([ |
| 279 | { text: nodeId, bold: true }, |
| 280 | { text: "Capacity: " + nodeJson[":capacity"] }, |
| 281 | { text: "Latency: " + nodeJson[":latency"] } |
| 282 | ]) |
| 283 | |
| 284 | // Construct the node |
| 285 | var node = { |
| 286 | "id": nodeId, |
| 287 | "label": nodeId, |
| 288 | "color": { |
| 289 | "background": col, |
| 290 | "highlight": { |
| 291 | "background": selectedCol |
| 292 | } |
| 293 | }, |
| 294 | "shape": shape, |
| 295 | "shadow": { |
| 296 | "enabled": true |
| 297 | }, |
| 298 | "title": title, |
| 299 | "size": 45 |
| 300 | }; |
| 301 | |
| 302 | // Construct edges |
| 303 | for (var index in nodeJson[":inputs"]) { |
no test coverage detected