コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="location"></param>
        public void IncreaseLevel(Point location)
        {
            // If already zoomed, quit
            if (iZoomIn)
            {
                return;
            }

            TreeRectangle selectedRectangle = null;

            foreach (TreeRectangle rectangle in iCurrentRootRectangle.GetChildren())
            {
                selectedRectangle = rectangle.LocationInsideRectangle(location);
                if (selectedRectangle != null)
                {
                    break;
                }
            }

            if (selectedRectangle != null)
            {
                this.iCurrentRootRectangle = selectedRectangle;
            }

            /************************************************************************/
            /* THE SAME AS IN SIZECHANGED!!! CREATE INVALIDATEDATA / INVALIDATEVIEW */
            /************************************************************************/
            UpdateData();
            UpdateScale();
            UpdateDrawingArea();

            this.Invalidate();

            iZoomIn = true;
        }
コード例 #2
0
        /// <summary>
        /// Parse the whole tree squerifying all the nodes
        /// </summary>
        /// <param name="aRectangle">current rectangle</param>
        public void SquarifyTree(TreeRectangle aRectangle)
        {
            if (0 == aRectangle.GetChildren().Count)
            {
                return;
            }

            List <TreeRectangle> row            = new List <TreeRectangle>();
            List <TreeRectangle> copyOfChildren = new List <TreeRectangle>(aRectangle.GetChildren());

            SquarifyLevel(copyOfChildren, row, aRectangle);

            foreach (TreeRectangle rect in aRectangle.GetChildren())
            {
                SquarifyTree(rect);
            }
        }
コード例 #3
0
        /// <summary>
        /// Initializes the TreeMap from a descending order object[,,] cube
        /// </summary>
        /// <param name="aDataCube">[columns, rows, 1]</param>
        /// <param name="aQuantitativeDataIndex"></param>
        /// <param name="aOrdinalDataIndex"></param>
        /// <param name="aIdIndex"></param>
        private void InitTreeMapFromDataCube(object[, ,] aDataCube, int aQuantitativeDataIndex,
                                             int aOrdinalDataIndex, int aIdIndex, int aLeafNodeLabelIndex,
                                             List <GMSToolTipComponent> aToolTipComponents)
        {
            iRootRectangle        = new TreeRectangle(0.0F);
            iCurrentRootRectangle = iRootRectangle;

            string        currentGroup = (string)aDataCube[aOrdinalDataIndex, 0, 0];
            TreeRectangle currentNode  = new TreeRectangle(0.0F);

            currentNode.Label = currentGroup;

            // iterate through the rows
            for (int i = 0; i < aDataCube.GetLength(1); i++)
            {
                // if changing to a different group
                if (currentGroup != (string)aDataCube[aOrdinalDataIndex, i, 0])
                {
                    // only add the node to the root if any children have been created
                    if (currentNode.GetChildren().Count != 0)
                    {
                        iRootRectangle.AddRectangle(currentNode);
                    }
                    currentNode       = new TreeRectangle(0.0F);
                    currentGroup      = (string)aDataCube[aOrdinalDataIndex, i, 0];
                    currentNode.Label = currentGroup;
                }

                float area = Convert.ToSingle(aDataCube[aQuantitativeDataIndex, i, 0]);

                // only add the node if the area is bigger or equal to one
                if (area >= 1.0F)
                {
                    TreeRectangle childRectangle = new TreeRectangle(area);
                    childRectangle.Id = Convert.ToInt32(aDataCube[aIdIndex, i, 0]);

                    // Tooltip Data and Label
                    BuildToolTipData(childRectangle, aDataCube, aToolTipComponents, i);
                    childRectangle.Label = (string)aDataCube[aLeafNodeLabelIndex, i, 0];

                    currentNode.AddRectangle(childRectangle);
                }
            }

            iRootRectangle.AddRectangle(currentNode);
        }