Exemplo n.º 1
0
 private void gg_useExternalERAlgo_Checked(object sender, RoutedEventArgs e)
 {
     if (gg_useExternalERAlgo.IsChecked == true)
     {
         var graph = gg_Area.LogicCore.Graph ?? ShowcaseHelper.GenerateDataGraph(Convert.ToInt32(gg_vertexCount.Text));
         gg_Area.LogicCore.Graph = graph;
         gg_Area.GetLogicCore <LogicCoreExample>().ExternalEdgeRoutingAlgorithm = gg_Area.LogicCore.AlgorithmFactory.CreateEdgeRoutingAlgorithm(EdgeRoutingAlgorithmTypeEnum.SimpleER, new Rect(gg_Area.DesiredSize.ToGraphX()), graph, null, null);
     }
     else
     {
         gg_Area.GetLogicCore <LogicCoreExample>().ExternalEdgeRoutingAlgorithm = null;
     }
 }
Exemplo n.º 2
0
 private void gg_useExternalLayAlgo_Checked(object sender, RoutedEventArgs e)
 {
     if (gg_useExternalLayAlgo.IsChecked == true)
     {
         var graph = gg_Area.LogicCore.Graph ?? ShowcaseHelper.GenerateDataGraph(Convert.ToInt32(gg_vertexCount.Text));
         gg_Area.LogicCore.Graph = graph;
         AssignExternalLayoutAlgorithm(graph);
     }
     else
     {
         gg_Area.LogicCore.ExternalLayoutAlgorithm = null;
     }
 }
Exemplo n.º 3
0
        private void GenerateGraph()
        {
            var logicCore = new LogicCoreExample()
            {
                Graph = ShowcaseHelper.GenerateDataGraph(3, false)
            };
            var vList = logicCore.Graph.Vertices.ToList();

            //add edges
            ShowcaseHelper.AddEdge(logicCore.Graph, vList[0], vList[1]);
            ShowcaseHelper.AddEdge(logicCore.Graph, vList[1], vList[0]);

            ShowcaseHelper.AddEdge(logicCore.Graph, vList[1], vList[2]);
            ShowcaseHelper.AddEdge(logicCore.Graph, vList[1], vList[2]);
            ShowcaseHelper.AddEdge(logicCore.Graph, vList[2], vList[1]);

            graphArea.LogicCore = logicCore;
            //set positions
            var posList = new Dictionary <DataVertex, Point>()
            {
                { vList[0], new Point(0, -150) },
                { vList[1], new Point(300, 0) },
                { vList[2], new Point(600, -150) },
            };

            //settings
            graphArea.LogicCore.EnableParallelEdges         = true;
            graphArea.LogicCore.EdgeCurvingEnabled          = true;
            graphArea.LogicCore.ParallelEdgeDistance        = _edgeDistance;
            graphArea.LogicCore.DefaultEdgeRoutingAlgorithm = EdgeRoutingAlgorithmTypeEnum.SimpleER;
            //preload graph
            graphArea.PreloadGraph(posList);
            //behaviors
            graphArea.SetVerticesDrag(true, true);
            graphArea.ShowAllEdgesLabels();
            graphArea.AlignAllEdgesLabels();
            zoomControl.MaxZoom = 50;
            //manual edge corrections
            var eList = graphArea.EdgesList.Values.ToList();

            eList[0].LabelVerticalOffset = 12;
            eList[1].LabelVerticalOffset = 12;

            eList[2].ShowLabel           = false;
            eList[3].LabelVerticalOffset = 12;
            eList[4].LabelVerticalOffset = 12;

            //PS: to see how parallel edges logic works go to GraphArea::UpdateParallelEdgesData() method

            zoomControl.ZoomToFill();
        }
