redo link type handling

This commit is contained in:
Milan Pässler 2016-02-18 19:26:05 +00:00
parent 3a7cc2bbc5
commit f77aabd37d
8 changed files with 67 additions and 33 deletions

View file

@ -213,7 +213,7 @@ define(["d3"], function (d3) {
function drawLabel(d) {
var neighbours = d.neighbours.filter(function (d) {
return !d.link.o.vpn
return !d.link.o.type === "VPN"
})
var sum = neighbours.reduce(function (a, b) {
@ -244,8 +244,7 @@ define(["d3"], function (d3) {
return (d.source.x > screenRect.left && d.source.x < screenRect.right &&
d.source.y > screenRect.top && d.source.y < screenRect.bottom) ||
(d.target.x > screenRect.left && d.target.x < screenRect.right &&
d.target.y > screenRect.top && d.target.y < screenRect.bottom) ||
d.o.vpn
d.target.y > screenRect.top && d.target.y < screenRect.bottom)
}
function visibleNodes(d) {
@ -316,6 +315,7 @@ define(["d3"], function (d3) {
var uplinkColor = "#5BAAEB"
var highlightColor = "rgba(252, 227, 198, 0.15)"
var nodeRadius = 6
var cableColor = "#50B0F0"
// -- draw links --
ctx.save()
@ -329,9 +329,9 @@ define(["d3"], function (d3) {
ctx.beginPath()
ctx.moveTo(d.source.x + dx * nodeRadius, d.source.y + dy * nodeRadius)
ctx.lineTo(d.target.x - dx * nodeRadius, d.target.y - dy * nodeRadius)
ctx.strokeStyle = d.color
ctx.globalAlpha = d.o.vpn ? 0.1 : 0.8
ctx.lineWidth = d.o.vpn ? 1.5 : 2.5
ctx.strokeStyle = d.o.type === "Kabel" ? cableColor : d.color
ctx.globalAlpha = d.o.type === "VPN" ? 0.1 : 0.8
ctx.lineWidth = d.o.type === "VPN" ? 1.5 : 2.5
ctx.stroke()
})
@ -516,7 +516,7 @@ define(["d3"], function (d3) {
}
var links = intLinks.filter(function (d) {
return !d.o.vpn
return !d.o.type === "VPN"
}).filter(function (d) {
return distanceLink(e, d.source, d.target) < LINE_RADIUS
})
@ -577,13 +577,13 @@ define(["d3"], function (d3) {
.charge(-250)
.gravity(0.1)
.linkDistance(function (d) {
if (d.o.vpn)
if (d.o.type === "VPN")
return 0
else
return LINK_DISTANCE
})
.linkStrength(function (d) {
if (d.o.vpn)
if (d.o.type === "VPN")
return 0
else
return Math.max(0.5, 1 / d.o.tq)
@ -637,7 +637,7 @@ define(["d3"], function (d3) {
e.source = newNodesDict[d.source.id]
e.target = newNodesDict[d.target.id]
if (d.vpn)
if (d.type === "VPN")
e.color = "rgba(255, 255, 255, " + (0.6 / d.tq) + ")"
else
e.color = linkScale(d.tq).hex()