Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/DataTableHelper.cs @ 9059

Last change on this file since 9059 was 9059, checked in by ascheibe, 11 years ago

#1886 track min and max quality values for scaling

File size: 2.7 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using HeuristicLab.Collections;
23using HeuristicLab.Common;
24using HeuristicLab.Core;
25using HeuristicLab.Optimization;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27
28namespace HeuristicLab.Analysis.AlgorithmBehavior.Analyzers {
29  [Item("DataTableHelper", "Helper class for creating datatables.")]
30  [StorableClass]
31  public class DataTableHelper : Item {
32
33    [Storable]
34    private ResultCollection resultsCol;
35    [Storable]
36    private string chartName;
37    [Storable]
38    private string[] dataRowNames;
39    [Storable]
40    DataTable dt;
41
42    [StorableConstructor]
43    private DataTableHelper(bool deserializing) : base(deserializing) { }
44    private DataTableHelper(DataTableHelper original, Cloner cloner)
45      : base(original, cloner) { }
46    public DataTableHelper() : base() { }
47
48    public override IDeepCloneable Clone(Cloner cloner) {
49      return new DataTableHelper(this, cloner);
50    }
51
52    public void InitializeChart(ResultCollection results, string chartName, string[] dataRowNames) {
53      if (!results.ContainsKey(chartName)) {
54        this.resultsCol = results;
55        this.chartName = chartName;
56        this.dataRowNames = dataRowNames;
57
58        dt = new DataTable(chartName);
59
60        foreach (string dataRowName in dataRowNames) {
61          DataRow dtRow = new DataRow(dataRowName);
62          dt.Rows.Add(dtRow);
63        }
64
65        results.Add(new Result(chartName, dt));
66      }
67    }
68
69    public void AddPoint(string dataRow, double point) {
70      dt.Rows[dataRow].Values.Add(point);
71    }
72
73    public void AddPoint(double point) {
74      // assume that there is only 1 row and therefore the name doesn't have to be provided
75      dt.Rows[dataRowNames[0]].Values.Add(point);
76    }
77
78    public ObservableList<double> GetFirstDataRow() {
79      return dt.Rows[dataRowNames[0]].Values;
80    }
81  }
82}
Note: See TracBrowser for help on using the repository browser.