/// <summary> /// positions location nodes /// </summary> /// <param name="locationNodes">the nodes represent the labels and originally are positioned at locations</param> /// <param name="locationRadius">the minimum gap between a location and its label</param> /// <param name="removeCrossings">If set to true will remove intersections between line segments (location, locationLabel). /// The result will be better but the calculation will take more time. /// </param> public static GeometryGraph PositionLabels(Node[] locationNodes, double locationRadius, bool routeEdges, double labelSeparation) { #if TEST_MSAGL Microsoft.Msagl.GraphViewerGdi.DisplayGeometryGraph.SetShowFunctions(); #endif var labeler = new LocationLabeler(locationNodes, locationRadius, routeEdges, labelSeparation); labeler.Work(); return(labeler.graph); }
/// <summary> /// positions location nodes /// </summary> /// <param name="locationNodes">the nodes represent the labels and originally are positioned at locations</param> /// <param name="locationRadius">the minimum gap between a location and its label</param> /// <param name="removeCrossings">If set to true will remove intersections between line segments (location, locationLabel). /// The result will be better but the calculation will take more time. /// </param> public static GeometryGraph PositionLabels(Node[] locationNodes, double locationRadius, bool routeEdges, double labelSeparation) { #if MYDEBUG Microsoft.Msagl.GraphViewerGdi.DisplayGeometryGraph.SetShowFunctions(); #endif var labeler = new LocationLabeler(locationNodes, locationRadius, routeEdges, labelSeparation); labeler.Work(); return labeler.graph; }
public Form1() { InitializeComponent(); Node n0 = new Node(CurveFactory.CreateEllipse(10, 10, new Microsoft.Msagl.Core.Geometry.Point()), "a"); Microsoft.Msagl.Core.Geometry.Point n1Center = new Microsoft.Msagl.Core.Geometry.Point(20, 0); Node n1 = new Node(CurveFactory.CreateEllipse(10, 10, n1Center), "b"); n1.Center = n1Center; Microsoft.Msagl.Core.Geometry.Point n2Center = new Microsoft.Msagl.Core.Geometry.Point(5, 3); Node n2 = new Node(CurveFactory.CreateEllipse(10, 10, n2Center), "c"); n2.Center = n2Center; Microsoft.Msagl.Core.Geometry.Point n3Center = new Microsoft.Msagl.Core.Geometry.Point(8, -1); Node n3 = new Node(CurveFactory.CreateEllipse(10, 10, n3Center), "d"); n3.Center = n3Center; Microsoft.Msagl.Core.Geometry.Point n4Center = new Microsoft.Msagl.Core.Geometry.Point(6, -4); Node n4 = new Node(CurveFactory.CreateEllipse(10, 10, n4Center), "e"); n4.Center = n4Center; Microsoft.Msagl.Core.Geometry.Point n5Center = new Microsoft.Msagl.Core.Geometry.Point(19, -3); Node n5 = new Node(CurveFactory.CreateEllipse(10, 10, n5Center), "f"); n5.Center = n5Center; IncrementalLabeler il = new IncrementalLabeler(6, false, -1); #if TEST_MSAGL Microsoft.Msagl.GraphViewerGdi.DisplayGeometryGraph.SetShowFunctions(); #endif il.AddNode(n0); il.AddNode(n1); il.Layout(); il.AddNode(n2); il.AddNode(n3); il.Layout(); GeometryGraph graph = LocationLabeler.PositionLabels(new[] { n0, n1, n2, n3, n4, n5 }, 5, false, -1); // var g=GeometryGraph.CreateFromFile("c:/tmp/graph"); // ChangeShapes(g); // var graph = LocationLabeler.PositionLabels( g.Nodes , 6, false, -6); }