Changeset 12725
- Timestamp:
- 07/11/15 13:37:32 (9 years ago)
- Location:
- stable
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 12077,12112,12116-12117,12131,12173,12458,12599,12613,12631,12672,12684,12690,12692
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Analysis.Statistics.Views/3.3/ChartAnalysisView.cs
r12009 r12725 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using System.Threading; 25 26 using System.Threading.Tasks; 26 27 using System.Windows.Forms; … … 52 53 private bool valuesAdded = false; 53 54 private bool suppressUpdates = false; 55 private SemaphoreSlim sem = new SemaphoreSlim(1, 1); 54 56 55 57 public ChartAnalysisView() { … … 108 110 109 111 void Content_RowsChanged(object sender, EventArgs e) { 110 RebuildDataTableAsync(); 112 if (suppressUpdates) return; 113 if (InvokeRequired) Invoke((Action<object, EventArgs>)Content_RowsChanged, sender, e); 114 else { 115 RebuildDataTableAsync(); 116 } 111 117 } 112 118 113 119 void Content_ColumnsChanged(object sender, EventArgs e) { 114 RebuildDataTableAsync(); 120 if (suppressUpdates) return; 121 if (InvokeRequired) Invoke((Action<object, EventArgs>)Content_ColumnsChanged, sender, e); 122 else { 123 UpdateDataTableComboBox(); 124 RebuildDataTableAsync(); 125 } 115 126 } 116 127 117 128 private void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) { 118 UpdateComboboxes(); 119 RebuildDataTableAsync(); 129 if (suppressUpdates) return; 130 if (InvokeRequired) Invoke((Action<object, CollectionItemsChangedEventArgs<IRun>>)Content_CollectionReset, sender, e); 131 else { 132 UpdateComboboxes(); 133 RebuildDataTableAsync(); 134 } 120 135 } 121 136 122 137 private void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) { 123 suppressUpdates = Content.UpdateOfRunsInProgress; 124 125 if (!suppressUpdates && !valuesAdded) { 126 RebuildDataTableAsync(); 127 } 128 if (valuesAdded) { 129 valuesAdded = false; 138 if (InvokeRequired) Invoke((Action<object, EventArgs>)Content_UpdateOfRunsInProgressChanged, sender, e); 139 else { 140 suppressUpdates = Content.UpdateOfRunsInProgress; 141 142 if (!suppressUpdates && !valuesAdded) { 143 UpdateDataTableComboBox(); 144 RebuildDataTableAsync(); 145 } 146 if (valuesAdded) { 147 valuesAdded = false; 148 } 130 149 } 131 150 } … … 149 168 150 169 private void dataRowComboBox_SelectedIndexChanged(object sender, EventArgs e) { 170 if (suppressUpdates) return; 151 171 RebuildDataTableAsync(); 152 172 } … … 246 266 247 267 private void RebuildDataTableAsync() { 248 progress = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, "Calculating values...");249 250 268 string resultName = (string)dataTableComboBox.SelectedItem; 269 if (string.IsNullOrEmpty(resultName)) return; 270 251 271 string rowName = (string)dataRowComboBox.SelectedItem; 252 272 253 var task = Task.Factory.StartNew(() => RebuildDataTable(resultName, rowName)); 273 var task = Task.Factory.StartNew(() => { 274 sem.Wait(); 275 progress = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, "Calculating values..."); 276 RebuildDataTable(resultName, rowName); 277 }); 254 278 255 279 task.ContinueWith((t) => { 256 280 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this); 257 281 ErrorHandling.ShowErrorDialog("An error occured while calculating values. ", t.Exception); 282 sem.Release(); 258 283 }, TaskContinuationOptions.OnlyOnFaulted); 259 284 260 285 task.ContinueWith((t) => { 261 286 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this); 287 sem.Release(); 262 288 }, TaskContinuationOptions.OnlyOnRanToCompletion); 263 289 } … … 289 315 double percentile25 = values.Percentile(0.25); 290 316 double percentile75 = values.Percentile(0.75); 291 double lowerAvg = values. OrderBy(x => x).Take((int)(values.Count() * 0.25)).Average();292 double upperAvg = values. OrderByDescending(x => x).Take((int)(values.Count() * 0.25)).Average();293 double firstAvg = values. Take((int)(values.Count() * 0.25)).Average();294 double lastAvg = values. Skip((int)(values.Count() * 0.75)).Average();317 double lowerAvg = values.Count() > 4 ? values.OrderBy(x => x).Take((int)(values.Count() * 0.25)).Average() : double.NaN; 318 double upperAvg = values.Count() > 4 ? values.OrderByDescending(x => x).Take((int)(values.Count() * 0.25)).Average() : double.NaN; 319 double firstAvg = values.Count() > 4 ? values.Take((int)(values.Count() * 0.25)).Average() : double.NaN; 320 double lastAvg = values.Count() > 4 ? values.Skip((int)(values.Count() * 0.75)).Average() : double.NaN; 295 321 double slope, intercept, r; 296 322 llsFitting.Calculate(values, out slope, out intercept); -
stable/HeuristicLab.Analysis.Statistics.Views/3.3/CorrelationView.cs
r12199 r12725 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HeuristicLab.Collections; 25 26 using HeuristicLab.Core.Views; 26 27 using HeuristicLab.Data; … … 81 82 Content.ColumnsChanged += Content_ColumnsChanged; 82 83 Content.RowsChanged += Content_RowsChanged; 83 Content.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);84 Content.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset); 84 85 Content.UpdateOfRunsInProgressChanged += Content_UpdateOfRunsInProgressChanged; 85 86 } … … 89 90 Content.ColumnsChanged -= Content_ColumnsChanged; 90 91 Content.RowsChanged -= Content_RowsChanged; 91 Content.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);92 Content.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset); 92 93 Content.UpdateOfRunsInProgressChanged -= Content_UpdateOfRunsInProgressChanged; 93 94 } 94 95 95 96 void Content_RowsChanged(object sender, EventArgs e) { 96 UpdateUI(); 97 if (suppressUpdates) return; 98 if (InvokeRequired) Invoke((Action<object, EventArgs>)Content_RowsChanged, sender, e); 99 else { 100 UpdateUI(); 101 } 97 102 } 98 103 99 104 void Content_ColumnsChanged(object sender, EventArgs e) { 100 UpdateUI(); 101 } 102 103 private void Content_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) { 104 UpdateUI(); 105 if (suppressUpdates) return; 106 if (InvokeRequired) Invoke((Action<object, EventArgs>)Content_ColumnsChanged, sender, e); 107 else { 108 UpdateUI(); 109 } 110 } 111 112 private void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) { 113 if (suppressUpdates) return; 114 if (InvokeRequired) Invoke((Action<object, CollectionItemsChangedEventArgs<IRun>>)Content_CollectionReset, sender, e); 115 else { 116 UpdateUI(); 117 } 105 118 } 106 119 107 120 private void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) { 108 suppressUpdates = Content.UpdateOfRunsInProgress; 109 UpdateUI(); 121 if (InvokeRequired) Invoke((Action<object, EventArgs>)Content_UpdateOfRunsInProgressChanged, sender, e); 122 else { 123 suppressUpdates = Content.UpdateOfRunsInProgress; 124 UpdateUI(); 125 } 110 126 } 111 127 #endregion 112 128 113 129 private void UpdateUI() { 114 if (!suppressUpdates) { 115 RebuildCorrelationTable(); 116 } 130 RebuildCorrelationTable(); 117 131 } 118 132 -
stable/HeuristicLab.Analysis.Statistics.Views/3.3/SampleSizeInfluenceView.cs
r12009 r12725 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Drawing; 24 25 using System.Linq; 25 26 using System.Windows.Forms; … … 33 34 using HeuristicLab.Optimization; 34 35 using HeuristicLab.PluginInfrastructure; 36 using ViewEventArgs = System.Windows.Forms.DataVisualization.Charting.ViewEventArgs; 35 37 36 38 namespace HeuristicLab.Analysis.Statistics.Views { … … 41 43 private const string BoxPlotSeriesName = "BoxPlotSeries"; 42 44 private const string BoxPlotChartAreaName = "BoxPlotChartArea"; 43 private const string delimit or = ";";44 45 private bool suppressUpdates = false;45 private const string delimiter = ";"; 46 47 private bool suppressUpdates; 46 48 private string yAxisValue; 47 49 private Dictionary<int, Dictionary<object, double>> categoricalMapping; … … 66 68 } 67 69 public IStringConvertibleMatrix Matrix { 68 get { return this.Content; }70 get { return Content; } 69 71 } 70 72 … … 72 74 protected override void RegisterContentEvents() { 73 75 base.RegisterContentEvents(); 74 Content.Reset += new EventHandler(Content_Reset); 75 Content.ColumnNamesChanged += new EventHandler(Content_ColumnNamesChanged); 76 Content.ItemsAdded += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded); 77 Content.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved); 78 Content.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset); 79 Content.UpdateOfRunsInProgressChanged += new EventHandler(Content_UpdateOfRunsInProgressChanged); 80 Content.OptimizerNameChanged += new EventHandler(Content_AlgorithmNameChanged); 76 Content.ColumnNamesChanged += Content_ColumnNamesChanged; 77 Content.ItemsAdded += Content_ItemsAdded; 78 Content.ItemsRemoved += Content_ItemsRemoved; 79 Content.CollectionReset += Content_CollectionReset; 80 Content.UpdateOfRunsInProgressChanged += Content_UpdateOfRunsInProgressChanged; 81 Content.OptimizerNameChanged += Content_AlgorithmNameChanged; 81 82 RegisterRunEvents(Content); 82 83 } 83 84 protected override void DeregisterContentEvents() { 84 85 base.DeregisterContentEvents(); 85 Content.Reset -= new EventHandler(Content_Reset); 86 Content.ColumnNamesChanged -= new EventHandler(Content_ColumnNamesChanged); 87 Content.ItemsAdded -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded); 88 Content.ItemsRemoved -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved); 89 Content.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset); 90 Content.UpdateOfRunsInProgressChanged -= new EventHandler(Content_UpdateOfRunsInProgressChanged); 91 Content.OptimizerNameChanged -= new EventHandler(Content_AlgorithmNameChanged); 86 Content.ColumnNamesChanged -= Content_ColumnNamesChanged; 87 Content.ItemsAdded -= Content_ItemsAdded; 88 Content.ItemsRemoved -= Content_ItemsRemoved; 89 Content.CollectionReset -= Content_CollectionReset; 90 Content.UpdateOfRunsInProgressChanged -= Content_UpdateOfRunsInProgressChanged; 91 Content.OptimizerNameChanged -= Content_AlgorithmNameChanged; 92 92 DeregisterRunEvents(Content); 93 93 } … … 142 142 DeregisterRunEvents(e.OldItems); 143 143 RegisterRunEvents(e.Items); 144 UpdateAll();144 if (!suppressUpdates) UpdateAll(); 145 145 } 146 146 private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) { 147 147 DeregisterRunEvents(e.Items); 148 UpdateComboBoxes();148 if (!suppressUpdates) UpdateComboBoxes(); 149 149 } 150 150 private void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRun> e) { 151 151 RegisterRunEvents(e.Items); 152 UpdateComboBoxes();152 if (!suppressUpdates) UpdateComboBoxes(); 153 153 } 154 154 private void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) { … … 157 157 else { 158 158 suppressUpdates = Content.UpdateOfRunsInProgress; 159 if (!suppressUpdates) UpdateDataPoints(); 160 } 161 } 162 163 private void Content_Reset(object sender, EventArgs e) { 164 if (InvokeRequired) 165 Invoke(new EventHandler(Content_Reset), sender, e); 166 else { 167 this.categoricalMapping.Clear(); 168 UpdateDataPoints(); 169 UpdateAxisLabels(); 159 if (!suppressUpdates) UpdateAll(); 170 160 } 171 161 } … … 174 164 Invoke(new EventHandler(Content_ColumnNamesChanged), sender, e); 175 165 else { 176 UpdateComboBoxes();166 if (!suppressUpdates) UpdateComboBoxes(); 177 167 } 178 168 } 179 169 private void run_Changed(object sender, EventArgs e) { 180 170 if (InvokeRequired) 181 this.Invoke(new EventHandler(run_Changed), sender, e); 182 else if (!suppressUpdates) { 183 UpdateDataPoints(); 184 } 171 Invoke(new EventHandler(run_Changed), sender, e); 172 else if (!suppressUpdates) UpdateDataPoints(); 185 173 } 186 174 … … 188 176 if (InvokeRequired) 189 177 Invoke(new EventHandler(Content_AlgorithmNameChanged), sender, e); 190 else UpdateCaption();178 else if (!suppressUpdates) UpdateCaption(); 191 179 } 192 180 #endregion … … 199 187 200 188 private void UpdateAll() { 201 this.categoricalMapping.Clear();189 categoricalMapping.Clear(); 202 190 UpdateComboBoxes(); 203 191 UpdateDataPoints(); … … 210 198 211 199 private void UpdateSampleSizes(bool forceUpdate = false) { 212 string selectedYAxis = (string) this.yAxisComboBox.SelectedItem;200 string selectedYAxis = (string)yAxisComboBox.SelectedItem; 213 201 214 202 if (selectedYAxis != null && (xAxisTextBox.Text.Trim() == string.Empty || forceUpdate)) { … … 224 212 if (values.Any()) { 225 213 if (hypergeometricCheckBox.Checked) { 226 xAxisTextBox.Text += ((int)(values.Count() / 16)) + delimitor + " ";227 xAxisTextBox.Text += ((int)(values.Count() / 8)) + delimitor + " ";228 xAxisTextBox.Text += (int)(values.Count() / 4);214 xAxisTextBox.Text += values.Count() / 16 + delimiter + " "; 215 xAxisTextBox.Text += values.Count() / 8 + delimiter + " "; 216 xAxisTextBox.Text += values.Count() / 4; 229 217 } else { 230 xAxisTextBox.Text += ((int)(values.Count() / 4)) + delimitor + " ";231 xAxisTextBox.Text += ((int)(values.Count() / 2)) + delimitor + " ";232 xAxisTextBox.Text += ((int)(values.Count() / 4 * 3)) + delimitor + " ";233 xAxisTextBox.Text += (int)(values.Count());218 xAxisTextBox.Text += values.Count() / 4 + delimiter + " "; 219 xAxisTextBox.Text += values.Count() / 2 + delimiter + " "; 220 xAxisTextBox.Text += values.Count() / 4 * 3 + delimiter + " "; 221 xAxisTextBox.Text += values.Count(); 234 222 } 235 223 } … … 238 226 239 227 private void UpdateComboBoxes() { 240 string selectedYAxis = (string)this.yAxisComboBox.SelectedItem; 241 this.xAxisTextBox.Text = string.Empty; 242 this.yAxisComboBox.Items.Clear(); 243 if (Content != null) { 244 string[] additionalAxisDimension = Enum.GetNames(typeof(AxisDimension)); 245 UpdateSampleSizes(); 246 this.yAxisComboBox.Items.AddRange(additionalAxisDimension); 247 this.yAxisComboBox.Items.AddRange(Matrix.ColumnNames.ToArray()); 248 249 if (selectedYAxis != null && yAxisComboBox.Items.Contains(selectedYAxis)) { 250 yAxisComboBox.SelectedItem = selectedYAxis; 251 UpdateDataPoints(); 228 if (InvokeRequired) { 229 Invoke((Action)UpdateComboBoxes); 230 } else { 231 string selectedYAxis = (string)yAxisComboBox.SelectedItem; 232 xAxisTextBox.Text = string.Empty; 233 yAxisComboBox.Items.Clear(); 234 if (Content != null) { 235 string[] additionalAxisDimension = Enum.GetNames(typeof(AxisDimension)); 236 UpdateSampleSizes(); 237 yAxisComboBox.Items.AddRange(additionalAxisDimension); 238 yAxisComboBox.Items.AddRange(Matrix.ColumnNames.ToArray()); 239 240 if (selectedYAxis != null && yAxisComboBox.Items.Contains(selectedYAxis)) { 241 yAxisComboBox.SelectedItem = selectedYAxis; 242 UpdateDataPoints(); 243 } 252 244 } 253 245 } … … 255 247 256 248 private void UpdateDataPoints() { 257 this.chart.Series.Clear();258 this.seriesCache.Clear();249 chart.Series.Clear(); 250 seriesCache.Clear(); 259 251 if (Content != null) { 260 252 var usableRuns = Content.Where(r => r.Visible).ToList(); … … 267 259 } 268 260 269 foreach (Series s in this.seriesCache.Values)270 this.chart.Series.Add(s);261 foreach (Series s in seriesCache.Values) 262 chart.Series.Add(s); 271 263 272 264 UpdateStatistics(); 273 265 if (seriesCache.Count > 0) { 274 266 Series boxPlotSeries = CreateBoxPlotSeries(); 275 this.chart.Series.Add(boxPlotSeries);267 chart.Series.Add(boxPlotSeries); 276 268 } 277 269 … … 328 320 329 321 if (!yAxisComboBox.DroppedDown) 330 this.yAxisValue = (string)yAxisComboBox.SelectedItem;331 332 List<double?> yValue = usableRuns.Select(x => GetValue(x, this.yAxisValue)).ToList();322 yAxisValue = (string)yAxisComboBox.SelectedItem; 323 324 List<double?> yValue = usableRuns.Select(x => GetValue(x, yAxisValue)).ToList(); 333 325 if (yValue.Any(x => !x.HasValue)) return; 334 326 … … 338 330 339 331 private List<int> ParseGroupSizesFromText(string groupsText, bool verbose = true) { 340 string[] gs = groupsText.Split(delimit or.ToCharArray());332 string[] gs = groupsText.Split(delimiter.ToCharArray()); 341 333 List<int> vals = new List<int>(); 342 334 … … 352 344 catch (Exception ex) { 353 345 if (verbose) { 354 ErrorHandling.ShowErrorDialog("Can't parse group sizes. Please only use numbers seperated by a " + delimit or + ". ", ex);346 ErrorHandling.ShowErrorDialog("Can't parse group sizes. Please only use numbers seperated by a " + delimiter + ". ", ex); 355 347 } 356 348 } … … 384 376 } 385 377 matrix.ColumnNames = columnNames; 386 matrix.RowNames = new string[] { "Count", "Minimum", "Maximum", "Average", "Median", "Standard Deviation", "Variance", "25th Percentile", "75th Percentile", "Lower Confidence Int.", "Upper Confidence Int." };378 matrix.RowNames = new[] { "Count", "Minimum", "Maximum", "Average", "Median", "Standard Deviation", "Variance", "25th Percentile", "75th Percentile", "Lower Confidence Int.", "Upper Confidence Int." }; 387 379 388 380 for (int i = 0; i < seriesCache.Count; i++) { … … 415 407 boxPlotSeries["BoxPlotShowUnusualValues"] = "true"; 416 408 boxPlotSeries["PointWidth"] = "0.4"; 417 boxPlotSeries.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.VerticalCenter;418 boxPlotSeries.BackSecondaryColor = System.Drawing.Color.FromArgb(130, 224, 64, 10);419 boxPlotSeries.BorderColor = System.Drawing.Color.FromArgb(64, 64, 64);420 boxPlotSeries.Color = System.Drawing.Color.FromArgb(224, 64, 10);409 boxPlotSeries.BackGradientStyle = GradientStyle.VerticalCenter; 410 boxPlotSeries.BackSecondaryColor = Color.FromArgb(130, 224, 64, 10); 411 boxPlotSeries.BorderColor = Color.FromArgb(64, 64, 64); 412 boxPlotSeries.Color = Color.FromArgb(224, 64, 10); 421 413 422 414 return boxPlotSeries; … … 429 421 430 422 if (!yAxisComboBox.DroppedDown) 431 this.yAxisValue = (string)yAxisComboBox.SelectedItem;423 yAxisValue = (string)yAxisComboBox.SelectedItem; 432 424 433 425 xValue = idx; 434 yValue = GetValue(run, this.yAxisValue);426 yValue = GetValue(run, yAxisValue); 435 427 436 428 if (yValue.HasValue) { 437 if (! this.seriesCache.ContainsKey(xValue))429 if (!seriesCache.ContainsKey(xValue)) 438 430 seriesCache[xValue] = new Series(xValue.ToString()); 439 431 … … 454 446 AxisDimension axisDimension = (AxisDimension)Enum.Parse(typeof(AxisDimension), columnName); 455 447 return GetValue(run, axisDimension); 456 } else { 457 int columnIndex = Matrix.ColumnNames.ToList().IndexOf(columnName); 458 IItem value = Content.GetValue(run, columnIndex); 459 if (value == null) 460 return null; 461 462 DoubleValue doubleValue = value as DoubleValue; 463 IntValue intValue = value as IntValue; 464 TimeSpanValue timeSpanValue = value as TimeSpanValue; 465 double? ret = null; 466 if (doubleValue != null) { 467 if (!double.IsNaN(doubleValue.Value) && !double.IsInfinity(doubleValue.Value)) 468 ret = doubleValue.Value; 469 } else if (intValue != null) 470 ret = intValue.Value; 471 else if (timeSpanValue != null) { 472 ret = timeSpanValue.Value.TotalSeconds; 473 } else 474 ret = GetCategoricalValue(columnIndex, value.ToString()); 475 476 return ret; 477 } 448 } 449 int columnIndex = Matrix.ColumnNames.ToList().IndexOf(columnName); 450 IItem value = Content.GetValue(run, columnIndex); 451 if (value == null) 452 return null; 453 454 DoubleValue doubleValue = value as DoubleValue; 455 IntValue intValue = value as IntValue; 456 TimeSpanValue timeSpanValue = value as TimeSpanValue; 457 double? ret = null; 458 if (doubleValue != null) { 459 if (!double.IsNaN(doubleValue.Value) && !double.IsInfinity(doubleValue.Value)) 460 ret = doubleValue.Value; 461 } else if (intValue != null) 462 ret = intValue.Value; 463 else if (timeSpanValue != null) { 464 ret = timeSpanValue.Value.TotalSeconds; 465 } else 466 ret = GetCategoricalValue(columnIndex, value.ToString()); 467 468 return ret; 478 469 } 479 470 private double GetCategoricalValue(int dimension, string value) { 480 if (! this.categoricalMapping.ContainsKey(dimension)) {481 this.categoricalMapping[dimension] = new Dictionary<object, double>();471 if (!categoricalMapping.ContainsKey(dimension)) { 472 categoricalMapping[dimension] = new Dictionary<object, double>(); 482 473 var orderedCategories = Content.Where(r => r.Visible && Content.GetValue(r, dimension) != null).Select(r => Content.GetValue(r, dimension).ToString()) 483 474 .Distinct().OrderBy(x => x, new NaturalStringComparer()); 484 475 int count = 1; 485 476 foreach (var category in orderedCategories) { 486 this.categoricalMapping[dimension].Add(category, count);477 categoricalMapping[dimension].Add(category, count); 487 478 count++; 488 479 } 489 480 } 490 return this.categoricalMapping[dimension][value];481 return categoricalMapping[dimension][value]; 491 482 } 492 483 private double GetValue(IRun run, AxisDimension axisDimension) { … … 498 489 } 499 490 default: { 500 throw new ArgumentException("No handling strategy for " + axisDimension .ToString()+ " is defined.");491 throw new ArgumentException("No handling strategy for " + axisDimension + " is defined."); 501 492 } 502 493 } … … 507 498 #region GUI events 508 499 private void UpdateNoRunsVisibleLabel() { 509 if ( this.chart.Series.Count > 0) {500 if (chart.Series.Count > 0) { 510 501 noRunsLabel.Visible = false; 511 502 showStatisticsCheckBox.Enabled = true; … … 532 523 } 533 524 private void UpdateAxisLabels() { 534 Axis xAxis = this.chart.ChartAreas[BoxPlotChartAreaName].AxisX;535 Axis yAxis = this.chart.ChartAreas[BoxPlotChartAreaName].AxisY;525 Axis xAxis = chart.ChartAreas[BoxPlotChartAreaName].AxisX; 526 Axis yAxis = chart.ChartAreas[BoxPlotChartAreaName].AxisY; 536 527 int axisDimensionCount = Enum.GetNames(typeof(AxisDimension)).Count(); 537 528 … … 544 535 } 545 536 546 private void chart_AxisViewChanged(object sender, System.Windows.Forms.DataVisualization.Charting.ViewEventArgs e) {547 this.UpdateAxisLabels();537 private void chart_AxisViewChanged(object sender, ViewEventArgs e) { 538 UpdateAxisLabels(); 548 539 } 549 540 … … 566 557 } 567 558 } else if (dimension > 0 && Content.GetValue(0, dimension) is TimeSpanValue) { 568 this.chart.ChartAreas[0].RecalculateAxesScale();569 Axis correspondingAxis = this.chart.ChartAreas[0].Axes.Where(x => x.Name == axis.Name).SingleOrDefault();559 chart.ChartAreas[0].RecalculateAxesScale(); 560 Axis correspondingAxis = chart.ChartAreas[0].Axes.Where(x => x.Name == axis.Name).SingleOrDefault(); 570 561 if (correspondingAxis == null) 571 562 correspondingAxis = axis; 572 563 for (double i = correspondingAxis.Minimum; i <= correspondingAxis.Maximum; i += correspondingAxis.LabelStyle.Interval) { 573 564 TimeSpan time = TimeSpan.FromSeconds(i); 574 string x = string.Format("{0:00}:{1:00}:{2:00}", (int)time.Hours, time.Minutes, time.Seconds);565 string x = string.Format("{0:00}:{1:00}:{2:00}", time.Hours, time.Minutes, time.Seconds); 575 566 axis.CustomLabels.Add(i - correspondingAxis.LabelStyle.Interval / 2, i + correspondingAxis.LabelStyle.Interval / 2, x); 576 567 } … … 595 586 string newTooltipText = string.Empty; 596 587 string oldTooltipText; 597 HitTestResult h = this.chart.HitTest(e.X, e.Y);588 HitTestResult h = chart.HitTest(e.X, e.Y); 598 589 if (h.ChartElementType == ChartElementType.AxisLabels) { 599 590 newTooltipText = ((CustomLabel)h.Object).ToolTip; 600 591 } 601 592 602 oldTooltipText = t his.tooltip.GetToolTip(chart);593 oldTooltipText = tooltip.GetToolTip(chart); 603 594 if (newTooltipText != oldTooltipText) 604 t his.tooltip.SetToolTip(chart, newTooltipText);595 tooltip.SetToolTip(chart, newTooltipText); 605 596 } 606 597 #endregion … … 623 614 string newVals = ""; 624 615 foreach (int v in values) { 625 newVals += v + delimit or + " ";616 newVals += v + delimiter + " "; 626 617 } 627 618 xAxisTextBox.Text = newVals; -
stable/HeuristicLab.Analysis.Statistics.Views/3.3/StatisticalTestsView.cs
r12009 r12725 27 27 using HeuristicLab.Collections; 28 28 using HeuristicLab.Common; 29 using HeuristicLab.Common.Resources; 29 30 using HeuristicLab.Core.Views; 30 31 using HeuristicLab.Data; … … 40 41 private const int requiredSampleSize = 5; 41 42 private double[][] data; 43 private bool suppressUpdates; 44 private bool initializing; 42 45 43 46 public double SignificanceLevel { … … 76 79 77 80 if (Content != null) { 78 Update ResultComboBox();79 UpdateGroupsComboBox();80 Re buildDataTable();81 UpdateUI(); 82 } else { 83 ResetUI(); 81 84 } 82 85 UpdateCaption(); 86 } 87 88 private void UpdateUI() { 89 initializing = true; 90 UpdateResultComboBox(); 91 UpdateGroupsComboBox(); 92 RebuildDataTable(); 93 FillCompComboBox(); 94 ResetUI(); 95 CalculateValues(); 96 initializing = false; 83 97 } 84 98 … … 92 106 Content.ColumnsChanged += Content_ColumnsChanged; 93 107 Content.RowsChanged += Content_RowsChanged; 94 Content.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);108 Content.CollectionReset += Content_CollectionReset; 95 109 Content.UpdateOfRunsInProgressChanged += Content_UpdateOfRunsInProgressChanged; 96 110 } … … 100 114 Content.ColumnsChanged -= Content_ColumnsChanged; 101 115 Content.RowsChanged -= Content_RowsChanged; 102 Content.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);116 Content.CollectionReset -= Content_CollectionReset; 103 117 Content.UpdateOfRunsInProgressChanged -= Content_UpdateOfRunsInProgressChanged; 104 118 } 105 119 106 120 void Content_RowsChanged(object sender, EventArgs e) { 121 if (suppressUpdates) return; 122 if (InvokeRequired) Invoke((Action<object, EventArgs>)Content_RowsChanged, sender, e); 123 else { 124 UpdateUI(); 125 } 126 } 127 128 void Content_ColumnsChanged(object sender, EventArgs e) { 129 if (suppressUpdates) return; 130 if (InvokeRequired) Invoke((Action<object, EventArgs>)Content_ColumnsChanged, sender, e); 131 else { 132 UpdateUI(); 133 } 134 } 135 136 private void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) { 137 if (suppressUpdates) return; 138 if (InvokeRequired) Invoke((Action<object, CollectionItemsChangedEventArgs<IRun>>)Content_CollectionReset, sender, e); 139 else { 140 UpdateUI(); 141 } 142 } 143 144 void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) { 145 if (InvokeRequired) Invoke((Action<object, EventArgs>)Content_UpdateOfRunsInProgressChanged, sender, e); 146 else { 147 suppressUpdates = Content.UpdateOfRunsInProgress; 148 if (!suppressUpdates) UpdateUI(); 149 } 150 } 151 152 private void openBoxPlotToolStripMenuItem_Click(object sender, EventArgs e) { 153 RunCollectionBoxPlotView boxplotView = new RunCollectionBoxPlotView(); 154 boxplotView.Content = Content; 155 boxplotView.SetXAxis(groupComboBox.SelectedItem.ToString()); 156 boxplotView.SetYAxis(resultComboBox.SelectedItem.ToString()); 157 158 boxplotView.Show(); 159 } 160 161 private void groupCompComboBox_SelectedValueChanged(object sender, EventArgs e) { 162 if (initializing || suppressUpdates) return; 163 string curItem = (string)groupCompComboBox.SelectedItem; 164 CalculatePairwise(curItem); 165 } 166 167 private void resultComboBox_SelectedValueChanged(object sender, EventArgs e) { 168 if (initializing || suppressUpdates) return; 107 169 RebuildDataTable(); 108 } 109 110 void Content_ColumnsChanged(object sender, EventArgs e) { 170 ResetUI(); 171 CalculateValues(); 172 } 173 174 private void groupComboBox_SelectedValueChanged(object sender, EventArgs e) { 175 if (initializing || suppressUpdates) return; 111 176 RebuildDataTable(); 112 } 113 114 private void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) { 115 RebuildDataTable(); 116 } 117 118 void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) { 119 if (!Content.UpdateOfRunsInProgress) { 120 RebuildDataTable(); 121 } 177 FillCompComboBox(); 178 ResetUI(); 179 CalculateValues(); 122 180 } 123 181 #endregion 124 182 125 183 private void UpdateGroupsComboBox() { 184 string selectedItem = (string)groupComboBox.SelectedItem; 185 126 186 groupComboBox.Items.Clear(); 127 128 187 var parameters = (from run in Content 129 188 where run.Visible … … 154 213 } 155 214 156 if (possibleIndizes.Count > 0) { 215 if (selectedItem != null && groupComboBox.Items.Contains(selectedItem)) { 216 groupComboBox.SelectedItem = selectedItem; 217 } else if (possibleIndizes.Count > 0) { 157 218 groupComboBox.SelectedItem = groupComboBox.Items[possibleIndizes.First()]; 158 } else {159 groupComboBox.SelectedItem = groupComboBox.Items[0];160 219 } 161 220 } … … 169 228 170 229 private void UpdateResultComboBox() { 230 string selectedItem = (string)resultComboBox.SelectedItem; 231 171 232 resultComboBox.Items.Clear(); 172 233 var results = (from run in Content … … 177 238 178 239 resultComboBox.Items.AddRange(results); 179 if (resultComboBox.Items.Count > 0) resultComboBox.SelectedItem = resultComboBox.Items[0]; 240 241 if (selectedItem != null && resultComboBox.Items.Contains(selectedItem)) { 242 resultComboBox.SelectedItem = selectedItem; 243 } else if (resultComboBox.Items.Count > 0) { 244 resultComboBox.SelectedItem = resultComboBox.Items[0]; 245 } 180 246 } 181 247 182 248 private void FillCompComboBox() { 249 string selectedItem = (string)groupCompComboBox.SelectedItem; 183 250 string parameterName = (string)groupComboBox.SelectedItem; 184 251 if (parameterName != null) { … … 189 256 groupCompComboBox.Items.Clear(); 190 257 columnNames.ForEach(x => groupCompComboBox.Items.Add(x)); 191 if (groupCompComboBox.Items.Count > 0) groupCompComboBox.SelectedItem = groupCompComboBox.Items[0]; 258 if (selectedItem != null && groupCompComboBox.Items.Contains(selectedItem)) { 259 groupCompComboBox.SelectedItem = selectedItem; 260 } else if (groupCompComboBox.Items.Count > 0) { 261 groupCompComboBox.SelectedItem = groupCompComboBox.Items[0]; 262 } 192 263 } 193 264 } … … 259 330 } 260 331 261 private void resultComboBox_SelectedValueChanged(object sender, EventArgs e) {262 RebuildDataTable();263 ResetUI();264 CalculateValues();265 }266 267 private void groupComboBox_SelectedValueChanged(object sender, EventArgs e) {268 RebuildDataTable();269 FillCompComboBox();270 ResetUI();271 CalculateValues();272 }273 274 332 private bool VerifyDataLength(bool showMessage) { 275 333 if (data == null || data.Length == 0) … … 277 335 278 336 //alglib needs at least 5 samples for computation 279 if (data.Any(x => x.Length < =requiredSampleSize)) {337 if (data.Any(x => x.Length < requiredSampleSize)) { 280 338 if (showMessage) 281 339 MessageBox.Show(this, "You need at least " + requiredSampleSize … … 291 349 return; 292 350 293 if (data != null ) {294 MainFormManager.GetMainForm< HeuristicLab.MainForm.WindowsForms.MainForm>()351 if (data != null && data.All(x => x != null)) { 352 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>() 295 353 .AddOperationProgressToView(this, "Calculating..."); 296 354 … … 305 363 CalculatePairwiseTest(groupName); 306 364 307 MainFormManager.GetMainForm< HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);365 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this); 308 366 } 309 367 310 368 private void CalculatePairwise(string groupName) { 369 if (groupName == null) return; 311 370 if (!VerifyDataLength(false)) 312 371 return; 313 372 314 MainFormManager.GetMainForm< HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(pairwiseTestGroupBox, "Calculating...");373 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddOperationProgressToView(pairwiseTestGroupBox, "Calculating..."); 315 374 Task.Factory.StartNew(() => CalculatePairwiseAsync(groupName)); 316 375 } … … 319 378 CalculatePairwiseTest(groupName); 320 379 321 MainFormManager.GetMainForm< HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(pairwiseTestGroupBox);380 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(pairwiseTestGroupBox); 322 381 } 323 382 324 383 private void CalculateAllGroupsTest() { 325 384 double pval = KruskalWallisTest.Test(data); 326 pValTextBox.Text = pval.ToString(); 327 if (pval < significanceLevel) { 328 this.Invoke(new Action(() => { 329 groupCompLabel.Image = HeuristicLab.Common.Resources.VSImageLibrary.Default; 385 DisplayAllGroupsTextResults(pval); 386 } 387 388 private void DisplayAllGroupsTextResults(double pval) { 389 if (InvokeRequired) { 390 Invoke((Action<double>)DisplayAllGroupsTextResults, pval); 391 } else { 392 pValTextBox.Text = pval.ToString(); 393 if (pval < significanceLevel) { 394 groupCompLabel.Image = VSImageLibrary.Default; 330 395 groupComTextLabel.Text = "There are groups with different distributions"; 331 })); 332 } else { 333 this.Invoke(new Action(() => { 334 groupCompLabel.Image = HeuristicLab.Common.Resources.VSImageLibrary.Warning; 396 } else { 397 groupCompLabel.Image = VSImageLibrary.Warning; 335 398 groupComTextLabel.Text = "Groups have an equal distribution"; 336 } ));399 } 337 400 } 338 401 } … … 343 406 DoubleMatrix pValsMatrix = new DoubleMatrix(1, stringConvertibleMatrixView.Content.Columns); 344 407 pValsMatrix.ColumnNames = stringConvertibleMatrixView.Content.ColumnNames; 345 pValsMatrix.RowNames = new string[] { "p-Value" };408 pValsMatrix.RowNames = new[] { "p-Value" }; 346 409 347 410 for (int i = 0; i < data.Length; i++) { … … 353 416 // p-value is below significance level and thus the null hypothesis (data is normally distributed) is rejected 354 417 if (res.Any(x => x < significanceLevel)) { 355 this.Invoke(new Action(() => {356 normalityLabel.Image = HeuristicLab.Common.Resources.VSImageLibrary.Warning;418 Invoke(new Action(() => { 419 normalityLabel.Image = VSImageLibrary.Warning; 357 420 normalityTextLabel.Text = "Some groups may not be normally distributed"; 358 421 })); 359 422 } else { 360 this.Invoke(new Action(() => {361 normalityLabel.Image = HeuristicLab.Common.Resources.VSImageLibrary.Default;423 Invoke(new Action(() => { 424 normalityLabel.Image = VSImageLibrary.Default; 362 425 normalityTextLabel.Text = "All sample data is normally distributed"; 363 426 })); 364 427 } 365 428 366 this.Invoke(new Action(() => {429 Invoke(new Action(() => { 367 430 normalityStringConvertibleMatrixView.Content = pValsMatrix; 368 431 normalityStringConvertibleMatrixView.DataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); … … 372 435 private void ShowPairwiseResult(int nrOfEqualDistributions) { 373 436 double ratio = ((double)nrOfEqualDistributions) / (data.Length - 1) * 100.0; 374 equalDistsTextBox.Text = ratio .ToString()+ " %";437 equalDistsTextBox.Text = ratio + " %"; 375 438 376 439 if (nrOfEqualDistributions == 0) { 377 this.Invoke(new Action(() => {378 pairwiseLabel.Image = HeuristicLab.Common.Resources.VSImageLibrary.Default;440 Invoke(new Action(() => { 441 pairwiseLabel.Image = VSImageLibrary.Default; 379 442 pairwiseTextLabel.Text = "All groups have different distributions"; 380 443 })); 381 444 } else { 382 this.Invoke(new Action(() => {383 pairwiseLabel.Image = HeuristicLab.Common.Resources.VSImageLibrary.Warning;445 Invoke(new Action(() => { 446 pairwiseLabel.Image = VSImageLibrary.Warning; 384 447 pairwiseTextLabel.Text = "Some groups have equal distributions"; 385 448 })); … … 394 457 double[][] newData = FilterDataForPairwiseTest(colIndex); 395 458 396 var rowNames = new string[] { "p-Value of Mann-Whitney U", "Adjusted p-Value of Mann-Whitney U",459 var rowNames = new[] { "p-Value of Mann-Whitney U", "Adjusted p-Value of Mann-Whitney U", 397 460 "p-Value of T-Test", "Adjusted p-Value of T-Test", "Cohen's d", "Hedges' g" }; 398 461 … … 433 496 } 434 497 435 this.Invoke(new Action(() => {498 Invoke(new Action(() => { 436 499 pairwiseStringConvertibleMatrixView.Content = pValsMatrix; 437 500 pairwiseStringConvertibleMatrixView.DataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); … … 469 532 return newData; 470 533 } 471 472 private void openBoxPlotToolStripMenuItem_Click(object sender, EventArgs e) {473 RunCollectionBoxPlotView boxplotView = new RunCollectionBoxPlotView();474 boxplotView.Content = Content;475 boxplotView.SetXAxis(groupComboBox.SelectedItem.ToString());476 boxplotView.SetYAxis(resultComboBox.SelectedItem.ToString());477 478 boxplotView.Show();479 }480 481 private void groupCompComboBox_SelectedValueChanged(object sender, EventArgs e) {482 string curItem = (string)groupCompComboBox.SelectedItem;483 CalculatePairwise(curItem);484 }485 534 } 486 535 } -
stable/HeuristicLab.Analysis.Views
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Analysis.Views merged: 12173,12458
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Analysis.Views/3.3/HistogramControl.Designer.cs
r12154 r12725 48 48 private void InitializeComponent() { 49 49 this.components = new System.ComponentModel.Container(); 50 System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea 1= new System.Windows.Forms.DataVisualization.Charting.ChartArea();51 System.Windows.Forms.DataVisualization.Charting.Legend legend 1= new System.Windows.Forms.DataVisualization.Charting.Legend();52 System.Windows.Forms.DataVisualization.Charting.Series series 1= new System.Windows.Forms.DataVisualization.Charting.Series();50 System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); 51 System.Windows.Forms.DataVisualization.Charting.Legend legend2 = new System.Windows.Forms.DataVisualization.Charting.Legend(); 52 System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series(); 53 53 this.chart = new HeuristicLab.Visualization.ChartControlsExtensions.EnhancedChart(); 54 54 this.binsNumericUpDown = new System.Windows.Forms.NumericUpDown(); … … 57 57 this.label2 = new System.Windows.Forms.Label(); 58 58 this.bandwidthNumericUpDown = new System.Windows.Forms.NumericUpDown(); 59 this.noDataLabel = new System.Windows.Forms.Label(); 59 60 ((System.ComponentModel.ISupportInitialize)(this.chart)).BeginInit(); 60 61 ((System.ComponentModel.ISupportInitialize)(this.binsNumericUpDown)).BeginInit(); … … 67 68 | System.Windows.Forms.AnchorStyles.Left) 68 69 | System.Windows.Forms.AnchorStyles.Right))); 69 chartArea 1.Name = "ChartArea1";70 this.chart.ChartAreas.Add(chartArea 1);71 legend 1.Alignment = System.Drawing.StringAlignment.Center;72 legend 1.Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Top;73 legend 1.Name = "Default";74 this.chart.Legends.Add(legend 1);70 chartArea2.Name = "ChartArea1"; 71 this.chart.ChartAreas.Add(chartArea2); 72 legend2.Alignment = System.Drawing.StringAlignment.Center; 73 legend2.Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Top; 74 legend2.Name = "Default"; 75 this.chart.Legends.Add(legend2); 75 76 this.chart.Location = new System.Drawing.Point(0, 27); 76 77 this.chart.Name = "chart"; 77 series 1.ChartArea = "ChartArea1";78 series 1.Legend = "Default";79 series 1.Name = "Series1";80 this.chart.Series.Add(series 1);78 series2.ChartArea = "ChartArea1"; 79 series2.Legend = "Default"; 80 series2.Name = "Series1"; 81 this.chart.Series.Add(series2); 81 82 this.chart.Size = new System.Drawing.Size(465, 336); 82 83 this.chart.TabIndex = 0; … … 159 160 this.bandwidthNumericUpDown.ValueChanged += new System.EventHandler(this.bandwidthNumericUpDown_ValueChanged); 160 161 // 162 // noDataLabel 163 // 164 this.noDataLabel.Anchor = System.Windows.Forms.AnchorStyles.None; 165 this.noDataLabel.AutoSize = true; 166 this.noDataLabel.Location = new System.Drawing.Point(163, 175); 167 this.noDataLabel.Name = "noDataLabel"; 168 this.noDataLabel.Size = new System.Drawing.Size(139, 13); 169 this.noDataLabel.TabIndex = 22; 170 this.noDataLabel.Text = "No data could be displayed."; 171 // 161 172 // HistogramControl 162 173 // 163 174 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; 175 this.Controls.Add(this.noDataLabel); 164 176 this.Controls.Add(this.label2); 165 177 this.Controls.Add(this.bandwidthNumericUpDown); … … 186 198 private System.Windows.Forms.Label label2; 187 199 private System.Windows.Forms.NumericUpDown bandwidthNumericUpDown; 200 private System.Windows.Forms.Label noDataLabel; 188 201 } 189 202 } -
stable/HeuristicLab.Analysis.Views/3.3/HistogramControl.cs
r12154 r12725 139 139 if (!point.Value.Any()) continue; 140 140 141 Series histogramSeries = new Series(point.Key);142 chart.Series.Add(histogramSeries);143 141 double minValue = point.Value.Min(); 144 142 double maxValue = point.Value.Max(); 145 143 double intervalWidth = (maxValue - minValue) / bins; 146 144 if (intervalWidth <= 0) continue; 145 146 Series histogramSeries = new Series(point.Key); 147 chart.Series.Add(histogramSeries); 147 148 148 149 if (!exactCheckBox.Checked) { … … 167 168 overallMax = Math.Max(overallMax, maxValue); 168 169 overallMin = Math.Min(overallMin, minValue); 169 } 170 171 chart.ApplyPaletteColors(); 172 173 int i = 0; 174 foreach (var point in points) { 175 if (!point.Value.Any()) continue; 176 177 var histogramSeries = chart.Series[i]; 170 171 chart.ApplyPaletteColors(); 178 172 CalculateDensity(histogramSeries, point.Value, bandwith); 179 180 i++; 181 } 182 173 } 174 175 if (chart.Series.Any()) { 176 noDataLabel.Visible = false; 177 } else { 178 noDataLabel.Visible = true; 179 } 183 180 184 181 ChartArea chartArea = chart.ChartAreas[0]; -
stable/HeuristicLab.Data.Views
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Data.Views merged: 12077
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Data.Views/3.3
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Data.Views/3.3 merged: 12077
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.cs
r12718 r12725 124 124 } 125 125 126 pr ivatevoid UpdateData() {126 protected virtual void UpdateData() { 127 127 rowsTextBox.Text = Content.Rows.ToString(); 128 128 rowsTextBox.Enabled = true; -
stable/HeuristicLab.Optimization
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Optimization merged: 12672,12692
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBoxPlotView.cs
r12009 r12725 122 122 if (InvokeRequired) 123 123 Invoke(new EventHandler(Content_Reset), sender, e); 124 else {124 else if (!suppressUpdates) { 125 125 UpdateDataPoints(); 126 126 UpdateAxisLabels(); … … 376 376 Axis yAxis = this.chart.ChartAreas[BoxPlotChartAreaName].AxisY; 377 377 int axisDimensionCount = Enum.GetNames(typeof(AxisDimension)).Count(); 378 //mkommend: combobox.SelectedIndex could not be used as this changes during ho overing over possible values378 //mkommend: combobox.SelectedIndex could not be used as this changes during hovering over possible values 379 379 var xSAxisSelectedIndex = xAxisValue == null ? 0 : xAxisComboBox.Items.IndexOf(xAxisValue); 380 380 var ySAxisSelectedIndex = yAxisValue == null ? 0 : xAxisComboBox.Items.IndexOf(yAxisValue); -
stable/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.cs
r12009 r12725 262 262 263 263 private void Content_Reset(object sender, EventArgs e) { 264 if (suppressUpdates) return; 264 265 if (InvokeRequired) 265 266 Invoke(new EventHandler(Content_Reset), sender, e); -
stable/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionChartAggregationView.cs
r12009 r12725 24 24 using System.ComponentModel; 25 25 using System.Linq; 26 using System.Windows.Forms;27 26 using HeuristicLab.Analysis; 28 27 using HeuristicLab.Collections; … … 41 40 } 42 41 43 private int rowNumber = 0;42 private int rowNumber; 44 43 private bool suppressUpdates; 45 44 private readonly Dictionary<IRun, IEnumerable<DataRow>> runMapping; … … 60 59 protected override void RegisterContentEvents() { 61 60 base.RegisterContentEvents(); 62 Content.ItemsAdded += new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);63 Content.ItemsRemoved += new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);64 Content.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);65 Content.UpdateOfRunsInProgressChanged += new EventHandler(Content_UpdateOfRunsInProgressChanged);66 Content.OptimizerNameChanged += new EventHandler(Content_AlgorithmNameChanged);61 Content.ItemsAdded += Content_ItemsAdded; 62 Content.ItemsRemoved += Content_ItemsRemoved; 63 Content.CollectionReset += Content_CollectionReset; 64 Content.UpdateOfRunsInProgressChanged += Content_UpdateOfRunsInProgressChanged; 65 Content.OptimizerNameChanged += Content_AlgorithmNameChanged; 67 66 } 68 67 protected override void DeregisterContentEvents() { 69 Content.ItemsAdded -= new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);70 Content.ItemsRemoved -= new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);71 Content.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);72 Content.UpdateOfRunsInProgressChanged -= new EventHandler(Content_UpdateOfRunsInProgressChanged);73 Content.OptimizerNameChanged -= new EventHandler(Content_AlgorithmNameChanged);68 Content.ItemsAdded -= Content_ItemsAdded; 69 Content.ItemsRemoved -= Content_ItemsRemoved; 70 Content.CollectionReset -= Content_CollectionReset; 71 Content.UpdateOfRunsInProgressChanged -= Content_UpdateOfRunsInProgressChanged; 72 Content.OptimizerNameChanged -= Content_AlgorithmNameChanged; 74 73 base.DeregisterContentEvents(); 75 74 } 76 75 77 76 private void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRun> e) { 77 if (suppressUpdates) return; 78 78 if (InvokeRequired) { 79 79 Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded), sender, e); 80 80 return; 81 81 } 82 UpdateDataTableComboBox(); 83 UpdateDataRowComboBox(); 82 84 AddRuns(e.Items); 83 85 } 84 86 private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) { 87 if (suppressUpdates) return; 85 88 if (InvokeRequired) { 86 89 Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved), sender, e); 87 90 return; 88 91 } 92 UpdateDataTableComboBox(); 93 UpdateDataRowComboBox(); 89 94 RemoveRuns(e.Items); 90 95 } 91 96 private void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) { 97 if (suppressUpdates) return; 92 98 if (InvokeRequired) { 93 99 Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset), sender, e); 94 100 return; 95 101 } 102 UpdateDataTableComboBox(); 103 UpdateDataRowComboBox(); 96 104 RemoveRuns(e.OldItems); 97 105 AddRuns(e.Items); … … 108 116 } 109 117 suppressUpdates = Content.UpdateOfRunsInProgress; 110 if (!suppressUpdates) UpdateRuns(Content); 118 if (!suppressUpdates) { 119 UpdateDataTableComboBox(); 120 UpdateDataRowComboBox(); 121 UpdateRuns(Content); 122 } 111 123 } 112 124 … … 124 136 var run = (IRun)sender; 125 137 if (e.PropertyName == "Color" || e.PropertyName == "Visible") 126 UpdateRuns(new IRun[] { run });138 UpdateRuns(new[] { run }); 127 139 } 128 140 } … … 168 180 169 181 private void UpdateRuns(IEnumerable<IRun> runs) { 170 if (suppressUpdates) return;171 182 foreach (var run in runs) { 172 183 //update color 173 foreach (var dataRow in runMapping[run]) { 174 dataRow.VisualProperties.Color = run.Color; 184 if (!runMapping.ContainsKey(run)) { 185 runMapping[run] = ExtractDataRowsFromRun(run).ToList(); 186 RegisterRunEvents(run); 187 } else { 188 foreach (var dataRow in runMapping[run]) { 189 dataRow.VisualProperties.Color = run.Color; 190 } 175 191 } 176 //update visibility - remove and add all rows to keep the same order as before177 combinedDataTable.Rows.Clear();178 combinedDataTable.Rows.AddRange(runMapping.Where(mapping => mapping.Key.Visible).SelectMany(mapping => mapping.Value));179 }192 } 193 //update visibility - remove and add all rows to keep the same order as before 194 combinedDataTable.Rows.Clear(); 195 combinedDataTable.Rows.AddRange(runMapping.Where(mapping => mapping.Key.Visible).SelectMany(mapping => mapping.Value)); 180 196 } 181 197 182 198 private IEnumerable<DataRow> ExtractDataRowsFromRun(IRun run) { 183 199 var resultName = (string)dataTableComboBox.SelectedItem; 200 if (string.IsNullOrEmpty(resultName)) yield break; 201 184 202 var rowName = (string)dataRowComboBox.SelectedItem; 185 203 if (!run.Results.ContainsKey(resultName)) yield break; … … 199 217 200 218 private void UpdateDataTableComboBox() { 219 string selectedItem = (string)dataTableComboBox.SelectedItem; 220 201 221 dataTableComboBox.Items.Clear(); 202 222 var dataTables = (from run in Content … … 206 226 207 227 dataTableComboBox.Items.AddRange(dataTables); 208 if (dataTableComboBox.Items.Count > 0) dataTableComboBox.SelectedItem = dataTableComboBox.Items[0]; 228 if (selectedItem != null && dataTableComboBox.Items.Contains(selectedItem)) { 229 dataTableComboBox.SelectedItem = selectedItem; 230 } else if (dataTableComboBox.Items.Count > 0) { 231 dataTableComboBox.SelectedItem = dataTableComboBox.Items[0]; 232 } 209 233 } 210 234 … … 214 238 215 239 private void UpdateDataRowComboBox() { 240 string selectedItem = (string)dataRowComboBox.SelectedItem; 241 216 242 dataRowComboBox.Items.Clear(); 217 243 var resultName = (string)dataTableComboBox.SelectedItem; 244 if (resultName == null) return; 245 218 246 var dataTables = from run in Content 219 247 where run.Results.ContainsKey(resultName) … … 225 253 dataRowComboBox.Items.AddRange(rowNames); 226 254 dataRowComboBox.Items.Add(AllDataRows); 227 if (dataRowComboBox.Items.Count > 0) dataRowComboBox.SelectedItem = dataRowComboBox.Items[0]; 228 } 229 230 private void dataTableComboBox_SelectedIndexChanged(object sender, System.EventArgs e) { 231 UpdateDataRowComboBox(); 232 } 233 private void dataRowComboBox_SelectedIndexChanged(object sender, System.EventArgs e) { 255 if (selectedItem != null && dataRowComboBox.Items.Contains(selectedItem)) { 256 dataRowComboBox.SelectedItem = selectedItem; 257 } else if (dataRowComboBox.Items.Count > 0) { 258 dataRowComboBox.SelectedItem = dataRowComboBox.Items[0]; 259 } 260 } 261 262 private void dataTableComboBox_SelectedIndexChanged(object sender, EventArgs e) { 263 UpdateDataRowComboBox(); 264 } 265 private void dataRowComboBox_SelectedIndexChanged(object sender, EventArgs e) { 266 if (suppressUpdates) return; 234 267 RebuildCombinedDataTable(); 235 268 } -
stable/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionTableView.cs
r12009 r12725 53 53 base.OnContentChanged(); 54 54 if (Content != null) { 55 runToRowMapping = Enumerable.Range(0, Content.Count).ToArray();56 55 UpdateRowAttributes(); 57 56 } … … 117 116 } 118 117 118 protected override void UpdateData() { 119 if (suppressUpdates) return; 120 base.UpdateData(); 121 } 122 119 123 protected override void UpdateColumnHeaders() { 120 124 HashSet<string> visibleColumnNames = new HashSet<string>(dataGridView.Columns.OfType<DataGridViewColumn>() … … 145 149 else { 146 150 suppressUpdates = Content.UpdateOfRunsInProgress; 147 if (!suppressUpdates) UpdateRowAttributes(); 151 if (!suppressUpdates) { 152 UpdateData(); 153 UpdateRowAttributes(); 154 } 148 155 } 149 156 } … … 171 178 protected override void ClearSorting() { 172 179 base.ClearSorting(); 173 runToRowMapping = Enumerable.Range(0, Content.Count).ToArray();174 180 UpdateRowAttributes(); 175 181 } … … 190 196 i++; 191 197 } 192 UpdateRowAttributes( );198 UpdateRowAttributes(rebuild: false); 193 199 return newSortedIndex; 194 200 } 195 201 196 private void UpdateRowAttributes() { 202 private void UpdateRowAttributes(bool rebuild = true) { 203 if (rebuild) runToRowMapping = Enumerable.Range(0, Content.Count).ToArray(); 197 204 int runIndex = 0; 198 205 foreach (IRun run in Content) { -
stable/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionView.cs
r12009 r12725 41 41 private Dictionary<IRun, List<ListViewItem>> itemListViewItemMapping; 42 42 private bool validDragOperation; 43 private bool suppressUpdates; 43 44 44 45 public new IItemCollection<IRun> Content { … … 66 67 Content.ItemsRemoved -= new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved); 67 68 Content.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset); 69 if (RunCollection != null) 70 RunCollection.UpdateOfRunsInProgressChanged -= new EventHandler(RunCollection_UpdateOfRunsInProgressChanged); 68 71 foreach (IRun run in itemListViewItemMapping.Keys) { 69 72 DeregisterItemEvents(run); … … 76 79 Content.ItemsRemoved += new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved); 77 80 Content.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset); 81 if (RunCollection != null) 82 RunCollection.UpdateOfRunsInProgressChanged += new EventHandler(RunCollection_UpdateOfRunsInProgressChanged); 78 83 } 79 84 private void DeregisterItemEvents(IRun item) { … … 394 399 #region Content Events 395 400 private void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRun> e) { 401 if (suppressUpdates) return; 396 402 if (InvokeRequired) 397 403 Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded), sender, e); … … 407 413 } 408 414 private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) { 415 if (suppressUpdates) return; 409 416 if (InvokeRequired) 410 417 Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved), sender, e); … … 422 429 } 423 430 private void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) { 431 if (suppressUpdates) return; 424 432 if (InvokeRequired) 425 433 Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset), sender, e); … … 440 448 } 441 449 } 450 private void RunCollection_UpdateOfRunsInProgressChanged(object sender, EventArgs e) { 451 if (InvokeRequired) Invoke((Action<object, EventArgs>)RunCollection_UpdateOfRunsInProgressChanged, sender, e); 452 else { 453 suppressUpdates = RunCollection.UpdateOfRunsInProgress; 454 if (!suppressUpdates) { 455 foreach (IRun item in Content) { 456 //remove only the first matching ListViewItem, because the IRun could be contained multiple times in the ItemCollection 457 ListViewItem listViewItem = GetListViewItemsForItem(item).FirstOrDefault(); 458 if (listViewItem != null) RemoveListViewItem(listViewItem); 459 } 460 RebuildImageList(); 461 foreach (IRun item in Content) 462 AddListViewItem(CreateListViewItem(item)); 463 464 AdjustListViewColumnSizes(); 465 analyzeRunsToolStripDropDownButton.Enabled = itemsListView.Items.Count > 0; 466 clearButton.Enabled = itemsListView.Items.Count > 0 && !Content.IsReadOnly && !ReadOnly; 467 runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0; 468 } 469 } 470 } 442 471 #endregion 443 472 444 473 #region Item Events 445 474 private void Item_ItemImageChanged(object sender, EventArgs e) { 475 if (suppressUpdates) return; 446 476 if (InvokeRequired) 447 477 Invoke(new EventHandler(Item_ItemImageChanged), sender, e); … … 453 483 } 454 484 private void Item_ToStringChanged(object sender, EventArgs e) { 485 if (suppressUpdates) return; 455 486 if (InvokeRequired) 456 487 Invoke(new EventHandler(Item_ToStringChanged), sender, e); … … 463 494 } 464 495 private void Item_PropertyChanged(object sender, PropertyChangedEventArgs e) { 496 if (suppressUpdates) return; 465 497 if (InvokeRequired) 466 this.Invoke((Action<object, PropertyChangedEventArgs>)Item_PropertyChanged, sender, e);498 Invoke((Action<object, PropertyChangedEventArgs>)Item_PropertyChanged, sender, e); 467 499 else { 468 500 IRun run = (IRun)sender; -
stable/HeuristicLab.Optimization/3.3/RunCollection.cs
r12708 r12725 445 445 EventHandler<EventArgs<int, int>> handler = ItemChanged; 446 446 if (handler != null) handler(this, new EventArgs<int, int>(rowIndex, columnIndex)); 447 OnToStringChanged();448 447 } 449 448 public event EventHandler Reset; … … 451 450 EventHandler handler = Reset; 452 451 if (handler != null) handler(this, EventArgs.Empty); 453 OnToStringChanged();454 452 } 455 453 public event EventHandler ColumnsChanged; … … 485 483 #region Filtering 486 484 private void UpdateFiltering(bool reset) { 485 var oldUpateRuns = UpdateOfRunsInProgress; 487 486 UpdateOfRunsInProgress = true; 488 487 if (reset) … … 490 489 foreach (IRunCollectionConstraint constraint in this.constraints) 491 490 constraint.Check(); 492 UpdateOfRunsInProgress = false;491 UpdateOfRunsInProgress = oldUpateRuns; 493 492 } 494 493 … … 552 551 #region Modification 553 552 public void Modify() { 553 var oldUpateRuns = UpdateOfRunsInProgress; 554 554 UpdateOfRunsInProgress = true; 555 555 var runs = this.ToList(); … … 566 566 } 567 567 } 568 UpdateOfRunsInProgress = false;568 UpdateOfRunsInProgress = oldUpateRuns; 569 569 } 570 570
Note: See TracChangeset
for help on using the changeset viewer.