Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Visualization/MinAggregator.cs @ 1454

Last change on this file since 1454 was 1350, checked in by mstoeger, 16 years ago

Implemented multiple Y-Axes. A LineChart has several Y-Axes and each Y-Axis has several data rows. The same clipping area is set for all data rows belonging to a Y-Axis. (#433)

File size: 3.2 KB
RevLine 
[1325]1using System;
2using System.Collections.Generic;
3
4namespace HeuristicLab.Visualization {
[1350]5  public class MinAggregator : DataRowBase {
[1325]6    #region IAggregator Members
7
8    public void AddWatch(IDataRow dataRow) {
9      dataRowWatches.Add(dataRow);
10      dataRow.ValueChanged += dataRow_ValueChanged;
11      dataRow.ValuesChanged += dataRow_ValuesChanged;
12      dataRow.DataRowChanged += dataRow_DataRowChanged;
13    }
14
15    public void RemoveWatch(IDataRow dataRow) {
16
17      dataRowWatches.Remove(dataRow);
18      dataRow.DataRowChanged -= dataRow_DataRowChanged;
19      dataRow.ValuesChanged -= dataRow_ValuesChanged;
20      dataRow.ValueChanged -= dataRow_ValueChanged;
21    }
22
23
24    #endregion
25
26    readonly List<IDataRow> dataRowWatches = new List<IDataRow>();
27    double curMinValue;
28
29    void dataRow_ValueChanged(IDataRow row, double value, int index, Action action) {
30      refreshValue(value);
31    }
32
33    void dataRow_ValuesChanged(IDataRow row, double[] values, int index, Action action) {
34      for (int i = 0; i < values.Length; i++) {
35        refreshValue(values[i]);
36      }
37    }
38
39    void dataRow_DataRowChanged(IDataRow row) {
40      refreshValue(double.MaxValue);
41    }
42
43    private void refreshValue(double newVal) {
44      //alle durchlaufen und neues min berechnen; verbesserung: merken in welcher row lowest wert steckt
45      if (curMinValue > newVal) {
46        curMinValue = newVal;
47        OnValueChanged(newVal, 0, Action.Modified);
48      } else {
49        curMinValue = double.MaxValue;
[1350]50        foreach (IDataRow rows in dataRowWatches) {
[1325]51          for (int i = 0; i < rows.Count; i++) {
52            if (rows[i] < curMinValue) {
53              curMinValue = rows[i];
54            }
55          }
56        }
57
58      }
59      // evtl nur feuern wenn sich geändert hat (jedes mal?)
60      OnValueChanged(curMinValue, 0, Action.Modified);
61    }
62
63    #region IDataRow Members
64
[1350]65    public override void AddValue(double value) {
[1325]66      OnValueChanged(2, 0, Action.Added);
67    }
68
[1350]69    public override void AddValue(double value, int index) {
[1325]70      throw new NotSupportedException();
71    }
72
[1350]73    public override void AddValues(double[] values) {
[1325]74      throw new NotSupportedException();
75    }
76
[1350]77    public override void AddValues(double[] values, int index) {
[1325]78      throw new NotSupportedException();
79    }
80
[1350]81    public override void ModifyValue(double value, int index) {
[1325]82      throw new NotSupportedException();
83    }
84
[1350]85    public override void ModifyValues(double[] values, int index) {
[1325]86      throw new NotSupportedException();
87    }
88
[1350]89    public override void RemoveValue(int index) {
[1325]90      throw new NotSupportedException();
91    }
92
[1350]93    public override void RemoveValues(int index, int count) {
[1325]94      throw new NotSupportedException();
95    }
96
[1350]97    public override int Count {
[1325]98      get { return 1; }
99    }
100
[1350]101    public override double this[int index] {
[1325]102      get {
103        return curMinValue;
104      }
105      set {
106        throw new NotSupportedException();
107      }
108    }
109
[1350]110    public override double MinValue {
111      get { return curMinValue; }
[1327]112    }
113
[1350]114    public override double MaxValue {
115      get { return curMinValue; }
[1327]116    }
117
[1325]118    #endregion
119  }
120}
Note: See TracBrowser for help on using the repository browser.