Пример #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;
                }
            }
        }
Пример #3
0
        public void _secondWalk(TreeLayout tree, LayoutNode node, int level, double X, double Y)
        {
            if (level <= tree.Config.iMaxDepth)
            {
                var    xTmp        = tree.RootXOffset + node.Prelim + X;
                var    yTmp        = tree.RootYOffset + Y;
                double maxsizeTmp  = 0;
                double nodesizeTmp = 0;
                var    flag        = false;

                switch (tree.Config.iRootOrientation)
                {
                case TreeLayout.RO_TOP:
                case TreeLayout.RO_BOTTOM:
                    maxsizeTmp  = tree.MaxLevelHeight[level];
                    nodesizeTmp = node.H;
                    break;

                case TreeLayout.RO_RIGHT:
                case TreeLayout.RO_LEFT:
                    maxsizeTmp  = tree.MaxLevelWidth[level];
                    flag        = true;
                    nodesizeTmp = node.W;
                    break;
                }
                switch (tree.Config.iNodeJustification)
                {
                case TreeLayout.NJ_TOP:
                    node.X = xTmp;
                    node.Y = yTmp;
                    break;

                case TreeLayout.NJ_CENTER:
                    node.X = xTmp;
                    node.Y = yTmp + (maxsizeTmp - nodesizeTmp) / 2;
                    break;

                case TreeLayout.NJ_BOTTOM:
                    node.X = xTmp;
                    node.Y = (yTmp + maxsizeTmp) - nodesizeTmp;
                    break;
                }
                if (flag)
                {
                    var swapTmp = node.X;
                    node.X = node.Y;
                    node.Y = swapTmp;
                }
                switch (tree.Config.iRootOrientation)
                {
                case TreeLayout.RO_BOTTOM:
                    node.Y = -node.Y - nodesizeTmp;
                    break;

                case TreeLayout.RO_RIGHT:
                    node.X = -node.X - nodesizeTmp;
                    break;
                }
                if (node._getChildrenCount() != 0)
                {
                    _secondWalk(tree, node._getFirstChild(), level + 1, X + node.Modifier, Y + maxsizeTmp + tree.Config.iLevelSeparation);
                }
                var rightSibling = node._getRightSibling();
                if (rightSibling != null)
                {
                    _secondWalk(tree, rightSibling, level, X, Y);
                }
            }
        }