Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/LineChartLogic.cs @ 10638

Last change on this file since 10638 was 10628, checked in by aesterer, 11 years ago

Refactored LineChartLogic and added CheckedItemListView to LineChartView

File size: 2.9 KB
RevLine 
[10539]1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 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
[10544]22using System;
[10244]23using System.Collections.Generic;
[10377]24using HeuristicLab.Analysis;
[10628]25using HeuristicLab.Core;
26using HeuristicLab.Data;
[10244]27
[10539]28namespace HeuristicLab.DataPreprocessing {
29  public class LineChartLogic : ILineChartLogic {
[10628]30 
[10586]31    private ITransactionalPreprocessingData preprocessingData;
[10377]32
[10586]33    public LineChartLogic(ITransactionalPreprocessingData preprocessingData) {
[10377]34      this.preprocessingData = preprocessingData;
35    }
36
[10628]37    public DataTable CreateDataTable(String title) {
38      DataTable dataTable = new DataTable(title);
39      IEnumerable<string> variableNames = GetVariableNames();
[10377]40
[10539]41      foreach (string variableName in variableNames) {
[10628]42        DataRow row = CreateDataRow(variableName);
[10377]43        dataTable.Rows.Add(row);
44      }
[10628]45      return dataTable;
46    }
[10539]47
[10628]48    public DataRow CreateDataRow(string variableName) {
49      IList<double> values = preprocessingData.GetValues<double>(variableName);
50      DataRow row = new DataRow(variableName, "", values);
51      return row;
[10377]52    }
[10382]53
[10628]54    private IEnumerable<string> GetVariableNames() {
[10552]55      List<string> doubleVariableNames = new List<string>();
56
57      //only return variable names from type double
58      foreach (string variableName in preprocessingData.VariableNames) {
59        if (preprocessingData.IsType<double>(preprocessingData.GetColumnIndex(variableName)))
60          doubleVariableNames.Add(variableName);
61      }
62
63      return doubleVariableNames;
[10382]64    }
65
[10628]66    public ICheckedItemList<StringValue> CreateVariableItemList() {
67      ICheckedItemList<StringValue> itemList = new CheckedItemList<StringValue>();
68      foreach (string name in GetVariableNames()) {
69        itemList.Add(new StringValue(name), true);
[10382]70      }
[10628]71      return new ReadOnlyCheckedItemList<StringValue>(itemList);
[10382]72    }
73
[10573]74    public event DataPreprocessingChangedEventHandler Changed {
75      add { preprocessingData.Changed += value; }
76      remove { preprocessingData.Changed -= value; }
77    }
[10628]78
79    public string GetVariableNameByIndex(int index) {
80      return preprocessingData.GetVariableName(index);
81    }
82
[10244]83  }
84}
Note: See TracBrowser for help on using the repository browser.