Пример #1
0
        private static ILayout ChooseLayout(GraphLayoutType s)
        {
            EdgeDrawer ed = new EdgeDrawer();

            gd.EdgeDrawer = ed;
            ed.Color      = Color.Red;
            VertexDrawer vd = new VertexDrawer();

            gd.VertexDrawer = vd;
            vd.Shape        = VertexDrawer.VertexShape.Disk;
            ILayout fr = new FruchtermanReingoldLayout();

            switch (s)
            {
            case GraphLayoutType.Fruchterman_Reingold:
                fr = new FruchtermanReingoldLayout();
                break;

            case GraphLayoutType.Random:
                fr = new RandomLayout();
                break;

            case GraphLayoutType.Circle:
                fr = new CircleLayout();
                break;

            case GraphLayoutType.Kamada_Kawaii:
                fr = new KamadaKawaiiLayout();
                break;

            case GraphLayoutType.Grid:
                fr = new GridLayout();
                break;

            case GraphLayoutType.Sugiyama:
                SugiyamaEdgeDrawer eds = new SugiyamaEdgeDrawer();
                gd.EdgeDrawer = eds;
                eds.Color     = Color.Red;
                SugiyamaVertexDrawer vds = new SugiyamaVertexDrawer();
                gd.VertexDrawer = vds;
                vds.Shape       = VertexDrawer.VertexShape.Sphere;
                fr = new SugiyamaLayout();
                break;
            }
            return(fr);
        }
