Plotter.cs :  » Build-Systems » CruiseControl.NET » ThoughtWorks » CruiseControl » Core » Publishers » Statistics » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Build Systems » CruiseControl.NET 
CruiseControl.NET » ThoughtWorks » CruiseControl » Core » Publishers » Statistics » Plotter.cs
using System.Collections;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using NPlot;
using PlotSurface2DNPlot.Bitmap.PlotSurface2D;

namespace ThoughtWorks.CruiseControl.Core.Publishers.Statistics{
    /// A 2-dimensional surface plotter.
    public class Plotter : IPlotter
  {
        /// <summary>
        /// The directory where the file will be created.
        /// </summary>
    private string savePath;
        /// <summary>
        /// The disk file extension (should make sense for <see cref="imageFormat"/>.
        /// </summary>
      private readonly string fileExtension;
        /// <summary>
        /// The type of image to generate.
        /// </summary>
      private ImageFormat imageFormat;

        /// <summary>
        /// Create a 2-dimensional surface plotter with the specified disk location and image format.
        /// </summary>
        /// <param name="savePath">The directory where the file will be created.</param>
        /// <param name="fileExtension">The disk file extension (should make sense
        /// for <paramref name="imageFormat"/>.</param>
        /// <param name="imageFormat">The type of image to generate.</param>
      public Plotter(string savePath, string fileExtension, ImageFormat imageFormat)
    {
      this.savePath = savePath;
          this.fileExtension = fileExtension;
          this.imageFormat = imageFormat;
    }

        /// <summary>
        /// Plot a set of statistic data and save it to the configured disk file.
        /// </summary>
        /// <param name="ordinateData">The Y-axis data values.</param>
        /// <param name="abscissaData">The X-axis data values.</param>
        /// <param name="statisticName">The name of the statistic to plot.</param>
        /// <remarks>
        /// The disk file name will be
        /// <i><see cref="savePath"/></i>.<i><paramref name="statisticName"/></i>.<i><see cref="fileExtension"/></i>. 
        /// </remarks>
        public void DrawGraph(IList ordinateData, IList abscissaData, string statisticName)
    {
      Bitmap bitmap = Plot(ordinateData, abscissaData);
      bitmap.Save(Path.Combine(savePath, string.Format("{0}.{1}", statisticName, fileExtension)));
    }

    /// <summary>
        /// Plot a set of statistic data and write the image to a stream.
    /// </summary>
        /// <param name="ordinateData">The Y-axis data values.</param>
        /// <param name="abscissaData">The X-axis data values.</param>
        /// <param name="stream">The stream to receive the resulting image.</param>
        public void WriteToStream(IList ordinateData, IList abscissaData, Stream stream)
    {
      Bitmap bitmap = Plot(ordinateData, abscissaData);
      bitmap.Save(stream, imageFormat);
    }

        /// <summary>
        /// Create a 2-dimensional surface plot of the specified statistic data.
        /// </summary>
        /// <param name="ordinateData">The Y-axis data values.</param>
        /// <param name="abscissaData">The X-axis data values.</param>
        /// <returns>The plot image bitmap.</returns>
    private static Bitmap Plot(IList ordinateData, IList abscissaData)
    {

      PlotSurface2D plotSurface2D = new PlotSurface2D(200, 200);
        plotSurface2D.SmoothingMode = SmoothingMode.HighQuality;

        LinePlot linePlot = new LinePlot(ordinateData, abscissaData);
      linePlot.ShadowColor = Color.Beige;
      linePlot.Pen = new Pen(Color.Blue);
      linePlot.Pen.Width = 1.0f;
      plotSurface2D.Add(linePlot);
      plotSurface2D.Refresh();
      return plotSurface2D.Bitmap;
    }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.