Draw() public method

Draw the the PlotSurface2D and all contents [axes, drawables] on the supplied graphics surface.
public Draw ( Graphics g, Rectangle bounds ) : void
g System.Drawing.Graphics The graphics surface on which to draw.
bounds System.Drawing.Rectangle A bounding box on this surface that denotes the area on the /// surface to confine drawing to.
return void
Esempio n. 1
0
        public Gdk.Pixbuf CreateIcon3D(Table3D table)
        {
            if (table.Zmin == table.Zmax)
            {
                return(GetNoDataPixBuf);
            }

            Plot3D.Draw(plotSurface, table);

            // Things like Padding needs to be set each time after Clear()
            plotSurface.Padding = padding;

            using (System.Drawing.Graphics g = Graphics.FromImage(bitmap_cache)) {
                plotSurface.Draw(g, bounds);
            }

            if (memoryStream == null)
            {
                memoryStream = new System.IO.MemoryStream(MemoryStreamCapacity);
            }
            memoryStream.Position = 0;
            bitmap_cache.Save(memoryStream, imageFormat);
            memoryStream.Position = 0;
            // TODO create Pixbuf directly from bitmap if possible, avoiding MemoryStream
            return(new Gdk.Pixbuf(memoryStream));
        }
Esempio n. 2
0
        public Gdk.Pixbuf CreateIcon2D(Table2D table)
        {
            if (table.Ymin == table.Ymax)
            {
                return(GetNoDataPixBuf);
            }

            plotSurface.Clear();
            // needs to be set each time after Clear()
            plotSurface.Padding       = padding;
            plotSurface.SmoothingMode = SmoothingMode;

            float[] valuesY = table.GetValuesYasFloats();

            // y-values, x-values (!)
            LinePlot lp = new LinePlot(valuesY, table.ValuesX);

            lp.Pen = pen;

            plotSurface.Add(lp);

            plotSurface.XAxis1.Hidden = true;
            plotSurface.YAxis1.Hidden = true;

            using (System.Drawing.Graphics g = Graphics.FromImage(bitmap_cache)) {
                plotSurface.Draw(g, bounds);
            }

            if (memoryStream == null)
            {
                memoryStream = new System.IO.MemoryStream(MemoryStreamCapacity);
            }
            memoryStream.Position = 0;
            bitmap_cache.Save(memoryStream, imageFormat);
            memoryStream.Position = 0;
            // TODO create Pixbuf directly from bitmap if possible, avoiding MemoryStream
            return(new Gdk.Pixbuf(memoryStream));
        }
Esempio n. 3
0
	static void Main ()
	{
#if GTK
		Application.Init ();

		Window w = new Window ("Test");
		w.DeleteEvent += delegate {
			Application.Quit ();
		};
		
		NPlot.Gtk.PlotSurface2D plot = new NPlot.Gtk.PlotSurface2D ();

		PlotTest (plot);
		
		plot.Show ();
		w.Add (plot);
		w.ShowAll ();

		Application.Run ();
#else

		NPlot.PlotSurface2D s = new NPlot.PlotSurface2D ();
		Bitmap b = new Bitmap (1000, 1000);
		Graphics g = Graphics.FromImage (b);
		g.FillRectangle  (Brushes.White, 0, 0, 1000, 1000);
		Rectangle bounds = new Rectangle (0, 0, 1000, 1000);
		PlotTest (s);
		s.Draw (g, bounds);
		b.Save ("file.png", ImageFormat.Png);
#endif
	}