Пример #2
0
 /// <summary>
 /// Méthode statique de Layout
 /// </summary>
 /// <param name="graphe">Graphe entrée</param>
 /// <param name="rectangle">Zone de dessin</param>
 /// <param name="layout">Type de layout</param>
 /// <returns>Le graphe repositionné</returns>
 public static Graph LayoutGraph(Graph graphe, Rectangle rectangle, GraphLayoutType layout)
 {
     Microsoft.Chung.Core.Graph mcg = new Microsoft.Chung.Core.Graph();
     #region Copy the graph
     foreach (Noeud n in graphe.Noeuds)
     {
         if (!n.Supprimé)
         {
             Microsoft.Chung.Core.Vertex v = new Microsoft.Chung.Core.Vertex();
             v.SetValue("ID", n.ID);
             v.Name = n.Texte;
             mcg.Vertices.Add(v);
         }
     }
     foreach (Trait e in graphe.Traits)
     {
         Microsoft.Chung.Core.IVertex vs;
         Microsoft.Chung.Core.IVertex vt;
         mcg.Vertices.Find(e.Source.Texte, out vs);
         mcg.Vertices.Find(e.Destination.Texte, out vt);
         if ((vs != null) && (vt != null))
         {
             Microsoft.Chung.Core.Edge mce = new Microsoft.Chung.Core.Edge(vs, vt, true);
             mcg.Edges.Add(mce);
         }
     }
     #endregion
     ILayout fr = ChooseLayout(layout);
     rectangle = new Rectangle(100, 100, rectangle.Width - 150, rectangle.Height - 150);
     LayoutContext t = new LayoutContext(rectangle, gd);
     fr.LayOutGraph(mcg, t);
     gd.Layout = fr;
     #region Update initialgraph
     foreach (Noeud n in graphe.Noeuds)
     {
         lock (graphe)
         {
             Microsoft.Chung.Core.IVertex vs;
             mcg.Vertices.Find(n.Texte, out vs);
             n.Déplace(new Point((int)vs.Location.X, (int)vs.Location.Y));
         }
     }
     #endregion
     return(graphe);
 }
        private void SetupGraphTabs(int numberOfBenchmarks, int clientsPerGraph)
        {
            int graphs = 1;

            if (GraphLayoutType.Equals(GraphLayoutType.ClientsPerGraph))
            {
                graphs = (int)Math.Ceiling(numberOfBenchmarks / (double)clientsPerGraph);
                if (graphs == 0)
                {
                    graphs = 1;
                }
            }

            if (graphs > _currentNumberOfGraphs)
            {
                for (int i = _currentNumberOfGraphs + 1; i <= graphs; i++)
                {
                    tabControl1.TabPages.Add("tabGraphFrameTime" + i, "Graph - Frame Time (" + i + ")");
                    var zgFrameTime = new ZedGraphControl();
                    zgFrameTime.Name = "zgFrameTime" + i;
                    zgFrameTime.Dock = DockStyle.Fill;
                    tabControl1.TabPages[tabControl1.TabPages.Count - 1].Controls.Add(zgFrameTime);

                    tabControl1.TabPages.Add("tabGraphPPD" + i, "Graph - PPD (" + i + ")");
                    var zgPpd = new ZedGraphControl();
                    zgPpd.Name = "zgPpd" + i;
                    zgPpd.Dock = DockStyle.Fill;
                    tabControl1.TabPages[tabControl1.TabPages.Count - 1].Controls.Add(zgPpd);
                }
            }
            else if (graphs < _currentNumberOfGraphs)
            {
                for (int i = _currentNumberOfGraphs; i > graphs; i--)
                {
                    tabControl1.TabPages.RemoveByKey("tabGraphFrameTime" + i);
                    tabControl1.TabPages.RemoveByKey("tabGraphPPD" + i);
                }
            }

            _currentNumberOfGraphs = graphs;
        }
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            txtBenchmarks.Text = String.Empty;
            int     projectId = (int)listBox1.SelectedItem;
            Protein protein   = _proteinService.Get(projectId);

            if (protein == null)
            {
                Logger.WarnFormat("Could not find Project {0}.", projectId);
            }

            var projectInfoLines = new List <string>();

            PopulateProteinInformation(protein, projectInfoLines);

            List <ProteinBenchmark> list = _benchmarkService.GetBenchmarks(_currentSlotIdentifier, projectId).ToList();

            list.Sort((benchmark1, benchmark2) => benchmark1.OwningSlotName.CompareTo(benchmark2.OwningSlotName));

            var benchmarkInfoLines = new List <string>(projectInfoLines);

            foreach (ProteinBenchmark benchmark in list)
            {
                UnitInfoModel unitInfoModel = null;
                SlotStatus    status        = SlotStatus.Unknown;

                var slotModel = _clientConfiguration.Slots.FirstOrDefault(x =>
                                                                          x.Name == benchmark.OwningSlotName &&
                                                                          x.Settings.DataPath() == benchmark.OwningClientPath &&
                                                                          x.UnitInfoModel.UnitInfoData.ProjectID == benchmark.ProjectID);
                if (slotModel != null && slotModel.ProductionValuesOk)
                {
                    unitInfoModel = slotModel.UnitInfoModel;
                    status        = slotModel.Status;
                }
                PopulateBenchmarkInformation(protein, benchmark, unitInfoModel, status, _prefs.GetPpdFormatString(), benchmarkInfoLines);
            }

            UpdateBenchmarkText(benchmarkInfoLines);

            tabControl1.SuspendLayout();

            int clientsPerGraph = _prefs.Get <int>(Preference.BenchmarksClientsPerGraph);

            SetupGraphTabs(list.Count, clientsPerGraph);

            int tabIndex = 1;

            if (GraphLayoutType.Equals(GraphLayoutType.ClientsPerGraph))
            {
                int lastDisplayed = 0;
                for (int i = 1; i < list.Count; i++)
                {
                    if (i % clientsPerGraph == 0)
                    {
                        var benchmarks = new ProteinBenchmark[clientsPerGraph];
                        list.CopyTo(lastDisplayed, benchmarks, 0, clientsPerGraph);
                        DrawGraphs(tabIndex, projectInfoLines, benchmarks, protein);
                        tabIndex++;
                        lastDisplayed = i;
                    }
                }

                if (lastDisplayed < list.Count)
                {
                    var benchmarks = new ProteinBenchmark[list.Count - lastDisplayed];
                    list.CopyTo(lastDisplayed, benchmarks, 0, list.Count - lastDisplayed);
                    DrawGraphs(tabIndex, projectInfoLines, benchmarks, protein);
                }
            }
            else
            {
                DrawGraphs(tabIndex, projectInfoLines, list, protein);
            }

            tabControl1.ResumeLayout(true);
        }
