コード例 #1
0
        private void BtnPopulationGenerate_Click(object sender, EventArgs e)
        {
            double offerPrice = double.Parse(txtPriceOffer.Text);
            double offerRange = double.Parse(txtRange.Text);
            int    qtdInfo    = int.Parse(txtPopulationSize.Text);

            if (qtdInfo == 0 || qtdInfo < 20)
            {
                qtdInfo = 20;
            }

            Constants.SetOfferPrice(offerPrice);
            Constants.SetOfferPriceRange(offerRange);
            Constants.SetSizeOfPopulation(qtdInfo);

            btnAGBegin.Enabled = true;
            population         = new Population();
            graphicPopulation  = new PointPairList();

            for (int i = 0; i < Constants.sizePopulation; i++)
            {
                graphicPopulation.Add(Math.Min(population.GetPopulation()[i].GetChromosome()[0], population.GetPopulation()[i].GetChromosome()[1]), population.GetPopulation()[i].GetFitness());
            }

            LineItem inds = panePopulation.AddStick("Individuos", graphicPopulation, Color.Blue);

            zedPopulation.AxisChange();
            zedPopulation.Invalidate();
            zedPopulation.Refresh();
        }
コード例 #2
0
        private void btnPopulacao_Click(object sender, System.EventArgs e)
        {
            btnExecucao.Enabled = true;
            populacao           = new Populacao();
            populacaoGrafico    = new PointPairList();

            for (int i = 0; i < Constantes.TamanhoPopulacao; i++)
            {
                populacaoGrafico.Add(populacao[i].Valor, populacao[i].Aptidao);
            }

            LineItem lineItem = panePopulacao.AddStick("Indivíduos", populacaoGrafico, Color.Blue);

            AtualizarGraficoPopulacao();
        }
コード例 #3
0
ファイル: frm_Histogram.cs プロジェクト: 2018wz/ArcGis-
        private void CreateGraph(ZedGraphControl zgc1, Array x_value1, Array y_value1, double x_min1, double x_max1)
        {
            zgc1.GraphPane.CurveList.Clear();
            zgc1.Refresh();
            GraphPane myPane = zgc1.GraphPane;

            // Set the titles and axis labels
            myPane.Title.Text       = "图像直方图";
            myPane.XAxis.Title.Text = "像元值";
            myPane.YAxis.Title.Text = "像元个数";

            PointPairList list = new PointPairList();

            for (int i = 0; i < y_value1.Length; i++)    //256改为y_value.Length,纠正错误:有些影像的像元数不到256个,会产生索引溢出,by-zhzhx,
            {
                string a = x_value1.GetValue(i).ToString();
                string b = y_value1.GetValue(i).ToString();
                double x = Convert.ToDouble(a);
                double y = Convert.ToDouble(b);
                list.Add(x, y);
            }

            StickItem myCurve = myPane.AddStick("", list, Color.Blue);

            myCurve.Line.Width = 2.0f;
            //myPane.XAxis.MajorGrid.IsVisible = true;
            myPane.XAxis.Scale.Max = x_max1;
            myPane.XAxis.Scale.Min = x_min1;
            //myPane.YAxis.Scale.MajorStep = 500;

            // Fill the axis background with a color gradient
            myPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45.0F);
            zgc1.AxisChange();
            zgc1.Refresh();
        }
コード例 #4
0
        /// <summary>
        /// 通过制定(X,Y)坐标作为图表的数据源
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button7_Click(object sender, System.EventArgs e)
        {
            myPane = zedGraphControl1.GraphPane;

            double        x, y1, y2;                   //定义变量存放点的X,Y坐标
            PointPairList list1 = new PointPairList();
            PointPairList list2 = new PointPairList(); // PointPair类是一个包含(X,Y)的坐标类

            for (int i = 0; i < 36; i++)
            {
                x  = (double)i + 5;                         //给数据的X坐标赋值
                y1 = 1.5 + Math.Sin((double)i * 0.2);       //给数据的Y坐标赋值
                y2 = 3.0 * (1.5 + Math.Sin((double)i * 0.2));
                list1.Add(x, y1);
                list2.Add(x, y2);   //在列表中存数每个点的X,Y坐标
            }
            LineItem myCurve = myPane.AddCurve("Porsche", list1, Color.Red, SymbolType.Diamond);
            //LineItem类是ZedGraph中的线条类. 根据数据集list1创建红色的菱形曲线,标记"Porsche",这个函数的返回值是一个LineItem。
            //可以通过myCurve这个变量来对它进行进一步的设定。其中SymbolType是个Enum,它枚举了12个可供使用的形状,
            //包括Circle,Default,Diamond,HDash,None,Plus,Square,Star,Triangle,UserDefined,VDash,XCross.

            LineItem myCurve2 = myPane.AddCurve("Piper", list2, Color.Blue, SymbolType.Circle);

            // 根据数据集list2创建蓝色的圆形曲线, 标记"Piper"

            myCurve.Line.IsVisible = false;                 //设置曲线的线不可见,则只显示各个散点

            myPane.AddStick("采样线", list1, Color.BurlyWood); //对于数据集list1的每个点添加投影线

            myPane.AxisChange(this.CreateGraphics());       // 在数据变化时绘制图形

            zedGraphControl1.Refresh();
        }
