Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11697


Ignore:
Timestamp:
12/18/14 16:55:53 (10 years ago)
Author:
ascheibe
Message:

#2031 improved code of views

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

Legend:

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

    r11665 r11697  
    5656      InitializeComponent();
    5757
    58       stringConvertibleMatrixView.DataGridView.RowHeaderMouseDoubleClick += new DataGridViewCellMouseEventHandler(DataGridView_RowHeaderMouseDoubleClick);
     58      stringConvertibleMatrixView.DataGridView.RowHeaderMouseDoubleClick += DataGridView_RowHeaderMouseDoubleClick;
    5959
    6060      var fittingAlgs = ApplicationManager.Manager.GetInstances<IFitting>();
     
    6767    protected override void Dispose(bool disposing) {
    6868      if (disposing && (components != null)) {
    69         stringConvertibleMatrixView.DataGridView.RowHeaderMouseDoubleClick -= new DataGridViewCellMouseEventHandler(DataGridView_RowHeaderMouseDoubleClick);
     69        stringConvertibleMatrixView.DataGridView.RowHeaderMouseDoubleClick -= DataGridView_RowHeaderMouseDoubleClick;
    7070        components.Dispose();
    7171      }
     
    9393    protected override void RegisterContentEvents() {
    9494      base.RegisterContentEvents();
    95       Content.ItemsAdded += Content_ItemsAdded;
    96       Content.ItemsRemoved += Content_ItemsRemoved;
     95      Content.ColumnsChanged += Content_ColumnsChanged;
     96      Content.RowsChanged += Content_RowsChanged;
    9797      Content.CollectionReset += Content_CollectionReset;
    9898      Content.UpdateOfRunsInProgressChanged += Content_UpdateOfRunsInProgressChanged;
    99       RegisterRunEvents(Content);
    10099    }
    101100
    102101    protected override void DeregisterContentEvents() {
    103102      base.DeregisterContentEvents();
    104       Content.ItemsAdded -= Content_ItemsAdded;
    105       Content.ItemsRemoved -= Content_ItemsRemoved;
     103      Content.ColumnsChanged -= Content_ColumnsChanged;
     104      Content.RowsChanged -= Content_RowsChanged;
    106105      Content.CollectionReset -= Content_CollectionReset;
    107106      Content.UpdateOfRunsInProgressChanged -= Content_UpdateOfRunsInProgressChanged;
    108       DeregisterRunEvents(Content);
    109     }
    110 
    111     private void RegisterRunEvents(IEnumerable<IRun> runs) {
    112       foreach (IRun run in runs) {
    113         RegisterRunResultsEvents(run);
    114       }
    115     }
    116 
    117     private void DeregisterRunEvents(IEnumerable<IRun> runs) {
    118       foreach (IRun run in runs) {
    119         DeregisterRunResultsEvents(run);
    120       }
    121     }
    122 
    123     private void RegisterRunResultsEvents(IRun run) {
    124       IObservableDictionary<string, IItem> dict = run.Results;
    125       dict.ItemsAdded += run_Changed;
    126       dict.ItemsRemoved += run_Changed;
    127       dict.ItemsReplaced += run_Changed;
    128       dict.CollectionReset += run_Changed;
    129     }
    130 
    131     private void DeregisterRunResultsEvents(IRun run) {
    132       IObservableDictionary<string, IItem> dict = run.Results;
    133       dict.ItemsAdded -= run_Changed;
    134       dict.ItemsRemoved -= run_Changed;
    135       dict.ItemsReplaced -= run_Changed;
    136       dict.CollectionReset -= run_Changed;
     107    }
     108
     109    void Content_RowsChanged(object sender, EventArgs e) {
     110      RebuildDataTableAsync();
     111    }
     112
     113    void Content_ColumnsChanged(object sender, EventArgs e) {
     114      RebuildDataTableAsync();
    137115    }
    138116
    139117    private void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) {
    140       DeregisterRunEvents(e.OldItems);
    141       RegisterRunEvents(e.Items);
    142118      UpdateComboboxes();
    143119      RebuildDataTableAsync();
    144120    }
    145121
    146     private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) {
    147       DeregisterRunEvents(e.Items);
    148       RebuildDataTableAsync();
    149     }
    150 
    151     private void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRun> e) {
    152       RegisterRunEvents(e.Items);
    153       RebuildDataTableAsync();
    154     }
    155 
    156122    private void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) {
    157123      suppressUpdates = Content.UpdateOfRunsInProgress;
     
    164130      }
    165131    }
    166 
    167     private void run_Changed(object sender, EventArgs e) {
    168       if (InvokeRequired)
    169         Invoke(new EventHandler(run_Changed), sender, e);
    170       else if (!suppressUpdates) {
    171         UpdateComboboxes();
    172       }
    173     }
    174132    #endregion
    175133
    176     #region Events
     134    #region events
    177135    private void DataGridView_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) {
    178136      if (e.RowIndex >= 0) {
     
    219177
    220178        var fittingAlg = fittingComboBox.SelectedItem as IFitting;
    221         DataRow newRow = fittingAlg.CalculateFittedLine(values, row.Name + " (" + fittingAlg.ToString() + ")");
     179        DataRow newRow = fittingAlg.CalculateFittedLine(values, row.Name + " (" + fittingAlg + ")");
    222180
    223181        if (!resTable.Rows.ContainsKey(newRow.Name))
     
    239197            string newResultName = resultName + " " + rowName + " " + sm.ColumnNames.ElementAt(j);
    240198            if (!run.Results.ContainsKey(newResultName)) {
    241               run.Results.Add(new KeyValuePair<string, Core.IItem>(newResultName, new DoubleValue(sm[i, j])));
     199              run.Results.Add(new KeyValuePair<string, IItem>(newResultName, new DoubleValue(sm[i, j])));
    242200            }
    243201          }
     
    306264    private void RebuildDataTable(string resultName, string rowName) {
    307265      LinearLeastSquaresFitting llsFitting = new LinearLeastSquaresFitting();
    308       LogFitting logFitting = new LogFitting();
    309266      string[] columnNames = new string[] { "Count", "Minimum", "Maximum", "Average", "Median", "Standard Deviation", "Variance", "25th Percentile", "75th Percentile",
    310267        "Avg. of Upper 25 %", " Avg. of Lower 25 %", "Avg. of First 25 %", "Avg. of Last 25 %", "Linear Gradient", "Average Relative Error" };
  • branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/CorrelationView.cs

    r11644 r11697  
    2323using System.Collections.Generic;
    2424using System.Linq;
    25 using HeuristicLab.Collections;
    26 using HeuristicLab.Core;
    2725using HeuristicLab.Core.Views;
    2826using HeuristicLab.Data;
     
    8078    protected override void RegisterContentEvents() {
    8179      base.RegisterContentEvents();
    82       Content.ItemsAdded += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);
    83       Content.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
     80      Content.ColumnsChanged += Content_ColumnsChanged;
     81      Content.RowsChanged += Content_RowsChanged;
    8482      Content.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
    8583      Content.UpdateOfRunsInProgressChanged += Content_UpdateOfRunsInProgressChanged;
    86       RegisterRunEvents(Content);
    8784    }
    8885
    8986    protected override void DeregisterContentEvents() {
    9087      base.DeregisterContentEvents();
    91       Content.ItemsAdded -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);
    92       Content.ItemsRemoved -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
     88      Content.ColumnsChanged -= Content_ColumnsChanged;
     89      Content.RowsChanged -= Content_RowsChanged;
    9390      Content.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
    9491      Content.UpdateOfRunsInProgressChanged -= Content_UpdateOfRunsInProgressChanged;
    95       DeregisterRunEvents(Content);
    96     }
    97 
    98     private void RegisterRunEvents(IEnumerable<IRun> runs) {
    99       foreach (IRun run in runs) {
    100         RegisterRunResultsEvents(run);
    101         RegisterRunParametersEvents(run);
    102         run.PropertyChanged += run_PropertyChanged;
    103       }
    104     }
    105 
    106     private void DeregisterRunEvents(IEnumerable<IRun> runs) {
    107       foreach (IRun run in runs) {
    108         DeregisterRunResultsEvents(run);
    109         DeregisterRunParametersEvents(run);
    110         run.PropertyChanged -= run_PropertyChanged;
    111       }
    112     }
    113 
    114     private void RegisterRunResultsEvents(IRun run) {
    115       IObservableDictionary<string, IItem> dict = run.Results;
    116       dict.ItemsAdded += run_Changed;
    117       dict.ItemsRemoved += run_Changed;
    118       dict.ItemsReplaced += run_Changed;
    119       dict.CollectionReset += run_Changed;
    120     }
    121 
    122     private void DeregisterRunResultsEvents(IRun run) {
    123       IObservableDictionary<string, IItem> dict = run.Results;
    124       dict.ItemsAdded -= run_Changed;
    125       dict.ItemsRemoved -= run_Changed;
    126       dict.ItemsReplaced -= run_Changed;
    127       dict.CollectionReset -= run_Changed;
    128     }
    129 
    130     private void RegisterRunParametersEvents(IRun run) {
    131       IObservableDictionary<string, IItem> dict = run.Parameters;
    132       dict.ItemsAdded += run_Changed;
    133       dict.ItemsRemoved += run_Changed;
    134       dict.ItemsReplaced += run_Changed;
    135       dict.CollectionReset += run_Changed;
    136     }
    137 
    138     private void DeregisterRunParametersEvents(IRun run) {
    139       IObservableDictionary<string, IItem> dict = run.Parameters;
    140       dict.ItemsAdded -= run_Changed;
    141       dict.ItemsRemoved -= run_Changed;
    142       dict.ItemsReplaced -= run_Changed;
    143       dict.CollectionReset -= run_Changed;
     92    }
     93
     94    void Content_RowsChanged(object sender, EventArgs e) {
     95      UpdateUI();
     96    }
     97
     98    void Content_ColumnsChanged(object sender, EventArgs e) {
     99      UpdateUI();
    144100    }
    145101
    146102    private void Content_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
    147       DeregisterRunEvents(e.OldItems);
    148       RegisterRunEvents(e.Items);
    149       UpdateUI();
    150     }
    151 
    152     private void Content_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
    153       DeregisterRunEvents(e.Items);
    154       UpdateUI();
    155     }
    156 
    157     private void Content_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
    158       RegisterRunEvents(e.Items);
    159103      UpdateUI();
    160104    }
     
    162106    private void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) {
    163107      suppressUpdates = Content.UpdateOfRunsInProgress;
    164       UpdateUI();
    165     }
    166 
    167     private void run_Changed(object sender, EventArgs e) {
    168       if (InvokeRequired) {
    169         Invoke(new EventHandler(run_Changed), sender, e);
    170       }
    171       UpdateUI();
    172     }
    173 
    174     void run_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) {
    175108      UpdateUI();
    176109    }
  • branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/SampleSizeInfluenceView.cs

    r11671 r11697  
    4141    private const string BoxPlotSeriesName = "BoxPlotSeries";
    4242    private const string BoxPlotChartAreaName = "BoxPlotChartArea";
     43    private const string delimitor = ";";
    4344
    4445    private bool suppressUpdates = false;
     
    221222        }
    222223
    223         if (values.Count() > 0) {
     224        if (values.Any()) {
    224225          if (hypergeometricCheckBox.Checked) {
    225             xAxisTextBox.Text += ((int)(values.Count() / 16)).ToString() + "; ";
    226             xAxisTextBox.Text += ((int)(values.Count() / 8)).ToString() + "; ";
    227             xAxisTextBox.Text += ((int)(values.Count() / 4)).ToString();
     226            xAxisTextBox.Text += ((int)(values.Count() / 16)) + delimitor + " ";
     227            xAxisTextBox.Text += ((int)(values.Count() / 8)) + delimitor + " ";
     228            xAxisTextBox.Text += (int)(values.Count() / 4);
    228229          } else {
    229             xAxisTextBox.Text += ((int)(values.Count() / 4)).ToString() + "; ";
    230             xAxisTextBox.Text += ((int)(values.Count() / 2)).ToString() + "; ";
    231             xAxisTextBox.Text += ((int)(values.Count() / 4 * 3)).ToString() + "; ";
    232             xAxisTextBox.Text += ((int)(values.Count())).ToString();
     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());
    233234          }
    234235        }
     
    332333      if (yValue.Any(x => !x.HasValue)) return;
    333334
    334       double y = SampleSizeDetermination.DetermineSampleSizeByEstimatingMeanForLargeSampleSizes(yValue.Select(x => x.Value).ToArray());
    335       sampleSizeTextBox.Text = y.ToString();
     335      double estimatedSampleSize = SampleSizeDetermination.DetermineSampleSizeByEstimatingMeanForLargeSampleSizes(yValue.Select(x => x.Value).ToArray());
     336      sampleSizeTextBox.Text = estimatedSampleSize.ToString();
    336337    }
    337338
    338339    private List<int> ParseGroupSizesFromText(string groupsText, bool verbose = true) {
    339       const string delimitor = ";";
    340       string[] gs = groupsText.Split(delimitor.ToString().ToCharArray());
     340      string[] gs = groupsText.Split(delimitor.ToCharArray());
    341341      List<int> vals = new List<int>();
    342342
     
    352352          catch (Exception ex) {
    353353            if (verbose) {
    354               ErrorHandling.ShowErrorDialog("Can't parse group sizes. Please only use numbers seperated by a semicolon. ", ex);
     354              ErrorHandling.ShowErrorDialog("Can't parse group sizes. Please only use numbers seperated by a " + delimitor + ". ", ex);
    355355            }
    356356          }
     
    481481        this.categoricalMapping[dimension] = new Dictionary<object, double>();
    482482        var orderedCategories = Content.Where(r => r.Visible && Content.GetValue(r, dimension) != null).Select(r => Content.GetValue(r, dimension).ToString())
    483 
    484                                        .Distinct().OrderBy(x => x, new NaturalStringComparer());
     483                                          .Distinct().OrderBy(x => x, new NaturalStringComparer());
    485484        int count = 1;
    486485        foreach (var category in orderedCategories) {
     
    624623          string newVals = "";
    625624          foreach (int v in values) {
    626             newVals += v + "; ";
     625            newVals += v + delimitor + " ";
    627626          }
    628627          xAxisTextBox.Text = newVals;
Note: See TracChangeset for help on using the changeset viewer.