Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/18/09 14:41:05 (15 years ago)
Author:
cbahner
Message:

#519 test cases + code review

Location:
trunk/sources/HeuristicLab.Visualization/3.2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Visualization/3.2/AvgAggregator.cs

    r1605 r1607  
    2222    #endregion
    2323
    24     private List<IDataRow> dataRowWatches = new List<IDataRow>();
     24    private readonly List<IDataRow> dataRowWatches = new List<IDataRow>();
    2525    private double curAvgValue;
    2626
     
    126126    }
    127127
    128     public override void RemoveValues(int index, int count) {
     128    public override void RemoveValues(int index, int countVals) {
    129129      throw new NotSupportedException();
    130130    }
  • trunk/sources/HeuristicLab.Visualization/3.2/AvgLineAggregator.cs

    r1605 r1607  
    66
    77    private readonly List<double> dataRow = new List<double>();
     8    readonly List<IDataRow> dataRowWatches = new List<IDataRow>();
    89
    910    #region IAggregator Members
    1011
    11     public void AddWatch(IDataRow dataRow) {
    12       dataRowWatches.Add(dataRow);
    13       dataRow.ValueChanged += dataRow_ValueChanged;
    14       dataRow.ValuesChanged += dataRow_ValuesChanged;
    15       dataRow.DataRowChanged += dataRow_DataRowChanged;
     12    public void AddWatch(IDataRow watchDataRow) {
     13      dataRowWatches.Add(watchDataRow);
     14      watchDataRow.ValueChanged += dataRow_ValueChanged;
     15      watchDataRow.ValuesChanged += dataRow_ValuesChanged;
     16      watchDataRow.DataRowChanged += dataRow_DataRowChanged;
    1617    }
    1718
    18     public void RemoveWatch(IDataRow dataRow) {
    19 
    20       dataRowWatches.Remove(dataRow);
    21       dataRow.DataRowChanged -= dataRow_DataRowChanged;
    22       dataRow.ValuesChanged -= dataRow_ValuesChanged;
    23       dataRow.ValueChanged -= dataRow_ValueChanged;
     19    public void RemoveWatch(IDataRow watchDataRow) {
     20      dataRowWatches.Remove(watchDataRow);
     21      watchDataRow.DataRowChanged -= dataRow_DataRowChanged;
     22      watchDataRow.ValuesChanged -= dataRow_ValuesChanged;
     23      watchDataRow.ValueChanged -= dataRow_ValueChanged;
    2424    }
    2525
    26 
    2726    #endregion
    28 
    29     List<IDataRow> dataRowWatches = new List<IDataRow>();
    3027
    3128    void dataRow_ValueChanged(IDataRow row, double value, int index, Action action) {
    3229      switch (action) {
    3330        case Action.Added:
    34           refreshValue(row, value, Action.Added);
     31          refreshLastValues(row);
    3532          break;
    3633        case Action.Modified:
     
    3835          break;
    3936        case Action.Deleted:
    40           refreshValue(row, value, Action.Deleted);
     37          refreshLastValues(row);
    4138          break;
    4239        default:
    4340          throw new ArgumentOutOfRangeException("action");
    4441      }
    45 
    4642    }
    4743
     
    5753
    5854    private void refreshValue() {
    59       double tmpSum = 0;
     55     
    6056      int count = dataRowWatches.Count;
    6157
    6258      IDataRow firstRow = dataRowWatches[0];
    6359      int count1 = firstRow.Count;
    64       System.Console.WriteLine("count: " + count1);
     60      Console.WriteLine("count: " + count1);
    6561
    6662      dataRow.Clear();
     
    6864      if (dataRowWatches.Count >= 2) {
    6965        for (int i = 0; i < count1; i++) {
    70           tmpSum = 0;
     66          double tmpSum = 0;
    7167          for (int j = 0; j < count; j++) {
    7268            if (dataRowWatches[j].Count > i) {
     
    7571          }
    7672
    77           this.dataRow.Add(tmpSum / count);
     73          dataRow.Add(tmpSum / count);
    7874          OnValueChanged(tmpSum / count, dataRow.Count - 1, Action.Added);
    7975        }
     
    8177    }
    8278
    83     private void refreshValue(IDataRow row, double newVal, Action action) {
     79    private void refreshLastValues(IDataRow row) {
    8480
    8581      int index = row.Count - 1;
    86 
    87 
    88      
    89      
    9082      double curAvg = 0;
    91 //      if (dataRow.Count > 0) {
    92 //        curAvg = dataRow[0];   //?
    93 //      } else {
    94 //        curAvg = 0;
    95 //      }
    96 
    9783
    9884      foreach (IDataRow watch in dataRowWatches) {
    9985        if (watch.Count >= index +1) {
    100           curAvg += watch[index];
    101          
     86          curAvg += watch[index];
    10287        }
    103         //curAvg += watch[watch.Count - 1];
    10488      }
    10589
     
    116100        OnValueChanged(curAvg, dataRow.Count - 1, Action.Modified); 
    117101      }
    118 
    119 
    120 
    121 //      curAvg *= dataRow.Count * dataRowWatches.Count;
    122 //      switch (action) {
    123 //        case Action.Added:
    124 //          curAvg += newVal;
    125 //          break;
    126 //        case Action.Modified:
    127 //          throw new InvalidOperationException();
    128 //        case Action.Deleted:
    129 //          curAvg -= newVal;
    130 //          break;
    131 //        default:
    132 //          throw new ArgumentOutOfRangeException("action");
    133 //      }
    134 //
    135 //      dataRow.Add((curAvg / (dataRow.Count + 1)) / dataRowWatches.Count);
    136 //      OnValueChanged((curAvg / (dataRow.Count + 1)) / dataRowWatches.Count, dataRow.Count - 1, Action.Added); // nicht immer adden!
    137 
    138       //      double tmpSum = 0;
    139       //      int count = dataRowWatches.Count;
    140       //
    141       //      IDataRow firstRow = dataRowWatches[0];
    142       //      int count1 = firstRow.Count;
    143       //      System.Console.WriteLine("count: " + count1);
    144       //
    145       //      dataRow.Clear();
    146       //
    147       //      if (dataRowWatches.Count >= 2) {
    148       //        for (int i = 0; i < count1; i++) {
    149       //          tmpSum = 0;
    150       //          for (int j = 0; j < count; j++) {
    151       //            if (dataRowWatches[j].Count > i) {
    152       //              tmpSum += dataRowWatches[j][i];
    153       //            }
    154       //          }
    155       //
    156       //          this.dataRow.Add(tmpSum/count);
    157       //          OnValueChanged(tmpSum / count, dataRow.Count - 1, Action.Added);
    158       //        }
    159       //      }
    160 
    161       // evtl nur feuern wenn sich geändert hat (jedes mal?)
    162       //OnDataRowChanged(this);
    163102    }
    164103
     
    171110
    172111    public override void AddValue(double value, int index) {
    173       throw new NotImplementedException();
     112      throw new NotSupportedException();
    174113    }
    175114
     
    194133    }
    195134
    196     public override void RemoveValues(int index, int count) {
     135    public override void RemoveValues(int index, int countVals) {
    197136      throw new NotSupportedException();
    198137    }
     
    210149    }
    211150
    212     // TODO calculate min value
    213151    public override double MinValue {
    214152      get { return 0; }
    215153    }
    216154
    217     // TODO calculate max value
    218155    public override double MaxValue {
    219156      get { return 0; }
  • trunk/sources/HeuristicLab.Visualization/3.2/MaxAggregator.cs

    r1530 r1607  
    11using System;
    22using System.Collections.Generic;
    3 using System.Drawing;
    43
    54namespace HeuristicLab.Visualization {
Note: See TracChangeset for help on using the changeset viewer.