Exemple #1
1
        private UIElement GenerateWpfVisuals()
        {
            zoomctrl = new ZoomControl();
            ZoomControl.SetViewFinderVisibility(zoomctrl, System.Windows.Visibility.Visible);
            /* ENABLES WINFORMS HOSTING MODE --- >*/
            var logic = new GXLogicCore<DataVertex, DataEdge, BidirectionalGraph<DataVertex, DataEdge>>();
            gArea = new GraphAreaExample() { EnableWinFormsHostingMode = true, LogicCore = logic };
            logic.Graph = GenerateGraph();
            logic.DefaultLayoutAlgorithm = GraphX.LayoutAlgorithmTypeEnum.KK;
            logic.DefaultLayoutAlgorithmParams = logic.AlgorithmFactory.CreateLayoutParameters(GraphX.LayoutAlgorithmTypeEnum.KK);
            ((KKLayoutParameters)logic.DefaultLayoutAlgorithmParams).MaxIterations = 100;
            logic.DefaultOverlapRemovalAlgorithm = GraphX.OverlapRemovalAlgorithmTypeEnum.FSA;
            logic.DefaultOverlapRemovalAlgorithmParams = logic.AlgorithmFactory.CreateOverlapRemovalParameters(GraphX.OverlapRemovalAlgorithmTypeEnum.FSA);
            ((OverlapRemovalParameters)logic.DefaultOverlapRemovalAlgorithmParams).HorizontalGap = 50;
            ((OverlapRemovalParameters)logic.DefaultOverlapRemovalAlgorithmParams).VerticalGap = 50;
            logic.DefaultEdgeRoutingAlgorithm = GraphX.EdgeRoutingAlgorithmTypeEnum.None;
            logic.AsyncAlgorithmCompute = false;
            zoomctrl.Content = gArea;
            gArea.RelayoutFinished += gArea_RelayoutFinished;

            var myResourceDictionary = new ResourceDictionary {Source = new Uri("Templates\\template.xaml", UriKind.Relative)};
            zoomctrl.Resources.MergedDictionaries.Add(myResourceDictionary);

            return zoomctrl;
        }
Exemple #2
0
        private UIElement GenerateWpfVisuals()
        {
            zoomctrl = new ZoomControl();
            ZoomControl.SetViewFinderVisibility(zoomctrl, System.Windows.Visibility.Visible);
            /* ENABLES WINFORMS HOSTING MODE --- >*/
            var logic = new GXLogicCore <DataVertex, DataEdge, BidirectionalGraph <DataVertex, DataEdge> >();

            gArea = new GraphAreaExample()
            {
                EnableWinFormsHostingMode = true, LogicCore = logic
            };
            logic.Graph = GenerateGraph();
            logic.DefaultLayoutAlgorithm       = GraphX.LayoutAlgorithmTypeEnum.KK;
            logic.DefaultLayoutAlgorithmParams = logic.AlgorithmFactory.CreateLayoutParameters(GraphX.LayoutAlgorithmTypeEnum.KK);
            ((KKLayoutParameters)logic.DefaultLayoutAlgorithmParams).MaxIterations = 100;
            logic.DefaultOverlapRemovalAlgorithm       = GraphX.OverlapRemovalAlgorithmTypeEnum.FSA;
            logic.DefaultOverlapRemovalAlgorithmParams = logic.AlgorithmFactory.CreateOverlapRemovalParameters(GraphX.OverlapRemovalAlgorithmTypeEnum.FSA);
            ((OverlapRemovalParameters)logic.DefaultOverlapRemovalAlgorithmParams).HorizontalGap = 50;
            ((OverlapRemovalParameters)logic.DefaultOverlapRemovalAlgorithmParams).VerticalGap   = 50;
            logic.DefaultEdgeRoutingAlgorithm = GraphX.EdgeRoutingAlgorithmTypeEnum.None;
            logic.AsyncAlgorithmCompute       = false;
            zoomctrl.Content        = gArea;
            gArea.RelayoutFinished += gArea_RelayoutFinished;
            return(zoomctrl);
        }
