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