edges from different types in same direction are shown

This commit is contained in:
itsikkes 2016-05-27 08:47:22 +03:00
parent 347833d619
commit 41a5f0a1ed
1 changed files with 11 additions and 7 deletions

View File

@ -22,6 +22,9 @@ var edges = [];
const ICONS_DIR = "./css/img/objects/";
const ICONS_EXT = ".png";
const EDGE_TYPE_PARENT = "parent";
const EDGE_TYPE_TUNNEL = "tunnel";
// General options
// If variable from local storage != null, assign it, otherwise set it's default value.
@ -174,10 +177,10 @@ function createEdges() {
for (var i = 0; i < monkeys.length; i++) {
var monkey = monkeys[i];
if(monkey.parent != monkey.guid) {
parent = getMonkeyByGuid(monkey.parent);
var parent = getMonkeyByGuid(monkey.parent);
if(parent && !edgeExists([parent.id, monkey.id])) {
edges.push({from: parent.id, to: monkey.id, arrows:'middle', color: 'red'});
if(parent && !edgeExists([parent.id, monkey.id, EDGE_TYPE_PARENT])) {
edges.push({from: parent.id, to: monkey.id, arrows:'middle', type: EDGE_TYPE_PARENT, color: 'red'});
}
}
}
@ -189,10 +192,10 @@ function createTunnels() {
for (var i = 0; i < monkeys.length; i++) {
var monkey = monkeys[i];
if(monkey.tunnel_guid) {
tunnel = getMonkeyByGuid(monkey.tunnel_guid);
var tunnel = getMonkeyByGuid(monkey.tunnel_guid);
if(tunnel && !edgeExists([monkey.id, tunnel.id])) {
edges.push({from: monkey.id, to: tunnel.id, arrows:'middle', color:'blue'});
if(tunnel && !edgeExists([monkey.id, tunnel.id, EDGE_TYPE_TUNNEL])) {
edges.push({from: monkey.id, to: tunnel.id, arrows:'middle', type: EDGE_TYPE_TUNNEL, color:'blue'});
}
}
}
@ -528,7 +531,8 @@ function edgeExists(link) {
for (var i = 0; i < edges.length; i++) {
var from = edges[i].from;
var to = edges[i].to;
if (from == link[0] && to == link[1]) {
var type = edges[i].type;
if (from == link[0] && to == link[1] && type == link[2]) {
return true;
}
}