Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/17/14 17:34:43 (10 years ago)
Author:
ascheibe
Message:

#2031 improved correlation view and some clean ups

Location:
branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/ChartAnalysisView.cs

    r11376 r11378  
    114114    private void RegisterRunEvents(IEnumerable<IRun> runs) {
    115115      foreach (IRun run in runs) {
    116         RegisterRunParametersEvents(run);
    117116        RegisterRunResultsEvents(run);
    118117      }
     
    121120    private void DeregisterRunEvents(IEnumerable<IRun> runs) {
    122121      foreach (IRun run in runs) {
    123         DeregisterRunParametersEvents(run);
    124122        DeregisterRunResultsEvents(run);
    125123      }
    126     }
    127 
    128     private void RegisterRunParametersEvents(IRun run) {
    129       IObservableDictionary<string, IItem> dict = run.Parameters;
    130       dict.ItemsAdded += run_Changed;
    131       dict.ItemsRemoved += run_Changed;
    132       dict.ItemsReplaced += run_Changed;
    133       dict.CollectionReset += run_Changed;
    134124    }
    135125
     
    142132    }
    143133
    144     private void DeregisterRunParametersEvents(IRun run) {
    145       IObservableDictionary<string, IItem> dict = run.Parameters;
    146       dict.ItemsAdded -= run_Changed;
    147       dict.ItemsRemoved -= run_Changed;
    148       dict.ItemsReplaced -= run_Changed;
    149       dict.CollectionReset -= run_Changed;
    150     }
    151 
    152134    private void DeregisterRunResultsEvents(IRun run) {
    153135      IObservableDictionary<string, IItem> dict = run.Results;
     
    175157    }
    176158
    177     void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) {
     159    private void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) {
    178160      suppressUpdates = Content.UpdateOfRunsInProgress;
    179161
     
    196178
    197179    #region Events
    198     void DataGridView_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) {
     180    private void DataGridView_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) {
    199181      if (e.RowIndex >= 0) {
    200182        IRun run = runs[stringConvertibleMatrixView.GetRowIndex(e.RowIndex)];
  • branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/CorrelationView.cs

    r11375 r11378  
    2323using System.Collections.Generic;
    2424using System.Linq;
    25 using System.Windows.Forms;
     25using HeuristicLab.Collections;
     26using HeuristicLab.Core;
    2627using HeuristicLab.Core.Views;
    2728using HeuristicLab.Data;
     
    4950
    5051    private Dictionary<string, ResultParameterType> resultsParameters;
     52    private bool suppressUpdates = false;
    5153
    5254    public CorrelationView() {
     
    6163
    6264      if (Content != null) {
    63         resultsParameters = GetRowNames();
    6465        UpdateResultComboBox();
    6566      }
     
    7879      Content.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
    7980      Content.UpdateOfRunsInProgressChanged += Content_UpdateOfRunsInProgressChanged;
     81      RegisterRunEvents(Content);
    8082    }
    8183
     
    8688      Content.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
    8789      Content.UpdateOfRunsInProgressChanged -= Content_UpdateOfRunsInProgressChanged;
     90      DeregisterRunEvents(Content);
     91    }
     92
     93    private void RegisterRunEvents(IEnumerable<IRun> runs) {
     94      foreach (IRun run in runs) {
     95        RegisterRunResultsEvents(run);
     96        RegisterRunParametersEvents(run);
     97        run.PropertyChanged += run_PropertyChanged;
     98      }
     99    }
     100
     101    private void DeregisterRunEvents(IEnumerable<IRun> runs) {
     102      foreach (IRun run in runs) {
     103        DeregisterRunResultsEvents(run);
     104        DeregisterRunParametersEvents(run);
     105        run.PropertyChanged -= run_PropertyChanged;
     106      }
     107    }
     108
     109    private void RegisterRunResultsEvents(IRun run) {
     110      IObservableDictionary<string, IItem> dict = run.Results;
     111      dict.ItemsAdded += run_Changed;
     112      dict.ItemsRemoved += run_Changed;
     113      dict.ItemsReplaced += run_Changed;
     114      dict.CollectionReset += run_Changed;
     115    }
     116
     117    private void DeregisterRunResultsEvents(IRun run) {
     118      IObservableDictionary<string, IItem> dict = run.Results;
     119      dict.ItemsAdded -= run_Changed;
     120      dict.ItemsRemoved -= run_Changed;
     121      dict.ItemsReplaced -= run_Changed;
     122      dict.CollectionReset -= run_Changed;
     123    }
     124
     125    private void RegisterRunParametersEvents(IRun run) {
     126      IObservableDictionary<string, IItem> dict = run.Parameters;
     127      dict.ItemsAdded += run_Changed;
     128      dict.ItemsRemoved += run_Changed;
     129      dict.ItemsReplaced += run_Changed;
     130      dict.CollectionReset += run_Changed;
     131    }
     132
     133    private void DeregisterRunParametersEvents(IRun run) {
     134      IObservableDictionary<string, IItem> dict = run.Parameters;
     135      dict.ItemsAdded -= run_Changed;
     136      dict.ItemsRemoved -= run_Changed;
     137      dict.ItemsReplaced -= run_Changed;
     138      dict.CollectionReset -= run_Changed;
    88139    }
    89140
    90141    private void Content_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
    91       RebuildCorrelationTable();
     142      UpdateUI();
    92143    }
    93144
    94145    private void Content_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
    95       RebuildCorrelationTable();
     146      UpdateUI();
    96147    }
    97148
    98149    private void Content_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
    99       RebuildCorrelationTable();
    100     }
    101 
    102     void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) {
    103       if (!Content.UpdateOfRunsInProgress) {
     150      UpdateUI();
     151    }
     152
     153    private void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) {
     154      suppressUpdates = Content.UpdateOfRunsInProgress;
     155      UpdateUI();
     156    }
     157
     158    private void run_Changed(object sender, EventArgs e) {
     159      if (InvokeRequired) {
     160        Invoke(new EventHandler(run_Changed), sender, e);
     161      }
     162      UpdateUI();
     163    }
     164
     165    void run_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) {
     166      UpdateUI();
     167    }
     168    #endregion
     169
     170    private void UpdateUI() {
     171      if (!suppressUpdates) {
     172        UpdateResultComboBox();
    104173        RebuildCorrelationTable();
    105174      }
    106175    }
    107     #endregion
    108176
    109177    private void UpdateResultComboBox() {
     178      resultsParameters = GetRowNames();
     179      string selectedResult = (string)this.resultComboBox.SelectedItem;
    110180      resultComboBox.Items.Clear();
    111 
    112181      resultComboBox.Items.AddRange(resultsParameters.Keys.ToArray());
    113       if (resultComboBox.Items.Count > 0) resultComboBox.SelectedItem = resultComboBox.Items[0];
     182
     183      if (selectedResult != null && resultComboBox.Items.Contains(selectedResult)) {
     184        resultComboBox.SelectedItem = selectedResult;
     185      } else if (resultComboBox.Items.Count > 0) {
     186        resultComboBox.SelectedItem = resultComboBox.Items[0];
     187      }
    114188    }
    115189
     
    195269        var resultVals = GetDoublesFromResults(runs.Where(x => x.Results.ContainsKey(resultName)).Where(x => x.Results[resultName] is DoubleValue || x.Results[resultName] is IntValue).ToList(), resultName);
    196270
    197         List<double> resultRowVals = new List<double>();
     271        List<double> resultRowVals;
    198272        if (rowName.Value == ResultParameterType.Result) {
    199273          resultRowVals = GetDoublesFromResults(runs.Where(x => x.Results.ContainsKey(rowName.Key)).Where(x => x.Results[rowName.Key] is DoubleValue || x.Results[rowName.Key] is IntValue).ToList(), rowName.Key);
  • branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/SampleSizeInfluenceView.cs

    r11376 r11378  
    141141      DeregisterRunEvents(e.OldItems);
    142142      RegisterRunEvents(e.Items);
     143      UpdateAll();
    143144    }
    144145    private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) {
    145146      DeregisterRunEvents(e.Items);
     147      UpdateComboBoxes();
    146148    }
    147149    private void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRun> e) {
    148150      RegisterRunEvents(e.Items);
     151      UpdateComboBoxes();
    149152    }
    150153    private void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) {
     
    191194    protected override void OnContentChanged() {
    192195      base.OnContentChanged();
     196      UpdateAll();
     197    }
     198
     199    private void UpdateAll() {
    193200      this.categoricalMapping.Clear();
    194201      UpdateComboBoxes();
     
    233240        this.yAxisComboBox.Items.AddRange(Matrix.ColumnNames.ToArray());
    234241
    235         bool changed = false;
    236242        if (selectedYAxis != null && yAxisComboBox.Items.Contains(selectedYAxis)) {
    237243          yAxisComboBox.SelectedItem = selectedYAxis;
    238           changed = true;
    239         }
    240         if (changed)
    241244          UpdateDataPoints();
     245        }
    242246      }
    243247    }
     
    340344          }
    341345
    342           string columnName = string.Empty;
    343           if (value != null && value is DoubleValue || value is IntValue) {
    344             columnName = selectedAxis + ": ";
    345             columnName += value.ToString();
    346           } else {
    347             columnName = series.Name;
    348           }
    349 
     346          string columnName = series.Name;
    350347          columnNames.Add(columnName);
    351348        }
Note: See TracChangeset for help on using the changeset viewer.