Exemple #3
0
        public UIElement GenerateWpfVisuals(GraphExample example)
        {
            ZoomControl = new ZoomControl();
            ZoomControl.SetViewFinderVisibility(ZoomControl, System.Windows.Visibility.Visible);
            /* ENABLES WINFORMS HOSTING MODE --- >*/
            var logic = new GXLogicCore <DataVertex, DataEdge, BidirectionalGraph <DataVertex, DataEdge> >();

            GraphArea = new GraphAreaExample()
            {
                EnableWinFormsHostingMode = true, LogicCore = logic
            };
            logic.Graph = example;
            logic.DefaultLayoutAlgorithm       = GraphX.LayoutAlgorithmTypeEnum.KK;
            logic.DefaultLayoutAlgorithmParams = logic.AlgorithmFactory.CreateLayoutParameters(GraphX.LayoutAlgorithmTypeEnum.KK);
            ((KKLayoutParameters)logic.DefaultLayoutAlgorithmParams).MaxIterations = 100;
            logic.DefaultOverlapRemovalAlgorithm       = GraphX.OverlapRemovalAlgorithmTypeEnum.FSA;
            logic.DefaultOverlapRemovalAlgorithmParams = logic.AlgorithmFactory.CreateOverlapRemovalParameters(GraphX.OverlapRemovalAlgorithmTypeEnum.FSA);
            ((OverlapRemovalParameters)logic.DefaultOverlapRemovalAlgorithmParams).HorizontalGap = 50;
            ((OverlapRemovalParameters)logic.DefaultOverlapRemovalAlgorithmParams).VerticalGap   = 50;
            logic.DefaultEdgeRoutingAlgorithm = GraphX.EdgeRoutingAlgorithmTypeEnum.None;
            logic.AsyncAlgorithmCompute       = false;
            ZoomControl.Content         = GraphArea;
            GraphArea.RelayoutFinished += GAreaRelayoutFinished;



            var myResourceDictionary = new ResourceDictionary {
                Source = new Uri("Templates\\template.xaml", UriKind.Relative)
            };

            ZoomControl.Resources.MergedDictionaries.Add(myResourceDictionary);


            return(ZoomControl);
        }
Exemple #4
0
        private UIElement GenerateWpfVisuals()
        {
            _zoomctrl = new ZoomControl();
            ZoomControl.SetViewFinderVisibility(_zoomctrl, Visibility.Visible);
            var logic = new GXLogicCore <DataVertex, DataEdge, BidirectionalGraph <DataVertex, DataEdge> >();

            _gArea = new GraphAreaExample
            {
                // EnableWinFormsHostingMode = false,
                LogicCore        = logic,
                EdgeLabelFactory = new DefaultEdgelabelFactory()
            };
            _gArea.ShowAllEdgesLabels(true);
            logic.Graph = GenerateGraph();
            logic.DefaultLayoutAlgorithm       = LayoutAlgorithmTypeEnum.LinLog;
            logic.DefaultLayoutAlgorithmParams = logic.AlgorithmFactory.CreateLayoutParameters(LayoutAlgorithmTypeEnum.LinLog);
            //((LinLogLayoutParameters)logic.DefaultLayoutAlgorithmParams). = 100;
            logic.DefaultOverlapRemovalAlgorithm       = OverlapRemovalAlgorithmTypeEnum.FSA;
            logic.DefaultOverlapRemovalAlgorithmParams = logic.AlgorithmFactory.CreateOverlapRemovalParameters(OverlapRemovalAlgorithmTypeEnum.FSA);
            ((OverlapRemovalParameters)logic.DefaultOverlapRemovalAlgorithmParams).HorizontalGap = 50;
            ((OverlapRemovalParameters)logic.DefaultOverlapRemovalAlgorithmParams).VerticalGap   = 50;
            logic.DefaultEdgeRoutingAlgorithm = EdgeRoutingAlgorithmTypeEnum.None;
            logic.AsyncAlgorithmCompute       = false;
            _zoomctrl.Content        = _gArea;
            _gArea.RelayoutFinished += gArea_RelayoutFinished;


            var myResourceDictionary = new ResourceDictionary {
                Source = new Uri("Templates\\template.xaml", UriKind.Relative)
            };

            _zoomctrl.Resources.MergedDictionaries.Add(myResourceDictionary);

            return(_zoomctrl);
        }
Exemple #5
0
        private UIElement initEmptyGraphVisualization()
        {
            _zoomControl = new ZoomControl();
            ZoomControl.SetViewFinderVisibility(_zoomControl, Visibility.Visible);
            var logic = new GXLogicCore <NodeV, EdgeV, BidirectionalGraph <NodeV, EdgeV> >();

            _graphAreaVisualizer = new GraphAreaVisualizer {
                LogicCore        = logic,
                EdgeLabelFactory = new DefaultEdgelabelFactory()
            };
            logic.DefaultLayoutAlgorithm       = LayoutAlgorithmTypeEnum.LinLog;
            logic.DefaultLayoutAlgorithmParams = logic.AlgorithmFactory.CreateLayoutParameters(LayoutAlgorithmTypeEnum.LinLog);
            //((LinLogLayoutParameters)logic.DefaultLayoutAlgorithmParams). = 100;
            logic.DefaultOverlapRemovalAlgorithm       = OverlapRemovalAlgorithmTypeEnum.FSA;
            logic.DefaultOverlapRemovalAlgorithmParams = logic.AlgorithmFactory.CreateOverlapRemovalParameters(OverlapRemovalAlgorithmTypeEnum.FSA);
            ((OverlapRemovalParameters)logic.DefaultOverlapRemovalAlgorithmParams).HorizontalGap = 50;
            ((OverlapRemovalParameters)logic.DefaultOverlapRemovalAlgorithmParams).VerticalGap   = 50;
            logic.DefaultEdgeRoutingAlgorithm = EdgeRoutingAlgorithmTypeEnum.None;
            logic.AsyncAlgorithmCompute       = false;
            _graphAreaVisualizer.ShowAllEdgesLabels(true);
            _zoomControl.Content = _graphAreaVisualizer;

            var myResourceDictionary = new ResourceDictionary {
                Source = new Uri("Templates\\template.xaml", UriKind.Relative)
            };

            _zoomControl.Resources.MergedDictionaries.Add(myResourceDictionary);

            return(_zoomControl);
        }
