Changeset 9377 for branches/StatisticalTesting
- Timestamp:
- 04/18/13 09:47:03 (12 years ago)
- Location:
- branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/ChartAnalysisView.cs
r9353 r9377 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Drawing;25 24 using System.Linq; 26 25 using System.Windows.Forms; … … 34 33 [View("RunCollection Chart Analysis View")] 35 34 [Content(typeof(RunCollection), false)] 36 public sealed partial class RunCollectionStatisticalTabularView : ItemView { 37 public RunCollectionStatisticalTabularView() { 35 public sealed partial class ChartAnalysisView : ItemView { 36 public new RunCollection Content { 37 get { return (RunCollection)base.Content; } 38 set { base.Content = value; } 39 } 40 41 public override bool ReadOnly { 42 get { return true; } 43 set { /*not needed because results are always readonly */} 44 } 45 46 public ChartAnalysisView() { 38 47 InitializeComponent(); 39 48 stringConvertibleMatrixView.DataGridView.RowHeaderMouseDoubleClick += new DataGridViewCellMouseEventHandler(DataGridView_RowHeaderMouseDoubleClick); 40 }41 42 void DataGridView_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) {43 if (e.RowIndex >= 0) {44 IRun run = Content.ElementAt(e.RowIndex);45 IContentView view = MainFormManager.MainForm.ShowContent(run);46 if (view != null) {47 view.ReadOnly = this.ReadOnly;48 view.Locked = this.Locked;49 }50 }51 49 } 52 50 … … 63 61 } 64 62 65 public new RunCollection Content { 66 get { return (RunCollection)base.Content; } 67 set { base.Content = value; } 68 } 69 70 public override bool ReadOnly { 71 get { return true; } 72 set { /*not needed because results are always readonly */} 73 } 74 63 #region Content Events 75 64 protected override void OnContentChanged() { 76 65 base.OnContentChanged(); … … 83 72 } 84 73 85 #region events86 74 protected override void RegisterContentEvents() { 87 75 base.RegisterContentEvents(); … … 140 128 #endregion 141 129 130 #region Events 131 void DataGridView_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { 132 if (e.RowIndex >= 0) { 133 IRun run = Content.ElementAt(stringConvertibleMatrixView.GetRowIndex(e.RowIndex)); 134 IContentView view = MainFormManager.MainForm.ShowContent(run); 135 if (view != null) { 136 view.ReadOnly = this.ReadOnly; 137 view.Locked = this.Locked; 138 } 139 } 140 } 141 142 private void dataTableComboBox_SelectedIndexChanged(object sender, EventArgs e) { 143 UpdateDataRowComboBox(); 144 } 145 146 private void dataRowComboBox_SelectedIndexChanged(object sender, EventArgs e) { 147 RebuildCombinedDataTable(); 148 } 149 150 private void addLineToChart_Click(object sender, EventArgs e) { 151 string resultName = (string)dataTableComboBox.SelectedItem; 152 string rowName = (string)dataRowComboBox.SelectedItem; 153 var runs = Content.Where(x => x.Results.ContainsKey(resultName) && x.Visible); 154 155 foreach (Run run in runs) { 156 DataTable resTable = (DataTable)run.Results[resultName]; 157 DataRow row = resTable.Rows[rowName]; 158 var values = row.Values.ToArray(); 159 double k, d; 160 LinearLeastSquaresFitting.Calculate(values, out k, out d); 161 162 DataRow newRow = new DataRow(row.Name + " Fitted Line"); 163 for (int i = 0; i < values.Count(); i++) { 164 newRow.Values.Add(k * i + d); 165 } 166 167 if (!resTable.Rows.ContainsKey(newRow.Name)) 168 resTable.Rows.Add(newRow); 169 } 170 } 171 172 private void addValuesButton_Click(object sender, EventArgs e) { 173 string resultName = (string)dataTableComboBox.SelectedItem; 174 string rowName = (string)dataRowComboBox.SelectedItem; 175 var runs = Content.Where(x => x.Results.ContainsKey(resultName) && x.Visible); 176 StringMatrix sm = (StringMatrix)stringConvertibleMatrixView.Content; 177 178 Content.UpdateOfRunsInProgress = true; 179 for (int i = 0; i < runs.Count(); i++) { 180 IRun run = runs.ElementAt(i); 181 182 for (int j = 0; j < sm.ColumnNames.Count(); j++) { 183 string newResultName = resultName + " " + rowName + " " + sm.ColumnNames.ElementAt(j); 184 if (!run.Results.ContainsKey(newResultName)) 185 run.Results.Add(new KeyValuePair<string, Core.IItem>(newResultName, new DoubleValue(double.Parse(sm[i, j])))); 186 } 187 } 188 Content.UpdateOfRunsInProgress = false; 189 //update column names of run collection 190 Content.Modify(); 191 } 192 #endregion 193 142 194 private void UpdateRun(IRun run) { 143 195 //TODO: hacky di hack... this is baaaadddd 144 RebuildCombinedDataTable();145 }146 147 private void dataTableComboBox_SelectedIndexChanged(object sender, EventArgs e) {148 UpdateDataRowComboBox();149 }150 151 private void dataRowComboBox_SelectedIndexChanged(object sender, EventArgs e) {152 196 RebuildCombinedDataTable(); 153 197 } … … 181 225 string resultName = (string)dataTableComboBox.SelectedItem; 182 226 string rowName = (string)dataRowComboBox.SelectedItem; 183 184 227 string[] columnNames = new string[] { "Count", "Minimum", "Maximum", "Average", "Median", "Standard Deviation", "Variance", "25th Percentile", "75th Percentile", "Gradient", "Relative Error", "Avg. of Upper 25 %", " Avg. of Lower 25 %", "Avg. of First 25 %", "Avg. of Last 25 %" }; 185 228 … … 193 236 foreach (Run run in runs) { 194 237 DataTable resTable = (DataTable)run.Results[resultName]; 238 dt.SortableView = true; 195 239 DataRow row = resTable.Rows[rowName]; 196 240 var values = row.Values.AsEnumerable(); … … 234 278 stringConvertibleMatrixView.Content = dt; 235 279 } 236 237 private void addLineToChart_Click(object sender, EventArgs e) {238 string resultName = (string)dataTableComboBox.SelectedItem;239 string rowName = (string)dataRowComboBox.SelectedItem;240 var runs = Content.Where(x => x.Results.ContainsKey(resultName) && x.Visible);241 242 foreach (Run run in runs) {243 DataTable resTable = (DataTable)run.Results[resultName];244 DataRow row = resTable.Rows[rowName];245 var values = row.Values.ToArray();246 double k, d;247 LinearLeastSquaresFitting.Calculate(values, out k, out d);248 249 DataRow newRow = new DataRow(row.Name + " Fitted Line");250 for (int i = 0; i < values.Count(); i++) {251 newRow.Values.Add(k * i + d);252 }253 254 if (!resTable.Rows.ContainsKey(newRow.Name))255 resTable.Rows.Add(newRow);256 }257 }258 259 private void addValuesButton_Click(object sender, EventArgs e) {260 string resultName = (string)dataTableComboBox.SelectedItem;261 string rowName = (string)dataRowComboBox.SelectedItem;262 var runs = Content.Where(x => x.Results.ContainsKey(resultName) && x.Visible);263 StringMatrix sm = (StringMatrix)stringConvertibleMatrixView.Content;264 265 Content.UpdateOfRunsInProgress = true;266 for (int i = 0; i < runs.Count(); i++) {267 IRun run = runs.ElementAt(i);268 269 for (int j = 0; j < sm.ColumnNames.Count(); j++) {270 string newResultName = resultName + " " + rowName + " " + sm.ColumnNames.ElementAt(j);271 if (!run.Results.ContainsKey(newResultName))272 run.Results.Add(new KeyValuePair<string, Core.IItem>(newResultName, new DoubleValue(double.Parse(sm[i, j]))));273 }274 }275 Content.UpdateOfRunsInProgress = false;276 //update column names of run collection277 Content.Modify();278 }279 280 private void colorButton_Click(object sender, EventArgs e) {281 string resultName = (string)dataTableComboBox.SelectedItem;282 string rowName = (string)dataRowComboBox.SelectedItem;283 var runs = Content.Where(x => x.Results.ContainsKey(resultName) && x.Visible);284 Dictionary<int, double> values = new Dictionary<int, double>();285 286 if (stringConvertibleMatrixView.DataGridView.CurrentCell != null) {287 int curIndex = stringConvertibleMatrixView.DataGridView.CurrentCell.ColumnIndex;288 289 for (int i = 0; i < stringConvertibleMatrixView.Content.Rows; i++) {290 values[i] = double.Parse(stringConvertibleMatrixView.Content.GetValue(i, curIndex));291 }292 293 var orderedValues = values.OrderBy(x => x.Value);294 295 for (int i = 0; i < orderedValues.Count(); i++) {296 var row = stringConvertibleMatrixView.DataGridView.Rows[orderedValues.ElementAt(i).Key];297 298 int r = (int)Math.Round((double)i / (double)orderedValues.Count() * 255.0);299 int g = (int)Math.Round(((double)orderedValues.Count() - (double)i) / (double)orderedValues.Count() * 255.0);300 301 Color color = Color.FromArgb(r, g, 0);302 row.DefaultCellStyle.ForeColor = color;303 }304 }305 }306 280 } 307 281 } -
branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/ChartAnalysisView.designer.cs
r9355 r9377 21 21 22 22 namespace HeuristicLab.Analysis.Statistics { 23 partial class RunCollectionStatisticalTabularView {23 partial class ChartAnalysisView { 24 24 /// <summary> 25 25 /// Required designer variable. … … 52 52 this.stringConvertibleMatrixView.Location = new System.Drawing.Point(3, 59); 53 53 this.stringConvertibleMatrixView.Name = "stringConvertibleMatrixView"; 54 this.stringConvertibleMatrixView.ReadOnly = false;54 this.stringConvertibleMatrixView.ReadOnly = true; 55 55 this.stringConvertibleMatrixView.ShowRowsAndColumnsTextBox = true; 56 56 this.stringConvertibleMatrixView.ShowStatisticalInformation = true; … … 122 122 this.addValuesButton.Click += new System.EventHandler(this.addValuesButton_Click); 123 123 // 124 // RunCollectionStatisticalTabularView124 // ChartAnalysisView 125 125 // 126 126 this.Controls.Add(this.addValuesButton); … … 131 131 this.Controls.Add(this.dataTableComboBox); 132 132 this.Controls.Add(this.stringConvertibleMatrixView); 133 this.Name = " RunCollectionStatisticalTabularView";133 this.Name = "ChartAnalysisView"; 134 134 this.Size = new System.Drawing.Size(498, 385); 135 135 this.ResumeLayout(false);
Note: See TracChangeset
for help on using the changeset viewer.