/// <inheritdoc /> protected override ILayoutAlgorithm CreateConfiguredLayout(GraphControl graphControl) { MultiStageLayout layout; switch (LayoutStyleItem) { default: case EnumStyle.Default: layout = ConfigureDefaultLayout(); break; case EnumStyle.Classic: layout = ConfigureClassicLayout(); break; case EnumStyle.HorizontalVertical: layout = new TreeLayout(); break; case EnumStyle.Compact: layout = ConfigureCompactLayout(graphControl); break; } layout.ParallelEdgeRouterEnabled = false; ((ComponentLayout)layout.ComponentLayout).Style = ComponentArrangementStyles.MultiRows; layout.SubgraphLayoutEnabled = ActOnSelectionOnlyItem; layout.PrependStage(CreateTreeReductionStage()); var placeLabels = EdgeLabelingItem == EnumEdgeLabeling.Integrated || EdgeLabelingItem == EnumEdgeLabeling.Generic; // required to prevent WrongGraphStructure exception which may be thrown by TreeLayout if there are edges // between group nodes layout.PrependStage(new HandleEdgesBetweenGroupsStage(placeLabels)); if (EdgeLabelingItem == EnumEdgeLabeling.Generic) { layout.LabelingEnabled = true; layout.Labeling = new GenericLabeling { PlaceEdgeLabels = true, PlaceNodeLabels = false, ReduceAmbiguity = ReduceAmbiguityItem }; } AddPreferredPlacementDescriptor(graphControl.Graph, LabelPlacementAlongEdgeItem, LabelPlacementSideOfEdgeItem, LabelPlacementOrientationItem, LabelPlacementDistanceItem); return(layout); }
/// <summary> /// Creates and configures the <see cref="TreeLayout"/> and the <see cref="TreeLayoutData"/> /// such that node types are considered. /// </summary> private Sample CreateTreeSample() { // create a tree layout including a reduction stage to support non-tree graphs too var layout = new TreeLayout { DefaultNodePlacer = new CompactNodePlacer() }; var edgeRouter = new EdgeRouter { Scope = Scope.RouteAffectedEdges }; var reductionStage = new TreeReductionStage { NonTreeEdgeRouter = edgeRouter, NonTreeEdgeSelectionKey = edgeRouter.AffectedEdgesDpKey }; layout.PrependStage(reductionStage); // the node types are specified as delegate on the nodeTypes property of the layout data var layoutData = new TreeLayoutData { NodeTypes = { Delegate = node => GetNodeType(node) } }; return(new Sample { Name = "Tree", File = "tree", Layout = layout, LayoutData = layoutData, IsDirected = true }); }
private static ILayoutAlgorithm CreateTreeLayout() { var reductionStage = new TreeReductionStage { NonTreeEdgeRouter = new NonTreeEdgeRouterStage(), NonTreeEdgeSelectionKey = LayoutKeys.AffectedEdgesDpKey }; var treeLayout = new TreeLayout { IntegratedEdgeLabeling = true }; treeLayout.PrependStage(reductionStage); DisableAutoFlipping(treeLayout); return(treeLayout); }
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; }