Exemplo n.º 4
0
        void butVCP_Click(object sender, RoutedEventArgs e)
        {
            CreateNewArea();
            dg_Area.VertexList.Values.ToList().ForEach(a => a.SetConnectionPointsVisibility(true));
            dg_Area.LogicCore.Graph = ShowcaseHelper.GenerateDataGraph(6, false);
            var vlist = dg_Area.LogicCore.Graph.Vertices.ToList();
            var edge  = new DataEdge(vlist[0], vlist[1])
            {
                SourceConnectionPointId = 1, TargetConnectionPointId = 1
            };

            dg_Area.LogicCore.Graph.AddEdge(edge);
            edge = new DataEdge(vlist[0], vlist[0])
            {
                SourceConnectionPointId = 1, TargetConnectionPointId = 1
            };
            dg_Area.LogicCore.Graph.AddEdge(edge);



            dg_Area.LogicCore.DefaultLayoutAlgorithm               = LayoutAlgorithmTypeEnum.ISOM;
            dg_Area.LogicCore.DefaultOverlapRemovalAlgorithm       = OverlapRemovalAlgorithmTypeEnum.FSA;
            dg_Area.LogicCore.DefaultOverlapRemovalAlgorithmParams = dg_Area.LogicCore.AlgorithmFactory.CreateOverlapRemovalParameters(OverlapRemovalAlgorithmTypeEnum.FSA);
            ((OverlapRemovalParameters)dg_Area.LogicCore.DefaultOverlapRemovalAlgorithmParams).HorizontalGap = 50;
            ((OverlapRemovalParameters)dg_Area.LogicCore.DefaultOverlapRemovalAlgorithmParams).VerticalGap   = 50;
            dg_Area.LogicCore.DefaultEdgeRoutingAlgorithm = EdgeRoutingAlgorithmTypeEnum.None;

            dg_Area.GenerateGraph(true);
            var vertex = dg_Area.VertexList[edge.Target];

            var newVcp = new StaticVertexConnectionPoint {
                Id = 5, Margin = new Thickness(2, 0, 0, 0)
            };
            var cc = new Border
            {
                Margin  = new Thickness(2, 0, 0, 0),
                Padding = new Thickness(0),
                Child   = newVcp
            };

            edge.TargetConnectionPointId = 5;
            vertex.VCPRoot.Children.Add(cc);
            vertex.VertexConnectionPointsList.Add(newVcp);

            dg_Area.EdgesList[edge].UpdateEdge();
            dg_Area.UpdateAllEdges(true);
        }
Exemplo n.º 5
0
        private void GenerateGraph()
        {
            graphArea.LogicCore = new LogicCoreExample
            {
                Graph = ShowcaseHelper.GenerateDataGraph(30),
                EdgeCurvingEnabled          = true,
                DefaultEdgeRoutingAlgorithm = EdgeRoutingAlgorithmTypeEnum.SimpleER,
                DefaultLayoutAlgorithm      = LayoutAlgorithmTypeEnum.SimpleRandom
            };
            graphArea.LogicCore.Graph.Vertices.ToList().ForEach(a => a.IsBlue = Convert.ToBoolean(ShowcaseHelper.Rand.Next(2)));

            //settings
            //gen graph
            graphArea.GenerateGraph();
            //behaviors
            graphArea.SetVerticesDrag(true, true);
            zoomControl.MaxZoom = 50;
            zoomControl.ZoomToFill();
        }
Exemplo n.º 6
0
        void butGeneral_Click(object sender, RoutedEventArgs e)
        {
            CreateNewArea();
            dg_Area.LogicCore.Graph = ShowcaseHelper.GenerateDataGraph(2, false);
            dg_Area.LogicCore.Graph.Vertices.First().IsBlue = true;
            var vlist = dg_Area.LogicCore.Graph.Vertices.ToList();

            //dg_Area.LogicCore.Graph.AddEdge(new DataEdge(vlist[0], vlist[1]) { ArrowTarget = true});
            //dg_Area.LogicCore.Graph.AddEdge(new DataEdge(vlist[0], vlist[2]) { ArrowTarget = true });
            //dg_Area.LogicCore.Graph.AddEdge(new DataEdge(vlist[0], vlist[3]) { ArrowTarget = true });
            //dg_Area.LogicCore.Graph.AddEdge(new DataEdge(vlist[0], vlist[4]) { ArrowTarget = true });


            dg_Area.LogicCore.EdgeCurvingEnabled     = true;
            dg_Area.LogicCore.DefaultLayoutAlgorithm = LayoutAlgorithmTypeEnum.EfficientSugiyama;
            dg_Area.SetVerticesMathShape(VertexShape.Ellipse);
            dg_Area.GenerateGraph(true);

            dg_Area.VertexList.Values.ToList().ForEach(a => a.SetConnectionPointsVisibility(false));
        }
