Пример #1
0
        LayoutNode _GetLeftmost(LayoutNode node, int level, int maxlevel)
        {
            if (level >= maxlevel)
            {
                return(node);
            }
            if (node._getChildrenCount() == 0)
            {
                return(null);
            }

            var n = node._getChildrenCount();

            for (var i = 0; i < n; i++)
            {
                var iChild             = node._getChildAt(i);
                var leftmostDescendant = this._GetLeftmost(iChild, level + 1, maxlevel);
                if (leftmostDescendant != null)
                {
                    return(leftmostDescendant);
                }
            }

            return(null);
        }
Пример #2
0
        //Layout algorithm
        public void FirstWalk(LayoutNode node, int level)
        {
            LayoutNode leftSibling = null;

            node.X             = 0;
            node.Y             = 0;
            node.Prelim        = 0;
            node.Modifier      = 0;
            node.LeftNeighbor  = null;
            node.RightNeighbor = null;
            _setLevelHeight(node, level);
            _setLevelWidth(node, level);
            _setNeighbors(node, level);
            if (node._getChildrenCount() == 0 || level == Config.iMaxDepth)
            {
                leftSibling = node._getLeftSibling();
                if (leftSibling != null)
                {
                    node.Prelim = leftSibling.Prelim + GetNodeSize(leftSibling) + Config.iSiblingSeparation;
                }
                else
                {
                    node.Prelim = 0;
                }
            }
            else
            {
                var n = node._getChildrenCount();
                for (var i = 0; i < n; i++)
                {
                    var iChild = node._getChildAt(i);
                    FirstWalk(iChild, level + 1);
                }

                var midPoint = node._getChildrenCenter(this);
                midPoint   -= GetNodeSize(node) / 2;
                leftSibling = node._getLeftSibling();
                if (leftSibling != null)
                {
                    node.Prelim   = leftSibling.Prelim + GetNodeSize(leftSibling) + Config.iSiblingSeparation;
                    node.Modifier = node.Prelim - midPoint;
                    _apportion(node, level);
                }
                else
                {
                    node.Prelim = midPoint;
                }
            }
        }