Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/ChartLogic.cs @ 10733

Last change on this file since 10733 was 10733, checked in by aesterer, 10 years ago

Modified chart logic

File size: 2.9 KB
Line 
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
22using System;
23using System.Collections.Generic;
24using HeuristicLab.Analysis;
25using HeuristicLab.Core;
26using HeuristicLab.Data;
27
28namespace HeuristicLab.DataPreprocessing {
29
30  public class ChartLogic : IChartLogic {
31 
32    private ITransactionalPreprocessingData preprocessingData;
33
34    public ChartLogic(ITransactionalPreprocessingData preprocessingData) {
35      this.preprocessingData = preprocessingData;
36    }
37
38    public DataRow CreateDataRow(string variableName, DataRowVisualProperties.DataRowChartType chartType) {
39      IList<double> values = preprocessingData.GetValues<double>(variableName);
40      DataRow row = new DataRow(variableName, "", values);
41      row.VisualProperties.ChartType = chartType;
42      return row;
43    }
44
45    private IEnumerable<string> GetVariableNames() {
46      List<string> doubleVariableNames = new List<string>();
47
48      //only return variable names from type double
49      foreach (string variableName in preprocessingData.VariableNames) {
50        if (preprocessingData.IsType<double>(preprocessingData.GetColumnIndex(variableName)))
51          doubleVariableNames.Add(variableName);
52      }
53
54      return doubleVariableNames;
55    }
56
57    public ICheckedItemList<StringValue> CreateVariableItemList() {
58      ICheckedItemList<StringValue> itemList = new CheckedItemList<StringValue>();
59      foreach (string name in GetVariableNames()) {
60        itemList.Add(new StringValue(name), true);
61      }
62      return new ReadOnlyCheckedItemList<StringValue>(itemList);
63    }
64
65    public event DataPreprocessingChangedEventHandler Changed {
66      add { preprocessingData.Changed += value; }
67      remove { preprocessingData.Changed -= value; }
68    }
69
70    public string GetVariableNameByIndex(int index) {
71      return preprocessingData.GetVariableName(index);
72    }
73
74
75    public List<DataRow> CreateAllDataRows(DataRowVisualProperties.DataRowChartType chartType) {
76      List<DataRow> dataRows = new List<DataRow>();
77      foreach (var name in GetVariableNames())
78        dataRows.Add(CreateDataRow(name, chartType));
79      return dataRows;
80    }
81
82  }
83}
Note: See TracBrowser for help on using the repository browser.