public void NodeShapeChange() { // Setup string filePath = Path.Combine(this.TestContext.TestDir, "Out\\Dots", "chat.dot"); GeometryGraph graph = this.LoadGraph(filePath); var settings = new SugiyamaLayoutSettings(); // Initial layout LayeredLayout layeredLayout = new LayeredLayout(graph, settings); layeredLayout.Run(); SortedList <double, SortedList <double, Node> > originalLayers = SugiyamaValidation.GetLayers(graph, true); // Incremental layout List <Node> nodes = graph.Nodes.ToList(); for (int i = 0; i < nodes.Count; i++) { // Resize a node Node node = nodes[i]; node.BoundaryCurve = node.BoundaryCurve.ScaleFromOrigin(2.0, 2.0); // Run incremental layout LayeredLayout.IncrementalLayout(graph, node); // Verify - the layering and ordering of nodes should not have changed. SortedList <double, SortedList <double, Node> > newLayers = SugiyamaValidation.GetLayers(graph, true); VerifyLayersAreEqual(originalLayers, newLayers); } }
static void ProcessDotFile(GViewer gviewer, ArgsParser.ArgsParser argsParser, string dotFileName) { int line; int col; string msg; Graph graph = Parser.Parse(dotFileName, out line, out col, out msg); if (graph == null) { System.Diagnostics.Debug.WriteLine("{0}({1},{2}): error: {3}", dotFileName, line, col, msg); Environment.Exit(1); } if (argsParser.OptionIsUsed(RecoverSugiyamaTestOption)) { gviewer.CalculateLayout(graph); graph.GeometryGraph.AlgorithmData = null; LayeredLayout.RecoverAlgorithmData(graph.GeometryGraph); Node node = graph.GeometryGraph.Nodes[1]; node.BoundaryCurve = node.BoundaryCurve.Transform(new PlaneTransformation(3, 0, 0, 0, 3, 0)); LayeredLayout.IncrementalLayout(graph.GeometryGraph, node); gviewer.NeedToCalculateLayout = false; gviewer.Graph = graph; gviewer.NeedToCalculateLayout = true; return; } if (argsParser.OptionIsUsed(MdsOption)) { graph.LayoutAlgorithmSettings = gviewer.mdsLayoutSettings; } else if (argsParser.OptionIsUsed(FdOption)) { graph.LayoutAlgorithmSettings = new FastIncrementalLayoutSettings(); } if (argsParser.OptionIsUsed(BundlingOption)) { graph.LayoutAlgorithmSettings.EdgeRoutingSettings.EdgeRoutingMode = EdgeRoutingMode.SplineBundling; BundlingSettings bs = GetBundlingSettings(argsParser); graph.LayoutAlgorithmSettings.EdgeRoutingSettings.BundlingSettings = bs; string ink = argsParser.GetStringOptionValue(InkImportanceOption); if (ink != null) { double inkCoeff; if (double.TryParse(ink, out inkCoeff)) { bs.InkImportance = inkCoeff; BundlingSettings.DefaultInkImportance = inkCoeff; } else { System.Diagnostics.Debug.WriteLine("cannot parse {0}", ink); Environment.Exit(1); } } string esString = argsParser.GetStringOptionValue(EdgeSeparationOption); if (esString != null) { double es; if (double.TryParse(esString, out es)) { BundlingSettings.DefaultEdgeSeparation = es; bs.EdgeSeparation = es; } else { System.Diagnostics.Debug.WriteLine("cannot parse {0}", esString); Environment.Exit(1); } } } gviewer.Graph = graph; string svgout = argsParser.GetStringOptionValue(SvgFileNameOption); try { if (svgout != null) { SvgGraphWriter.Write(gviewer.Graph, svgout, null, null, 4); } } catch (Exception e) { Console.WriteLine(e.Message); } }