예제 #1
0
        //绘制高亮节点和其相关连边
        void IfPaintStrategy.DrawHighLightNodeEdge(int iNum, Point newLoc, ref Graphics GraCam)
        {
            int   intRadiusSource, intRadiusTarget;
            dNode curNode = curNetwork.Network[iNum];

            curNode.Location = newLoc;
            //起始节点的半径
            intRadiusSource = curNetwork.SharedImages[curNode.Degree].Width;
            intRadiusSource = (intRadiusSource - 1) / 2;
            foreach (Edge edge in curNode)
            {
                dNode tarNode = curNetwork.Network[edge.Target];
                //目标节点的半径
                intRadiusTarget = curNetwork.SharedImages[tarNode.Degree].Width;
                intRadiusTarget = (intRadiusTarget - 1) / 2;
                //起始节点到目标点连边
                DrawLine(ref GraCam,
                         curNode.Location, intRadiusSource,
                         tarNode.Location, intRadiusTarget,
                         edge.Value);
                if (curNetwork.Type == "无向图")
                {
                    //目标点到起始节点连边
                    DrawLine(ref GraCam,
                             tarNode.Location, intRadiusTarget,
                             curNode.Location, intRadiusSource,
                             edge.Value);
                }
            }
            if (curNetwork.Type == "有向图")
            {
                foreach (dNode tarNode in curNetwork.Network)
                {
                    if (tarNode.Contains(iNum) == true)
                    {
                        //目标节点的半径
                        intRadiusTarget = curNetwork.SharedImages[tarNode.Degree].Width;
                        intRadiusTarget = (intRadiusTarget - 1) / 2;
                        //目标节点到起始节点的连边
                        DrawLine(ref GraCam,
                                 tarNode.Location, intRadiusTarget,
                                 curNode.Location, intRadiusSource,
                                 tarNode.GetWeight(iNum));
                    }
                }
            }
            //绘制高亮节点
            DrawHighLightNode(iNum, ref GraCam);
        }
예제 #2
0
        //高亮节点绘制函数
        public void DrawHighLightNode(int iNum, ref Graphics GraCam)
        {
            Image          img;
            PaintParameter curNodePara;
            Point          potStart;
            dNode          curNode = curNetwork.Network[iNum];

            //计算网络绘制参数
            curNodePara = new PaintParameter(iNum, curNode.Degree, curNetwork.MaxDeg, curNetwork.MinDeg);
            //获取绘制完成的图片
            img = this.DrawNode(curNodePara, true);
            //在图元对应位置绘制图片
            GraCam.DrawImage(img, new Point(curNode.Location.X - img.Width / 2, curNode.Location.Y - img.Height / 2));
            //计算编号绘制起点
            potStart = new Point(curNode.Location.X - curNode.Offset.X, curNode.Location.Y - curNode.Offset.Y);
            //绘制节点编号
            this.DrawString(iNum.ToString(), potStart, ref GraCam, true);
        }