private void CreateOrganic() { if (organic == null) { organic = new OrganicLayout(); organic.PrependStage(new PortCalculator()); } }
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; }
private void ConfigureGrouping() { IOptionItem groupingItem = Handler.GetItemByName("GROUPING.GROUP_LAYOUT_POLICY"); switch ((string)groupingItem.Value) { case IGNORE_GROUPS: preStage = new HideGroupsStage(); organic.PrependStage(preStage); break; case LAYOUT_GROUPS: //do nothing... break; case FIX_GROUP_BOUNDS: IDataProvider groupDP = CurrentLayoutGraph.GetDataProvider(GroupingKeys.GroupDpKey); if (groupDP != null) { groupNodeContentDP = Maps.CreateHashedNodeMap(); foreach (Node node in CurrentLayoutGraph.Nodes) { if (groupDP.GetBool(node)) { groupNodeContentDP.Set(node, GroupNodeMode.FixBounds); } } CurrentLayoutGraph.AddDataProvider(OrganicLayout.GroupNodeModeDpKey, groupNodeContentDP); } break; case FIX_GROUP_CONTENTS: groupDP = CurrentLayoutGraph.GetDataProvider(GroupingKeys.GroupDpKey); if (groupDP != null) { groupNodeContentDP = Maps.CreateHashedNodeMap(); foreach (Node node in CurrentLayoutGraph.Nodes) { if (groupDP.GetBool(node)) { groupNodeContentDP.Set(node, GroupNodeMode.FixContents); } } CurrentLayoutGraph.AddDataProvider(OrganicLayout.GroupNodeModeDpKey, groupNodeContentDP); } break; } }
/// <summary> /// Lays out the graph with nodes that are laid out incrementally. /// </summary> /// <param name="incrementalNodes">Nodes that should be inserted into the graph incrementally.</param> private async Task ApplyLayout(HashSet <INode> incrementalNodes) { toolStrip.Enabled = false; // We'll use an OrganicLayout with OrganicEdgeRouter to get a pleasing image for most databases var layout = new OrganicLayout { NodeEdgeOverlapAvoided = true, NodeOverlapsAllowed = false, PreferredEdgeLength = 180, MinimumNodeDistance = 80, StarSubstructureStyle = StarSubstructureStyle.Radial, StarSubstructureSize = 3, ConsiderNodeSizes = true, CycleSubstructureStyle = CycleSubstructureStyle.Circular, StarSubstructureTypeSeparation = false, LabelingEnabled = true, ParallelEdgeRouterEnabled = true, Scope = incrementalNodes.Count > 0 ? Scope.MainlySubset : Scope.All }; layout.PrependStage(new OrganicEdgeRouter() { ConsiderExistingBends = false, KeepExistingBends = false, EdgeNodeOverlapAllowed = false, RouteAllEdges = false, MinimumDistance = 10 }); // GenericLabeling ensures that labels don't overlap layout.PrependStage(new GenericLabeling { RemoveNodeOverlaps = true }); // CurveFittingLayoutStage adds Bezier control points so we can use BezierEdgeStyle to render the edges layout.PrependStage(new CurveFittingLayoutStage()); var layoutData = new CompositeLayoutData( new OrganicLayoutData { NodeTypes = { Delegate = node => ((INeo4jNode)node.Tag).Labels[0] }, AffectedNodes = { Source = incrementalNodes }, }, new LabelingData { EdgeLabelPreferredPlacement = { Constant = new PreferredPlacementDescriptor { AngleReference = LabelAngleReferences.RelativeToEdgeFlow, PlaceAlongEdge = LabelPlacements.AtSource, SideOfEdge = LabelPlacements.RightOfEdge | LabelPlacements.LeftOfEdge } } } ); await graphControl.MorphLayout(layout, TimeSpan.FromMilliseconds(700), layoutData); toolStrip.Enabled = true; }