NPlot.ImagePlot.Draw C# (CSharp) Метод

Draw() публичный Метод

Draw on to the supplied graphics surface against the supplied axes.
TODO: block positions may be off by a pixel or so. maybe. Re-think calculations
public Draw ( Graphics g, PhysicalAxis xAxis, PhysicalAxis yAxis ) : void
g System.Drawing.Graphics The graphics surface on which to draw.
xAxis PhysicalAxis The X-Axis to draw against.
yAxis PhysicalAxis The Y-Axis to draw against.
Результат void
        public void Draw( Graphics g, PhysicalAxis xAxis, PhysicalAxis yAxis )
        {
            if ( data_==null || data_.GetLength(0) == 0 || data_.GetLength(1) == 0 )
            {
                return;
            }

            double worldWidth = xAxis.Axis.WorldMax - xAxis.Axis.WorldMin;
            double numBlocksHorizontal = worldWidth / this.xStep_;
            double worldHeight = yAxis.Axis.WorldMax - yAxis.Axis.WorldMin;
            double numBlocksVertical = worldHeight / this.yStep_;

            double physicalWidth = xAxis.PhysicalMax.X - xAxis.PhysicalMin.X;
            double blockWidth = physicalWidth / numBlocksHorizontal;
            bool wPositive = true;
            if (blockWidth < 0.0)
            {
                wPositive = false;
            }
            blockWidth = Math.Abs(blockWidth)+1;

            double physicalHeight = yAxis.PhysicalMax.Y - yAxis.PhysicalMin.Y;
            double blockHeight = physicalHeight / numBlocksVertical;
            bool hPositive = true;
            if (blockHeight < 0.0)
            {
                hPositive = false;
            }
            blockHeight = Math.Abs(blockHeight)+1;

            for (int i=0; i<data_.GetLength(0); ++i)
            {
                for (int j=0; j<data_.GetLength(1); ++j)
                {
                    double wX = (double)j*this.xStep_ + xStart_;
                    double wY = (double)i*this.yStep_ + yStart_;
                    if ( !hPositive )
                    {
                        wY += yStep_;
                    }
                    if (!wPositive )
                    {
                        wX += xStep_;
                    }

                    if (this.center_)
                    {
                        wX -= this.xStep_/2.0;
                        wY -= this.yStep_/2.0;
                    }
                    Pen p = new Pen( this.Gradient.GetColor( (data_[i,j]-this.dataMin_)/(this.dataMax_-this.dataMin_) ) );
                    int x = (int)xAxis.WorldToPhysical(wX,false).X;
                    int y = (int)yAxis.WorldToPhysical(wY,false).Y;
                    g.FillRectangle( p.Brush,
                        x,
                        y,
                        (int)blockWidth,
                        (int)blockHeight);
                    //g.DrawRectangle(Pens.White,x,y,(int)blockWidth,(int)blockHeight);
                }
            }
        }