Exemplo n.º 7
0
        private void gg_but_randomgraph_Click(object sender, RoutedEventArgs e)
        {
            gg_Area.ClearLayout();
            var graph = ShowcaseHelper.GenerateDataGraph(Convert.ToInt32(gg_vertexCount.Text));

            graph.AddEdge(new DataEdge(graph.Vertices.First(), graph.Vertices.First()));
            //assign graph again as we need to update Graph param inside and i have no independent examples
            if (gg_Area.LogicCore.ExternalLayoutAlgorithm != null)
            {
                AssignExternalLayoutAlgorithm(graph);
            }

            if (gg_Area.LogicCore.AsyncAlgorithmCompute)
            {
                gg_loader.Visibility = Visibility.Visible;
            }

            //supplied graph will be automaticaly be assigned to GraphArea::LogicCore.Graph property
            gg_Area.GenerateGraph(graph);
        }
Exemplo n.º 8
0
        private void gg_but_randomgraph_Click(object sender, RoutedEventArgs e)
        {
            gg_Area.ClearLayout();
            var          mult = 25;
            GraphExample graph;

            switch (gg_Area.LogicCore.DefaultLayoutAlgorithm)
            {
            case LayoutAlgorithmTypeEnum.LinLog:
                mult  = 45;
                graph = ShowcaseHelper.GenerateDataGraph(Convert.ToInt32(gg_vertexCount.Text), true, mult);
                break;

            case LayoutAlgorithmTypeEnum.EfficientSugiyama:
            case LayoutAlgorithmTypeEnum.Sugiyama:
                graph = ShowcaseHelper.GenerateDataGraph(Convert.ToInt32(gg_vertexCount.Text), true, mult);
                //graph = ShowcaseHelper.GenerateSugiDataGraph();
                break;

            default:
                graph = ShowcaseHelper.GenerateDataGraph(Convert.ToInt32(gg_vertexCount.Text), true, mult);
                break;
            }
            //add self loop
            graph.AddEdge(new DataEdge(graph.Vertices.First(), graph.Vertices.First()));


            //assign graph again as we need to update Graph param inside and i have no independent examples
            if (gg_Area.LogicCore.ExternalLayoutAlgorithm != null)
            {
                AssignExternalLayoutAlgorithm(graph);
            }

            if (gg_Area.LogicCore.AsyncAlgorithmCompute)
            {
                gg_loader.Visibility = Visibility.Visible;
            }

            //supplied graph will be automaticaly be assigned to GraphArea::LogicCore.Graph property
            gg_Area.GenerateGraph(graph);
        }
Exemplo n.º 9
0
        private void GenerateGraph()
        {
            var logicCore = new LogicCoreExample
            {
                Graph = ShowcaseHelper.GenerateDataGraph(6, false)
            };
            var vList = logicCore.Graph.Vertices.ToList();

            //add edges
            ShowcaseHelper.AddEdge(logicCore.Graph, vList[0], vList[1], 3, 2);
            ShowcaseHelper.AddEdge(logicCore.Graph, vList[0], vList[2], 4, 2);

            ShowcaseHelper.AddEdge(logicCore.Graph, vList[1], vList[3], 3, 1);
            ShowcaseHelper.AddEdge(logicCore.Graph, vList[3], vList[5], 2, 3);

            ShowcaseHelper.AddEdge(logicCore.Graph, vList[2], vList[4], 4, 2);
            ShowcaseHelper.AddEdge(logicCore.Graph, vList[4], vList[5], 1, 4);

            ShowcaseHelper.AddEdge(logicCore.Graph, vList[5], vList[1], 1, 4);
            ShowcaseHelper.AddEdge(logicCore.Graph, vList[5], vList[2], 2, 3);

            graphArea.LogicCore = logicCore;
            //set positions
            var posList = new Dictionary <DataVertex, Point>()
            {
                { vList[0], new Point(0, 0) },
                { vList[1], new Point(200, -200) },
                { vList[2], new Point(200, 200) },
                { vList[3], new Point(600, -300) },
                { vList[4], new Point(600, 300) },
                { vList[5], new Point(400, 0) },
            };

            graphArea.PreloadGraph(posList);

            //settings
            graphArea.SetVerticesDrag(true, true);

            zoomControl.ZoomToFill();
        }
