public override void InitGraph()
        {
            if (dataNode != null)
            {
                biTreeGenerator.DataNode  = dataNode;
                biTreeGenerator.IsPreview = false;
                biTreeGenerator.GenerateTree(diameter, status.结点颜色);
            }
            preOrderTreeIterator  = new BiTreePreOrderIterator(biTreeGenerator.RootNode);
            preOrderTreeIterator1 = new BiTreePreOrderIterator(biTreeGenerator.RootLineNode);

            stackIterator = new StackIterator(new ArrayList());

            visitedIterator = new ArrayIterator(new ArrayList());
        }
示例#2
0
        Image CreatePreviewImage(XmlNode dataNode)
        {
            int height   = 240;
            int width    = 530;
            int diameter = 40;

            Bitmap   bmp = new Bitmap(width, height);
            Graphics g   = Graphics.FromImage(bmp);

            BiTreeGenerator biTreeGenerator = new BiTreeGenerator();

            biTreeGenerator.DataNode  = dataNode;
            biTreeGenerator.IsPreview = true;
            biTreeGenerator.GenerateTree(diameter, Color.HotPink);
            //注意:这里我还是使用先序遍历,因为用什么遍历方法无很大关系,关键是最终的结果要正确
            IIterator preOrderTreeIterator  = new BiTreePreOrderIterator(biTreeGenerator.RootNode);
            IIterator preOrderTreeIterator1 = new BiTreePreOrderIterator(biTreeGenerator.RootLineNode);

            if (preOrderTreeIterator != null)
            {
                for (IIterator iterator = preOrderTreeIterator.First(); !preOrderTreeIterator.IsDone(); iterator = preOrderTreeIterator.Next())
                {
                    if (iterator.CurrentItem != null)
                    {
                        iterator.CurrentItem.BackColor = Color.HotPink;
                        iterator.CurrentItem.Draw(g);
                    }
                }
            }
            if (preOrderTreeIterator1 != null)
            {
                for (IIterator iterator = preOrderTreeIterator1.First(); !preOrderTreeIterator1.IsDone(); iterator = preOrderTreeIterator1.Next())
                {
                    if (iterator.CurrentItem != null)
                    {
                        iterator.CurrentItem.Draw(g);
                    }
                }
            }

            return(bmp);
        }
		Image CreatePreviewImage(XmlNode dataNode)
		{
			int height = 240;
			int width = 530;
			int diameter = 40;
			
			Bitmap bmp = new Bitmap(width,height);
			Graphics g = Graphics.FromImage(bmp);

			BiTreeGenerator biTreeGenerator = new BiTreeGenerator();
			biTreeGenerator.DataNode = dataNode;
			biTreeGenerator.IsPreview = true;
			biTreeGenerator.GenerateTree(diameter,Color.HotPink);
			//注意:这里我还是使用先序遍历,因为用什么遍历方法无很大关系,关键是最终的结果要正确
			IIterator preOrderTreeIterator = new BiTreePreOrderIterator(biTreeGenerator.RootNode);
			IIterator preOrderTreeIterator1 =  new BiTreePreOrderIterator(biTreeGenerator.RootLineNode);

			if(preOrderTreeIterator != null)
			{
				for(IIterator iterator = preOrderTreeIterator.First();!preOrderTreeIterator.IsDone();iterator = preOrderTreeIterator.Next())
				{
					if(iterator.CurrentItem != null)
					{
						iterator.CurrentItem.BackColor = Color.HotPink;
						iterator.CurrentItem.Draw(g);
					}
				}
			}
			if(preOrderTreeIterator1 != null)
			{
				for(IIterator iterator = preOrderTreeIterator1.First();!preOrderTreeIterator1.IsDone();iterator = preOrderTreeIterator1.Next())
				{
					if(iterator.CurrentItem != null)
					{
						iterator.CurrentItem.Draw(g);
					}
				}
			}

			return bmp;

		}