using System; using System.Linq; using GraphX; using GraphX.GraphSharp.Algorithms.OverlapRemoval; using GraphX.Logic; using QuickGraph; namespace JD.AssetDependencies.Graph { public class DependencyGraphLogicCore : GXLogicCore> { public DependencyGraphLogicCore() { //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. DefaultLayoutAlgorithm = CurrentLayout; //Now we can set optional parameters using AlgorithmFactory DefaultLayoutAlgorithmParams = AlgorithmFactory.CreateLayoutParameters(CurrentLayout); //Unfortunately to change algo parameters you need to specify params type which is different for every algorithm. //((BoundedFRLayoutParameters)DefaultLayoutAlgorithmParams).IterationLimit = 100; //This property sets vertex overlap removal algorithm. //Such algorithms help to arrange vertices in the layout so no one overlaps each other. DefaultOverlapRemovalAlgorithm = GraphX.OverlapRemovalAlgorithmTypeEnum.FSA; //Setup optional params DefaultOverlapRemovalAlgorithmParams = AlgorithmFactory.CreateOverlapRemovalParameters(GraphX.OverlapRemovalAlgorithmTypeEnum.FSA); ((OverlapRemovalParameters)DefaultOverlapRemovalAlgorithmParams).HorizontalGap = 200; ((OverlapRemovalParameters)DefaultOverlapRemovalAlgorithmParams).VerticalGap = 200; //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. DefaultEdgeRoutingAlgorithm = GraphX.EdgeRoutingAlgorithmTypeEnum.None; //DefaultEdgeRoutingAlgorithmParams = AlgorithmFactory.CreateEdgeRoutingParameters(EdgeRoutingAlgorithmTypeEnum.SimpleER); EnableParallelEdges = false; EdgeCurvingEnabled = true; //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. AsyncAlgorithmCompute = true; } public void SetLayout(LayoutAlgorithmTypeEnum layout, bool saveToCurrent = true) { DefaultLayoutAlgorithm = layout; DefaultLayoutAlgorithmParams = AlgorithmFactory.CreateLayoutParameters(layout); if (saveToCurrent) { CurrentLayout = layout; } } public LayoutAlgorithmTypeEnum CurrentLayout { get; private set; } = LayoutAlgorithmTypeEnum.EfficientSugiyama; } }