Exemple #6
0
        UIElement RedrawGraph(ref BiGraphArea <string> _gArea)
        {
            _zoomctrl = new ZoomControl();
            ZoomControl.SetViewFinderVisibility(_zoomctrl, Visibility.Visible);
            var logic = new GXLogicCore <Node <string>, Base.Edge <string>, BidirectionalGraph <Node <string>, Base.Edge <string> > >();

            _gArea = new BiGraphArea <string>
            {
                // EnableWinFormsHostingMode = false,
                LogicCore        = logic,
                EdgeLabelFactory = new DefaultEdgelabelFactory()
            };
            _gArea.ShowAllEdgesLabels(true);
            logic.Graph = current_graph;
            logic.DefaultLayoutAlgorithm       = ((LayoutAlgorithmTypeEnum)(layoutcombo.SelectedItem as ComboBoxItem).Tag);
            logic.DefaultLayoutAlgorithmParams = logic.AlgorithmFactory.CreateLayoutParameters(((LayoutAlgorithmTypeEnum)(layoutcombo.SelectedItem as ComboBoxItem).Tag));
            //((LinLogLayoutParameters)logic.DefaultLayoutAlgorithmParams). = 100;
            logic.DefaultOverlapRemovalAlgorithm       = OverlapRemovalAlgorithmTypeEnum.FSA;
            logic.DefaultOverlapRemovalAlgorithmParams = logic.AlgorithmFactory.CreateOverlapRemovalParameters(OverlapRemovalAlgorithmTypeEnum.FSA);
            ((OverlapRemovalParameters)logic.DefaultOverlapRemovalAlgorithmParams).HorizontalGap = 50;
            ((OverlapRemovalParameters)logic.DefaultOverlapRemovalAlgorithmParams).VerticalGap   = 50;
            logic.DefaultEdgeRoutingAlgorithm = ((EdgeRoutingAlgorithmTypeEnum)(ercombo.SelectedItem as ComboBoxItem).Tag);
            logic.EnableParallelEdges         = paredge.Checked;
            logic.ParallelEdgeDistance        = edgedist.Value;
            logic.AsyncAlgorithmCompute       = false;
            _zoomctrl.Content        = _gArea;
            _gArea.RelayoutFinished += gArea_RelayoutFinished;

            var myResourceDictionary = new ResourceDictionary {
                Source = new Uri("WpfTemplate\\template.xaml", UriKind.Relative)
            };

            _zoomctrl.Resources.MergedDictionaries.Add(myResourceDictionary);
            return(_zoomctrl);
        }
Exemple #7
0
        private UIElement GenerateElementVisuals()
        {
            _zoomControl = new ZoomControl();
            ZoomControl.SetViewFinderVisibility(_zoomControl, Visibility.Visible);
            GXLogicCore <Node, BeltPlanGraphEdge, BeltPlanGraphCore> logicCore = new GXLogicCore <Node, BeltPlanGraphEdge, BeltPlanGraphCore>();

            _graph = new BeltPlanGraph
            {
                LogicCore        = logicCore,
                EdgeLabelFactory = new DefaultEdgelabelFactory(),
            };
            _graph.ShowAllEdgesLabels(false);
            logicCore.Graph = GenerateGraphCore();
            logicCore.DefaultLayoutAlgorithm               = _layoutAlgorithm;
            logicCore.DefaultLayoutAlgorithmParams         = logicCore.AlgorithmFactory.CreateLayoutParameters(_layoutAlgorithm);
            logicCore.DefaultOverlapRemovalAlgorithm       = _overlapAlgorithm;
            logicCore.DefaultOverlapRemovalAlgorithmParams = logicCore.AlgorithmFactory.CreateOverlapRemovalParameters(_overlapAlgorithm);
            logicCore.DefaultOverlapRemovalAlgorithmParams.HorizontalGap = 50;
            logicCore.DefaultOverlapRemovalAlgorithmParams.VerticalGap   = 50;
            logicCore.DefaultEdgeRoutingAlgorithm       = _edgeAlgorithm;
            logicCore.DefaultEdgeRoutingAlgorithmParams = logicCore.AlgorithmFactory.CreateEdgeRoutingParameters(_edgeAlgorithm);
            logicCore.AsyncAlgorithmCompute             = false;
            _zoomControl.Content = _graph;
            return(_zoomControl);
        }
        public BidirectionalGraphArea(GXLogicCore <TVertex, TEdge, BidirectionalGraph <TVertex, TEdge> > logicCore)
        {
            LogicCore = logicCore;
            EnableWinFormsHostingMode = true;
            EdgeLabelFactory          = new DefaultEdgelabelFactory();
            SetVerticesDrag(true);

            logicCore.DefaultLayoutAlgorithmParams =
                logicCore.AlgorithmFactory.CreateLayoutParameters(LayoutAlgorithmTypeEnum.LinLog);
            logicCore.DefaultOverlapRemovalAlgorithmParams =
                logicCore.AlgorithmFactory.CreateOverlapRemovalParameters(OverlapRemovalAlgorithmTypeEnum.FSA);
        }
