///<inheritdoc/> protected override void PerformPreLayout() { String selGroupPolicy = (String)Handler.GetValue(GROUPING, GROUP_LAYOUT_POLICY); String edgeLabelingName = (String)Handler.GetValue(LABELING, EDGE_LABELING); MultiStageLayout multiStageLayout = LayoutAlgorithm as MultiStageLayout; IDataProvider upwardDP = null; if ((upwardDP = CurrentLayoutGraph.GetDataProvider(OrthogonalLayout.DirectedEdgeDpKey)) == null) { //determine upward edges if not already marked. if ((bool)Handler.GetValue(EDGES, DRAW_SELECTED_EDGES_UPWARDS)) { CurrentLayoutGraph.AddDataProvider(OrthogonalLayout.DirectedEdgeDpKey, upwardDP = new UpwardEdgeDP(this)); } } // if ((bool)Handler.GetValue(EDGES, UPWARD_EDGE_BUS_ROUTING) && upwardDP != null) { // sgDPOrig = CurrentLayoutGraph.GetDataProvider(PortConstraintKeys.SourceGroupIdDpKey); // tgDPOrig = CurrentLayoutGraph.GetDataProvider(PortConstraintKeys.TargetGroupIdDpKey); // sourceGroupMap = CurrentLayoutGraph.CreateEdgeMap(); // tgMap = CurrentLayoutGraph.CreateEdgeMap(); // CurrentLayoutGraph.AddDataProvider(PortConstraintKeys.SourceGroupIdDpKey, sourceGroupMap); // CurrentLayoutGraph.AddDataProvider(PortConstraintKeys.TargetGroupIdDpKey, tgMap); // AutoGroupEdges(CurrentLayoutGraph, sourceGroupMap, tgMap, upwardDP); // } if ((selGroupPolicy != IGNORE_GROUPS) && ContainsGroupNodes()) { multiStageLayout.HideGroupsStageEnabled = false; if (FIX_GROUPS == selGroupPolicy) { var fgl = new FixGroupLayoutStage(); fgl.InterEdgeRoutingStyle = InterEdgeRoutingStyle.Orthogonal; if (multiStageLayout != null) { multiStageLayout.PrependStage(fgl); preStage = fgl; } } } else { multiStageLayout.HideGroupsStageEnabled = true; } if (edgeLabelingName == GENERIC && multiStageLayout != null) { var la = new GenericLabeling(); la.MaximumDuration = 0; la.PlaceNodeLabels = false; la.PlaceEdgeLabels = true; la.AutoFlipping = true; la.ProfitModel = new SimpleProfitModel(); multiStageLayout.Labeling = la; } }
///<inheritdoc/> protected override void ConfigureLayout() { string style = (string)Handler.GetValue(GENERAL, LAYOUT_STYLE); if (style.Equals(DIRECTED)) { multiStageLayout = ConfigureDirectedRouter(); } else if (style.Equals(AR)) { multiStageLayout = ConfigureARRouter(); } ((ComponentLayout)multiStageLayout.ComponentLayout).Style = ComponentArrangementStyles.MultiRows; multiStageLayout.SubgraphLayoutEnabled = (bool)Handler.GetValue(GENERAL, ACT_ON_SELECTION_ONLY); LayoutAlgorithm = multiStageLayout; }
///<inheritdoc/> protected override void ConfigureLayout() { BalloonLayout balloon = new BalloonLayout(); ((ComponentLayout)balloon.ComponentLayout).Style = ComponentArrangementStyles.MultiRows; string rootNodePolicyChoice = (string)Handler.GetValue(GENERAL, ROOT_NODE_POLICY); balloon.RootNodePolicy = enumRoot[rootNodePolicyChoice]; balloon.PreferredChildWedge = (int)Handler.GetValue(GENERAL, PREFERRED_CHILD_WEDGE); balloon.PreferredRootWedge = (int)Handler.GetValue(GENERAL, PREFERRED_ROOT_WEDGE); balloon.MinimumEdgeLength = (int)Handler.GetValue(GENERAL, MINIMAL_EDGE_LENGTH); balloon.CompactnessFactor = (double)Handler.GetValue(GENERAL, COMPACTNESS_FACTOR); balloon.AllowOverlaps = (bool)Handler.GetValue(GENERAL, ALLOW_OVERLAPS); balloon.FromSketchMode = (bool)Handler.GetValue(GENERAL, BALLOON_FROM_SKETCH); balloon.ChainStraighteningMode = (bool)Handler.GetValue(GENERAL, STRAIGHTEN_CHAINS); balloon.InterleavedMode = (bool)Handler.GetValue(GENERAL, PLACE_CHILDREN_INTERLEAVED) ? InterleavedMode.AllNodes : InterleavedMode.Off; balloon.IntegratedEdgeLabeling = (bool)Handler.GetValue(LABELING, INTEGRATED_EDGE_LABELING); switch ((string)Handler.GetValue(LABELING, NODE_LABELING_STYLE)) { case NODE_LABELING_STYLE_RAYLIKE_LEAVES: balloon.IntegratedNodeLabeling = true; balloon.NodeLabelingPolicy = NodeLabelingPolicy.RayLikeLeaves; break; case NODE_LABELING_STYLE_CONSIDER_CURRENT_POSITION: balloon.ConsiderNodeLabels = true; break; case NODE_LABELING_STYLE_HORIZONTAL: balloon.IntegratedEdgeLabeling = true; balloon.NodeLabelingPolicy = NodeLabelingPolicy.Horizontal; break; } balloon.SubgraphLayoutEnabled = (bool)Handler.GetValue(GENERAL, ACT_ON_SELECTION_ONLY); multiStageLayout = balloon; LayoutAlgorithm = balloon; }
///<inheritdoc/> protected override void PerformPostLayout() { MultiStageLayout multiStageLayout = LayoutAlgorithm as MultiStageLayout; if ((preStage != null) && (multiStageLayout != null)) { multiStageLayout.RemoveStage(preStage); } if (sgDPOrig != null) { CurrentLayoutGraph.AddDataProvider(PortConstraintKeys.SourceGroupIdDpKey, sgDPOrig); sgDPOrig = null; } if (tgDPOrig != null) { CurrentLayoutGraph.AddDataProvider(PortConstraintKeys.TargetGroupIdDpKey, tgDPOrig); tgDPOrig = null; } if (sourceGroupMap != null) { CurrentLayoutGraph.DisposeEdgeMap(sourceGroupMap); sourceGroupMap = null; } if (tgMap != null) { CurrentLayoutGraph.DisposeEdgeMap(tgMap); tgMap = null; } CurrentLayoutGraph.RemoveDataProvider(OrthogonalLayout.DirectedEdgeDpKey); IGraph graph = Context.Lookup <IGraph>(); if (graph != null) { ClearPreferredLabelPlacement(graph); } }
private static void DisableAutoFlipping(MultiStageLayout multiStageLayout) { var labelLayoutTranslator = (LabelLayoutTranslator)multiStageLayout.Labeling; labelLayoutTranslator.AutoFlipping = false; }
/// <inheritdoc /> protected override ILayoutAlgorithm CreateConfiguredLayout(GraphControl graphControl) { var layout = new BalloonLayout(); ((ComponentLayout)layout.ComponentLayout).Style = ComponentArrangementStyles.MultiRows; layout.RootNodePolicy = RootNodePolicyItem; layout.PreferredChildWedge = PreferredChildWedgeItem; layout.PreferredRootWedge = PreferredRootWedgeItem; layout.MinimumEdgeLength = MinimumEdgeLengthItem; layout.CompactnessFactor = 1 - CompactnessFactorItem; layout.AllowOverlaps = AllowOverlapsItem; layout.FromSketchMode = FromSketchItem; layout.ChainStraighteningMode = StraightenChainsItem; layout.InterleavedMode = PlaceChildrenInterleavedItem ? InterleavedMode.AllNodes : InterleavedMode.Off; switch (NodeLabelingStyleItem) { case EnumNodeLabelingPolicies.None: layout.ConsiderNodeLabels = false; break; case EnumNodeLabelingPolicies.RaylikeLeaves: layout.IntegratedNodeLabeling = true; layout.NodeLabelingPolicy = NodeLabelingPolicy.RayLikeLeaves; break; case EnumNodeLabelingPolicies.ConsiderCurrentPosition: layout.ConsiderNodeLabels = true; break; case EnumNodeLabelingPolicies.Horizontal: layout.IntegratedNodeLabeling = true; layout.NodeLabelingPolicy = NodeLabelingPolicy.Horizontal; break; default: layout.ConsiderNodeLabels = false; break; } // configures tree reduction stage and non-tree edge routing. layout.SubgraphLayoutEnabled = ActOnSelectionOnlyItem; MultiStageLayout multiStageLayout = layout; var treeReductionStage = new TreeReductionStage(); multiStageLayout.AppendStage(treeReductionStage); if (RoutingStyleForNonTreeEdgesItem == EnumRoute.Organic) { var organic = new OrganicEdgeRouter(); treeReductionStage.NonTreeEdgeRouter = organic; treeReductionStage.NonTreeEdgeSelectionKey = OrganicEdgeRouter.AffectedEdgesDpKey; } else if (RoutingStyleForNonTreeEdgesItem == EnumRoute.Orthogonal) { var edgeRouter = new EdgeRouter { Rerouting = true, Scope = Scope.RouteAffectedEdges }; treeReductionStage.NonTreeEdgeSelectionKey = edgeRouter.AffectedEdgesDpKey; treeReductionStage.NonTreeEdgeRouter = edgeRouter; } else if (RoutingStyleForNonTreeEdgesItem == EnumRoute.StraightLine) { treeReductionStage.NonTreeEdgeRouter = treeReductionStage.CreateStraightLineRouter(); } else if (RoutingStyleForNonTreeEdgesItem == EnumRoute.Bundled) { var ebc = treeReductionStage.EdgeBundling; var bundleDescriptor = new EdgeBundleDescriptor { Bundled = true }; ebc.BundlingStrength = EdgeBundlingStrengthItem; ebc.DefaultBundleDescriptor = bundleDescriptor; } if (EdgeLabelingItem == EnumEdgeLabeling.Generic) { layout.IntegratedEdgeLabeling = false; var genericLabeling = new GenericLabeling { PlaceEdgeLabels = true, PlaceNodeLabels = false, ReduceAmbiguity = ReduceAmbiguityItem }; layout.LabelingEnabled = true; layout.Labeling = genericLabeling; } else if (EdgeLabelingItem == EnumEdgeLabeling.Integrated) { layout.IntegratedEdgeLabeling = true; treeReductionStage.NonTreeEdgeLabelingAlgorithm = new GenericLabeling(); } if (NodeLabelingStyleItem == EnumNodeLabelingPolicies.RaylikeLeaves || NodeLabelingStyleItem == EnumNodeLabelingPolicies.Horizontal) { foreach (var label in graphControl.Graph.GetNodeLabels()) { graphControl.Graph.SetLabelLayoutParameter(label, FreeNodeLabelModel.Instance.FindBestParameter(label, FreeNodeLabelModel.Instance, label.GetLayout())); } } return(layout); }