Commits

Frederic De Groef committed 3a05ab5

draw disabled edge arrows in grey

  • Participants
  • Parent commits 62aacc3

Comments (0)

Files changed (1)

File scripts/sigmajs/sigma.min.js

 d+m;if(c!=a.stageX||f!=a.stageY)q=A,w=v,A=c,v=f,a.stageX=c,a.stageY=f,a.dispatch("drag")}a.dispatch("move");b.preventDefault?b.preventDefault():b.returnValue=!1},!0);b.addEventListener("mousedown",function(b){a.p.mouseEnabled&&(a.isMouseDown=!0,a.dispatch("mousedown"),j=a.stageX,m=a.stageY,g=a.mouseX,d=a.mouseY,q=A=a.stageX,w=v=a.stageY,a.dispatch("startdrag"),b.preventDefault?b.preventDefault():b.returnValue=!1)},!0);document.addEventListener("mouseup",function(b){a.p.mouseEnabled&&a.isMouseDown&&
 (a.isMouseDown=!1,a.dispatch("mouseup"),(j!=a.stageX||m!=a.stageY)&&f(a.stageX+a.p.inertia*(a.stageX-q),a.stageY+a.p.inertia*(a.stageY-w)),b.preventDefault?b.preventDefault():b.returnValue=!1)},!0);this.checkBorders=function(){return a};this.interpolate=f}function k(b,i,f,c,a,g,d){function j(a){function b(a){var c=Math.sqrt(a[0]*a[0]+a[1]*a[1]);return[a[0]/c,a[1]/c]}function c(a,b){return[a[0]-b[0],a[1]-b[1]]}function d(a,b){return[a[0]*Math.cos(b)-a[1]*Math.sin(b),a[0]*Math.sin(b)+a[1]*Math.cos(b)]}
 var f=a.source.displayX,g=a.source.displayY,m=a.target.displayX,l=a.target.displayY,k=a.color;if(!k)switch(h.p.edgeColor){case "source":k=a.source.color||h.p.defaultNodeColor;break;case "target":k=a.target.color||h.p.defaultNodeColor;break;default:k=h.p.defaultEdgeColor}var n=i;switch(a.type||h.p.defaultEdgeType){case "curve":n.strokeStyle=k;n.lineWidth=a.displaySize/3;n.beginPath();n.moveTo(f,g);n.quadraticCurveTo((f+m)/2+(l-g)/4,(g+l)/2+(f-m)/4,m,l);n.stroke();break;default:n.strokeStyle=k,n.lineWidth=
-a.displaySize/3,n.beginPath(),n.moveTo(f,g),n.lineTo(m,l),n.stroke()}k=a.target.displaySize;n.save();n.translate(m,l);switch(a.type||h.p.defaultEdgeType){case "curve":f=b(c([(f+m)/2+(l-g)/4,(g+l)/2+(f-m)/4],[m,l]));break;default:f=b(c([f,g],[m,l]))}g=[f[0]*1.1*k,f[1]*1.1*k];n.save();n.translate(g[0],g[1]);g=d(f,Math.PI/8);f=d(f,-Math.PI/8);g=[g[0]*k,g[1]*k];f=[f[0]*k,f[1]*k];n.fillStyle=a.source.color;n.strokeStyle="#fff";n.beginPath();n.moveTo(0,0);n.lineTo(g[0],g[1]);n.lineTo(f[0],f[1]);n.closePath();
-n.fill();n.restore();n.restore();return h}function m(a){var b=c,d="fixed"==h.p.labelSize?h.p.defaultLabelSize:h.p.labelSizeRatio*a.displaySize;b.font=(h.p.hoverFontStyle||h.p.fontStyle||"")+" "+d+"px "+(h.p.hoverFont||h.p.font||"");b.fillStyle="node"==h.p.labelHoverBGColor?a.color||h.p.defaultNodeColor:h.p.defaultHoverLabelBGColor;b.beginPath();h.p.labelHoverShadow&&(b.shadowOffsetX=0,b.shadowOffsetY=0,b.shadowBlur=4,b.shadowColor=h.p.labelHoverShadowColor);sigma.tools.drawRoundRect(b,Math.round(a.displayX-
-d/2-2),Math.round(a.displayY-d/2-2),Math.round(b.measureText(a.label).width+1.5*a.displaySize+d/2+4),Math.round(d+4),Math.round(d/2+2),"left");b.closePath();b.fill();b.shadowOffsetX=0;b.shadowOffsetY=0;b.shadowBlur=0;b.beginPath();b.fillStyle="node"==h.p.nodeBorderColor?a.color||h.p.defaultNodeColor:h.p.defaultNodeBorderColor;b.arc(Math.round(a.displayX),Math.round(a.displayY),a.displaySize+h.p.borderSize,0,2*Math.PI,!0);b.closePath();b.fill();b.beginPath();b.fillStyle="node"==h.p.nodeHoverColor?
-a.color||h.p.defaultNodeColor:h.p.defaultNodeHoverColor;b.arc(Math.round(a.displayX),Math.round(a.displayY),a.displaySize,0,2*Math.PI,!0);b.closePath();b.fill();b.fillStyle="node"==h.p.labelHoverColor?a.color||h.p.defaultNodeColor:h.p.defaultLabelHoverColor;b.fillText(a.label,Math.round(a.displayX+1.5*a.displaySize),Math.round(a.displayY+d/2-3));return h}function l(a){if(isNaN(a.x)||isNaN(a.y))throw Error("A node's coordinate is not a number (id: "+a.id+")");return!a.hidden&&a.displayX+a.displaySize>
--k/3&&a.displayX-a.displaySize<4*k/3&&a.displayY+a.displaySize>-A/3&&a.displayY-a.displaySize<4*A/3}sigma.classes.Cascade.call(this);var h=this;this.p={labelColor:"default",defaultLabelColor:"#000",labelHoverBGColor:"default",defaultHoverLabelBGColor:"#fff",labelHoverShadow:!0,labelHoverShadowColor:"#000",labelHoverColor:"default",defaultLabelHoverColor:"#000",labelActiveBGColor:"default",defaultActiveLabelBGColor:"#fff",labelActiveShadow:!0,labelActiveShadowColor:"#000",labelActiveColor:"default",
+a.displaySize/3,n.beginPath(),n.moveTo(f,g),n.lineTo(m,l),n.stroke()}k=a.target.displaySize;n.save();n.translate(m,l);switch(a.type||h.p.defaultEdgeType){case "curve":f=b(c([(f+m)/2+(l-g)/4,(g+l)/2+(f-m)/4],[m,l]));break;default:f=b(c([f,g],[m,l]))}g=[f[0]*1.1*k,f[1]*1.1*k];n.save();n.translate(g[0],g[1]);g=d(f,Math.PI/8);f=d(f,-Math.PI/8);g=[g[0]*k,g[1]*k];f=[f[0]*k,f[1]*k];n.fillStyle=a.attr.grey?"#666":a.source.color;n.strokeStyle="#fff";n.beginPath();n.moveTo(0,0);n.lineTo(g[0],g[1]);n.lineTo(f[0],
+f[1]);n.closePath();n.fill();n.restore();n.restore();return h}function m(a){var b=c,d="fixed"==h.p.labelSize?h.p.defaultLabelSize:h.p.labelSizeRatio*a.displaySize;b.font=(h.p.hoverFontStyle||h.p.fontStyle||"")+" "+d+"px "+(h.p.hoverFont||h.p.font||"");b.fillStyle="node"==h.p.labelHoverBGColor?a.color||h.p.defaultNodeColor:h.p.defaultHoverLabelBGColor;b.beginPath();h.p.labelHoverShadow&&(b.shadowOffsetX=0,b.shadowOffsetY=0,b.shadowBlur=4,b.shadowColor=h.p.labelHoverShadowColor);sigma.tools.drawRoundRect(b,
+Math.round(a.displayX-d/2-2),Math.round(a.displayY-d/2-2),Math.round(b.measureText(a.label).width+1.5*a.displaySize+d/2+4),Math.round(d+4),Math.round(d/2+2),"left");b.closePath();b.fill();b.shadowOffsetX=0;b.shadowOffsetY=0;b.shadowBlur=0;b.beginPath();b.fillStyle="node"==h.p.nodeBorderColor?a.color||h.p.defaultNodeColor:h.p.defaultNodeBorderColor;b.arc(Math.round(a.displayX),Math.round(a.displayY),a.displaySize+h.p.borderSize,0,2*Math.PI,!0);b.closePath();b.fill();b.beginPath();b.fillStyle="node"==
+h.p.nodeHoverColor?a.color||h.p.defaultNodeColor:h.p.defaultNodeHoverColor;b.arc(Math.round(a.displayX),Math.round(a.displayY),a.displaySize,0,2*Math.PI,!0);b.closePath();b.fill();b.fillStyle="node"==h.p.labelHoverColor?a.color||h.p.defaultNodeColor:h.p.defaultLabelHoverColor;b.fillText(a.label,Math.round(a.displayX+1.5*a.displaySize),Math.round(a.displayY+d/2-3));return h}function l(a){if(isNaN(a.x)||isNaN(a.y))throw Error("A node's coordinate is not a number (id: "+a.id+")");return!a.hidden&&a.displayX+
+a.displaySize>-k/3&&a.displayX-a.displaySize<4*k/3&&a.displayY+a.displaySize>-A/3&&a.displayY-a.displaySize<4*A/3}sigma.classes.Cascade.call(this);var h=this;this.p={labelColor:"default",defaultLabelColor:"#000",labelHoverBGColor:"default",defaultHoverLabelBGColor:"#fff",labelHoverShadow:!0,labelHoverShadowColor:"#000",labelHoverColor:"default",defaultLabelHoverColor:"#000",labelActiveBGColor:"default",defaultActiveLabelBGColor:"#fff",labelActiveShadow:!0,labelActiveShadowColor:"#000",labelActiveColor:"default",
 defaultLabelActiveColor:"#000",labelSize:"fixed",defaultLabelSize:12,labelSizeRatio:2,labelThreshold:6,font:"Arial",hoverFont:"",activeFont:"",fontStyle:"",hoverFontStyle:"",activeFontStyle:"",edgeColor:"source",defaultEdgeColor:"#aaa",defaultEdgeType:"line",defaultNodeColor:"#aaa",nodeHoverColor:"node",defaultNodeHoverColor:"#fff",nodeActiveColor:"node",defaultNodeActiveColor:"#fff",borderSize:0,nodeBorderColor:"node",defaultNodeBorderColor:"#fff",edgesSpeed:200,nodesSpeed:200,labelsSpeed:200};var k=
 g,A=d;this.currentLabelIndex=this.currentNodeIndex=this.currentEdgeIndex=0;this.task_drawLabel=function(){for(var b=a.nodes.length,c=0;c++<h.p.labelsSpeed&&h.currentLabelIndex<b;)if(h.isOnScreen(a.nodes[h.currentLabelIndex])){var d=a.nodes[h.currentLabelIndex++],i=f;if(d.displaySize>=h.p.labelThreshold||d.forceLabel){var g="fixed"==h.p.labelSize?h.p.defaultLabelSize:h.p.labelSizeRatio*d.displaySize;i.font=h.p.fontStyle+g+"px "+h.p.font;i.fillStyle="node"==h.p.labelColor?d.color||h.p.defaultNodeColor:
 h.p.defaultLabelColor;i.fillText(d.label,Math.round(d.displayX+1.5*d.displaySize),Math.round(d.displayY+g/2-3))}}else h.currentLabelIndex++;return h.currentLabelIndex<b};this.task_drawEdge=function(){for(var b=a.edges.length,c,d,f=0;f++<h.p.edgesSpeed&&h.currentEdgeIndex<b;)e=a.edges[h.currentEdgeIndex],c=e.source,d=e.target,e.hidden||c.hidden||d.hidden||!h.isOnScreen(c)&&!h.isOnScreen(d)?h.currentEdgeIndex++:j(a.edges[h.currentEdgeIndex++]);return h.currentEdgeIndex<b};this.task_drawNode=function(){for(var c=