Exemple #9
0
        private void GraphAreaExample_Setup()
        {
            //Lets create logic core and filled data graph with edges and vertices
            var logicCore = new GXLogicCore()
            {
                Graph = dataGraph
            };

            Console.WriteLine(dataGraph);



            //This property sets layout algorithm that will be used to calculate vertices positions
            //Different algorithms uses different values and some of them uses edge Weight property.
            logicCore.DefaultLayoutAlgorithm = LayoutAlgorithmTypeEnum.FR;

            //Now we can set parameters for selected algorithm using AlgorithmFactory property. This property provides methods for
            //creating all available algorithms and algo parameters.
            logicCore.DefaultLayoutAlgorithmParams = logicCore.AlgorithmFactory.CreateLayoutParameters(LayoutAlgorithmTypeEnum.KK);
            //Unfortunately to change algo parameters you need to specify params type which is different for every algorithm.
            ((KKLayoutParameters)logicCore.DefaultLayoutAlgorithmParams).MaxIterations = 100;

            //This property sets vertex overlap removal algorithm.
            //Such algorithms help to arrange vertices in the layout so no one overlaps each other.
            logicCore.DefaultOverlapRemovalAlgorithm = OverlapRemovalAlgorithmTypeEnum.FSA;
            //Default parameters are created automaticaly when new default algorithm is set and previous params were NULL
            logicCore.DefaultOverlapRemovalAlgorithmParams.HorizontalGap = 50;
            logicCore.DefaultOverlapRemovalAlgorithmParams.VerticalGap   = 50;

            //This property sets edge routing algorithm that is used to build route paths according to algorithm logic.
            //For ex., SimpleER algorithm will try to set edge paths around vertices so no edge will intersect any vertex.
            //Bundling algorithm will try to tie different edges that follows same direction to a single channel making complex graphs more appealing.
            logicCore.DefaultEdgeRoutingAlgorithm = EdgeRoutingAlgorithmTypeEnum.SimpleER;

            //This property sets async algorithms computation so methods like: Area.RelayoutGraph() and Area.GenerateGraph()
            //will run async with the UI thread. Completion of the specified methods can be catched by corresponding events:
            //Area.RelayoutFinished and Area.GenerateGraphFinished.
            logicCore.AsyncAlgorithmCompute = false;



            //Finally assign logic core to GraphArea object
            Area.LogicCore = logicCore;
        }
