/// <summary> /// Setup default values for various configuration parameters. /// </summary> public PolylineEdgeRouterConfig() { var router = new EdgeRouter(); ScopeItem = router.Scope; OptimizationStrategyItem = EnumStrategies.Balanced; MonotonicRestrictionItem = EnumMonotonyFlags.None; EnableReroutingItem = router.Rerouting; MaximumDurationItem = 30; var descriptor = router.DefaultEdgeLayoutDescriptor; MinimumEdgeToEdgeDistanceItem = descriptor.MinimumEdgeToEdgeDistance; MinimumNodeToEdgeDistanceItem = router.MinimumNodeToEdgeDistance; MinimumNodeCornerDistanceItem = descriptor.MinimumNodeCornerDistance; MinimumFirstSegmentLengthItem = descriptor.MinimumFirstSegmentLength; MinimumLastSegmentLengthItem = descriptor.MinimumLastSegmentLength; var grid = router.Grid; GridEnabledItem = grid != null; GridSpacingItem = grid != null ? grid.Spacing : 10; EdgeRoutingStyleItem = EdgeRoutingStyle.Orthogonal; PreferredOctilinearSegmentLengthItem = router.DefaultEdgeLayoutDescriptor.PreferredOctilinearSegmentLength; MaximumOctilinearSegmentRatioItem = router.DefaultEdgeLayoutDescriptor.MaximumOctilinearSegmentRatio; ConsiderNodeLabelsItem = router.ConsiderNodeLabels; ConsiderEdgeLabelsItem = router.ConsiderEdgeLabels; EdgeLabelingItem = EnumEdgeLabeling.None; LabelPlacementAlongEdgeItem = EnumLabelPlacementAlongEdge.Centered; LabelPlacementSideOfEdgeItem = EnumLabelPlacementSideOfEdge.OnEdge; LabelPlacementOrientationItem = EnumLabelPlacementOrientation.Horizontal; LabelPlacementDistanceItem = 10; }
/// <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 }); }
/// <summary> /// Configures the tree reduction stage that will handle edges that do not belong to the tree. /// </summary> private TreeReductionStage CreateTreeReductionStage() { var reductionStage = new TreeReductionStage(); if (EdgeLabelingItem == EnumEdgeLabeling.Integrated) { reductionStage.NonTreeEdgeLabelingAlgorithm = new GenericLabeling(); } reductionStage.MultiParentAllowed = (LayoutStyleItem == EnumStyle.Classic && !EnforceGlobalLayeringItem && ChildPlacementPolicyItem != LeafPlacement.AllLeavesOnSameLayer) || (LayoutStyleItem == EnumStyle.Default && (NodePlacerItem == EnumNodePlacer.Default || NodePlacerItem == EnumNodePlacer.Bus || NodePlacerItem == EnumNodePlacer.LeftRight || NodePlacerItem == EnumNodePlacer.Dendrogram) && AllowMultiParentsItem); if (RoutingStyleForNonTreeEdgesItem == EnumRoute.Organic) { reductionStage.NonTreeEdgeRouter = new OrganicEdgeRouter(); reductionStage.NonTreeEdgeSelectionKey = OrganicEdgeRouter.AffectedEdgesDpKey; } else if (RoutingStyleForNonTreeEdgesItem == EnumRoute.Orthogonal) { var edgeRouter = new EdgeRouter { Rerouting = true, Scope = Scope.RouteAffectedEdges }; reductionStage.NonTreeEdgeRouter = edgeRouter; reductionStage.NonTreeEdgeSelectionKey = edgeRouter.AffectedEdgesDpKey; } else if (RoutingStyleForNonTreeEdgesItem == EnumRoute.StraightLine) { reductionStage.NonTreeEdgeRouter = reductionStage.CreateStraightLineRouter(); } else if (RoutingStyleForNonTreeEdgesItem == EnumRoute.Bundled) { var ebc = reductionStage.EdgeBundling; ebc.BundlingStrength = EdgeBundlingStrengthItem; ebc.DefaultBundleDescriptor = new EdgeBundleDescriptor { Bundled = true }; } return reductionStage; }
/// <summary> /// Setup default values for various configuration parameters. /// </summary> public PolylineEdgeRouterCustomConfig() { var router = new EdgeRouter(); ScopeItem = router.Scope; OptimizationStrategyItem = EnumStrategies.Balanced; MonotonicRestrictionItem = EnumMonotonyFlags.None; EnableReroutingItem = router.Rerouting; MaximumDurationItem = 30; var descriptor = router.DefaultEdgeLayoutDescriptor; MinimumEdgeToEdgeDistanceItem = descriptor.MinimumEdgeToEdgeDistance; MinimumNodeToEdgeDistanceItem = router.MinimumNodeToEdgeDistance; MinimumNodeCornerDistanceItem = descriptor.MinimumNodeCornerDistance; MinimumFirstSegmentLengthItem = descriptor.MinimumFirstSegmentLength; MinimumLastSegmentLengthItem = descriptor.MinimumLastSegmentLength; var grid = router.Grid; GridEnabledItem = grid != null; GridSpacingItem = grid != null ? grid.Spacing : 10; EnablePolylineRoutingItem = true; PreferredPolylineSegmentLengthItem = router.PreferredPolylineSegmentLength; }
/// <summary> /// Gets the layout algorithm selected by the user. /// </summary> /// <returns></returns> private ILayoutAlgorithm GetLayoutAlgorithm() { var graph = graphControl.Graph; var item = layoutChooserBox.SelectedItem as ComboBoxItem; var layoutName = item != null ? item.Tag as String: null; ILayoutAlgorithm layout = new HierarchicLayout(); if (layoutName != null) { if (layoutName == "hierarchic") { layout = new HierarchicLayout(); } else if (layoutName == "organic") { layout = new OrganicLayout { PreferredEdgeLength = 1.5 * Math.Max(graph.NodeDefaults.Size.Width, graph.NodeDefaults.Size.Height) }; } else if (layoutName == "orthogonal") { layout = new OrthogonalLayout(); } else if (layoutName == "circular") { layout = new CircularLayout(); } else if (layoutName == "tree") { layout = new TreeReductionStage(new TreeLayout()) { NonTreeEdgeRouter = new OrganicEdgeRouter() }; } else if (layoutName == "balloon") { layout = new TreeReductionStage(new BalloonLayout()) { NonTreeEdgeRouter = new OrganicEdgeRouter() }; } else if (layoutName == "radial") { layout = new RadialLayout(); } else if (layoutName == "router-polyline") { layout = new EdgeRouter(); } else if (layoutName == "router-organic") { layout = new OrganicEdgeRouter { EdgeNodeOverlapAllowed = false }; } } return(layout); }
/// <summary> /// Gets the layout algorithm selected by the user. /// </summary> /// <returns></returns> private ILayoutAlgorithm GetLayoutAlgorithm() { var graph = graphControl.Graph; var layoutName = layoutBox.SelectedItem as string; ILayoutAlgorithm layout = new HierarchicLayout(); if (layoutName != null) { if (layoutName == "Layout: Hierarchic") { layout = new HierarchicLayout(); } else if (layoutName == "Layout: Organic") { layout = new OrganicLayout { PreferredEdgeLength = 1.5 * Math.Max(graph.NodeDefaults.Size.Width, graph.NodeDefaults.Size.Height) }; } else if (layoutName == "Layout: Orthogonal") { layout = new OrthogonalLayout(); } else if (layoutName == "Layout: Circular") { layout = new CircularLayout(); } else if (layoutName == "Layout: Tree") { layout = new TreeReductionStage(new TreeLayout()) { NonTreeEdgeRouter = new OrganicEdgeRouter() }; } else if (layoutName == "Layout: Balloon") { layout = new TreeReductionStage(new BalloonLayout()) { NonTreeEdgeRouter = new OrganicEdgeRouter() }; } else if (layoutName == "Layout: Radial") { layout = new RadialLayout(); } else if (layoutName == "Routing: Polyline") { layout = new EdgeRouter(); } else if (layoutName == "Routing: Organic") { layout = new OrganicEdgeRouter { EdgeNodeOverlapAllowed = false }; } } return(layout); }
private void CreateRouter() { if (router != null) { return; } router = new EdgeRouter(); //ConfigureLayout(); }
/// <inheritdoc /> protected override ILayoutAlgorithm CreateConfiguredLayout(GraphControl graphControl) { var router = new EdgeRouter(); router.Scope = ScopeItem; router.MinimumNodeToEdgeDistance = MinimumNodeToEdgeDistanceItem; if (GridEnabledItem) { router.Grid = new Grid(0, 0, GridSpacingItem); } else { router.Grid = null; } router.ConsiderNodeLabels = ConsiderNodeLabelsItem; router.ConsiderEdgeLabels = ConsiderEdgeLabelsItem; router.Rerouting = EnableReroutingItem; // Note that CreateConfiguredLayoutData replaces the settings on the DefaultEdgeLayoutDescriptor // by providing a custom one for each edge. router.DefaultEdgeLayoutDescriptor.RoutingStyle = EdgeRoutingStyleItem; router.DefaultEdgeLayoutDescriptor.PreferredOctilinearSegmentLength = PreferredOctilinearSegmentLengthItem; router.DefaultEdgeLayoutDescriptor.MaximumOctilinearSegmentRatio = MaximumOctilinearSegmentRatioItem; router.DefaultEdgeLayoutDescriptor.SourceCurveConnectionStyle = SourceConnectionStyleItem; router.DefaultEdgeLayoutDescriptor.TargetCurveConnectionStyle = TargetConnectionStyleItem; router.MaximumDuration = MaximumDurationItem * 1000; var layout = new SequentialLayout(); layout.AppendLayout(router); if (EdgeLabelingItem == EnumEdgeLabeling.None) { router.IntegratedEdgeLabeling = false; } else if (EdgeLabelingItem == EnumEdgeLabeling.Integrated) { router.IntegratedEdgeLabeling = true; } else if (EdgeLabelingItem == EnumEdgeLabeling.Generic) { var genericLabeling = new GenericLabeling(); genericLabeling.PlaceEdgeLabels = true; genericLabeling.PlaceNodeLabels = false; genericLabeling.ReduceAmbiguity = ReduceAmbiguityItem; layout.AppendLayout(genericLabeling); } AddPreferredPlacementDescriptor(graphControl.Graph, LabelPlacementAlongEdgeItem, LabelPlacementSideOfEdgeItem, LabelPlacementOrientationItem, LabelPlacementDistanceItem); return(layout); }
public NonTreeEdgeRouterStage() { var polylineRouter = new EdgeRouter { PolylineRouting = true, Rerouting = true }; polylineRouter.DefaultEdgeLayoutDescriptor.PenaltySettings.BendPenalty = 3; polylineRouter.DefaultEdgeLayoutDescriptor.PenaltySettings.EdgeCrossingPenalty = 5; this.nonTreeEdgeRouter = polylineRouter; this.nonTreeEdgeLabelLayout = CreateFastLabeling(); }
/// <summary> /// Setup default values for various configuration parameters. /// </summary> public PolylineEdgeRouterConfig() { var router = new EdgeRouter(); ScopeItem = router.Scope; OptimizationStrategyItem = EnumStrategies.Balanced; MonotonicRestrictionItem = EnumMonotonyFlags.None; EnableReroutingItem = router.Rerouting; MaximumDurationItem = 30; var descriptor = router.DefaultEdgeLayoutDescriptor; MinimumEdgeToEdgeDistanceItem = descriptor.MinimumEdgeToEdgeDistance; MinimumNodeToEdgeDistanceItem = router.MinimumNodeToEdgeDistance; MinimumNodeCornerDistanceItem = descriptor.MinimumNodeCornerDistance; MinimumFirstSegmentLengthItem = descriptor.MinimumFirstSegmentLength; MinimumLastSegmentLengthItem = descriptor.MinimumLastSegmentLength; RoutingPolicyItem = descriptor.RoutingPolicy; var grid = router.Grid; GridEnabledItem = grid != null; GridSpacingItem = grid != null ? grid.Spacing : 10; EdgeRoutingStyleItem = EdgeRoutingStyle.Orthogonal; PreferredOctilinearSegmentLengthItem = router.DefaultEdgeLayoutDescriptor.PreferredOctilinearSegmentLength; PreferredPolylineSegmentRatioItem = router.DefaultEdgeLayoutDescriptor.MaximumOctilinearSegmentRatio; SourceConnectionStyleItem = descriptor.SourceCurveConnectionStyle; TargetConnectionStyleItem = descriptor.TargetCurveConnectionStyle; CurveUTurnSymmetryItem = descriptor.CurveUTurnSymmetry; CurveShortcutsItem = descriptor.CurveShortcuts; PortSidesItem = PortSides.Any; ConsiderNodeLabelsItem = router.ConsiderNodeLabels; ConsiderEdgeLabelsItem = router.ConsiderEdgeLabels; EdgeLabelingItem = EnumEdgeLabeling.None; LabelPlacementAlongEdgeItem = EnumLabelPlacementAlongEdge.Centered; LabelPlacementSideOfEdgeItem = EnumLabelPlacementSideOfEdge.OnEdge; LabelPlacementOrientationItem = EnumLabelPlacementOrientation.Horizontal; LabelPlacementDistanceItem = 10; AutomaticEdgeGroupingItem = true; MinimumBackboneSegmentLengthItem = 100; AllowMultipleBackboneSegmentsItem = true; }
/// <summary> /// configures tree reduction state and non-tree edge routing. /// </summary> protected override void PerformPreLayout() { if ((bool)Handler.GetValue(GENERAL, ALLOW_NON_TREE_EDGES)) { additionalStage = new TreeReductionStage(); multiStageLayout.AppendStage(additionalStage); string routingStyleChoice = (string)Handler.GetValue(GENERAL, ROUTING_STYLE_FOR_NON_TREE_EDGES); switch (routingStyleChoice) { case ROUTE_ORGANIC: OrganicEdgeRouter organic = new OrganicEdgeRouter(); additionalStage.NonTreeEdgeRouter = organic; additionalStage.NonTreeEdgeSelectionKey = OrganicEdgeRouter.AffectedEdgesDpKey; break; case ROUTE_ORTHOGONAL: EdgeRouter orthogonal = new EdgeRouter { Rerouting = true, Scope = Scope.RouteAffectedEdges }; additionalStage.NonTreeEdgeSelectionKey = orthogonal.AffectedEdgesDpKey; additionalStage.NonTreeEdgeRouter = orthogonal; break; case ROUTE_STRAIGHTLINE: additionalStage.NonTreeEdgeRouter = additionalStage.CreateStraightLineRouter(); break; case ROUTE_BUNDLED: EdgeBundling ebc = additionalStage.EdgeBundling; EdgeBundleDescriptor descriptor = new EdgeBundleDescriptor(); descriptor.Bundled = true; ebc.DefaultBundleDescriptor = descriptor; ebc.BundlingStrength = (double)Handler.GetValue(GENERAL, EDGE_BUNDLING_STRENGTH); // Sets a new straight-line router in case some edges are not bundled, e.g. self-loops OrganicEdgeRouter oer = new OrganicEdgeRouter(); additionalStage.NonTreeEdgeRouter = oer; additionalStage.NonTreeEdgeSelectionKey = OrganicEdgeRouter.AffectedEdgesDpKey; break; } } }
/// <summary> /// Configures the tree reduction stage that will handle edges that do not belong to the tree. /// </summary> private TreeReductionStage CreateTreeReductionStage() { var reductionStage = new TreeReductionStage(); if (EdgeLabelingItem == EnumEdgeLabeling.Integrated) { reductionStage.NonTreeEdgeLabelingAlgorithm = new GenericLabeling(); } reductionStage.MultiParentAllowed = (NodePlacerItem == EnumNodePlacer.Default || NodePlacerItem == EnumNodePlacer.Bus || NodePlacerItem == EnumNodePlacer.LeftRight || NodePlacerItem == EnumNodePlacer.Dendrogram) && AllowMultiParentsItem; if (RoutingStyleForNonTreeEdgesItem == EnumRoute.Organic) { reductionStage.NonTreeEdgeRouter = new OrganicEdgeRouter(); reductionStage.NonTreeEdgeSelectionKey = OrganicEdgeRouter.AffectedEdgesDpKey; } else if (RoutingStyleForNonTreeEdgesItem == EnumRoute.Orthogonal) { var edgeRouter = new EdgeRouter { Rerouting = true, Scope = Scope.RouteAffectedEdges }; reductionStage.NonTreeEdgeRouter = edgeRouter; reductionStage.NonTreeEdgeSelectionKey = edgeRouter.AffectedEdgesDpKey; } else if (RoutingStyleForNonTreeEdgesItem == EnumRoute.StraightLine) { reductionStage.NonTreeEdgeRouter = reductionStage.CreateStraightLineRouter(); } else if (RoutingStyleForNonTreeEdgesItem == EnumRoute.Bundled) { var ebc = reductionStage.EdgeBundling; ebc.BundlingStrength = EdgeBundlingStrengthItem; ebc.DefaultBundleDescriptor = new EdgeBundleDescriptor { Bundled = true }; } return(reductionStage); }
public override void Justify(TItem target, IShape tshape) { if ((target is IVisualEdge) && (tshape is IEdgeShape)) { var edge = (IVisualEdge)target; EdgeRouter.RouteEdge((TEdge)edge); var shape = (IEdgeShape)tshape; var rootShape = edge.Root.Shape; var leafShape = edge.Leaf.Shape; if (rootShape != null) { shape.Start = rootShape[edge.RootAnchor]; } if (leafShape != null) { shape.End = leafShape[edge.LeafAnchor]; } } else { AdjustSize(target, tshape); } }
/// <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); }
/// <inheritdoc /> protected override ILayoutAlgorithm CreateConfiguredLayout(GraphControl graphControl) { var layout = new SeriesParallelLayout(); layout.GeneralGraphHandling = true; layout.LayoutOrientation = OrientationItem; layout.VerticalAlignment = VerticalAlignmentItem; layout.FromSketchMode = UseDrawingAsSketchItem; layout.MinimumNodeToNodeDistance = MinimumNodeToNodeDistanceItem; layout.MinimumNodeToEdgeDistance = MinimumNodeToEdgeDistanceItem; layout.MinimumEdgeToEdgeDistance = MinimumEdgeToEdgeDistanceItem; layout.ConsiderNodeLabels = ConsiderNodeLabelsItem; layout.IntegratedEdgeLabeling = PlaceEdgeLabelsItem; var portAssignment = (DefaultPortAssignment)layout.DefaultPortAssignment; portAssignment.Mode = PortStyleItem; portAssignment.ForkStyle = RouteEdgesInFlowDirectionItem ? ForkStyle.OutsideNode : ForkStyle.AtNode; layout.RoutingStyle = RoutingStyleItem; if (RoutingStyleItem == RoutingStyle.Octilinear) { layout.PreferredOctilinearSegmentLength = PreferredOctilinearSegmentLengthItem; } else if (RoutingStyleItem == RoutingStyle.Polyline) { layout.MinimumPolylineSegmentLength = MinimumPolylineSegmentLengthItem; layout.MinimumSlope = MinimumSlopeItem; } if (RoutingStyleNonSeriesParallelItem == NonSeriesParallelRoutingStyle.Orthogonal) { var edgeRouter = new EdgeRouter { Rerouting = true, Scope = Scope.RouteAffectedEdges }; layout.NonSeriesParallelEdgeRouter = edgeRouter; layout.NonSeriesParallelEdgesDpKey = edgeRouter.AffectedEdgesDpKey; } else if (RoutingStyleNonSeriesParallelItem == NonSeriesParallelRoutingStyle.Organic) { var edgeRouter = new OrganicEdgeRouter(); layout.NonSeriesParallelEdgeRouter = edgeRouter; layout.NonSeriesParallelEdgesDpKey = OrganicEdgeRouter.AffectedEdgesDpKey; } else if (RoutingStyleNonSeriesParallelItem == NonSeriesParallelRoutingStyle.Straight) { var edgeRouter = new StraightLineEdgeRouter { Scope = Scope.RouteAffectedEdges }; layout.NonSeriesParallelEdgeRouter = edgeRouter; layout.NonSeriesParallelEdgesDpKey = edgeRouter.AffectedEdgesDpKey; } var edgeLayoutDescriptor = layout.DefaultEdgeLayoutDescriptor; edgeLayoutDescriptor.MinimumFirstSegmentLength = MinimumFirstSegmentLengthItem; edgeLayoutDescriptor.MinimumLastSegmentLength = MinimumLastSegmentLengthItem; edgeLayoutDescriptor.MinimumLength = MinimumEdgeLengthItem; return(layout); }
private void SetupLayouts() { //using hierarchical layout style HierarchicLayout hierarchicLayout = new HierarchicLayout(); hierarchicLayout.EdgeLayoutDescriptor.RoutingStyle = new yWorks.Layout.Hierarchic.RoutingStyle( yWorks.Layout.Hierarchic.EdgeRoutingStyle.Orthogonal); CurrentLayout = hierarchicLayout; layouts.Add("Hierarchic", hierarchicLayout); //using organic layout style OrganicLayout organic = new OrganicLayout { QualityTimeRatio = 1.0, NodeOverlapsAllowed = false, NodeEdgeOverlapAvoided = true, MinimumNodeDistance = 10, PreferredEdgeLength = 50, }; layouts.Add("Organic", organic); //using orthogonal layout style OrthogonalLayout orthogonal = new OrthogonalLayout { GridSpacing = 15, OptimizePerceivedBends = true }; layouts.Add("Orthogonal", orthogonal); //using circular layout style CircularLayout circular = new CircularLayout(); circular.BalloonLayout.MinimumEdgeLength = 50; circular.BalloonLayout.CompactnessFactor = 0.1; layouts.Add("Circular", circular); // a tree layout algorithm TreeLayout treeLayout = new TreeLayout { ConsiderNodeLabels = true }; treeLayout.AppendStage(new TreeReductionStage() { NonTreeEdgeRouter = new OrganicEdgeRouter(), NonTreeEdgeSelectionKey = OrganicEdgeRouter.AffectedEdgesDpKey, }); layouts.Add("Tree", treeLayout); //using Polyline Router var polylineRouter = new EdgeRouter { Grid = new Grid(0, 0, 10), PolylineRouting = true, Rerouting = true }; polylineRouter.DefaultEdgeLayoutDescriptor.PenaltySettings.BendPenalty = 3; polylineRouter.DefaultEdgeLayoutDescriptor.PenaltySettings.EdgeCrossingPenalty = 5; layouts.Add("Polyline Edge Router", polylineRouter); }
public static void Main() { DefaultLayoutGraph graph = new DefaultLayoutGraph(); //construct graph and assign sizes to its nodes Node[] nodes = new Node[16]; for (int i = 0; i < 16; i++) { nodes[i] = graph.CreateNode(); graph.SetSize(nodes[i], 30, 30); } graph.CreateEdge(nodes[0], nodes[1]); graph.CreateEdge(nodes[0], nodes[2]); graph.CreateEdge(nodes[0], nodes[3]); graph.CreateEdge(nodes[0], nodes[14]); graph.CreateEdge(nodes[2], nodes[4]); graph.CreateEdge(nodes[3], nodes[5]); graph.CreateEdge(nodes[3], nodes[6]); graph.CreateEdge(nodes[3], nodes[9]); graph.CreateEdge(nodes[4], nodes[7]); graph.CreateEdge(nodes[4], nodes[8]); graph.CreateEdge(nodes[5], nodes[9]); graph.CreateEdge(nodes[6], nodes[10]); graph.CreateEdge(nodes[7], nodes[11]); graph.CreateEdge(nodes[8], nodes[12]); graph.CreateEdge(nodes[8], nodes[15]); graph.CreateEdge(nodes[9], nodes[13]); graph.CreateEdge(nodes[10], nodes[13]); graph.CreateEdge(nodes[10], nodes[14]); graph.CreateEdge(nodes[12], nodes[15]); GraphViewer gv = new GraphViewer(); //using organic layout style OrganicLayout organic = new OrganicLayout(); organic.QualityTimeRatio = 1.0; organic.NodeOverlapsAllowed = false; organic.MinimumNodeDistance = 10; organic.PreferredEdgeLength = 40; new BufferedLayout(organic).ApplyLayout(graph); LayoutGraphUtilities.ClipEdgesOnBounds(graph); gv.AddLayoutGraph(new CopiedLayoutGraph(graph), "Organic Layout Style"); //using orthogonal edge router (node positions stay fixed) EdgeRouter router = new EdgeRouter(); new BufferedLayout(router).ApplyLayout(graph); gv.AddLayoutGraph(new CopiedLayoutGraph(graph), "Polyline Edge Router"); //using orthogonal layout style OrthogonalLayout orthogonal = new OrthogonalLayout(); orthogonal.GridSpacing = 15; orthogonal.OptimizePerceivedBends = true; new BufferedLayout(orthogonal).ApplyLayout(graph); gv.AddLayoutGraph(new CopiedLayoutGraph(graph), "Orthogonal Layout Style"); //using circular layout style CircularLayout circular = new CircularLayout(); circular.BalloonLayout.MinimumEdgeLength = 20; circular.BalloonLayout.CompactnessFactor = 0.1; new BufferedLayout(circular).ApplyLayout(graph); LayoutGraphUtilities.ClipEdgesOnBounds(graph); gv.AddLayoutGraph(new CopiedLayoutGraph(graph), "Circular Layout Style"); //using hierarchical layout style var hierarchic = new HierarchicLayout(); new BufferedLayout(hierarchic).ApplyLayout(graph); gv.AddLayoutGraph(graph, "Hierarchical Layout Style"); var application = new System.Windows.Application(); application.Run(gv); }
protected override void ConfigureLayout() { OptionGroup generalGroup = Handler.GetGroupByName(GENERAL); SeriesParallelLayout series = new SeriesParallelLayout { GeneralGraphHandling = true }; series.LayoutOrientation = orientations[(string)Handler.GetValue(GENERAL, ORIENTATION)]; series.VerticalAlignment = verticalAlignments[(string)Handler.GetValue(GENERAL, VERTICAL_ALIGNMENT)]; RoutingStyle routingStyle = routingStyles[(string)Handler.GetValue(EDGE_SETTINGS, ROUTING_STYLE)]; series.RoutingStyle = routingStyle; switch (routingStyle) { case RoutingStyle.Octilinear: series.PreferredOctilinearSegmentLength = (double)Handler.GetValue(EDGE_SETTINGS, PREFERRED_OCTILINEAR_SEGMENT_LENGTH); break; case RoutingStyle.Polyline: series.MinimumPolylineSegmentLength = (double)Handler.GetValue(EDGE_SETTINGS, POLYLINE_DISTANCE); series.MinimumSlope = (double)Handler.GetValue(EDGE_SETTINGS, MINIMUM_SLOPE); break; } ((DefaultPortAssignment)series.DefaultPortAssignment).ForkStyle = (bool)Handler.GetValue(EDGE_SETTINGS, ROUTE_IN_FLOW) ? ForkStyle.OutsideNode : ForkStyle.AtNode; series.FromSketchMode = (bool)Handler.GetValue(GENERAL, FROM_SKETCH_MODE); string nonSeriesParallelRoutingStyle = (string)Handler.GetValue(GENERAL, ROUTING_STYLE_FOR_NON_SERIES_PARALLEL_EDGES); switch (nonSeriesParallelRoutingStyle) { case ROUTE_ORGANIC: series.NonSeriesParallelEdgeRouter = new OrganicEdgeRouter(); series.NonSeriesParallelEdgesDpKey = OrganicEdgeRouter.AffectedEdgesDpKey; break; case ROUTE_ORTHOGONAL: var orthogonal = new EdgeRouter(); orthogonal.Rerouting = true; orthogonal.Scope = Scope.RouteAffectedEdges; series.NonSeriesParallelEdgeRouter = orthogonal; series.NonSeriesParallelEdgesDpKey = orthogonal.AffectedEdgesDpKey; break; case ROUTE_STRAIGHTLINE: var straightLine = new StraightLineEdgeRouter(); straightLine.Scope = Scope.RouteAffectedEdges; series.NonSeriesParallelEdgeRouter = straightLine; series.NonSeriesParallelEdgesDpKey = straightLine.AffectedEdgesDpKey; break; } series.MinimumNodeToNodeDistance = (double)Handler.GetValue(GENERAL, NODE_TO_NODE_DISTANCE); series.MinimumNodeToEdgeDistance = (double)Handler.GetValue(GENERAL, NODE_TO_EDGE_DISTANCE); series.MinimumEdgeToEdgeDistance = (double)Handler.GetValue(GENERAL, EDGE_TO_EDGE_DISTANCE); Object portStyle = Handler.GetValue(EDGE_SETTINGS, PORT_STYLE); if (CENTER_PORTS == portStyle) { ((DefaultPortAssignment)series.DefaultPortAssignment).Mode = PortAssignmentMode.Center; } else { ((DefaultPortAssignment)series.DefaultPortAssignment).Mode = PortAssignmentMode.Distributed; } EdgeLayoutDescriptor eld = series.DefaultEdgeLayoutDescriptor; eld.MinimumFirstSegmentLength = (double)Handler.GetValue(EDGE_SETTINGS, MINIMUM_FIRST_SEGMENT_LENGTH); eld.MinimumLastSegmentLength = (double)Handler.GetValue(EDGE_SETTINGS, MINIMUM_LAST_SEGMENT_LENGTH); eld.MinimumLength = (double)Handler.GetValue(EDGE_SETTINGS, MINIMUM_EDGE_LENGTH); series.ConsiderNodeLabels = (bool)Handler.GetValue(GENERAL, CONSIDER_NODE_LABELS); series.IntegratedEdgeLabeling = (bool)Handler.GetValue(GENERAL, INTEGRATED_EDGE_LABELING); LayoutAlgorithm = series; }
public EdgeRouter CreateConfiguredLayout(GraphControl graphControl) { var router = new EdgeRouter(); var descriptor = router.DefaultEdgeLayoutDescriptor; router.Scope = ScopeItem; if (OptimizationStrategyItem == EnumStrategies.Balanced) { descriptor.PenaltySettings = PenaltySettings.OptimizationBalanced; } else if (OptimizationStrategyItem == EnumStrategies.MinimizeBends) { descriptor.PenaltySettings = PenaltySettings.OptimizationEdgeBends; } else if (OptimizationStrategyItem == EnumStrategies.MinimizeEdgeLength) { descriptor.PenaltySettings = PenaltySettings.OptimizationEdgeLengths; } else { descriptor.PenaltySettings = PenaltySettings.OptimizationEdgeCrossings; } if (MonotonicRestrictionItem == EnumMonotonyFlags.Horizontal) { descriptor.MonotonicPathRestriction = MonotonicPathRestriction.Horizontal; } else if (MonotonicRestrictionItem == EnumMonotonyFlags.Vertical) { descriptor.MonotonicPathRestriction = MonotonicPathRestriction.Vertical; } else if (MonotonicRestrictionItem == EnumMonotonyFlags.Both) { descriptor.MonotonicPathRestriction = MonotonicPathRestriction.Both; } else { descriptor.MonotonicPathRestriction = MonotonicPathRestriction.None; } descriptor.MinimumEdgeToEdgeDistance = MinimumEdgeToEdgeDistanceItem; router.MinimumNodeToEdgeDistance = MinimumNodeToEdgeDistanceItem; descriptor.MinimumNodeCornerDistance = MinimumNodeCornerDistanceItem; descriptor.MinimumFirstSegmentLength = MinimumFirstSegmentLengthItem; descriptor.MinimumLastSegmentLength = MinimumLastSegmentLengthItem; if (GridEnabledItem) { router.Grid = new Grid(0, 0, GridSpacingItem); } else { router.Grid = null; } router.Rerouting = EnableReroutingItem; router.PolylineRouting = EnablePolylineRoutingItem; router.PreferredPolylineSegmentLength = PreferredPolylineSegmentLengthItem; router.MaximumDuration = MaximumDurationItem * 1000; return(router); }