void GraphLayoutCalculation() { try { var gv = new GViewer(); gv.CurrentLayoutMethod = this.GViewer.CurrentLayoutMethod; object res = gv.CalculateLayout(generatedGraph); double ar = generatedGraph.GeometryGraph.BoundingBox.Width / generatedGraph.GeometryGraph.BoundingBox.Height; if (ar > 5) { Console.WriteLine("ar={0}", ar); } //update the dotviewer if (InvokeRequired) { Invoke(new VoidFunctionWithOneParameterDelegate(UpdateViewer), new[] { res }); } else { UpdateViewer(res); } } catch (Exception e) { //if it is thread abort exception then just ignore it if (!(e is ThreadAbortException)) { } } }
private void Analyze(string dll) { if (!string.IsNullOrEmpty(dll)) { toolStripStatusLabel1.Text = dll; var graph = new Graph("glee"); richTextBox1.Clear(); richTextBox2.Clear(); foreach (string relation in _references) { if (relation.StartsWith(dll)) { string[] strs = relation.Split(','); graph.AddEdge(strs[0], strs[1]).Attr.Color = Microsoft.Glee.Drawing.Color.DarkBlue; richTextBox1.AppendText(strs[1] + "\n"); graph.FindNode(strs[1]).Attr.Fillcolor = Microsoft.Glee.Drawing.Color.Blue; } else if (relation.EndsWith(dll)) { string[] strs = relation.Split(','); graph.AddEdge(strs[0], strs[1]).Attr.Color = Microsoft.Glee.Drawing.Color.DarkRed; richTextBox2.AppendText(strs[0] + "\n"); graph.FindNode(strs[0]).Attr.Fillcolor = Microsoft.Glee.Drawing.Color.Red; } } var node = graph.FindNode(dll); if (node != null) { node.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.Green; } _viewer.Graph = graph; _viewer.CalculateLayout(graph); } }
private void Calculate_graph_btn_Click(object sender, EventArgs e) { var form = new Form(); var viewer = new GViewer(); var graph = GenerateGraph(); if (graph == default) { return; } viewer.Graph = graph; form.SuspendLayout(); viewer.CalculateLayout(graph); viewer.Dock = DockStyle.Fill; form.Controls.Add(viewer); form.ResumeLayout(); form.ShowDialog(); }
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); } }