Click here to Skip to main content
15,892,289 members
Articles / Programming Languages / C#

Reconstruction of Charts from Images

Rate me:
Please Sign up or sign in to vote.
4.92/5 (13 votes)
18 Mar 2010CPOL7 min read 38K   4.1K   42  
Usage of universal framework for chart reconstruction
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;


using Chart.Drawing.Interfaces;

namespace Chart.Drawing.Painters
{
    public class StepSeriesPainter : SimpleSeriesPainter
    {

 
        #region Constructors

        public StepSeriesPainter(Color color)
            : base(color)
        {
        }

        #endregion

        #region ISeriesPainter Members

        /// <summary>
        /// Draws series
        /// </summary>
        /// <param name="series">Series to draw</param>
        /// <param name="g">Graphics to draw</param>
        public override void Draw(ISeries series, Graphics g)
        {
            IList<IPoint> points = series.Points;
            if (points.Count < 2)
            {
                return;
            }
            IPoint xx = points[0];
            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    dSize[i, j] = performer[i, j];
                }
            }
            if ((dSize[0, 1] == dSize[1, 1]) | (dSize[0, 0] == dSize[1, 0]))
            {
                return;
            }
            int[] size = performer.CanvasSize;
            performer.Transform(xx.X, xx.Y, pointStart);
            for (int i = 1; i < points.Count; i++)
            {
                xx = points[i];
                performer.Transform(xx.X, xx.Y, pointFinish);
                int dx = Math.Abs(pointStart[0] - pointFinish[0]);
                int dy = Math.Abs(pointStart[1] - pointFinish[1]);
                if ((dx < performer.StepX) | (dy < performer.StepY))
                {
                    continue;
                }
                g.DrawLine(pen, pointStart[0], pointStart[1], pointFinish[0], pointStart[1]);
                g.DrawLine(pen, pointFinish[0], pointStart[1], pointFinish[0], pointFinish[1]);
                pointStart[0] = pointFinish[0];
                pointStart[1] = pointFinish[1];
            }
        }

        #endregion

        #region ICloneable Members


        /// <summary>
        /// Clones itself
        /// </summary>
        /// <returns>The clone</returns>
        public override object Clone()
        {
            return new StepSeriesPainter(color);
        }

 
   
        #endregion
 

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
Russian Federation Russian Federation
Ph. D. Petr Ivankov worked as scientific researcher at Russian Mission Control Centre since 1978 up to 2000. Now he is engaged by Aviation training simulators http://dinamika-avia.com/ . His additional interests are:

1) Noncommutative geometry

http://front.math.ucdavis.edu/author/P.Ivankov

2) Literary work (Russian only)

http://zhurnal.lib.ru/editors/3/3d_m/

3) Scientific articles
http://arxiv.org/find/all/1/au:+Ivankov_Petr/0/1/0/all/0/1

Comments and Discussions