Exemple #10
0
        public MainWindow()
        {
            this.InitializeComponent();
            this.editorManager = new EditorObjectManager(this.g_Area, this.g_zoomctrl);
            this.dataGraph     = new GraphExample();
            var logic = new GXLogicCore <DataVertex, DataEdge, BidirectionalGraph <DataVertex, DataEdge> >();

            this.g_Area.LogicCore        = logic;
            logic.Graph                  = this.dataGraph;
            logic.DefaultLayoutAlgorithm = LayoutAlgorithmTypeEnum.LinLog;

            this.g_Area.VertexSelected            += this.VertexSelectedAction;
            this.g_Area.EdgeSelected              += this.EdgeSelectedAction;
            this.g_zoomctrl.Click                 += this.ClearSelection;
            this.elementsListBox.MouseDoubleClick += this.ElementInBoxSelectedAction;

            ZoomControl.SetViewFinderVisibility(this.g_zoomctrl, Visibility.Visible);
            this.g_zoomctrl.Loaded += (sender, args) =>
            {
                (this.g_zoomctrl.ViewFinder.Parent as Grid).Children.Remove(this.g_zoomctrl.ViewFinder);
                this.rightPanel.Children.Add(this.g_zoomctrl.ViewFinder);
                Grid.SetRow(this.g_zoomctrl.ViewFinder, 0);
            };

            logic.DefaultLayoutAlgorithmParams =
                logic.AlgorithmFactory.CreateLayoutParameters(LayoutAlgorithmTypeEnum.LinLog);
            logic.DefaultOverlapRemovalAlgorithm       = OverlapRemovalAlgorithmTypeEnum.FSA;
            logic.DefaultOverlapRemovalAlgorithmParams =
                logic.AlgorithmFactory.CreateOverlapRemovalParameters(OverlapRemovalAlgorithmTypeEnum.FSA);
            ((OverlapRemovalParameters)logic.DefaultOverlapRemovalAlgorithmParams).HorizontalGap = 50;
            ((OverlapRemovalParameters)logic.DefaultOverlapRemovalAlgorithmParams).VerticalGap   = 50;
            logic.DefaultEdgeRoutingAlgorithm = EdgeRoutingAlgorithmTypeEnum.None;
            logic.AsyncAlgorithmCompute       = false;

            this.Closed += this.CloseChildrenWindows;

            var modelName = "RobotsTestModel";

            this.g_zoomctrl.MouseDown += (object sender, MouseButtonEventArgs e) => this.ZoomCtrl_MouseDown(sender, e, modelName);

            this.InitPalette(modelName);
            this.InitModel(modelName);
        }
        private UIElement GenerateWpfVisual2Export(string g6)
        {
            _zoomctrl = new ZoomControl();
            ZoomControl.SetViewFinderVisibility(_zoomctrl, Visibility.Hidden);
            var logic = new GXLogicCore <DataVertex, DataEdge, BidirectionalGraph <DataVertex, DataEdge> >();

            _gArea = new GraphAreaView
            {
                LogicCore        = logic,
                EdgeLabelFactory = new DefaultEdgelabelFactory()
            };
            _gArea.ShowAllEdgesLabels(false);
            logic.DefaultLayoutAlgorithm       = LayoutAlgorithmTypeEnum.LinLog;
            logic.DefaultLayoutAlgorithmParams = logic.AlgorithmFactory.CreateLayoutParameters(LayoutAlgorithmTypeEnum.LinLog);

            /*if (listOfG6Exp.Items[i].ToString().Length != 0)
             * {
             *
             * }*/
            logic.Graph = Conversor.G6toQuickGraph(g6);
            logic.DefaultOverlapRemovalAlgorithm       = OverlapRemovalAlgorithmTypeEnum.FSA;
            logic.DefaultOverlapRemovalAlgorithmParams = logic.AlgorithmFactory.CreateOverlapRemovalParameters(OverlapRemovalAlgorithmTypeEnum.FSA);
            ((OverlapRemovalParameters)logic.DefaultOverlapRemovalAlgorithmParams).HorizontalGap = 100;
            ((OverlapRemovalParameters)logic.DefaultOverlapRemovalAlgorithmParams).VerticalGap   = 100;
            logic.DefaultEdgeRoutingAlgorithm = EdgeRoutingAlgorithmTypeEnum.None;
            logic.AsyncAlgorithmCompute       = false;

            _zoomctrl.Content        = _gArea;
            _gArea.RelayoutFinished += gArea_RelayoutFinished;

            //Edge visualization edit
            _gArea.SetEdgesDashStyle(EdgeDashStyle.Solid);
            _gArea.ShowAllEdgesArrows(false);

            var myResourceDictionary = new ResourceDictionary {
                Source = new Uri("GraphX_Utils\\template.xaml", UriKind.Relative)
            };

            _zoomctrl.Resources.MergedDictionaries.Add(myResourceDictionary);

            return(_zoomctrl);
        }
