/// <summary>
        /// Setup default values for various configuration parameters.
        /// </summary>
        public TreeLayoutConfig()
        {
            var layout = new ClassicTreeLayout();
            var aspectRatioNodePlacer = new AspectRatioNodePlacer();
            var defaultNodePlacer     = new DefaultNodePlacer();

            LayoutStyleItem = EnumStyle.Default;
            RoutingStyleForNonTreeEdgesItem = EnumRoute.Orthogonal;
            EdgeBundlingStrengthItem        = 0.95;
            ActOnSelectionOnlyItem          = false;

            DefaultLayoutOrientationItem = LayoutOrientation.TopToBottom;
            ClassicLayoutOrientationItem = LayoutOrientation.TopToBottom;

            MinimumNodeDistanceItem  = (int)layout.MinimumNodeDistance;
            MinimumLayerDistanceItem = (int)layout.MinimumLayerDistance;
            PortStyleItem            = PortStyle.NodeCenter;

            ConsiderNodeLabelsItem = false;

            OrthogonalEdgeRoutingItem = false;

            VerticalAlignmentItem     = 0.5;
            ChildPlacementPolicyItem  = LeafPlacement.SiblingsOnSameLayer;
            EnforceGlobalLayeringItem = false;

            NodePlacerItem = EnumNodePlacer.Default;

            SpacingItem           = 20;
            RootAlignmentItem     = EnumRootAlignment.Center;
            AllowMultiParentsItem = false;
            PortAssignmentItem    = PortAssignmentMode.None;

            HvHorizontalSpaceItem = (int)defaultNodePlacer.HorizontalDistance;
            HvVerticalSpaceItem   = (int)defaultNodePlacer.VerticalDistance;

            BusAlignmentItem = 0.5;

            ArHorizontalSpaceItem     = (int)aspectRatioNodePlacer.HorizontalDistance;
            ArVerticalSpaceItem       = (int)aspectRatioNodePlacer.VerticalDistance;
            NodePlacerAspectRatioItem = aspectRatioNodePlacer.AspectRatio;

            ArUseViewAspectRatioItem        = true;
            CompactPreferredAspectRatioItem = aspectRatioNodePlacer.AspectRatio;

            EdgeLabelingItem              = EnumEdgeLabeling.None;
            LabelPlacementAlongEdgeItem   = EnumLabelPlacementAlongEdge.Centered;
            LabelPlacementSideOfEdgeItem  = EnumLabelPlacementSideOfEdge.OnEdge;
            LabelPlacementOrientationItem = EnumLabelPlacementOrientation.Horizontal;
            LabelPlacementDistanceItem    = 10;
        }
Пример #2
0
        ///<summary>
        /// Create a sample graph: a simple tree with SimpleNodePlacers assigned to each node.
        /// This implementation creates three layers with three children each.
        ///</summary>
        private void CreateSampleGraph(IGraph graph)
        {
            graph.Clear();
            INode root  = graph.CreateNode();
            var   style = new ShinyPlateNodeStyle {
                Brush = NodePlacerPanel.LayerBrushes[0]
            };

            graph.SetStyle(root, style);
            var placer = new DefaultNodePlacer
            {
                ChildPlacement = ChildPlacement.VerticalToRight
            };

            placers[root] = placer;
            CreateSubTree(graph, root, 1, 2);
        }
Пример #3
0
        ///<summary>
        /// Recursively builds a sub tree
        ///</summary>summary>
        private void CreateSubTree(IGraph graph, INode root, int layer, int layers)
        {
            int children = NumChildren[layer];

            for (int i = 0; i < children; i++)
            {
                INode child = graph.CreateNode();
                graph.CreateEdge(root, child);
                graph.SetStyle(child, new ShinyPlateNodeStyle {
                    Brush = NodePlacerPanel.LayerBrushes[layer % NodePlacerPanel.LayerBrushes.Length]
                });

                var placer = new DefaultNodePlacer {
                    ChildPlacement = ChildPlacement.VerticalToRight
                };
                placers[child] = placer;

                if (layers > 0)
                {
                    CreateSubTree(graph, child, layer + 1, layers - 1);
                }
            }
        }