TestConstructor() { // Has CombinedIntergroupEdges. GroupInfo [] aoGroupInfo = new GroupInfo [] { new GroupInfo(), new GroupInfo(), new GroupInfo() }; const Double PenWidth = 1.234; IntergroupEdgeInfo[] aoCombinedIntergroupEdges = new IntergroupEdgeInfo[5]; GroupLayoutDrawingInfo oGroupLayoutDrawingInfo = new GroupLayoutDrawingInfo(aoGroupInfo, PenWidth, aoCombinedIntergroupEdges); Assert.AreEqual(aoGroupInfo, oGroupLayoutDrawingInfo.GroupsToDraw); Assert.AreEqual(PenWidth, oGroupLayoutDrawingInfo.PenWidth); Assert.AreEqual(aoCombinedIntergroupEdges, oGroupLayoutDrawingInfo.CombinedIntergroupEdges); }
GetEdgeWeightSum ( IList <IntergroupEdgeInfo> oIntergroupEdges, Int32 iGroup1Index, Int32 iGroup2Index ) { IntergroupEdgeInfo oIntergroupEdgeInfo = GetIntergroupEdgeInfo( oIntergroupEdges, iGroup1Index, iGroup2Index); return(oIntergroupEdgeInfo.EdgeWeightSum); }
GetEdgeCount ( IList <IntergroupEdgeInfo> oIntergroupEdges, Int32 iGroup1Index, Int32 iGroup2Index ) { IntergroupEdgeInfo oIntergroupEdgeInfo = GetIntergroupEdgeInfo( oIntergroupEdges, iGroup1Index, iGroup2Index); return(oIntergroupEdgeInfo.Edges); }
GetCombinedIntergroupEdgePenWidth ( IntergroupEdgeInfo oCombinedIntergroupEdge ) { Debug.Assert(oCombinedIntergroupEdge != null); AssertValid(); return(MathUtil.TransformValueToRange( (Single)oCombinedIntergroupEdge.EdgeWeightSum, CombinedIntergroupEdgeMinimumCount, CombinedIntergroupEdgeMaximumCount, CombinedIntergroupEdgeMinimumWidth, CombinedIntergroupEdgeMaximumWidth )); }
TestConstructor() { const Int32 Group1Index = 0; const Int32 Group2Index = 12; const Int32 Edges = 1; const Double EdgeWeightSum = 1.234; IntergroupEdgeInfo oIntergroupEdgeInfo = new IntergroupEdgeInfo(Group1Index, Group2Index, Edges, EdgeWeightSum); Assert.AreEqual(Group1Index, oIntergroupEdgeInfo.Group1Index); Assert.AreEqual(Group2Index, oIntergroupEdgeInfo.Group2Index); Assert.AreEqual(Edges, oIntergroupEdgeInfo.Edges); Assert.AreEqual(EdgeWeightSum, oIntergroupEdgeInfo.EdgeWeightSum); oIntergroupEdgeInfo.Edges++; Assert.AreEqual(Edges + 1, oIntergroupEdgeInfo.Edges); }
CountIncidentEdge ( IEdge oIntergroupEdge, Int32 iGroup1Index, Int32 iGroup2Index, IList <IntergroupEdgeInfo> oIntergroupEdges, Dictionary <Int32, IntergroupEdgeInfo> oIntergroupEdgeIndexes ) { Debug.Assert(oIntergroupEdge != null); Debug.Assert(iGroup1Index >= 0); Debug.Assert(iGroup2Index >= 0); Debug.Assert(oIntergroupEdges != null); Debug.Assert(oIntergroupEdgeIndexes != null); AssertValid(); Double dPositiveEdgeWeight = EdgeUtil.GetPositiveEdgeWeight( oIntergroupEdge); // Does an object already exist for the iGroup1Index/iGroup2Index pair? IntergroupEdgeInfo oIntergroupEdgeInfo; if (oIntergroupEdgeIndexes.TryGetValue(iGroup2Index, out oIntergroupEdgeInfo)) { // Yes. oIntergroupEdgeInfo.Edges++; oIntergroupEdgeInfo.EdgeWeightSum += dPositiveEdgeWeight; } else { // No. Create one. oIntergroupEdgeInfo = new IntergroupEdgeInfo( iGroup1Index, iGroup2Index, 1, dPositiveEdgeWeight); oIntergroupEdges.Add(oIntergroupEdgeInfo); oIntergroupEdgeIndexes.Add(iGroup2Index, oIntergroupEdgeInfo); } }
CompareIntergroupEdges ( IntergroupEdgeInfo oIntergroupEdge1, IntergroupEdgeInfo oIntergroupEdge2 ) { Debug.Assert(oIntergroupEdge1 != null); Debug.Assert(oIntergroupEdge2 != null); // Sort first by Group1Index, then Group2Index. Int32 iReturnValue = oIntergroupEdge1.Group1Index.CompareTo( oIntergroupEdge2.Group1Index); if (iReturnValue == 0) { iReturnValue = oIntergroupEdge1.Group2Index.CompareTo( oIntergroupEdge2.Group2Index); } return(iReturnValue); }
DrawCombinedIntergroupEdge ( DrawingContext oDrawingContext, GraphDrawingContext oGraphDrawingContext, IntergroupEdgeInfo oCombinedIntergroupEdge, GroupLayoutDrawingInfo oGroupLayoutDrawingInfo ) { Debug.Assert(oDrawingContext != null); Debug.Assert(oGraphDrawingContext != null); Debug.Assert(oCombinedIntergroupEdge != null); Debug.Assert(oGroupLayoutDrawingInfo != null); AssertValid(); Rect oGroupRectangle1, oGroupRectangle2; if ( !TryGetGroupRectangle( oGroupLayoutDrawingInfo.GroupsToDraw[ oCombinedIntergroupEdge.Group1Index], out oGroupRectangle1) || !TryGetGroupRectangle( oGroupLayoutDrawingInfo.GroupsToDraw[ oCombinedIntergroupEdge.Group2Index], out oGroupRectangle2) ) { return; } Point oGroupRectangle1Center = WpfGraphicsUtil.GetRectCenter(oGroupRectangle1); Point oGroupRectangle2Center = WpfGraphicsUtil.GetRectCenter(oGroupRectangle2); Point oBezierControlPoint = GetBezierControlPoint(oGraphDrawingContext, oGroupRectangle1Center, oGroupRectangle2Center, CombinedIntergroupEdgeBezierDisplacementFactor ); PathGeometry oBezierCurve = WpfPathGeometryUtil.GetQuadraticBezierCurve(oGroupRectangle1Center, oGroupRectangle2Center, oBezierControlPoint); Color oColor = GetContrastingColor( oGraphDrawingContext, CombinedIntergroupEdgeAlpha, true); Pen oPen = CreateFrozenPen(CreateFrozenSolidColorBrush(oColor), GetCombinedIntergroupEdgePenWidth(oCombinedIntergroupEdge) * this.GraphScale, DashStyles.Solid, PenLineCap.Round); oDrawingContext.DrawGeometry(null, oPen, oBezierCurve); }