Exemple #12
0
        private void SetupGraph()
        {
            Area.ClearLayout(true);

            if (mGraph != null)
            {
                mGraph.Clear();
            }

            //Lets create logic core and filled data graph with edges and vertices
            var logicCore = new GXLogicCore()
            {
                Graph = CreateGraph()
            };

            logicCore.DefaultLayoutAlgorithm       = LayoutAlgorithmTypeEnum.Tree;
            logicCore.DefaultLayoutAlgorithmParams = logicCore.AlgorithmFactory.CreateLayoutParameters(GraphX.LayoutAlgorithmTypeEnum.Tree);
            ((SimpleTreeLayoutParameters)logicCore.DefaultLayoutAlgorithmParams).Direction = GraphX.GraphSharp.Algorithms.Layout.LayoutDirection.TopToBottom;
            ((SimpleTreeLayoutParameters)logicCore.DefaultLayoutAlgorithmParams).SpanningTreeGeneration = SpanningTreeGeneration.DFS;
            ((SimpleTreeLayoutParameters)logicCore.DefaultLayoutAlgorithmParams).LayerGap  = 50;
            ((SimpleTreeLayoutParameters)logicCore.DefaultLayoutAlgorithmParams).VertexGap = 50;

            //This property sets vertex overlap removal algorithm.
            //Such algorithms help to arrange vertices in the layout so no one overlaps each other.
            logicCore.DefaultOverlapRemovalAlgorithm = OverlapRemovalAlgorithmTypeEnum.FSA;
            //Default parameters are created automaticaly when new default algorithm is set and previous params were NULL
            logicCore.DefaultOverlapRemovalAlgorithmParams.HorizontalGap = 50;
            logicCore.DefaultOverlapRemovalAlgorithmParams.VerticalGap   = 50;

            //This property sets edge routing algorithm that is used to build route paths according to algorithm logic.
            //For ex., SimpleER algorithm will try to set edge paths around vertices so no edge will intersect any vertex.
            //Bundling algorithm will try to tie different edges that follows same direction to a single channel making complex graphs more appealing.
            logicCore.DefaultEdgeRoutingAlgorithm = EdgeRoutingAlgorithmTypeEnum.SimpleER;

            //This property sets async algorithms computation so methods like: Area.RelayoutGraph() and Area.GenerateGraph()
            //will run async with the UI thread. Completion of the specified methods can be catched by corresponding events:
            //Area.RelayoutFinished and Area.GenerateGraphFinished.
            logicCore.AsyncAlgorithmCompute = false;

            //Finally assign logic core to GraphArea object
            Area.LogicCore = logicCore;// as IGXLogicCore<DataVertex, DataEdge, BidirectionalGraph<DataVertex, DataEdge>>;
        }
Exemple #13
0
        public VisualGraphArea()
        {
            LogicCore = new GXLogicCore <VisualVertex, VisualEdge, BidirectionalGraph <VisualVertex, VisualEdge> >
            {
                DefaultLayoutAlgorithm       = LayoutAlgorithmTypeEnum.BoundedFR,
                DefaultLayoutAlgorithmParams = new BoundedFRLayoutParameters
                {
                    Width  = 400,
                    Height = 400
                },
                EnableParallelEdges         = true,
                EdgeCurvingEnabled          = true,
                DefaultEdgeRoutingAlgorithm = EdgeRoutingAlgorithmTypeEnum.SimpleER
            };
            ControlFactory   = new VisualGraphControlFactory(this);
            EdgeLabelFactory = new DefaultEdgelabelFactory();

            SetVerticesDrag(true, true);
            ShowAllEdgesLabels();
        }
Exemple #14
0
        private void InitGraphXLogicCore()
        {
            var logic =
                new GXLogicCore <NodeViewModel, EdgeViewModel, BidirectionalGraph <NodeViewModel, EdgeViewModel> >
            {
                Graph = this.Graph.DataGraph,
                DefaultLayoutAlgorithm = LayoutAlgorithmTypeEnum.LinLog
            };

            this.scene.LogicCore = logic;

            logic.DefaultLayoutAlgorithmParams =
                logic.AlgorithmFactory.CreateLayoutParameters(LayoutAlgorithmTypeEnum.LinLog);
            logic.DefaultOverlapRemovalAlgorithm       = OverlapRemovalAlgorithmTypeEnum.FSA;
            logic.DefaultOverlapRemovalAlgorithmParams =
                logic.AlgorithmFactory.CreateOverlapRemovalParameters(OverlapRemovalAlgorithmTypeEnum.FSA);
            ((OverlapRemovalParameters)logic.DefaultOverlapRemovalAlgorithmParams).HorizontalGap = 50;
            ((OverlapRemovalParameters)logic.DefaultOverlapRemovalAlgorithmParams).VerticalGap   = 50;
            logic.DefaultEdgeRoutingAlgorithm = EdgeRoutingAlgorithmTypeEnum.None;
            logic.AsyncAlgorithmCompute       = false;
        }
Exemple #15
0
        public void InitializeScene(ZoomControl zoomControl)
        {
            _zoomControl = zoomControl;
            _graphArea   = zoomControl.Content as GraphArea;
            if (_graphArea == null)
            {
                throw new ArgumentException("Zoom control doesn't contain an instance of class GraphArea.");
            }
            var graph = new BidirectionalGraph <ModelNode, ModelEdge>();

            _logicCore = new GXLogicCore
            {
                DefaultLayoutAlgorithm = LayoutAlgorithmTypeEnum.KK,
                Graph = graph
            };

            _graphArea.LogicCore = _logicCore;
            _graphArea.SetVerticesDrag(true);
            _graphArea.GenerateGraph();
            zoomControl.CenterContent();
        }
