Exemple #1
0
        public PlottableSignalBase(T[] ys, double sampleRate, double xOffset, double yOffset, Color color,
                                   double lineWidth, double markerSize, string label, Color[] colorByDensity,
                                   int minRenderIndex, int maxRenderIndex, LineStyle lineStyle, bool useParallel,
                                   IMinMaxSearchStrategy <T> minMaxSearchStrategy = null)
        {
            if (ys == null)
            {
                throw new Exception("Y data cannot be null");
            }

            this.ys           = ys;
            this.sampleRate   = sampleRate;
            this.samplePeriod = 1.0 / sampleRate;
            this.markerSize   = (float)markerSize;
            this.xOffset      = xOffset;
            this.label        = label;
            this.color        = color;
            this.lineWidth    = lineWidth;
            this.fillType     = FillType.NoFill;
            this.yOffset      = yOffset;
            this.baseline     = 0;
            if (minRenderIndex < 0 || minRenderIndex > maxRenderIndex)
            {
                throw new ArgumentException("minRenderIndex must be between 0 and maxRenderIndex");
            }
            this.minRenderIndex = minRenderIndex;
            if ((maxRenderIndex > ys.Length - 1) || maxRenderIndex < 0)
            {
                throw new ArgumentException("maxRenderIndex must be a valid index for ys[]");
            }
            this.maxRenderIndex = maxRenderIndex;
            this.lineStyle      = lineStyle;
            this.useParallel    = useParallel;
            brush = new SolidBrush(color);
            penLD = GDI.Pen(color, (float)lineWidth, lineStyle, true);
            penHD = GDI.Pen(color, (float)lineWidth, LineStyle.Solid, true);

            if (colorByDensity != null)
            {
                // turn the ramp into a pen triangle
                densityLevelCount = colorByDensity.Length * 2 - 1;
                penByDensity      = new Pen[densityLevelCount];
                for (int i = 0; i < colorByDensity.Length; i++)
                {
                    penByDensity[i] = new Pen(colorByDensity[i]);
                    penByDensity[densityLevelCount - 1 - i] = new Pen(colorByDensity[i]);
                }
            }
            if (minMaxSearchStrategy == null)
            {
                this.minmaxSearchStrategy = new SegmentedTreeMinMaxSearchStrategy <T>();
            }
            else
            {
                this.minmaxSearchStrategy = minMaxSearchStrategy;
            }
            minmaxSearchStrategy.SourceArray = ys;
        }
 public PlottableSignalXYConst(TX[] xs, TY[] ys, Color color, double lineWidth, double markerSize, string label, int minRenderIndex, int maxRenderIndex, LineStyle lineStyle, bool useParallel, IMinMaxSearchStrategy <TY> minMaxSearchStrategy = null)
     : base(xs, ys, color, lineWidth, markerSize, label, minRenderIndex, maxRenderIndex, lineStyle, useParallel, new SegmentedTreeMinMaxSearchStrategy <TY>())
 {
 }
Exemple #3
0
        public PlottableSignalXYGeneric(TX[] xs, TY[] ys, Color color, double lineWidth, double markerSize, string label, int minRenderIndex, int maxRenderIndex, LineStyle lineStyle, bool useParallel, IMinMaxSearchStrategy <TY> minMaxSearchStrategy = null)
            : base(ys, 1, 0, 0, color, lineWidth, markerSize, label, null, minRenderIndex, maxRenderIndex, lineStyle, useParallel, minMaxSearchStrategy)
        {
            if ((xs == null) || (ys == null))
            {
                throw new ArgumentException("X and Y data cannot be null");
            }

            if ((xs.Length == 0) || (ys.Length == 0))
            {
                throw new ArgumentException("xs and ys must have at least one element");
            }

            if (xs.Length != ys.Length)
            {
                throw new ArgumentException("Xs and Ys must have same length");
            }

            for (int i = 1; i < xs.Length; i++)
            {
                if (xs[i].CompareTo(xs[i - 1]) < 0)
                {
                    throw new ArgumentException("Xs must only contain ascending values");
                }
            }

            if (minMaxSearchStrategy == null)
            {
                this.minmaxSearchStrategy = new SegmentedTreeMinMaxSearchStrategy <TY>();
            }
            else
            {
                this.minmaxSearchStrategy = minMaxSearchStrategy;
            }
            minmaxSearchStrategy.SourceArray = ys;

            this.xs = xs;
        }