Changeset 14545
- Timestamp:
- 01/05/17 15:12:27 (8 years ago)
- Location:
- branches/DataPreprocessing Enhancements
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/DataPreprocessingView.cs
r14467 r14545 57 57 var viewShortcuts = new ItemList<IViewShortcut> { 58 58 new DataGridContent(data, manipulationLogic, filterLogic), 59 new StatisticsContent( statisticsLogic),59 new StatisticsContent(data, statisticsLogic), 60 60 61 61 new LineChartContent(data), -
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/StatisticsView.Designer.cs
r14185 r14545 55 55 this.lblNominalColumns = new System.Windows.Forms.Label(); 56 56 this.txtMissingValuesTotal = new System.Windows.Forms.Label(); 57 this.dataGridView = new System.Windows.Forms.DataGridView(); 58 ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); 57 this.stringMatrixView = new HeuristicLab.Data.Views.StringConvertibleMatrixView(); 59 58 this.SuspendLayout(); 60 59 // … … 149 148 this.txtMissingValuesTotal.Text = "102"; 150 149 // 151 // dataGridView 152 // 153 this.dataGridView.AllowUserToAddRows = false; 154 this.dataGridView.AllowUserToDeleteRows = false; 155 this.dataGridView.AllowUserToOrderColumns = true; 156 this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 157 | System.Windows.Forms.AnchorStyles.Left) 150 // stringMatrixView 151 // 152 this.stringMatrixView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 153 | System.Windows.Forms.AnchorStyles.Left) 158 154 | System.Windows.Forms.AnchorStyles.Right))); 159 this. dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;160 this. dataGridView.Location = new System.Drawing.Point(5, 117);161 this. dataGridView.Name = "dataGridView";162 this. dataGridView.ReadOnly = true;163 this. dataGridView.RowHeadersWidth = 80;164 this. dataGridView.Size = new System.Drawing.Size(530, 278);165 this. dataGridView.TabIndex = 4;166 this. dataGridView.VirtualMode = true;167 this. dataGridView.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.dataGridView_CellValueNeeded);155 this.stringMatrixView.Caption = "StringConvertibleMatrix View"; 156 this.stringMatrixView.Content = null; 157 this.stringMatrixView.Location = new System.Drawing.Point(5, 117); 158 this.stringMatrixView.Name = "stringMatrixView"; 159 this.stringMatrixView.ReadOnly = true; 160 this.stringMatrixView.ShowRowsAndColumnsTextBox = false; 161 this.stringMatrixView.ShowStatisticalInformation = true; 162 this.stringMatrixView.Size = new System.Drawing.Size(530, 278); 163 this.stringMatrixView.TabIndex = 4; 168 164 // 169 165 // StatisticsView … … 171 167 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 172 168 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 173 this.Controls.Add(this. dataGridView);169 this.Controls.Add(this.stringMatrixView); 174 170 this.Controls.Add(this.lblNominalColumns); 175 171 this.Controls.Add(this.lblNumericColumns); … … 184 180 this.Name = "StatisticsView"; 185 181 this.Size = new System.Drawing.Size(549, 408); 186 ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();187 182 this.ResumeLayout(false); 188 183 this.PerformLayout(); … … 202 197 private System.Windows.Forms.Label lblNominalColumns; 203 198 private System.Windows.Forms.Label txtMissingValuesTotal; 204 private System.Windows.Forms.DataGridView dataGridView;199 private HeuristicLab.Data.Views.StringConvertibleMatrixView stringMatrixView; 205 200 } 206 201 } -
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/StatisticsView.cs
r14185 r14545 24 24 using System.Windows.Forms; 25 25 using HeuristicLab.Core.Views; 26 using HeuristicLab.Data; 26 27 using HeuristicLab.MainForm; 27 28 … … 32 33 public partial class StatisticsView : ItemView { 33 34 34 private List<List<string>> columnsRowsMatrix; 35 private readonly int COLUMNS = 12; 35 private StringMatrix statisticsMatrix; 36 37 private static readonly string[] RowNames = new[] { 38 "Type", 39 "Missing Values", 40 "Min", 41 "Max", 42 "Median", 43 "Average", 44 "std. Deviation", 45 "Variance", 46 "25th Percentile", 47 "75th Percentile", 48 "Most Common Value", 49 "Num. diff. Values" 50 }; 36 51 37 52 public new StatisticsContent Content { … … 52 67 txtNominalColumns.Text = ""; 53 68 txtMissingValuesTotal.Text = ""; 54 dataGridView.Columns.Clear(); 69 stringMatrixView.Content = null; 70 statisticsMatrix = null; 55 71 } else { 56 72 UpdateData(); … … 58 74 } 59 75 60 /// <summary>61 /// Adds eventhandlers to the current instance.62 /// </summary>63 76 protected override void RegisterContentEvents() { 77 base.RegisterContentEvents(); 64 78 Content.Changed += Content_Changed; 65 79 } 66 80 67 68 /// <summary>69 /// Removes the eventhandlers from the current instance.70 /// </summary>71 81 protected override void DeregisterContentEvents() { 72 82 Content.Changed -= Content_Changed; 83 base.DeregisterContentEvents(); 73 84 } 74 85 … … 76 87 var logic = Content.StatisticsLogic; 77 88 var rowCount = logic.GetRowCount(); 78 txtRows.Text = rowCount.ToString();79 txtColumns.Text = logic.GetColumnCount().ToString();89 txtRows.Text = logic.GetColumnCount().ToString(); 90 txtColumns.Text = rowCount.ToString(); 80 91 txtNumericColumns.Text = logic.GetNumericColumnCount().ToString(); 81 92 txtNominalColumns.Text = logic.GetNominalColumnCount().ToString(); 82 93 txtMissingValuesTotal.Text = logic.GetMissingValueCount().ToString(); 83 94 84 columnsRowsMatrix = new List<List<string>>(); 85 DataGridViewColumn[] columns = new DataGridViewColumn[COLUMNS]; 86 for (int i = 0; i < COLUMNS; ++i) { 87 var column = new DataGridViewTextBoxColumn(); 88 column.SortMode = DataGridViewColumnSortMode.Automatic; 89 column.FillWeight = 1; 90 columns[i] = column; 91 } 92 93 columns[0].HeaderCell.Value = "Type"; 94 columns[1].HeaderCell.Value = "Missing Values"; 95 columns[2].HeaderCell.Value = "Min"; 96 columns[3].HeaderCell.Value = "Max"; 97 columns[4].HeaderCell.Value = "Median"; 98 columns[5].HeaderCell.Value = "Average"; 99 columns[6].HeaderCell.Value = "std. Deviation"; 100 columns[7].HeaderCell.Value = "Variance"; 101 columns[8].HeaderCell.Value = "25th Percentile"; 102 columns[9].HeaderCell.Value = "75th Percentile"; 103 columns[10].HeaderCell.Value = "Most Common Value"; 104 columns[11].HeaderCell.Value = "Num. diff. Values"; 95 statisticsMatrix = new StringMatrix(RowNames.Length, Content.PreprocessingData.Columns) { 96 RowNames = StatisticsView.RowNames, 97 ColumnNames = Content.PreprocessingData.VariableNames 98 }; 105 99 106 100 if (rowCount > 0) { 107 101 for (int i = 0; i < logic.GetColumnCount(); ++i) { 108 columnsRowsMatrix.Add(GetList(i)); 102 var data = GetList(i); 103 for (int j = 0; j < data.Count; j++) { 104 statisticsMatrix[j, i] = data[j]; 105 } 109 106 } 110 107 } 111 112 dataGridView.Columns.Clear(); 113 dataGridView.Columns.AddRange(columns); 114 dataGridView.RowCount = columnsRowsMatrix.Count; 115 116 for (int i = 0; i < columnsRowsMatrix.Count; ++i) { 117 dataGridView.Rows[i].HeaderCell.Value = logic.GetVariableName(i); 118 } 119 120 dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); 121 dataGridView.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders); 122 dataGridView.AllowUserToResizeColumns = true; 108 stringMatrixView.Content = statisticsMatrix; 109 110 foreach (DataGridViewColumn column in stringMatrixView.DataGridView.Columns) { 111 var variable = column.HeaderText; 112 bool isInputTarget = Content.PreprocessingData.InputVariables.Contains(variable) 113 || Content.PreprocessingData.TargetVariable == variable; 114 column.Visible = isInputTarget; 115 } 116 stringMatrixView.DataGridView.AutoResizeColumns(); 117 118 //foreach (DataGridViewRow row in stringMatrixView.DataGridView.Rows) { 119 // var variable = (string)row.HeaderCell.Value; 120 // bool isInputTarget = Content.PreprocessingData.InputVariables.Contains(variable) 121 // || Content.PreprocessingData.TargetVariable == variable; 122 // row.Visible = isInputTarget; 123 //} 123 124 } 124 125 … … 134 135 } else { 135 136 list = new List<string>(); 136 for (int j = 0; j < COLUMNS; ++j) {137 for (int j = 0; j < RowNames.Length; ++j) { 137 138 list.Add("unknown column type"); 138 139 } … … 195 196 } 196 197 197 private void dataGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) {198 if (Content != null && e.RowIndex < columnsRowsMatrix.Count && e.ColumnIndex < columnsRowsMatrix[0].Count) {199 e.Value = columnsRowsMatrix[e.RowIndex][e.ColumnIndex];200 }201 }202 203 198 private void Content_Changed(object sender, DataPreprocessingChangedEventArgs e) { 204 switch (e.Type) {205 case DataPreprocessingChangedEventType.DeleteColumn:206 columnsRowsMatrix.RemoveAt(e.Column);207 break;208 case DataPreprocessingChangedEventType.AddColumn:209 columnsRowsMatrix.Insert(e.Row, GetList(e.Column));210 dataGridView.RowCount++;211 break;212 case DataPreprocessingChangedEventType.ChangeItem:213 columnsRowsMatrix[e.Column] = GetList(e.Column);214 break;215 case DataPreprocessingChangedEventType.DeleteRow:216 case DataPreprocessingChangedEventType.AddRow:217 default:218 for (int i = 0; i < columnsRowsMatrix.Count; ++i) {219 columnsRowsMatrix[i] = GetList(e.Column);220 }221 break;222 }223 dataGridView.Refresh();199 UpdateData(); 200 //switch (e.Type) { 201 // case DataPreprocessingChangedEventType.DeleteColumn: 202 // statisticsMatrix.RemoveAt(e.Column); 203 // break; 204 // case DataPreprocessingChangedEventType.AddColumn: 205 // statisticsMatrix.Insert(e.Row, GetList(e.Column)); 206 // stringMatrixView.Content.Rows++; 207 // break; 208 // case DataPreprocessingChangedEventType.ChangeItem: 209 // statisticsMatrix[e.Column] = GetList(e.Column); 210 // break; 211 // case DataPreprocessingChangedEventType.DeleteRow: 212 // case DataPreprocessingChangedEventType.AddRow: 213 // default: 214 // for (int i = 0; i < statisticsMatrix.Count; ++i) { 215 // statisticsMatrix[i] = GetList(e.Column); 216 // } 217 // break; 218 //} 224 219 } 225 220 } -
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/StatisticsContent.cs
r14185 r14545 27 27 [Item("Statistics", "Represents the statistics grid.")] 28 28 public class StatisticsContent : Item, IViewShortcut { 29 public ITransactionalPreprocessingData PreprocessingData { get; private set; } 29 30 30 31 private readonly StatisticsLogic statisticsLogic; 31 public StatisticsContent(StatisticsLogic theStatisticsLogic) { 32 public StatisticsContent(ITransactionalPreprocessingData preProcessingData, StatisticsLogic theStatisticsLogic) { 33 PreprocessingData = preProcessingData; 32 34 statisticsLogic = theStatisticsLogic; 33 35 }
Note: See TracChangeset
for help on using the changeset viewer.