Ejemplo n.º 1
0
        /// <summary>
        /// Initialize/reset the integration method
        /// </summary>
        public virtual void Initialize()
        {
            // Initialize variables
            Time = 0.0;
            Breaks.Clear();
            Order      = 1;
            Delta      = double.NaN;
            Prediction = null;
            DeltaOld   = new double[MaxOrder + 1];
            Solutions  = new Vector <double> [MaxOrder + 1];
            savetime   = double.NaN;
            savedelta  = double.NaN;

            // Last point was START so the current point is the point after a breakpoint (start)
            Break = true;

            // Initialize the old timesteps - none
            for (int i = 0; i < DeltaOld.Length; i++)
            {
                DeltaOld[i] = double.NaN;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Updates the raster breaks.
        /// </summary>
        public void UpdateRasterBreaks()
        {
            if (_rasterLayer == null)
            {
                return;
            }
            IColorCategory selectedBrk = null;

            if (_selectedSlider != null)
            {
                selectedBrk = _selectedSlider.Category as IColorCategory;
            }
            Breaks.Clear();
            Statistics stats = _rasterSymbolizer.Scheme.Statistics;
            Rectangle  gb    = _graph.GetGraphBounds();

            _graph.ColorRanges.Clear();
            foreach (IColorCategory category in _rasterSymbolizer.Scheme.Categories)
            {
                ColorRange cr = new ColorRange(category.LowColor, category.Range);
                _graph.ColorRanges.Add(cr);
                BreakSlider bs = new BreakSlider(gb, _graph.Minimum, _graph.Maximum, cr)
                {
                    Color       = _breakColor,
                    SelectColor = _selectedBreakColor
                };
                if (selectedBrk != null && category == selectedBrk)
                {
                    bs.Selected          = true;
                    _selectedSlider      = bs;
                    _graph.SelectedRange = cr;
                }

                bs.Value = category.Maximum != null?double.Parse(category.Maximum.ToString()) : stats.Maximum;

                bs.Category = category;
                Breaks.Add(bs);
            }

            Breaks.Sort();

            // Moving a break generally affects both a maximum and a minimum.
            // Point to the next category to actuate that.
            for (int i = 0; i < Breaks.Count - 1; i++)
            {
                Breaks[i].NextCategory = Breaks[i + 1].Category;

                // We use the maximums to set up breaks. Minimums should simply
                // be set to work with the maximums of the previous category.
                // _breaks[i + 1].Category.Minimum = _breaks[i].Value; REMOVED BY jany_ (2015-07-07) Don't set minimum, because that changes the minimum of the rasters category which causes the colors to change when saving in RasterColorControl without making changes or for example only applying opacity without wanting to use statistics.
            }

            if (Breaks.Count == 0)
            {
                return;
            }
            int         breakIndex = 0;
            BreakSlider nextSlider = Breaks[breakIndex];
            int         count      = 0;

            if (_graph?.Bins == null)
            {
                return;
            }
            foreach (double value in _values)
            {
                if (value < nextSlider.Value)
                {
                    count++;
                    continue;
                }

                nextSlider.Count = count;
                while (value > nextSlider.Value)
                {
                    breakIndex++;
                    if (breakIndex >= Breaks.Count)
                    {
                        break;
                    }

                    nextSlider = Breaks[breakIndex];
                }

                count = 0;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Given a scheme, this will build the break list to match approximately. This does not
        /// force the interval method to build a new scheme.
        /// </summary>
        public void UpdateBreaks()
        {
            if (_isRaster)
            {
                UpdateRasterBreaks();
                return;
            }

            if (_scheme == null)
            {
                return;
            }
            IFeatureCategory selectedCat = null;

            if (_selectedSlider != null)
            {
                selectedCat = _selectedSlider.Category as IFeatureCategory;
            }
            Breaks.Clear();
            Statistics stats = _scheme.Statistics;
            Rectangle  gb    = _graph.GetGraphBounds();

            _graph.ColorRanges.Clear();
            foreach (IFeatureCategory category in _scheme.GetCategories())
            {
                ColorRange cr = new ColorRange(category.GetColor(), category.Range);
                _graph.ColorRanges.Add(cr);
                BreakSlider bs = new BreakSlider(gb, _graph.Minimum, _graph.Maximum, cr)
                {
                    Color       = _breakColor,
                    SelectColor = _selectedBreakColor
                };
                if (selectedCat != null && category == selectedCat)
                {
                    bs.Selected          = true;
                    _selectedSlider      = bs;
                    _graph.SelectedRange = cr;
                }

                bs.Value = category.Maximum != null?double.Parse(category.Maximum.ToString()) : stats.Maximum;

                bs.Category = category;
                Breaks.Add(bs);
            }

            Breaks.Sort();

            // Moving a break generally affects both a maximum and a minimum.
            // Point to the next category to actuate that.
            for (int i = 0; i < Breaks.Count - 1; i++)
            {
                Breaks[i].NextCategory = Breaks[i + 1].Category;

                // We use the maximums to set up breaks. Minimums should simply
                // be set to work with the maximums of the previous category.
                Breaks[i + 1].Category.Minimum = Breaks[i].Value;
            }

            if (Breaks.Count == 0)
            {
                return;
            }
            int         breakIndex = 0;
            BreakSlider nextSlider = Breaks[breakIndex];
            int         count      = 0;

            if (_graph?.Bins == null)
            {
                return;
            }
            foreach (double value in _values)
            {
                if (value < nextSlider.Value)
                {
                    count++;
                    continue;
                }

                nextSlider.Count = count;
                while (value > nextSlider.Value)
                {
                    breakIndex++;
                    if (breakIndex >= Breaks.Count)
                    {
                        break;
                    }

                    nextSlider = Breaks[breakIndex];
                }

                count = 0;
            }
        }