Exemple #16
0
        private void SetupGraphArea(int selectIndex)
        {
            //Lets create logic core and filled data graph with edges and vertices
            var logicCore = new GXLogicCore {
                Graph = SetupGraph(selectIndex)
            };

            //This property sets layout algorithm that will be used to calculate vertices positions
            //Different algorithms uses different values and some of them uses edge Weight property.
            logicCore.DefaultLayoutAlgorithm = LayoutAlgorithmTypeEnum.KK;
            //Now we can set parameters for selected algorithm using AlgorithmFactory property. This property provides methods for
            //creating all available algorithms and algo parameters.
            logicCore.DefaultLayoutAlgorithmParams =
                logicCore.AlgorithmFactory.CreateLayoutParameters(LayoutAlgorithmTypeEnum.KK);
            //Unfortunately to change algo parameters you need to specify params type which is different for every algorithm.
            ((KKLayoutParameters)logicCore.DefaultLayoutAlgorithmParams).MaxIterations = 100;

            //This property sets vertex overlap removal algorithm.
            //Such algorithms help to arrange vertices in the layout so no one overlaps each other.
            logicCore.DefaultOverlapRemovalAlgorithm = OverlapRemovalAlgorithmTypeEnum.FSA;
            //Default parameters are created automaticaly when new default algorithm is set and previous params were NULL
            logicCore.DefaultOverlapRemovalAlgorithmParams.HorizontalGap = 50;
            logicCore.DefaultOverlapRemovalAlgorithmParams.VerticalGap   = 50;


            //このプロパティは、アルゴリズムロジックに従ってルートパスを構築するために使用されるエッジルーティングアルゴリズムを設定します。
            //例えば、SimpleERアルゴリズムは頂点の周りに辺のパスを設定しようとするので、辺が頂点と交差することはありません。
            // Bundlingアルゴリズムは、複雑なグラフをより魅力的にする単一のチャンネルと同じ方向に続く異なるエッジを結びつけるよう試みます。
            logicCore.DefaultEdgeRoutingAlgorithm = EdgeRoutingAlgorithmTypeEnum.SimpleER;


            //このプロパティは、非同期アルゴリズムの計算を、Area.RelayoutGraph()やArea.GenerateGraph()のように設定します。
            // UIスレッドで非同期を実行します。指定されたメソッドの完了は、対応するイベントによってキャッチできます。
            //Area.RelayoutFinishedおよびArea.GenerateGraphFinished。
            logicCore.AsyncAlgorithmCompute = false;


            //最後に、GraphAreaオブジェクトにロジックコアを割り当てます
            Area.LogicCore = logicCore;
        }
