Changeset 1605
- Timestamp:
- 04/18/09 13:26:48 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.Visualization/3.2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Visualization/3.2/AvgAggregator.cs
r1530 r1605 26 26 27 27 private void dataRow_ValueChanged(IDataRow row, double value, int index, Action action) { 28 refreshValue(value); 28 switch (action) { 29 case Action.Added: 30 refreshValue(value, action); 31 break; 32 case Action.Modified: 33 refreshValue(); 34 break; 35 case Action.Deleted: 36 refreshValue(value, action); 37 break; 38 default: 39 throw new ArgumentOutOfRangeException("action"); 40 } 41 42 29 43 } 30 44 31 45 private void dataRow_ValuesChanged(IDataRow row, double[] values, int index, Action action) { 32 46 for (int i = 0; i < values.Length; i++) { 33 refreshValue( values[i]);47 refreshValue(); 34 48 } 35 49 } 36 50 37 51 private void dataRow_DataRowChanged(IDataRow row) { 38 refreshValue( double.MinValue);52 refreshValue(); 39 53 } 40 54 41 private void refreshValue(double newVal) { 42 //alle durchlaufen und neues min berechnen; verbesserung: merken in welcher row lowest wert steckt 55 private int count; 56 57 public AvgAggregator() { 58 curAvgValue = 0; 59 count = 0; 60 } 43 61 62 private void refreshValue() { 44 63 curAvgValue = double.MinValue; 45 64 double tmpSum = 0; 46 intcount = 0;65 count = 0; 47 66 foreach (IDataRow rows in dataRowWatches) { 48 67 for (int i = 0; i < rows.Count; i++) { … … 51 70 } 52 71 } 53 curAvgValue = tmpSum/count; 54 // evtl nur feuern wenn sich geändert hat (jedes mal?) 72 if (count == 0) curAvgValue = 0; 73 else curAvgValue = tmpSum / count; 74 OnValueChanged(curAvgValue, 0, Action.Modified); 75 } 76 private void refreshValue(double newVal, Action action) { 77 double temp = curAvgValue * count; 78 79 switch (action) { 80 case Action.Added: 81 temp += newVal; 82 count++; 83 break; 84 case Action.Modified: 85 throw new InvalidOperationException(); 86 case Action.Deleted: 87 temp -= newVal; 88 count--; 89 break; 90 default: 91 throw new ArgumentOutOfRangeException("action"); 92 } 93 94 curAvgValue = temp / count; 55 95 OnValueChanged(curAvgValue, 0, Action.Modified); 56 96 } -
trunk/sources/HeuristicLab.Visualization/3.2/AvgLineAggregator.cs
r1530 r1605 28 28 29 29 List<IDataRow> dataRowWatches = new List<IDataRow>(); 30 30 31 31 void dataRow_ValueChanged(IDataRow row, double value, int index, Action action) { 32 refreshValue(value); 32 switch (action) { 33 case Action.Added: 34 refreshValue(row, value, Action.Added); 35 break; 36 case Action.Modified: 37 refreshValue(); 38 break; 39 case Action.Deleted: 40 refreshValue(row, value, Action.Deleted); 41 break; 42 default: 43 throw new ArgumentOutOfRangeException("action"); 44 } 45 33 46 } 34 47 35 48 void dataRow_ValuesChanged(IDataRow row, double[] values, int index, Action action) { 36 49 for (int i = 0; i < values.Length; i++) { 37 refreshValue( values[i]);50 refreshValue(); 38 51 } 39 52 } 40 53 41 54 void dataRow_DataRowChanged(IDataRow row) { 42 refreshValue(double.MinValue); 43 } 44 45 private void refreshValue(double newVal) { 46 //alle durchlaufen und neues min berechnen; verbesserung: merken in welcher row lowest wert steckt 47 48 //curAvgValue = double.MinValue; 55 refreshValue(); 56 } 57 58 private void refreshValue() { 49 59 double tmpSum = 0; 50 60 int count = dataRowWatches.Count; … … 65 75 } 66 76 67 this.dataRow.Add(tmpSum /count);77 this.dataRow.Add(tmpSum / count); 68 78 OnValueChanged(tmpSum / count, dataRow.Count - 1, Action.Added); 69 79 } 70 80 } 81 } 82 83 private void refreshValue(IDataRow row, double newVal, Action action) { 84 85 int index = row.Count - 1; 86 87 88 89 90 double curAvg = 0; 91 // if (dataRow.Count > 0) { 92 // curAvg = dataRow[0]; //? 93 // } else { 94 // curAvg = 0; 95 // } 96 97 98 foreach (IDataRow watch in dataRowWatches) { 99 if (watch.Count >= index +1) { 100 curAvg += watch[index]; 101 102 } 103 //curAvg += watch[watch.Count - 1]; 104 } 105 106 if (dataRowWatches.Count > 0) 107 curAvg /= dataRowWatches.Count; 108 109 110 if (dataRow.Count <= index) { 111 dataRow.Add(curAvg); 112 OnValueChanged(curAvg, dataRow.Count - 1, Action.Added); 113 } 114 else { 115 dataRow[index] = curAvg; 116 OnValueChanged(curAvg, dataRow.Count - 1, Action.Modified); 117 } 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 // } 71 160 72 161 // evtl nur feuern wenn sich geändert hat (jedes mal?)
Note: See TracChangeset
for help on using the changeset viewer.