Exemplo n.º 1
0
        /// <summary>
        /// Constructor to initialize the PointPairList from two arrays of
        /// type double.
        /// </summary>
        public FilteredPointList(IReadOnlyList <double> x, IReadOnlyList <double> y)
        {
            var len = Math.Max(x.Count, y.Count);
            var dt  = new CompactPt[len];

            if (x.Count < y.Count)
            {
                for (var i = 0; i < x.Count; ++i)
                {
                    dt[i] = new CompactPt(x[i], y[i]);
                }
                for (var i = x.Count; i < y.Count; ++i)
                {
                    dt[i] = new CompactPt(PointPairBase.Missing, y[i]);
                }
            }
            else
            {
                for (var i = 0; i < y.Count; ++i)
                {
                    dt[i] = new CompactPt(x[i], y[i]);
                }
                for (var i = y.Count; i < x.Count; ++i)
                {
                    dt[i] = new CompactPt(x[i], PointPairBase.Missing);
                }
            }

            _data = dt;
        }
Exemplo n.º 2
0
//    /// <summary>
//    /// Switch used to indicate if the next filtered point should be the high point or the
//    /// low point within the current range.
//    /// </summary>
//    private bool _upDown = false;

//    /// <summary>
//    /// Determines if the high/low logic will be used.
//    /// </summary>
//    private bool _isApplyHighLowLogic = true;

        #endregion

        #region Properties

        /// <summary>
        /// Indexer to access the specified <see cref="PointPair"/> object by
        /// its ordinal position in the list.
        /// </summary>
        /// <remarks>
        /// Returns <see cref="PointPairBase.Missing" /> for any value of <see paramref="index" />
        /// that is outside of its corresponding array bounds.
        /// </remarks>
        /// <param name="index">The ordinal position (zero-based) of the
        /// <see cref="PointPair"/> object to be accessed.</param>
        /// <value>A <see cref="PointPair"/> object reference.</value>
        public IPointPair this[int index]
        {
            get
            {
                // See if the array should be bounded
                if (_minBoundIndex >= 0 && _maxBoundIndex >= 0 && MaxPts >= 0)
                {
                    // get number of points in bounded range
                    var nPts = _maxBoundIndex - _minBoundIndex + 1;

                    if (nPts > MaxPts)
                    {
                        // if we're skipping points, then calculate the new index
                        index = _minBoundIndex + (int)(index * (double)nPts / MaxPts);
                    }
                    else
                    {
                        // otherwise, index is just offset by the start of the bounded range
                        index += _minBoundIndex;
                    }
                }

                return(index >= 0 && index < _data.Length ? (IPointPair)_data[index] : PointPair.Empty);
            }

            set
            {
                // See if the array should be bounded
                if (_minBoundIndex >= 0 && _maxBoundIndex >= 0 && MaxPts >= 0)
                {
                    // get number of points in bounded range
                    int nPts = _maxBoundIndex - _minBoundIndex + 1;

                    if (nPts > MaxPts)
                    {
                        // if we're skipping points, then calculate the new index
                        index = _minBoundIndex + (int)(index * (double)nPts / MaxPts);
                    }
                    else
                    {
                        // otherwise, index is just offset by the start of the bounded range
                        index += _minBoundIndex;
                    }
                }

                if (index >= 0 && index < _data.Length)
                {
                    _data[index] = new CompactPt(value);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Indexer: get the DataPoint instance at the specified ordinal position in the list
        /// </summary>
        /// <remarks>
        /// This method will throw an exception if the index is out of range.  This can happen
        /// if the index is less than the number of filtered values, or if data points are
        /// removed from a filtered dataset with updating the filter (by calling
        /// <see cref="FilterData" />).
        /// </remarks>
        /// <param name="index">The ordinal position in the list of points</param>
        /// <returns>Returns a <see cref="PointPair" /> instance.  The <see cref="PointPair.Z" />
        /// and <see cref="PointPair.Tag" /> properties will be defaulted to
        /// <see cref="PointPairBase.Missing" /> and null, respectively.
        /// </returns>
        public new IPointPair this[int index]
        {
            get
            {
                int j = index;
                if (_isFiltered)
                {
                    j = _visibleIndicies[index];
                }

                return(base[j]);
            }
            set
            {
                int j = index;
                if (_isFiltered)
                {
                    j = _visibleIndicies[index];
                }

                base[j] = new CompactPt(value);
            }
        }