Exemplo n.º 10
0
        private void tg_but_randomgraph_Click(object sender, RoutedEventArgs e)
        {
            var graph = ShowcaseHelper.GenerateDataGraph(ShowcaseHelper.Rand.Next(10, 20));

            foreach (var item in graph.Vertices)
            {
                ThemedDataStorage.FillDataVertex(item);
            }
            foreach (var item in graph.Edges)
            {
                item.ToolTipText = string.Format("{0} -> {1}", item.Source.Name, item.Target.Name);
            }

            //TIP: trick to disable zoomcontrol behaviour when it is performing fill animation from top left zoomed corner
            //instead we will fill-animate from maximum zoom distance
            //tg_zoomctrl.Zoom = 0.01; //disable zoom control auto fill animation by setting this value
            tg_Area.GenerateGraph(graph, tg_edgeMode.SelectedIndex == 0);

            if (tg_Area.LogicCore.AsyncAlgorithmCompute)
            {
                tg_loader.Visibility = Visibility.Visible;
            }
        }
Exemplo n.º 11
0
        void butEdgeLabels_Click(object sender, RoutedEventArgs e)
        {
            CreateNewArea();

            dg_Area.ShowAllEdgesLabels(true);
            dg_Area.AlignAllEdgesLabels(true);
            dg_Area.ShowAllEdgesArrows(true);

            dg_Area.LogicCore.Graph = ShowcaseHelper.GenerateDataGraph(2, false);

            var vlist = dg_Area.LogicCore.Graph.Vertices.ToList();
            var edge  = new DataEdge(vlist[0], vlist[1])
            {
                Text = "Testing edge labels..."
            };

            dg_Area.LogicCore.Graph.AddEdge(edge);

            dg_Area.PreloadGraph(new Dictionary <DataVertex, Point> {
                { vlist[0], new Point() }, { vlist[1], new Point(0, 200) }
            });
            dg_Area.VertexList.Values.ToList().ForEach(a => a.SetConnectionPointsVisibility(false));
        }
