- Timestamp:
- 05/07/14 10:49:15 (11 years ago)
- Location:
- branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/DataGridLogic.cs
r10662 r10804 143 143 return columnIndices.All(x => preprocessingData.IsType<string>(x)); 144 144 } 145 146 147 148 public void SetSelection(IDictionary<int, IList<int>> selection) { 149 preprocessingData.SetSelection(selection); 150 } 151 152 public IDictionary<int, IList<int>> GetSelection() { 153 return preprocessingData.GetSelection(); 154 } 155 public void ClearSelection() { 156 preprocessingData.ClearSelection(); 157 } 158 159 public event EventHandler SelectionChanged { 160 add { preprocessingData.SelectionChanged += value; } 161 remove { preprocessingData.SelectionChanged -= value; } 162 } 163 145 164 } 146 165 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/FilteredPreprocessingData.cs
r10783 r10804 4 4 using HeuristicLab.Core; 5 5 using HeuristicLab.Data; 6 using HeuristicLab.DataPreprocessing.Interfaces; 6 7 using HeuristicLab.Problems.DataAnalysis; 7 8 using HeuristicLab.Problems.DataAnalysis.Transformations; 8 using HeuristicLab.DataPreprocessing.Interfaces;9 9 10 namespace HeuristicLab.DataPreprocessing.Implementations 11 { 12 public class FilteredPreprocessingData : NamedItem, IFilteredPreprocessingData 13 { 10 namespace HeuristicLab.DataPreprocessing.Implementations { 11 public class FilteredPreprocessingData : NamedItem, IFilteredPreprocessingData { 14 12 protected ITransactionalPreprocessingData originalData; 15 13 protected ITransactionalPreprocessingData filteredData; … … 17 15 protected FilteredPreprocessingData(FilteredPreprocessingData original, Cloner cloner) 18 16 : base(original, cloner) { 19 20 17 originalData = (ITransactionalPreprocessingData)original.originalData; 18 filteredData = (ITransactionalPreprocessingData)original.filteredData; 21 19 } 22 20 23 21 public FilteredPreprocessingData(ITransactionalPreprocessingData preporcessingData) 24 22 : base() { 25 26 23 originalData = preporcessingData; 24 filteredData = null; 27 25 } 28 26 29 public override IDeepCloneable Clone(Cloner cloner) 30 { 31 return new FilteredPreprocessingData(this, cloner); 32 } 27 public override IDeepCloneable Clone(Cloner cloner) { 28 return new FilteredPreprocessingData(this, cloner); 29 } 33 30 34 public T GetCell<T>(int columnIndex, int rowIndex) 35 { 36 return ActiveData.GetCell<T>(columnIndex, rowIndex); 37 } 31 public T GetCell<T>(int columnIndex, int rowIndex) { 32 return ActiveData.GetCell<T>(columnIndex, rowIndex); 33 } 38 34 39 public void SetCell<T>(int columnIndex, int rowIndex, T value) 40 { 41 ReadOnlyOnFilterData.SetCell<T>(columnIndex, rowIndex, value); 42 } 35 public void SetCell<T>(int columnIndex, int rowIndex, T value) { 36 ReadOnlyOnFilterData.SetCell<T>(columnIndex, rowIndex, value); 37 } 43 38 44 public string GetCellAsString(int columnIndex, int rowIndex) 45 { 46 return ActiveData.GetCellAsString(columnIndex, rowIndex); 47 } 39 public string GetCellAsString(int columnIndex, int rowIndex) { 40 return ActiveData.GetCellAsString(columnIndex, rowIndex); 41 } 48 42 49 public IList<T> GetValues<T>(string variableName) 50 { 51 return ActiveData.GetValues<T>(variableName); 52 } 43 public IList<T> GetValues<T>(string variableName) { 44 return ActiveData.GetValues<T>(variableName); 45 } 53 46 54 public IList<T> GetValues<T>(int columnIndex) 55 { 56 return ActiveData.GetValues<T>(columnIndex); 57 } 47 public IList<T> GetValues<T>(int columnIndex) { 48 return ActiveData.GetValues<T>(columnIndex); 49 } 58 50 59 public void SetValues<T>(int columnIndex, IList<T> values) 60 { 61 ReadOnlyOnFilterData.SetValues<T>(columnIndex, values); 62 } 51 public void SetValues<T>(int columnIndex, IList<T> values) { 52 ReadOnlyOnFilterData.SetValues<T>(columnIndex, values); 53 } 63 54 64 public void InsertRow(int rowIndex) 65 { 66 ReadOnlyOnFilterData.InsertRow(rowIndex); 67 } 55 public void InsertRow(int rowIndex) { 56 ReadOnlyOnFilterData.InsertRow(rowIndex); 57 } 68 58 69 public void DeleteRow(int rowIndex) 70 { 71 ReadOnlyOnFilterData.DeleteRow(rowIndex); 72 } 59 public void DeleteRow(int rowIndex) { 60 ReadOnlyOnFilterData.DeleteRow(rowIndex); 61 } 73 62 74 public void InsertColumn<T>(string variableName, int columnIndex) 75 { 76 ReadOnlyOnFilterData.InsertColumn<T>(variableName, columnIndex); 77 } 63 public void InsertColumn<T>(string variableName, int columnIndex) { 64 ReadOnlyOnFilterData.InsertColumn<T>(variableName, columnIndex); 65 } 78 66 79 public void DeleteColumn(int columnIndex) 80 { 81 ReadOnlyOnFilterData.DeleteColumn(columnIndex); 82 } 67 public void DeleteColumn(int columnIndex) { 68 ReadOnlyOnFilterData.DeleteColumn(columnIndex); 69 } 83 70 84 public IntRange TrainingPartition 85 { 86 get { return originalData.TrainingPartition; } 87 } 71 public IntRange TrainingPartition { 72 get { return originalData.TrainingPartition; } 73 } 88 74 89 public IntRange TestPartition 90 { 91 get { return originalData.TestPartition; } 92 } 75 public IntRange TestPartition { 76 get { return originalData.TestPartition; } 77 } 93 78 94 public IList<ITransformation> Transformations 95 { 96 get { return originalData.Transformations; } 97 } 79 public IList<ITransformation> Transformations { 80 get { return originalData.Transformations; } 81 } 98 82 99 public IEnumerable<string> VariableNames 100 { 101 get { return ActiveData.VariableNames; } 102 } 83 public IEnumerable<string> VariableNames { 84 get { return ActiveData.VariableNames; } 85 } 103 86 104 public string GetVariableName(int columnIndex) 105 { 106 return ActiveData.GetVariableName(columnIndex); 107 } 87 public string GetVariableName(int columnIndex) { 88 return ActiveData.GetVariableName(columnIndex); 89 } 108 90 109 public int GetColumnIndex(string variableName) 110 { 111 return ActiveData.GetColumnIndex(variableName); 112 } 91 public int GetColumnIndex(string variableName) { 92 return ActiveData.GetColumnIndex(variableName); 93 } 113 94 114 public bool IsType<T>(int columnIndex) 115 { 116 return originalData.IsType<T>(columnIndex); 117 } 95 public bool IsType<T>(int columnIndex) { 96 return originalData.IsType<T>(columnIndex); 97 } 118 98 119 public int Columns 120 { 121 get { return ActiveData.Columns; } 122 } 99 public int Columns { 100 get { return ActiveData.Columns; } 101 } 123 102 124 public int Rows 125 { 126 get { return ActiveData.Rows; } 127 } 103 public int Rows { 104 get { return ActiveData.Rows; } 105 } 128 106 129 public Dataset ExportToDataset() 130 { 131 return originalData.ExportToDataset(); 132 } 107 public Dataset ExportToDataset() { 108 return originalData.ExportToDataset(); 109 } 133 110 134 111 public void SetFilter(bool[] rowFilters) { 135 112 136 113 filteredData = (ITransactionalPreprocessingData)originalData.Clone(); 137 114 138 for (int row = (rowFilters.Length - 1); row >= 0; --row) 139 { 140 if (rowFilters[row]) 141 { 142 filteredData.DeleteRow(row); 143 } 144 } 145 } 115 for (int row = (rowFilters.Length - 1); row >= 0; --row) { 116 if (rowFilters[row]) { 117 filteredData.DeleteRow(row); 118 } 119 } 120 } 146 121 147 148 149 150 122 public void PersistFilter() { 123 originalData = (ITransactionalPreprocessingData)filteredData.Clone(); 124 ResetFilter(); 125 } 151 126 152 153 154 127 public void ResetFilter() { 128 filteredData = null; 129 } 155 130 156 public ITransactionalPreprocessingData ActiveData 157 { 158 get { return IsFiltered ? filteredData : originalData; } 159 } 131 public ITransactionalPreprocessingData ActiveData { 132 get { return IsFiltered ? filteredData : originalData; } 133 } 160 134 161 public ITransactionalPreprocessingData ReadOnlyOnFilterData 162 { 163 get { 164 if (IsFiltered) 165 throw new InvalidOperationException(); 166 167 return originalData; 168 } 169 } 135 public ITransactionalPreprocessingData ReadOnlyOnFilterData { 136 get { 137 if (IsFiltered) 138 throw new InvalidOperationException(); 170 139 171 public bool IsFiltered {172 get { return filteredData != null;}173 140 return originalData; 141 } 142 } 174 143 175 public event DataPreprocessingChangedEventHandler Changed; 144 public bool IsFiltered { 145 get { return filteredData != null; } 146 } 176 147 177 public bool IsUndoAvailable 178 { 179 get { return IsFiltered ? false : originalData.IsUndoAvailable; } 180 } 148 public event DataPreprocessingChangedEventHandler Changed; 181 149 182 public void Undo() 183 { 184 ReadOnlyOnFilterData.Undo(); 185 } 150 public bool IsUndoAvailable { 151 get { return IsFiltered ? false : originalData.IsUndoAvailable; } 152 } 186 153 187 public void InTransaction(Action action, DataPreprocessingChangedEventType type = DataPreprocessingChangedEventType.Any) 188 { 189 ReadOnlyOnFilterData.InTransaction(action, type); 190 } 154 public void Undo() { 155 ReadOnlyOnFilterData.Undo(); 156 } 191 157 192 public void BeginTransaction(DataPreprocessingChangedEventType type) 193 { 194 ReadOnlyOnFilterData.BeginTransaction(type); 195 } 158 public void InTransaction(Action action, DataPreprocessingChangedEventType type = DataPreprocessingChangedEventType.Any) { 159 ReadOnlyOnFilterData.InTransaction(action, type); 160 } 196 161 197 public void EndTransaction() 198 { 199 originalData.EndTransaction(); 200 } 162 public void BeginTransaction(DataPreprocessingChangedEventType type) { 163 ReadOnlyOnFilterData.BeginTransaction(type); 164 } 165 166 public void EndTransaction() { 167 originalData.EndTransaction(); 168 } 169 170 #region IPreprocessingData Members 171 172 173 public void SetSelection(IDictionary<int, IList<int>> selection) { 174 originalData.SetSelection(selection); 175 } 176 177 public IDictionary<int, IList<int>> GetSelection() { 178 return originalData.GetSelection(); 179 } 180 181 public void ClearSelection() { 182 originalData.ClearSelection(); 183 } 184 185 public event EventHandler SelectionChanged; 186 187 #endregion 201 188 } 202 189 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/PreprocessingData.cs
r10786 r10804 43 43 protected IList<ITransformation> transformations; 44 44 45 protected IDictionary<int, IList<int>> currentSelection; 46 45 47 protected PreprocessingData(PreprocessingData original, Cloner cloner) 46 48 : base(original, cloner) { … … 55 57 56 58 transformations = new List<ITransformation>(); 59 currentSelection = new Dictionary<int, IList<int>>(); 57 60 58 61 variableNames = new List<string>(problemData.Dataset.VariableNames); … … 205 208 } 206 209 210 public void SetSelection(IDictionary<int, IList<int>> selection) { 211 currentSelection = selection; 212 if (SelectionChanged != null) { 213 SelectionChanged(this, new EventArgs()); 214 } 215 } 216 217 public IDictionary<int, IList<int>> GetSelection() { 218 return currentSelection; 219 } 220 221 public void ClearSelection() { 222 currentSelection = new Dictionary<int, IList<int>>(); 223 } 224 225 public event EventHandler SelectionChanged; 226 207 227 #endregion 208 228 }
Note: See TracChangeset
for help on using the changeset viewer.