/// <summary> /// Removes node overlap occurring in the input graph /// </summary> /// <param name="graph">GraphMapData</param> public static void FSAOverlapRemoval(GraphMapData graph) { ICollection<NodeMapData> nodes = graph.GetNodes(); IDictionary<string, Rect> rectangles = new Dictionary<string, Rect>(nodes.Count); foreach (NodeMapData node in nodes) { Point location = new Point(node.Position.X, node.Position.Y); Rect rect = new Rect(location, node.Dimension); rectangles[node.Id] = rect; } OverlapRemovalParameters overlapRemovalParameters = new OverlapRemovalParameters() { HorizontalGap = 0F, VerticalGap = 0F }; FSAAlgorithm<string> overlapRemoval = new FSAAlgorithm<string>(rectangles, overlapRemovalParameters); overlapRemoval.Compute(); foreach (NodeMapData node in nodes) { Rect rect = overlapRemoval.Rectangles[node.Id]; Point pos = new Point(rect.X, rect.Y); node.Position = pos; } }
private void ComputerOverlapRemoval() { //Overlap Param OverlapRemovalParameters orp = new OverlapRemovalParameters(); orp.VerticalGap = 2; orp.HorizontalGap = 2; //Get Rect for Each Vertex Dictionary<FlockVertex, Rect> rectangles = new Dictionary<FlockVertex, Rect>(); for (int i = 0; i < directed.VertexCount; i++) { FlockVertex v = directed.Vertices.ElementAt(i); rectangles.Add(v, v.FlockRect); } try { FSAAlgorithm<FlockVertex> ora = new FSAAlgorithm<FlockVertex>(rectangles, orp); ora.Compute(); //Update New Rect Postions for (int i = 0; i < ora.Rectangles.Count; i++) { FlockVertex v = directed.Vertices.ElementAt(i); v.FlockRect = ora.Rectangles.ElementAt(i).Value; v.FlockPoint = new Point(v.FlockRect.X, v.FlockRect.Y); } } catch (Exception ex) { Debug.WriteLine(string.Format("Error at Overlap: {0}. {1}", ex.Message, ex.StackTrace)); } }