Exemplo n.º 12
0
        void erg_but_randomgraph_Click(object sender, RoutedEventArgs e)
        {
            if ((EdgeRoutingAlgorithmTypeEnum)erg_eralgo.SelectedItem != EdgeRoutingAlgorithmTypeEnum.Bundling)
            {
                var gr = ShowcaseHelper.GenerateDataGraph(30);

                if (erg_Area.LogicCore.EnableParallelEdges)
                {
                    if (erg_Area.VertexList.Count() < 2)
                    {
                        var v1 = new DataVertex(); gr.AddVertex(v1);
                        var v2 = new DataVertex(); gr.AddVertex(v2);
                        gr.AddEdge(new DataEdge(v1, v2)
                        {
                            Text = string.Format("{0} -> {1}", v1.Text, v2.Text)
                        });
                        gr.AddEdge(new DataEdge(v2, v1)
                        {
                            Text = string.Format("{0} -> {1}", v2.Text, v1.Text)
                        });
                    }
                    else
                    {
                        var v1 = gr.Vertices.ToList()[0];
                        var v2 = gr.Vertices.ToList()[1];
                        gr.AddEdge(new DataEdge(v1, v2)
                        {
                            Text = string.Format("{0} -> {1}", v1.Text, v2.Text)
                        });
                        gr.AddEdge(new DataEdge(v2, v1)
                        {
                            Text = string.Format("{0} -> {1}", v2.Text, v1.Text)
                        });
                    }
                }

                erg_Area.GetLogicCore <LogicCoreExample>().DefaultEdgeRoutingAlgorithm = (EdgeRoutingAlgorithmTypeEnum)erg_eralgo.SelectedItem;
                switch ((EdgeRoutingAlgorithmTypeEnum)erg_eralgo.SelectedItem)
                {
                case EdgeRoutingAlgorithmTypeEnum.SimpleER:
                    erg_Area.GetLogicCore <LogicCoreExample>().DefaultEdgeRoutingAlgorithmParams = SimpleErParameters;
                    break;

                case EdgeRoutingAlgorithmTypeEnum.PathFinder:
                    erg_Area.GetLogicCore <LogicCoreExample>().DefaultEdgeRoutingAlgorithmParams = PfErParameters;
                    break;
                }

                erg_Area.GetLogicCore <LogicCoreExample>().DefaultLayoutAlgorithm               = LayoutAlgorithmTypeEnum.SimpleRandom;
                erg_Area.GetLogicCore <LogicCoreExample>().DefaultOverlapRemovalAlgorithm       = OverlapRemovalAlgorithmTypeEnum.FSA;
                erg_Area.GetLogicCore <LogicCoreExample>().DefaultOverlapRemovalAlgorithmParams = erg_Area.LogicCore.AlgorithmFactory.CreateOverlapRemovalParameters(OverlapRemovalAlgorithmTypeEnum.FSA);

                erg_Area.GenerateGraph(gr, true);
                erg_Area.SetVerticesDrag(true, true);
                erg_zoomctrl.ZoomToFill();

                return;
            }

            erg_Area.RemoveAllEdges();
            erg_Area.RemoveAllVertices();
            //generate graph
            var graph = new GraphExample();

            foreach (var item in ShowcaseHelper.DataSource.Take(120))
            {
                graph.AddVertex(new DataVertex(item.Text)
                {
                    ID = item.ID
                });
            }

            var vlist = graph.Vertices.ToList();

            foreach (var item in vlist)
            {
                if (ShowcaseHelper.Rand.Next(0, 50) > 25)
                {
                    continue;
                }
                var vertex2 = vlist[ShowcaseHelper.Rand.Next(0, graph.VertexCount - 1)];
                graph.AddEdge(new DataEdge(item, vertex2, ShowcaseHelper.Rand.Next(1, 50))
                {
                    ToolTipText = string.Format("{0} -> {1}", item, vertex2)
                });
            }

            //generate vertices

            var vertexPositions = GenerateRandomVertices(graph, 0, 40, 0, 2000, 0, 2000).ToDictionary(item => item.Key, item => item.Value);

            foreach (var item in GenerateRandomVertices(graph, 40, 40, 5000, 7000, 3000, 4000))
            {
                vertexPositions.Add(item.Key, item.Value);
            }
            foreach (var item in GenerateRandomVertices(graph, 80, 40, 500, 2500, 6000, 9000))
            {
                vertexPositions.Add(item.Key, item.Value);
            }
            erg_Area.LogicCore.Graph = graph;
            UpdateLayout();

            erg_Area.SetVerticesDrag(true);
            _logicCore.DefaultLayoutAlgorithm            = LayoutAlgorithmTypeEnum.Custom;
            _logicCore.DefaultEdgeRoutingAlgorithm       = EdgeRoutingAlgorithmTypeEnum.Bundling;
            _logicCore.DefaultEdgeRoutingAlgorithmParams = BundleEdgeRoutingParameters;
            erg_Area.GenerateGraph(true);

            erg_zoomctrl.ZoomToFill();
        }