コード例 #5
0
ファイル: StickItemDemo.cs プロジェクト: ctddjyds/WinFormsApp
        public StickItemDemo() : base("A demonstration of the 'StickItem', which is a single line for " +
                                      "each point running from the XAxis to the data value",
                                      "Stick Item Demo", DemoType.Bar)
        {
            GraphPane myPane = base.GraphPane;

            // Set the titles and axis labels
            myPane.Title.Text       = "StickItem Demo Chart";
            myPane.XAxis.Title.Text = "X Label";
            myPane.YAxis.Title.Text = "My Y Axis";

            PointPairList list = new PointPairList();

            for (int i = 0; i < 100; i++)
            {
                double x = (double)i;
                double y = Math.Sin(i / 8.0);
                double z = Math.Abs(Math.Cos(i / 8.0)) * y;
                list.Add(x, y, z);
            }

            StickItem myCurve = myPane.AddStick("Some Sticks", list, Color.Blue);

            myCurve.Line.Width = 2.0f;
            myPane.XAxis.MajorGrid.IsVisible = true;
            myPane.XAxis.Scale.Max           = 100;

            // Fill the axis background with a color gradient
            myPane.Chart.Fill = new Fill(Color.White,
                                         Color.LightGoldenrodYellow, 45.0F);

            base.ZedGraphControl.AxisChange();
        }
コード例 #6
0
        private void BtnPopulationGenerate_Click(object sender, EventArgs e)
        {
            btnAGBegin.Enabled = true;
            population         = new Population();
            graphicPopulation  = new PointPairList();

            for (int i = 0; i < Constants.sizePopulation; i++)
            {
                graphicPopulation.Add(population.GetPopulation()[i].getInt(), population.GetPopulation()[i].GetFitness());
            }

            LineItem inds = panePopulation.AddStick("Individuos", graphicPopulation, Color.Blue);

            zedPopulation.AxisChange();
            zedPopulation.Invalidate();
            zedPopulation.Refresh();
        }
コード例 #7
0
        private void btnCriarPop_Click(object sender, EventArgs e)
        {
            btnIniciarAG.Enabled = true;
            pop = new Populacao();
            populacaoGrafico = new PointPairList();

            for (int j = 0; j < Constants.sizePopulacao; j++)
            {
                populacaoGrafico.Add(pop.getPopulacao()[j].getInt(), pop.getPopulacao()[j].getFitness());
            }

            LineItem inds = panePop.AddStick("Indivuos", populacaoGrafico, Color.Blue);

            zedPopulacao.AxisChange();
            zedPopulacao.Invalidate();
            zedPopulacao.Refresh();
        }
コード例 #8
0
        private void btnCriarPop_Click(object sender, EventArgs e)
        {
            btnIniciarAG.Enabled = true;
            pop = new Populacao();
            populacaoGrafico = new PointPairList();

            for (int j = 0; j < Constants.sizePopulacao; j++)
            {
                //Eixo X é o valor inteiro do Individuo (Bool convertido para decimal
                //Eixo Y é o valor decimal já convertido
                populacaoGrafico.Add(pop.getPopulacao()[j].getInt(), pop.getPopulacao()[j].getFitness());
            }

            LineItem inds = panePop.AddStick("Individuos", populacaoGrafico, Color.Blue);

            zedPopulacao.AxisChange();
            zedPopulacao.Invalidate();
            zedPopulacao.Refresh();
        }