Пример #5
0
 private static ILayout ChooseLayout(GraphLayoutType s)
 {
     EdgeDrawer ed = new EdgeDrawer();
     gd.EdgeDrawer = ed;
     ed.Color = Color.Red;
     VertexDrawer vd = new VertexDrawer();
     gd.VertexDrawer = vd;
     vd.Shape = VertexDrawer.VertexShape.Disk;
     ILayout fr = new FruchtermanReingoldLayout();
     switch (s)
     {
         case GraphLayoutType.Fruchterman_Reingold:
             fr = new FruchtermanReingoldLayout();
             break;
         case GraphLayoutType.Random:
             fr = new RandomLayout();
             break;
         case GraphLayoutType.Circle:
             fr = new CircleLayout();
             break;
         case GraphLayoutType.Kamada_Kawaii:
             fr = new KamadaKawaiiLayout();
             break;
         case GraphLayoutType.Grid:
             fr = new GridLayout();
             break;
         case GraphLayoutType.Sugiyama:
             SugiyamaEdgeDrawer eds = new SugiyamaEdgeDrawer();
             gd.EdgeDrawer = eds;
             eds.Color = Color.Red;
             SugiyamaVertexDrawer vds = new SugiyamaVertexDrawer();
             gd.VertexDrawer = vds;
             vds.Shape = VertexDrawer.VertexShape.Sphere;
             fr = new SugiyamaLayout();
             break;
     }
     return fr;
 }
Пример #6
0
 /// <summary>
 /// Méthode statique de Layout
 /// </summary>
 /// <param name="graphe">Graphe entrée</param>
 /// <param name="rectangle">Zone de dessin</param>
 /// <param name="layout">Type de layout</param>
 /// <returns>Le graphe repositionné</returns>
 public static Graph LayoutGraph(Graph graphe, Rectangle rectangle, GraphLayoutType layout)
 {
     Microsoft.Chung.Core.Graph mcg = new Microsoft.Chung.Core.Graph();
     #region Copy the graph
     foreach (Noeud n in graphe.Noeuds)
     {
         if (!n.Supprimé)
         {
             Microsoft.Chung.Core.Vertex v = new Microsoft.Chung.Core.Vertex();
             v.SetValue("ID", n.ID);
             v.Name = n.Texte;
             mcg.Vertices.Add(v);
         }
     }
     foreach (Trait e in graphe.Traits)
     {
         Microsoft.Chung.Core.IVertex vs;
         Microsoft.Chung.Core.IVertex vt;
         mcg.Vertices.Find(e.Source.Texte, out vs);
         mcg.Vertices.Find(e.Destination.Texte, out  vt);
         if ((vs != null) && (vt != null))
         {
             Microsoft.Chung.Core.Edge mce = new Microsoft.Chung.Core.Edge(vs, vt, true);
             mcg.Edges.Add(mce);
         }
     }
     #endregion
     ILayout fr = ChooseLayout(layout);
     rectangle = new Rectangle(100, 100, rectangle.Width - 150, rectangle.Height - 150);
     LayoutContext t = new LayoutContext(rectangle, gd);
     fr.LayOutGraph(mcg, t);
     gd.Layout = fr;
     #region Update initialgraph
     foreach (Noeud n in graphe.Noeuds)
     {
         lock (graphe)
         {
             Microsoft.Chung.Core.IVertex vs;
             mcg.Vertices.Find(n.Texte, out vs);
             n.Déplace(new Point((int)vs.Location.X, (int)vs.Location.Y));
         }
     }
     #endregion
     return graphe;
 }