Changeset 14459 for branches/DataPreprocessing Enhancements
- Timestamp:
- 12/07/16 13:50:21 (8 years ago)
- Location:
- branches/DataPreprocessing Enhancements
- Files:
-
- 3 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/HeuristicLab.DataPreprocessing.Views-3.4.csproj
r14446 r14459 239 239 </Compile> 240 240 <Compile Include="DataPreprocessorStarter.cs" /> 241 <Compile Include="PreprocessingDataTableView.cs">242 <SubType>UserControl</SubType>243 </Compile>244 <Compile Include="PreprocessingDataTableView.Designer.cs">245 <DependentUpon>PreprocessingDataTableView.cs</DependentUpon>246 </Compile>247 241 <Compile Include="FilterView.cs"> 248 242 <SubType>UserControl</SubType> … … 326 320 <Name>HeuristicLab.DataPreprocessing-3.4</Name> 327 321 </ProjectReference> 322 </ItemGroup> 323 <ItemGroup> 324 <EmbeddedResource Include="PreprocessingChartView.resx"> 325 <DependentUpon>PreprocessingChartView.cs</DependentUpon> 326 </EmbeddedResource> 328 327 </ItemGroup> 329 328 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/HistogramView.Designer.cs
r14268 r14459 46 46 private void InitializeComponent() { 47 47 this.optionsBox = new System.Windows.Forms.GroupBox(); 48 this.displayDetailsCheckBox = new System.Windows.Forms.CheckBox();49 48 this.label1 = new System.Windows.Forms.Label(); 50 49 this.classifierComboBox = new System.Windows.Forms.ComboBox(); … … 66 65 this.optionsBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 67 66 | System.Windows.Forms.AnchorStyles.Right))); 68 this.optionsBox.Controls.Add(this.displayDetailsCheckBox);69 67 this.optionsBox.Controls.Add(this.label1); 70 68 this.optionsBox.Controls.Add(this.classifierComboBox); … … 75 73 this.optionsBox.TabStop = false; 76 74 this.optionsBox.Text = "Options"; 77 //78 // displayDetailsCheckBox79 //80 this.displayDetailsCheckBox.AutoSize = true;81 this.displayDetailsCheckBox.Location = new System.Drawing.Point(5, 58);82 this.displayDetailsCheckBox.Margin = new System.Windows.Forms.Padding(2);83 this.displayDetailsCheckBox.Name = "displayDetailsCheckBox";84 this.displayDetailsCheckBox.RightToLeft = System.Windows.Forms.RightToLeft.Yes;85 this.displayDetailsCheckBox.Size = new System.Drawing.Size(119, 17);86 this.displayDetailsCheckBox.TabIndex = 3;87 this.displayDetailsCheckBox.Text = "Display value count";88 this.displayDetailsCheckBox.UseVisualStyleBackColor = true;89 this.displayDetailsCheckBox.CheckedChanged += new System.EventHandler(this.displayDetailsCheckBox_CheckedChanged);90 75 // 91 76 // label1 … … 130 115 private System.Windows.Forms.ComboBox classifierComboBox; 131 116 private System.Windows.Forms.Label label1; 132 private System.Windows.Forms.CheckBox displayDetailsCheckBox;133 117 134 118 } -
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/HistogramView.cs
r14185 r14459 21 21 22 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 23 25 using HeuristicLab.Analysis; 24 26 using HeuristicLab.MainForm; … … 29 31 [Content(typeof(HistogramContent), true)] 30 32 public partial class HistogramView : PreprocessingChartView { 31 private const string HISTOGRAM_CHART_TITLE = "Histogram"; 33 34 public List<double> Classification { get; set; } 35 public bool IsDetailedChartViewEnabled { get; set; } 32 36 33 37 public HistogramView() { 34 38 InitializeComponent(); 35 chartType = DataRowVisualProperties.DataRowChartType.Histogram;36 chartTitle = HISTOGRAM_CHART_TITLE;37 39 } 38 40 … … 53 55 } 54 56 57 protected override DataTable CreateDataTable(string variableName) { 58 var dt = new DataTable(); 59 var row = Content.CreateDataRow(variableName, DataRowVisualProperties.DataRowChartType.Histogram); 60 if (Classification == null) { 61 dt.Rows.Add(row); 62 } else { 63 dt.VisualProperties.Title = variableName; 64 //var valuesPerClass = row.Values.Zip(Classification, (value, @class) => new { value, @class }) 65 // .GroupBy(x => x.@class) 66 // .ToDictionary(x => x.Key, x => x.Select(v => v.value)); 67 var valuesPerClass = row.Values.Select((i, index) => new { i, j = Classification.ToList()[index] }) 68 .GroupBy((x) => x.j) 69 .ToDictionary(x => x.Key, x => x.Select(v => v.i) 70 .ToList()); 71 foreach (var entry in valuesPerClass) { 72 var classRow = new DataRow(entry.Key.ToString()); 73 classRow.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Histogram; 74 classRow.Values.AddRange(entry.Value); 75 dt.Rows.Add(classRow); 76 } 77 } 78 return dt; 79 } 80 55 81 public new HistogramContent Content { 56 82 get { return (HistogramContent)base.Content; } … … 64 90 if (classifierComboBox.SelectedIndex != 0) { 65 91 int columndIndex = Content.PreprocessingData.GetColumnIndex(classifierComboBox.SelectedItem.ToString()); 66 Classification = Content.PreprocessingData.GetValues<double>(columndIndex) ;92 Classification = Content.PreprocessingData.GetValues<double>(columndIndex).ToList(); 67 93 } else { 68 94 Classification = null; … … 70 96 71 97 Content.ClassifierVariableIndex = classifierComboBox.SelectedIndex; 72 if (Content.IsDetailedChartViewEnabled != IsDetailedChartViewEnabled) { 73 displayDetailsCheckBox.Checked = Content.IsDetailedChartViewEnabled; 74 } else { 75 GenerateChart(); 76 } 77 } 78 private void displayDetailsCheckBox_CheckedChanged(object sender, EventArgs e) { 79 bool isChecked = displayDetailsCheckBox.Checked; 80 if (IsDetailedChartViewEnabled != isChecked) { 81 IsDetailedChartViewEnabled = isChecked; 82 Content.IsDetailedChartViewEnabled = isChecked; 83 GenerateChart(); 84 } 98 99 // rebuild datatables 100 InitData(); 101 GenerateLayout(); 85 102 } 86 103 } -
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/LineChartView.cs
r14185 r14459 21 21 22 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 23 25 using HeuristicLab.Analysis; 26 using HeuristicLab.Analysis.Views; 27 using HeuristicLab.Collections; 28 using HeuristicLab.Data; 24 29 using HeuristicLab.MainForm; 25 30 … … 30 35 public partial class LineChartView : PreprocessingChartView { 31 36 32 private const string LINE_CHART_TITLE = "Line Chart"; 37 protected Dictionary<string, DataRow> allInOneDataRows; 38 protected DataTable allInOneDataTable; 39 protected DataTableControl allInOneDataTableControl; 33 40 34 41 public LineChartView() { 35 42 InitializeComponent(); 36 chartType = DataRowVisualProperties.DataRowChartType.Line;37 chartTitle = LINE_CHART_TITLE;43 allInOneDataRows = new Dictionary<string, DataRow>(); 44 allInOneDataTable= new DataTable(); 38 45 } 39 46 … … 43 50 } 44 51 52 protected override void InitData() { 53 base.InitData(); 54 55 allInOneDataRows.Clear(); 56 foreach (var x in Content.VariableItemList.Select((v, i) => new { variable = v.Value, i })) { 57 var row = Content.CreateDataRow(x.variable, DataRowVisualProperties.DataRowChartType.Line); 58 row.VisualProperties.Color = Colors[x.i % Colors.Length]; 59 allInOneDataRows.Add(x.variable, row); 60 } 61 62 allInOneDataTable.Rows.Clear(); 63 foreach (var variable in Content.VariableItemList.CheckedItems) { 64 allInOneDataTable.Rows.Add(allInOneDataRows[variable.Value.Value]); 65 } 66 } 67 68 protected override int GetNumberOfVisibleDataTables() { 69 return Content.AllInOneMode ? 1 : base.GetNumberOfVisibleDataTables(); 70 } 71 protected override IEnumerable<DataTableControl> GetVisibleDataTables() { 72 if (Content.AllInOneMode) { 73 if (allInOneDataTableControl == null) 74 allInOneDataTableControl = new DataTableControl() { Content = allInOneDataTable }; 75 return new[] { allInOneDataTableControl }; 76 } 77 return base.GetVisibleDataTables(); 78 } 79 protected override DataTable CreateDataTable(string variableName) { 80 var dt = new DataTable(); 81 dt.Rows.Add(Content.CreateDataRow(variableName, DataRowVisualProperties.DataRowChartType.Line)); 82 return dt; 83 } 84 45 85 private void allInOneCheckBox_CheckedChanged(object sender, EventArgs e) { 46 86 Content.AllInOneMode = allInOneCheckBox.Checked; 47 87 48 Generate Chart();88 GenerateLayout(); 49 89 } 50 90 … … 55 95 } 56 96 } 97 98 protected override void CheckedItemsChanged(object sender, CollectionItemsChangedEventArgs<IndexedItem<StringValue>> checkedItems) { 99 base.CheckedItemsChanged(sender, checkedItems); 100 101 foreach (IndexedItem<StringValue> item in checkedItems.Items) { 102 string variableName = item.Value.Value; 103 104 if (IsVariableChecked(variableName)) { 105 // ToDo: avoid clearing all rows, but how? 106 allInOneDataTable.Rows.Clear(); 107 foreach (var variable in Content.VariableItemList.CheckedItems) { 108 allInOneDataTable.Rows.Add(allInOneDataRows[variable.Value.Value]); 109 } 110 } else { 111 allInOneDataTable.Rows.Remove(variableName); 112 } 113 } 114 } 115 116 #region Add/Remove/Update Variable, Reset 117 protected override void AddVariable(string name) { 118 base.AddVariable(name); 119 var row = Content.CreateDataRow(name, DataRowVisualProperties.DataRowChartType.Line); 120 allInOneDataTable.Rows.Add(row); 121 } 122 123 // remove variable from data table and item list 124 protected override void RemoveVariable(string name) { 125 base.RemoveVariable(name); 126 allInOneDataTable.Rows.Remove(name); 127 } 128 129 protected override void UpdateVariable(string name) { 130 base.UpdateVariable(name); 131 allInOneDataTable.Rows.Remove(name); 132 var newRow = Content.CreateDataRow(name, DataRowVisualProperties.DataRowChartType.Line); 133 allInOneDataTable.Rows.Add(newRow); 134 } 135 #endregion 57 136 } 58 137 } -
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingChartView.Designer.cs
r14381 r14459 45 45 /// </summary> 46 46 private void InitializeComponent() { 47 this.dataTableView = new HeuristicLab.DataPreprocessing.Views.PreprocessingDataTableView();48 47 this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); 49 48 ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); … … 51 50 this.splitContainer.Panel2.SuspendLayout(); 52 51 this.splitContainer.SuspendLayout(); 53 this.tableLayoutPanel.SuspendLayout();54 52 this.SuspendLayout(); 55 53 // … … 61 59 this.splitContainer.Panel2.Controls.Add(this.tableLayoutPanel); 62 60 // 63 // dataTableView64 //65 this.dataTableView.AutoScroll = true;66 this.dataTableView.Caption = "DataTable View";67 this.dataTableView.Classification = null;68 this.dataTableView.Content = null;69 this.dataTableView.Dock = System.Windows.Forms.DockStyle.Fill;70 this.dataTableView.IsDetailedChartViewEnabled = false;71 this.dataTableView.Location = new System.Drawing.Point(3, 3);72 this.dataTableView.Name = "dataTableView";73 this.dataTableView.ReadOnly = false;74 this.dataTableView.ShowLegend = true;75 this.dataTableView.Size = new System.Drawing.Size(553, 397);76 this.dataTableView.TabIndex = 0;77 this.dataTableView.XAxisFormat = "";78 this.dataTableView.YAxisFormat = "";79 //80 61 // tableLayoutPanel 81 62 // 63 this.tableLayoutPanel.AutoScroll = true; 82 64 this.tableLayoutPanel.ColumnCount = 1; 83 65 this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); 84 66 this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); 85 this.tableLayoutPanel.Controls.Add(this.dataTableView, 0, 0);86 67 this.tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; 87 68 this.tableLayoutPanel.Location = new System.Drawing.Point(0, 0); … … 103 84 ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit(); 104 85 this.splitContainer.ResumeLayout(false); 105 this.tableLayoutPanel.ResumeLayout(false);106 86 this.ResumeLayout(false); 107 87 … … 110 90 #endregion 111 91 112 private DataPreprocessing.Views.PreprocessingDataTableView dataTableView; 113 private System.Windows.Forms.TableLayoutPanel tableLayoutPanel; 92 protected System.Windows.Forms.TableLayoutPanel tableLayoutPanel; 114 93 } 115 94 } -
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingChartView.cs
r14418 r14459 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 23 using System.Drawing; 24 24 using System.Linq; 25 25 using System.Windows.Forms; 26 26 using HeuristicLab.Analysis; 27 using HeuristicLab.Analysis.Views; 27 28 using HeuristicLab.Collections; 28 29 using HeuristicLab.Data; 29 30 using HeuristicLab.MainForm; 31 using HeuristicLab.MainForm.WindowsForms; 30 32 31 33 namespace HeuristicLab.DataPreprocessing.Views { … … 34 36 public partial class PreprocessingChartView : PreprocessingCheckedVariablesView { 35 37 36 protected PreprocessingDataTable dataTable; 37 protected List<PreprocessingDataTable> dataTablePerVariable; 38 protected List<DataRow> dataRows; 39 protected List<DataRow> selectedDataRows; 40 41 protected DataRowVisualProperties.DataRowChartType chartType; 42 protected string chartTitle; 43 44 private const string DEFAULT_CHART_TITLE = "Chart"; 38 protected Dictionary<string, DataTable> dataTables; 39 protected Dictionary<string, DataTableControl> dataTableControls; 40 45 41 private const int FIXED_CHART_SIZE = 300; 46 42 private const int MAX_TABLE_AUTO_SIZE_ROWS = 3; 47 43 48 49 public IEnumerable<double> Classification { get; set; } 50 public bool IsDetailedChartViewEnabled { get; set; } 44 protected static readonly Color[] Colors = { 45 Color.FromArgb(59, 136, 239), Color.FromArgb(252, 177, 59), Color.FromArgb(226, 64, 10), 46 Color.FromArgb(5, 100, 146), Color.FromArgb(191, 191, 191), Color.FromArgb(26, 59, 105), 47 Color.FromArgb(255, 226, 126), Color.FromArgb(18, 156, 221), Color.FromArgb(202, 107, 75), 48 Color.FromArgb(0, 92, 219), Color.FromArgb(243, 210, 136), Color.FromArgb(80, 99, 129), 49 Color.FromArgb(241, 185, 168), Color.FromArgb(224, 131, 10), Color.FromArgb(120, 147, 190) 50 }; 51 51 52 52 53 public PreprocessingChartView() { 53 54 InitializeComponent(); 54 chartType = DataRowVisualProperties.DataRowChartType.Line;55 chartTitle = DEFAULT_CHART_TITLE;55 dataTables = new Dictionary<string, DataTable>(); 56 dataTableControls= new Dictionary<string, DataTableControl>(); 56 57 } 57 58 … … 60 61 if (Content != null) { 61 62 InitData(); 62 GenerateChart(); 63 64 foreach (var row in dataRows) { 65 string variableName = row.Name; 66 if (!IsVariableChecked(variableName)) { 67 dataTableView.SetRowEnabled(variableName, false); 68 dataTable.SelectedRows.Remove(variableName); 69 dataTablePerVariable.Remove(dataTablePerVariable.Find(x => (x.Name == variableName))); 70 } 71 } 72 } 73 } 74 75 private void InitData() { 76 //Create data tables and data rows 77 dataRows = Content.CreateAllDataRows(chartType); 78 dataTable = new PreprocessingDataTable(chartTitle); 79 dataTablePerVariable = new List<PreprocessingDataTable>(); 80 81 //add data rows to data tables according to checked item list 82 foreach (var row in dataRows) { 83 string variableName = row.Name; 84 85 //add row to data table 86 dataTable.Rows.Add(row); 87 88 //add row to data table per variable 89 PreprocessingDataTable d = new PreprocessingDataTable(variableName); 90 d.Rows.Add(row); 91 dataTablePerVariable.Add(d); 92 } 93 94 UpdateSelection(); 63 GenerateLayout(); 64 } 65 } 66 67 protected virtual int GetNumberOfVisibleDataTables() { 68 return checkedItemList.Content.CheckedItems.Count(); 69 } 70 71 protected virtual IEnumerable<DataTableControl> GetVisibleDataTables() { 72 foreach (var name in Content.VariableItemList.CheckedItems) { 73 if (!dataTableControls.ContainsKey(name.Value.Value)) 74 dataTableControls.Add(name.Value.Value, new DataTableControl() { Content = dataTables[name.Value.Value] }); 75 yield return dataTableControls[name.Value.Value]; 76 } 77 } 78 79 protected virtual DataTable CreateDataTable(string variableName) { 80 return null; 81 } 82 83 protected virtual void InitData() { 84 dataTables.Clear(); 85 dataTableControls.Clear(); 86 foreach (var variable in Content.VariableItemList.Select(v => v.Value)) { 87 dataTables.Add(variable, CreateDataTable(variable)); 88 } 95 89 } 96 90 … … 101 95 string variableName = item.Value.Value; 102 96 103 104 97 if (!IsVariableChecked(variableName)) { 105 98 // not checked -> remove 106 dataTableView.SetRowEnabled(variableName, false); 107 dataTable.SelectedRows.Remove(variableName); 108 dataTablePerVariable.Remove(dataTablePerVariable.Find(x => (x.Name == variableName))); 99 //dataTableView.SetRowEnabled(variableName, false); 100 //dataTablePerVariable.Remove(dataTablePerVariable.Find(x => (x.Name == variableName))); 109 101 } else { 110 102 // checked -> add 111 DataRow row = GetDataRow(variableName);112 DataRow selectedRow = GetSelectedDataRow(variableName);113 dataTableView.SetRowEnabled(variableName, true); 114 115 PreprocessingDataTable pdt = new PreprocessingDataTable(variableName);116 pdt.Rows.Add(row);103 //DataRow row = GetDataRow(variableName); 104 //dataTableView.SetRowEnabled(variableName, true); 105 106 //var pdt = new DataTable(variableName); 107 //pdt.VisualProperties.Title = string.Empty; 108 //pdt.Rows.Add(row); 117 109 // dataTablePerVariable does not contain unchecked variables => reduce insert position by number of uncheckt variables to correct the index 118 int uncheckedUntilVariable = checkedItemList.Content.TakeWhile(x => x.Value != variableName).Count(x => !checkedItemList.Content.ItemChecked(x)); 119 dataTablePerVariable.Insert(item.Index - uncheckedUntilVariable, pdt); 120 121 //update selection 122 if (selectedRow != null) { 123 dataTable.SelectedRows.Add(selectedRow); 124 pdt.SelectedRows.Add(selectedRow); 125 } 110 //int uncheckedUntilVariable = checkedItemList.Content.TakeWhile(x => x.Value != variableName).Count(x => !checkedItemList.Content.ItemChecked(x)); 111 //dataTables.Insert(item.Index - uncheckedUntilVariable, pdt); 126 112 } 127 113 } 128 114 129 115 // update chart if not in all in one mode 130 if (Content != null && !Content.AllInOneMode) 131 GenerateChart(); 132 } 133 134 private DataRow GetSelectedDataRow(string variableName) { 135 foreach (DataRow row in selectedDataRows) { 136 if (row.Name == variableName) 137 return row; 138 } 139 return null; 140 } 141 private DataRow GetDataRow(string variableName) { 142 foreach (DataRow row in dataRows) { 143 if (row.Name == variableName) 144 return row; 145 } 146 return null; 147 } 116 //if (Content != null && !Content.AllInOneMode) 117 //GenerateChart();?? 118 GenerateLayout(); 119 } 120 148 121 149 122 #region Add/Remove/Update Variable, Reset 150 123 protected override void AddVariable(string name) { 151 124 base.AddVariable(name); 152 DataRow row = Content.CreateDataRow(name, chartType); 153 dataTable.Rows.Add(row); 154 PreprocessingDataTable d = new PreprocessingDataTable(name); 155 d.Rows.Add(row); 156 dataTablePerVariable.Add(d); 157 158 if (!Content.AllInOneMode) 159 GenerateChart(); 125 dataTables.Add(name, CreateDataTable(name)); 126 127 GenerateLayout(); 160 128 } 161 129 … … 163 131 protected override void RemoveVariable(string name) { 164 132 base.RemoveVariable(name); 165 dataTable.Rows.Remove(name); 166 dataTablePerVariable.Remove(dataTablePerVariable.Find(x => (x.Name == name))); 167 168 if (!Content.AllInOneMode) 169 GenerateChart(); 133 dataTables.Remove(name); 134 dataTableControls.Remove(name); 135 136 GenerateLayout(); 170 137 } 171 138 172 139 protected override void UpdateVariable(string name) { 173 140 base.UpdateVariable(name); 174 DataRow newRow = Content.CreateDataRow(name, chartType); 175 dataTable.Rows.Remove(name); 176 dataTable.Rows.Add(newRow); 177 DataTable dt = dataTablePerVariable.Find(x => x.Rows.Find(y => y.Name == name) != null); 178 if (dt != null) { 179 dt.Rows.Remove(name); 180 dt.Rows.Add(newRow); 181 } 141 dataTables.Remove(name); 142 var newDataTable = CreateDataTable(name); 143 dataTables.Add(name, newDataTable); 144 dataTableControls[name].Content = newDataTable; 145 GenerateLayout(); 182 146 } 183 147 protected override void ResetAllVariables() { … … 186 150 #endregion 187 151 188 #region Generate Charts 189 protected void GenerateChart() { 152 #region Generate Layout 153 protected void GenerateLayout() { 154 tableLayoutPanel.SuspendRepaint(); 155 190 156 ClearTableLayout(); 191 if (Content.AllInOneMode) { 192 GenerateSingleChartLayout(); 193 } else 194 GenerateMultiChartLayout(); 195 } 196 197 private void GenerateSingleChartLayout() { 198 tableLayoutPanel.ColumnCount = 1; 199 tableLayoutPanel.RowCount = 1; 200 tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); 201 tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100)); 202 tableLayoutPanel.Controls.Add(dataTableView, 0, 0); 203 dataTableView.Content = dataTable; 204 } 205 206 private void GenerateMultiChartLayout() { 207 int checkedItemsCnt = 0; 208 foreach (var item in Content.VariableItemList.CheckedItems) 209 checkedItemsCnt++; 210 211 // set columns and rows based on number of items 212 int columns = GetNrOfMultiChartColumns(checkedItemsCnt); 213 int rows = GetNrOfMultiChartRows(checkedItemsCnt, columns); 157 158 int nrCharts = GetNumberOfVisibleDataTables(); 159 160 // Set columns and rows based on number of items 161 int columns = GetNrOfMultiChartColumns(nrCharts); 162 int rows = GetNrOfMultiChartRows(nrCharts, columns); 214 163 215 164 tableLayoutPanel.ColumnCount = columns; 216 165 tableLayoutPanel.RowCount = rows; 217 166 218 List<PreprocessingDataTable>.Enumerator enumerator = dataTablePerVariable.GetEnumerator(); 219 for (int x = 0; x < columns; x++) { 220 221 if (rows <= MAX_TABLE_AUTO_SIZE_ROWS) 222 tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100 / columns)); 223 else 224 //scrollbar is shown if there are more than 3 rows -> remove scroll bar width from total width 225 tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, (tableLayoutPanel.Width - System.Windows.Forms.SystemInformation.VerticalScrollBarWidth) / columns)); 226 for (int y = 0; y < rows; y++) { 227 //Add a row only when creating the first column 228 if (x == 0) { 229 // fixed chart size when there are more than 3 tables 230 if (rows > MAX_TABLE_AUTO_SIZE_ROWS) 231 tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, FIXED_CHART_SIZE)); 232 else 233 tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100 / rows)); 167 using (var enumerator = GetVisibleDataTables().GetEnumerator()) { 168 for (int x = 0; x < columns; x++) { 169 var columnStyle = rows <= MAX_TABLE_AUTO_SIZE_ROWS 170 ? new ColumnStyle(SizeType.Percent, 100 / columns) 171 : new ColumnStyle(SizeType.Absolute, (tableLayoutPanel.Width - SystemInformation.VerticalScrollBarWidth) / columns); 172 tableLayoutPanel.ColumnStyles.Add(columnStyle); 173 174 for (int y = 0; y < rows; y++) { 175 // Add a row only when creating the first column 176 if (x == 0) { 177 var rowStyle = rows > MAX_TABLE_AUTO_SIZE_ROWS 178 ? new RowStyle(SizeType.Absolute, FIXED_CHART_SIZE) 179 : new RowStyle(SizeType.Percent, 100 / rows); 180 tableLayoutPanel.RowStyles.Add(rowStyle); 181 } 182 183 if (enumerator.MoveNext()) 184 AddDataTableToTableLayout(enumerator.Current, x, y); 234 185 } 235 236 enumerator.MoveNext();237 PreprocessingDataTable d = enumerator.Current;238 AddDataTableToTableLayout(d, x, y);239 240 186 } 241 187 } 242 } 188 189 tableLayoutPanel.ResumeRepaint(true); 190 } 191 243 192 private int GetNrOfMultiChartColumns(int itemCount) { 244 193 int columns = 0; … … 262 211 } 263 212 264 private void AddDataTableToTableLayout(PreprocessingDataTable dataTable, int x, int y) { 265 PreprocessingDataTableView dataView = new PreprocessingDataTableView(); 266 dataView.Classification = Classification; 267 dataView.IsDetailedChartViewEnabled = IsDetailedChartViewEnabled; 213 private void AddDataTableToTableLayout(DataTableControl dataTable, int x, int y) { 214 //dataView.Classification = Classification; 215 //dataView.IsDetailedChartViewEnabled = IsDetailedChartViewEnabled; 268 216 269 217 if (dataTable == null) { 270 218 // dummy panel for empty field 271 Panel p = new Panel(); 272 p.Dock = DockStyle.Fill; 219 Panel p = new Panel { Dock = DockStyle.Fill }; 273 220 tableLayoutPanel.Controls.Add(p, y, x); 274 221 } else { 275 dataView.Content = dataTable; 276 dataView.Dock = DockStyle.Fill; 277 tableLayoutPanel.Controls.Add(dataView, y, x); 222 dataTable.Dock = DockStyle.Fill; 223 tableLayoutPanel.Controls.Add(dataTable, y, x); 278 224 } 279 225 } … … 286 232 tableLayoutPanel.ColumnStyles.Clear(); 287 233 tableLayoutPanel.RowStyles.Clear(); 234 235 tableLayoutPanel.Width = 0; 236 tableLayoutPanel.Height = 0; 237 288 238 tableLayoutPanel.AutoScroll = false; 289 239 tableLayoutPanel.AutoScroll = true; … … 301 251 } 302 252 #endregion 303 304 #region Update Selection305 protected override void PreprocessingData_SelctionChanged(object sender, EventArgs e) {306 base.PreprocessingData_SelctionChanged(sender, e);307 UpdateSelection();308 }309 310 private void UpdateSelection() {311 //update data table selection312 selectedDataRows = Content.CreateAllSelectedDataRows(chartType);313 dataTable.SelectedRows.Clear();314 foreach (var selectedRow in selectedDataRows) {315 if (IsVariableChecked(selectedRow.Name))316 dataTable.SelectedRows.Add(selectedRow);317 }318 319 //update data table per variable selection320 foreach (PreprocessingDataTable d in dataTablePerVariable) {321 d.SelectedRows.Clear();322 DataRow row = selectedDataRows.Find(x => x.Name == d.Name);323 if (row != null)324 d.SelectedRows.Add(row);325 }326 }327 #endregion328 253 } 329 254 } -
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingCheckedVariablesView.cs
r14425 r14459 33 33 [View("Preprocessing Checked Variables View")] 34 34 [Content(typeof(PreprocessingChartContent), false)] 35 public abstractpartial class PreprocessingCheckedVariablesView : ItemView {35 public partial class PreprocessingCheckedVariablesView : ItemView { 36 36 37 37 public new PreprocessingChartContent Content { -
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/ScatterPlotMultiView.cs
r14446 r14459 253 253 if (!bodyCache.ContainsKey(key)) { 254 254 if (rowVariable == colVariable) { // use historgram if x and y variable are equal 255 PreprocessingDataTable dataTable = new PreprocessingDataTable();255 var dataTable = new DataTable(); 256 256 DataRow dataRow = Content.CreateDataRow(rowVariable, DataRowVisualProperties.DataRowChartType.Histogram); 257 dataRow.VisualProperties.IsVisibleInLegend = false; 257 258 dataTable.Rows.Add(dataRow); 258 PreprocessingDataTableView pcv = new PreprocessingDataTableView{259 var pcv = new DataTableControl { 259 260 Name = key.ToString(), 260 261 Content = dataTable, 261 262 Dock = DockStyle.Fill, 262 ShowLegend = false,263 XAxisFormat = "G3"263 //ShowLegend = false, 264 //XAxisFormat = "G3" 264 265 }; 265 pcv.ChartDoubleClick += HistogramDoubleClick;266 //pcv.ChartDoubleClick += HistogramDoubleClick; 266 267 bodyCache.Add(key, pcv); 267 268 } else { //scatter plot … … 361 362 //open histogram in new tab with new content when double clicked 362 363 private void HistogramDoubleClick(object sender, EventArgs e) { 363 PreprocessingDataTableView pcv = (PreprocessingDataTableView)sender;364 DataTableControl pcv = (DataTableControl)sender; 364 365 HistogramContent histoContent = new HistogramContent(Content.PreprocessingData); // create new content 365 366 histoContent.VariableItemList = Content.CreateVariableItemList(); 366 PreprocessingDataTabledataTable = pcv.Content;367 var dataTable = pcv.Content; 367 368 368 369 //Set variable item list from with variable from data table -
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/HistogramContent.cs
r14185 r14459 35 35 private const int MAX_DISTINCT_VALUES_FOR_CLASSIFCATION = 20; 36 36 37 p rivate int classifierVariableIndex = 0;37 public int ClassifierVariableIndex { get; set; } 38 38 39 public int ClassifierVariableIndex { 40 get { return this.classifierVariableIndex; } 41 set { this.classifierVariableIndex = value; } 42 } 43 public bool IsDetailedChartViewEnabled { get; set; } 44 39 public int Bins { get; set; } 40 public bool ExactBins { get; set; } 45 41 46 42 public HistogramContent(IFilteredPreprocessingData preprocessingData) 47 43 : base(preprocessingData) { 48 AllInOneMode = false; 44 Bins = 10; 45 ExactBins = false; 49 46 } 50 47 … … 70 67 return doubleVariableNames; 71 68 } 72 73 69 } 74 70 } -
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/LineChartContent.cs
r14185 r14459 29 29 public class LineChartContent : PreprocessingChartContent { 30 30 31 private bool allInOneMode = true; 32 public bool AllInOneMode { 33 get { return this.allInOneMode; } 34 set { this.allInOneMode = value; } 35 } 36 31 37 public static new Image StaticItemImage { 32 38 get { return HeuristicLab.Common.Resources.VSImageLibrary.Performance; } … … 39 45 public LineChartContent(LineChartContent content, Cloner cloner) 40 46 : base(content, cloner) { 47 this.allInOneMode = content.allInOneMode; 41 48 } 42 49 public override IDeepCloneable Clone(Cloner cloner) { -
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/PreprocessingChartContent.cs
r14418 r14459 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 23 using System.Drawing; … … 33 32 public static new Image StaticItemImage { 34 33 get { return HeuristicLab.Common.Resources.VSImageLibrary.PieChart; } 35 }36 37 private bool allInOneMode = true;38 public bool AllInOneMode {39 get { return this.allInOneMode; }40 set { this.allInOneMode = value; }41 34 } 42 35 … … 55 48 public PreprocessingChartContent(PreprocessingChartContent content, Cloner cloner) 56 49 : base(content, cloner) { 57 this.allInOneMode = content.allInOneMode;58 50 this.PreprocessingData = content.PreprocessingData; 59 51 this.variableItemList = cloner.Clone<ICheckedItemList<StringValue>>(variableItemList); … … 62 54 return new PreprocessingChartContent(this, cloner); 63 55 } 64 65 56 66 57 public DataRow CreateDataRow(string variableName, DataRowVisualProperties.DataRowChartType chartType) { … … 71 62 } 72 63 73 public List<DataRow> CreateAllDataRows(DataRowVisualProperties.DataRowChartType chartType) {74 List<DataRow> dataRows = new List<DataRow>();75 foreach (var name in PreprocessingData.GetDoubleVariableNames())76 dataRows.Add(CreateDataRow(name, chartType));77 return dataRows;78 }79 64 80 public DataRow CreateSelectedDataRow(string variableName, DataRowVisualProperties.DataRowChartType chartType) {81 82 IDictionary<int, IList<int>> selection = PreprocessingData.Selection;83 int variableIndex = PreprocessingData.GetColumnIndex(variableName);84 85 if (selection.Keys.Contains(variableIndex)) {86 List<int> selectedIndices = new List<int>(selection[variableIndex]);87 //need selection with more than 1 value88 if (selectedIndices.Count < 2)89 return null;90 91 selectedIndices.Sort();92 int start = selectedIndices[0];93 int end = selectedIndices[selectedIndices.Count - 1];94 95 DataRow rowSelect = CreateDataRowRange(variableName, start, end, chartType);96 return rowSelect;97 } else98 return null;99 }100 101 public DataRow CreateDataRowRange(string variableName, int start, int end, DataRowVisualProperties.DataRowChartType chartType) {102 IList<double> values = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableName));103 IList<double> valuesRange = new List<double>();104 for (int i = 0; i < values.Count; i++) {105 if (i >= start && i <= end)106 valuesRange.Add(values[i]);107 else108 valuesRange.Add(Double.NaN);109 }110 111 DataRow row = new DataRow(variableName, "", valuesRange);112 row.VisualProperties.ChartType = chartType;113 return row;114 }115 116 public List<DataRow> CreateAllSelectedDataRows(DataRowVisualProperties.DataRowChartType chartType) {117 List<DataRow> dataRows = new List<DataRow>();118 foreach (var name in PreprocessingData.GetDoubleVariableNames()) {119 DataRow row = CreateSelectedDataRow(name, chartType);120 if (row != null)121 dataRows.Add(row);122 }123 return dataRows;124 }125 65 126 66 -
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/HeuristicLab.DataPreprocessing-3.4.csproj
r14445 r14459 126 126 <Compile Include="Content\PreprocessingChartContent.cs" /> 127 127 <Compile Include="Data\PreprocessingData.cs" /> 128 <Compile Include="Content\PreprocessingDataTable.cs" />129 128 <Compile Include="Content\IViewChartShortcut.cs" /> 130 129 <Compile Include="Data\IFilteredPreprocessingData.cs" />
Note: See TracChangeset
for help on using the changeset viewer.