コード例 #9
0
        private void btnCriarPop_Click(object sender, EventArgs e)
        {
            //Habilita o botão para executar o algoritmo genético
            btnExecutarAG.Enabled = true;

            //Instancia uma nova população
            pop = new Populacao();

            populacaoGrafico = new PointPairList();

            for (int i = 0; i < Constants.sizePopulacao; i++)
            {
                populacaoGrafico.Add(pop.GetPopulacao()[i].GetInt(), pop.GetPopulacao()[i].GetFitness());
            }

            LineItem inds = panePop.AddStick("Indivíduos", populacaoGrafico, Color.Blue);

            zedPopulacao.AxisChange();
            zedPopulacao.Invalidate();
            zedPopulacao.Refresh();
        }
コード例 #10
0
        private void DrawCurveGraph()
        {
            zedGraphControl1.GraphPane.CurveList.Clear();
            zedGraphControl1.GraphPane.GraphObjList.Clear();
            zedGraphControl1.RestoreScale(zedGraphControl1.GraphPane);


            zedGraphControl1.GraphPane.Chart.Fill = new ZedGraph.Fill(Color.White, Color.SteelBlue, 45.0F);
            if (m_pnt3ds != null)
            {
                GraphPane myPane = zedGraphControl1.GraphPane;


                myPane.Legend.IsVisible = false;



                PointPairList list = new PointPairList();

                int    nPointCount = m_pnt3ds.Count;
                double dOneSegLen  = m_dXTotalLength / (nPointCount - 1);

                for (int i = 0; i < m_pnt3ds.Count; i++)
                {
                    double x = i * dOneSegLen;
                    double y = (int)(Math.Round(m_pnt3ds[i].Z * 100)) / 100.0; // 精确到厘米就行了
                    list.Add(x, y);
                }


                myPane.AddStick("采样线", list, Color.Blue);

                LineItem myCurve = myPane.AddCurve("剖面", list, Color.Blue, SymbolType.None);
                //myCurve.Symbol.Fill = new Fill(Color.White);
                myCurve.Line.IsAntiAlias = true;
                myCurve.Line.IsSmooth    = true;
                myCurve.Line.Width       = 2;
                myCurve.Line.Fill        = new Fill(Color.Yellow, Color.LightGray, 45.0f);



                // Show the x axis grid
                myPane.XAxis.MajorGrid.IsVisible  = true;
                myPane.XAxis.IsAxisSegmentVisible = true;


                if (m_bSetMinX)
                {
                    myPane.XAxis.Scale.Min = 0;
                }


                if (m_bSetMinY)
                {
                    myPane.YAxis.Scale.Min = m_pntMin.Z;
                }



                // Make the Y axis scale red
                //myPane.YAxis.Scale.FontSpec.FontColor = Color.Red;
                //myPane.YAxis.Title.FontSpec.FontColor = Color.Red;
                // turn off the opposite tics so the Y tics don't show up on the Y2 axis
                //myPane.YAxis.MajorTic.IsOpposite = false;
                // myPane.YAxis.MinorTic.IsOpposite = false;



                myPane.YAxis.MajorGrid.IsVisible = true;
                // Don't display the Y zero line
                myPane.YAxis.MajorGrid.IsZeroLine = false;
                // Align the Y axis labels so they are flush to the axis
                myPane.YAxis.Scale.Align = AlignP.Inside;
                // Manually set the axis range
                //myPane.YAxis.Scale.Min = -1000;
                // myPane.YAxis.Scale.Max = 1000;


                // Fill the axis background with a gradient
                myPane.Chart.Fill = new Fill(Color.White, Color.LightGray, 45.0f);


                // Enable scrollbars if needed
                //zedGraphControl1.IsShowHScrollBar = true;
                //zedGraphControl1.IsShowVScrollBar = true;
                zedGraphControl1.IsAutoScrollRange = true;


                // OPTIONAL: Show tooltips when the mouse hovers over a point
                zedGraphControl1.IsShowPointValues = true;
                zedGraphControl1.PointValueEvent  += new ZedGraphControl.PointValueHandler(MyPointValueHandler);


                // OPTIONAL: Handle the Zoom Event
                zedGraphControl1.ZoomEvent += new ZedGraphControl.ZoomEventHandler(MyZoomEvent);



                // Size the control to fit the window
                //SetSize();

                // Tell ZedGraph to calculate the axis ranges
                // Note that you MUST call this after enabling IsAutoScrollRange, since AxisChange() sets
                // up the proper scrolling parameters
                zedGraphControl1.AxisChange();
                if (m_bXYSameScale)
                {
                    graphPane_AxisChangeEvent();
                }

                // Make sure the Graph gets redrawn
                zedGraphControl1.Invalidate();

                SetLableText();
            }
        }