Exemple #17
0
        private UIElement GenerateWpfVisuals()
        {
            //Basic Options
            var logic = new GXLogicCore <DataVertex, DataEdge, BidirectionalGraph <DataVertex, DataEdge> >();

            logic.Graph = GenerateGraph();
            logic.DefaultLayoutAlgorithm               = graphLayoutOptions.layoutAlgorithm;
            logic.DefaultLayoutAlgorithmParams         = logic.AlgorithmFactory.CreateLayoutParameters(graphLayoutOptions.layoutAlgorithm);
            logic.EdgeCurvingEnabled                   = true;
            logic.EnableParallelEdges                  = true;
            logic.DefaultOverlapRemovalAlgorithm       = graphLayoutOptions.overlapRemovalAlgorithm;
            logic.DefaultOverlapRemovalAlgorithmParams = logic.AlgorithmFactory.CreateOverlapRemovalParameters(graphLayoutOptions.overlapRemovalAlgorithm);
            ((OverlapRemovalParameters)logic.DefaultOverlapRemovalAlgorithmParams).HorizontalGap = graphLayoutOptions.overlapRemovalHorizontalGap;
            ((OverlapRemovalParameters)logic.DefaultOverlapRemovalAlgorithmParams).VerticalGap   = graphLayoutOptions.overlapRemovalVerticalGap;
            logic.DefaultEdgeRoutingAlgorithm = graphLayoutOptions.edgeRoutingAlgorithm;
            logic.AsyncAlgorithmCompute       = false;

            //GraphArea Stuff
            _gArea = new FSMGraphArea
            {
                LogicCore        = logic,
                EdgeLabelFactory = new DefaultEdgelabelFactory()
            };
            _gArea.ShowAllEdgesLabels(graphLayoutOptions.showAllEdgesLabels);

            _gArea.RelayoutFinished += gArea_RelayoutFinished;

            var gAreaContextMenu = new System.Windows.Controls.ContextMenu();
            var mipng            = new System.Windows.Controls.MenuItem();

            mipng.Header = "Save graph as .png";
            mipng.Click += toolStripMenuItemSavePNG_Click;
            var mijpg = new System.Windows.Controls.MenuItem();

            mijpg.Header = "Save graph as .jpeg";
            mijpg.Click += toolStripMenuItemSaveJPG_Click;
            var mitiff = new System.Windows.Controls.MenuItem();

            mitiff.Header = "Save graph as .tiff";
            mitiff.Click += toolStripMenuItemSaveTIFF_Click;
            var mibmp = new System.Windows.Controls.MenuItem();

            mibmp.Header = "Save graph as .bmp";
            mibmp.Click += toolStripMenuItemSaveBMP_Click;
            var misvg = new System.Windows.Controls.MenuItem();

            misvg.Header = "Save graph as .svg";
            misvg.Click += toolStripMenuItemSaveSVG_Click;
            gAreaContextMenu.Items.Add(mipng);
            gAreaContextMenu.Items.Add(mijpg);
            gAreaContextMenu.Items.Add(mitiff);
            gAreaContextMenu.Items.Add(mibmp);
            gAreaContextMenu.Items.Add(misvg);

            //_gArea.ContextMenu = gAreaContextMenu;

            //Zoom control stuff
            _zoomctrl = new ZoomControl();
            ZoomControl.SetViewFinderVisibility(_zoomctrl, Visibility.Visible);
            _zoomctrl.Content     = _gArea;
            _zoomctrl.ContextMenu = gAreaContextMenu;
            var myResourceDictionary = new ResourceDictionary {
                Source = new Uri("Templates\\template.xaml", UriKind.Relative)
            };

            _zoomctrl.Resources.MergedDictionaries.Add(myResourceDictionary);

            return(_zoomctrl);
        }
        public static GraphArea CreateTransitionGraph()
        {
            Graph graph = new Graph();
            Dictionary <string, DataVertex> vertices = new Dictionary <string, DataVertex>();
            int i = 0;

            foreach (string s in areaRandomizer ? areas : roomRandomizer ? rooms : new HashSet <string>())
            {
                i++;
                DataVertex v = new DataVertex()
                {
                    ID = i, Name = s, uiName = AltRoomNames.TryGetValue(s, out string altName) ? altName : null
                };
                vertices[s] = v;
                graph.AddVertex(v);
            }
            List <string> sourceTransitions = new List <string>();

            foreach (var kvp in FoundTransitions)
            {
                //DataEdge e = new DataEdge(vertices[pair.Item1], vertices[pair.Item2]);
                string source;
                string target;

                if (areaRandomizer)
                {
                    source = transitionToArea[kvp.Key];
                    target = transitionToArea[kvp.Value];
                }
                else
                {
                    source = transitionToRoom[kvp.Key];
                    target = transitionToRoom[kvp.Value];
                }

                DataEdge e = new DataEdge(vertices[source], vertices[target])
                {
                    SourceTransition = kvp.Key,
                    TargetTransition = kvp.Value,
                    Label            = !sourceTransitions.Contains(kvp.Value)
                };
                sourceTransitions.Add(kvp.Key);
                graph.AddEdge(e);
            }

            var LogicCore = new GXLogicCore()
            {
                Graph = graph
            };

            if (!Enum.TryParse <GraphX.PCL.Common.Enums.LayoutAlgorithmTypeEnum>(RandomizerTracker.instance.vertAlgo, out var vertAlgo))
            {
                vertAlgo = GraphX.PCL.Common.Enums.LayoutAlgorithmTypeEnum.LinLog;
            }
            if (!Enum.TryParse <GraphX.PCL.Common.Enums.EdgeRoutingAlgorithmTypeEnum>(RandomizerTracker.instance.edgeAlgo, out var edgeAlgo))
            {
                edgeAlgo = GraphX.PCL.Common.Enums.EdgeRoutingAlgorithmTypeEnum.SimpleER;
            }

            LogicCore.DefaultLayoutAlgorithm               = vertAlgo;
            LogicCore.DefaultLayoutAlgorithmParams         = LogicCore.AlgorithmFactory.CreateLayoutParameters(vertAlgo);
            LogicCore.DefaultOverlapRemovalAlgorithm       = GraphX.PCL.Common.Enums.OverlapRemovalAlgorithmTypeEnum.FSA;
            LogicCore.DefaultOverlapRemovalAlgorithmParams = LogicCore.AlgorithmFactory.CreateOverlapRemovalParameters(GraphX.PCL.Common.Enums.OverlapRemovalAlgorithmTypeEnum.FSA);
            ((OverlapRemovalParameters)LogicCore.DefaultOverlapRemovalAlgorithmParams).HorizontalGap = 30;
            ((OverlapRemovalParameters)LogicCore.DefaultOverlapRemovalAlgorithmParams).VerticalGap   = 30;
            LogicCore.DefaultEdgeRoutingAlgorithm = edgeAlgo;
            //LogicCore.AsyncAlgorithmCompute = false;
            GraphArea GA = new GraphArea();

            GA.LogicCore = LogicCore;
            return(GA);
        }