private void CalcBundling() { //perform edge routing IExternalEdgeRouting <DataVertex, DataEdge> era = null; IEdgeRoutingParameters prms = null; switch ((EdgeRoutingAlgorithmTypeEnum)erg_eralgo.SelectedItem) { case EdgeRoutingAlgorithmTypeEnum.Bundling: prms = erg_BundleEdgeRoutingParameters; era = new BundleEdgeRouting <DataVertex, DataEdge, GraphExample>(erg_Area.ContentSize, erg_Area.LogicCore.Graph as GraphExample, erg_Area.GetVertexPositions(), erg_Area.GetVertexSizeRectangles(), prms); break; /*case EdgeRoutingAlgorithmTypeEnum.SimpleER: * prms = erg_SimpleERParameters; * era = new SimpleEdgeRouting<DataVertex, DataEdge, GraphExample>(graph, VertexPositions, erg_Area.GetVertexSizeRectangles(VertexPositions), prms); * break;*/ case EdgeRoutingAlgorithmTypeEnum.None: break; } if (era != null) { era.Compute(); foreach (var item in erg_Area.LogicCore.Graph.Edges) { if (era.EdgeRoutes.ContainsKey(item)) { item.RoutingPoints = era.EdgeRoutes[item]; } } } }
public void StandardFactory() { var graph = new BidirectionalGraph <int, Edge <int> >(); var verticesPositions = new Dictionary <int, Point>(); var verticesSizes = new Dictionary <int, Size>(); var context = new LayoutContext <int, Edge <int>, BidirectionalGraph <int, Edge <int> > >( graph, verticesPositions, verticesSizes, LayoutMode.Simple); var factory = new StandardEdgeRoutingAlgorithmFactory <int, Edge <int>, BidirectionalGraph <int, Edge <int> > >(); CollectionAssert.IsEmpty(factory.AlgorithmTypes); Assert.IsNull(factory.CreateAlgorithm( string.Empty, context, null)); Assert.IsNull(factory.CreateAlgorithm( string.Empty, context, new EdgeRoutingParameters())); Assert.IsNull(factory.CreateAlgorithm( "TestType", context, new EdgeRoutingParameters())); var parameters = new EdgeRoutingParameters(); IEdgeRoutingParameters createdParameters = factory.CreateParameters(string.Empty, null); Assert.IsInstanceOf <EdgeRoutingParameters>(createdParameters); Assert.AreNotSame(parameters, createdParameters); createdParameters = factory.CreateParameters(string.Empty, null); Assert.IsInstanceOf <EdgeRoutingParameters>(createdParameters); Assert.AreNotSame(parameters, createdParameters); createdParameters = factory.CreateParameters("TestType", null); Assert.IsInstanceOf <EdgeRoutingParameters>(createdParameters); Assert.AreNotSame(parameters, createdParameters); createdParameters = factory.CreateParameters("TestType", null); Assert.IsInstanceOf <EdgeRoutingParameters>(createdParameters); Assert.AreNotSame(parameters, createdParameters); Assert.IsFalse(factory.IsValidAlgorithm(null)); Assert.IsFalse(factory.IsValidAlgorithm(string.Empty)); Assert.IsFalse(factory.IsValidAlgorithm("TestType")); var algorithm = new TestEdgeRoutingAlgorithm(graph, verticesPositions); Assert.IsEmpty(factory.GetAlgorithmType(algorithm)); }
/// <summary> /// Base class for edge routing algorithms /// </summary> /// <param name="graph">Graph</param> /// <param name="vertexPositions">Vertex positions dictionary</param> /// <param name="vertexSizes">Vertex sizes dictionary</param> /// <param name="parameters">Algorithm parameters</param> protected EdgeRoutingAlgorithmBase(TGraph graph, IDictionary <TVertex, Point> vertexPositions, IDictionary <TVertex, Rect> vertexSizes, IEdgeRoutingParameters parameters = null) { Graph = graph; Parameters = parameters; VertexSizes = vertexSizes ?? new Dictionary <TVertex, Rect>(); VertexPositions = vertexPositions ?? new Dictionary <TVertex, Point>(); EdgeRoutes = new Dictionary <TEdge, Point[]>(); }
public EdgeRoutingAlgorithmBase(TGraph graph, IDictionary <TVertex, Point> vertexPositions, IDictionary <TVertex, Rect> vertexSizes, IEdgeRoutingParameters parameters = null) { _graph = graph; _parameters = parameters; VertexSizes = vertexSizes; VertexPositions = vertexPositions; EdgeRoutes = new Dictionary <TEdge, Point[]>(); }
/// <inheritdoc /> public IEdgeRoutingParameters CreateParameters(string algorithmType, IEdgeRoutingParameters parameters) { if (algorithmType is null) { throw new ArgumentNullException(nameof(algorithmType)); } return(new EdgeRoutingParameters()); }
public IEdgeRoutingParameters CreateParameters(string algorithmType, IEdgeRoutingParameters oldParameters) { switch (algorithmType) { case "Bundle": return(CreateNewParameter <BundleEdgeRoutingParameters>(oldParameters)); } return(null); }
public static TParam CreateNewParameter <TParam>(IEdgeRoutingParameters oldParameters) where TParam : class, IEdgeRoutingParameters, new() { var parameters = oldParameters as TParam; if (parameters != null) { return((TParam)parameters.Clone()); } return(new TParam()); }
public BundleEdgeRouting(Rect graphArea, TGraph graph, IDictionary <TVertex, Point> vertexPositions, IDictionary <TVertex, Rect> vertexSizes, IEdgeRoutingParameters parameters = null) : base(graph, vertexPositions, vertexSizes, parameters) { _parameters = parameters; this.AreaRectangle = graphArea; var prm = parameters as BundleEdgeRoutingParameters; if (prm != null) { SubdivisionPoints = prm.SubdivisionPoints; Straightening = prm.Straightening; RepulsionCoefficient = prm.RepulsionCoefficient; Threshold = prm.Threshold; SpringConstant = prm.SpringConstant; UseThreading = prm.UseThreading; RepulseOpposite = prm.RepulseOpposite; Iterations = prm.Iterations; } }
public IEdgeRoutingAlgorithm <TVertex, TEdge, TGraph> CreateAlgorithm(string newAlgorithmType, ILayoutContext <TVertex, TEdge, TGraph> context, IEdgeRoutingParameters parameters) { return(null); }
public void Dispose() { _graph = null; _parameters = null; }
public IExternalEdgeRouting <TVertex, TEdge> CreateEdgeRoutingAlgorithm(EdgeRoutingAlgorithmTypeEnum newAlgorithmType, Rect graphArea, TGraph iGraph, IDictionary <TVertex, Point> positions, IDictionary <TVertex, Rect> rectangles, IEdgeRoutingParameters parameters = null) { //if (Rectangles == null) return null; if (parameters == null) { parameters = CreateEdgeRoutingParameters(newAlgorithmType); } IMutableBidirectionalGraph <TVertex, TEdge> graph = iGraph.CopyToBidirectionalGraph(); graph.RemoveEdgeIf(a => a.SkipProcessing == ProcessingOptionEnum.Exclude); graph.RemoveVertexIf(a => a.SkipProcessing == ProcessingOptionEnum.Exclude); switch (newAlgorithmType) { case EdgeRoutingAlgorithmTypeEnum.SimpleER: return(new SimpleEdgeRouting <TVertex, TEdge, TGraph>((TGraph)graph, positions, rectangles, parameters)); case EdgeRoutingAlgorithmTypeEnum.Bundling: return(new BundleEdgeRouting <TVertex, TEdge, TGraph>(graphArea, (TGraph)graph, positions, rectangles, parameters)); case EdgeRoutingAlgorithmTypeEnum.PathFinder: return(new PathFinderEdgeRouting <TVertex, TEdge, TGraph>((TGraph)graph, positions, rectangles, parameters)); default: return(null); } }
public OrthEr(TGraph graph, IDictionary <TVertex, Point> vertexPositions, IDictionary <TVertex, Rect> vertexSizes, IEdgeRoutingParameters parameters = null) : base(graph, vertexPositions, vertexSizes, parameters) { }
/// <summary> /// Dispose resources /// </summary> public void Dispose() { Graph = null; Parameters = null; }
/// <inheritdoc /> public IEdgeRoutingAlgorithm <TVertex, TEdge, TGraph> CreateAlgorithm(string algorithmType, ILayoutContext <TVertex, TEdge, TGraph> context, IEdgeRoutingParameters parameters) { if (algorithmType is null) { throw new ArgumentNullException(nameof(algorithmType)); } if (context is null) { throw new ArgumentNullException(nameof(context)); } return(null); }
public IExternalEdgeRouting <TVertex, TEdge> CreateEdgeRoutingAlgorithm(EdgeRoutingAlgorithmTypeEnum newAlgorithmType, Rect graphArea, TGraph Graph, IDictionary <TVertex, Point> Positions, IDictionary <TVertex, Rect> Rectangles, IEdgeRoutingParameters parameters = null) { //if (Rectangles == null) return null; if (parameters == null) { parameters = CreateEdgeRoutingParameters(newAlgorithmType); } switch (newAlgorithmType) { case EdgeRoutingAlgorithmTypeEnum.SimpleER: return(new SimpleEdgeRouting <TVertex, TEdge, TGraph>(Graph, Positions, Rectangles, parameters)); case EdgeRoutingAlgorithmTypeEnum.Bundling: return(new BundleEdgeRouting <TVertex, TEdge, TGraph>(graphArea, Graph, Positions, Rectangles, parameters)); case EdgeRoutingAlgorithmTypeEnum.PathFinder: return(new PathFinderEdgeRouting <TVertex, TEdge, TGraph>(Graph, Positions, Rectangles, parameters)); default: return(null); } }
public IEdgeRoutingAlgorithm <TVertex, TEdge, TGraph> CreateAlgorithm(string newAlgorithmType, ILayoutContext <TVertex, TEdge, TGraph> context, IEdgeRoutingParameters parameters) { switch (newAlgorithmType) { case "Bundle": return(new BundleEdgeRoutingAlgorithm <TVertex, TEdge, TGraph>(context.Graph, context.Positions, context.Sizes, parameters as BundleEdgeRoutingParameters)); } return(null); }
public PathFinderEdgeRouting(TGraph graph, IDictionary <TVertex, Point> vertexPositions, IDictionary <TVertex, Rect> vertexSizes, IEdgeRoutingParameters parameters = null) : base(graph, vertexPositions, vertexSizes, parameters) { if (parameters is PathFinderEdgeRoutingParameters) { var prms = parameters as PathFinderEdgeRoutingParameters; _horizontalGs = prms.HorizontalGridSize; _verticalGs = prms.VerticalGridSize; _sideAreaOffset = prms.SideGridOffset; _useDiagonals = prms.UseDiagonals; _pathAlgo = prms.PathFinderAlgorithm; _punishChangeDirection = prms.PunishChangeDirection; _useHeavyDiagonals = prms.UseHeavyDiagonals; _pfHeuristic = prms.Heuristic; _useTieBreaker = prms.UseTieBreaker; } }
public CurvedEr(GraphExample graph, IDictionary <DataVertex, Point> vertexPositions = null, IDictionary <DataVertex, Rect> vertexSizes = null, IEdgeRoutingParameters parameters = null) : base(graph, vertexPositions, vertexSizes, parameters) { var prms = parameters as CurvedErParameters; _curveOffset = prms != null ? prms.VerticalCurveOffset : 20; }
public SimpleEdgeRouting(TGraph graph, IDictionary <TVertex, Point> vertexPositions, IDictionary <TVertex, Rect> vertexSizes, IEdgeRoutingParameters parameters = null) : base(graph, vertexPositions, vertexSizes, parameters) { var erParameters = parameters as SimpleERParameters; if (erParameters != null) { drawback_distance = erParameters.BackStep; side_distance = erParameters.SideStep; } }
public IEdgeRoutingParameters CreateParameters(string algorithmType, IEdgeRoutingParameters oldParameters) { return(null); }