Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9378


Ignore:
Timestamp:
04/18/13 13:07:15 (12 years ago)
Author:
ascheibe
Message:

#2031 fixed some bugs and the coloring in the chart analysis view

File:
1 edited

Legend:

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

    r9377 r9378  
    4444    }
    4545
     46    private List<IRun> runs;
     47
    4648    public ChartAnalysisView() {
    4749      InitializeComponent();
     
    7779      Content.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
    7880      Content.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
    79 
    80       RegisterRunEvents(Content);
    81     }
    82 
    83     private void RegisterRunEvents(IEnumerable<IRun> runs) {
    84       foreach (IRun run in runs)
    85         run.Changed += new EventHandler(run_Changed);
     81      Content.UpdateOfRunsInProgressChanged += Content_UpdateOfRunsInProgressChanged;
    8682    }
    8783
     
    9187      Content.ItemsRemoved -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
    9288      Content.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
    93 
    94       DeregisterRunEvents(Content);
    95     }
    96 
    97     private void DeregisterRunEvents(IEnumerable<IRun> runs) {
    98       foreach (IRun run in runs)
    99         run.Changed -= new EventHandler(run_Changed);
     89      Content.UpdateOfRunsInProgressChanged -= Content_UpdateOfRunsInProgressChanged;
    10090    }
    10191
    10292    private void Content_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
    103       DeregisterRunEvents(e.OldItems);
    104       RegisterRunEvents(e.Items);
    105       RebuildCombinedDataTable();
     93      RebuildDataTable();
    10694    }
    10795
    10896    private void Content_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
    109       DeregisterRunEvents(e.Items);
    110       RebuildCombinedDataTable();
     97      RebuildDataTable();
    11198    }
    11299
    113100    private void Content_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
    114       RegisterRunEvents(e.Items);
    115       RebuildCombinedDataTable();
    116     }
    117 
    118     private void run_Changed(object sender, EventArgs e) {
    119       if (InvokeRequired)
    120         this.Invoke(new EventHandler(run_Changed), sender, e);
    121       else {
    122         if (!Content.UpdateOfRunsInProgress) {
    123           IRun run = (IRun)sender;
    124           UpdateRun(run);
    125         }
     101      RebuildDataTable();
     102    }
     103
     104    void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) {
     105      if (!Content.UpdateOfRunsInProgress) {
     106        RebuildDataTable();
    126107      }
    127108    }
     
    131112    void DataGridView_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) {
    132113      if (e.RowIndex >= 0) {
    133         IRun run = Content.ElementAt(stringConvertibleMatrixView.GetRowIndex(e.RowIndex));
     114        IRun run = runs[stringConvertibleMatrixView.GetRowIndex(e.RowIndex)];
    134115        IContentView view = MainFormManager.MainForm.ShowContent(run);
    135116        if (view != null) {
     
    145126
    146127    private void dataRowComboBox_SelectedIndexChanged(object sender, EventArgs e) {
    147       RebuildCombinedDataTable();
     128      RebuildDataTable();
    148129    }
    149130
     
    151132      string resultName = (string)dataTableComboBox.SelectedItem;
    152133      string rowName = (string)dataRowComboBox.SelectedItem;
    153       var runs = Content.Where(x => x.Results.ContainsKey(resultName) && x.Visible);
    154 
    155       foreach (Run run in runs) {
     134
     135      foreach (IRun run in runs) {
    156136        DataTable resTable = (DataTable)run.Results[resultName];
    157137        DataRow row = resTable.Rows[rowName];
     
    173153      string resultName = (string)dataTableComboBox.SelectedItem;
    174154      string rowName = (string)dataRowComboBox.SelectedItem;
    175       var runs = Content.Where(x => x.Results.ContainsKey(resultName) && x.Visible);
    176       StringMatrix sm = (StringMatrix)stringConvertibleMatrixView.Content;
     155      DoubleMatrix sm = (DoubleMatrix)stringConvertibleMatrixView.Content;
    177156
    178157      Content.UpdateOfRunsInProgress = true;
    179158      for (int i = 0; i < runs.Count(); i++) {
    180         IRun run = runs.ElementAt(i);
     159        IRun run = runs[i];
    181160
    182161        for (int j = 0; j < sm.ColumnNames.Count(); j++) {
    183           string newResultName = resultName + " " + rowName + " " + sm.ColumnNames.ElementAt(j);
    184           if (!run.Results.ContainsKey(newResultName))
    185             run.Results.Add(new KeyValuePair<string, Core.IItem>(newResultName, new DoubleValue(double.Parse(sm[i, j]))));
     162          if (stringConvertibleMatrixView.DataGridView.Columns[j].Visible) {
     163            string newResultName = resultName + " " + rowName + " " + sm.ColumnNames.ElementAt(j);
     164            if (!run.Results.ContainsKey(newResultName)) {
     165              run.Results.Add(new KeyValuePair<string, Core.IItem>(newResultName, new DoubleValue(sm[i, j])));
     166            }
     167          }
    186168        }
    187169      }
    188170      Content.UpdateOfRunsInProgress = false;
    189       //update column names of run collection
    190       Content.Modify();
    191171    }
    192172    #endregion
    193 
    194     private void UpdateRun(IRun run) {
    195       //TODO: hacky di hack... this is baaaadddd
    196       RebuildCombinedDataTable();
    197     }
    198173
    199174    private void UpdateDataRowComboBox() {
     
    222197    }
    223198
    224     private void RebuildCombinedDataTable() {
     199    private void RebuildDataTable() {
    225200      string resultName = (string)dataTableComboBox.SelectedItem;
    226201      string rowName = (string)dataRowComboBox.SelectedItem;
    227202      string[] columnNames = new string[] { "Count", "Minimum", "Maximum", "Average", "Median", "Standard Deviation", "Variance", "25th Percentile", "75th Percentile", "Gradient", "Relative Error", "Avg. of Upper 25 %", " Avg. of Lower 25 %", "Avg. of First 25 %", "Avg. of Last 25 %" };
    228203
    229       var runs = Content.Where(x => x.Results.ContainsKey(resultName) && x.Visible);
    230 
    231       StringMatrix dt = new StringMatrix(runs.Count(), columnNames.Count());
     204      runs = Content.Where(x => x.Results.ContainsKey(resultName) && x.Visible).ToList();
     205      DoubleMatrix dt = new DoubleMatrix(runs.Count(), columnNames.Count());
    232206      dt.RowNames = runs.Select(x => x.Name);
    233207      dt.ColumnNames = columnNames;
     
    257231        double lastAvg = values.Skip((int)(values.Count() * 0.75)).Average();
    258232
    259         dt[i, 0] = cnt.ToString();
    260         dt[i, 1] = min.ToString();
    261         dt[i, 2] = max.ToString();
    262         dt[i, 3] = avg.ToString();
    263         dt[i, 4] = median.ToString();
    264         dt[i, 5] = stdDev.ToString();
    265         dt[i, 6] = variance.ToString();
    266         dt[i, 7] = percentile25.ToString();
    267         dt[i, 8] = percentile75.ToString();
    268         dt[i, 9] = k.ToString();
    269         dt[i, 10] = r.ToString();
    270         dt[i, 11] = upperAvg.ToString();
    271         dt[i, 12] = lowerAvg.ToString();
    272         dt[i, 13] = firstAvg.ToString();
    273         dt[i, 14] = lastAvg.ToString();
     233        dt[i, 0] = cnt;
     234        dt[i, 1] = min;
     235        dt[i, 2] = max;
     236        dt[i, 3] = avg;
     237        dt[i, 4] = median;
     238        dt[i, 5] = stdDev;
     239        dt[i, 6] = variance;
     240        dt[i, 7] = percentile25;
     241        dt[i, 8] = percentile75;
     242        dt[i, 9] = k;
     243        dt[i, 10] = r;
     244        dt[i, 11] = upperAvg;
     245        dt[i, 12] = lowerAvg;
     246        dt[i, 13] = firstAvg;
     247        dt[i, 14] = lastAvg;
    274248
    275249        i++;
    276250      }
    277 
    278251      stringConvertibleMatrixView.Content = dt;
     252
     253      for (i = 0; i < runs.Count(); i++) {
     254        stringConvertibleMatrixView.DataGridView.Rows[i].DefaultCellStyle.ForeColor = runs[i].Color;
     255      }
    279256    }
    280257  }
Note: See TracChangeset for help on using the changeset viewer.