Beispiel #1
0
        private void LayoutAllOurChildren(int iLayer, ITreeNode tnLast, TreeNodeGroup tng)
        {
            List <Double> lstLeftToBB    = new List <double>();
            List <int>    lstResponsible = new List <int>();

            for (int i = 0; i < tng.Count; i++)
            {
                ITreeNode tn = tng[i];
                LayoutTree(tn, iLayer + 1);
                RepositionSubtree(i, tng, lstLeftToBB, lstResponsible);
                tnLast = tn;
            }
        }
Beispiel #2
0
        private void RepositionSubtree(
            int itn,
            TreeNodeGroup tngSiblings,
            List <double> lstLeftToBB,
            List <int> lsttnResponsible)
        {
            int             itnResponsible;
            ITreeNode       tn  = tngSiblings[itn];
            LayeredTreeInfo lti = Info(tn);

            if (itn == 0)
            {
                // No shifting but we still have to prepare the initial version of the
                // left hand skeleton list
                foreach (double pxRelativeToRoot in lti.lstPosRightBoundaryRelativeToRoot)
                {
                    lstLeftToBB.Add(pxRelativeToRoot + lti.pxLeftPosRelativeToBoundingBox);
                    lsttnResponsible.Add(0);
                }
                return;
            }

            ITreeNode tnLeft = tngSiblings[itn - 1];
            //LayeredTreeInfo ltiLeft = Info(tnLeft);
            int    iLayer;
            double pxHorizontalBuffer = _pxBufferHorizontal;

            double pxNewPosFromBB = PxCalculateNewPos(lti, lstLeftToBB, lsttnResponsible, out itnResponsible, out iLayer);

            if (iLayer != 0)
            {
                pxHorizontalBuffer = _pxBufferHorizontalSubtree;
            }

            lti.pxToLeftSibling = pxNewPosFromBB - lstLeftToBB.First() + tnLeft.TreeWidth + pxHorizontalBuffer;

            int cLevels = Math.Min(lti.lstPosRightBoundaryRelativeToRoot.Count, lstLeftToBB.Count);

            for (int i = 0; i < cLevels; i++)
            {
                lstLeftToBB[i]      = lti.lstPosRightBoundaryRelativeToRoot[i] + pxNewPosFromBB + pxHorizontalBuffer;
                lsttnResponsible[i] = itn;
            }
            for (int i = lstLeftToBB.Count; i < lti.lstPosRightBoundaryRelativeToRoot.Count; i++)
            {
                lstLeftToBB.Add(lti.lstPosRightBoundaryRelativeToRoot[i] + pxNewPosFromBB + pxHorizontalBuffer);
                lsttnResponsible.Add(itn);
            }

            ApportionSlop(itn, itnResponsible, tngSiblings);
        }
Beispiel #3
0
        private void ApportionSlop(int itn, int itnResponsible, TreeNodeGroup tngSiblings)
        {
            LayeredTreeInfo lti    = Info(tngSiblings[itn]);
            ITreeNode       tnLeft = tngSiblings[itn - 1];

            double pxSlop = lti.pxToLeftSibling - tnLeft.TreeWidth - _pxBufferHorizontal;

            if (pxSlop > 0)
            {
                for (int i = itnResponsible + 1; i < itn; i++)
                {
                    Info(tngSiblings[i]).pxToLeftSibling += pxSlop * (i - itnResponsible) / (itn - itnResponsible);
                }
                lti.pxToLeftSibling -= (itn - itnResponsible - 1) * pxSlop / (itn - itnResponsible);
            }
        }
Beispiel #4
0
        private void LayoutInteriorNode(ITreeNode tnRoot, int iLayer)
        {
            ITreeNode       tnLast = null;
            TreeNodeGroup   tng    = GetChildren(tnRoot);
            LayeredTreeInfo ltiThis;

            LayoutAllOurChildren(iLayer, tnLast, tng);

            // This width doesn't account for the parent node's width...
            ltiThis = new LayeredTreeInfo(CalculateWidthFromInterChildDistances(tnRoot), tnRoot);
            tnRoot.PrivateNodeInfo = ltiThis;

            // ...so that this centering may place the parent node negatively while the "width" is the width of
            // all the child nodes.
            CenterOverChildren(tnRoot, ltiThis);
            DetermineParentRelativePositionsOfChildren(tnRoot);
            CalculateBoundaryLists(tnRoot);
        }