Changeset 10804
- Timestamp:
- 05/07/14 10:49:15 (11 years ago)
- Location:
- branches/DataPreprocessing
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/DataGridContentView.cs
r10785 r10804 82 82 _highlightedCellsBackground = new Dictionary<int, IList<int>>(); 83 83 currentCell = null; 84 DataGridView.SelectionChanged += DataGridView_SelectionChanged; 85 } 86 87 void DataGridView_SelectionChanged(object sender, EventArgs e) { 88 Content.DataGridLogic.SetSelection(GetSelectedCells()); 84 89 } 85 90 -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/PreprocessingChartView.cs
r10803 r10804 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Drawing;25 24 using System.Windows.Forms; 26 25 using HeuristicLab.Analysis; … … 64 63 if (VariableIsDisplayed(variableName)) { 65 64 dataTable.Rows.Remove(variableName); 66 dataTablePerVariable.Remove(dataTablePerVariable.Find( 65 dataTablePerVariable.Remove(dataTablePerVariable.Find(x => (x.Name == variableName))); 67 66 } else { 68 67 DataRow row = GetDataRow(variableName); … … 91 90 base.RegisterContentEvents(); 92 91 Content.ChartLogic.Changed += PreprocessingData_Changed; 93 92 94 93 } 95 94 … … 112 111 dataTable = new PreprocessingDataTable(chartTitle); 113 112 dataTable.Rows.AddRange(dataRows); 114 113 115 114 116 115 // init data table per variable 117 116 dataTablePerVariable = new List<PreprocessingDataTable>(); 118 foreach (var checkedItem in variableItemList.CheckedItems){117 foreach (var checkedItem in variableItemList.CheckedItems) { 119 118 string variableName = variableItemList[checkedItem.Index].Value; 120 119 PreprocessingDataTable d = new PreprocessingDataTable(variableName); … … 123 122 //rowSelect.Name = variableName + "(Selected)"; 124 123 //rowSelect.VisualProperties.Color = Color.Green; 125 124 126 125 d.Rows.Add(row); 127 126 //d.SelectedRows.Add(rowSelect); 128 127 129 128 dataTablePerVariable.Add(d); 130 129 … … 144 143 if (Content != null) { 145 144 logic = Content.ChartLogic; 146 InitData(); 145 InitData(); 147 146 variableItemList.CheckedItemsChanged += CheckedItemsChanged; 148 GenerateChart(); 147 GenerateChart(); 149 148 } 150 149 } … … 167 166 case DataPreprocessingChangedEventType.Any: 168 167 InitData(); 169 GenerateChart(); 168 GenerateChart(); 170 169 break; 171 170 } … … 217 216 protected void GenerateChart() { 218 217 219 ClearTableLayout(); 218 ClearTableLayout(); 220 219 221 220 if (allInOneMode) { … … 234 233 tableLayoutPanel.AutoScroll = false; 235 234 tableLayoutPanel.AutoScroll = true; 236 } 235 } 237 236 238 237 private void GenerateSingleChartLayout() { … … 247 246 private void GenerateMultiChartLayout() { 248 247 int checkedItemsCnt = 0; 249 foreach (var item in variableItemList.CheckedItems)248 foreach (var item in variableItemList.CheckedItems) 250 249 checkedItemsCnt++; 251 250 … … 262 261 263 262 if (columns == 3) 264 rows = (checkedItemsCnt +2) / columns;265 else if (columns == 2)263 rows = (checkedItemsCnt + 2) / columns; 264 else if (columns == 2) 266 265 rows = (checkedItemsCnt + 1) / columns; 267 266 else … … 274 273 List<PreprocessingDataTable>.Enumerator enumerator = dataTablePerVariable.GetEnumerator(); 275 274 for (int x = 0; x < columns; x++) { 276 277 if (rows <= 3)275 276 if (rows <= 3) 278 277 tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100 / columns)); 279 278 else … … 298 297 p.Dock = DockStyle.Fill; 299 298 tableLayoutPanel.Controls.Add(p, y, x); 300 } 301 else { 299 } else { 302 300 dataView.Content = d; 303 301 dataView.Dock = DockStyle.Fill; -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/PreprocessingDataTableView.cs
r10803 r10804 20 20 #endregion 21 21 22 using HeuristicLab.Collections;23 using HeuristicLab.Core.Views;24 using HeuristicLab.MainForm;25 22 using System; 26 23 using System.Collections.Generic; … … 29 26 using System.Windows.Forms; 30 27 using System.Windows.Forms.DataVisualization.Charting; 28 using HeuristicLab.Collections; 29 using HeuristicLab.Core.Views; 31 30 using HeuristicLab.DataPreprocessing.Implementations; 31 using HeuristicLab.MainForm; 32 32 33 33 namespace HeuristicLab.Analysis.Views { … … 172 172 else series.Color = Color.Empty; 173 173 series.IsVisibleInLegend = row.VisualProperties.IsVisibleInLegend; 174 174 175 175 switch (row.VisualProperties.ChartType) { 176 176 case DataRowVisualProperties.DataRowChartType.Line: … … 535 535 536 536 // get minimum ignores nan values 537 private double GetMinimum(IEnumerable<double> values) 538 { 537 private double GetMinimum(IEnumerable<double> values) { 539 538 double min = Double.MaxValue; 540 539 541 540 foreach (double value in values) { 542 541 if (!Double.IsNaN(value) && value < min) 543 min = value; 542 min = value; 544 543 } 545 544 return min; -
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 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IDataGridLogic.cs
r10622 r10804 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 … … 38 39 39 40 void DeleteRow(List<int> rows); 41 42 void SetSelection(IDictionary<int, IList<int>> selection); 43 IDictionary<int, IList<int>> GetSelection(); 44 void ClearSelection(); 45 46 event EventHandler SelectionChanged; 40 47 } 41 48 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IPreprocessingData.cs
r10772 r10804 64 64 65 65 Dataset ExportToDataset(); 66 67 void SetSelection(IDictionary<int, IList<int>> selection); 68 IDictionary<int, IList<int>> GetSelection(); 69 void ClearSelection(); 70 71 event EventHandler SelectionChanged; 66 72 } 67 73 }
Note: See TracChangeset
for help on using the changeset viewer.