Exemplo n.º 13
0
        void butGroupedGraph_Click(object sender, RoutedEventArgs e)
        {
            CreateNewArea();
            dg_Area.LogicCore.Graph = ShowcaseHelper.GenerateDataGraph(10, true);
            dg_Area.LogicCore.Graph.Vertices.Take(5).ForEach(a => a.GroupId = 1);
            dg_Area.LogicCore.Graph.Vertices.Where(a => a.GroupId == 0).ForEach(a => a.GroupId = 2);
            dg_Area.LogicCore.DefaultOverlapRemovalAlgorithm = OverlapRemovalAlgorithmTypeEnum.None;
            //generate group params
            var prms = new List <AlgorithmGroupParameters <DataVertex, DataEdge> >
            {
                new AlgorithmGroupParameters <DataVertex, DataEdge>
                {
                    GroupId         = 1,
                    LayoutAlgorithm =
                        new RandomLayoutAlgorithm <DataVertex, DataEdge, GraphExample>(
                            new RandomLayoutAlgorithmParams {
                        Bounds = new Rect(0, 0, 500, 500)
                    }),

                    // ZoneRectangle = new Rect(0, 0, 500, 500)
                },
                new AlgorithmGroupParameters <DataVertex, DataEdge>
                {
                    GroupId         = 2,
                    LayoutAlgorithm =
                        new RandomLayoutAlgorithm <DataVertex, DataEdge, GraphExample>(
                            new RandomLayoutAlgorithmParams {
                        Bounds = new Rect(0, 0, 500, 500)
                    }),

                    // ZoneRectangle = new Rect(1000, 0, 500, 500)
                }
            };

            var gParams = new GroupingLayoutAlgorithmParameters <DataVertex, DataEdge>(prms, true);

            //generate grouping algo
            dg_Area.LogicCore.ExternalLayoutAlgorithm =
                new GroupingLayoutAlgorithm <DataVertex, DataEdge, BidirectionalGraph <DataVertex, DataEdge> >(dg_Area.LogicCore.Graph, null, gParams);

            //generate graphs
            dg_Area.GenerateGraph();

            //generate group visuals
            foreach (var item in prms)
            {
                if (!item.ZoneRectangle.HasValue)
                {
                    continue;
                }
                var rect = new Rectangle
                {
                    Width   = item.ZoneRectangle.Value.Width,
                    Height  = item.ZoneRectangle.Value.Height,
                    Fill    = item.GroupId == 1 ? Brushes.Blue : Brushes.Black,
                    Opacity = .5
                };
                dg_Area.InsertCustomChildControl(0, rect);
                GraphAreaBase.SetX(rect, item.ZoneRectangle.Value.X);
                GraphAreaBase.SetY(rect, item.ZoneRectangle.Value.Y);
            }
            dg_zoomctrl.ZoomToFill();
        }
Exemplo n.º 14
0
        private void GenerateGraph()
        {
            graphArea.ClearLayout();
            var logicCore = new LogicCoreExample()
            {
                Graph = ShowcaseHelper.GenerateDataGraph(10)
            };

            logicCore.Graph.Vertices.Take(5).ForEach(a => a.GroupId = 1);
            logicCore.Graph.Vertices.Where(a => a.GroupId == 0).ForEach(a => a.GroupId = 2);
            logicCore.DefaultOverlapRemovalAlgorithm = OverlapRemovalAlgorithmTypeEnum.None;
            //generate group params
            var prms = new List <AlgorithmGroupParameters <DataVertex, DataEdge> >
            {
                new AlgorithmGroupParameters <DataVertex, DataEdge>
                {
                    GroupId         = 1,
                    LayoutAlgorithm =
                        new RandomLayoutAlgorithm <DataVertex, DataEdge, GraphExample>(
                            new RandomLayoutAlgorithmParams {
                        Bounds = new Rect(10, 10, 490, 490)
                    }),
                },
                new AlgorithmGroupParameters <DataVertex, DataEdge>
                {
                    GroupId         = 2,
                    LayoutAlgorithm =
                        new RandomLayoutAlgorithm <DataVertex, DataEdge, GraphExample>(
                            new RandomLayoutAlgorithmParams {
                        Bounds = new Rect(10, 10, 490, 490)
                    }),
                }
            };

            var gParams = new GroupingLayoutAlgorithmParameters <DataVertex, DataEdge>(prms, true)
            {
                OverlapRemovalAlgorithm = logicCore.AlgorithmFactory.CreateFSAA <object>(100, 100),
                ArrangeGroups           = cbArrangeGroups.IsChecked ?? false,
            };

            //generate grouping algo
            logicCore.ExternalLayoutAlgorithm =
                new GroupingLayoutAlgorithm <DataVertex, DataEdge, BidirectionalGraph <DataVertex, DataEdge> >(logicCore.Graph, null, gParams);

            graphArea.LogicCore = logicCore;
            //generate graphs
            graphArea.GenerateGraph();

            //generate group visuals
            foreach (var item in prms)
            {
                if (!item.ZoneRectangle.HasValue)
                {
                    continue;
                }
                var rect = GenerateGroupBorder(item);
                graphArea.InsertCustomChildControl(0, rect);
                GraphAreaBase.SetX(rect, item.ZoneRectangle.Value.X - _groupInnerPadding * .5);
                GraphAreaBase.SetY(rect, item.ZoneRectangle.Value.Y - _groupInnerPadding * .5 - _headerHeight);
            }
            zoomControl.ZoomToFill();
        }