private void SetupLayouts() { // create TreeLayout var treeLayout = new TreeLayout { LayoutOrientation = LayoutOrientation.LeftToRight }; treeLayout.PrependStage(new FixNodeLayoutStage()); layouts.Add(treeLayout); layoutMapper["Tree"] = treeLayout; layoutComboBox.Items.Add("Tree"); // create BalloonLayout var balloonLayout = new BalloonLayout { FromSketchMode = true, CompactnessFactor = 1.0, AllowOverlaps = true }; balloonLayout.PrependStage(new FixNodeLayoutStage()); layouts.Add(balloonLayout); layoutMapper["Balloon"] = balloonLayout; layoutComboBox.Items.Add("Balloon"); // create OrganicLayout var organicLayout = new OrganicLayout { MinimumNodeDistance = 40, Deterministic = true }; organicLayout.PrependStage(new FixNodeLayoutStage()); layouts.Add(organicLayout); layoutMapper["Organic"] = organicLayout; layoutComboBox.Items.Add("Organic"); // create OrthogonalLayout var orthogonalLayout = new OrthogonalLayout(); orthogonalLayout.PrependStage(new FixNodeLayoutStage()); layouts.Add(orthogonalLayout); layoutMapper["Orthogonal"] = orthogonalLayout; layoutComboBox.Items.Add("Orthogonal"); // set it as initial value currentLayout = treeLayout; layoutComboBox.SelectedIndex = 0; }
/// <summary> /// Runs a balloon layout where the hierarchy edges are the tree edges and original edges are bundled. /// </summary> private async Task RunBalloonLayout(IListEnumerable <INode> affectedNodes = null) { // create the balloon layout var layout = new BalloonLayout { IntegratedNodeLabeling = true, NodeLabelingPolicy = NodeLabelingPolicy.RayLikeLeaves, FromSketchMode = true, CompactnessFactor = 0.1, AllowOverlaps = true }; // prepend a TreeReduction stage with the hierarchy edges as tree edges layout.PrependStage(new TreeReductionStage()); var nonTreeEdges = GraphControl.Graph.Edges.Where(e => !aggregationHelper.IsHierarchyEdge(e)).ToList(); // mark all other edges to be bundled var bundleDescriptorMap = new ItemMapping <IEdge, EdgeBundleDescriptor>(); foreach (var nonTreeEdge in nonTreeEdges) { bundleDescriptorMap.Mapper[nonTreeEdge] = new EdgeBundleDescriptor { Bundled = true }; } var treeReductionStageData = new TreeReductionStageData { NonTreeEdges = { Items = nonTreeEdges }, EdgeBundleDescriptors = bundleDescriptorMap }; // create a layout executor that also zooms to all nodes that were affected by the last operation var layoutExecutor = new ZoomToNodesLayoutExecutor(affectedNodes ?? ListEnumerable <INode> .Empty, GraphControl, layout) { Duration = TimeSpan.FromSeconds(0.5), AnimateViewport = true, EasedAnimation = true, LayoutData = treeReductionStageData }; await layoutExecutor.Start(); }