Ejemplo n.º 1
0
        /// <summary>
        /// Checks whether the row can be continued, or is it better to start a new one.
        /// </summary>
        /// <param name="aRow">List of values</param>
        /// <param name="aHead">The proposed new row member</param>
        /// <param name="aWidth">Width of the current cell</param>
        /// <returns>True if the row should be continued</returns>
        private bool ContinueRow(List <TreeRectangle> aRow, TreeRectangle aChild, TreeRectangle aParent)
        {
            float width = aParent.MinSideLength();
            float area  = aChild.GetArea();

            int count = aRow.Count;

            if (count == 0)
            {
                return(true);
            }
            float widthSqr = width * width;

            //First ratio
            float sum      = Sum(aRow);
            float sumSqr   = sum * sum;
            float rMax     = aRow[0].GetArea();
            float rMin     = aRow[count - 1].GetArea();
            float max      = (widthSqr * rMax) / sumSqr;
            float min      = sumSqr / (widthSqr * rMin);
            float firstMax = Math.Max(max, min);

            //Second ratio
            sum   += area;
            sumSqr = sum * sum;
            rMax   = Math.Max(rMax, area);
            rMin   = Math.Min(rMin, area);
            max    = (widthSqr * rMax) / sumSqr;
            min    = sumSqr / (widthSqr * rMin);
            float secondMax = Math.Max(max, min);

            //does the aspect ratio improve or not?
            return(firstMax >= secondMax);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Update the data according to the available screenspace
        /// </summary>
        public void UpdateData()
        {
            float sum = iCurrentRootRectangle.GetArea();

            float ratio  = iPanel.Width / (float)iPanel.Height;
            float height = (float)Math.Sqrt(sum / ratio);
            float width  = height * ratio;

            iCurrentRootRectangle.SetSize(0, 0, width, height);
            BuildTreeMap();
        }