- Timestamp:
- 03/19/14 14:24:40 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/LineChartLogic.cs
r10586 r10628 23 23 using System.Collections.Generic; 24 24 using HeuristicLab.Analysis; 25 using HeuristicLab.Core; 26 using HeuristicLab.Data; 25 27 26 28 namespace HeuristicLab.DataPreprocessing { 27 29 public class LineChartLogic : ILineChartLogic { 30 28 31 private ITransactionalPreprocessingData preprocessingData; 29 private DataTable dataTable;30 32 31 33 public LineChartLogic(ITransactionalPreprocessingData preprocessingData) { 32 34 this.preprocessingData = preprocessingData; 33 dataTable = new DataTable("LineChart");34 FillDataTable();35 preprocessingData.Changed += PreprocessingData_Changed;36 35 } 37 36 38 private void FillDataTable() { 39 IEnumerable<string> variableNames = preprocessingData.VariableNames; 37 public DataTable CreateDataTable(String title) { 38 DataTable dataTable = new DataTable(title); 39 IEnumerable<string> variableNames = GetVariableNames(); 40 40 41 41 foreach (string variableName in variableNames) { 42 IList<double> values = preprocessingData.GetValues<double>(variableName); 43 DataRow row = new DataRow(variableName, "", values); 42 DataRow row = CreateDataRow(variableName); 44 43 dataTable.Rows.Add(row); 45 44 } 46 45 return dataTable; 47 46 } 48 47 49 public IEnumerable<object> GetVariableNames() { 48 public DataRow CreateDataRow(string variableName) { 49 IList<double> values = preprocessingData.GetValues<double>(variableName); 50 DataRow row = new DataRow(variableName, "", values); 51 return row; 52 } 53 54 private IEnumerable<string> GetVariableNames() { 50 55 List<string> doubleVariableNames = new List<string>(); 51 56 … … 59 64 } 60 65 61 public DataTable GetDataTable() { 62 return dataTable; 63 } 64 65 public void RemoveVariable(string name) { 66 dataTable.Rows.Remove(name); 67 } 68 69 public void AddVariable(string name) { 70 IList<double> values = preprocessingData.GetValues<double>(name); 71 DataRow row = new DataRow(name, "", values); 72 dataTable.Rows.Add(row); 73 } 74 75 public bool VariableIsDisplayed(string name) { 76 77 foreach (var item in dataTable.Rows) { 78 if (item.Name == name) 79 return true; 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); 80 70 } 81 return false; 82 } 83 84 //TODO: refactor: possible code duplication with HistogramLogic 85 void PreprocessingData_Changed(object sender, DataPreprocessingChangedEventArgs e) { 86 switch (e.Type) { 87 case DataPreprocessingChangedEventType.DeleteColumn: 88 dataTable.Rows.Remove(preprocessingData.GetVariableName(e.Column)); 89 break; 90 case DataPreprocessingChangedEventType.AddColumn: 91 dataTable.Rows.Add(new DataRow(preprocessingData.GetVariableName(e.Column), String.Empty, preprocessingData.GetValues<double>(e.Column))); 92 break; 93 case DataPreprocessingChangedEventType.ChangeColumn: 94 case DataPreprocessingChangedEventType.ChangeItem: 95 dataTable.Rows.Remove(preprocessingData.GetVariableName(e.Column)); 96 dataTable.Rows.Add(new DataRow(preprocessingData.GetVariableName(e.Column), String.Empty, preprocessingData.GetValues<double>(e.Column))); 97 break; 98 case DataPreprocessingChangedEventType.DeleteRow: 99 case DataPreprocessingChangedEventType.AddRow: 100 dataTable.Rows.Clear(); 101 FillDataTable(); 102 break; 103 } 71 return new ReadOnlyCheckedItemList<StringValue>(itemList); 104 72 } 105 73 … … 108 76 remove { preprocessingData.Changed -= value; } 109 77 } 78 79 public string GetVariableNameByIndex(int index) { 80 return preprocessingData.GetVariableName(index); 81 } 82 110 83 } 111 84 }
Note: See TracChangeset
for help on using the changeset viewer.