function TrajectoryLink(streamNode, otherStreamNode, arrowDirection, changeList, streamUtilities) { //console.log('streamNode: ' + streamNode.stream.mName + ' other: ' + otherStreamNode.stream.mName); var mStreamUtilities = streamUtilities; var otherLinkPoint = otherStreamNode.GetTopLinkPoint(); var parentLinkPoint = streamNode.GetBottomLinkPoint(); var otherStreamIsHigher = streamNode.row() < otherStreamNode.row(); var mSameRow = streamNode.row() == otherStreamNode.row(); if(otherStreamIsHigher) { otherLinkPoint = otherStreamNode.GetBottomLinkPoint(); parentLinkPoint = streamNode.GetTopLinkPoint(); } var x = 0; var y = 0 var height = 0; var width = 0; var bottomToTop = true; var otherXGreaterThanParent = otherLinkPoint.X > parentLinkPoint.X; //the plan here is to build one of four different rectangles relative to this node: // A B // ____ ____ // | || | // | || | // ---- ---- // streamNode // ____ ____ // | || | // | || | // ---- ---- // C D var point = 'no point specified'; if( otherStreamIsHigher && !otherXGreaterThanParent )//A { point = 'A'; x = otherLinkPoint.X; y = otherLinkPoint.Y; height = parentLinkPoint.Y - otherLinkPoint.Y; width = parentLinkPoint.X - otherLinkPoint.X; bottomToTop = false; } else if( otherStreamIsHigher && otherXGreaterThanParent )//B { point = 'B'; x = parentLinkPoint.X; y = otherLinkPoint.Y; height = parentLinkPoint.Y - otherLinkPoint.Y; width = otherLinkPoint.X - parentLinkPoint.X; bottomToTop = true; } else if( !otherStreamIsHigher && !otherXGreaterThanParent )//C { point = 'C'; x = otherLinkPoint.X; y = parentLinkPoint.Y; height = otherLinkPoint.Y - parentLinkPoint.Y; width = parentLinkPoint.X - otherLinkPoint.X; bottomToTop = true; } else if( !otherStreamIsHigher && otherXGreaterThanParent )//D { point = 'D'; x = parentLinkPoint.X; y = parentLinkPoint.Y; height = otherLinkPoint.Y - parentLinkPoint.Y; width = otherLinkPoint.X - parentLinkPoint.X; bottomToTop = false; } //console.log('DrawLinkToChild stream: ' + streamNode.stream + ' other: ' + otherStreamNode.stream.mName + ' x: ' + x + ' y: ' + y + ' width: ' + width + ' heigth: ' + height); //if( mSameRow ) // height = height/2; var linkCanvas = document.createElement( "canvas" ); linkCanvas.style.position = "absolute"; document.getElementById( "streamGraph" ).appendChild( linkCanvas ); linkCanvas.style.left = x; linkCanvas.style.top = y; linkCanvas.width = width; linkCanvas.height = height; var color = streamNode.highlightColor; var zIndex = -2; if( streamNode.selected ) { color = streamNode.selectionColor; zIndex = -1; } if( streamNode.stream.mParent != otherStreamNode.stream.mStream && otherStreamNode.stream.mParent != streamNode.stream.mStream ) color = new mStreamUtilities.StreamColor(240, 128, 128, 1); color = new mStreamUtilities.StreamColor(color.r, color.g , color.b, .5);//make colors translucent for trajectory lines; it's easier to read //streamNode.DrawChangeNumber(arrowPoint, changeList, otherStreamIsHigher); //console.log( 'changeListNum: ' + changeListNum + ' arrowPoint x: ' + arrowPoint.x + ' y: ' + arrowPoint ); this.draw = function(horizontal) { if( mSameRow ) mStreamUtilities.DrawHorizontalColorBezier(linkCanvas, color, mStreamUtilities.CurveDirection.uShaped, mStreamUtilities.LinkThickness.thick, zIndex, mStreamUtilities.ArrowDirection.top) else mStreamUtilities.DrawColorBezier(linkCanvas, color, bottomToTop, arrowDirection, mStreamUtilities.LinkThickness.thick, zIndex, streamNode.shapeCanvas, horizontal); } this.close = function() { linkCanvas.parentElement.removeChild(linkCanvas); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 8125 | David George | Added handling for change trajectories that drive through the hedges and live in the same row. | ||
#1 | 8081 | David George |
Initial submit of JavaScript StreamGraph. Main functionality is: Change Trajectory (Change Flow), Timeline, and GitStreams. |