/// <summary> /// Performs the actual layout algorithm. /// </summary> /// <param name="graph">The object containing the graph data</param> /// <param name="rootNode">Root node</param> protected override void PerformLayout(GraphMapData graph, INode rootNode) { BidirectionalGraph<string, WeightedEdge<string>> bGraph = GraphSharpUtility.GetBidirectionalGraph(graph); IDictionary<string, Vector> nodePositions = GraphSharpUtility.GetNodePositions(graph); IDictionary<string, Size> nodeSizes = GraphSharpUtility.GetNodeSizes(graph); SimpleTreeLayoutParameters simpleTreeLayoutParameters = new SimpleTreeLayoutParameters(); SimpleTreeLayoutAlgorithm<string, WeightedEdge<string>, BidirectionalGraph<string, WeightedEdge<string>>> simpleTreeLayoutAlgorithm = new SimpleTreeLayoutAlgorithm<string, WeightedEdge<string>, BidirectionalGraph<string, WeightedEdge<string>>>(bGraph, nodePositions, nodeSizes, simpleTreeLayoutParameters); simpleTreeLayoutAlgorithm.Compute(); GraphSharpUtility.SetNodePositions(graph, simpleTreeLayoutAlgorithm.VertexPositions); }
public SimpleTreeLayoutAlgorithm(TGraph visitedGraph, IDictionary <TVertex, Point> vertexPositions, IDictionary <TVertex, Size> vertexSizes, SimpleTreeLayoutParameters parameters) : base(visitedGraph, vertexPositions, parameters) { _sizes = new Dictionary <TVertex, Size>(vertexSizes); }
/// <summary> /// Initializes a new instance of the <see cref="DatasetGraphModel"/> class. /// </summary> /// <param name="context">The context that is used to execute actions on the UI thread.</param> /// <param name="facade">The project that holds the graph of datasets.</param> /// <param name="datasetModelBuilder">The function that builds <see cref="DatasetModel"/> objects.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="context"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="facade"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="datasetModelBuilder"/> is <see langword="null" />. /// </exception> public DatasetGraphModel( IContextAware context, ProjectFacade facade, Func<DatasetFacade, DatasetModel> datasetModelBuilder) : base(context) { { Enforce.Argument(() => facade); } m_Project = facade; m_Project.OnDatasetCreated += (s, e) => AddDatasetToGraph(); m_Project.OnDatasetDeleted += (s, e) => RemoveDatasetFromGraph(); m_DatasetModelBuilder = datasetModelBuilder; LayoutType = "Tree"; LayoutParameters = new SimpleTreeLayoutParameters { LayerGap = 250, VertexGap = 250, Direction = LayoutDirection.TopToBottom, }; ReloadProject(); }
public SimpleTreeLayoutAlgorithm(TGraph visitedGraph, IDictionary <TVertex, Point> vertexPositions, IDictionary <TVertex, Size> vertexSizes, SimpleTreeLayoutParameters parameters) : base(visitedGraph, vertexPositions, parameters) { //Contract.Requires( vertexSizes != null ); //Contract.Requires( visitedGraph.Vertices.All( v => vertexSizes.ContainsKey( v ) ) ); sizes = new Dictionary <TVertex, Size>(vertexSizes); }