/// <summary> /// /// </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); bs.Color = _breakColor; bs.SelectColor = _selectedBreakColor; if (selectedBrk != null && category == selectedBrk) { bs.Selected = true; _selectedSlider = bs; _graph.SelectedRange = cr; } if (category.Maximum != null) { bs.Value = double.Parse(category.Maximum.ToString()); } else { bs.Value = 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 == null || _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; } }
/// <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); bs.Color = _breakColor; bs.SelectColor = _selectedBreakColor; if (selectedCat != null && category == selectedCat) { bs.Selected = true; _selectedSlider = bs; _graph.SelectedRange = cr; } if (category.Maximum != null) { bs.Value = double.Parse(category.Maximum.ToString()); } else { bs.Value = 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 == null || _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; } }