- Timestamp:
- 04/02/14 16:01:01 (11 years ago)
- Location:
- branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/HeuristicLab.DataPreprocessing.Views-3.3.csproj
r10709 r10717 43 43 <HintPath>..\..\bin\HeuristicLab.Collections-3.3.dll</HintPath> 44 44 </Reference> 45 <Reference Include="HeuristicLab.Problems.ExternalEvaluation-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 46 <SpecificVersion>False</SpecificVersion> 47 <HintPath>..\..\bin\HeuristicLab.Problems.ExternalEvaluation-3.3.dll</HintPath> 48 </Reference> 45 49 <Reference Include="HeuristicLab.Problems.Instances-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 46 50 <SpecificVersion>False</SpecificVersion> … … 229 233 <Project>{DF87C13E-A889-46FF-8153-66DCAA8C5674}</Project> 230 234 <Name>HeuristicLab.Problems.DataAnalysis-3.4</Name> 235 </ProjectReference> 236 <ProjectReference Include="..\..\HeuristicLab.Problems.ExternalEvaluation.Views\3.3\HeuristicLab.Problems.ExternalEvaluation.Views-3.3.csproj"> 237 <Project>{3081630C-9521-47D7-8075-1777C12F212C}</Project> 238 <Name>HeuristicLab.Problems.ExternalEvaluation.Views-3.3</Name> 231 239 </ProjectReference> 232 240 <ProjectReference Include="..\..\HeuristicLab.Visualization.ChartControlsExtensions\3.3\HeuristicLab.Visualization.ChartControlsExtensions-3.3.csproj"> -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/LineChartView.Designer.cs
r10658 r10717 24 24 /// </summary> 25 25 private void InitializeComponent() { 26 components = new System.ComponentModel.Container(); 26 this.groupBox1 = new System.Windows.Forms.GroupBox(); 27 this.checkBox1 = new System.Windows.Forms.CheckBox(); 28 this.groupBox1.SuspendLayout(); 29 this.SuspendLayout(); 30 // 31 // groupBox1 32 // 33 this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 34 this.groupBox1.Controls.Add(this.checkBox1); 35 this.groupBox1.Location = new System.Drawing.Point(4, 262); 36 this.groupBox1.Name = "groupBox1"; 37 this.groupBox1.Size = new System.Drawing.Size(151, 134); 38 this.groupBox1.TabIndex = 7; 39 this.groupBox1.TabStop = false; 40 this.groupBox1.Text = "Options"; 41 // 42 // checkBox1 43 // 44 this.checkBox1.AutoSize = true; 45 this.checkBox1.Location = new System.Drawing.Point(7, 20); 46 this.checkBox1.Name = "checkBox1"; 47 this.checkBox1.Size = new System.Drawing.Size(66, 17); 48 this.checkBox1.TabIndex = 0; 49 this.checkBox1.Text = "AllInOne"; 50 this.checkBox1.UseVisualStyleBackColor = true; 51 this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged); 52 // 53 // LineChartView 54 // 55 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 27 56 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 57 this.Controls.Add(this.groupBox1); 58 this.Name = "LineChartView"; 59 this.Controls.SetChildIndex(this.groupBox1, 0); 60 this.groupBox1.ResumeLayout(false); 61 this.groupBox1.PerformLayout(); 62 this.ResumeLayout(false); 63 28 64 } 29 65 30 66 #endregion 67 68 private System.Windows.Forms.GroupBox groupBox1; 69 private System.Windows.Forms.CheckBox checkBox1; 31 70 } 32 71 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/LineChartView.cs
r10712 r10717 20 20 #endregion 21 21 22 using System; 22 23 using System.Windows.Forms; 23 24 using HeuristicLab.Analysis; … … 42 43 set { base.Content = value; } 43 44 } 45 46 private void checkBox1_CheckedChanged(object sender, EventArgs e) { 47 if (allInOneMode == false) 48 allInOneMode = true; 49 else 50 allInOneMode = false; 51 GenerateChart(); 52 } 44 53 } 45 54 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/PreprocessingChartView.Designer.cs
r10658 r10717 46 46 /// </summary> 47 47 private void InitializeComponent() { 48 this.dataTableView = new HeuristicLab.Analysis.Views.DataTableView(); 49 this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); 48 50 this.checkedItemList = new HeuristicLab.DataPreprocessing.Views.PreprocessingCheckedItemListView(); 49 this.chartPanel = new System.Windows.Forms.Panel(); 50 this.dataTableView = new HeuristicLab.Analysis.Views.DataTableView(); 51 this.chartPanel.SuspendLayout(); 51 this.tableLayoutPanel.SuspendLayout(); 52 52 this.SuspendLayout(); 53 // 54 // dataTableView 55 // 56 this.dataTableView.Caption = "DataTable View"; 57 this.dataTableView.Content = null; 58 this.dataTableView.Dock = System.Windows.Forms.DockStyle.Fill; 59 this.dataTableView.Location = new System.Drawing.Point(3, 3); 60 this.dataTableView.Name = "dataTableView"; 61 this.dataTableView.ReadOnly = false; 62 this.dataTableView.Size = new System.Drawing.Size(486, 390); 63 this.dataTableView.TabIndex = 0; 64 // 65 // tableLayoutPanel 66 // 67 this.tableLayoutPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 68 | System.Windows.Forms.AnchorStyles.Left) 69 | System.Windows.Forms.AnchorStyles.Right))); 70 this.tableLayoutPanel.AutoScroll = true; 71 this.tableLayoutPanel.ColumnCount = 1; 72 this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); 73 this.tableLayoutPanel.Controls.Add(this.dataTableView, 0, 0); 74 this.tableLayoutPanel.Location = new System.Drawing.Point(162, 4); 75 this.tableLayoutPanel.Name = "tableLayoutPanel"; 76 this.tableLayoutPanel.RowCount = 1; 77 this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle()); 78 this.tableLayoutPanel.Size = new System.Drawing.Size(492, 396); 79 this.tableLayoutPanel.TabIndex = 6; 80 this.tableLayoutPanel.Layout += new System.Windows.Forms.LayoutEventHandler(this.tableLayoutPanel_Layout); 53 81 // 54 82 // checkedItemList … … 64 92 this.checkedItemList.TabIndex = 4; 65 93 // 66 // chartPanel 67 // 68 this.chartPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 69 | System.Windows.Forms.AnchorStyles.Left) 70 | System.Windows.Forms.AnchorStyles.Right))); 71 this.chartPanel.Controls.Add(this.dataTableView); 72 this.chartPanel.Location = new System.Drawing.Point(163, 4); 73 this.chartPanel.Name = "chartPanel"; 74 this.chartPanel.Size = new System.Drawing.Size(488, 396); 75 this.chartPanel.TabIndex = 5; 76 // 77 // dataTableView 78 // 79 this.dataTableView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 80 | System.Windows.Forms.AnchorStyles.Left) 81 | System.Windows.Forms.AnchorStyles.Right))); 82 this.dataTableView.Caption = "DataTable View"; 83 this.dataTableView.Content = null; 84 this.dataTableView.Location = new System.Drawing.Point(3, 3); 85 this.dataTableView.Name = "dataTableView"; 86 this.dataTableView.ReadOnly = false; 87 this.dataTableView.Size = new System.Drawing.Size(482, 390); 88 this.dataTableView.TabIndex = 0; 89 // 90 // LineChartView 94 // PreprocessingChartView 91 95 // 92 96 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 93 97 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 94 this.Controls.Add(this. chartPanel);98 this.Controls.Add(this.tableLayoutPanel); 95 99 this.Controls.Add(this.checkedItemList); 96 this.Name = " LineChartView";100 this.Name = "PreprocessingChartView"; 97 101 this.Size = new System.Drawing.Size(654, 403); 98 this. chartPanel.ResumeLayout(false);102 this.tableLayoutPanel.ResumeLayout(false); 99 103 this.ResumeLayout(false); 100 104 … … 104 108 105 109 private PreprocessingCheckedItemListView checkedItemList; 106 private System.Windows.Forms.Panel chartPanel;107 110 private Analysis.Views.DataTableView dataTableView; 111 private System.Windows.Forms.TableLayoutPanel tableLayoutPanel; 108 112 } 109 113 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/PreprocessingChartView.cs
r10712 r10717 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Drawing; 22 25 using System.Windows.Forms; 23 26 using HeuristicLab.Analysis; 27 using HeuristicLab.Analysis.Views; 24 28 using HeuristicLab.Collections; 25 29 using HeuristicLab.Core; … … 36 40 private IChartLogic logic; 37 41 private DataTable dataTable; 42 private List<DataTable> dataTablePerVariable; 38 43 private ICheckedItemList<StringValue> variableItemList; 44 private List<DataRow> dataRows; 45 39 46 protected DataRowVisualProperties.DataRowChartType chartType; 40 47 protected string chartTitle; 48 protected bool allInOneMode = true; 41 49 42 50 private const string DEFAULT_CHART_TITLE = "Chart"; … … 54 62 if (VariableIsDisplayed(variableName)) { 55 63 dataTable.Rows.Remove(variableName); 64 dataTablePerVariable.Remove(dataTablePerVariable.Find( x => (x.Name == variableName))); 56 65 } else { 57 dataTable.Rows.Add(logic.CreateDataRow(variableName, chartType)); 66 DataRow row = GetDataRow(variableName); 67 //row.VisualProperties.Color = GetRandomColor(); 68 dataTable.Rows.Add(row); 69 DataTable d = new DataTable(variableName); 70 d.Rows.Add(row); 71 dataTablePerVariable.Add(d); 58 72 } 59 73 } 60 } 61 62 public bool VariableIsDisplayed(string name) { 74 75 if (!allInOneMode) 76 GenerateChart(); 77 78 } 79 80 private Color GetRandomColor() { 81 Random randomGen = new Random(); 82 KnownColor[] names = (KnownColor[])Enum.GetValues(typeof(KnownColor)); 83 KnownColor randomColorName = names[randomGen.Next(names.Length)]; 84 Color randomColor = Color.FromKnownColor(randomColorName); 85 return randomColor; 86 } 87 88 private bool VariableIsDisplayed(string name) { 63 89 64 90 foreach (var item in dataTable.Rows) { … … 69 95 } 70 96 71 private void InitDataTable() {72 dataTable = logic.CreateDataTable(chartTitle, chartType);73 dataTableView.Content = dataTable;74 }75 76 private void InitVariablesListBox() {77 variableItemList = logic.CreateVariableItemList();78 checkedItemList.Content = variableItemList;79 }80 81 97 protected override void RegisterContentEvents() { 82 98 base.RegisterContentEvents(); … … 96 112 get { return (PreprocessingChartContent)base.Content; } 97 113 set { base.Content = value; } 114 } 115 116 private void InitData() { 117 variableItemList = logic.CreateVariableItemList(); 118 dataRows = logic.CreateAllDataRows(chartType); 119 120 // init data table 121 dataTable = new DataTable(chartTitle); 122 dataTable.Rows.AddRange(dataRows); 123 124 // init data table per variable 125 dataTablePerVariable = new List<DataTable>(); 126 foreach(var checkedItem in variableItemList.CheckedItems) { 127 string variableName = variableItemList[checkedItem.Index].Value; 128 DataTable d = new DataTable(variableName); 129 DataRow row = GetDataRow(variableName); 130 //row.VisualProperties.Color = GetRandomColor(); 131 d.Rows.Add(row); 132 dataTablePerVariable.Add(d); 133 } 134 135 } 136 137 private DataRow GetDataRow(string variableName) { 138 foreach (DataRow row in dataRows) { 139 if (row.Name == variableName) 140 return row; 141 } 142 return null; 98 143 } 99 144 … … 102 147 if (Content != null) { 103 148 logic = Content.ChartLogic; 104 InitDataTable(); 105 InitVariablesListBox(); 149 InitData(); 150 checkedItemList.Content = variableItemList; 151 GenerateChart(); 106 152 variableItemList.CheckedItemsChanged += CheckedItemsChanged; 107 153 logic.Changed += PreprocessingData_Changed; … … 109 155 } 110 156 111 // TODO: refactor: possible code duplication with HistogramLogic157 // TODO : handle also other changed events 112 158 void PreprocessingData_Changed(object sender, DataPreprocessingChangedEventArgs e) { 113 159 switch (e.Type) { 114 160 case DataPreprocessingChangedEventType.DeleteColumn: 115 RemoveVariable(logic.GetVariableNameByIndex(e.Column));161 //RemoveVariable(logic.GetVariableNameByIndex(e.Column)); 116 162 break; 117 163 case DataPreprocessingChangedEventType.AddColumn: 118 AddVariable(logic.GetVariableNameByIndex(e.Column));164 //AddVariable(logic.GetVariableNameByIndex(e.Column)); 119 165 break; 120 166 case DataPreprocessingChangedEventType.ChangeColumn: 121 167 case DataPreprocessingChangedEventType.ChangeItem: 122 dataTable.Rows.Remove(logic.GetVariableNameByIndex(e.Column));123 dataTable.Rows.Add(logic.CreateDataRow(logic.GetVariableNameByIndex(e.Column), chartType)); 168 //UpdateDataForVariable(logic.GetVariableNameByIndex(e.Column)); 169 124 170 break; 125 171 case DataPreprocessingChangedEventType.DeleteRow: 126 172 case DataPreprocessingChangedEventType.AddRow: 127 InitDataTable();128 173 break; 129 174 } 175 } 176 177 private void UpdateDataForVariable(string variableName) { 178 DataRow newRow = logic.CreateDataRow(variableName, chartType); 179 dataTable.Rows.Remove(variableName); 180 dataTable.Rows.Add(newRow); 181 DataTable dt = dataTablePerVariable.Find(x => (x.Rows.ItemName == variableName)); 182 dt.Rows.Remove(variableName); 183 dt.Rows.Add(newRow); 130 184 } 131 185 … … 154 208 } 155 209 210 protected void GenerateChart() { 211 212 //Clear out the existing controls 213 tableLayoutPanel.Controls.Clear(); 214 215 //Clear out the existing row and column styles 216 tableLayoutPanel.ColumnStyles.Clear(); 217 tableLayoutPanel.RowStyles.Clear(); 218 tableLayoutPanel.AutoScroll = false; 219 tableLayoutPanel.AutoScroll = true; 220 221 if (allInOneMode) { 222 GenerateSingleChartLayout(); 223 } else 224 GenerateMultiChartLayout(); 225 } 226 227 private void GenerateSingleChartLayout() { 228 tableLayoutPanel.ColumnCount = 1; 229 tableLayoutPanel.RowCount = 1; 230 tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); 231 tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100)); 232 tableLayoutPanel.Controls.Add(dataTableView, 0, 0); 233 dataTableView.Content = dataTable; 234 } 235 236 private void GenerateMultiChartLayout() { 237 int checkedItemsCnt = 0; 238 foreach(var item in variableItemList.CheckedItems) 239 checkedItemsCnt++; 240 241 int rows = 0; 242 int columns = 0; 243 244 // set columns and rows based on number of items 245 if (checkedItemsCnt <= 2) 246 columns = 1; 247 else if (checkedItemsCnt <= 6) 248 columns = 2; 249 else 250 columns = 3; 251 252 if (columns == 3) 253 rows = (checkedItemsCnt+2) / columns; 254 else if(columns == 2) 255 rows = (checkedItemsCnt + 1) / columns; 256 else 257 rows = checkedItemsCnt / columns; 258 259 //Now we will generate the table, setting up the row and column counts first 260 tableLayoutPanel.ColumnCount = columns; 261 tableLayoutPanel.RowCount = rows; 262 263 List<DataTable>.Enumerator enumerator = dataTablePerVariable.GetEnumerator(); 264 for (int x = 0; x < columns; x++) { 265 266 if(rows <= 3) 267 tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100 / columns)); 268 else 269 //scrollbar is shown if there are more than 3 rows -> remove scroll bar width from total width 270 tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, (tableLayoutPanel.Width - System.Windows.Forms.SystemInformation.VerticalScrollBarWidth) / columns)); 271 for (int y = 0; y < rows; y++) { 272 //Add a row only when creating the first column 273 if (x == 0) { 274 // fixed chart size when there are more than 3 tables 275 if (rows > 3) 276 tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 300)); 277 else 278 tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100 / rows)); 279 } 280 281 DataTableView dataView = new DataTableView(); 282 enumerator.MoveNext(); 283 DataTable d = enumerator.Current; 284 if (d == null) { 285 // dummy panel for empty field 286 Panel p = new Panel(); 287 p.Dock = DockStyle.Fill; 288 tableLayoutPanel.Controls.Add(p, y, x); 289 } 290 else { 291 dataView.Content = d; 292 dataView.Dock = DockStyle.Fill; 293 tableLayoutPanel.Controls.Add(dataView, y, x); 294 } 295 } 296 } 297 } 298 299 //Remove horizontal scroll bar if visible 300 private void tableLayoutPanel_Layout(object sender, LayoutEventArgs e) { 301 if (tableLayoutPanel.HorizontalScroll.Visible) { 302 // Add padding on the right in order to accomodate the vertical scrollbar 303 int vWidth = SystemInformation.VerticalScrollBarWidth; 304 tableLayoutPanel.Padding = new Padding(0, 0, vWidth, 0); 305 } else { 306 // Reset padding 307 tableLayoutPanel.Padding = new Padding(0); 308 } 309 } 310 311 private void radioButton1_CheckedChanged(object sender, EventArgs e) { 312 if (allInOneMode == false) 313 allInOneMode = true; 314 else 315 allInOneMode = false; 316 GenerateChart(); 317 } 318 319 320 156 321 } 157 322 }
Note: See TracChangeset
for help on using the changeset viewer.